Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split());x=y=0
for(a,b)in sorted([list(map(int,input().split()))for i in range(m)],key=lambda x:x[1]):
 if a>x:
  x=b-1
  y+=1
print(y)

Fixed submission:
a,b,c=sorted(map(int,input().split()));print(c-a)

Buggy python submission (verdict: Runtime Error):
input();print(sum(int(a)-1for i in input().split()))

Fixed submission:
a,b,c=sorted(map(int,input().split()));print(c-a)
Buggy python submission (verdict: Runtime Error):
input();print(sum(int(a-1)for i in input().split()))

Fixed submission:
print(sum(i-1for i in list(map(int,open(0).read().split()))[1:]))

Buggy python submission (verdict: Runtime Error):
print(sum(i-1for i in map(int,open(0).read().split())[1:]))

Fixed submission:
print(sum(i-1for i in list(map(int,open(0).read().split()))[1:]))
Buggy python submission (verdict: Runtime Error):
import operator as o
import functools as f
n,*a=map(int,open(0).read().split())
#print(f.reduce(o.mul,a))
a=[s for s in a if s%2==0]
x=f.reduce(o.mul,a)
count=0
while True:
    if x%2==0:
        x=x//2
        count+=1
    else:
        break
print(count)

Fixed submission:
n,*a=map(int,open(0).read().split())
#print(f.reduce(o.mul,a))
a=[s for s in a if s%2==0]
if len(a)==0:
    print(0)
    exit()
count=0

for x in a:
    while True:
        if x%2==0:
            x=x//2
            count+=1
        else:
            break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import operator as o
import functools as f
n,*a=map(int,open(0).read().split())
#print(f.reduce(o.mul,a))
x=f.reduce(o.mul,a)
count=0
while True:
    if x%2==0:
        x=x//2
        count+=1
    else:
        break
print(count)

Fixed submission:
n,*a=map(int,open(0).read().split())
#print(f.reduce(o.mul,a))
a=[s for s in a if s%2==0]
if len(a)==0:
    print(0)
    exit()
count=0

for x in a:
    while True:
        if x%2==0:
            x=x//2
            count+=1
        else:
            break
print(count)
Buggy python submission (verdict: Runtime Error):
from numpy import array
n=int(input())
s=input()
t=s.count("E")
r=s.count("W")
dp =[r-(s[-1]=="W")]+[0 for i in range(n-1)]
dp2=[t-(s[0 ]=="E")]+[0 for i in range(n-1)]

for i in range(1,n):
    if s[i]=="W":
        dp2[i]=dp2[i-1]
    else:
        dp2[i]=dp2[i-1]-1
    if s[::-1][i]=="E":
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]-1
print(min(array(dp[::-1])+array(dp2)))

Fixed submission:
from numpy import*
n=int(input())
s=input()
x=[0]+[1 if i=="W" else 0 for i in s]
del x[-1]
y=[1 if i=="E" else 0 for i in s]
print(min(array(cumsum(x))+s.count("E")-array(cumsum(y))))

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import array
n=int(input())
s=input()
t=s.count("E")
r=s.count("W")
dp =[r-(s[-1]=="W")]+[0 for i in range(n-1)]
dp2=[t-(s[0 ]=="E")]+[0 for i in range(n-1)]

for i in range(1,n):
    if s[i]=="W":
        dp2[i]=dp2[i-1]
    else:
        dp2[i]=dp2[i-1]-1
    if s[::-1][i]=="E":
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]-1
print(min(array(dp[::-1])+array(dp2)))

Fixed submission:
from numpy import*
n=int(input())
s=input()
x=[0]+[1 if i=="W" else 0 for i in s]
del x[-1]
y=[1 if i=="E" else 0 for i in s]
print(min(array(cumsum(x))+s.count("E")-array(cumsum(y))))

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import array
n=int(input())
s=input()
t=s.count("E")
r=s.count("W")
dp =[r-(s[-1]=="W")]+[0 for i in range(n-1)]
dp2=[t-(s[0 ]=="E")]+[0 for i in range(n-1)]
for i in range(1,n):
    if s[::-1][i]=="E":
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]-1

