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

Fixed submission:
n,m = map(int,input().split())
if m == 0 and n != 1:
    print(10**(n-1))
    exit()
if m== 0 and n==1:
    print(0)
    exit()
l = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    if l[s-1] == -1:
        l[s-1] = c
    elif l[s-1] != c:
        print('-1')
        exit()
if l[0] == 0 and n==1:
    print(0)
    exit()
if l[0] == 0:
    print('-1')
    exit()
if l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0
# print(l)
ans = 0
for i in range(n):
    ans += l[n-i-1]*10**i
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = [-1]*n
for i in range(m):
    s,c = map(int,input().split())
    if l[s-1] == -1:
        l[s-1] = c
    elif l[s-1] != c:
        print('-1')
        exit()
if l[0] == 0:
    print('-1')
    exit()
if l[0] == -1:
    l[0] = 1
for i in range(1,n):
    if l[i] == -1:
        l[i] = 0
# print(l)
print(100*l[0]+10*l[1]+l[2])
Problem p02767 (python)

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(101):
  ans=0
  for i in range(N):
    ans += (l[i] - j)**2
  k.append(ans)
print(min(k))

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(min(l), max(l)):
  ans=0
  for i in range(N):
    ans += (l[i] - j)**2
  k.append(ans)
print(min(k))

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(min(l), max(l)):
  ans=0
  for i in range(len(l)):
    x = (l[i] - j)**2
    ans += x
  k.append(ans)
print(min(k))
Problem p02900 (python)

Fixed submission:
from fractions import gcd

def factorization(n):
    arr = []
    temp = n
    for i in range(2,int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp != 1:
        arr.append([temp,1])
    if arr == []:
        arr.append([n,1])
    return arr

a,b = map(int,input().split())

x = gcd(a,b)

ans = len(factorization(x))+1
if factorization(x) == [[1,1]]:
  ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd,sqrt

def factorization(n):
    arr = []
    temp = n
    for i in range(2,int(sqrt(n))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp != 1:
        arr.append([temp,1])
    if arr == []:
        arr.append([n,1])
    return arr

a,b = map(int,input().split())

x = gcd(a,b)

print(len(factorization(x))+ (1 if len(factorization(x)) != 1 else 0))
Problem p03043 (python)

Fixed submission:
from math import log2,ceil
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i < k:
        ans += 1/2**(ceil(log2(k/i)))
    else:
        ans += 1
ans /= n
print('{:.15f}'.format(ans))

Buggy submission (verdict: Runtime Error):
from math import log2
n,k = map(int,input().split())
l = []
cnt = 0
for i in range(1,n+1):
    if i < k:
        l.append(int(log2(k/i))+1)
    else:
        cnt += 1
maxi = max(l)
preans = cnt * 2**maxi
for i in l:
    preans += 2**(maxi-i)
ans = preans / (n*2**maxi)
print('{:.20f}'.format(ans))

Buggy submission (verdict: Runtime Error):
from math import log2
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i < k:
        ans += 1/2**(int(log2(k/i))+1)
    else:
        ans += 1
ans /= n
print(ans)
Problem p03062 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))

minus = 0
zero = 0

for i in range(n):
    if A[i] < 0:
        minus += 1
    elif A[i] == 0:
        zero += 1

A2 = [abs(i) for i in A]
if minus %2 == 0 or zero >= 1:
    print(sum(A2))
else:
    print(sum(A2)-2*min(A2))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

def flip_signs(a,b):
    if A[a] + A[b] < 0:
        A[a] *= (-1)
        A[b] *= (-1)
    elif A[a] + A[b]  == 0:
        if n//2 < a:
            A[b] = abs(A[b])
            A[a] *= A[b]//abs(A[b])
        elif b < n//2:
            A[a] = abs(A[a])
            A[b] *= A[a]//abs(A[a])

