To be qualified as RA, you don't need stay more than five years. You only need to live more than 183days. If you live more than 183days, you should use 1040 rather than use 1040NR.