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

Fixed submission:
a,b=map(int,input().split());print(a+b//2)

Buggy 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]))
Problem p03231 (python)

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 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)

Buggy 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)

Buggy 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)

Buggy 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)
Problem p03238 (python)

Fixed submission:
input()
try:print(int(input())+int(input()))
except:print("Hello World")

Buggy 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])
Problem p03240 (python)

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 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])

Buggy 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])

Buggy 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])
Problem p03246 (python)

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 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))
Problem p03251 (python)

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 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")
Problem p03260 (python)

Fixed submission:
a,b=map(int,input().split());print("YNeos"[a*b%2!=1and 3*a*b%2!=1::2])

Buggy 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]))
Problem p03261 (python)

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 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")
Problem p03262 (python)

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 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))
Problem p03273 (python)

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 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))
Problem p03282 (python)

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

Buggy submission (verdict: Runtime Error):
print(max(1,input()[:int(input())].replace("1","")[:1]))

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

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

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

Buggy 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)

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

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

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

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

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 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)
Problem p03330 (python)

Fixed submission:
from itertools import*
n,c=map(int,input().split())
cost=[list(map(int,input().split()))for i in range(c)]
d=[[0]*c for i in range(3)]
for i in range(n):
    for j,v in enumerate(map(int,input().split())):
        d[(i+j)%3][v-1]+=1
print(min(sum(cost[j][cmb[i]]*d[i][j]for j in range(c)for i in range(3))for cmb in permutations(range(c),3)))

Buggy submission (verdict: Runtime Error):
from itertools import*
n,c=map(int,input().split())
cost=[list(map(int,input().split()))for i in range(c)]
d=[[0]*c for i in range(3)]
for i in range(n):
    for j,v in enumerate(map(int,input().split())):
        d[(i+j)%3][v-1]+=1
print(min(sum(d[j][cmb[i]]*cost[i][j]for j in range(c)for i in range(3))for cmb in permutations(range(c),3)))

Buggy submission (verdict: Runtime Error):
from collections import*
from itertools import*
n,c=map(int,input().split())
cost=defaultdict(int)
for i in range(1,c+1):
    for k,v in enumerate(map(int,input().split())):
        cost[(k+1,i)]=v
#print(cost)

dwatta=defaultdict(list)
l=set()
for i in range(n):
    for j,v in enumerate(map(int,input().split())):
        mod=(i+j+2)%3
        dwatta[mod]+=[(v,(i,j))]
        l.add(v)
#print(l)
#print(dwatta) #割った値、座標、色
c=[]
for i in combinations(l,3):
    for s in permutations(i):
        ccc=0
        for k,v in dwatta.items():
            for f,t in enumerate([v]):
                for a,b in t:
                    if a!=s[f]:
                        ccc+=cost[(a,s[f])]
        c.append(ccc)
print(min(c))
Problem p03341 (python)

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 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)))
Problem p03352 (python)

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 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))

Buggy 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))
Problem p03355 (python)

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 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])

Buggy 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])
Problem p03356 (python)

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 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)
Problem p03359 (python)

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

Buggy 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")
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split())
grid=[["."]*(w+2)]+[list("."+input()+".")for i in range(h)]+[["."]*(w+2)]
for s in range(1,1+h):
    for t in range(1,1+w):
        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")

Buggy 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+b):
    for t in range(1,1+a):
        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")

Buggy 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")

Buggy 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+a):
        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")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
grid=[["."]*(a+2)]+[list("."+input()+".")for i in range(b)]+[["."]*(a+2)]
for i in grid:
    print(*i)
for s in range(1,1+a):
    for t in range(1,1+a):
        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")

Buggy 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+a):
        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")
Problem p03362 (python)

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 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())])
Problem p03363 (python)

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 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)
Problem p03374 (python)

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 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)
Problem p03385 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
for i in range(a,b+1):
  print(i)

Buggy 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)
Problem p03393 (python)

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 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)))) )
Problem p03399 (python)

Fixed submission:
a,b,c,d=map(int,open(0).readlines());print([a,b][a>b]+[c,d][c>d])

Buggy 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)))
Problem p03408 (python)

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 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)
Problem p03409 (python)

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 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)
Problem p03415 (python)

Fixed submission:
print(input()[0]+input()[1]+input()[2])

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,open(0).readlines());print([a,b][a>b]+[c,d][c>d])
Problem p03425 (python)

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 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)))