if n%2 == 1:
    for i in range(n//2-1):
        flip_signs(i,i+1)
        flip_signs(n-1-i,n-2-i)
    ans = sum(A[:(n//2-1)]+A[(n//2+2):])
    x = A[n//2-1]
    y = A[n//2]
    z = A[n//2+1]
    ans += max([-x-y+z,x-y-z,x+y+z,-x+y-z])

else:
    for i in range(n//2-1):
        flip_signs(i,i+1)
        flip_signs(n-1-i,n-2-i)
    ans = sum(A[:(n//2-1)]+A[(n//2+2):])
    x = A[n//2-1]
    y = A[n//2]
    ans += max(-x-y,x+y)
print(ans)
Problem p03086 (python)

Fixed submission:
s = input()
l = []
count = 0
for i in range(len(s)):
  if s[i] in ['A','T','C','G']:
    count += 1
  else:
    l.append(count)
    count = 0
l.append(count)
print(max(l))

Buggy submission (verdict: Runtime Error):
s = input()
l = []
count = 0
for i in range(len(s)):
  if s[i] in ['A','T','C','G']:
    count += 1
  else:
    l.append(count)
    count = 0
print(max(l))
Problem p03126 (python)

Fixed submission:
n,m = map(int,input().split())
l = [0]*m
for i in range(n):
  a = list(map(int,input().split()))
  for i in range(1,a[0]+1):
    l[a[i]-1] += 1
count = 0
for i in l:
  if i == n:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = [0]*m
for i in range(n):
  a = list(map(int,input().split()))
  for i in range(1,a[0]+1):
    l[a[i-1]] += 1
count = 0
for i in l:
  if i == n:
    count += 1
print(count)
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict

n,m = map(int,input().split())
d = defaultdict(list)
for i in range(m):
    x,y = map(int,input().split())
    d[x-1].append(y-1)

dp = [-1]*n

def rec(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in d[v]:
        res = max(res,rec(nv)+1)
    dp[v] = res
    return res

res = 0
for v in range(n):
    res = max(res,rec(v))
print(res)

Buggy submission (verdict: Runtime Error):
# import sys
from collections import defaultdict
# sys.setrecursionlimit(10**9)
n,m = map(int,input().split())
d = defaultdict(list)
for i in range(m):
    x,y = map(int,input().split())
    d[x-1].append(y-1)

dp = [-1]*n

def rec(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in d[v]:
        res = max(res,rec(nv)+1)
    dp[v] = res
    return res

res = 0
for v in range(n):
    res = max(res,rec(v))
print(res)
Problem p03196 (python)

Fixed submission:
from math import gcd
def prime_factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp != 1:
        arr.append([temp,1])
    if arr == []:
        arr.append([n,1])
    return arr
n,p = map(int,input().split())
l = prime_factorization(p)
ans = []
for i in l:
    if i[1] >= n:
        for j in range(i[1]//n):
            ans.append(i[0])
product = 1
for i in ans:
    product *= i
print(product)

Buggy submission (verdict: Runtime Error):
n,p = map(int, input().split())
i = 1
l = []
while i**n <= p:
    if p % i**n == 0:
        l.append(i)
    i += 1
print(max(l))
Problem p03294 (python)

Fixed submission:
from fractions import gcd
n = int(input())
l = list(map(int,input().split()))
lcm = 1
for i in range(n):
    lcm = lcm*l[i]//gcd(l[i],lcm)
x = lcm-1
print(sum([x%i for i in l]))

Buggy submission (verdict: Runtime Error):
from math import gcd
n = int(input())
l = list(map(int,input().split()))
lcm = 1
for i in range(n):
    lcm = lcm*l[i]//gcd(l[i],lcm)
x = lcm-1
print(sum([x%i for i in l]))
Problem p03503 (python)

Fixed submission:
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

maxi = -10**10

for i in range(1,2**10):
    num = [0]*n
    for j in range(10):
        if ((i >> j) & 1):
            for k in range(n):
                num[k] += l[k][j]
    benefit = 0
    for m in range(n):
        benefit += p[m][num[m]]
    maxi = max(maxi,benefit)
print(maxi)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

maxi = -10**10

for i in range(1,2 ** 10):
    num = [0]*10
    for j in range(10):
        if ((i >> j) & 1):
            for k in range(n):
                num[k] += l[k][j]
    benefit = 0
    for m in range(n):
        benefit += p[m][num[m]]
    maxi = max(maxi,benefit)
print(maxi)
Problem p03612 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
count = 0
if l[0] == 1:
  l[1] = l[0]
  count += 1
for i in range(1,n):
  if l[i] == i+1:
    if i != n-1:
      if l[i+1] == i+2:
        l[i],l[i+1] = l[i+1],l[i]
    else:
      l[i] = l[i-1]
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
count = 0
if l[0] == 1:
  l[1] = l[0]
  count += 1
for i in range(1,n):
  if l[i] == i+1:
    if l[i+1] == i+2:
      l[i],l[i+1] = l[i+1],l[i]
      i += 1
    else:
      l[i] = l[i-1]
    count += 1
  
print(count)
Problem p02534 (python)

Fixed submission:
print('ACL'*int(input()))

Buggy submission (verdict: Runtime Error):
K=int('K')
if K==1:
 print('ACL')
elif K==2:
 print('ACL'*2)
elif K==3:
 print('ACL'*3)
elif K==4:
 print('ACL'*4)
else:
 print('ACL'*5)

Buggy submission (verdict: Runtime Error):
K=int('K')
if K=1:
 print('ACL')
elif K=2:
 print('ACL'*2)
elif K=3:
 print('ACL'*3)
elif K=4:
 print('ACL'*4)
else:
 print('ACL'*5)

Buggy submission (verdict: Runtime Error):
if K=1:
 print('ACL')
elif K=2:
 print('ACL'*2)
elif K=3:
 print('ACL'*3)
elif K=4:
 print('ACL'*4)
else:
 print('ACL'*5)

Buggy submission (verdict: Runtime Error):
num="K"
print('ACL'*num)

Buggy submission (verdict: Runtime Error):
count=int("K")
print('ACL'*count)
Problem p02952 (python)

Fixed submission:
n=int(input())
ans=0
for i in range(n+1):
    if len(str(i))%2==1:
        ans=ans+1
        
print(ans-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
    if len(list(n))%2==1:
        ans=ans+1
        
print(ans)
Problem p03001 (python)

Fixed submission:
# coding: utf-8
# Your code here!
n=input().rstrip().split(" ")
for i in range(4):
    n[i]=int(n[i])
S=n[0]*n[1]
senter=[n[0]/2,n[1]/2]#1
dis=[n[2],n[3]]#2
a=senter[1]-dis[1]
b=dis[0]-senter[0]
if(senter[1]==dis[1] and senter[0]==dis[0]):
    print(str(S/2) +" "+str(1))
else:
    print(str(S/2) +  " "+ str(0))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n=input().rstrip().split(" ")
for i in range(4):
    n[i]=int(n[i])
S=n[0]*n[1]
senter=[n[0]/2,n[1]/2]#1
dis=[n[2],n[3]]#2
a=senter[1]-dis[1]
b=dis[0]-senter[0]
if(senter[1]=dis[1] and senter[0]=dis[0]):
    print(str(S/2) 1)
else:
    print(4 0)
Problem p03293 (python)

Fixed submission:
import sys
s = input()
t = input()
for i in range(len(s)):
  ok = 1
  for j in range(len(s)):
    if s[(i+j)%len(s)] != t[j]:
      ok = 0
  if ok == 1:
    print("Yes")
    sys.exit()
print("No")

Buggy submission (verdict: Runtime Error):
import sys
s = input()
t = input()
for i in len(s):
  ok = 1
  for j in len(s):
    if s[(i+j)%len(s)] != t[j]:
      ok = 0
  if ok == 1:
    print("Yes")
    sys.exit()
print("No")
Problem p03302 (python)

Fixed submission:
a,b = map(int,input().split(" "))
if a+b==15:
  print("+")
elif a*b==15:
  print("*")
else:
  print("x")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a+b==15:
  print("+")
else if a*b==15:
  print("*")
else:
  print("x")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split(" "))
if a+b==15:
  print("+")
else if a*b==15:
  print("*")
else:
  print("x")

Buggy submission (verdict: Runtime Error):
a,b = int(input().split(" "))
if a+b==15:
  print("+")
else if a*b==15:
  print("*")
else:
  print("x")
Problem p02632 (python)

Fixed submission:
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 2 * 10 ** 6 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0

now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*cmb(lens+i-1,lens-1,mod)
    ans=ans%mod

print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0

now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*cmb(lens+i-1,lens-1,mod)
    ans=ans%mod

print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0


now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*cmb(lens+i-1,lens-1,mod)
    ans=ans%mod

print(ans)
Problem p02642 (python)

Fixed submission:
n=int(input())
A=[int(i) for i in input().split()]

A.sort()
A.append(-1)

dat={i:False for i in range(10**6+10)}

ans=0
for i in range(len(A)-1):
    if dat[A[i]]:
        pass
    else:
        if A[i]!=A[i+1]:
            ans+=1
        for i in range(A[i],10**6+10,A[i]):
            dat[i]=True

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[int(i) for i in input().split()]

A.sort()
A.append(-1)

dat={i:False for i in range(2*10**5+100)}

ans=0
for i in range(len(A)-1):
    if dat[A[i]]:
        pass
    else:
        if A[i]!=A[i+1]:
            ans+=1
        for i in range(A[i],2*10**5+100,A[i]):
            dat[i]=True

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[int(i) for i in input().split()]

A.sort()
A.append(-1)

dat={i:False for i in range(2*10**5+1)}

ans=0
for i in range(len(A)-1):
    if dat[A[i]]:
        pass
    else:
        if A[i]!=A[i+1]:
            ans+=1
        for i in range(A[i],2*10**5+1,A[i]):
            dat[i]=True

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[int(i) for i in input().split()]

A.sort()
A.append(-1)

dat={i:False for i in range(2*10**5+1)}

ans=0
for i in range(len(A)-1):
    if dat[A[i]]:
        pass
    else:
        if A[i]!=A[i+1]:
            ans+=1
        for i in range(A[i],20**5+1,A[i]):
            dat[i]=True

print(ans)
Problem p02690 (python)

Fixed submission:
can=[0]
for i in range(1,151):
    can.append(pow(i,5))
    can.append(-pow(i,5))
can.sort()

x=int(input())

end=False
for i in range(len(can)):
    for q in range(len(can)):
        if can[i]-can[q]==x:
            
            print(i-150,q-150)
            end=True
            break
    if end:
        break
else:
    raise ValueError("xx")

Buggy submission (verdict: Runtime Error):
can=[0]
for i in range(1,101):
    can.append(pow(i,5))
    can.append(-pow(i,5))
can.sort()

x=int(input())

end=False
for i in range(len(can)):
    for q in range(len(can)):
        if can[i]-can[q]==x:
            
            print(i-100,q-100)
            end=True
            break
    if end:
        break
else:
    raise ValueError("xx")
Problem p02850 (python)

Fixed submission:
import sys

sys.setrecursionlimit(100000)

n=int(input())

ans={}
inp_list=[]
G=[0 for i in range(n+1)]
T=[[] for i in range(n+1)]
for i in range(n-1):
    #print(G)
    a,b=map(int,input().split())
    inp_list.append((a,b))
    T[a].append(b)
    T[b].append(a)

L=[len(ppp) for ppp in T]
mod=max(L)

def addd(x,mod):
    x+=1
    if x==mod+1:
        x=1
    return x

def tansa(now,color):
    #print(T)
    now_col=color
    for i in T[now]:
        if G[i]==0:
            if now_col==color:
                now_col=addd(now_col,mod)
            G[i]==now_col
            ans[(now,i)]=now_col
            T[i].remove(now)
            tansa(i,now_col)
            now_col=addd(now_col,mod)


tansa(1,0)

print(mod)

for i in range(n-1):
    print(ans[inp_list[i]])

Buggy submission (verdict: Runtime Error):
n=int(input())

ans={}
inp_list=[]
G=[0 for i in range(n+1)]
T=[[] for i in range(n+1)]
for i in range(n-1):
    #print(G)
    a,b=map(int,input().split())
    inp_list.append((a,b))
    T[a].append(b)
    T[b].append(a)

L=[len(ppp) for ppp in T]
mod=max(L)

def addd(x,mod):
    x+=1
    if x==mod+1:
        x=1
    return x

def tansa(now,color):
    #print(T)
    now_col=color
    for i in T[now]:
        if G[i]==0:
            if now_col==color:
                now_col=addd(now_col,mod)
            G[i]==now_col
            ans[(now,i)]=now_col
            T[i].remove(now)
            tansa(i,now_col)
            now_col=addd(now_col,mod)


tansa(1,0)

print(mod)

for i in range(n-1):
    print(ans[inp_list[i]])
Problem p02952 (python)

Fixed submission:
N=input()
lenN=len(N)
ans=0

for i in range(1,int(N)+1):
    if len(str((i)))%2==1:
        ans+=1
    
print(ans)

Buggy submission (verdict: Runtime Error):
N=input()
lenN=len(N)
ans=0


for i in range(1,lenN,2):
    ans+=10**i*9//10
    #print(ans)

if lenN%2==1:
    ans+=int(N[1:])+1
    
print(ans)
    
    


#0をひかない
Problem p02999 (python)

Fixed submission:
L=[i for i in input().split()]
x=L[0]
a=L[1]
if x<a:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
L=[int(i) for i in input().split()]

sumL=[None for i in range(n)]
sumL[0] = L[0]
for i in range(len(L)-1):
    sumL[i+1] = sumL[i] + L[i+1]

res=0

step=0
lenL=len(sumL)

for q in range(lenL):
    step=0
    for nums in sumL:
        step+=1
        if nums>=k:
            #print(len(sumL)-step+1)
            res+=lenL-step+1
            break
    else:
        break
    #print(sumL)
    sumL=sumL[step-1:]
    #print(sumL)
    lenL-=step-1
    k+=L[q]
    
    
    
print(res)
Problem p03160 (python)

Fixed submission:
n=int(input())
H=[int(i) for i in input().split()]
H.append(0)
import math
dp=[1e10 for i in range(n+2)]
dp[0]=0

for i in range(n-1):
    dp[i+1]=min(dp[i+1],dp[i]+abs(H[i+1]-H[i]))
    dp[i+2]=min(dp[i+2],dp[i]+abs(H[i+2]-H[i]))

print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
H=[int(i) for i in input().split()]
H.append(0)
import math
dp=[math.inf for i in range(n+2)]
dp[0]=0

for i in range(n-1):
    dp[i+1]=min(dp[i+1],dp[i]+abs(H[i+1]-H[i]))
    dp[i+2]=min(dp[i+2],dp[i]+abs(H[i+2]-H[i]))

print(dp[n-1])
Problem p03497 (python)

Fixed submission:
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
tab=[0 for i in range(n+1)]
for num in A:
    tab[num]+=1
tab.sort(reverse=True)
print(n-sum(tab[:k]))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
tab=[0 for i in range(n+1)]
for num in A:
    tab[num]+=1
tab.sort(reverse=True)
print(n-10 sum(tab[:k]))
Problem p02555 (python)

Fixed submission:
n=int(input())
if n<7:print(n//3);quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=n-4
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M;dp+=1
  s=(s+n*d)%M
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n<6:print(int(n>2));quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=n-4
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M;dp+=1
  s=(s+n*d)%M
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n<6:print(int(n>2));quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=0
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M;dp+=1
  s=(s+n*d)%M
print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n<6:print(int(n>2));quit()
M=10**9+7
ln,hn,dp=n-6,n-5,2
s=0
n,d=n-5,1
while n:
  for i in range(3):n=(n*ln)%M;ln-=1
  for i in range(2):n=(n*pow(hn,-1,M))%M;hn-=1
  d=(d*pow(dp,-1,M))%M,dp+=1
  s=(s+n*d)%M
print(s)
Problem p02607 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i % 2 == 0 and a[i] % 2 == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
  	if i % 2 == 0 and a[i] % 2 == 1:
      	ans += 1
print(ans)
Problem p02641 (python)

Fixed submission:
def read_int():
    return int(input())


def read_ints():
    return map(int, input().split(' '))


x, n = read_ints()
p = []
if n > 0:
    p = list(read_ints())
ans = -1
delta = 1000
for i in range(-1, 102):
    ok = True
    for j in p:
        if j == i:
            ok = False
            break
    if ok:
        d = abs(x - i)
        if d < delta:
            ans = i
            delta = d
print(ans)

Buggy submission (verdict: Runtime Error):
def read_int():
    return int(input())


def read_ints():
    return map(int, input().split(' '))


x, n = read_ints()
p = list(read_ints())
ans = -1
delta = 1000
for i in range(102):
    ok = True
    for j in p:
        if p == i:
            ok = False
            break
    if ok:
        d = abs(x - i)
        if d < delta:
            ans = i
print(ans)
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
ans = min(a) + min(b)
for i in range(M):
    x, y, c = map(int, input().split(' '))
    ans = min(ans, a[x - 1] + b[y - 1] - c)
print(ans)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input.split(' '))
a = list(map(int, input.split(' ')))
b = list(map(int, input.split(' ')))
asum = [0]
bsum = [0]
for i in a:
    asum.append(asum[-1] + i)
for i in b:
    bsum.append(bsum[-1] + i)
ans = int(1e18)
for i in range(M):
    x, y, c = map(int, input.split(' '))
    ans = min(ans, asum[x] + bsum[y] - c)
print(ans)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input.split(' '))
a = list(map(int, input.split(' ')))
b = list(map(int, input.split(' ')))
asum = [0]
bsum = [0]
for i in a:
    asum.append(asum[-1] + i)
for i in b:
    bsum.append(bsum[-1] + i)
ans = int(1e18)
for i in range(M):
    x, y, c = map(int, input.split(' '))
    ans = min(ans, asum[x] + bsum[y] - c)
print(ans)