Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import *
n,m=map(int,input().split())
l=[]
for s in m*[0]:
    a,b=map(int,input().split())
    l.append([a,b])
def f(l):
    d=defaultdict(list)
    for t in l:
        d[t[0]].append(t[1])
        d[t[1]].append(t[0])
    return d

def DFS_dict(point,TFlist,d):
    if all(TFlist):
        return 1
    ans=0
    for i in d[point]:
        if TFlist[i-1]:
            continue
        TFlist[i-1]=True
        ans+=DFS_dict(i,TFlist,d)
        TFlist[i-1]=False
    return ans
TFlist=[True]+[False]*(n-1)
for q in range(m):
    if DFS_dict(1,TFlist,f(l))>0:
        print(0)
    else:
        print(m+2-sum(len(e) for e in f(l).values())//2)
    l.pop(0)
    

Fixed submission:
class UNION_FIND(object):
    def __init__(self,n):
        #親の番号を格納する。親だった場合は-(その集合のサイズ)
        #作るときはParentの値を全て-1にする
	    #こうすると全てバラバラになる
        self.parent=[-1 for i in range(n)]
        
    def root(self,x):
        #Aがどのグループに属しているか調べる
        if self.parent[x]<0:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])
            return self.parent[x]

    def size(self,x):
        #自分のいるグループの頂点数を調べる
        return -self.parent[self.root(x)]   #親をとってきたい
        
    def union(self,x,y):
        #AとBをくっ付ける
        #AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        #print(self.parent)
        x=self.root(x)
        y=self.root(y)
        #print(x,y)
        if x==y:   #すでにくっついてるからくっ付けない
            return False
            
        #大きい方(A)に小さいほう(B)をくっ付けたい
		#大小が逆だったらひっくり返しちゃう。
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]  #Aのサイズを更新する
        self.parent[y]=x   #Bの親をAに変更する
        return True



n,m=map(int,input().split())
uni=UNION_FIND(n)
ans=n*(n-1)//2

Input=[]
anslist=[ans]
for s in m*[0]:
    a,b=map(int,input().split())
    Input.append([a-1,b-1])

for i in range(m-1,0,-1):
    x=Input[i][0]
    y=Input[i][1]
    #print(x,y)
    if uni.root(x) != uni.root(y):
        ans-=uni.size(x)*uni.size(y)
        uni.union(x,y)
    anslist.append(ans)

for t in anslist[::-1]:
    print(t)
Buggy python submission (verdict: Runtime Error):
n,*a=open(0).read().split();f=float;;print(sum([f(a[s])*380000,f(a[s])][a[s+1]=="JPY"]for s in range(0,int(n)*2,2)))

Fixed submission:
n=int(input())
ans=0
for i in range(n):
  a,b=input().split()
  if b=="JPY":
    ans+=int(a)
  else:
    ans+=float(a)*380000.0
print(ans)
Buggy python submission (verdict: Runtime Error):
from itertools import*
n,a,b,c,*l=map(int,open(0).read().split())
want=[a,b,c]
ans=0
#print(n,want,l)
for s in range(3):
  if want[s] in l:
    l.remove(want[s])
    want[s]=0
#print(want,l)
want=list(filter(lambda x:x!=0,want))
for s in range(3):
  for t in l:
    if abs(want[s]-t)<10:
      ans+=abs(want[s]-t)
      l.remove(t)
      want[s]=0
want=list(filter(lambda x:x!=0,want))
#print(want,l,ans)
x=[]
y=[]
z=[]
for s in range(1,len(l)+1):
  x.extend(list(combinations(l,s)))
#print(x)
for s in want:
  for t in range(len(x)):
    y.append(abs(s-sum(x[t]))+(len(x[t])-1)*10)
    z.append(x[t])
  ans+=min(y)
#  print(x[y.count(min(y))])
  x[y.count(min(y))]=(999999,9999999)
print(ans)

