I wrote another solution as this(2nd). Surprisingly, this passed with 100 pts. The only difference was on line 60 and 67, where I just changed: (1<<i) → i on line 60 and, res[i].second → (1<<res[i].second) on line 67.
I would be thankful if anyone could provide a reason for this, so to avoid such silly mistakes in further submissions.
Try with 1ll<<i, it will be AC. This happened becuse 1<<i leads to overflow for i=32 (most probably, seee the limit for int). If you convert it into long then it will be in limit