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

Fixed submission:
input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input() # 無視

equalized = 1
i = 0
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(str(i))

Buggy submission (verdict: Runtime Error):
import math
 
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
if N == K:
    print(1)
    quit()
else:
    one_index = A.index(1)
    l = one_index #1の左側にある数字の数
    r = N - one_index - 1 #1の右側にある数字の数
 
    assert N % 3 == 0

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

if N == K:
    print(1)
    quit()
else:
    one_index = A.index(1)
    l = one_index #1の左側にある数字の数
    r = N - one_index - 1 #1の右側にある数字の数

    assert l < r

    print(114514)

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

if N == K:
    print(1)
    quit()
else:
    one_index = A.index(1)
    l = one_index #1の左側にある数字の数
    r = N - one_index - 1 #1の右側にある数字の数

    assert r % 3 == 1
    
    print(114514)

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

if N == K:
    print(1)
    quit()
else:
    one_index = A.index(1)
    l = one_index #1の左側にある数字の数
    r = N - one_index - 1 #1の右側にある数字の数

    assert r % 3 == 0
    
    print(114514)

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

if N == K:
    print(1)
    quit()
else:
    one_index = A.index(1)
    l = one_index #1の左側にある数字の数
    r = N - one_index - 1 #1の右側にある数字の数

    assert l % 3 == 0
    
    print(114514)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K == 3
 
print(114514)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K == 3
assert N < 100
 
print(114514)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K > 3
 
print(114514)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K > 2
 
print(114514)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K > 5
 
print(114514)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K > 10
 
print(114514)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K > 50
 
print(114514)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

assert K > 100

print(114514)
Problem p02682 (python)

Fixed submission:
A, B, C, K =map(int, input().split())
print(min(A, K) - max(0, K - A - B))

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

ans = 0
while a > 0:
  a - 1
  k - 1
  ans += 1
  if k = 0:
    brake
  if a = 0:
    brake
while b > 0:
  b - 1
  k - 1
  ans += 0
  if k = 0:
    brake
  if b = 0:
    brake
while c > 0:
  c - 1
  k - 1
  ans -= 1
  if k = 0:
    brake
  if c = 0:
    brake
Problem p02793 (python)

Fixed submission:
N = int(input())
listA = list(map(int, input().split(' ')))

from fractions import gcd

