Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03050 (python)

Fixed submission:
# km + k = N
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


N = int(input())
i = 1
ans = 0
for i in make_divisors(N)[:-1]:
    m = ((N - i) // i)
    if N // m != N % m:
        break
    ans += m
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [input() for _ in range(N)]
ans = 0
ac = 0
bc = 0
abc = 0
for st in s:
    ans += st.count('AB')
    if st[-1] == 'A' and st[0] == 'B':
        abc += 1
    else:
        if st[-1] == 'A':
            ac += 1
        elif st[0] == 'B':
            bc += 1
absoluteNum = abs(ac - bc)
basicCon = min(ac, bc)
ans += basicCon + min(abc, absoluteNum)

if (absoluteNum < abc):
    ans += abc - 1
print(ans)
Problem p03061 (python)

Fixed submission:
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [0] * N
R = [0] * N
for i in range(N - 1):
    L[i + 1] = gcd(L[i], A[i])
for i in range(N - 1, 0, -1):
    R[i - 1] = gcd(R[i], A[i])
ans = 0
for i in range(N):
    ans = max(gcd(L[i], R[i]), ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))
L = [0] * N
R = [0] * N
for i in range(N - 1):
    L[i + 1] = math.gcd(L[i], A[i])
for i in range(N - 1, 0, -1):
    R[i - 1] = math.gcd(R[i], A[i])
ans = 0
for i in range(N):
    ans = max(math.gcd(L[i], R[i]), ans)
print(ans)
Problem p03067 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a < c < b or b < c < a:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
k = int(input())
d = s[k - 1]
for i in range(n):
    if s[i] != d:
        s[i] = '*'
print(''.join(s))
Problem p03079 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A == B == C:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
t = [None] * q
d = [None] * q
for i in range(q):
    t[i], d[i] = input().split()
l, r = 0, n + 1
while r - l > 1:
    m = (l + r) // 2
    c = m - 1
    for i in range(q):
        if s[c] == t[i]:
            if d[i] == 'L':
                c -= 1
            else:
                c += 1
        if c < 0:
            l = m
            break
    else:
        r = m
a = l
l, r = 0, n + 1
while r - l > 1:
    m = (l + r) // 2
    c = m - 1
    for i in range(q):
        if s[c] == t[i]:
            if d[i] == 'L':
                c -= 1
            else:
                c += 1
        if c >= n:
            r = m
            break
    else:
        l = m
b = n - l
print(max(0, n - a - b))
Problem p03087 (python)

Fixed submission:
from itertools import accumulate
n, q = map(int, input().split())
s = input()
L = [0]*n
for i in range(1, n):
    if(s[i-1:i+1] == 'AC'):
        L[i] = 1
c = list(accumulate(L))
for i in range(q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n, q, l, r, count;
    string s;
    cin >> n >> q;
    cin >> s;
    int L[10100];
    for(int i = 0; i < n - 1; i++) {
        if(s[i] == 'A' && s[i + 1] == 'C') {
            L[i] = 1;
        } else {
            L[i] = 0;
        }
    }
    for(int i = 0; i < q; i++) {
        count = 0;
        cin >> l >> r;
        for(int j = l - 1; j < r - 1; j++) {
            if(L[j] == 1) {
                count++;
            }
        }
        cout << count << endl;
    }
}
Problem p03089 (python)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
ans = []
while(b != []):
    for i in range(len(b), 0, -1):
        if i not in b:
            continue
        if b[i - 1] == i:
            ans.append(i)
            del b[i - 1]
            break
    else:
        print(-1)
        exit()
for i in ans[::-1]:
    print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2:
    print(((n - 1) * (n - 2) + (n - 1)) // 2)
else:
    print(n * (n - 2) // 2)
for i in range(n):
    for j in range(i + 1, n):
        if i + j != n - 2:
            print(i + 1, j + 1)
if n % 2:
    exit(1)
Problem p03130 (python)

Fixed submission:
import numpy as np
ans = 'YES'
a = np.array([])
for i in range(3):
    b, c = input().split()
    a = np.append(a, [b, c])
a = a.astype(np.int32)
for i in range(4):
    count = np.sum(a == i + 1)
    if count > 2:
        ans = 'NO'
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b = [], []
for i in range(3):
  a[i], b[i] = np.array(input()split())
Problem p03136 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
ans = 'Yes'
lmax = max(L)
L.remove(max(L))
if lmax >= sum(L):
    ans = 'No'
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))
ans = 'Yes' 
if max(L) >= sum(L.pop(L.index.max(L))):
    ans = 'No'