for i in range(1,n):
    if s[i]=="W":
        dp2[i]=dp2[i-1]
    else:
        dp2[i]=dp2[i-1]-1

print(min(array(dp[::-1])+array(dp2)))

Fixed submission:
from numpy import*
n=int(input())
s=input()
x=[0]+[1 if i=="W" else 0 for i in s]
del x[-1]
y=[1 if i=="E" else 0 for i in s]
print(min(array(cumsum(x))+s.count("E")-array(cumsum(y))))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
print(min(s[:i].count("W")+s[i+1:].count("E")for i in range(n)))

Fixed submission:
from numpy import*
n=int(input())
s=input()
x=[0]+[1 if i=="W" else 0 for i in s]
del x[-1]
y=[1 if i=="E" else 0 for i in s]
print(min(array(cumsum(x))+s.count("E")-array(cumsum(y))))
Buggy python submission (verdict: Runtime Error):
x=int(input())
l=[]
for s in range(1,x):
  for t in range(2,x):
    if s**t<x:
      l.append(s**t)
    if s**t>x:
      break
print(max(l))

Fixed submission:
x=int(input())
l=[]
for i in range(1,40):
  for j in range(2,40):
    if i**j<=x:
      l.append(i**j)
print(max(l))

Buggy python submission (verdict: Runtime Error):
x=int(input())
l=[]
for s in range(x):
  for t in range(2,x):
    if s**t<=x:
      l.append(s**t)
print(max(l))

Fixed submission:
x=int(input())
l=[]
for i in range(1,40):
  for j in range(2,40):
    if i**j<=x:
      l.append(i**j)
print(max(l))
Buggy python submission (verdict: Runtime Error):
from itertools import*
s=input()
k=int(input())
l=[]
for i in range(1,10):
    for t in range(len(s)+1-i):
        if len(set(s[t:t+i]))!=1:
            l.append(s[t:t+i])
for i in set(s):
    l.append(i)
print(sorted(set(l))[k-1])

Fixed submission:
s=input()
k=int(input())
l=[]
for i in range(1,k+1):
    for t in range(len(s)-i+1):
        l.append(s[t:t+i])
print(sorted(set(l))[k-1])

Buggy python submission (verdict: Runtime Error):
from itertools import*
s=input()
k=int(input())
l=[]
for i in range(1,6):
    for t in range(len(s)+1-i):
        if len(set(s[t:t+i]))!=1:
            l.append(s[t:t+i])
for i in set(s):
    l.append(i)
print(sorted(set(l))[k-1])

Fixed submission:
s=input()
k=int(input())
l=[]
for i in range(1,k+1):
    for t in range(len(s)-i+1):
        l.append(s[t:t+i])
print(sorted(set(l))[k-1])
Buggy python submission (verdict: Runtime Error):
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])  #親を再帰で探知 再帰は最後に上のifにひっかかる
            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


a,b=map(int,input().split())
*p,=map(int,input().split())
u=UNION_FIND(a)
d=defaultdict(list)

p=array(p)
for i in range(b):
    x,y=map(int,input().split())
    u.union(x-1,y-1)
for i in range(a):
    ans+=(u.root(i)==u.root(p[i]))
print(ans)


Fixed submission:
from numpy import*
from collections import*
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])  #親を再帰で探知 再帰は最後に上のifにひっかかる
            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


a,b=map(int,input().split())
*p,=map(int,input().split())
u=UNION_FIND(a)
d=defaultdict(list)

p=array(p)
for i in range(b):
    x,y=map(int,input().split())
    u.union(x-1,y-1)
for k,v in enumerate(u.root(i)for i in range(a)):
    d[v].append(k)