tmp_lcm = 1
sumB = 0
for i in listA:
  tmp_gcd = gcd(tmp_lcm, i)
  next_lcm = (tmp_lcm * i) // tmp_gcd
  sumB = sumB * (next_lcm // tmp_lcm) + (next_lcm // i)
  tmp_lcm = next_lcm

print(sumB % (10 ** 9 + 7))

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

from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

total_times = 1
for i in listA:
  total_times = total_times * i

result = 0
prev = 1
for i in listA:
  result += total_times / i

print(int(result * lcm(listA) / total_times % (10 ** 9 + 7)))

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

from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

total_times = 1
for i in listA:
  total_times = total_times * i

result = 0
prev = 1
for i in listA:
  result += total_times / i

print(int(result * lcm(a) / total_times % (10 ** 9 + 7)))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a < 3200:
  print('red')
else:
  print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
s = int(input())

if a < 3200:
  print('red')
else:
  print(s)
Problem p03631 (python)

Fixed submission:
N = str(input())
start = 0
end = len(N) - 1
result = True

while start < end: 
    if N[start] == N[end]: 
        start += 1
        end -= 1
    else:
        result = False
        break

if result:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
start = 0
end = len(N) - 1
result = True

while start < end: 
    if N[start] == N[end]: 
        start += 1
        end -= 1
    else:
        result = False
        break

return result

Buggy submission (verdict: Runtime Error):
start = 0
end = len(N) - 1
result = True

while start < end: 
    if N[start] == N[end]: 
        start += 1
        end -= 1
    else:
        result = False
        break

return resul

Buggy submission (verdict: Runtime Error):
start = 0
end = len(N) - 1
result = True

while start < end: 
    if N[start] == N[end]: 
        start += 1
        end -= 1
    else:
        result = False
        break

return result
Problem p02819 (python)

Fixed submission:
X = int(input())
for i in range(X, 9999999999999999):
    flag = 1
    for j in range(2, X//2 +1):
        if i % j == 0:
            flag = -1
            break
    if X == 2:
        print(2)
        break
    elif X == 3:
        print(3)
        break
    elif flag == 1:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
X = int(input())
for i in range(X+1, 9999999999999999):
    flag = 1
    for j in range(2, X//2 +1):
        if i % j == 0:
            flag = -1
            break
    # if X == 2:
    #     print(2)
    #     break
    # elif X == 3:
    #     print(3)
    #     break
    elif flag == 1:
        print(i)
        break
Problem p02777 (python)

Fixed submission:
S,U = map(str,input().split())
M,N = map(int,input().split())
a = str(input())
if S == a:
  print(M-1,N)
else:
  print(M,N-1)

Buggy submission (verdict: Runtime Error):
N,*a = map(int,open(0).read().split())
a.sort()
flag = True
for i in range(1,N):
  if a[i]==a[i-1]:
    print('NO')
    flag=False
    break
if flag ==True:
  print('YES')
Problem p02859 (python)

Fixed submission:
r = int(input())

print(int(r**2))

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

print(int(r**2))
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
flag = 0
if n%2 == 0:
    m = int(n/2)
    for i in range(m):
        if s[i] != s[m+i]:
            flag = 1

    if flag == 1:
        print("No")
    else:
        print("Yes")

else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
flag = 0
if n%2 == 0:
    m = n/2
    for i in range(m):
        if s[i] != s[m+i]:
            flag = 1
    
    if flag == 1:
        print("No")
    else:
        print("Yes")
    
else:
    print("No")
Problem p02881 (python)

Fixed submission:
import math

n = int(input())
ans = n-1

for i in range(1, math.floor(math.sqrt(n))+1):
  if n % i == 0:
    ans = min(ans, (i+(n/i)-2))
      
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

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())
l = make_divisors(n)

ans = 999999999999999999
for i in range(0, len(l), 2):
  a = l[i]
  b = l[i+1]
  ans = min(ans,(a+b-2))
  
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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())
l = make_divisors(n)
ans = 999999999999999999
for i in range(0,len(l), 2):
  a = l[i]
  b = l[i+1]
  ans = min(ans,(a+b-2))
  
print(ans)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = str(input())

if a >= 3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
s = string(input())

if a >= 3200:
  print(s)
elif:
  print('red')
Problem p03803 (python)

Fixed submission:
a, b = map(int, input().split())

if a == b:
  print('Draw')
elif a == 1:
  print('Alice')
elif b == 1:
  print('Bob')
elif a < b:
  print('Bob')
elif a > b:
  print('Alice')

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

if:
  print('Draw')
elif a == 1:
  print('Alice')
elif b == 1:
  print('Bob')
elif a < b:
  print('Bob')
elif a > b:
  print('Alice')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a < b:
  print('Bob')
elif a > b:
  print('Alice')
else:
  print('Draw')
Problem p02701 (python)

Fixed submission:
n = int(input())
a = []
ans = 0
for i in range(n):
    b = input()
    a+=[b]
c = sorted(a)
b = 0
for i in range(n-1):
    if c[i] == c[i+1]:
        b += 1

print(n-b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [[""for i in range(10)]for j in range(26)]
dic = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans = 0
for i in range(n):
    b = input()
    p = dic.index(b[0])
    q = len(b)
    if b not in a[p][q]:
        a[p][q] += b
        ans += 1
print(ans)
Problem p02759 (python)

Fixed submission:
n = int(input())+1
ans = int(n/2)
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
ans = 0

if n % 2 == 0:
    ans = n/2
else:
    ans = int(n/2) + 1

print(ans)
Problem p02831 (python)

Fixed submission:
import fractions

# 最小公倍数lcm（ least common multiple）を返す関数は用意されていない
# が、lcm(a, b) = a * b / gcd(a, b)で求められる

A, B = map(int, input().split())
ans = A * B // fractions.gcd(A, B)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

# 最小公倍数lcm（ least common multiple）を返す関数は用意されていない
# が、lcm(a, b) = a * b / gcd(a, b)で求められる

A, B = map(int, input().split())
ans = A * B // math.gcd(A, B)
print(ans)
Problem p02847 (python)

Fixed submission:
S = input()

X = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7 - X.index(S))

Buggy submission (verdict: Runtime Error):
S = input()

X = [SUN,MON,TUE,WED,THU,FRI,SAT]
print(7 - X.index(S))
Problem p02773 (python)

Fixed submission:
from collections import Counter
n=int(input())
a=[input() for _ in range(n)]
c=Counter(a)
max_cnt=max(c.values())
names=[name for name,v in c.items() if v==max_cnt]
names.sort()
print(*names,sep='\n')

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=[input() for _ in range(n)]
c=Counter(s)
sort(c.items())
max_cnt=max(c.values())
names=[name for k,v in c if v==max_cnt]
print(names)
Problem p02820 (python)

Fixed submission:

def win(n):
	if n=='r':
		return p
	elif n=='s':
		return r
	else:
		return s

n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
score=0
for i in t:
	score += win(i)

hands=list(t)

for i in range(n):
	if i+k<n:
		if hands[i]==hands[i+k]:
			score-=win(hands[i+k])
			hands[i+k]='x'
print(score)

Buggy submission (verdict: Runtime Error):
#149d

def win(n):
	if n=='r':
		return p
	elif n=='s':
		return r
	else:
		return s

n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
score=0
for i in t:
	score += win(i)

#hands=list(t)

for i in range(n):
	if i+k<n:
		if t[i]==t[i+k]:
			score-=win(t[i+k])
			t[i+k]='x'
print(score)
Problem p02833 (python)

Fixed submission:
n=int(input())
cnt=0
div=5
if n%2!=0:
	print(0)
	exit()
else:
	n//=2
	while n>=1:
		n//=div
		cnt+=n
#print(ans)
print(cnt)

Buggy submission (verdict: Runtime Error):
def cal(n):
	#dp=[]
	if n<2:
		return 1
	else:
		return n*cal(n-2)

n=int(input())
ans=cal(n)
cnt=0
while ans%10==0:
	ans//=10
	cnt+=1
#print(ans)
print(cnt)
Problem p03042 (python)

Fixed submission:
s=input()
f=int(s[:2])
b=int(s[2:])
if f>=13 or f==0:
	if 0<b and b<13:
		print("YYMM")
	else:
		print("NA")
elif 0<f and f<13:
	if 0<b and b<13:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	print("NA")

Buggy submission (verdict: Runtime Error):
s=input()
f=int(s[:2])
b=int(s[3:])
if f>13:
	if 0<b and b<13:
		print("YYMM")
	else:
		print("NA")
else:
	if 0<b and b<13:
		print("AMBIGUOUS")
	else:
		prinr("MMYY")
Problem p03075 (python)

Fixed submission:
x=[int(input()) for _ in range(5)]
k=int(input())
max=max(x)
min=min(x)
if max-min <= k:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
x=[int(intput()) for _ in range(5)]
k=int(input())
max=max(x)
min=min(x)
if max-min < k:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
x=[int(intput() for _ in range(5))]
k=int(input())
max=max(x)
min=min(x)
if max-min < k:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
an=[int(x) for x in input().split()]
k=an[-1]
max=max(an[:-2])
min=min(an[:-2])
if max -min < k:
    print("Yay!")
else:
    print(":()")
Problem p02659 (python)

Fixed submission:
import math
from decimal import Decimal
A,B = map(Decimal,input().split())
X = math.floor(A * B)
print(X)

Buggy submission (verdict: Runtime Error):
A,B = map(float,input().split())
X = math.floor(A * B)
print(X)

Buggy submission (verdict: Runtime Error):
A,B = map(float,input().split())
X = math.floor(A * B)
print(X)
Problem p02753 (python)

Fixed submission:
S = input()
if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
S = input()
if S = "AAA" or S = "BBB":
  print("NO")
else:
  print("YES")
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
  if i % k == 0:
    print("OK")
    break
else:
  print("NG")

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

s = (B // K) * K
if s => A: #もし最大のKの倍数がA以上ならOK
    print("OK")
else:
    print("NG")

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

s = (B // K) * K
if B => A: #もし最大のKの倍数がA以上ならOK
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
k=int(input())
a, b=map(int, input().split())
for i in range(a, b+i):
  if i % k == 0:
    print("OK")
    break
else:
  print("NG")
Problem p02987 (python)

Fixed submission:

a = input()
dic = {}
if len(set(a)) == 2:
    for i in range(len(a)):
        if a[i] not in dic:
            dic.setdefault(a[i], 1)
        else:
            dic[a[i]] += 1
            if dic[a[i]] > 2:
                print('No')
                break
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
a = list(input())
s  = set(a)
if len(s) == 2 and a.count(s[0]) == a.count(s[1]):
  print('Yes')
else:
  print('No')
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb
n, k = map(int, input().split())
for i in range(1, k+1):
	print( comb(k-1, i-1, exact=True)*comb(n-k+1, i, exact=True)%(10**9+7) )

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb
n, k = map(int, input().split())
for i in range(1, k+1):
	print( comb(k-1, i-1, exact=True)*comb(n-k+1, i, exact=True)%(10**9+7) )
Problem p03012 (python)

Fixed submission:
ans=10**10
n=int(input())
w=list(map(int,input().split()))
for i in range(1,n):
    ans=min(ans,abs(sum(w[:i])-sum(w[i:])))

print(ans)

Buggy submission (verdict: Runtime Error):
ans=10**10
n=int(input())
w=list(map(int,input().split()))
for i in range(1,n):
    ans=min(ans,abs(sum(w[:i])-sum(w[i:])))

print(ans)AC
Problem p03013 (python)

Fixed submission:
N,M = map(int,input().split())
A = set([int(input()) for i in range(M)])
MOD = 10**9+7

if 0 in A:
    print(0)
    exit()

dp = [0]*(N+1)
dp[0] = 1
for i in range(N):
    if i+1 not in A:
        dp[i+1] += dp[i]
        dp[i+1] %= MOD
    if i+2 <= N and i+2 not in A:
        dp[i+2] += dp[i]
        dp[i+2] %= MOD
print(dp[-1])

Buggy submission (verdict: Runtime Error):
ans=10**10
n=int(input())
w=list(map(int,input().split()))
for i in range(1,n):
    ans=min(ans,abs(sum(w[:i])-sum(w[i:])))

print(ans)AC
Problem p03073 (python)

Fixed submission:
s=input()
n=len(s)
ans=0
for i in range(n):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
for i in range(n-1):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n-1):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))A
Problem p04005 (python)