print(ans)
Problem p03194 (python)

Fixed submission:
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
if int(P ** (1 / N)) < 2:
    print(1)
    exit()
for n in range(int(P ** (1 / N))+1, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break

Buggy submission (verdict: Runtime Error):
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
if int(P ** (1 / N)) < 2:
    print(1)
print(int(P ** (1 / N)) + 10)
for n in range(int(P ** (1 / N))+1, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break
Problem p03219 (python)

Fixed submission:
x,y=map(int,input().split())
print(int(x+y/2))

Buggy submission (verdict: Runtime Error):
x,y=map(int,input())
print(x+y/2)
Problem p03239 (python)

Fixed submission:
n,T=map(int,input().split())
a = []
for i in range(n):
  A,t=map(int,input().split())
  if t > T:
    pass
  else:
    a.append(A)
if a != []:
    print(min(a))
else:
  print('TLE')

Buggy submission (verdict: Runtime Error):
n,T=map(int,input().split())
a = []
for i in range(n):
  A,t=map(int,input().split())
  if t > T:
    pass
  else:
    a.append(A)
print(min(a))
Problem p03248 (python)

Fixed submission:
s = input()
n = len(s)
if s[0] == '0':
    print(-1)
    exit(0)
if s[-1] == '1':
    print(-1)
    exit(0)
for i in range((n - 1) // 2):
    if s[i] != s[n - i - 2]:
        print(-1)
        exit(0)
p = 1
t = 2
i = n - 2
while i >= 0:
    print(p, t)
    if s[i] == '1':
        p = t
    t += 1
    i -= 1

Buggy submission (verdict: Runtime Error):
input()
print(input().split().index('1')+1)
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
if K < 110 and S[:K] == '1'*K:
    print(1)
else:
    print(S.replace('1', '')[0])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[:K] == '1'*K:
    print(1)
else:
    print(S.replace('1', '')[0])
Problem p03284 (python)

Fixed submission:
print(0 if eval(input().replace(' ','%'))==0 else 1)

Buggy submission (verdict: Runtime Error):
print('YNeos'[int(input()) in[1,2,3,5,6,9,10,13,17]::2])
Problem p03293 (python)

Fixed submission:
S, T = input(), input()
for i in range(len(S)):
    if T[i:] + T[:i] == S:
        print('Yes')
        break
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
for i in range(n):
  if s == t[i:] + t[:i]:
    print('Yes')
    exit(0)
print('No')
Problem p03393 (python)

Fixed submission:
def f(s):
    return len(s) != len(set(s)) or s[-1] >= 123


st = input()
if st == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit(0)
s = list(map(ord, st))
s += [97]
while f(s):
    if s[-1] == 123:
        s.pop()
    s[-1] += 1
print(''.join(map(chr, s)))

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 3:
    print(2, 5, 63)
elif n == 4:
    print(2, 3, 4, 9)
else:
    l = [2, 3, 4, 9]
    a = 8
    b = 10
    while b <= 30000 and len(l) + 1 < n:
        l.append(a)
        l.append(b)
        a += 6
        b += 6
    c = 15
    d = 21
    while d <= 30000 and len(l) + 1 < n:
        l.append(c)
        l.append(d)
        c += 12
        d += 12
    t = 6
    while t <= 30000 and len(l) < n:
        l.append(t)
        t += 6
    print(' '.join(map(str, l)))
Problem p03425 (python)

Fixed submission:
one = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
n=int(input())
for i in range(n):
  c=input()[0]
  one[c] = one.get(c,0)+1
m,a,r,c,h=one['M'],one['A'],one['R'],one['C'],one['H']
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)

Buggy submission (verdict: Runtime Error):
one = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
n=int(input())
for i in range(n):
  one[input()[0]] += 1
m,a,r,c,h=one['M'],one['A'],one['R'],one['C'],one['H']
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)
Problem p03450 (python)

Fixed submission:
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    g[l - 1].append((r - 1, d))
    g[r - 1].append((l - 1, -d))
l = [None] * n
for i in range(n):
    if l[i] != None:
        continue
    l[i] = 0
    stack = [i]
    while stack:
        d = stack.pop()
        for node, cost in g[d]:
            if l[node] == None:
                l[node] = l[d] + cost
                stack.append(node)
            else:
                if l[node] != l[d] + cost:
                    print('No')
                    exit(0)
print('Yes')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
g = {i: [] for i in range(n)}
for i in range(m):
    l, r, d = map(int, input().split())
    g[l - 1].append((r - 1, d))
    g[r - 1].append((l - 1, -d))
l = [-1] * n
l[0] = n
stack = [r]
s = set()
while stack:
    d = stack.pop()
    if d in s:
        continue
    for node, cost in g[d]:
        if l[node] == -1:
            l[node] = l[d] + cost
        else:
            if l[node] != l[d] + cost:
                print('No')
                exit()
        stack.append(node)
    s.add(d)
print('Yes')
Problem p03501 (python)

Fixed submission:
n,a,b=map(int,input().split());print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
n,a,b=map(input().split());print(min(n*a,b))
Problem p03505 (python)

Fixed submission:
k, a, b = map(int, input().split())
k = max(0, k - a)
if k > 0 and a <= b:
  print(-1)
elif a == b:
  print(1)
else:
  print((k // (a - b) + int(k % (a - b) != 0)) * 2 + 1)

Buggy submission (verdict: Runtime Error):
k, a, b = map(int, input().split())
k = max(0, k - a)
if k > 0 and a <= b:
  print(-1)
else:
  print((k // (a - b) + int(k % (a - b) != 0)) * 2 + 1)
Problem p03555 (python)

Fixed submission:
print('YNEOS'[input()!=input()[::-1]::2])

Buggy submission (verdict: Runtime Error):
import bisect
ans = 0
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
for i in range(n):
    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(ans)
Problem p03623 (python)

Fixed submission:
x,a,b=map(int,input().split())
if abs(x-a)>abs(x-b):
  print('B')
else:
  print('A')

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input.split())
if x-a>x-b:
  print('B')
else:
  print('A')

Buggy submission (verdict: Runtime Error):
input()
a = list(map(int, input().split()))
a.sort(reverse=True)
i, c = 0, 0
m = list()
while i < len(a)-1:
    if a[i] == a[i+1]:
        m.append(a[i])
        i += 1
        c += 1
    i += 1
    if c == 2:
        break
if c == 2:
    print(m[0]*m[1])
else:
    print(0)
Problem p03625 (python)

Fixed submission:
input()
a = list(map(int, input().split()))
a.sort(reverse=True)
i, c = 0, 0
m = list()
while i < len(a)-1:
    if a[i] == a[i+1]:
        m.append(a[i])
        i += 1
        c += 1
    i += 1
    if c == 2:
        break
if c == 2:
    print(m[0]*m[1])
else:
    print(0)

Buggy submission (verdict: Runtime Error):
input()
a = list(map(int, input().split()))
a.sort(reverse=True)
i, c = 0, 0
m = list()
while i < n-1:
    if a[i] == a[i+1]:
        m.append(a[i])
        i += 1
        c += 1
    i += 1
    if c == 2:
        break
if c == 2:
    print(m[0]*m[1])
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a = []
tmp = 0
input()
a = list(map(int, input().split()))
a.sort(reverse=True)
for i in range(len(a)):
    if a[i] == a[i+3] and tmp == 0:
        print(a[i]**2)
        exit()
    elif a[i] == a[i+1]:
        if tmp == 0:
            W = a[i]
            tmp = 1
            del a[i+1]
        else:
            H = a[i]
            break
print(W*H)
Problem p03685 (python)

Fixed submission:
r, c, n = map(int, input().split())
l = []
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if (x1 == 0 or x1 == r or y1 == 0 or y1 == c) and (x2 == 0 or x2 == r or y2 == 0 or y2 == c):
        if x1 == 0:
            l.append((y1, i))
        elif y1 == c:
            l.append((c + x1, i))
        elif x1 == r:
            l.append((c * 2 + r - y1, i))
        else:
            l.append((r * 2 + c * 2 - x1, i))
        if x2 == 0:
            l.append((y2, i))
        elif y2 == c:
            l.append((c + x2, i))
        elif x2 == r:
            l.append((c * 2 + r - y2, i))
        else:
            l.append((r * 2 + c * 2 - x2, i))
l.sort()
s = []
d = [False] * n
for x, i in l:
    if d[i]:
        if s[-1] != i:
            print('NO')
            exit(0)
        s.pop()
    else:
        s.append(i)
        d[i] = True
print('YES')

Buggy submission (verdict: Runtime Error):
r, c, n = map(int, input().split())
l = []
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if (x1 == 0 or x1 == r or y1 == 0 or y1 == c) and (x2 == 0 or x2 == r or y2 == 0 or y2 == c):
        if x1 == 0:
            l.append((y1, i))
        elif y1 == c:
            l.append((c + x1, i))
        elif x1 == r:
            l.append((c * 2 + r - y1, i))
        else:
            l.append((r * 2 + c * 2 - x1, i))
        if x2 == 0:
            l.append((y2, i))
        elif y2 == c:
            l.append((c + x2, i))
        elif x2 == r:
            l.append((c * 2 + r - y2, i))
        else:
            l.append((r * 2 + c * 2 - x2, i))
l.sort()
s = [l[0][1]]
for x, i in l[1:]:
    s.append(0)
    s.append(i)
r = [0] * len(s)
i, j = 0, 0
while i < len(s):
    while i - j >= 0 and i + j < len(s) and s[i - j] == s[i + j]:
        j += 1
    r[i] = j
    k = 1
    while i - k >= 0 and k + r[i - k] < j:
        r[i + k] = r[i - k]
        k += 1
    i += k
    j -= k
for i in range(1, len(s), 2):
    p = r[i]
    if i == p - 1:
        m = (len(s) - p * 2) // 2
        if m == -1 or (m > 0 and r[-m] == m):
            print('YES')
            exit(1)
print('NO')
Problem p03696 (python)

Fixed submission:
n = int(input())
s = input()
x = 0
y = 0
for i in range(n):
    if s[i] == '(':
        x += 1
    elif s[i] == ')':
        x -= 1
    if x < 0:
        y += 1
        x += 1
print('(' * y + s + ')' * x)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
x = 0
xm = float('inf')
for i in range(n):
    if s[i] == '(':
        x += 1
    elif s[i] == ')':
        x -= 1
        xm = min(xm, x)
print('(' * -xm + s + ')' * (x - xm))
Problem p03697 (python)

Fixed submission:
a, b = map(int,input().split())
if a + b < 10:
  print(a + b)
else:
  print('error')

Buggy submission (verdict: Runtime Error):
a, b = int(input())
if a + b < 10:
  print(a + b)
else:
  print('error')
Problem p03751 (python)

Fixed submission:
n=int(input())
s = [input()for _ in range(n)]
t = input()
s += [t]
a = s.copy()
z = s.copy()
for i in range(n):
  a[i] = a[i].replace('?', 'a')
  z[i] = z[i].replace('?', 'z')
a.sort(reverse=True)
z.sort()
idx1 = z.index(t)
idx2 = n - a.index(t)
print(' '.join(map(str,range(idx1 + 1, idx2 + 2))))

Buggy submission (verdict: Runtime Error):
n=int(input())
s = [input()for _ in range(n)]
t = input()
s += t
a = s.copy()
z = s.copy()
for i in range(n):
  a[i] = a[i].replace('?', 'a')
  z[i] = z[i].replace('?', 'z')
a.sort()
z.sort()
idx1 = z.index(t)
idx2 = a.index(t)
print(' '.join(map(str,range(idx1 + 1, idx2 + 2))))
Problem p03795 (python)

Fixed submission:
x=int(input());print(800*x-x//15*200)

Buggy submission (verdict: Runtime Error):
n=int(input());print(800*x-x//15*200)
Problem p03808 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
if (2 * s) % (n * (n + 1)) != 0:
    print('NO')
else:
    t = (2 * s) // (n * (n + 1))
    for i in range(n - 1):
        k = a[i - 1] - a[i] + t
        if k % n or k < 0:
            print('NO')
            break
    else:
        print('YES')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
t = n * (n + 1) // 2
s = sum(a)
if s % t:
    print('NO')
else:
    c = s // t
    b = [0] * n
    for i in range(n):
        b[i] = a[i] - a[i - 1] - c
    for i in range(n):
        if b[i] % n or k < 0:
            print('NO')
            break
    else:
        print('YES')
Problem p03814 (python)

Fixed submission:
s=input()
a=s.find('A')
z=s[::-1].find('Z')
print(len(s)-z-a)

Buggy submission (verdict: Runtime Error):
s=input()
for i in len(s):
  if s[i] == 'A':
    a=i
    break
for i in len(s):
  if s[i] == 'Z':
    z=i
print(z-a+1)
Problem p03891 (python)

Fixed submission:
a,b,c=[int(input()) for _ in range(3)]
s=3*c
print(a,b,s-a-b)
print(2*s-2*a-b-2*c,c,2*a+b+c-s)
print(a+b+2*c-s,s-b-c,s-a-c)

Buggy submission (verdict: Runtime Error):
a,b,c=[input() for _ in range(3)]
s=3*c
print(a,b,s-a-b)
print(2*s-2*a-b-2*c,c,2*a+b+c-s)
print(a+b+2*c-s,s-b-c,s-a-c)
Problem p03892 (python)

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
if abs(c-a)==0 or abs(d-b)==0:
  print(0)
else:
  x,y=abs(c-a),abs(d-b)
  g=gcd(x,y)
  print(x+y-g)

Buggy submission (verdict: Runtime Error):
from fraction import gcd
a,b,c,d=map(int,input().split())
if abs(c-a)==0 or abs(d-b)==0:
  print(0)
else:
  x,y=abs(c-a),abs(d-b)
  g=gcd(x,y)
  print(x+y-g)
Problem p03938 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
a = [0]*n
b = [0]*n
for i in range(n):
  a[p[i] - 1] += i
  a[i] += n * (i + 1)
  b[i] = n * (n - i)
print(' '.join(map(str,a)))
print(' '.join(map(str,b)))

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
a = [0]*n
b = [0]*n
for i in range(n):
  a[i] = 10 ** 5 * (i + 1) + p
  b[i] = 10 ** 5 * (n - i)
print(' '.join(map(str,a)))
print(' '.join(map(str,b)))
Problem p04006 (python)

Fixed submission:
n, x = map(int, input().split())
a = list(map(int, input().split()))
d = a[:]
ans = float('inf')
for i in range(n):
    ans = min(ans, sum(d) + x * i)
    for j in range(n):
        d[j] = min(d[j], a[(j - (i + 1) + n) % n])
print(ans)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
a = list(map(int, input().split()))
d = a.copy()
ans = float('inf')
for i in range(n):
    ans = min(ans, sum(d) + x * i)
    for j in range(n):
        d[j] = min(d[j], a[(j - (i + 1) + n) % n])
print(ans)
Problem p04043 (python)

Fixed submission:
l = list(map(int, input().split()))
l.sort()
ans = 'NO'
if l == [5, 5, 7]:
  ans = 'YES'
print(ans)

Buggy submission (verdict: Runtime Error):
l = list(map(int, input().split()))
l.sort()
ans = NO
if l == [5, 5, 7]:
  ans = YES
print(ans)
Problem p02917 (python)

Fixed submission:
while True:
    try:
        num = int(input())
        lst = list(map(int, input().split()))
        ans = 0
        ans += lst[-1] + lst[0]
        if num == 2:
            print(ans)
            continue
        for i in range(1, num-1):
            ans += min(lst[i], lst[i-1])
        print(ans)
    except:
        break

Buggy submission (verdict: Runtime Error):
while True:
    try:
        num = int(input())
        lst = list(map(int, input().split()))
        point = lst[-1]
        ans = 0
        for n in lst[-1::-1]:
            point = min(point, n)
            ans += point
        ans lst[0]
        print(ans)
    except:
        break
Problem p02584 (python)

Fixed submission:
x,k,d = list(map(int,input().split()))
x = abs(x)
point =x % d
num = x//d
if num<k:
    rest = k - num
    if rest%2==0:
        pass
    else:
        point = d -point
else:
    point = x - k*d
print(point)

Buggy submission (verdict: Runtime Error):
x,k,d = list(map(int,input().split()))
dis = x
cnt = 0
while cnt<k:
    if abs(dis)<d:
        recnt = k -cnt
        if recnt%2==0:
        else:
            dis = d-abs(dis)
        break
    elif dis>=0:
        dis = dis - d
    else:
        dis = dis + d
    cnt += 1
print(abs(dis))
Problem p02555 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 20:41:22 2020

@author: liang
"""
"""
float => int への変換誤差あり。
scipy.special.comb()は返り値がfloat
math.factorial()で自分で実装する。（大きな値のとき）
"""
#from scipy.special import comb
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#D
key = 10**9 + 7
S = int(input())

#かご
n = S//3

ans = 0
for i in range(1,n+1):
    #玉
    a = S - 3*i 
    #tmp = int(comb(i-1+a,i-1))
    tmp = combinations_count(i-1+a,i-1)
    tmp %= key
    ans += tmp
    ans %= key
    #print("print:",i,ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 20:41:22 2020

@author: liang
"""
from scipy.special import comb
#D
key = 10**9 + 7
S = int(input())

#かご
n = S//3

ans = 0
for i in range(1,n+1):
    #玉
    a = S - 3*i 
    tmp = int(comb(i-1+a,i-1))
    tmp %= key
    ans += tmp
    ans %= key
    #print("print:",i,ans,tmp)
print(ans)