ans=0
for i in d.values():
    i=array(i)
    ans+=len(set(i+1)&set(p[i]))
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
grid=[["."]*(a+2)]+[list("."+input()+".")for i in range(b)]+[["."]*(a+2)]
for s in range(1,1+a):
    for t in range(1,1+b):
        if grid[s][t]=="#" and all([grid[s+x][t+y]=="."for x,y in ([0,-1],[0,1],[1,0],[-1,0])]):
            print("No")
            exit()
print("Yes")

Fixed submission:
a,b=map(int,input().split());print(a-(b<a))
Buggy python submission (verdict: Runtime Error):
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

x=[i for i in range(2,55556)if is_prime(i)and i%5==1]
print(*x[:int(input())])

Fixed submission:
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

x=[i for i in range(2,55556)if is_prime(i)and i%5==1]
print(*x[:int(input())])
Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split())
c=0
for s in range(1,n+1): #長さ
    for t in range(n-s+1):
        if sum(a[t:t+s])==0:
            c+=1
print(c)

Fixed submission:
from itertools import*
from collections import*
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n,*a=map(int,open(0).read().split())
print(sum(cmb(v,2)for k,v in Counter(accumulate(a)).items() if v>1)+list(accumulate(a)).count(0))

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
print(q)
ans=0
for t in range(2,n):
    for s in range(n):
        try:
            if s+t>n:
                break
   #         print(q[s:s+t])
            if sum(q[s:s+t])==0:
                ans+=1
        except:
            break
print(ans)

Fixed submission:
from itertools import*
from collections import*
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n,*a=map(int,open(0).read().split())
print(sum(cmb(v,2)for k,v in Counter(accumulate(a)).items() if v>1)+list(accumulate(a)).count(0))
Buggy python submission (verdict: Runtime Error):
n,c = map(int,input().split())
x = [0]
v = [0]
rf = [0] * (n+2)
rg = [0] * (n+2)
lf = [0] * (n+2)
lg = [0] * (n+2)
for i in range(0,n):
    X,V = map(int,input().split())
    x.append(X)
    v.append(V)
for i in range(0,n):
    rf[i+1] = rf[i] + v[i+1]
    rg[i+1] = max(rg[i],rf[i+1] - x[i+1])
for i in range(n+1,1,-1):
    lf[i-1] = lf[i] + v[i-1]
    lg[i-1] = max(lg[i],lf[i-1] - (c-x[i-1]))

#print(lg[::-1])
#print(rg)

for i in range(1,n):
    ans = max(ans,rg[i]+lg[i+1] - x[i],rg[i]+lg[i+1] - (c - x[i+1]))
print(ans)

Fixed submission:
from itertools import*
from numpy import array
n,c=map(int,input().split())

l1=[]
l2=[]
for i in range(n):
    x,v=map(int,input().split())
    l1.append(x)
    l2.append(v)
#print(l1,l2)

ll=array([0]+l1)
lll=array([0]+list(accumulate(l2)))
lr=array([0]+[c-i for i in l1][::-1])
llr=array([0]+list(accumulate(l2[::-1])))
x=lll-ll
y=llr-lr
for i in range(1,n+1):
    x[i]=max(x[i-1],x[i])
    y[i]=max(y[i-1],y[i])