Fixed submission:
import numpy as np
a = map(int,raw_input().split())
a = np.array(a)

if len(a[a % 2==0]) > 0:
  print 0
else:
  m = max(a)
  a = list(a)
  a.remove(m)
  print np.prod(np.array(a))

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy

a = map(int,raw_input().split())

def myfunc(a):
  A.sort(reverse=True)
  if (A[0]%2 != 0 and A[1]%2 !=0 and A[2]%2 != 0):
    print A[1]*A[2]
  else:
    print 0

myfunc(a)
Problem p02912 (python)

Fixed submission:
import heapq

n=list(map(int,input().split()))
m=list(map(int,input().split()))
m = [-x for x in m]
heapq.heapify(m)

for i in range(n[1]):
  x=(-1*m[0])//2
  heapq.heappop(m)
  heapq.heappush(m, -x)

ans=0
for i in range(n[0]):
  ans+=-m[i]

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq

n=list(map(int,input().split()))
m=list(map(int,input().split()))
m = [-x for x in m]
heapq.heapify(m)

for i in range(n[1]):
  x=-m[0]//2
  heapq.heappop(m)
  heapq.heappush(m, -x)

ans=0
for i in range(n[1]):
  ans+=-m[i]
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq

n=list(map(int,input().split()))
m=list(map(int,input().split()))
m = [(-x, x) for x in m]
heapq.heapify(m)

