Compiler is g++ 4.2.
Yikes. That compiler is ancient. I’ve met competitive programmers younger than that compiler. If you’re planning to do any serious C++ programming, you really should look into upgrading your toolchain, if possible.
#define BIG unsigned long long int
This is absolutely the wrong way to create a new type.
First, there is a trend in C++ ...
Currently all of your code exists in one global pile, with no functions, submodules or classes. Introduce some of those.
I see that your password is shown as blank for the database. A few things:
I really hope that the password is not actually blank, and that you've instead omitted it for the purposes of review. Please don't use a blank password.
step does two things: (1) step to the next state, and (2) check that the state is valid. Its name suggests only the first meaning. The repetition of wrapValidInJust suggests that they can be separated.
Instead of == you can use pattern-matching.
isgood :: String -> Bool
isgood = isValidFinal . foldM (check . step) (0, 0)
step (x, y) 'R' = (...
Curious, this code looks a lot like the code in this question. I'm not saying that you have another account, but you don't happen to be in the same class or something?
Your formatting seems to be inconsistent, use an automatic code formatter (your IDE most likely has one).
private static final Scanner SC = new Scanner(System.in);
Don't shorten names just ...