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

Fixed submission:
N,M=map(int,input().split())
e=[[] for i in range(N)]
tester=[None]*M
for i in range(M):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  e[a].append(b)
  e[b].append(a)
  tester[i]=set([a,b])
  
ans=0
for test in tester:
  stack=[]
  stack.append([0,-1])
  seen=[0 for i in range(N)]
  while stack:
    node=stack.pop()
    v=node[0]
    parent=node[1]
    if seen[v]==1:
      continue
    seen[v]=1
    childs=e[v]
    for child in childs:
      if child==parent:
        continue
      if test==set([v,child]):
        continue
      stack.append([child,v])
      
  if sum(seen)!=N:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,Mmap(int,input())
e=[[] for i in range(N)]
tester=[None]*M
for i in range(M):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  e[a].append(b)
  e[b].append(a)
  tester[i]=set(a,b)
  
ans=0
seen=[0 for i in range(N)]
for test in tester:
  stack=[]
  stack.append([0,-1])
  while stack:
    node=stack.pop()
    v=node[0]
    parent=node[1]
    if seen[v]==1:
      continue
    seen[v]=1
    childs=e[v]
    for child in childs:
      if child==parent:
        continue
      if len(test&set([v,child]))==2:
        continue
      stack.append([child,v])
      
  if sum(seen)!=N:
    ans+=1
print(ans)
Problem p03578 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
M=int(input())
t=list(map(int,input().split()))
import collections
ac=collections.Counter(a)
tc=collections.Counter(t)

for task in tc.items():
  if task[0] not in ac:
    print("NO")
    exit(0)
  elif ac[task[0]]<task[1]:
    print("NO")
    exit(0)
print("YES")

Buggy submission (verdict: Runtime Error):
n=int(input())
d=sorted(list(map(int,input().split())))
m=int(input())
t=sorted(list(map(int,input().split())))

j=0
for i in range(len(t)):
  if j==len(s):
    print("NO")
    break
  t[i]==s[j]:
    j+=1
else:
  print("YES")
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F=map(int,input().split())
# 作れる水の量をDPで求める (MAXはF)
# 作れる砂糖の量をDPで求める　（MAXは、F*(E/(E+100)）
# 作れる水の量に対して二分探索で、最も多く入れられる砂糖の量を求める。

dpW=[False]*(F+1)
dpW[0]=True
for w in (A*100,B*100):
  for j in range(len(dpW)):
    if dpW[j] and j+w<len(dpW):
      dpW[j+w]=True
      
water=[]
for i in range(len(dpW)):
  if dpW[i] and i!=0:
    water.append(i)

maxsugar=int(F*(E/(E+100)))+1
dpS=[False]*(maxsugar+1)
dpS[0]=True
for s in (C,D):
  for j in range(len(dpS)):
    if dpS[j] and j+s<len(dpS):
      dpS[j+s]=True
sugar=[]
for i in range(len(dpS)):
  if dpS[i]:
    sugar.append(i)
    
ans=[0,0]
maxrate=0
for w in water:
  maxS=int(w*(E/100))
  if w+maxS>F:
    maxS=F-w
  # maxSを越えない最大の砂糖をsugarから探す
  ok=0
  ng=len(sugar)
  while abs(ok-ng)>1:
    mid=abs(ok+ng)//2
    if sugar[mid]<=maxS:
      ok=mid
    else:
      ng=mid
  if sugar[ok]/w>=maxrate:
    maxrate=sugar[ok]/w
    ans=[w+sugar[ok],sugar[ok]]
print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline

# A + Bの組み合わせはせいぜい1～30のうち作れる数字のみなので全探索

A,B,C,D,E,F = map(int,readline().split())

if E == 0:
  print(min(A,B) * 100, 0)
  exit(0)

ans = [0,0]
maxrate = 0.0
for a in range(0,F,100 * A):
  for b in range(0,F,100 * B):
    if a == 0 and b == 0:
      continue
    if a + b > F:
      break
    water = a + b
    # waterに対して溶ける最大量は (a + b) * E
    limit = min(((a + b) / 100) * E, F - water)
    maxsugar = 0
    for c in range(0,limit + 1,C):
      for d in range(0,limit + 1,D):
        if c + d > limit:
          break
        if c + d > maxsugar:
          maxsugar = c + d
          rate = maxsugar / (water + maxsugar)
          if rate > maxrate:
            maxrate = rate
            ans = [water + maxsugar, maxsugar]
          