for i in range(n[1]):
  x=m[0][1]//2
  heapq.heappop(m)
  heapq.heappush(m, (-x, x))
  
ans=0

for i in range(n[1]):
  ans+=m[i][1]
  
print(ans)
Problem p02729 (python)

Fixed submission:
n, m = map(int, input().split())
result = (n+m)*(n+m-1)//2 - n*m
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
d = [0]*(n+1)
count = 0
for el in set(a):
    temp = d[el] = a.count(el)
    count += temp*(temp-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0
for el in a:
    count += a.count(el)-1
count //= 2
for el in a:
    print(count - a.count(el)+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0
L = len(a)
for el in a:
    count += a.count(el)-1
count //= 2
for el in a:
    print(count - a.count(el)+1)

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

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

Fixed submission:
def cmb(n, r, p):
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
n = 7*10**5  # N は必要分だけ用意する
N = 2*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)
    if i <= n:
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
X, Y = map(int, input().split())
if (X+Y)%3 != 0:
    result = 0
else:
    n = Y-(X+Y)//3
    m = X-(X+Y)//3
    if n<0 or m<0:
        result = 0
    else:
        result = cmb(n+m, n, p)
print(result)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, p):
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
n = 4*10**5  # N は必要分だけ用意する
N = 2*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)
    if i <= n:
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    
X, Y = map(int, input().split())
if (X+Y)%3 != 0:
    result = 0
