Please check this code

https://ide.codingblocks.com/#/s/14222
https://hack.codingblocks.com/contests/c/452/975

3
1 1
2 4
5 5
chck this case. you are getting 0 but answer should be 4