Fixed submission:
from itertools import*
n,a,b,c,*l=map(int,open(0).read().split())
d=[a,b,c]
ans=float("inf")
for i in product(range(4),repeat=n):
    take=[[],[],[]]
    for k,j in enumerate(i):  #0を捨てる
        if j!=0:
            take[j-1].append(l[k])
    if all(take):
        take2=list(map(sum,take))
        #print(sum(abs(s-t)for s,t in zip(d,take2)),(sum(map(len,take))-3)*10)
        ans=min(ans,sum(abs(s-t)for s,t in zip(d,take2))+(sum(map(len,take))-3)*10)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=0
if m>n*2:
  m-=n*2
  ans=n+m//4
elif m==n*2:
  ans=n
else:
  ans=m//2
print(ans)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
for s in range(len(a)-1):
  if s==0:x=a[s]
  x=gcd(x,a[s+1])
print(x)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(sorted(map(int,input().split()),reverse=True))
L=[]
for s in range(len(a)-1):
  x=a[s]
  b=a[s+1:]
  L.extend([x%s for s in b if x%s!=0])
if L!=[]:
  print(min([r%d for r in a for d in L if r%d!=0]))
else:
  print(0)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
for s in range(len(a)-1):
  if s==0:x=a[s]
  x=gcd(x,a[s+1])
print(x)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,split())
print("YES") if n/2-1>=k print("NO")

Fixed submission:
n,k=map(int,input().split())
print("YES") if n>=k*2-1 else print("NO")
Buggy python submission (verdict: Runtime Error):
print(int(input())/int(input()))

Fixed submission:
A,B=map(int,input().split(" "))
print('{:.10f}'.format(A/B))

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split(" "))
A=list(sorted(map(int,input().split(" "))))
L=sorted([A[s]-A[s+1] for s in range(M-1)])
print(abs(sum(L[N-1:])))

Fixed submission:
A,B=map(int,input().split(" "))
print('{:.10f}'.format(A/B))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(input())
B=list(input())
C=list(input())
litter=[]
c=0
for s in range(N):
    c+=[0,0,1,2][len(set([A[s],B[s],C[s]]))]
print(c)

Fixed submission:
N,A,B=map(int,input().split(" "))
if N-A-B>0:
	W=0
else:
    W=A+B-N
print(min(A,B),W)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
A=np.array(input().split(" ")).astype(int)
for s in range(N-1):
    B=np.array(input().split(" ")).astype(int)
    A=np.r_[A,B]
A=A.reshape(N,-1)
SUM=np.sum(A,axis=1)
SUM=sorted(SUM,reverse=True)
SUB=np.sum(A[:,1])
ans=0
for s in range(0,N,2):
    ans+=SUM[s]
    
print(ans-SUB)

Fixed submission:
n=int(input())
ans=0
l=[]
x=0
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])
    x-=b

print(sum(map(sum,sorted(l,reverse=1,key=lambda x:sum(x))[::2]))+x)
Buggy python submission (verdict: Runtime Error):
from itertools import*
from numpy import*
n,*a=map(int,open(0).read().split())
a=array(a)
count=0
ans=0
while 1:
    count=min(a[a!=0])
    ans+=count*sum(k for k,v in groupby(a>0)if k==True)
    a=a-min(a[a!=0])
    a[a<0]=0
    if sum(a)==0:
        break
print(ans)

Fixed submission:
from itertools import*
from numpy import*
n,*a=map(int,open(0).read().split())
if set(a)=={0}:
    print(0)
    exit()
a=array(a)
count=0
ans=0
while 1:
    count=min(a[a!=0])
    ans+=count*sum(k for k,v in groupby(a>0)if k==True)
    a=a-min(a[a!=0])
    a[a<0]=0
    if sum(a)==0:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import*
import functools
import sys
input=sys.stdin.readline
@functools.lru_cache(maxsize=None)
def Knapsack(N,W):
    for i in range(N):
        w,v=map(int,input().split())
        for k,b in d.copy().items():
            if k+w<=W:
                d[k+w]=max(d[k+w],b+v)
    return max(d.values())
N,W=map(int,input().split())   #pypyで実行！
d=defaultdict(int)
d[0]=0
print(Knapsack(N,W))

Fixed submission:
from collections import*
n,*h=map(int,open(0).read().split())
dp=defaultdict(int)

for i in range(1,n+1):
    dp[i]=float("inf")
dp[0]=0
for i in range(n):
    for j in range(1,3):
        if i+j<n:
            dp[i+j]=min(abs(h[i]-h[i+j])+dp[i],dp[i+j])
        else:
            break
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
n,k,*h=map(int,open(0).read().split())
dp=defaultdict(int)

for i in range(1,n+1):
    dp[i]=float("inf")
dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j]=min(abs(h[i]-h[i+j])+dp[i],dp[i+j])
        else:
            break
print(dp[n-1])


Fixed submission:
from collections import*
n,k,*h=map(int,open(0).read().split())
dp=defaultdict(int)

for i in range(1,n+1):
    dp[i]=float("inf")
dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j]=min(abs(h[i]-h[i+j])+dp[i],dp[i+j])
        else:
            break
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
n,k,*h=map(int,open(0).read().split())
dp=defaultdict(int)

for i in range(1,n+1):
    dp[i]=float("inf")
dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j]=min(abs(h[i]-h[i+j])+dp[i],dp[i+j])
            #print(dp)
print(dp[n-1])

Fixed submission:
from collections import*
n,k,*h=map(int,open(0).read().split())
dp=defaultdict(int)

for i in range(1,n+1):
    dp[i]=float("inf")
dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j]=min(abs(h[i]-h[i+j])+dp[i],dp[i+j])
        else:
            break
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
from collections import*
d=defaultdict(int)
d[0]=0
for i in range(N):
    w,v=map(int,input().split())
    for k,b in d.copy().items():
        if k+w<=W:
            d[k+w]=max(d[k+w],b+v)
print(max(d.values()))

Fixed submission:
from numpy import*
N,W=map(int, input().split())
dp=zeros(W+1)
for i in range(N):
    w,v=map(int, input().split())
    dp[w:]=maximum(dp[w:], dp[:-w]+v)
print(int(max(dp)))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
ans=0
for s in range(a):
    d,e=map(int,input().split())
    if b<=d and c<=e:
        ans+=1
print(ans)

Fixed submission:
print(input().count("2"))
Buggy python submission (verdict: Runtime Error):
_,*a=map(int,open(0).readlines());print(sum(a)-max(a)//2)

Fixed submission:
print("Christmas"+(25-int(input()))*" Eve")
Buggy python submission (verdict: Runtime Error):
s=input();print(min(abs(int(s[i:i+3])-753)for i in range(7)))

Fixed submission:
s=input();print(min(abs(int(s[i:i+3])-753)for i in range(len(s)-2)))

Buggy python submission (verdict: Runtime Error):
s=input();print(min(abs(int(s[i:i+3])-753)for i in range(8)))

Fixed submission:
s=input();print(min(abs(int(s[i:i+3])-753)for i in range(len(s)-2)))

Buggy python submission (verdict: Runtime Error):
s=input();print(min(abs(int(s[i:i+3])-753)for i in range(9)))

Fixed submission:
s=input();print(min(abs(int(s[i:i+3])-753)for i in range(len(s)-2)))
Buggy python submission (verdict: Runtime Error):
import itertools
n=input()
c=[0,0,6,36,150,540,1806,5796,18150]
b=len(list(a for a in itertools.product(["3","5","7"],repeat=len(n))if len(set(a))==3 and int("".join(a))<int(n)))
print(sum(c[:l-1])+b)

Fixed submission:
import itertools
n=input()
c=[0,0,6,36,150,540,1806,5796,18150]
b=len(list(a for a in itertools.product(["3","5","7"],repeat=len(n))if len(set(a))==3 and int("".join(a))<=int(n)))
print(sum(c[:len(n)-1])+b)
Buggy python submission (verdict: Runtime Error):
input();a=map(int,input().split());b=[abs(i-sum(a)/n)for i in a];print(b.index(min(b)))

Fixed submission:
n,*a=map(int,open(0).read().split());b=[abs(i-sum(a)/n)for i in a];print(b.index(min(b)))
Buggy python submission (verdict: Runtime Error):
import collections as c
d=c.defaultdict(list)
d2=c.defaultdict(list)
a,b,*q=map(int,open(0).read().split())
for s in range(b):
    g,j=q[2*s],q[2*s+1]
    d[g].append(j)
    d[g]=sorted(d[g])
for t in d.keys():
    for k,v in enumerate(d[t]):
        d2[t].append((v,k+1))
for s in range(b):
    g,j=q[2*s],q[2*s+1]
    for sss in d2[g]:
        if sss[0]==j:
            print('{:06d}'.format(g)+'{:06d}'.format(sss[1]))

Fixed submission:
a,b=map(int,input().split());print(a+b//2)
Buggy python submission (verdict: Runtime Error):
from fractions import*
a,b=map(int,input().split())
c=a*b//gcd(a,b)
d=[0]*c
s=input()
t=input()
for i in range(a):
    d[i*(c//a)]=s[i]
for i in range(b):
    if d[i*(c//b)]!=t[i]:
        if d[i*(c//b)]==0:
            continue
        else:
            print(-1)
            exit()
print(c)

Fixed submission:
from fractions import*
a,b=map(int,input().split())
c=gcd(a,b)
d=a*b//gcd(a,b)
s=input()
t=input()
for i in range(c):
    if s[i*(a//c)] != t[i*(b//c)]:
        print(-1)
        exit()
print(d)

Buggy python submission (verdict: Runtime Error):
from fractions import*
a,b=map(int,input().split())
c=a*b//gcd(a,b)
d=[0]*c
s=input()
t=input()
for i in range(a):
    try:
        d[i*(c//a)]=s[i]
    except:
for i in range(b):
    if d[i*(c//b)]!=t[i]:
        if d[i*(c//b)]==0:
            continue
        else:
            print(-1)
            exit()
    print(-1)
print(c)

Fixed submission:
from fractions import*
a,b=map(int,input().split())
c=gcd(a,b)
d=a*b//gcd(a,b)
s=input()
t=input()
for i in range(c):
    if s[i*(a//c)] != t[i*(b//c)]:
        print(-1)
        exit()
print(d)

Buggy python submission (verdict: Runtime Error):
from fractions import*
a,b=map(int,input().split())
c=a*b//gcd(a,b)
d=[0]*c
s=input()
t=input()
for i in range(a):
    d[i*(c//a)]=s[i]
for i in range(b):
    try:
        if d[i*(c//b)]!=t[i]:
            if d[i*(c//b)]==0:
                continue
            else:
                print(-1)
                exit()
    except:
        print(-1)
print(c)

Fixed submission:
from fractions import*
a,b=map(int,input().split())
c=gcd(a,b)
d=a*b//gcd(a,b)
s=input()
t=input()
for i in range(c):
    if s[i*(a//c)] != t[i*(b//c)]:
        print(-1)
        exit()
print(d)

Buggy python submission (verdict: Runtime Error):
from fractions import*
a,b=map(int,input().split())
c=a*b//gcd(a,b)
d=[0]*c
s=input()
t=input()
for i in range(a):
    d[i*(c//a)]=s[i]
for i in range(b):
    if d[i*(c//b)]!=t[i]:
        if d[i*(c//b)]==0:
            continue
        else:
            print(-1)
            exit()
print(c)

Fixed submission:
from fractions import*
a,b=map(int,input().split())
c=gcd(a,b)
d=a*b//gcd(a,b)
s=input()
t=input()
for i in range(c):
    if s[i*(a//c)] != t[i*(b//c)]:
        print(-1)
        exit()
print(d)
Buggy python submission (verdict: Runtime Error):
from copy import deepcopy
n=int(input())
l=[tuple(map(int,input().split()))for i in range(n)]
l=[i for i in l if i[2]!=0]
s=l[0]
l2=[[x,y,s[2]+abs(x-s[0])+abs(y-s[1])]for y in range(101)for x in range(101)]
l3=deepcopy(l2)
for s in l3:
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
print(*l2[0])

Fixed submission:
input()
try:print(int(input())+int(input()))
except:print("Hello World")
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[tuple(map(int,input().split()))for i in range(n)]
l=[i for i in l if i[2]!=0]
s=l[0]
l2=[[x,y,s[2]+abs(x-s[0])+abs(y-s[1])]for y in range(101)for x in range(101)]
for s in l2.copy():
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
print(*l2[0])

Fixed submission:
n=int(input())
l=[]
for i in range(n):
    a,b,c=map(int,input().split())
    l.append((a,b,c))
    if c>0:
        x,y,h=a,b,c
ma=len(l)
for s in range(101):
    for t in range(101):
        x2,y2,h2=s,t,h+abs(x-s)+abs(y-t)  #候補点
        c=0
        if all(h3==max(h2-abs(x3-x2)-abs(y3-y2),0)for(x3,y3,h3)in l):
            print(x2,y2,h2)
            exit()
print(-1,-1,-1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[tuple(map(int,input().split()))for i in range(n)]
s=l[0]
l2=[[x,y,s[2]+abs(x-s[0])+abs(y-s[1])]for y in range(101)for x in range(101)]
for s in l2.copy():
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
print(*l2[0])

Fixed submission:
n=int(input())
l=[]
for i in range(n):
    a,b,c=map(int,input().split())
    l.append((a,b,c))
    if c>0:
        x,y,h=a,b,c
ma=len(l)
for s in range(101):
    for t in range(101):
        x2,y2,h2=s,t,h+abs(x-s)+abs(y-t)  #候補点
        c=0
        if all(h3==max(h2-abs(x3-x2)-abs(y3-y2),0)for(x3,y3,h3)in l):
            print(x2,y2,h2)
            exit()
print(-1,-1,-1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
    a,b,c=map(int,input().split())
    if c>0:
        l.append([a,b,c])
s=l[0]
l2=[]
for x in range(100):
    for y in range(100):
        l2.append([x,y,s[2]+abs(x-s[0])+abs(y-s[1])])
for s in l2.copy():
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
            
print(*l2[0])

Fixed submission:
n=int(input())
l=[]
for i in range(n):
    a,b,c=map(int,input().split())
    l.append((a,b,c))
    if c>0:
        x,y,h=a,b,c
ma=len(l)
for s in range(101):
    for t in range(101):
        x2,y2,h2=s,t,h+abs(x-s)+abs(y-t)  #候補点
        c=0
        if all(h3==max(h2-abs(x3-x2)-abs(y3-y2),0)for(x3,y3,h3)in l):
            print(x2,y2,h2)
            exit()
print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
from collections import*
n,*v=open(0).read().split()
n=int(n)
a=[v[s]for s in range(0,n,2)]
b=[v[s]for s in range(1,n,2)]
#print(Counter(a).most_common(),Counter(b).most_common())
c=Counter(a).most_common()
d=Counter(b).most_common()
if c[0][1]!=d[0][1]:
  print(sum([s[1]for s in c[1:]])+sum([s[1]for s in d[1:]]))
else:
  if len(c)and len(d)==1:
    if c==d:
      print(n//2)
    else:
      print(0)
  else:
    x=sum([s[1]for s in c[1:]])+sum(d[0][1]+[s[1]for s in d[2:]])
    y=sum([s[1]for s in d[1:]])+sum(c[0][1]+[s[1]for s in c[2:]])
    print(min(x,y))    

Fixed submission:
from collections import*
n,*a=map(int,open(0).read().split())
odd =Counter([v for k,v in enumerate(a) if k%2==0]).most_common()
even=Counter([v for k,v in enumerate(a) if k%2==1]).most_common()


if len(odd)==len(even)==1:
    if odd[0][0]==even[0][0]:
        print(len(a)//2)
    else:
        print(0)
elif odd[0][0]!=even[0][0]:
    print(sum(t for(s,t)in odd[1:])+sum(t for(s,t)in even[1:]))
else:
    a=odd[0][1]+sum(t for(s,t)in odd[2:])+sum(t for(s,t)in even[1:])
    b=even[0][1]+sum(t for(s,t)in even[2:])+sum(t for(s,t)in odd[1:])
    print(min(a,b))
Buggy python submission (verdict: Runtime Error):
import collections as c
s=input()
t=input()
d=c.defaultdict(list)
d2=c.defaultdict(list)
for k,v in enumerate(s):
    d[v].append(k)
for k,v in enumerate(t):
    d2[v].append(k)
if list(d.values())==list(d2.values()):
    print("Yes")
else:
    print("No")

Fixed submission:
a=list(sorted(input().split()))[::-1];a.insert(2,"+");print(eval("".join(a)))
Buggy python submission (verdict: Runtime Error):
_,b,c,d,*e=map(int,open(0).read().split());print((c<max(e[:b])<min(e[b:]<d))*"No "+"War")

Fixed submission:
n,m,x,y=map(int,input().split())
zmin=max(map(int,input().split()))
zmax=min(map(int,input().split()))
if max(zmin,x)<min(zmax,y):
    print("No War")
else:
    print("War")
Buggy python submission (verdict: Runtime Error):
from itertools import*;i=lambda:sorted([len(list(v))for k,v in groupby(input()]);print('YNeos'[i()!=i()::2])

Fixed submission:
import collections as c
s=input()
t=input()
d=c.defaultdict(list)
d2=c.defaultdict(list)
for k,v in enumerate(s):
    d[v].append(k)
for k,v in enumerate(t):
    d2[v].append(k)
a=set(tuple(i) for i in d.values())
b=set(tuple(i) for i in d2.values())
if a==b:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import collections as c
s=input()
t=input()
d=c.defaultdict(list)
d2=c.defaultdict(list)
for k,v in enumerate(s):
    d[v].append(k)
for k,v in enumerate(t):
    d2[v].append(k)
if set(tuple(d.values()))==set(tuple(d2.values())):
    print("Yes")
else:
    print("No")

Fixed submission:
import collections as c
s=input()
t=input()
d=c.defaultdict(list)
d2=c.defaultdict(list)
for k,v in enumerate(s):
    d[v].append(k)
for k,v in enumerate(t):
    d2[v].append(k)
a=set(tuple(i) for i in d.values())
b=set(tuple(i) for i in d2.values())
if a==b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from fractions import*;from functools import*;n,x,*a=map(int,open(0).read().split());print(reduce(gcd,[abs(x-i)for i in a]))

Fixed submission:
a,b=map(int,input().split());print("YNeos"[a*b%2!=1and 3*a*b%2!=1::2])
Buggy python submission (verdict: Runtime Error):
_,a=open(0).readlines()
if len(set(a))<len(a):
  print("No")
  exit()
b=[(i[0],i[-2]) for i in a]
for k in range(len(b)-1):
  if b[k][1]!=b[k+1][0]:
    print("No")
    exit()
print("Yes")

Fixed submission:
_,*a=open(0).readlines()
if len(set(a))<len(a):
  print("No")
  exit()
b=[(i[0],i[-2]) for i in a]
for k in range(len(b)-1):
  if b[k][1]!=b[k+1][0]:
    print("No")
    exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
from fractions import*
from functools import*
n,x,*a=map(int,open(0).read().split())
a=[abs(a[i+1]-a[i]) for i in range(n-1)]
print(reduce(gcd,a))

Fixed submission:
from fractions import*
from functools import*
n,x,*a=map(int,open(0).read().split())
b=[abs(x-i)for i in a]
print(reduce(gcd,b))
Buggy python submission (verdict: Runtime Error):
from numpy import *
a,b=map(int,input().split())
c=array([list(input())for i in range(a)])
bl=[]
for i in c:
    if any(i=="#"):
        bl.append(True)
    else:
        bl.append(False)
c=c[bl]
bl2=[]
for i in range(b):
    if any(c[:,i]=="#"):
        bl2.append(True)
    else:
        bl2.append(False)
for i in c[:,bl2]:
    print("".join(i))

Fixed submission:
a,b=map(int,input().split())
l=[]
for i in range(a):
    s=input()
    if set(s)=={"."}:
        continue
    else:
        l.append(s)
#print(l)
r=""
l2=[]
for i in range(b):
    for t in range(len(l)):
        r+=l[t][i]
#    print(r)
    if set(r)!={"."}:
        l2.append(r)
    r=""
g=""
#print(l2)
for i in range(len(l2[0])):
    for t in l2:
        g+=t[i]
    print(g)
    g=""
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import*
n,k,*a=map(int,open(0).read().split())
if 0 in a:
    k-=1
    a.remove(0)
#print(a)
ans=[]
for i in range(-k,1):
    b=a[bisect(a,0)+i:bisect(a,0)+i+k]
    if len(b)==0:
        continue
    if len(b)==k:
        #print(b)
        ans.append(abs(b[0])+abs(b[-1]-b[0]))
        ans.append(abs(b[-1])+abs(b[-1]-b[0]))
print(min(ans or [0]))

Fixed submission:
from bisect import*
n,k,*a=map(int,open(0).read().split())
if 0 in a:
    k-=1
    a.remove(0)
#print(a)
ans=[]

x=bisect(a,0)
for i in range(-k,1):
    p=x+i
    q=x+i+k-1

    if 0<=p<n and 0<=q<n:
        #print(p,q)
        c=a[p]
        d=a[q]
        ans.append(abs(c)+abs(d-c))
        ans.append(abs(d)+abs(d-c))
#print(ans)
print(min(ans or [0]))

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import*
n,k,*a=map(int,open(0).read().split())
if 0 in a:
    k-=1
    a.remove(0)
#print(a)
ans=[]
for i in range(-k,1):
    b=a[bisect(a,0)+i:bisect(a,0)+i+k]
    if len(b)==0:
        continue
    if len(b)==k:
        #print(b)
        ans.append(abs(b[0])+abs(b[-1]-b[0]))
        ans.append(abs(b[-1])+abs(b[-1]-b[0]))
print(min(ans or [0]))

Fixed submission:
from bisect import*
n,k,*a=map(int,open(0).read().split())
if 0 in a:
    k-=1
    a.remove(0)
#print(a)
ans=[]

x=bisect(a,0)
for i in range(-k,1):
    p=x+i
    q=x+i+k-1

    if 0<=p<n and 0<=q<n:
        #print(p,q)
        c=a[p]
        d=a[q]
        ans.append(abs(c)+abs(d-c))
        ans.append(abs(d)+abs(d-c))
#print(ans)
print(min(ans or [0]))
Buggy python submission (verdict: Runtime Error):
print(max(1,input()[:int(input())].replace("1","")[:1]))

Fixed submission:
s=input()
k=int(input())
for i in range(k):
    if s[i] !="1":
        print(s[i])
        exit()
print("1")

Buggy python submission (verdict: Runtime Error):
print(max(1,[int(i)for i in input()[:int(input())]if i!="1"][0]))

Fixed submission:
s=input()
k=int(input())
for i in range(k):
    if s[i] !="1":
        print(s[i])
        exit()
print("1")

Buggy python submission (verdict: Runtime Error):
print([i for i in input()[:int(input())]if i!="1"][0])

Fixed submission:
s=input()
k=int(input())
for i in range(k):
    if s[i] !="1":
        print(s[i])
        exit()
print("1")