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

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ruiseki = 0
count = 0
for i in range(n-1):
    ruiseki += a[i]
    count += ruiseki * a[i+1]
mod = 10**9 + 7
if count >= mod:
    print(count%mod)
else:
    print(count)

Buggy submission (verdict: Runtime Error):
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    if lst[i] not in d_lst:
        if lst[i] == lst[i+1]:
            d_lst.append(lst[i])
for d in d_lst:
    count += d**2
lst = list(set(lst))

for i in range(len(lst)):
    for j in range(i+1,len(lst)):
        a = lst[i] * lst[j]
        count += a

if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

Buggy submission (verdict: Runtime Error):
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    if lst[i] not in d_lst:
        if lst[i] == lst[i+1]:
            d_lst.append(lst[i])
for d in d_lst:
    count += d**2
lst = set(lst)

for i in range(len(lst)):
    for j in range(i+1,len(lst)):
        a = lst[i] * lst[j]
        count += a

if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

Buggy submission (verdict: Runtime Error):
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    for j in range(i+1,len(lst)):
    # print(i,j)
        a = lst[i] * lst[j]
        if lst[j] in d_lst:
            continue
        else:
            if lst[i] == lst[j]:
                d_lst.apend(lst[j])
                count += a
            else:
                count += a
    
if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)
Problem p02595 (python)

Fixed submission:
n, d = map(int, input().split())
lst = [[int(j) for j in input().split()] for i in range(n)]
count = 0
for x in lst:
  distance = (x[0]**2 + x[1]**2)**0.5
  if distance <= d:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
lst = [[int(j) for j in input().split()] for i in range(n)]
count = 0
for d in lst:
  distance = (d[0]**2 + d[1]**2)**0.5
  if distance <= d:
    count += 1
print(count)
Problem p02622 (python)

Fixed submission:
s = input()
t = input()
def hamming_dist(str1,str2):
    ans = 0
    a,b = len(str1),len(str2)
    if a > b:
        ans = a - b
        length = b
    elif a < b:
        ans = b - a
        length = a
    else:
        length = a
    for i in range(length):
        if str1[i] != str2[i]:
            ans += 1
    return ans
print(hamming_dist(s,t))

Buggy submission (verdict: Runtime Error):
s = input()
t - input()
def hamming_dist(str1,str2):
    ans = 0
    a,b = len(str1),len(str2)
    if a > b:
        ans = a - b
        length = b
    elif a < b:
        ans = b - a
        length = a
    else:
        length = a
    for i in range(length):
        if str1[i] != str2[i]:
            ans += 1
    return ans
print(hamming_dist(s,t))
Problem p02659 (python)

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

a = int(a)
b = int(round(float(b) * 100))

