Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    H = N // 3
    min_num = -float('inf')
    #dpの初期化
    dp = [[min_num for j in range(H+1)] for i in range(N+1)]
    dp[0][0] = 1
    res = 0
    
    mod=10 ** 9 + 7
    
    for i in range(1, H+1):
        for j in range(3*i, N+1):
            for k in range(3, j+1):
                if dp[j][i] == min_num:
                    if dp[j-k][i-1] != min_num:
                        dp[j][i] = dp[j-k][i-1] % mod
                else:
                    if dp[j-k][i-1] != min_num:
                        dp[j][i] += (dp[j-k][i-1] % mod)

    for num in dp[N]:
        if num != min_num:
            res += (num % mod)
    print(res % mod)

if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    #dpの初期化
    dp = [0]*(N+1)
    dp[0] = 1
    
    mod=10 ** 9 + 7
    
    for i in range(3, N+1):
        dp[i] = (dp[i-1]+dp[i-3]) % mod
        
    print(dp[N])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    H = N // 3
    min_num = -float('inf')
    #dpの初期化
    dp = [[min_num for j in range(H+1)] for i in range(N+1)]
    dp[0][0] = 1
    res = 0
    
    mod=10 ** 9 + 7
    
    for i in range(1, H+1):
        for j in range(3, N+1):
            for k in range(3, j+1):
                if dp[j][i] == min_num:
                    dp[j][i] = dp[j-k][i-1]
                else:
                    if dp[j-k][i-1] != min_num:
                        dp[j][i] += dp[j-k][i-1]

    for num in dp[N]:
        if num != min_num:
            res += (num % mod)
    print(res % mod)

if __name__ == "__main__":
    main()

Fixed submission:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    #dpの初期化
    dp = [0]*(N+1)
    dp[0] = 1
    
    mod=10 ** 9 + 7
    
    for i in range(3, N+1):
        dp[i] = (dp[i-1]+dp[i-3]) % mod
        
    print(dp[N])

if __name__ == "__main__":
    main()