print(*ans)
Problem p03600 (python)

Fixed submission:
import sys
readline = sys.stdin.readline

N = int(readline())

A = [None] * N
for i in range(N):
  A[i] = list(map(int,readline().split()))
  
# まずワーシャルフロイド表を作る
# ワーシャルフロイド表より大きな数値が元の表にあったら、最短距離の表ではないので-1
# 最短距離の表になっているのであれば、
# A[1][3]に行くときにA[1][2] + A[2][3]となるのであれば、
# A[1][3]のほうだけansに記録していく

import copy
newA = copy.deepcopy(A)

for k in range(N):
  for i in range(N):
    for j in range(N):
      if i == k or k == j or i == j:
        continue
      if A[i][k] + A[k][j] < A[i][j]:
        print(-1)
        exit(0)
      elif A[i][k] + A[k][j] == A[i][j]:
        # A[i][j]の道路は不要
        newA[i][j] = 0

ans = 0
for a in newA:
  ans += sum(a)
print(ans // 2)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline

N = int(readline())

A = [None] * N
for i in range(N):
  A[i] = list(map(int,readline().split()))
  
# まずワーシャルフロイド表を作る
# ワーシャルフロイド表より大きな数値が元の表にあったら、最短距離の表ではないので-1
# 最短距離の表になっているのであれば、
# A[1][3]に行くときにA[1][2] + A[2][3]となるのであれば、
# A[1][3]のほうだけansに記録していく

import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse.csgraph import csgraph_from_dense
A = np.array(A)
G = csgraph_from_dense(A, null_value=0)
w = floyd_warshall(G)

for i in range(N):
  for j in range(N):
    if A[i][j] > w[i][j]:
      print(-1)
      exit(0)

ans = 0
for a in A:
  ans += sum(a)
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      if i == k or k == j or i == j:
        continue
      if A[i][k] + A[k][j] == A[i][j]:
        ans -= A[i][j]
        
print(ans // 2)
Problem p03612 (python)

Fixed submission:
n=int(input())
import numpy as np
a=np.array(input().split(),dtype=int)
i=0
ans=0
while i<a.size:
  if a[i]==i+1:
    ans+=1
    if i+1 < a.size and a[i+1]==i+2:
      i+=2
      continue
  i+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
import numpy as np
a=np.array(input().split(),dtype=int)
np.append(a,[0])
i=0
ans=0
while i<a.size:
  if a[i]==i+1:
    ans+=1
    if a[i+1]==i+2:
      i+=2
      continue
  i+=1
print(ans)
Problem p03638 (python)

Fixed submission:
H,W=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

grid=[[0 for i in range(W)] for j in range(H)]
cur=0
curcnt=0
for i in range(H):
  for j in range(W):
    p=j
    if i%2==1:
      p=W-1-j
    grid[i][p]=cur+1
    curcnt+=1
    if curcnt==a[cur]:
      cur+=1
      curcnt=0
      
for i in range(H):
  print(*grid[i])

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

grid=[[0 for i in range(W)] for j in range(H)]
cur=0
curcnt=0
for i in range(H):
  for j in range(W):
    p=j
    if i%2==1:
      p=W-1-j
    grid[i][p]=cur+1
    curcnt+=1
    if curcnt=a[cur]:
      cur+=1
      curcnt=0
      
for i in range(H):
  print(*grid[i])
Problem p03646 (python)

Fixed submission:
# K回の操作
# N = 50とする
# 0,1,2,3,4...N - 1の数列に対して左からi番目にNを足し、それ以外から1を引く操作
# K // N回の操作をすると、1回あたり全項目に1が足される。

import sys
readline = sys.stdin.readline

K = int(readline())
N = 50

A = [i for i in range(N)]
A = list(map(lambda x:x + (K // N),A))
rest = K % N
for i in range(rest):
  A[i] += N
  for j in range(N):
    if i != j:
      A[j] -= 1

print(N)
print(*A)

Buggy submission (verdict: Runtime Error):
K=int(input())
N=int(K**0.5)+2
print(N)
print(*([N*K]+[0]*(N-1)))

Buggy submission (verdict: Runtime Error):
K=int(input())
N=K+1
print(N)
print(str(N*K)+" "+"0 "*(N-2)+"0")

Buggy submission (verdict: Runtime Error):
K=int(input())
N=K+1
print(N)
print(*([N*K]+[0]*(N-1)))
Problem p03658 (python)

Fixed submission:
n,k=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
ans=0
for i in range(k):
  ans+=L.pop()
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,imput().split())
a=list(map(int,input().split()))
a=sorted(a)
sum=0
for i in range(len(a)-1,len(a)-k,-1):
  sum=sum+a[i]
print(sum)
Problem p03673 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=a[1::2][::-1]+a[0::2]
print((*b,*(b[::-1]))[n%2>0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
bbottom=""
btop=""
for i in range(n):
  if i%2==0:
    bbottom.append(a[i])
  else:
    btop.append(a[i])
ans=btop[::-1]+bbottom
if n%2==1:
  ans=ans[::-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
bbottom=""
btop=""
for i in range(n):
  if i%2==0:
    bbottom+=a[i]
  else:
    btop+=a[i]
ans=btop[::-1]+bbottom
if n%2==1:
  ans=ans[::-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
bbottom=""
btop=""
for i in range(n):
  if i%2==0:
    bbottom+=a[i]
  else:
    btop+=a[i]
ans=btop[::-1]+bbottom
if n%2==1:
  ans=ans[::-1]
prin(ans)
Problem p03701 (python)

Fixed submission:
n=int(input())
s=[None]*n
minv=100
for i in range(n):
  s[i]=int(input())
  if minv>s[i]:
    if s[i]%10!=0:
      minv=s[i]
if minv==100:
  print(0)
elif sum(s)%10==0:
  print(sum(s)-minv)
else:
  print(sum(s))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[None]*n
minv=100
for in range(n):
  s[i]=int(input())
  if minv>s[i]:
    if s[i]%10!=0:
      minv=s[i]
if minv==100:
  print(0)
elif sum(s)%10==0:
  print(sum(s)-minv)
else:
  print(sum(s))
Problem p03813 (python)

Fixed submission:
print(("ARC","ABC")[int(input())<1200])

Buggy submission (verdict: Runtime Error):
print(("ARC","ABC")[int(input()<1200])
Problem p03993 (python)

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

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

Fixed submission:
n,m=map(int,input().split())
b=[1]*n
red=[False]*n
red[0]=True
for i in range(m):
  x,y=map(int,input().split())
  x,y=x-1,y-1
  if not b[x]:
    continue
  b[y]+=1
  if red[x]:
    red[y]=True
  
  b[x]-=1
  if b[x]==0:
    red[x]=False
    
print(red.count(True))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
b=[1]*n
red=[False]*n
red[0]=True
for i in range(m):
  x,y=map(int,input().split())
  if not b[x]:
    continue
  x,y=x-1,y-1
  b[y]+=1
  red[y]=red[x]
  
  b[x]-=1
  if b[x]==0:
    red[x]=False
    
print(red.count(True))
Problem p02534 (python)

Fixed submission:
k=int(input())
s="ACL"
for i in range(k):
  print(s,end="")

Buggy submission (verdict: Runtime Error):
k=int(input())
print(k**"ACL")
Problem p02817 (python)

Fixed submission:
test1, test2 = input().split()

ans = test2 + test1

print(ans)

Buggy submission (verdict: Runtime Error):
test1 = input()
test2 = input()

ans = test2 + test1

print(ans)
Problem p02999 (python)

Fixed submission:
abc = [int(e) for e in input().split()]

x = abc[0]
a = abc[1]

if x < a:
    ans = 0
else:
    ans = 10

print(ans)

Buggy submission (verdict: Runtime Error):
nx = [int(e) for e in input().split()]
ll = [int(e) for e in input().split()]

n = nx[0]   # バウンド回数
x = nx[1]   # 終点
point = 0   # バウンド位置
count = 0   # バウンド回数

if point <= x:
    count += 1

while point <= x:

    if count == n:
        break
    point += ll[count - 1]
    count += 1
    if point > x:
        count -= 1
        break

if count == n:
    count = n
print(count)

Buggy submission (verdict: Runtime Error):
nx = [int(e) for e in input().split()]
ll = [int(e) for e in input().split()]

n = nx[0]   # バウンド回数
x = nx[1]   # 終点
point = 0   # バウンド位置
count = 0   # バウンド回数

if point <= x:
    count += 1

while point <= x:

    if count == n:
        break
    point += ll[count - 1]
    count += 1
    if point > x:
        count -= 1
        break

if count == n:
    count = n
print(count)
Problem p03059 (python)

Fixed submission:
import math

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

print(math.floor(t / a) * b)

Buggy submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

# 価値 - コスト > 0 のフィルタ
for i in range(N):
    s = V[i] - C[i]
    if s > 0:
        ans += s

print(ans)
Problem p02817 (python)

Fixed submission:
l=list(map(str,input().split()))
print(l[1]+l[0])

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())
print(t+s)
Problem p02995 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
p=c*d//gcd(c,d)

x = (a-1) - ((a-1)//c + (a-1)//d - (a-1)//p)
y = b - (b//c + b//d - b//p)


print(y-x)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())

p=c*d//(math.gcd(c,d))

x = (a-1) - ((a-1)//c + (a-1)//d - (a-1)//p)
y = b - (b//c + b//d - b//p)


print(y-x)
Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())
s=float((w/2)*h)
ans=0
if w%2==0 and h%2==0:
    if w//2==x and h//2==y:
        ans=1
else:
    ans=0

print(str(float(s))+" "+str(ans))

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())

s=float(w*h/2)

if w%2==0 and h%2==0:
    if w//2==x and h//2==y:
        ans=1
else:
    ans=0

print(str(float(s))+" "+str(ans))
Problem p03006 (python)

Fixed submission:
import collections
n=int(input())
xy=[]
for i in range(n):
    xy.append(list(map(int,input().split())))
dif=[]
for i in range(n):
    for k in range(i+1,n):
        dif.append([xy[i][0]-xy[k][0],xy[i][1]-xy[k][1]])
        dif.append([xy[k][0]-xy[i][0],xy[k][1]-xy[i][1]])
for i in range(len(dif)):
    dif[i]=str(dif[i])
c=collections.Counter(dif)
ans=list(c.values())
ans.sort(reverse=True)

if n==1:
    print(1)
else:
    print(n-ans[0])

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
xy=[]
for i in range(n):
    xy.append(list(map(int,input().split())))

dif=[]
for i in range(n):
    for k in range(i+1,n):
        dif.append([xy[i][0]-xy[k][0],xy[i][1]-xy[k][1]])
        dif.append([xy[k][0]-xy[i][0],xy[k][1]-xy[i][1]])
for i in range(len(dif)):
    dif[i]=str(dif[i])
c=collections.Counter(dif)
ans=list(c.values())
ans.sort(reverse=True)
print(n-ans[0])
Problem p03047 (python)

Fixed submission:
n,k=map(int,input().split())
print(n-k+1)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
r=int(math.sqrt(n))
ctr=0
for i in range(1,r+1):
    if n%i==0 and n//i>i:
        ctr+=n//i-1
print(ctr)
Problem p03071 (python)

Fixed submission:
a,b=map(int,raw_input().split())
x=max(a,b)
y=min(a,b)
if x-y>1:
	print x+x-1
else:
	print x+y

Buggy submission (verdict: Runtime Error):
a,b=map(raw_input().split())

if abs(a-b)<=1:
	print a+b
else:
	print a+b+1
Problem p03087 (python)

Fixed submission:
n,q=map(int,input().split())
s=list(str(input()))
lr=[]
for i in range(q):
    lr.append(list(map(int,input().split())))
ctr1=0
t_list=[0]
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        ctr1+=1
        t_list.append(ctr1)
    else:
        t_list.append(ctr1)

for i in range(q):
    left=lr[i][0]
    right=lr[i][1]
    print(t_list[right-1]-t_list[left-1])

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(str(input()))
lr=[]
for i in range(q):
    lr.append(list(map(int,input().split())))

l_list=[]
r_list=[0]
ctr1=0
ctr2=0
for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        ctr1+=1
        l_list.append(ctr1)
        ctr2+=1
        r_list.append(ctr2)
    else:
        l_list.append(ctr1)
        r_list.append(ctr2)

for i in range(q):
    left=lr[i][0]
    right=lr[i][1]
    print(r_list[right-1]-l_list[left]+1)
Problem p03102 (python)

Fixed submission:
n,m,c=map(int, raw_input().split())
b=list(map(int,raw_input().split()))
a=[]
for i in range(n):
    a.append(list(map(int,raw_input().split())))
counter=0
for i in range(n):
    d=0
    for k in range(m):
        d+=a[i][k]*b[k]
    if d+c>0:
        counter+=1
print counter

Buggy submission (verdict: Runtime Error):
n,m,c=map(int, raw_input().split())
b=list(map(int,raw_input().split()))
a=[]
for i in range(n):
    a.append(list(map(int,raw_input().split())))
counter=0
for i in range(n):
    d=0
    for k in range(m):
        d+=a[i][k]*b[k]
    if d+c>0:
        counter+=1
print counter
Problem p03262 (python)

Fixed submission:
n,x=map(int,input().split())
xl=list(map(int,input().split()))
for i in range(n):
    xl[i]=abs(xl[i]-x)
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

while len(xl)>1:
    xl[0]=gcd(xl[0],xl[1])
    del xl[1]
    
print(xl[0])

Buggy submission (verdict: Runtime Error):
import math
import functools
n,x=map(int,input().split())
xl=list(map(int,input().split()))
for i in range(n):
    xl[i]=abs(xl[i]-x)
print(functools.reduce(math.gcd,xl))
Problem p03281 (python)

Fixed submission:
n=int(input())
l=[]
for i in range(3,n+1,2):
    c=0
    for k in range(1,i+1):
        if i%k==0:
            c+=1
        else:
            pass
    l.append(c)
print(l.count(8))

Buggy submission (verdict: Runtime Error):
n=int(input())
c=0
a=3
while a<=n:
    b=a*(a+2)*(a+4)
    if b==
    elif b<=n:
        c+=1
        a+=2
    else:
        break
print(c)
Problem p03284 (python)

Fixed submission:
n,k=map(int,input().split())
if n%k==0:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
tmp=n
i=0
while abs(tmp)>=(2**(i)):
    if tmp%(2**(i+1))!=0:
        l.append(1)
        tmp=tmp-(-2)**i
        i+=1
    else:
        l.append(0)
        i+=1
l=l[::-1]
l=map(str,l)
l="".join(l)
print(l)
Problem p03543 (python)

Fixed submission:
n=list(str(raw_input()))

if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n=list(str(raw_input()))

if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
	print("Yes")
else:
	print("No")
Problem p03544 (python)

Fixed submission:
n=int(raw_input())

if n==0:
	print(2)
elif n==1:
	print(1)
ln=[2,1]
if n >=2:
	for i in range(2,n+1):
		ln.append(ln[i-1]+ln[i-2])	
	print(ln[-1])

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

if n==0:
	print(2)
elif n==1:
	print(1)
else:
	ln=[2,1]
	for i in range(2,n+1):
		ln.append(ln[i-1]+ln[i-2])	
print(ln[-1])
Problem p02534 (python)

Fixed submission:
a=int(input())
repeat=""
for i in range(a):
    repeat=repeat+"ACL"
print(repeat)

Buggy submission (verdict: Runtime Error):
n,t=(int(x) for x in input().split())
t=t//1000
for y in range(((t-n)//4)+4):
    if (t-n-(4*y))%9 == 0:
        z=(t-n-(4*y))//9
        if n-y-z>=0:
            x=n-y-z
            print(x,y,z)
            break
else:
    print(-1,-1,-1)
Problem p02554 (python)

Fixed submission:
N, = map(int, input().split())
mod = 10**9+7
R=pow(10, N, mod) - 2*pow(9, N, mod) + pow(8, N, mod)
print(R%mod)

Buggy submission (verdict: Runtime Error):
a, b, c, d = list(map(int, input().split()))
R=max([b*d, a*d, a*c, b*c])
print(R)
Problem p02555 (python)

Fixed submission:
import sys
input=sys.stdin.readline
mod = 10**9+7
 
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
NNN = 2*10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def ff(N, M):
    R = 0
    for i in range(1, M+1):
        R += (-1 if (M-i)%2 else 1) * cmb(M, i) * pow(i, N, mod) % mod
    R = R*cmb(N, M)%mod
    return R
 
N, = map(int, input().split())
R = 0
for i in range(1, N):
    M=N-2*i
    if N < M:
        break
    R += cmb(M-1,i-1)
    R %= mod

print(R)

Buggy submission (verdict: Runtime Error):
mod = 10**9+7
N, = map(int, input().split())
dp1 = [0]*N
dp2 = [0]*N
for i in range(N):
    if i < 3:
        dp1[i] = 1
        dp2[i] = 0
    else:
        dp1[i] = dp1[i-1] + dp2[i-1]
        dp2[i] = dp1[i-3] + dp2[i-3]
    dp1[i] %= mod
    dp2[i] %= mod
print(dp1)
print(dp2)
print((dp1[-1]+dp2[-3])%mod)
Problem p02626 (python)

Fixed submission:
N, = map(int, input().split())
X = list(map(int, input().split()))
t = 0
for x in X:
    t = t^x
inf = float('inf')
d = dict()
def it(x, y, z):
    if (x, y, z) in d:
        return d[(x, y, z)]
    xm, ym, zm = x%2, y%2, z%2
    if xm ^ ym != zm:
        d[(x, y, z)] = inf
        return inf
    if x^y == z:
        d[(x, y, z)] = 0
        return 0
    Rz = 2*it(x>>1, y>>1, z>>1)
    Ro = inf
    if x:
        Ro = 2*it((x-1)>>1, (y+1)>>1, z>>1)+1
    Rz = min(Rz, Ro)
    d[(x, y, z)] = Rz
    return Rz

r = it(X[0], X[1], t^X[0]^X[1])
if 0 <= r < X[0]:
    print(r)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
N, = map(int, input().split())
X = list(map(int, input().split()))
S = X[0]+X[1]
T = 0
for i in range(2, N):
    T ^= X[i]
if S<T or (S-T)%2:
    print(-1)
    sys.exit()
D = (S-T)//2
if D&T:
    print(-1)
    sys.exit()
M = T.bit_length()+1
if D > X[0]:
    print(-1)
    sys.exit()
Y = 0
for i in range(M, -1, -1):
    if T & (1<<i) and ((1<<i)|Y)^D <= X[0]:
        Y = (1<<i)|Y
if a == 0:
    print(-1)
else:
    print(X[0]-a)
Problem p02632 (python)

Fixed submission:
import sys
readline = sys.stdin.readline
MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci

frac, fraci = frac(2341398)
def cmb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD

K, = map(int, input().split())
t = len(input().strip())

R = 0
for x in range(K+1):
    R += cmb(K+t-x-1, t-1)*pow(25, K-x, MOD)*pow(26, x, MOD)%MOD
    R %= MOD
print(R)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci

frac, fraci = frac(1341398)
def cmb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD

K, = map(int, input().split())
t = len(input().strip())

R = 0
for x in range(K+1):
    R += cmb(K+t-x-1, t-1)*pow(25, K-x, MOD)*pow(26, x, MOD)%MOD
    R %= MOD
print(R)
Problem p02697 (python)

Fixed submission:
N, M = map(int, input().split())
if N%2:
    for i in range(1, M+1):
        print(i, N-i)
else:
    if M%2:
        for i in range(1, M+1):
            if i <= -(-(N//2)//2):
                print(i, N-i+1)
            else:
                print(i+1, N-i+1)
    else:
        for i in range(1, M+1):
            if i < -(-(N//2)//2):
                print(i, N-i+1)
            else:
                print(i+1, N-i+1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if N%2:
    for i in range(1, M+1):
        print(1/0)
        print(i, N-i)
else:
    for i in range(1, M+1):
        if i <= -(-(N//2)//2):
            print(i, N-i+1)
        else:
            print(i+1, N-i+1)