Friends pairing problem

why it is giving wrong output.

hello @rohit2299
a)
u are accessing index n of dp array , for that ur dp size should be atleast n+1.
so change ur dp size.
b) use long long datatype in place of int