import sys
sys.setrecursionlimit(100005)

memo = [-1]*100005

def climb(n):
    if n == 0:
        return 1
    elif n == 1:
        return 1
    elif n == 2:
        return 2
    elif memo[n] == -1:
        memo[n] = ((climb(n-1)) + (climb(n-2)) + (climb(n-3)))%1000
        return (memo[n] % 1000)
    else:
        return memo[n]

n=int(input())
print(climb(n))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: