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

Fixed submission:
# coding: utf-8
 
a, b, c = map(int, input().split())
 
x = a*10 + b
y = b*10 + c
z = c*10 + a
 
if x >= y and x >= z:
    print(x + c)
elif y >= x and y >= z:
    print(y + a)
else:
    print(z + b)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
xn.append(x)
ym.append(y)
flag = 0
 
if x < y:
    for i in range(min(xn), max(ym)+1):
        if max(xn) < i and min(ym)>=i:
            print("No War")
            flag = 1
    if flag == 0:
        print("War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
flag = 0

if x < y:
    for i in range(x+1, y+1):
        if max(xn) < i and min(ym)>=i:
            print("No War")
            flag = 1
        elif flag == 0 and i == y:
            print("War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))

if x < y:
    for i in range(x, y+1):
        if max(xn) < i and min(ym)>=i:
            print("No War")
            break
        elif i == y:
            print("War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
 
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))
 
if x < y:
    for i in range(x, y+1):
        if max(xn) < i and min(ym)>=i:
            print("War")
        elif i == y:
            print("No War")
else:
    print("No War")

Buggy submission (verdict: Runtime Error):
# coding: utf-8

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

x = a*10 + b
y = b*10 + c
z = c*10 + a

if x >= y and x >= z:
    print(x + c)
elif y >= x and y >= z:
    print(y + a)
else
    print(z + b)
Problem p03041 (python)

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

if s[k]=="A":
    s[k]="a"
elif s[k]=="B":
    s[k]="b"
else:
    s[k]="c"

print("".join(s))

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

if s[k-1]==A:
    s[k-1]=a
elif s[k-1]==B:
    s[k-1]=b
else:
    s[k-1]=c
print(s)
Problem p03011 (python)

Fixed submission:
num=list(map(int, input().split()))
num=sorted(num)
ans=num[0]+num[1]

print(ans)

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

if (a>=b)&&(b>=c):
  ans=a+b
  print("",ans)
elif (b>=a)&&(c>=a):
  ans=b+c
  print("",ans)
else (a>=c)&&(c>=b):
  ans=a+c
  print("",ans)
Problem p03315 (python)

Fixed submission:
s = input()
k = 0
for i in s:
    if i == "+":
        k += 1
    else:
        k -= 1
print(k)

Buggy submission (verdict: Runtime Error):
a = input()
b = 0
for i in a:
     b += int(i)
if int(a)%b == 0:
     print("Yes")
else:
     print("No")
Problem p03127 (python)

Fixed submission:
import fractions

n = int(input())
m = list(map(int,input().split()))
ans = 0

for i in range(n):
	ans = fractions.gcd(ans,m[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
m = list(map(int,input().split()))
ans = 0

for i in range(n):
	ans = math.gcd(ans,m[i])
print(ans)
Problem p02987 (python)

Fixed submission:
S = set(input())
print('Yes' if len(S) == 2 else 'No')

Buggy submission (verdict: Runtime Error):
S = list(input())
r = S[0]
for i in range(4):
 S.remove(r)
if S[0] == S[1] and len(S) == 2:
 print('Yes')
else:
 print('NO')

Buggy submission (verdict: Runtime Error):
S = list(input())
r = S[0]
for i in range(4)
 S.remove(r)
if S[0] == S[1] and len(S) == 2:
 print('Yes')
else:
 print('NO')

Buggy submission (verdict: Runtime Error):
S = list(input())
r = S[0]
S.remove(r)
S.remove(r)
if S[0] == S[1] and len(S) == 2:
 print('Yes')
else:
 print('NO')
Problem p03041 (python)

Fixed submission:
n,k = map(int, input().split())
s = input()

b = ""
for i in range(n):
  if i == k-1:
    b += s[i].lower()
  else:
    b += s[i]
    
print(b)

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

b = ""
for i in range(n):
  if i == k-1:
    b += s[i].lower
  else:
    b += s[i]
    
print(b)

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

b = ""
for i in range(n):
  if i == k-1:
    b += s[i].lower
  else:
    b += s[i]
    
print(b)
Problem p03042 (python)

Fixed submission:
S = input()
A = int(S[0:2])
B = int(S[2:4])

if 0 < A and A <= 12:
  if 0 < B and B <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0 < B and B <= 12:
    print("YYMM")
  else:
    print("NA")

Buggy submission (verdict: Runtime Error):
S = input()
A = int(S[0:2])
B = int(S[2:4])

if 0 < A and A <= 12:
  if 0 < B and B <= 12:
    print(AMBIGUOUS)
  else:
    print(MMYY)
else:
  if 0 < B and B <= 12:
    print(YYMM)
  else:
    print(NA)
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if abs(a - b) <= k and abs(a - c) <= k and abs(a - d) <= k and abs(a - e) <= k and abs(b - c) <= k and abs(b - d) <= k and abs(b - e) <= k and abs(c - d) <= k and abs(c - e) <= k and abs(d - e) <= k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = a % 10
B = b % 10
C = c % 10
D = d % 10
E = e % 10

S = []
sum = 0
if A != 0:
  S.append(A)
if B != 0:
  S.append(B)
if C != 0:
  S.append(C)
if D != 0:
  S.append(D)
if E != 0:
  S.append(E)
if len(S) == 0:
  sum = a + b + c + d + e
else:
  sum = (a //10 + b //10 + c //10 + d //10 + e //10)*10 + 10*(len(A) - 1) +min(S)
print(sum)
Problem p02773 (python)

Fixed submission:
n = int(input())
from collections import defaultdict
d=defaultdict(int)

max_cnt=-1
for _ in range(n):
    s=input()
    d[s]+=1
    max_cnt=max(max_cnt, d[s])


ans=sorted([k for (k,v) in d.items() if v==max_cnt])
    
for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
from collections import defaultdict
d=defaultdict(int)
for _ in range(n):
    d[input()]+=1

L=[(v,k) for (k,v) in d.items()]
L.sort(reverse=True)
max_cnt=L[0][0]
#print('*'*30)
ans=[]
for l in L:
    if l[0]==max_cnt:
        ans.append(l[1])
    else :
        break

for a in ans:
    print(ans)
Problem p02891 (python)

Fixed submission:
s = input()
k = int(input())
def seqcnt(s):
    cnt=1
    ans=0
    bk=''
    for c in s+' ':
        if bk==c:
            cnt+=1
        else:
            ans+=(cnt)//2
            cnt=1
        bk=c
    return ans

cnt=seqcnt(s)
cnt2=seqcnt(s*2)    
if len(set(list(s)))==1:
    print(len(s)*k//2)
else:
    print(cnt+(cnt2-cnt)*(k-1))

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
def seqcnt(s):
    cnt=1
    ans=0
    bk=''
    for c in s+' ':
        print(f'bk={bk} c={c}')
        if bk==c:
            cnt+=1
        else:
            ans+=(cnt)//2
            cnt=1
        bk=c
    return ans

cnt=seqcnt(s)
cnt2=seqcnt(s*2)    
print(f'cnt={cnt} cnt2={cnt2}')
if len(set(list(s)))==1:
    if len(s)%2==0:
        print(cnt*k)
    else:
        print(cnt*(k//2)+(cnt2-cnt)*(k-k//2))
else:
    print(cnt+(cnt2-cnt)*(k-1))
Problem p03013 (python)

Fixed submission:
MOD=10**9+7
n,m = list(map(int, input().split()))
a = set([int(input()) for _ in range(m)])

dp = [0] * (n+1)

dp[0] = 1
dp[1] = int(1 not in a)
for step in range(2, n+1):
    if dp[step-1]==0 and dp[step-2]==0:
        break
    if step not in a:
        dp[step] = (dp[step-1] + dp[step-2])%MOD
    else:
        dp[step] = 0
        
print(dp[-1])

Buggy submission (verdict: Runtime Error):
MOD=10**10+7
n,m = list(map(int, input().split()))
a = set([int(input()) for _ in range(m)])

dp = [0] * (n+1)

if 1 in a and 2 in a:
    print(0)
    exit()
elif 1 in a:
    dp[2]=1
    dp[3]=2
    start=4
elif 2 in a:
    dp[1]=1
    dp[3]=2
    start=4
else:
    dp[1]=1
    dp[2]=2
    start=3
    
for step in range(start, n+1):
    if dp[step-1]==0 and dp[step-2]==0:
        break
    if step not in a:
        dp[step] = (dp[step-1] + dp[step-2])%MOD
print(dp[-1])
Problem p02679 (python)

Fixed submission:

from collections import defaultdict
from math import gcd

P=defaultdict(lambda :0)
n=int(input())
AB=[tuple(map(int,input().split()))for i in range(n)]

zero=0 #これがいるときは一匹のみ
a0=0 #a0とb0はお互いがペア
b0=0
for a,b in AB:
    g=gcd(a,b)
    if a==0 and b==0:
        zero+=1
    elif a==0:
        a0+=1
    elif b==0:
        b0+=1
    elif a<0:
        a//=-g
        b//=-g
        P[(a,b)]+=1
    else:
        a//=g
        b//=g
        P[(a,b)]+=1

ans=1
others=n-zero-a0-b0
mod=1000000007
from copy import copy
k=copy(list(P.keys()))
for p in k:
    me=P[p]
    if me==0:
        continue
    a,b=p
    oppidx=(-b,a) if b<0 else (b,-a)
    opp=P[oppidx]
    if P[oppidx]!=0:
        others-=me+opp
        ans*=pow(2,me,mod)+pow(2,opp,mod)-1
        ans%=mod
    P[p]=0
    P[oppidx]=0

if a0!=0 and b0!=0:
    ans*=pow(2,a0,mod)+pow(2,b0,mod)-1
    ans%=mod
elif a0!=0 or b0!=0:
    others+=a0+b0

ans*=pow(2,others,mod)
ans%=mod
ans=ans+zero-1
ans%=mod

print(ans)

"""
7
0 1
0 1
1 0
1 0
1 -1
1 1
1 3
"""

Buggy submission (verdict: Runtime Error):

from collections import defaultdict
from math import gcd

P=defaultdict(lambda :0)
n=int(input())
AB=[tuple(map(int,input().split()))for i in range(n)]



for a,b in AB:
    g=gcd(a,b)
    if a<0:
        a//=-g
        b//=-g
    else:
        a//=g
        b//=g
    P[(a,b)]+=1

ans=1
others=n
mod=1000000007
from copy import copy
k=copy(list(P.keys()))
for p in k:
    me=P[p]
    if me==0:
        continue
    a,b=p
    oppidx=(-b,a) if b<0 else (b,-a)
    opp=P[oppidx]
    if P[oppidx]!=0:
        others-=me+opp
        ans*=pow(2,me,mod)+pow(2,opp,mod)-1
        ans%=mod
    P[p]=0
    P[oppidx]=0

ans*=pow(2,others,mod)
ans
ans%=mod

print(ans-1)
Problem p02689 (python)

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

g=[[]for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans=0
for i in range(n):
    M=max([h[c] for c in g[i]]+[0])
    if M<h[i]:
        ans+=1
print(ans)

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

g=[[]for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans=0
for i in range(n):
    M=max([h[c] for c in g[i]]+[0])
    if M<h[i]:
        ans+=1
print(ans)
Problem p02781 (python)

Fixed submission:
n=input()
k=int(input())

n1,n2,n3=int(n[-1]),0,0
a1,a2,a3=9,0,0
for i in n[-2::-1]:
    i=int(i)
    if i!=0:
        n1,n2,n3=i+a1,(i-1)*a1+n1+a2,(i-1)*a2+n2+a3
    a1,a2,a3=9+a1,9*a1+a2,9*a2+a3
print([n1,n2,n3][k-1])

Buggy submission (verdict: Runtime Error):
from math import log10
n=input()
k=int(input())

#ないときも後で
l=len(n)
ans1=0
if l>k:
    if k==1:
        ans1=l-1
    elif k==2:
        ans1=(l-1)*(l-2)//2
    else:
        ans1=(l-1)*(l-2)*(l-3)//6
ans1*=9**k
ans=0
if l>=k:
    if k==1:
        ans=0
    elif k==2:
        ans=(l-1)
    else:
        ans=(l-1)*(l-2)//2
ans*=(int(n[0])-1)*9**(k-1)

dp=[[0]*3 for _ in range(l-1)]
dp[-1][0]=1
n=list(n)
n.reverse()
for i,c in enumerate(n[:-1]):
    c=int(c)
    dp[i][0]=1
    dp[i][1]=dp[i-1][1]+dp[i-1][0]*c
    dp[i][2]=dp[i-1][2]+dp[i-1][1]*c
ans+=dp[-1][k-1]
print(ans+ans1)

Buggy submission (verdict: Runtime Error):
from math import log10
n=input()
k=int(input())

#ないときも後で
l=len(n)
ans1=0
if l>k:
    if k==1:
        ans1=l-1
    elif k==2:
        ans1=(l-1)*(l-2)//2
    else:
        ans1=(l-1)*(l-2)*(l-3)//6
ans1*=9**k
if l>=k:
    if k==1:
        ans=0
    elif k==2:
        ans=(l-1)
    else:
        ans=(l-1)*(l-2)//2
ans*=(int(n[0])-1)*9**(k-1)

dp=[[0]*3 for _ in range(l-1)]
dp[-1][0]=1
n=list(n)
n.reverse()
for i,c in enumerate(n[:-1]):
    c=int(c)
    dp[i][0]=1
    dp[i][1]=dp[i-1][1]+dp[i-1][0]*c
    dp[i][2]=dp[i-1][2]+dp[i-1][1]*c
ans+=dp[-1][k-1]
print(ans+ans1)
Problem p02831 (python)

Fixed submission:
a,b = [int(i) for i in input().split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
print(a*b//gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math

a,b = [int(i) for i in input().split()]

print(a*b//math.gcd(a, b))
Problem p02847 (python)

Fixed submission:
s = input()

l = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

print(7-l.index(s))

Buggy submission (verdict: Runtime Error):

n = int(input())
vs = [[] for i in range(n)]
out = [0]*n


for i in range(n-1):
    a, b = [i+0,i+1]
    vs[a].append([b,i+1])
    vs[b].append([a,i+1])

nex = [[0,-1]]

def coloring(index,defColor):
    i=0
    for v in vs[index]:
        if i==defColor:
           i+=1
        out[v[1]]=i
        vs[v[0]].remove([index,v[1]])
        nex.append([v[0],i])
        i+=1
    out[0] = max(out[0],i-1)

while nex.__len__()>0:
    c,d = nex.pop()
    coloring(c,d)

for i in range(n):
    print(out[i]+1)

Buggy submission (verdict: Runtime Error):
def D(x):
    return str(x).__len__()

def price(x):
    return D(x)*b + a*x

d = 1

if price(1)>x:
    print(0)
else:
    while True:
        if price(d*10) <= x:
            d*=10
            if(d==1000000000):
                print(d)
                break
            continue
        else:
            print(max(d + (x-price(d))//a,d*10-1))
            break
Problem p03045 (python)

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

flag=list(range(N))
def takeflag(p):
    stock=[]
    while flag[flag[p]]!=flag[p]:
        stock.append(p)
        p=flag[p]
    p=flag[p]
    for i in stock:
        flag[i]=p
    return p

for i in range(M):
    x,y,z = map(int,input().split())
    x,y=x-1,y-1
    x,y = map(takeflag,(x,y))
    x,y = min(x,y),max(x,y)
    flag[x]=y

st=set()
for i in range(N):
    st.add(takeflag(i))

print(len(st))

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

flag=list(range(N))
def takeflag(p):
    stock=[]
    while flag[flag[p]]!=flag[p]:
        stock.append(p)
        p=flag[p]
    p=flag[p]
    for i in stock:
        flag[i]=p
    return p

for i in range(M):
    x,y,z = map(int,input().split())
    x,y = map(takeflag,(x,y))
    x,y = min(x,y),max(x,y)
    flag[x]=y

st=set()
for i in range(N):
    st.add(takeflag(i))

print(len(st))
Problem p04050 (python)

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

breakFlag = False
for i in range(1,m-1):
    if a[i]%2==1:
        if a[0]%2==1:
            if a[len(a)-1]%2==1:
                print("Impossible")
                breakFlag = True
                break
            else:
                a[i],a[len(a)-1] = a[len(a)-1],a[i]
        else:
            a[i],a[0] = a[0],a[i]

if breakFlag==False:
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])
    if m==1:
        if a[0]>1:
            a[0]-=1
            a.append(1)
            print(m+1)
        else:
            print(m)
    else:
        if a[len(a)-1]==1:
            print(m-1)
            a.pop()
            a[0]+=1
        else:
            print(m)
            a[0]+=1
            a[len(a)-1] -= 1
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])

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

breakFlag = False
for i in range(1,m-1):
    if a[i]%2==1:
        if a[0]%2==1:
            if a[len(a)-1]%2==1:
                print("Impossible")
                breakFlag = True
                break
            else:
                a[i],a[len(a)-1] = a[len(a)-1],a[i]
        else:
            a[i],a[0] = a[0],a[i]

if breakFlag==False:
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-1])
    if a[len(a)-1]==1:
        print(m-1)
        a.pop()
        a[0]+=1
    else:
        print(m)
        a[0]+=1
        a[len(a)-1] -= 1
    ans = ''.join([str(s)+" " for s in a])
    print(ans[:-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,w = map(int,input())
if w >= s:
    print('unsafe')
else:
    print('safe')
Problem p02771 (python)

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

if (a[0] != a[2] and a[1]==a[0] )or (a[0] != a[2] and a[1]==a[2] ):
    
    print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[]
for i in range(N):
    S.append(str(input()))

S_set=set(S)

c_max=0
ans=[]
for i in S_set:
    c= S.count(i)
    if c > c_max:
        c_max = c
        ans=[]
        ans.append(i)
    elif c == c_max:
        ans.append(i)

ans=sorted(ans)
for j in ans:
    print(j)
Problem p02831 (python)

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

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
gcd=math.gcd(A,B)
print(A*B//gcd)
Problem p02897 (python)

Fixed submission:
N=int(input())
a=(N-1)//2 + 1
print(a/N)

Buggy submission (verdict: Runtime Error):
import fractions
 
a,b = map(int,input().split())
g = fractions.gcd(a,b)
 
ans=[1]
p=2
while g != 1:
    if g%p == 0:
        ans.append(p)
        g = g//p
    else:
        p += 1
 
print(len(set(ans)))
Problem p03013 (python)

Fixed submission:
n,k=map(int,input().split())
d=[0]*n
s=[0]*n

if k !=0:
    for i in range(k):
        p=int(input())
        d[p-1]=1

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

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=[0]*n
s=[0]*n

if k !=0:
    for i in range(k):
        p=int(input())
        d[p-1]=1

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=[0]*n
s=[0]*n
for i in range(k):
    p=int(input())
    d[p-1]=1

 
if d[0]==1:
    s[0]=0
else:
    s[0]=1
 
if d[1]==1:
    s[1]=0
else:
    s[1]= s[0]+1
 
 
for i in range(2,n):
    if d[i]==1:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007
 
print( s[n-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=[]
s=[0]*n
for i in range(k):
    d.append(int(input()))

if 1 in d:
    s[0]=0
else:
    s[0]=1

if 2 in d:
    s[1]=0
else:
    s[1]= s[0]+1


for i in range(2,n):
    if i+1 in d:
        s[i]=0
    else:
        s[i]=(s[i-1]+s[i-2])%1000000007

print( s[n-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=[]
s=[0]*n
for i in range(k):
    d.append(int(input()))

if 1 in d:
    s[0]=0
else:
    s[0]=1

if 2 in d:
    s[1]=0
else:
    s[1]= s[0]+1


for i in range(2,n):
    if i+1 in d:
        s[i]=0
    else:
        s[i]=s[i-1]+s[i-2]

print( s[n-1] % (1000000007))
Problem p03127 (python)

Fixed submission:
import fractions

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

ans = a[0]

for i in range(1,n):
    ans = fractions.gcd(ans,a[i])

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

ans = a[0]

for i in range(1,n):
    ans = math.gcd(ans,a[i])

print(ans)

Buggy submission (verdict: Runtime Error):
import fraction

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

ans = a[0]

for i in range(1,n):
    ans = fraction.gcd(ans,a[i])

print(ans)
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2=map(int,input().split())

xd= x2-x1
yd= y2-y1

if xd >=0 and yd >= 0:
    x3 = x2 - abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 + abs(xd)

elif xd <= 0 and yd >= 0:

    x3 = x2 - abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 - abs(xd)

elif xd <= 0 and yd <= 0:

    x3 = x2 + abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 - abs(xd)

elif xd >= 0 and yd <= 0:

    x3 = x2 + abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 + abs(xd)


print(x3,y3,x4,y4)

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2=map(int,input().split())

xd= x2-x1
yd= y2-y1

if xd >=0 and yd >= 0:
    x3 = x2 - abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 + abs(xd)

elif xd < 0 and yd > 0:

    x3 = x2 - abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 - abs(yd)
    y4 = y1 - abs(xd)

elif xd < 0 and yd < 0:

    x3 = x2 + abs(yd)
    y3 = y2 - abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 - abs(xd)

elif xd >0 and yd < 0:

    x3 = x2 + abs(yd)
    y3 = y2 + abs(xd)
    x4 = x1 + abs(yd)
    y4 = y1 + abs(xd)


print(x3,y3,x4,y4)
Problem p03767 (python)

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

ans3=0
for i in range(N):
    ans3 += b[i*2+N]

print(ans3)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
ans1=sum(b[N:2*N])

ans2=0
for i in range(N):
    ans2 += b[i*3+1]

ans3=0
for i in range(N):
    ans3 += b[i*2+4]

print(max(ans1,ans2,ans3))
Problem p02547 (python)

Fixed submission:
_,*d=[{*t.split()}for t in open(0)]
print('YNeos'[all(max(map(len,d[i:i+3]))>1for i in range(len(d)-2))::2])

Buggy submission (verdict: Runtime Error):
print('NYoe s'[[*'000']in[eval(eval(t.replace(*' -')))for t in open(0)]::2])
Problem p02580 (python)

Fixed submission:
from collections import*
(h,w,m),*z=[tuple(map(int,o.split()))for o in open(0)]
s=set(z)
y,x=[Counter(t).most_common()for t in zip(*z)]
a,b=y[0][1],x[0][1]
p=[i for i,v in y if v==a]
q=[i for i,v in x if v==b]
for i in p:
  for j in q:
    if(i,j)not in s:exit(print(a+b))
print(a+b-1)

Buggy submission (verdict: Runtime Error):
from numpy import*
z=loadtxt(open(0),int,skiprows=1)
r=zeros(9**6,int)
c=copy(r)
for y,x in z:r[y]+=1;c[x]+=1
h,w=max(r),max(c)
y,x=z.T
print(h+w-(sum(r==h)*sum(w==c)==sum(h+w==r[y]+c[x])))
Problem p02595 (python)

Fixed submission:
(n,d),*z=[map(int,t.split())for t in open(0)]
print(sum(x*x+y*y<=d*d for x,y in z))

Buggy submission (verdict: Runtime Error):
z=[map(int,t.split())for t in open(0)];print(sum(x*x+y*y<=z[0][1]**2for x,y in z))
Problem p02659 (python)

Fixed submission:
a,b=input().split();print(int(a)*int(b[0]+b[-2:])//100)

Buggy submission (verdict: Runtime Error):
print(eval(input().translate({46:'',32:42}))//100)
Problem p02689 (python)

Fixed submission:
n,*t=map(int,open(0).read().split())
p=[1]*n
for a,b in zip(*[iter(t[n+1:])]*2):p[-a]&=t[a]>t[b];p[-b]&=t[b]>t[a]
print(sum(p))

Buggy submission (verdict: Runtime Error):
(n,_),h,*t=[[*map(int,t.split())]for t in open(0)]
p=[1]*n
for a,b in t:p[-a]&=h[a]>h[b];p[-b]&=h[b]>h[a]
print(sum(p))
Problem p02712 (python)

Fixed submission:
print(sum(i%3>0<i%5and i for i in range(int(input())+1)))

Buggy submission (verdict: Runtime Error):
from numpy import*;print(sum(arange(int(input())+1)[i%3>0<i%5]))

Buggy submission (verdict: Runtime Error):
*x,=range(int(input())+1);x[::3]=x[::5]=0;print(sum(x))
Problem p02726 (python)

Fixed submission:
from collections import*
n,x,y=map(int,input().split())
e=[[]for _ in range(n)]
for i in range(n-1):
    e[i]+=i+1,
    e[i+1]+=i,
e[x-1]+=y-1,
e[y-1]+=x-1,
a=[0]*n
for s in range(n):
    d=[-1]*n
    d[s]=0
    q=deque([s])
    while q:
        v=q.popleft()
        for w in e[v]:
            if d[w]<0:
                d[w]=d[v]+1
                q+=w,
    for i in d:a[i]+=1
print(*[i//2for i in a[1:]])

Buggy submission (verdict: Runtime Error):
n,x,y=map(int,input().split())
c=[0]*~-n
for i in range(n):
 for j in range(i):c[min(~j+i,abs(~j+x)+abs(~i+y))]+=1
print(*l)