WA in June cook off question "Longest non regular parentheses sub-sequence"

I dont know why my solution is giving WA, I read the editorial, saw other people solution but unable to find a flaw in my solution. Obviously I am missing somewhere. Please help!
Question Link

My solution link

There is a problem with the input, the admins are busy investigating the problem. See here for more info: