Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#from collections import deque
#import sys
#sys.setrecursionlimit(10**6)
#input = sys.stdin.buffer.readline
n,m=map(int,input().split())
g = [[] for j in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
q = [(0,-1)]
d=[-1]*n
d[0]=0
res={}
while len(q)>0:
    u,r = q.pop(0)
    for v in g[u]:
        if d[v] == -1 and r != v:
            d[v] = d[u] + 1
            q.append((v,u))
            if not v-1 in res:
                res[v-1] = u+1
res = sorted(res.items())
if len(res) != n-1:
    print("No")
    exit()
print("Yes")
for i,j in res:
    print(j)

Fixed submission:
from collections import deque
#import sys
#sys.setrecursionlimit(10**6)
#input = sys.stdin.buffer.readline
n,m=map(int,input().split())
g = [[] for j in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
q = deque([(0,-1)])
d=[-1]*n
d[0]=0
res={}
while len(q)>0:
    u,r = q.popleft()
    for v in g[u]:
        if d[v] == -1 and r != v:
            d[v] = d[u] + 1
            q.append((v,u))
            if not v-1 in res:
                res[v-1] = u+1
res = sorted(res.items())
if len(res) != n-1:
    print("No")
    exit()
print("Yes")
for i,j in res:
    print(j)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
n,m=map(int,input().split())
g = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
q = [(0,-1)]
d=[-1]*n
d[0]=0
res={}
while q:
    u,r = q.pop(0)
    for v in g[u]:
        if d[v] == -1 and r != v:
            d[v] = d[u] + 1
            q.append((v,u))
            if not v-1 in res:
                res[v-1] = u+1
res = sorted(res.items())
if len(res) != n-1:
    print("No")
    exit()
print("Yes")
for i,j in res:
    print(j)

Fixed submission:
from collections import deque
#import sys
#sys.setrecursionlimit(10**6)
#input = sys.stdin.buffer.readline
n,m=map(int,input().split())
g = [[] for j in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
q = deque([(0,-1)])
d=[-1]*n
d[0]=0
res={}
while len(q)>0:
    u,r = q.popleft()
    for v in g[u]:
        if d[v] == -1 and r != v:
            d[v] = d[u] + 1
            q.append((v,u))
            if not v-1 in res:
                res[v-1] = u+1
res = sorted(res.items())
if len(res) != n-1:
    print("No")
    exit()
print("Yes")
for i,j in res:
    print(j)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
a,b = 0,0
for i in range(x+1):
    if i**5 > x:
        a = i-1
        break
for i in range(x+1):
    if a**5 - i**5 == x:
        b = i
        break
    elif a**5 + i**5 == x:
        b = -i
        break
print(a,b)

Fixed submission:
x = int(input())
a,b = 0,0
f = 0
for i in range(int(x**0.25)+1):
    for j in range(int(x**0.25)+1):
        if i**5 - j**5 == x:
            a = i
            b = j
            f = 1
            break
        elif i**5 + j**5 == x:
            a = i
            b = -j
            f = 1
            break
    if f:
        break
print(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce 
import itertools
k = int(input())
l = [i for i in range(1,k+1)]
ans = 0
def gcd(*numbers):
    return reduce(math.gcd, numbers)
for x in itertools.product(l,repeat=3):
    ans += gcd(x[0],x[1],x[2])
print(ans)

Fixed submission:
import math
from functools import reduce 
import itertools
k = int(input())
l = [i for i in range(1,k+1)]
ans = 0
def gcd(*numbers):
    return reduce(math.gcd, numbers)
for x in itertools.product(l,repeat=3):
    ans += gcd(x[0],x[1],x[2])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
#from collections import deque
input = sys.stdin.buffer.readline

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
ans = p[:x]
ans[x:x] = q[:y]
ans=sorted(ans)
#print(ans)
i = 0
result = 0
for A in ans:
    if A < r[i]:
        result += r[i]
        if i < c:
            i += 1
        continue
    result += A
print(result)

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

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
ans = p[:x]
ans[x:x] = q[:y]
ans += r
ans = sorted(ans,reverse=True)
print(sum(ans[:x+y]))

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

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
ans = p[:x]
ans[x:x] = q[:y]
ans=sorted(ans,reverse=True)
i = 0
result = 0
for A in ans:
    if A < r[i]:
        result += r[i]
        i += 1
        continue
    result += A
print(result)

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

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)
ans = p[:x]
ans[x:x] = q[:y]
ans += r
ans = sorted(ans,reverse=True)
print(sum(ans[:x+y]))
Buggy python submission (verdict: Runtime Error):
s=input()
f=1
i=0
while i<len(s):
    if s[i]=="h" and s[i+1]=="i":
        i+=2
    else:
        f=0
        break
if f:
    print("Yes")
else:
    print("No")

Fixed submission:
s=input()
f=1
i=0
if len(s)%2!=0:
    print("No")
    exit()
while i<len(s):
    if s[i]=="h" and s[i+1]=="i":
        i+=2
    else:
        f=0
        break
if f:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
x=n//(a+b)
x*=a
if a!=0:
    for i in range(n%(a+b)):
        x+=1
        a-=1
        if a==0:
            break
print(x)    

Fixed submission:
n,a,b=map(int,input().split())
x=n//(a+b)
x*=a
if a!=0:
    if n%(a+b)<a:
        x=x+(n%(a+b))
    else:
        x+=a
print(x)
Buggy python submission (verdict: Runtime Error):
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
maze=[["*" for i in range(3)] for _ in range(3)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if b[i]==a[j][k]:
                maze[j][k]="#"
for i in range(3):
    f=1
    for j in range(3):
        if maze[i][j]!="#":
            f=0
            break
    if f:
        print("Yes")
        exit()
for i in range(3):
    fc=1
    for j in range(3):
        if maze[j][i]!="#":
            fc=0
            break
    if fc:
        print("Yes")
        exit()
for i in range(3):
    fa=1
    if maze[i][i]!="#":
        fa=0
        break
if fa:
    print("Yes")
    exit()
for i in range(3):
    fe=1
    if maze[i][2-i]!="#":
        fe=0
        break
if fe:
    print("Yes")
    exit()
print("No")

Fixed submission:
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
maze=[["*" for i in range(3)] for _ in range(3)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                maze[j][k]="#"
for i in range(3):
    f=1
    for j in range(3):
        if maze[i][j]!="#":
            f=0
            break
    if f:
        print("Yes")
        exit()
for i in range(3):
    fc=1
    for j in range(3):
        if maze[j][i]!="#":
            fc=0
            break
    if fc:
        print("Yes")
        exit()
for i in range(3):
    fa=1
    if maze[i][i]!="#":
        fa=0
        break
if fa:
    print("Yes")
    exit()
for i in range(3):
    fe=1
    if maze[i][2-i]!="#":
        fe=0
        break
if fe:
    print("Yes")
    exit()
print("No")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
z={}
f=1
maxs=0
ii=1
ss=1
if m==0 and n==1:
    print(0)
    exit()
elif m==0 and n==2:
  	print(10)
    exit()
elif m==0 and n==3:
  	print(100)
    exit()
for i in range(m):
    s,c=map(int,input().split())
    if n!=1 and s==1 and c==0:
        print(-1)
        exit()
    if ii==1:
        ii=c
    elif ii!=1:
        ii=min(c,ii)
    if s not in z:
        z[s]=ii
    elif z[s]==c:
        continue
    else:
        f=0
        continue
sorted(z.items(),key=lambda x:x[1])
if not f:
    print(-1)
    exit()
for i in range(1,n+1):
    if i in z:
        print(z[i],end="")
    elif i!=1:
        print(0,end="")
    else:
        print(1,end="")

Fixed submission:
n,m=map(int,input().split())
z={}
f=1
maxs=0
ii=1
ss=1
if m==0 and n==1:
    print(0)
    exit()
elif m==0 and n==2:
    print(10)
    exit()
elif m==0 and n==3:
    print(100)
    exit()
for i in range(m):
    s,c=map(int,input().split())
    if n!=1 and s==1 and c==0:
        print(-1)
        exit()
    if ii==1:
        ii=c
    elif ii!=1:
        ii=min(c,ii)
    if s not in z:
        z[s]=ii
    elif z[s]==c:
        continue
    else:
        f=0
        continue
sorted(z.items(),key=lambda x:x[1])
if not f:
    print(-1)
    exit()
for i in range(1,n+1):
    if i in z:
        print(z[i],end="")
    elif i!=1:
        print(0,end="")
    else:
        print(1,end="")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>1:
    print(0)
    exit()
a,b=[1,1]
for i in range(1,min(n,m)+1):
    a=(a*i)%mod
if n!=m:
    b*=max(n,m)*a
    print((a*b)%mod)
else:
    b=a
    print((2*a*b)%mod)

Fixed submission:
mod=10**9+7
import math

def co(n,r,mod):
    x=1
    y=1
    for i in range(1,r+1):
        x=(x*(n-i+1))%mod
        y=(y*i)%mod
    return (x*pow(y,mod-2,mod))%mod
    
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1-co(n,a,mod)-co(n,b,mod)
print(max(ans%mod,0))#ansにmod取らないと無理
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
dp=[10**9]*(h+1)
dp[0]=0
for i in range(n):
    a,b=map(int,input().split())
    for j in range(h):
        k=min(j+a,h)
        dp[k]=min(dp[k],dp[j]+b)
print(dp[h])
#写経ABC153E

Fixed submission:
h,n=map(int,input().split())
dp=[10**9]*(h+1)
dp[0]=0
for i in range(n):
    a,b=map(int,input().split())
    for j in range(h):
        k=min(j+a,h)
        dp[k]=min(dp[k],dp[j]+b)
print(dp[h])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
ans=n
for i in range(1,n):
    for j in range(i,-1,-1):
        if l[i]>l[j]:
            ans-=1
            break
print(ans)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
ans=0
tmp=l[0]
for i in range(n):
    if tmp>=l[i]:
      tmp=l[i]
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
if m==0:
    print(0,0)
    exit()
l=[]
for i in range(m):
    x,y=input().split()
    l.append([int(x),y])
l=sorted(l,key=lambda x:x[0])
ac=0
wa=0
tmp=0
t=[0]*(n+1)

for i in range(m):
    if tmp==l[i][0]:
        continue
    if l[i][1]=="WA":
        wa+=1
    elif l[i][1]=="AC":
        ac+=1
        tmp=l[i][0]
print(ac,wa)

Fixed submission:
n,m=map(int,input().split())
p=[];s=[]
if m==0:
    print(0,0)
    exit()
for i in range(m):
    x,y=input().split()
    p.append(int(x))
    s.append(y)
ac=0
wa=0
t=[0]*(n+1)
wf=[0]*(n+1)
for i in range(m):
    if t[p[i]]>=1:
        continue
    elif s[i]=="WA":
        wf[p[i]]+=1
    elif s[i]=="AC":
        t[p[i]]+=1
        ac+=1
        wa+=wf[p[i]]
print(ac,wa)
Buggy python submission (verdict: Runtime Error):
from math import gcd
n,m = map(int,input().split())
a = list(map(lambda x: int(x)//2,input().split()))
def lcm(x,y):
    return x*y//gcd(x,y)
T = 1
for i in range(n):
    T = lcm(T,a[i])
ans=-(-(m//T)//2)
c=T
print(ans)

Fixed submission:
from fractions import gcd
n,m = map(int,input().split())
a = list(map(lambda x: int(x)//2,input().split()))
def lcm(x,y):
    return x*y//gcd(x,y)
def f(x):
    cnt = 0
    while x%2 == 0:
        x //= 2
        cnt += 1
    return cnt
r = set([f(i) for i in a])
if len(r) != 1:
    print(0)
    exit()
T = 1
for i in range(n):
    T = lcm(T,a[i])
ans=-(-(m//T)//2)
c=T
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
a,b,k=[int(x) for x in stdin.readline().rstrip().split()]
while k>0:
    if a>=1:
        a-=1
    else :
      b-=1
    k-=1
print(a,b)

Fixed submission:
from sys import stdin
a,b,k=[int(x) for x in stdin.readline().rstrip().split()]
if b+a-k<0:
    print(0,0)
elif a-k<0:
    print(0,b+a-k)
else:
    print(a-k,b)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a,b=map(int,input().split())
print(lcm(a, b))


Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
ans=(a*b)//gcd(a,b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#from math import factorial
n = int(input())
s = input()
ans = 0
for i in range(1000):
    i=str(i).zfill(3)
    now = 0
    for S in s:
        if S==i[now]:
            now+=1
        if now == 3:
            ans += 1
            break
print(ans)

Fixed submission:

n = int(input())
s = input()
ans = 0
for i in range(1000):
    i=str(i).zfill(3)
    now = 0
    for S in s:
        if S==i[now]:
            now+=1
        if now == 3:
            ans += 1
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
i=0
while True:
    a[i]=a[i]//2
    a=sorted(a)[::-1]
    m-=1
    if m==0:
        break
print(sum(a))

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


Fixed submission:
s,t=input(),input() 
print((s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]))

Buggy python submission (verdict: Runtime Error):
s,t=input(),input() print((s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]))

Fixed submission:
s,t=input(),input() 
print((s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]))
Buggy python submission (verdict: Runtime Error):
n=long(input())
print((n*(n-1))/2)


Fixed submission:
from sys import stdin
n=int(stdin.readline().rstrip())
print((n*(n-1))//2)
Buggy python submission (verdict: Runtime Error):
#ABC131D
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l=sorted(l,key=lambda x:x[1])
deadline=0
tmp=0
for i in range(n):
    tmp=l[i][1]
    deadline+=l[i][0]
    if tmp<deadline
        print("No")
        exit()
print("Yes")

Fixed submission:
#ABC131D
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
l=sorted(l,key=lambda x:x[1])
deadline=0
tmp=0
for i in range(n):
    tmp=l[i][1]
    deadline+=l[i][0]
    if tmp<deadline:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
    b,c=map(int,input().split())
    a+=[c]*b
a=sorted(a)[::-1]
ans=0
for i in range(n):
    ans+=a[i]
print(ans)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append((a[i],1))
for i in range(m):
    b,c=map(int,input().split())
    l.append((c,b))
l=sorted(l,reverse=True) #
ans,cnt=0,n
for x,y in l:
    dy=min(y,cnt) #
    dx=dy*x
    ans+=dx
    cnt-=dy #
print(ans)
#ABC127D

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
import heapq
heapq.heapify(a)
for i in range(m):
    b,c=map(int,input().split())
    for j in range(b):
        mv=heapq.heappop(a)
        if mv<c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,mv)
print(sum(a))

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append((a[i],1))
for i in range(m):
    b,c=map(int,input().split())
    l.append((c,b))
l=sorted(l,reverse=True) #
ans,cnt=0,n
for x,y in l:
    dy=min(y,cnt) #
    dx=dy*x
    ans+=dx
    cnt-=dy #
print(ans)
#ABC127D
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
n=int(input())
h=[int(a) for a in input().split()]
ans=0
for i in range(n):
  del h[i]
  ans=max(reduce(gcd,h),ans)
print(ans)

Fixed submission:
#ABC125C
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
l,r=[0]*(n+1),[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])
for i in range(n,0,-1):
    r[i-1]=gcd(r[i],a[i-1])
ans=0
for i in range(n):
    ans=max(ans,gcd(l[i],r[i+1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

n=int(input())
a=[int(input()) for i in range(n)]

print(4+math.ceil(n/min(a)))

Fixed submission:
import math

n=int(input())
a=[int(input()) for i in range(5)]

print(4+math.ceil(n/min(a)))

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=[int(input()) for i in range(n)]
w=math.ceil(n/min(a))
print(w+4)

Fixed submission:
import math

n=int(input())
a=[int(input()) for i in range(5)]

print(4+math.ceil(n/min(a)))

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=[int(input()) for i in range(n)]
m=min(a)
w=math.ceil(n/m)
print(w+4)

Fixed submission:
import math

n=int(input())
a=[int(input()) for i in range(5)]

print(4+math.ceil(n/min(a)))

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=[int(input()) for i in range(n)]
m=min(a)
w=math.ceil(n/m)
print(w+4)

Fixed submission:
import math

n=int(input())
a=[int(input()) for i in range(5)]

print(4+math.ceil(n/min(a)))

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=[int(input()) for i in range(n)]
m=min(a)
w=math.ceil(n/m)
print(w+4)

Fixed submission:
import math

n=int(input())
a=[int(input()) for i in range(5)]

print(4+math.ceil(n/min(a)))
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def gcdl(numbers):
    return reduce(math.gcd, numbers)
n=int(input())
a=list(map(int,input().split()))
print(gcdl(a))

Fixed submission:
from fractions import gcd
from functools import reduce
def gcdl(numbers):
    return reduce(gcd, numbers)
n=int(input())
a=list(map(int,input().split()))
print(gcdl(a))
Buggy python submission (verdict: Runtime Error):
#ABC111C
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common(2)
b=Counter(v[::-2]).most_common(2)
#most_common()の引数は頻度が高い数を何番目まで表示するか
if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))

Fixed submission:
#ABC111C
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common(2)+[(0,0)]
b=Counter(v[::-2]).most_common(2)+[(0,0)]
#most_common()の引数は頻度が高い数を何番目まで表示するか
#[(0,0)]を追加しないとvがすべて同じ場合範囲外指定してしまう
if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))

Buggy python submission (verdict: Runtime Error):
#ABC111C
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common(2)
b=Counter(v[1::2]).most_common(2)
#most_common()の引数は頻度が高い数を何番目まで表示するか
if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))

Fixed submission:
#ABC111C
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2]).most_common(2)+[(0,0)]
b=Counter(v[::-2]).most_common(2)+[(0,0)]
#most_common()の引数は頻度が高い数を何番目まで表示するか
#[(0,0)]を追加しないとvがすべて同じ場合範囲外指定してしまう
if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))

Fixed submission:
from fractions import gcd
from functools import reduce
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))

Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
h=list(map(int,input().split()))
tmp=abs(x-h[0])
for i in range(n):
    ans=math.gcd(abs(x-h[i]),tmp)
print(tmp)

Fixed submission:
from fractions import gcd
from functools import reduce
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))

Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
h=list(map(int,input().split()))
tmp=abs(x-h[0])
for i in range(n):
    ans=math.gcd(abs(x-h[i]),tmp)
print(tmp)

Fixed submission:
from fractions import gcd
from functools import reduce
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))

Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
h=[int(i) for i in input().split()]
tmp=abs(x-h[0])
for q in range(1,n-1):
    tmp=math.gcd(abs(x-h[q]),tmp)
print(tmp)

Fixed submission:
from fractions import gcd
from functools import reduce
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))

Buggy python submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
h=[int(i) for i in input().split()]
tmp=abs(x-h[0])
for i in range(1,n-1):
    tmp=math.gcd(abs(x-h[i]),tmp)
print(tmp)

Fixed submission:
from fractions import gcd
from functools import reduce
n,x=map(int,input().split())
h=[abs(x-int(a)) for a in input().split()]
print(reduce(gcd,h))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
wc=[0]
ec=[0]
for i in range(n):
    if s[i]=="W":
        wc.append(wc[i]+1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i]+1)
ans=10**6
for i in range(n+1):
    tmp=0
    
    tmp+=wc[i]
    tmp+=ec[n]-ec[i+1]
    ans=min(tmp,ans)