z=array([min(ll[::-1][i],lr[i])for i in range(n+1)])
print(max(x[::-1]+y-z))
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce
from bisect import*
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,*a=map(int,open(0).read().split())
a.sort()
b=a.pop()
#print(a)
if n>10:
    x=bisect_left(a,b//2)
    if x>=n-1:
        print(b,a.pop())
    else:
        z=[cmb(b,a[i])for i in range(x-2,x+1)]
        y=max(z)
        print(b,a[x+z.index(y)-1])
elif n==2:
    print(b,*a)
else:
    z=[cmb(b,a[i])for i in range(n-1)]
    y=a[z.index(max(z))]
    print(b,y)

Fixed submission:
n,*a=map(int,open(0).read().split())
a.sort()
b=a.pop()
dif=float("inf")
ans=0
for i in range(n-1):
    if abs(a[i]-b/2)<dif:
        ans=a[i]
        dif=abs(a[i]-b/2)
print(b,ans)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce
from bisect import*
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,*a=map(int,open(0).read().split())
a.sort()
b=a.pop()
#print(a)
if n>10:
    x=bisect_left(a,b//2)
    if x>=n-1:
        print(b,a.pop())
    else:
        z=[cmb(b,a[i])for i in range(x-2,x+1)]
        y=max(z)
        print(b,a[x+z.index(y)-1])
elif n==2:
    print(b,*a)
else:
    z=[cmb(b,a[i])for i in range(n-1)]
    y=a[z.index(max(z))]
    print(b,y)


Fixed submission:
n,*a=map(int,open(0).read().split())
a.sort()
b=a.pop()
dif=float("inf")
ans=0
for i in range(n-1):
    if abs(a[i]-b/2)<dif:
        ans=a[i]
        dif=abs(a[i]-b/2)
print(b,ans)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,*a=map(int,open(0).read().split())
a.sort()
b=a[-1]
if n>10:
    a=a[n//3:n*2//3]
c=[cmb(b,i) for i in a]
print(b,a[c.index(max(c))])

Fixed submission:
n,*a=map(int,open(0).read().split())
a.sort()
b=a.pop()
dif=float("inf")
ans=0
for i in range(n-1):
    if abs(a[i]-b/2)<dif:
        ans=a[i]
        dif=abs(a[i]-b/2)
print(b,ans)
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
for i in range(a,b+1):
  print(i)

Fixed submission:
print("YNeos"[set(input())!=set("abc")::2])

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split());r=range(a,b+1)
for i in r:
  if i not in set(r[k:-k]):
    print(i)

Fixed submission:
print("YNeos"[set(input())!=set("abc")::2])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split());r=range(a,b+1)
for i in r:
  if i not in set(r[k:-k]):
    print(i)

Fixed submission:
a,b,k=map(int,input().split())
s=list((range(a,b+1)[:k]))
t=list(range(a,b+1)[-k:])
for r in sorted(set([s,s+t][b>k])):print(r)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split());r=range(a,b+1)
for i in sorted(set(r)-set(r[k:-k])):print(i)

Fixed submission:
a,b,k=map(int,input().split())
s=list((range(a,b+1)[:k]))
t=list(range(a,b+1)[-k:])
for r in sorted(set([s,s+t][b>k])):print(r)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split());r=range(a,b+1)
for i in sorted(set(r)-set(r[k:-k])):print(i)

Fixed submission:
a,b,k=map(int,input().split())
s=list((range(a,b+1)[:k]))
t=list(range(a,b+1)[-k:])
for r in sorted(set([s,s+t][b>k])):print(r)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split());r=range(a,b+1)
for i in sorted(set(r)-set(r[k:-k])):
  print(i)

Fixed submission:
a,b,k=map(int,input().split())
s=list((range(a,b+1)[:k]))
t=list(range(a,b+1)[-k:])
for r in sorted(set([s,s+t][b>k])):print(r)
Buggy python submission (verdict: Runtime Error):
s=input()
t=0
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    r=[ord(x) for x in s]
#    print(r)
    if len(s)==26:
        while 1:
            if r[t+1]==r[t]+1:
                t+=1
                continue
            else:
              #  print(r[t+1])
                print(s[:t]+chr(min(r[t+1:])))
                break
    else:
        print(s+ chr(min(list(set(range(97,123))-set(r)))) )

Fixed submission:
s = input()+"`"

for j in reversed(range(len(s))):
    sets=set(s[:j])
    for i in range(ord(s[j])+1,123):
        if chr(i) not in sets:
            print(s[:j] + chr(i))
            exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
for i in range(n):
  s=[0]+a[:i]+a[i+1:]+[0]
  print(sum(abs(s[t]-s[t+1])for t in range(n)))