else:
    result = cmb((X+Y)//3, Y-(X+Y)//3, p)
print(result)
Problem p03013 (python)

Fixed submission:
import math
import sys
sys.setrecursionlimit(100000)
f = math.factorial
n, m = map(int, input().split())
a = [-1] + [int(input()) for i in range(m)] + [n+1]
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 ** 5  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
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)


count = 1
for i in range(m+1):
    k = a[i+1] - a[i] - 2
    if k == -1:
        count = 0
        break
    else:
        work = 0
        for b in range(k//2+1):
            work += cmb(k-b, b, p)
        count *= work
print(count%p)

Buggy submission (verdict: Runtime Error):
import math
import sys
sys.setrecursionlimit(100000)
f = math.factorial
n, m = map(int, input().split())
a = [-1] + [int(input()) for i in range(m)] + [n+1]
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 ** 4  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
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)


count = 1
for i in range(m+1):
    k = a[i+1] - a[i] - 2
    if k == -1:
        count = 0
        break
    else:
        work = 0
        for b in range(k//2+1):
            work += cmb(k-b, b, p)
        count *= work
print(count%p)
Problem p03127 (python)

Fixed submission:
import fractions
n = int(input())
A = list(map(int, input().split()))
work = A[0]
for i in range(1, n):
    work = fractions.gcd(work, A[i])
print(work)

Buggy submission (verdict: Runtime Error):
import fractions
n = int(input())
A = list(map(int, input().split()))
work = A[0]
for i in range(1, N):
    work = fractions.gcd(work, A[i])
print(work)

Buggy submission (verdict: Runtime Error):
import fractions
n = int(input())
A = list(map(int, input().split())))
work = A[0]
for i in range(1, N):
    work = fractions.gcd(work, A[i])
print(work)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
n = int(input())
A = sorted(list(map(int, input().split())))
print(gcd(*A))