print(ans)


Fixed submission:
n=int(input())
s=input()
wc=[0]
ec=[0]
for i in range(n):
    if s[i]=="W":
        wc.append(wc[i]+1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i]+1)
ans=10**6
for i in range(n+1):
    tmp=0
    
    tmp+=wc[i]
    tmp+=ec[n]-ec[i]
    ans=min(tmp,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split()
l=[x,y]
l=sorted(l)
if l[1]%l[0]==0:
  print(-1)
else:
  print(x)

Fixed submission:
x,y=map(int,input().split())
if x%y==0:
  print(-1)
else:
  print(x)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
x,y=map(int,input().split())
ans=1
i=1
while ans<=10**18:
  ans=i*x
  if ans%y!=0:
    print(ans)
    sys.exit()
  i+=1
print(-1)


Fixed submission:
x,y=map(int,input().split())
if x%y==0:
  print(-1)
else:
  print(x)

Buggy python submission (verdict: Runtime Error):
import sys
x,y=map(int,input().split())
ans=1
i=1
while ans<=10**18:
  ans=i*x
  if ans%y=!0
    print(ans)
    sys.exit()
  i+=1
print(-1)


Fixed submission:
x,y=map(int,input().split())
if x%y==0:
  print(-1)
else:
  print(x)

Buggy python submission (verdict: Runtime Error):
import sys
x,y=map(int,input().split())
ans=1
i=1
while ans<=10**18:
  ans=i*x
  if ans%y!=0
    print(ans)
    sys.exit()
  i+=1
print(-1)

Fixed submission:
x,y=map(int,input().split())
if x%y==0:
  print(-1)
else:
  print(x)