Fixed submission:
a,b,c,d=map(int,open(0).readlines());print([a,b][a>b]+[c,d][c>d])
Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split());c=[0]+a+[0]
for i in range(n):s,t,r=c[i:i+3];print(sum(abs(c[t]-c[t+1])for t in range(n+1))+abs(r-s)-abs(t-s)-abs(t-r))

Fixed submission:
n,*a=map(int,open(0).read().split())
c=[0]+a+[0]
y=sum(abs(c[t]-c[t+1])for t in range(n+1))
for i in range(n):
  s,t,r=c[i:i+3]
  print(y+abs(r-s)-abs(t-s)-abs(t-r))

Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split())
for i in range(n):
  s=[0]+a[:i]+a[i+1:]+[0]
  print(sum(abs(s[t]-s[t+1])for t in range(n)))

Fixed submission:
n,*a=map(int,open(0).read().split())
c=[0]+a+[0]
y=sum(abs(c[t]-c[t+1])for t in range(n+1))
for i in range(n):
  s,t,r=c[i:i+3]
  print(y+abs(r-s)-abs(t-s)-abs(t-r))

Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split())
for i in range(n):
  s=[0]+a[:i]+a[i+1:]+[0]
  print(sum(abs(s[t]-s[t+1])for t in range(n)))

Fixed submission:
n,*a=map(int,open(0).read().split())
c=[0]+a+[0]
y=sum(abs(c[t]-c[t+1])for t in range(n+1))
for i in range(n):
  s,t,r=c[i:i+3]
  print(y+abs(r-s)-abs(t-s)-abs(t-r))

Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split())
for i in range(n):s=[0]+a[:i]+a[i+1:]+[0];print(sum(abs(s[t]-s[t+1])for t in range(n)))

Fixed submission:
n,*a=map(int,open(0).read().split())
c=[0]+a+[0]
y=sum(abs(c[t]-c[t+1])for t in range(n+1))
for i in range(n):
  s,t,r=c[i:i+3]
  print(y+abs(r-s)-abs(t-s)-abs(t-r))
Buggy python submission (verdict: Runtime Error):
n=int(input())
r=[]
for i in range(n):
    a,b=map(int,input().split())
    r.append((a,b))
l=[]
for i in range(n):
    c,d=map(int,input().split())
    l.append((c,d))


r.sort()
l.sort(key=lambda x:x[1],reverse=1)
ans=0
for s,t in r.copy():
    for p,q in l.copy():
        if s<p and t<q:
            ans+=1
            r.remove((s,t))
            l.remove((p,q))
            break
print(ans)

Fixed submission:
from collections import*
n,*a=open(0).read().split()
blue=a[0:int(n)]
red=a[int(n)+1:]
print(max(0,max(v-Counter(red)[k] for k,v in Counter(blue).items())))
Buggy python submission (verdict: Runtime Error):
n=int(input())
r=[]
for i in range(n):
    a,b=map(int,input().split())
    r.append((a,b))
l=[]
for i in range(n):
    c,d=map(int,input().split())
    l.append((c,d))


r.sort()
l.sort(key=lambda x:x[1],reverse=1)
ans=0
for s,t in r.copy():
    for p,q in l.copy():
        if s<p and t<q:
            ans+=1
            r.remove((s,t))
            l.remove((p,q))
print(ans)

Fixed submission:
n=int(input())
x=sorted([tuple(map(int,input().split()))for i in range(n)],key=lambda x:x[1])[::-1]
y=sorted([tuple(map(int,input().split()))for i in range(n)])
#print(x)
#print(y)
ans=0
for j in x.copy():
    for i in y.copy():
        s,t=i
        p,q=j
        if p<s and q<t:
            y.remove((s,t))
            x.remove((p,q))
            #print(p,q,s,t)
            ans+=1
            break
    #print(x,y)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,open(0).readlines());print([a,b][a>b]+[c,d][c>d])

Fixed submission:
print(input()[0]+input()[1]+input()[2])
Buggy python submission (verdict: Runtime Error):
from itertools import*;print(sum(p*q*r for p,q,r in combinations([list(s[0]for s in open(0).readlines()).count(s)for s in"MARCH"],3)))