print(a*b//100)

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

A = int(A)
B = int(round(float(B) * 100))

print(a*b//100)

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

print(int(a*b))
Problem p02699 (python)

Fixed submission:
s,w = map(int,input().split())
if s > w:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
s,w = map(int,input.split())
if s > w:
  print("saffe")
else:
  print("unsafe")
Problem p02753 (python)

Fixed submission:
s = input()
if s == 'AAA' or s == 'BBB':
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
s = intput()
if s == 'AAA' or s == 'BBB':
  print('No')
else:
  print('Yes')
Problem p02829 (python)

Fixed submission:
# https://atcoder.jp/contests/abc148/tasks/abc148_a


def main():
    ans = [1,2,3]
    a = int(input())
    b = int(input())
    ans.remove(a)
    ans.remove(b)
    print(ans[0])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc148/tasks/abc148_c
import fractions
# math.gcdは3.5からなのでAtCoderで使えない
# import math


def main():
    (a, b) = [int(i) for i in input().split(" ")]
    print(int(a * b / fractions.gcd(a, b)))


if __name__ == '__main__':
    main()
Problem p02831 (python)

Fixed submission:
# https://atcoder.jp/contests/abc148/tasks/abc148_c
import fractions
# math.gcdは3.5からなのでAtCoderで使えない
# import math


def main():
    (a, b) = [int(i) for i in input().split(" ")]
    print(int(a * b / fractions.gcd(a, b)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc148/tasks/abc148_c
import math


def main():
    (a, b) = [int(i) for i in input().split(" ")]
    print(int(a * b / math.gcd(a, b)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc148/tasks/abc148_c
import math


def main():
    (a, b) = [int(i) for i in input().split(" ")]
    print(a * b // math.gcd(a, b))
    


if __name__ == '__main__':
    main()
Problem p02793 (python)

Fixed submission:

import fractions as fr
import functools as ft
#import math as fr


prime = 10**9+7

n = int(input())
an = list( map( int, input().split() ))

an.sort()


lcm_ = 1
for a in an :
    lcm_ = a*lcm_ // fr.gcd(a, lcm_)
#    print(lcm_)
    
#ans = 0
#for a in an:
#    ans += lcm_ // a
#    ans = ans % prime if ans >= prime else ans

ans = ft.reduce(lambda x,y: (x + lcm_//y), an ,0 )

print(ans%prime)

Buggy submission (verdict: Runtime Error):

import fractions as ft
#import math as ft


prime = 10**9+7

n = int(input())
an = list( map( int, input().split() ))

an.sort()


lcm_ = 1
for a in an :
    lcm_ = a*lcm_ // ft.gcd(a,lcm_)
#    print(lcm_)
    
ans = 0
for i, a in an:
    t = lcm_ // a
    ans += t 
    ans = ans % prime if ans >= prime else ans

print(ans)

Buggy submission (verdict: Runtime Error):

import fractions as ft
#import math as ft


prime = 10**9+7

n = int(input())
an = list( map( int, input().split() ))

an.sort()


lcm_ = 1
for a in an :
    lcm_ = a*lcm_ // ft.gcd(a,lcm_)
#    print(lcm_)
    
ans = 0
for i, a in an:
    t = lcm_ // a
    ans += t 
    ans = ans - prime if ans >= prime else ans

print(ans)

Buggy submission (verdict: Runtime Error):

import functools as ft
#import math as ft


prime = 10**9+7

n = int(input())
an = list(map( int, input().split() ))

an.sort()


lcm_ = 1
for a in an :
    lcm_ = a*lcm_//ft.gcd(a,lcm_)
#    print(lcm_)
    
ans = 0
bn = [0]*n
for i, a in enumerate(an):
    t = lcm_//a
    ans += t 
    ans %= prime

print(ans)
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
an = [0]*m

for i in range(m):
#    s = input()
    an[i] = int( input() )
#an[-1] = n

#an.sort()
disjoint = False
for i in range(len(an)-1):
    if an[i] + 1 == an[i+1]:
        disjoint = True


if disjoint:
    print(0)

else:

    mod = 10**9+7
    tab = [0]*(10**5+10)
    tab[0] = 0
    tab[1] = tab[2]= 1

    for i in range(3, len(tab)):
        tab[i] = tab[i-1]+tab[i-2]
#        if i<100:
#            print(tab[i])

    an.append(n)
    prev = 0
    ans = 1
    for a in an:
        index = a-prev + (1 if a == n else 0)
#        print(a,prev,index,tab[index])
        ans *= tab[index]
        ans %= mod
        prev = a+1

    #ans *= tab[n - prev]
    #ans %= 1000000007

    print(ans)

Buggy submission (verdict: Runtime Error):

n, m = map(int, input().split())
an = [0]*m

for i in range(m):
#    s = input()
    an[i] = int( input() )
#an[-1] = n

#an.sort()
disjoint = False
for i in range(len(an)-1):
    if an[i] + 1 == an[i+1]:
        disjoint = True





if disjoint:
    print(0)

else:

    mod = 10**9+7
    tab = [0]*(10**5+1)
    tab[0] = 0
    tab[1] = tab[2]= 1

    for i in range(3, len(tab)):
        tab[i] = tab[i-1]+tab[i-2]
#        if i<100:
#            print(tab[i])

    an.append(n)
    prev = 0
    ans = 1
    for a in an:
        index = a-prev + (1 if a == n else 0)
#        print(a,prev,index,tab[index])
        ans *= tab[index]
        ans %= mod
        prev = a+1

    #ans *= tab[n - prev]
    #ans %= 1000000007

    print(ans)

Buggy submission (verdict: Runtime Error):

n, m = map(int, input().split())
an = [0]*m

for i in range(m):
#    s = input()
    an[i] = int( input() )
#an[-1] = n

#an.sort()
disjoint = False
for i in range(len(an)-1):
    if an[i] + 1 == an[i+1]:
        disjoint = True





if disjoint:
    print(0)

else:

    mod = 10**9+7
    tab = [0]*(10**5+1)
    tab[0] = 0
    tab[1] = tab[2]= 1

    for i in range(3, len(tab)):
        tab[i] = tab[i-1]+tab[i-2]
#        if i<100:
#            print(tab[i])

    an.append(n)
    prev = 0
    ans = 1
    for a in an:
        index = a-prev + (1 if a == n else 0)
        print(a,prev,index,tab[index])
        ans *= tab[index]
        ans %= mod
        prev = a+1

    #ans *= tab[n - prev]
    #ans %= 1000000007

    print(ans)
Problem p03209 (python)

Fixed submission:

# This src was written after reading editional.pdf .

n, x = map(int, input().split())


an, pn = [1], [1]

for i in range(n):
    an.append(2*an[i]+3)
    pn.append(2*pn[i]+1)

#print(an)

def f(n,x):

    #print(n,x)

    if n == 0:
        return 1 if 0<x else 0
    
    if x <= an[ n-1 ] + 1:
        return f( n-1, x-1 )

    else:# x <= 2*an[n-1] + 3:
        return f(n-1, x-an[n-1]-2) + pn[n-1] + 1


print(f(n,x))

    
#    else if: 
#        pass

Buggy submission (verdict: Runtime Error):

import math

n, x = map(int,input().split())

def rec(lv,ls):
    if lv == 0:
        return [1]
    else:
        ret = rec(lv-1,ls)
        for i in range(0,len(ret) -1):
            if ret[i]>0 and ret[i+1]>0:
                ret[i+1] += ret[i]
                ret[i] = 0  #deleted tag

        while 0 != ret.count(0):
            ret.remove(0)

        return [-1,*ret,1,*ret,-1]

#print( rec(n, list()) )


count = 0
for e in rec(n, list() ):
    abs_e = abs(e)

    if x == 0:
        break

    if x>=abs_e:
        x -= abs_e
        count += e if e>0 else 0
    else:
        count += x if e>0 else 0
        x = 0
    #print(x," ",count)

print(count)

Buggy submission (verdict: Runtime Error):

n, x = map(int,input().split())

def rec(lv,ls):
    if lv == 0:
        return [1]
    else:
        ret = rec(lv-1,ls)
        for i in range(0,len(ret) -1):
            if ret[i]>0 and ret[i+1]>0:
                ret[i+1] += ret[i]
                ret[i] = 0  #deleted tag

        while 0 != ret.count(0):
            ret.remove(0)
        return [-1,*ret,1,*ret,-1]

#print( rec(n, list()) )


count = 0
for e in rec(n, list() ):
    abs_e = abs(e)

    if x == 0:
        break

    if x>=abs_e:
        x -= abs_e
        count += e if e>0 else 0
    else:
        count += x if e>0 else 0
        x = 0
    #print(x," ",count)

print(count)

Buggy submission (verdict: Runtime Error):

n, x = map(int,input().split())

def rec(lv,ls):
    if lv == 0:
        return [1]
    else:
        ret = rec(lv-1,ls)
        for i in range(0,len(ret) -1):
            if ret[i]>0 and ret[i+1]>0:
                ret[i+1] += ret[i]
                ret[i] = 0  #deleted tag

        while 0 != ret.count(0):
            ret.remove(0)
        return [-1,*ret,1,*ret,-1]

 
count = 0
for e in rec(n, list() ):
    abs_e = abs(e)
    if x>=abs_e:
        x -= abs_e
        count += e if e>0 else 0
    else:
        count += e if e>0 else 0


print(count)
Problem p04005 (python)

Fixed submission:

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

lst = [a,b,c]

cnt = len(list( filter(lambda x:x%2==0,lst)))

if(0<cnt):
    print(0)
else:
    lst.sort()

    res = 0
    if(lst[2]%2 == 1):  
        res = lst[0]*lst[1]
    else:
        res = 0

    print(res)

Buggy submission (verdict: Runtime Error):

N,x = map(int,input().split())

lst = list( map(int,input().split() ) )

ans = sum(lst)

dp = lst[:]

#print(N,x)
#print(lst)


for i in range(1,N):
    tmp = 0
    for k in range(0,N):
        index_ = 0
        if(0 <= k-i):
            index_ = k-i
        else:
            index_ = N-i+k
        dp[k] = min(dp[k],lst[index_])
        tmp = tmp+dp[k]
    tmp = tmp + x*i
    ans = min(ans,tmp)

print(ans)

Buggy submission (verdict: Runtime Error):

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

lst = [a,b,c]

cnt = len(list( filter(lambda x:x%2==0,lst)))

if(0<cnt):
    print(0)
else:
    lst.sort()

    res = 0
    if(lst[2]%2 == 1):  
        res = lst[0]*lst[1]
    else:
        res = 0

    prin
Problem p02552 (python)

Fixed submission:
x = int(input())
if x == 1:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
x = int(input())
if x == 1:
  print(0)
else if x == 0:
  print(1)
Problem p02547 (python)

Fixed submission:
N = int(input())

xy = [map(int,input().split()) for _ in range(N)]
x,y = [list(i) for i in zip(*xy)]

ans = 0
flag = False

for i in range(N):
    if x[i] == y[i]:
        ans +=1
    elif ans >= 3:
        flag = True
        ans = 0
    else:
        ans = 0
        
if ans >= 3  or flag ==True:
    print("Yes")
    
else:
    print("No")

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

xy = [map(int,input().split()) for _ in range(N)]
x,y = [list(i) for i in zip(*xy)]

ans = 0

for i in range(N):
    if x[i] == y[i]:
        ans +=1
    elif ans >= 3:
        flag = True
        ans = 0
    else:
        ans = 0
        
if ans >= 3 or flag ==True:
    print("Yes")
    
else:
    print("No")

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

xy = [map(int,input().split()) for _ in range(N)]
x,y = [list(i) for i in zip(*xy)]

ans = 0

for i in range(N):
    if x[i] == y[i]:
        ans +=1
    elif ans >= 3:
        flag = True
    else:
        ans = 0
        
if ans >= 3 or flag ==True:
    print("Yes")
    
else:
    print("No")
Problem p02629 (python)

Fixed submission:
N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(num2alpha(N).lower())

Buggy submission (verdict: Runtime Error):
N = int(input())
l = []
alpha = "abcdefghijklmnopqrstuvwxyz"
d = {i+1: a for i, a in enumerate(alpha)}
while N != 0:
    l.append(N % 26)
    N = N // 26
ans = []
for i in l[::-1]:
    ans.append(d[i])
print("".join(ans))
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()
if S == U:
    A -= 1
elif T == U:
    B -= 1
print("{} {}".format(A, B))

Buggy submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()
if S == U:
    A -= 1
elif T == U:
    B -= 1
print(f"{A} {B}")

Buggy submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()
if S == U:
    A -= 1
elif T == U:
    B -= 1
print(f"{A} {B}")
Problem p02935 (python)

Fixed submission:
N = int(input())
V = list(map(int, input().split()))
V.sort()

ans = (V[0] + V[1]) / 2
for i in range(2, len(V)):
    ans = (ans + V[i]) / 2
print(ans)

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

ans = (V[0] + V[1]) / 2
for i in range(2, len(V) - 1)::
    ans = (ans + V[i]) / 2
print(ans)
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key = lambda x:-x[1])
i = 0
for b, c in BC:
    for j in range(b):
        if A[i] < c:
            A[i] = c
            i += 1
        else:
            break
        if i >= N:
            break
    if i >= N:
        break
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key = lambda x:-x[1])
i = 0
for b, c in BC:
    for j in range(b):
            if A[i] < c:
                A[i] = c
                i += 1
            else:
                break
print(sum(A))
Problem p02623 (python)

Fixed submission:
import numpy as np

n,m,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))

ak=np.cumsum(a,dtype=np.int64)
bk=np.cumsum(b,dtype=np.int64)
ak=ak[ak<=k]
bk=bk[bk<=k]
lak=len(ak)
lbk=len(bk)

an=lak
j=0
for i in range(lak-1,-1,-1):
    while bk[j]+ak[i]<=k:
        an=max(an,i+j+2)
        j+=1
        if j>=lbk:
            j-=1
            break
an=max(an,lbk)

print(an)

Buggy submission (verdict: Runtime Error):
import sys

def syoki(k,skk,atk,):
    sks=ats=0
    for i in range(len(skk)):
        if skk[i]<=k:
            sks=i+1
        else:
            break
    for i in range(len(atk)):
        if atk[i]+skk[sks-1]<=k:
            ats=i+1
        else:
            break
    return(sks,ats)

def keisan(o,s,k,ok,sk,os,ss):
    swk=ss
    for i in range(os-2,-1,-1):
        while k> ok[i]+sk[swk]:
            swk+=1
            if swk<s:
                break
    return max(os+ss,i+swk)

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ak=[]
aa=0
for i in a:
    aa+=i
    ak.append(aa)
bk=[]
bb=0
for i in b:
    bb+=i
    bk.append(bb)

xa,xb=syoki(k,ak,bk)
yb,ya=syoki(k,bk,ak)
if xa+xb>yb>ya:
    ass=xa
    bs=xb
else:
    ass=ya
    bs=yb

wk=ass+bs

if wk==n+m:
    print(n+m)
    sys.exit()
if ass ==0 and bs==0:
    print(0)
    sys.exit()
if ass>bs:
    an=keisan(n,m,k,ak,bk,ass,bs)
else:
    an=keisan(m,n,k,bk,ak,bs,ass)

print(an)

Buggy submission (verdict: Runtime Error):
import sys

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ak=[]
aa=0
for i in a:
    aa+=i
    ak.append(aa)
bk=[]
bb=0
for i in b:
    bb+=i
    bk.append(bb)
ass=bs=0
for i in range(len(ak)):
    if ak[i]<=k:
        ass=i+1
    else:
        break
for i in range(len(bk)):
    if bk[i]+ak[ass-1]<=k:
        bs=i+1
    else:
        break
wk=ass+bs
aswk=ass
bswk=bs
if wk==n+m:
    print(n+m)
    sys.exit()

for i in range(ass-2,-1,-1):
    while k> ak[i]+bk[bswk]:
        bswk+=1
        if bswk<=m:
            break
an = max(ass+bs,i+bswk)        
        
print(an)

Buggy submission (verdict: Runtime Error):
import sys

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ak=[]
aa=0
for i in a:
    aa+=i
    ak.append(aa)
bk=[]
bb=0
for i in b:
    bb+=i
    bk.append(bb)
ass=bs=0
for i in range(len(ak)):
    if ak[i]<=k:
        ass=i+1
    else:
        break
for i in range(len(bk)):
    if bk[i]+ak[ass-1]<=k:
        bs=i+1
    else:
        break
wk=ass+bs
aswk=ass
bswk=bs
if wk==n+m:
    print(n+m)
    sys.exit()

while aswk>1:
    aswk-=1
    while k< ak[aswk-1]+bk[bswk-1]:
        if bswk <=m:
            bswk+=1
        else:
            break
    if bs<=bswk-1:
        bs=bswk
        ass=aswk
    else:
        break        
print(ass+bs)
Problem p02629 (python)

Fixed submission:
n = int(input())

nn=n
i=1
while nn > 26**i:
    nn-=26**i
    i+=1

an=['a']*i
j=0
while n:
    n-=1
    wk=n%26
    an[j]=(chr(ord('a')+wk))
    n = n//26
    j+=1
    
an.reverse()
print(''.join(an))

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

nn=n
i=1
while nn >26**i:
    i+=1
    nn-=26**i

an=['a']*i
j=0
while n:
    n-=1
    wk=n%26
    an[j]=(chr(ord('a')+wk))
    n= n//26
    j+=1
    
an.reverse()
print(''.join(an))

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

an =[]

for i in range(11):
    if 26**(10-i)<=n and i<=10:
        wk = n//26**(10-i)
        n=n%26**(10-i)
        an.append(chr(wk%26+96))
    else:
        an.append(chr(n+96))
print(''.join(an))
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
a,b =map(Decimal,input().split())

print(int(a*b))

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

print((a*int(b)//100)
Problem p02707 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
al = [0 for i in range(n)]

for i in a:
    al[i-1] += 1
for i in range(n):
    print(al[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
al = [0 for i in range(n)]

for i in a:
    al[a[i]-1] += 1
for i in range(n):
    print(al[i])

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

Fixed submission:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result % (10 ** 9 + 7)
ab = input().split()
a, b = int(ab[0]), int(ab[1])
sum = a + b
if a>(2*b) or b>(2*a):
	print("0")
elif sum % 3 == 0:
    n = int(sum / 3)
    m = b - n
    print(cmb(n, m))
else:
	print("0")

Buggy submission (verdict: Runtime Error):
import math
ab = input().split()
a, b = int(ab[0]), int(ab[1])
n=int((a+b)/3)
m=a-n
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(n, m))
Problem p02990 (python)

Fixed submission:
import math
 
stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])
 
ans1 = 1 * (n-k +1 )
ansi = 0
ansi = int(ans1)
print(ansi)
for i in range(2,k+1):
    ansi = ansi * (k- i + 1) // int( i - 1 ) *  (n-k - i + 2) // int(i) 
    type(ansi)
    print(int(ansi % int(1000000007)))

Buggy submission (verdict: Runtime Error):
import math
 
stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])
 
ans1 = 1 * (n-k +1 )
ansi = 0
ansi = ans1
print(ansi)
for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Buggy submission (verdict: Runtime Error):
import math
 
stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])
 
ans1 = 1 * (n-k +1 )
ansi:int = 0
ansi = ans1
print(ansi)
 
for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Buggy submission (verdict: Runtime Error):
import math
 
stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])
 
ans1 = 1 * (n-k +1 )
ansi:int = ans1
print(ansi)
 
for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Buggy submission (verdict: Runtime Error):
import math
 
stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])
 
ans1 = 1 * (n-k +1 )
ansi = ans1
print(ansi)
 
for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Buggy submission (verdict: Runtime Error):
import math

stri = input()
ary = stri.split()
n:int = int(ary[0])
k:int = int(ary[1])

ans1=int( 1 * (n-k +1 ))
ansi:int= int(ans1)
print(ansi)

for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Buggy submission (verdict: Runtime Error):
import math

stri = input()
ary = stri.split()
n:int = int(ary[0])
k:int = int(ary[1])

ans1:int =int( 1 * (n-k +1 ))
ansi:int = int(ans1)
print(ansi)

for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Buggy submission (verdict: Runtime Error):
import math

stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])

ans1 = 1 * (n-k +1 )
ansi = ans1
print(ansi)

for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))