Have you tried the special case of empty lines as input?
[/quote]
yes I have tried the empty string case and had the correct answer ("Yes")
no, no problem thereAnd doesn't s.substring(i+2) give an exception when applied at the end of the string s?

but I finnally got AC, i think the problem was that the number that I was passing to ReadLn() was too small, (in the accepted version, I used 50 for the number n (wow, they really use BIG numbers):
int n = Integer.parseInt(ReadLn(50).trim())
really stupid thing, don't you think?
anyway, thanks a lot for your time, i really apreciated your help