Fixed submission:
import itertools as i;d=[0]*91
for _ in[0]*int(input()):d[ord(input()[0])]+=1
print(sum(d[p]*d[q]*d[r]for p,q,r in i.combinations(map(ord,'MARCH'),3)))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
h,w,d=map(int,input().split())
g=defaultdict(tuple)
for i in range(h):
    tmp=[]
    for j,v in enumerate(map(int,input().split())):
        g[v]=(i,j)
q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    for j in range(l,r-d+1,d):
        ans+=sum(abs(s-t)for s,t in zip(g[j],g[j+d]))
    print(ans)


Fixed submission:
from itertools import*
from collections import*
h,w,d=map(int,input().split())
g=defaultdict(tuple)
f=defaultdict(int)
for i in range(h):
    for j,v in enumerate(map(int,input().split())):
        g[v]=(i,j)
        
q=int(input())

for i in range(1,d+1):
    for k,v in enumerate(accumulate([0]+[sum(abs(s-t)for s,t in zip(g[j+d],g[j]))for j in range(i,h*w+1-d,d)])):
        f[i+k*d]=v
        
for i in range(q):
    l,r=map(int,input().split())
    print(f[r]-f[l])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
h,w,d=map(int,input().split())
g=defaultdict(tuple)
for i in range(h):
    tmp=[]
    for j,v in enumerate(map(int,input().split())):
        g[v]=(i,j)
q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    for j in range(l,r-d+1,d):
        ans+=sum(abs(s-t)for s,t in zip(g[j],g[j+d]))
    print(ans)

Fixed submission:
from itertools import*
from collections import*
h,w,d=map(int,input().split())
g=defaultdict(tuple)
f=defaultdict(int)
for i in range(h):
    for j,v in enumerate(map(int,input().split())):
        g[v]=(i,j)
        
q=int(input())

for i in range(1,d+1):
    for k,v in enumerate(accumulate([0]+[sum(abs(s-t)for s,t in zip(g[j+d],g[j]))for j in range(i,h*w+1-d,d)])):
        f[i+k*d]=v
        
for i in range(q):
    l,r=map(int,input().split())
    print(f[r]-f[l])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)>=sum(b):
    print("No")
else:
    ans=0
    lim=sum(b)-sum(a)
    for i in range(n):
        if a[i]<b[i]:
            ans+=(b[i]-a[i])//2
    if ans>lim:
        print("No")
    else:
        print("Yes")

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

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a%b==0:
    print(-1)
else:
    print(x)

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

Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
for i in range(a,10**18,a):
  if i%b!=0:
    print(i)
    exit()
  else:
    print(-1)

Fixed submission:
a,b=map(int,input().split())
if a%b==0:
    print(-1)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
n,h=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
b=max(a,key=lambda x:x[0])[0]
c=sorted(t for(s,t)in a if t>b)[::-1]
d=0
for i in c:
    h-=i
    d+=1
    if h<0:
        print(d)
        exit()
if h>0:
    d+=max(h-1,-1)//b+1
print(d)

Fixed submission:
a,b,c=input().split("/");print("2018/"+b+"/"+c)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
for s in range(b//10000+1):
    try:
        for t in range(b//5000+1):
            r=b-s-t
            if 10000*s+5000*t+1000*r==b and s+t+r==a:
                print(s,t,r)
                exit()
    except ZeroDivisionError:
        continue
print(-1,-1,-1)

Fixed submission:
a,b,c=input().split("/");print("2018/"+b+"/"+c)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
for s in range(b//10000+1):
    try:
        for t in range(b//5000+1):
            r=b-s-t
            if 10000*s+5000*t+1000*r==b and s+t+r==a:
                print(s,t,r)
                exit()
    except ZeroDivisionError:
        continue
print(-1,-1,-1)

Fixed submission:
print(len(set(open(0).read().split()[1:])))