thanks :)
Online C++ Compiler & Debugging Tool
Spoj gives WA for the solution using the formula for Delannoy number. Any suggestions/corner cases?