Number of subsets can grow very large after a level and with the given constraints there will be overflow. Is there a way around it or the test cases are so that it won’t overflow(i.e, it will fit in long long datatype)???

Part of an ONGOING CONTEST! You should not ask such questions!

If it won’t fit, then you would be asked to print (%1000000007) right ?

main answer is small but intermediate steps grow in size in this problem. So no need of modulo here

in this question during calculation we require to calculate c^k 2<=c<=100 and 1<=k<=50. which will clearly overflow

Sorry I misunderstood and you can look at this link : http://discuss.codechef.com/questions/46800/lepaint-doubt#46801