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

Fixed submission:
x = int(input())
if(x >= 30):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = int(inpt())
if(x >= 30):
    print("Yes")
else:
    print("No")
Problem p02688 (python)

Fixed submission:
import numpy as np
n,k = map(int, input().split())
l = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        l[j-1] = 1

print(l.count(0))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k = map(int, input().split())
l = np.zeros(n)
for i in range(k):
    d = int(input())
    a = map(int, input().split())
    for j in range(d):
        l[a[j]-1] = 1
ans = 0
for i in l:
    if(i == 0):
        ans += 1
print(ans)
Problem p02699 (python)

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

Buggy submission (verdict: Runtime Error):
s = int(input())
w = int(input())
if(w >= s):
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
s = int(input())
w = int(input())
if(w >= s):
    print("unsafe")
else:
    print("safe")
Problem p02723 (python)

Fixed submission:
s = input()
if(s[2] == s[3] and s[4] == s[5]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if(s[2] == s[3] && s[4] == s[5]):
    print("Yes")
else:
    print("No")
Problem p02729 (python)

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

Buggy submission (verdict: Runtime Error):
n,m = map(int,raw_input().split())
ans = 0
if(n >= 2):
    ans += n*(n-1)//2
    
if(m >= 2):
    ans += m*(m-1)//2
print(ans)
Problem p02753 (python)

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

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

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

Sum = sum(A)

ans = 0
for i in range(N-1):
    Sum = Sum - A[i]
    ans += int(A[i])*Sum

ans %= 1000000007

print(int(ans))

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

Sum = sum(A)

ans = 0
for i in range(N):
    ans += int(A[i])*(Sum-int(A[i]))

ans %= 1000000007

print(int(ans/2))
Problem p02594 (python)

Fixed submission:
n = int(input())

if n >= 30:
    print("Yes")
else:
    print("No")

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

if n >= 30:
    print("Yes")
else:
    print("No")
Problem p03805 (python)

Fixed submission:
import itertools
n,m = list(map(int,input().split()))

a = []
for i in range(m):
    b = (list(map(int,input().split())))
    b = [b[0]-1,b[1]-1]
    a.append(b)

b = [[0 for i in range(n)] for j in range(n)]
for i in a:
    b[i[0]][i[1]] = 1
    b[i[1]][i[0]] = 1


c = [i+1 for i in range(n-1)]
ans = 0
for i in itertools.permutations(c,n-1):
    j = [0]
    j += i
    count = 0
    for i in range(n-1):
        if b[j[i]][j[i+1]] == 1:
            count += 1
            if count == n-1:
                ans += 1
                count = 0
        else:
            break
print(ans)

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

a = []
for i in range(m):
    b = (list(map(int,input().split())))
    b = [b[0]-1,b[1]-1]
    a.append(b)

b = [[0 for i in range(n)] for j in range(n)]
for i in a:
    b[i[0]][i[1]] = 1
    b[i[1]][i[0]] = 1

c = [i+1 for i in range(m-1)]
ans = 0
for i in itertools.permutations(c,m-1):
    j = [0]
    j += i
    count = 0
    for i in range(m-1):
        if b[j[i]][j[i+1]] == 1:
            count += 1
            if count == m-1:
                ans += 1
                count = 0
        else:
            break
print(ans)
Problem p02572 (python)

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

a2=[a[n-1]]
for i in range(n-1,0,-1):
    a2.append(a2[-1]+a[i-1])
ans=0
for i in range(n-1):
    ans = ( ans + (a[i]*a2[-i-2]) )%(10**9+7)
print(ans)

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

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

A = a.reshape(1, -1)
Asq = np.transpose(A) @ A
Asq = np.triu(Asq) - np.diag(np.ndarray.diagonal(Asq))
Asq = Asq % (10**9+7)

print(np.sum(Asq) % (10**9+7))
Problem p02594 (python)

Fixed submission:
print("Yes" if int(input())>=30 else "No")

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
c = list(map(int,input().split()))
lr= [input().split() for _ in range(q)]
for i in range(q):
    print(len(set(c[int(lr[i][0])-1:int(lr[i][1])])))
Problem p02596 (python)

Fixed submission:
K = int(input())
rest = 7%K
count=1
while (count<=K):
    if rest == 0:
        print(count)
        exit()
    count +=1
    rest = (rest%K*10%K + 7%K)%K
print(-1)

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

rw_after=sorted(rw)

count=0
for i in range(N):
    if rw[i] != rw_after[i]:
        count+=1
print(int(count/2))
Problem p02622 (python)

Fixed submission:
S=input()
T=input()

count=0

for i in range(len(S)):
    if S[i]!=T[i]:
        count +=1
print(count)

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

count=0

for i in range(len(S)+1):
    if S[i]!=T[i]:
        count +=1
    print(T[i])
print(count)
Problem p02629 (python)

Fixed submission:
import math

# one = 1000000000000001
dict={1:"a",2:"b",3:"c",4:"d",5:"e",6:"f",7:"g",8:"h",9:"i",10:"j",
        11:"k",12:"l",13:"m",14:"n",15:"o",16:"p",17:"q",18:"r",19:"s",20:"t",
        21:"u",22:"v",23:"w",24:"x",25:"y",26:"z"}

n=int(input())

ans = str(dict[(n-1)%26+1])

n=(n-1)//26
while n:
    ans = str(dict[(n-1)%26+1]) + ans
    n=(n-1)//26

print(ans)

Buggy submission (verdict: Runtime Error):
import math

# one = 1000000000000001
dict={1:"a",2:"b",3:"c",4:"d",5:"e",6:"f",7:"g",8:"h",9:"i",10:"j",
        11:"k",12:"l",13:"m",14:"n",15:"o",16:"p",17:"q",18:"r",19:"s",20:"t",
        21:"u",22:"v",23:"w",24:"x",25:"y",26:"z"}

n=int(input())

if n==1:
    print("a")
    exit()

keta= math.floor(math.log(n-1,26))

ans=[]
for i in range(keta+1):

    if i==0:
        ans.append(dict[((n-1)//26**i)%26+1])
    else:
        ans.append(dict[((n-1)//26**i)%26])

for str in ans[::-1]:
    print(str,end="")
Problem p02699 (python)

Fixed submission:
S,W = list(map(int,input().split()))
print("safe" if S>W else "unsafe")

Buggy submission (verdict: Runtime Error):
S,W = list(map(int,input()split()))
print("safe" if S>W else "unsafe")
Problem p02701 (python)

Fixed submission:
N = int(input())
print(len(set([input() for _ in range(N)])))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = set()
for _ in range(n):
    a.append(input())
print(len(a))
Problem p02835 (python)

Fixed submission:
print("win" if sum(map(int,input().split()))<=21 else "bust")

Buggy submission (verdict: Runtime Error):
print("win" if sun(map(int,input().split()))<=21 else "bust")
Problem p02859 (python)

Fixed submission:
print(int(input())**2)

Buggy submission (verdict: Runtime Error):
pritn(int(input())**2)
Problem p02915 (python)

Fixed submission:
print(int(input())**3)

Buggy submission (verdict: Runtime Error):
prnt(int(input())**3)
Problem p02987 (python)

Fixed submission:
s=input()
if len(set(s))==2 and s.count(s[0])==2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input()
print("Yes" if (sorted(s[:2])==sorted(s[2:]) and len(sorted(s[:2))==2) else "No")
Problem p02989 (python)

Fixed submission:
N=int(input())
l=[int(i) for i in input().split()]
l.sort()
print(max(0,l[int(N/2)] - l[int(N/2)-1]))

Buggy submission (verdict: Runtime Error):
N=int(input())
l=[int(i) for i in input().split()]
l.sort()
print(max(0,l[int(N/2)] - l[int(N/2)-1])
Problem p03135 (python)

Fixed submission:
T,X=map(int,input().split())
print(float(T/X))

Buggy submission (verdict: Runtime Error):
T,X=map(int,input())
print(float(T/X))
Problem p02580 (python)

Fixed submission:
def resolve():
    #n=int(input())
    #a,b=map(int,input().split())
    #x=list(map(int,input().split()))
    #a=[list(map(lambda x:int(x)%2,input().split())) for _ in range(h)]
    import sys
    input = sys.stdin.readline
    H,W,m=map(int,input().split())
    bomb=set()
    cnt1=[0 for i in range(H)]
    cnt2=[0 for i in range(W)]
    for i in range(m):
        h,w=map(int,input().split())
        bomb.add((h-1,w-1))
        cnt1[h-1]+=1
        cnt2[w-1]+=1
    m1=max(cnt1)
    m2=max(cnt2)
    hk,wk=[],[]
    for i,x in enumerate(cnt1):
        if x==m1:
           hk.append(i)
    for i,x in enumerate(cnt2):
        if x==m2:
           wk.append(i)
    ans=m1+m2
    for i in hk:
        for j in wk:
            if (i,j) in bomb:
                continue
            print(ans)
            exit()
    print(ans-1)

if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
H,W,m=map(int,input().split())
bomb=[[0]*W for _ in range(H)]
cnt1=[[0,i] for i in range(H)]
cnt2=[[0,i] for i in range(W)]
for i in range(m):
    h,w=map(int,input().split())
    bomb[h-1][w-1]=1
    cnt1[h-1][0]+=1
    cnt2[w-1][0]+=1
cnt1.sort(reverse=True)
cnt2.sort(reverse=True)
m1=cnt1[0][0]
l1=[]
i=0
while cnt1[i][0]==m1:
    l1.append(cnt1[i][1])
    i+=1
    if i>=H-1:
        break
m2=cnt2[0][0]    
l2=[]
i=0
while cnt2[i][0]==m2:
    l2.append(cnt2[i][1])
    i+=1
    if i>=W-1:
        break
ans=0
for i in l1:
    for j in l2:
        ans=max(ans,m1+m2-bomb[i][j])
print(ans)
Problem p02679 (python)

Fixed submission:
def resolve():
    import math
    from math import gcd
    MOD=10**9+7
    n=int(input())
    zero=0
    cnt={}
    for i in range(n):
        a,b=map(int,input().split())
        if a==0 and b==0:
            zero+=1
            continue
        g=gcd(a,b)
        a//=g
        b//=g
        if b<0:
            a*=-1
            b*=-1
        if b==0 and a<0:
            a*=-1
        if a<=0:
            a,b=b,-a
            if (a,b) in cnt:
                cnt[(a,b)][0]+=1
            else:
                cnt[(a,b)]=[1,0]
        else:
            if (a,b) in cnt:
                cnt[(a,b)][1]+=1
            else:
                cnt[(a,b)]=[0,1]
    ans=1
    for i,v in cnt.items():
        ans*=pow(2,v[0],MOD)+pow(2,v[1],MOD)-1
        ans%=MOD
    print((zero-1+ans)%MOD)    

if __name__ == '__main__':
    resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    import math
    from math import gcd
    MOD=10**9+7
    n=int(input())
    zero=0
    cnt={}
    for i in range(n):
        a,b=map(int,input().split())
        if a==0 and b==0:
            zero+=1
            continue
        g=gcd(a,b)
        a//=g
        b//=g
        if b<0:
            a*=-1
            b*=-1
        if b==0 and a<0:
            a*=-1
        if a<=0:
            a,b=b,-a
            if (a,b) in cnt:
                cnt[(a,b)][0]+=1
            else:
                cnt[(a,b)]=[1,0]
        else:
            if (a,b) in cnt:
                cnt[(a,b)][1]+=1
            else:
                cnt[(a,b)]=[0,1]
        ans=1
    for i,v in cnt.items():
        ans*=pow(2,v[0],MOD)+pow(2,v[1],MOD)-1
        ans%=MOD
    print((zero-1+ans)%MOD)    

if __name__ == '__main__':
    resolve()
Problem p02685 (python)

Fixed submission:
n,m,k=map(int,input().split())
MOD=998244353

def prepare(n, MOD):
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return fn, invs

a,b=prepare(n-1,MOD)
ans,s=0,(m*pow(m-1,n-k-1,MOD))%MOD
for x in range(k,-1,-1):
    ans+=(s*a*b[x]*b[n-x-1])%MOD
    ans%=MOD
    s*=(m-1)
    s%=MOD
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
MOD=998244353

def prepare(n, MOD):
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return fn, invs

a,b=prepare(n-1,MOD)
if n==1:
    print(m)
else:
    ans,s=0,(m*pow(m-1,n-k-2,MOD))%MOD
    for x in range(k,-1,-1):
        s*=(m-1)
        s%=MOD
        ans+=(s*a*b[x]*b[n-x-1])%MOD
        ans%=MOD
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
MOD=998244353

def prepare(n, MOD):
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return fn, invs

a,b=prepare(n-1,MOD)
ans,s=0,(m*pow(m-1,n-k-2,MOD))%MOD
for x in range(k,-1,-1):
    s*=(m-1)
    s%=MOD
    ans+=(s*a*b[x]*b[n-x-1])%MOD
    ans%=MOD
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m,k=map(int,input().split())
MOD=998244353
dp = np.zeros((n+1,n),dtype=np.int64)
dp[1][0]=m
for i in range(2,n+1):
    dp[i]+=dp[i-1]*(m-1)
    dp[i][1:]+=dp[i-1][:1]
    dp[i]%=MOD
print(sum(dp[n][:k+1]))
Problem p02699 (python)

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

Buggy submission (verdict: Runtime Error):
s=list(map(int,list(input())))
n=len(s)
m=[[0]*(n+1) for _ in range(n+1)]
ans=0
for i in range(1,n+1):
    for j in range(i,n+1):
        m[i][j]=(m[i][j-1]*10+s[j-1])%2019
        if m[i][j]==0:
            ans+=1
print(ans)
Problem p02757 (python)

Fixed submission:
def main():
    n,p=map(int,input().split())
    s=list(map(int,list(input())))
    cnt,ans=0,0
    m=[0]*p
    m[0]=1

    if p in [2, 5]:
        for i, x in enumerate(s):
            if x % p == 0:
                ans += i + 1
        print(ans)
        exit()

    sm=0
    d=1
    for i in range(n):
        sm=(sm+s[n-1-i]*d)%p
        m[sm]+=1
        d=(d*10)%p
    
    for i in m:
        ans+=i*(i-1)//2

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,p=map(int,input().split())
    s=input()
    cnt,ans=0,0
    m=[0]*p

    if p==2 or p==5:
        for i in s:
            if i%p==0:
                cnt+=1
        print(cnt*(cnt+1)//2)
        exit()

    for i in range(n):
        m[int(s[i:])%p]+=1
    
    for i in m:
        ans+=i*(i-1)//2
    ans+=m[0]

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,p=map(int,input().split())
    s=input()
    cnt,ans=0,0
    m=[0]*p

    if p==2 or p==5:
        for i in s:
            if i%p==0:
                cnt+=1
        print(cnt*(cnt+1)//2)
        exit()

    for i in range(n):
        m[int(s[i:])%p]+=1
    
    for i in m:
        ans+=i*(i-1)//2
    ans+=m[0]

    print(ans)

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

Fixed submission:
import sys
from bisect import bisect_left,bisect_right,insort
#input = sys.stdin.readline

def main():
    n=int(input())
    s=list(str(input()))
    p=[[] for _ in range(26)]
    for i,S in enumerate(s):
        p[ord(S)-ord('a')].append(i)
    q=int(input())
    for i in range(q):
        a,b,c=map(str,input().split())
        if a=='1':
            b=int(b)-1
            if s[b]==c:
                continue
            else:
                insl=bisect_left(p[ord(s[b])-ord('a')],b)
                p[ord(s[b])-ord('a')].pop(insl)
                insort(p[ord(c)-ord('a')],b)
                s[b]=c
        else:
            b,c=int(b)-1,int(c)-1
            cnt=0
            for i in range(26):
                insl=bisect_left(p[i],b)
                if insl>=len(p[i]):
                    continue
                elif p[i][insl]<=c:
                    cnt+=1
            print(cnt)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_left,bisect_right,insort
input = sys.stdin.readline

def main():
    n=int(input())
    s=list(input())
    p=[[] for _ in range(26)]
    for i in range(n):
        p[ord(s[i])-ord('a')].append(i+1)
    q=int(input())
    for i in range(q):
        a,b,c=map(str,input().split())
        if a=='1':
            b=int(b)-1
            if s[b]==c:
                continue
            else:
                insl=bisect_left(p[ord(c)-ord('a')],b)
                p[ord(s[i])-ord('a')].pop(insl)
                insort(p[ord(c)-ord('a')],insl)
                s[b]=c
        else:
            b,c=int(b)-1,int(c)-1
            cnt=0
            for i in range(26):
                insl=bisect_left(p[i],b)
                if insl>=len(p[i]):
                    continue
                elif p[i][insl]<=c:
                    cnt+=1
            print(cnt)

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

Fixed submission:
s=input()
K=int(input())
n=len(s)
dp=[[[0]*2 for _ in range(K+1)] for _ in range(n+1)]
dp[0][0][0]=1
for i in range(n):
    for j in range(K+1):
        for k in range(2):
            nd=int(s[i])
            for d in range(10):
                ni,nj,nk=i+1,j,k
                if d!=0:
                    nj+=1
                if nj>K:
                    continue
                if nk==0:
                    if nd<d:
                        continue
                    if nd>d:
                        nk=1
                dp[ni][nj][nk]+=dp[i][j][k]
print(dp[n][K][0]+dp[n][K][1])

Buggy submission (verdict: Runtime Error):
from math import factorial

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

n=int(input())
k=int(input())
ans=0
nstr=str(n)
nl=len(nstr)
for i in range(k,nl):
    ans+=combinations_count(i-1,k-1)
ans*=9**k
zerocnt=0
for i in range(nl):
    if zerocnt<=nl-k:
        if i==0:
            ans+=(int(nstr[0])-1)*combinations_count(nl-1,k-1)*(9**(k-1))
        else:
            if nstr[i]=='0':
                zerocnt+=1
            else:
                ans+=(int(nstr[i])-1)*combinations_count(nl-i-1,k-i+zerocnt-1)*9**(k-i+zerocnt-1)
    else:
        break
print(ans)
Problem p02831 (python)

Fixed submission:
import fractions
a,b=map(int,input().split())
print(int((a*b)/fractions.gcd(a, b)))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(int((a*b)/math.gcd(a, b)))
Problem p02833 (python)

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

def main():
    n=int(input())
    cnt=5
    ans=0
    if n%2==0:
        n=n//2
        while cnt<=n:
            ans+=n//cnt
            cnt*=5
    print(ans)                
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==1:
	print(0)
else:
	n2=n/2
	ans=0
	while n2>0:
		n2=n2//5
		ans+=n2
    print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
n2=0
if n%2==1:
	print(0)
else:
	n2=n/2
	ans=0
	while n2>0:
		n2=n2//5
		ans+=n2
print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
n2=0
if n%2==1:
	print(0)
else:
	n2=int(n/2)
	ans=0
	while n2>0:
		n2=int(n2//5)
		ans+=n2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==1:
	print(0)
else:
	n2=int(n/2)
	ans=0
	while n2>0:
		n2=int(n2/5)
		ans+=n2
print(ans)
Problem p02862 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import deque
import math

def main():
    def pre(n,MOD):
        a=1
        for i in range(1,n+1):
            a=(a*i)%MOD
        an=a
        b=pow(a,MOD-2,MOD)
        bs=[1]*(n+1)
        bs[n]=b
        for i in range(n,1,-1):
            b=b*i%MOD
            bs[i-1]=b
        return an,bs
    
    x,y=map(int,input().split())
    d=(x+y)//3
    MOD=10**9+7
    if (x+y)%3!=0 or x<d or y<d:
        print(0)
    else:
        a,b=pre(d,MOD)
        a=a*b[y-d]*b[2*d-y]%MOD
        print(a)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque
import math

def main():
    x,y=map(int,input().split())
    MOD=10**9+7
    if (x+y)%3!=0:
        print(0)
    else:
        n=int((x+y)/3)
        k=int((2*x-y)/3)
    a,b=1,1
    for i in range(k):
        a=(a*(n-i))%MOD
        b=(b*(1+i))%MOD
    ans=(a*pow(b,MOD-2,MOD))%MOD
    print(int(ans))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque

def main():
    x,y=map(int,input().split())
    MOD=10**9+7
    if (x+y)%3!=0:
        print(0)
    else:
        n=int((x+y)/3)
        k=int((2*x-y)/3)
    a,b=1,1
    for i in range(k):
        a=(a*(n-i))%MOD
        b=(b*(1+i))%MOD
    ans=(a*pow(b,MOD-2,MOD))%MOD
    print(int(ans))
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque

def main():
    x,y=map(int,input().split())
    MOD=10**9+7
    if (x+y)%3!=0:
        print(0)
    else:
        n=int((x+y)/3)
        k=int((2*x-y)/3)
    a,b=1,1
    for i in range(k):
        a=(a*(n-i))%MOD
        b=(b*(1+i))%MOD
    ans=(a*pow(b,MOD-2,MOD))%MOD
    print(int(ans))
    
if __name__ == '__main__':
    main()
Problem p02873 (python)

Fixed submission:
s=str(input())
sl=len(s)+1
l,r=[0]*sl,[0]*sl
ss=[0]*sl
lcnt,rcnt=0,0
for i in range(sl):
  if i==0:
    l[0]=0
    r[sl-1]=0
  else:
    if s[i-1]=="<":
      lcnt+=1
    else:
      lcnt=0
    if s[sl-i-1]==">":
      rcnt+=1
    else:
      rcnt=0
    l[i]=lcnt
    r[sl-i-1]=rcnt
for i in range(sl):
  ss[i]=max(l[i],r[i])
print(sum(ss))

Buggy submission (verdict: Runtime Error):

s=input()
n=len(s)
ans=[0]*(n+1)
m=0
for i in range(1,n+1):
	if s[i]=='<':
		ans[i]=ans[i-1]+1
	else:
		ans[i]=ans[i-1]-1
	m=min(m,ans[i])
print(sum(ans)-m*n)
Problem p02879 (python)

Fixed submission:
a,b=map(int,input().split())
if a>=10 or b>=10:
  print(-1)
else:
  print(a*b)

Buggy submission (verdict: Runtime Error):
n=int(input())
2.i=int(n**0.5)
3.while i<n:
4.  if n%i==0:
5.    break
6.  else:
7.    i+=1
8.if i==n:
9.  print(i-1)
10.else:
11.  print(int(i+n/i)-2)
Problem p02881 (python)

Fixed submission:
n=int(input())
i=int(n**0.5)+1
while i>0:
  if n%i==0:
    break
  else:
    i-=1
if i==n:
  print(i-1)
else:
  print(int(i+n/i)-2)

Buggy submission (verdict: Runtime Error):
n=int(input())
2.i=int(n**0.5)
3.while i<n:
4.  if n%i==0:
5.    break
6.  else:
7.    i+=1
8.if i==n:
9.  print(i-1)
10.else:
11.  print(int(i+n/i)-2)
Problem p02912 (python)

Fixed submission:
import heapq
n,m=map(int,input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for i in range(m):
    ma=heapq.heappop(a)
    heapq.heappush(a,(-1)*((-ma)//2))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
I=list(map(int,open(0).read().split()))
n,m=I[:2]
a=I[2:]
for i in range(m):
    a.sort()
    a[m-1]=a[m-1]//2
print(int(sum(a)))
Problem p02925 (python)

Fixed submission:
from collections import deque
n=int(input())
x=lambda i:int(i)-1
a=[deque(list(map(x,input().split()))+[-1]) for _ in range(n)] 
tcnt,ans=n*(n-1),0
chk=set(range(n))
while tcnt>0:
    chk_next=set()
    for i in chk:
        if a[a[i][0]][0]==i:
            chk_next.add(i)
    if len(chk_next)==0:
        ans=-1
        break
    tcnt-=len(chk_next)
    chk=set()
    for i in chk_next:
        a[i].popleft()
        chk.add(i)
        if a[i][0]!=-1:
            chk.add(a[i][0])
    ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[list(map(int,input().split()))[::-1] for _ in range(n)]
tcnt,ans=0,0
while tcnt<n*(n-1)//2:
  cnt=0
  chk=[]
  for i in range(n-1):
    if i in chk:
      continue
    else:
      if a[i]:
        b=a[i][-1]-1
        if b in chk:
          continue
        else:
          if b>i and a[b][-1]-1==i:
            chk.append(a[i].pop()-1,a[b].pop()-1)
            cnt+=1
  tcnt+=cnt
  ans+=1
  if cnt==0:
    ans=-1
    break
print(ans)