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

Fixed submission:
def s(n):
    return[m(t)for t in d(f(n))]
def f(n):
    l=[]
    b,e=2,0
    while b*b<=n:
        while not n%b:
            n//=b
            e+=1
        if e:
            l.append((b,e))
        b,e=b+1,0
    if n>1:
        l.append((n,1))
    return l
def d(l):
    b,e=l.pop()
    p=d(l)if l else[[]]
    v=[[(b,k)]for k in range(e+1)]
    return[s+t for s in p for t in v]
def m(l):
    a=1
    for b,e in l:
        a*=b**e
    return a
N,M=map(int,input().split())
if M<2:print(1);exit()
a=0
for i in sorted(s(M))[::-1]:
    if M//i>=N:
        a=i
        break
print(a)

Buggy submission (verdict: Runtime Error):
def s(n):
    return[m(t)for t in d(f(n))]
def f(n):
    l=[]
    b,e=2,0
    while b*b<=n:
        while not n%b:
            n//=b
            e+=1
        if e:
            l.append((b,e))
        b,e=b+1,0
    if n>1:
        l.append((n,1))
    return l
def d(l):
    b,e=l.pop()
    p=d(l)if l else[[]]
    v=[[(b,k)]for k in range(e+1)]
    return[s+t for s in p for t in v]
def m(l):
    a=1
    for b,e in l:
        a*=b**e
    return a
N,M=map(int,input().split())
a=0
for i in sorted(s(M))[::-1]:
    if M//i>=N:
        a=i
        break
print(a)
Problem p03251 (python)

Fixed submission:
x,y=input().split()[2:];print('No '*(max(map(int,input().split()+[x]))<min(map(int,input().split()+[y])))+'War')

Buggy submission (verdict: Runtime Error):
z,x,y=eval('map(int,input().split()),'*3);print('No War'[3*(max(z[2],*x)>=min(z[3],*y)):])
Problem p03254 (python)

Fixed submission:
n,x=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)<x:
    a.sort(reverse=True)
else:
    a.sort()
c=0
for t in a:
    x-=t
    if x<0:break
    c+=1
if x>0:
    print(c-1)
else:
    print(c)

Buggy submission (verdict: Runtime Error):

Problem p03260 (python)

Fixed submission:
a,b=map(int,input().split())
if a*b%2:print('Yes')
else:print('No')

Buggy submission (verdict: Runtime Error):
print('No'*'2'in input()or'Yes')
Problem p03262 (python)

Fixed submission:
N,X=map(int,input().split())
x=sorted(map(lambda x:int(x)-X if int(x)-X>0 else -(int(x)-X),input().split()))
for i in range(x[0]+1)[::-1]:
    if x[0]%i:continue
    if sum(map(lambda x:x%i,x))==0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def g(x):return reduce(math.gcd,x)
print(g([int(input().split()[1])]+list(map(int,input().split()))))
Problem p03266 (python)

Fixed submission:
n,k=map(int,input().split())
m=[0]*k
for i in range(1,n+1):m[i%k]+=1
print(m[0]**3+[m[k//2]**3,0][k%2])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
m=[0]*n
for i in range(1,n+1):m[i%k]+=1
print(m[0]*3+[m[k//2]*3,0][k%2])
Problem p03273 (python)

Fixed submission:
h, w = map(int, input().split())
a = []
for _ in range(h):
  t = list(input())
  if t.count('.') != w:
    a.append(t)
i = 0
while True:
  if i >= len(a[0]):break
  for t in a:
    if t[i] != '.':
      i += 1
      break
  else:
    for j in range(len(a)):
      del a[j][i]
for t in a:
  print(''.join(t))

Buggy submission (verdict: Runtime Error):
f=lambda s:zip(*[t for t in s if'#'in t]);for r in f(f(open(0).readlines())):print(*r,sep='')
Problem p03280 (python)

Fixed submission:
a,b=map(lambda x:int(x)-1,input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
s=input();print(~-int(s[:2])*~-int(s[2:]))

Buggy submission (verdict: Runtime Error):
print(eval('~-'+'*~-'.join(input().split()))

Buggy submission (verdict: Runtime Error):
eval('print(('+input().replace(' ','-1)*(')+'-1))'
Problem p03284 (python)

Fixed submission:
n, k = map(int, input().split())
print((n + k - 1) // k - n // k)

Buggy submission (verdict: Runtime Error):
print(eval(input().replace(' ','%'))
Problem p03294 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1
print(sum(a))

Buggy submission (verdict: Runtime Error):
input();print(eval(input().replace(' ','-1+'))-1)
Problem p03308 (python)

Fixed submission:
input();a=list(map(int,input().split()));print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
input();a=map(int,input().split());print(max(a)-min(a))
Problem p03338 (python)

Fixed submission:
n = int(input())
s = list(input())
a = 0
for i in range(n):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    t = 0
    for j in x:
        if j in y:
            t += 1
    a = max(a, t)
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input());s=input();print(max((len(set(s[:i])*set(s[i:]))for i in range(n))))

Buggy submission (verdict: Runtime Error):
n=int(input());s=input();print(max(len(set(s[:i])&set(s[i:]))for i in range(n))
Problem p03339 (python)

Fixed submission:
n=int(input())
s=list(input())
a=[0]*(n+1)
b=[0]*(n+2)
for i in range(n):
  a[i+1]=a[i]
  b[n-i]=b[n-i+1]
  if s[i]=='W':
    a[i+1]+=1
  if s[n-i-1]=='E':
    b[n-i]+=1
print(min(a[i]+b[i]-1for i in range(1,n+1)))

Buggy submission (verdict: Runtime Error):
n,s=open(0)
a=[0]*(n+1)
b=[0]*(n+2)
for i in range(n):
  a[i+1]=a[i]
  b[n-i]=b[n-i+1]
  if s[i]=='W':
    a[i+1]+=1
  if s[n-i-1]=='E':
    b[n-i]+=1
print(min(a[i]+b[i]-1for i in range(1,n+1)))
Problem p03354 (python)

Fixed submission:
class UnionFind():
  def __init__(self,size):
    self.table=[-1for _ in range(size)]
  def root(self,x):
    while self.table[x]>=0:
      x=self.table[x]
    return x
  def unite(self,x,y):
    s1=self.root(x)
    s2=self.root(y)
    if s1!=s2:
      if self.table[s1]!=self.table[s2]:
        if self.table[s1]<self.table[s2]:
          self.table[s2]=s1
        else:
          self.table[s1]=s2
      else:
        self.table[s1]-=1
        self.table[s2]=s1
    return
  def same(self,x,y):
    return self.root(x)==self.root(y)
I=lambda:list(map(int,input().split()))
n,m=I()
p=I()
u=UnionFind(n)
for _ in range(m):
  a,b=I()
  u.unite(a-1,b-1)
print(sum(u.same(i,j-1)for i,j in zip(range(n),p)))

Buggy submission (verdict: Runtime Error):
I=lambda:list(map(int.input().split()));n,m=I();p=I();l=[i for i in range(n+1)]
def u(x):
 if l[x]!=x:l[x]=u(l[x])
 return l[x]
for _ in[0]*m:x,y=I();l[u(x)]=u(y)
print(sum(u(i)==u(j)for i,j in enumerate(p,1)))
Problem p03364 (python)

Fixed submission:
n,*s=[t[:-1]for t in open(0)]
n=int(n)
c=0
for _ in range(n):
  c+=all(x==''.join(y)for x,y in zip(s,zip(*s)))*n
  s=s[1:]+s[:1]
print(c)

Buggy submission (verdict: Runtime Error):
(n,),*s=[t.rstrip()for t in open(0)]
n=int(n)
c=0
for _ in range(n):
  c+=all(x==''.join(y)for x,y in zip(s,zip(*s)))*n
  s=s[1:]+s[:1]
print(c)

Buggy submission (verdict: Runtime Error):
(n,),*s=[tuple(t[:-1])for t in open(0)]
n=int(n)
c=0
for _ in range(n):
  c+=all(x==y for x,y in zip(s,zip(*s)))*n
  s=s[1:]+s[:1]
print(c)

Buggy submission (verdict: Runtime Error):
from collections import*
(n,),*s=[tuple(t[:-1])for t in open(0)]
s=deque(s)
n=int(n)
c=0
for _ in range(n):
  c+=all(x==y for x,y in zip(s,zip(*s)))*n
  s.rotate(1)
print(c)
Problem p03372 (python)

Fixed submission:
n, c, *t = map(int, open(0).read().split())
right = [0]
left = [0]
sushi = tuple([(0, 0)]) + tuple(zip(t[::2], t[1::2])) + tuple([(c, 0)])
for i in range(1, n + 1):
    x, v = sushi[i]
    y = sushi[i - 1][0]
    cost = right[-1] + v - (x - y)
    right.append(cost)
    x, v = sushi[n + 1 - i]
    y = sushi[n + 2 - i][0]
    cost = left[-1] + v - (y - x)
    left.append(cost)
ans = max(right + left)
right_max = right[:]
left_max = left[:]
for i in range(1, n + 1):
    right_max[i] = max(right_max[i], right_max[i - 1])
    left_max[i] = max(left_max[i], left_max[i - 1])
for i in range(1, n + 1):
    ans = max(ans, \
            right[i] - sushi[i][0] + left_max[n - i], \
            left[i] - c + sushi[n + 1 - i][0] + right_max[n - i])
print(ans)

Buggy submission (verdict: Runtime Error):
n, c, *t = map(int, open(0).read().split())
right = [0]
left = [0]
sushi = tuple([(0, 0)]) + tuple(zip(t[::2], t[1::2])) + tuple([(c, 0)])
for i in range(1, n + 1):
    x, v = sushi[i]
    y = sushi[i - 1][0]
    cost = right[-1] + v - (x - y)
    right.append(cost)
    x, v = sushi[n + 1 - i]
    y = sushi[n + 2 - i][0]
    cost = left[-1] + v - (y - x)
    left.append(cost)
ans = max(*right, *left)
right_max = right[:]
left_max = left[:]
for i in range(1, n + 1):
    right_max[i] = max(right_max[i], right_max[i - 1])
    left_max[i] = max(left_max[i], left_max[i - 1])
for i in range(1, n + 1):
    ans = max(ans, \
            right[i] - sushi[i][0] + left_max[n - i], \
            left[i] - c + sushi[n + 1 - i][0] + right_max[n - i])
print(ans)
Problem p03378 (python)

Fixed submission:
n, m, x = map(int, input().split())
l = [0 for _ in range(n + 1)]
a = list(map(int, input().split()))
for i in range(m):
  l[a[i]] = 1
print(min(l[:x].count(1), l[x:].count(1)))

Buggy submission (verdict: Runtime Error):
n,m,x,*a=map(int,open(0).read().split());print(min(c:=sorted(a).index(x),m-c))
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split());r=range(a,b+1);print(*sorted(set(r[:k])|set(r[-k:])),sep='\n')

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split());*r,=range(a,b+1);print(*sorted({*r[:k]+r[-k:]}))

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split());r=range(a,b+1);print(*sorted({*(r[:k]+r[-k:])}))

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split());r=range(a,b+1);print(*sorted({*r[:k]+r[-k:]}))

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

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split());*r,=range(a,b+1);print(*sorted(set(r[:k]+r[-k:])),sep='\n')
Problem p03395 (python)

Fixed submission:
from scipy.sparse.csgraph import floyd_warshall
n,*a=map(int,open(0).read().split())
a,b=a[:n],a[n:]
for x,y in zip(a,b):
    if x==y:continue
    if y>x:
        print(-1)
        exit()
    if x-y<=y:
        print(-1)
        exit()
M=max(a)
d=[]
for k in range(M-1,-1,-1):
    s=set(a)
    e=[[0]*(M+1)for _ in range(M+1)]
    for i in range(M+1):e[i][i]=1
    for i in d+list(range(k,0,-1)):
        t=s.copy()
        for x in s:
            e[x][x%i]=1
            t|={x%i}
        s=t
    c=floyd_warshall(e)
    for x,y in zip(a,b):
        if c[x,y]==float('inf'):
            d+=k+1,
            break
print(sum(2**k for k in d))

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
a,b=a[:n],a[n:]
for a,b in zip(a,b):
    if a==b:continue
    if b>a:
        print(-1)
        exit()
    if a-b<b:
        print(-1)
        exit()
1/0
Problem p03401 (python)

Fixed submission:
n,*a=map(int,open(0).read().split())
a=[0]+a+[0]
c=sum(abs(j-i)for i,j in zip(a,a[1:]))
for i,j,k in zip(a,a[1:],a[2:]):print(c-abs(j-i)-abs(k-j)+abs(k-i))

Buggy submission (verdict: Runtime Error):
_,a=open(0)
a=[0]+list(map(int,a.split()))+[0]
A=abs
c=sum(A(j-i)for i,j in zip(a,a[1:]));for i,j,k in zip(a,a[1:],a[2:]):print(c-A(j-i)-A(k-j)+A(k-i))
Problem p03402 (python)

Fixed submission:
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and i%2and j%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
for i in range(50):
    for j in range(100):
        if b-1and i%2and j%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and (i+j)%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
print('.'*100)
for i in range(49):
    for j in range(100):
        if b-1and (i+j)%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and (i+j)%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
print('.'*100)
for i in range(49):
    for j in range(100):
        if b-1and (i+j)%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and (i+j)%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
print('.'*100)
for i in range(49):
    for j in range(100):
        if b-1and (i+j)%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()
a,b=map(int,input().split())
print(100,100)
for i in range(50):
    for j in range(100):
        if a-1and (i+j)%2:
            print('.',end='')
            a-=1
        else:
            print('#',end='')
    print()
print('.'*100)
for i in range(49):
    for j in range(100):
        if b-1and (i+j)%2:
            print('#',end='')
            b-=1
        else:
            print('.',end='')
    print()
Problem p03408 (python)

Fixed submission:
I=lambda:[input()for _ in[0]*int(input())];s=I();t=I();print(max([0]+[s.count(i)-t.count(i)for i in set(s)]))

Buggy submission (verdict: Runtime Error):
n,s=open(0).read().split();n=int(n);print(max(0,*[s[:n].count(i)-s[n:].count(i)for i in s[:n]]))

Buggy submission (verdict: Runtime Error):
I=lambda:[input()for _ in[0]*int(input())].count;s=I();t=I();print(max([0]+[s(i)-t(i)for i in set(s)]))
Problem p03415 (python)

Fixed submission:
print(''.join(input()[i]for i in range(3)))

Buggy submission (verdict: Runtime Error):
print open(0).read(11)[::5]
Problem p03417 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=map(int-2,input().split());print(abs(a*b))

Buggy submission (verdict: Runtime Error):
print(abs((int(input())-2)*(int(input())-2)))
Problem p03438 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
d = 0
for i in range(n):
  if b[i] > a[i]:
    c += (b[i] - a[i]) // 2
  else:
    d += a[i] - b[i]
print(['Yes', 'No'][c < d])

Buggy submission (verdict: Runtime Error):
n = int(input)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
  if a[i] > b[i]:
    print('No')
    sys.exit(0)
print('Yes')
Problem p03439 (python)

Fixed submission:
n=int(input())
i=0
j=n-1
print(i)
a=input()
print(j)
b=input()
while 1:
    if j-i<2:
        print(i)
        _=input()
        print(j)
        if input()!='Vacant':
            print('助けてくれ～～～')
    k=(j-i)//2+i
    print(k)
    c=input()
    if(k-i)%2and a==c or not(k-i)%2and a!=c:
        j=k
    else:
        a=c
        i=k

Buggy submission (verdict: Runtime Error):
n=int(input())
q=lambda i:input('%d\n'%i)
i=0
j=n-1
a=q(i)
b=q(j)
print('hoge')

Buggy submission (verdict: Runtime Error):
n=int(input())
i=0
j=n//2
print(i)
a=input()
print(j)
b=input()
if j%2and a!=b or not j%2and a==b:
    i,j=j,n
while 1:
    if j-i<2:
        print(i)
        _=input()
        print(j)
        break
    k=i+(j-i)//2
    print(k)
    c=input()
    if(k-i)%2and a==c:
        j=k
    else:
        i=k
print('hoge')
Problem p03448 (python)

Fixed submission:
a,b,c,x=[int(input())+1for _ in[0]*4];print(sum(x-1==(10*s+2*t+r)*50for s in range(a)for t in range(b)for r in range(c)))

Buggy submission (verdict: Runtime Error):
a,b,c,x=[int(input())+1for _ in[0]*4];print(len(0for s in range(a)for t in range(b)for r in range(c)if x-1==(10*s+2*t+r)*50))
Problem p03449 (python)

Fixed submission:
n,*a=map(int,open(0).read().split());print(max(sum(a[:i+1]+a[n+i:])for i in range(n)))

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split());print(max(sum(a[:i+1]+a[n+i:]for i in range(n))))
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
print(['Even','Odd'][a*b%2>0])

Buggy submission (verdict: Runtime Error):
print('OEdvde n'['0'in s:=input()or'4'in s::2])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
print(['Even','Odd'][a*b%2>0])
Problem p03473 (python)

Fixed submission:
print(48-int(input()))

Buggy submission (verdict: Runtime Error):
print(48-int(input))
Problem p03479 (python)

Fixed submission:
x,y=map(int,input().split())
c=0
while x<=y:
  c+=1
  x*=2
print(c)

Buggy submission (verdict: Runtime Error):
print(len(eval('//'.join(input().split()[::-1])))-2)
Problem p03480 (python)

Fixed submission:
s=input();n=len(s);print(min([max(i,n-i)for i in range(1,n)if s[i-1]!=s[i]]or[n]))

Buggy submission (verdict: Runtime Error):
s=input();n=len(s);print(min(n*(s[i-1]==s[i])or max(i,n-i)for i in range(1,n)))

Buggy submission (verdict: Runtime Error):
s=input();n=len(s);print(min(n*(s[i-1]==s[i])or max(i,n-i)for i in range(1,n)))

Buggy submission (verdict: Runtime Error):
s=input();n=len(s);print(min(max(i,n-i*(s[i-1]!=s[i]))for i in range(1,n)))

Buggy submission (verdict: Runtime Error):
s=input();n=len(s);print(min(max(i,n-i*(s[i-1]!=s[i]))for i in range(1,n)))
Problem p03493 (python)

Fixed submission:
s=list(input())
print(int(s[0])+int(s[1])+int(s[2]))

Buggy submission (verdict: Runtime Error):
print(eval(input()+'%9'))
Problem p03496 (python)

Fixed submission:
n,*a=map(int,open(0).read().split())
ans=[]
if sum(t for t in a if t>0)>sum(-t for t in a if t<0):
    i=0
    while a[i]<0:i+=1
    for j in range(n):
        if a[j]>0and i!=j:
            a[i]+=a[j]
            ans+=[(j+1,i+1)]
    for j in range(n):
        if a[j]<0:
            a[j]+=a[i]
            ans+=[(i+1,j+1)]
    for i in range(1,n):
        ans+=[(i,i+1)]
else:
    i=0
    while a[i]>0:i+=1
    for j in range(n):
        if a[j]<0and i!=j:
            a[i]+=a[j]
            ans+=[(j+1,i+1)]
    for j in range(n):
        if a[j]>0:
            a[j]+=a[i]
            ans+=[(i+1,j+1)]
    for i in range(n,1,-1):
        ans+=[(i,i-1)]
print(len(ans))
for t in ans:print(*t)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
ans=[]
if sum(t for t in a if t>0)>sum(t for t in a if t<0):
    i=0
    while a[i]<0:i+=1
    for j in range(n):
        if a[j]>0and i!=j:
            a[i]+=a[j]
            ans+=[(j+1,i+1)]
    for j in range(n):
        if a[j]<0:
            a[j]+=a[i]
            ans+=[(i+1,j+1)]
    for i in range(1,n):
        ans+=[(i,i+1)]
else:
    i=0
    while a[i]>0:i+=1
    for j in range(n):
        if a[j]<0and i!=j:
            a[i]+=a[j]
            ans+=[(j+1,i+1)]
    for j in range(n):
        if a[j]>0:
            a[j]+=a[i]
            ans+=[(i+1,j+1)]
    for i in range(n,1,-1):
        ans+=[(i,i-1)]
print(len(ans))
for t in ans:print(*t)
Problem p03503 (python)

Fixed submission:
I=input;n=int(I());f=[int(I()[::2],2)for _ in[0]*n];p=[list(map(int,I().split()))for _ in[0]*n];print(max(sum(q[bin(i&g).count('1')]for g,q in zip(f,p))for i in range(1,1024)))

Buggy submission (verdict: Runtime Error):
I=input;n=int(I());print(max(sum(p[bin(i&f).count('1')]for f,p in zip([int(I()[::2],2)for _ in[0]*n],[list(map(int,I().split()))for _ in[0]*n]))for i in range(1,1024)))
Problem p03533 (python)

Fixed submission:
import re;print(['NO','YES'][re.match('A?KIHA?BA?RA?$',input())!=None])

Buggy submission (verdict: Runtime Error):
import re;print(['NO','YES'][re.match('A?KIHA?BA?RA?$',input())])
Problem p03555 (python)

Fixed submission:
print(['NO','YES'][input()==input()[::-1]])

Buggy submission (verdict: Runtime Error):
print(['NO','YES'][input()==input().reverse()])

Buggy submission (verdict: Runtime Error):
print(['NO','YES'][input()=input().reverse()])
Problem p03563 (python)

Fixed submission:
r=int(input())
g=int(input())
print(g+g-r)

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input())/2)
Problem p03564 (python)

Fixed submission:
n=int(input());k=int(input());r=1
for _ in[0]*n:r+=min(r,k)
print(r)

Buggy submission (verdict: Runtime Error):
n=int(input());k=int(input()),r=1
for _ in[0]*n:r+=min(r,k)
print(r)
Problem p03573 (python)

Fixed submission:
a=input().split()
a.sort()
print(a[2] if a[0]==a[1] else a[0])

Buggy submission (verdict: Runtime Error):
a=input().split()
a.sort()
print(a[4] if a[2]==a[3] else a[2])

Buggy submission (verdict: Runtime Error):
a=list(input()).sort
print(a[0] if a[0]!=a[1] else a[2])

Buggy submission (verdict: Runtime Error):
s=list(input)
a=[i for i in set(s) if s.count(i)>1]
print(a[0])
Problem p03576 (python)

Fixed submission:
n,k=map(int,input().split())
z=[list(map(int,input().split()))for _ in range(n)]
z.sort()
a=10**20
for i in range(n):
    for j in range(i+1,n):
        x=z[j][0]-z[i][0]
        l=sorted(t[1]for t in z[i:j+1])
        for u,v in zip(l,l[k-1:]):
            a=min(a,x*(v-u))
print(a)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
z=[tuple(map(int,input().split()))for _ in range(N)]
x=[i for i,_ in z]
y=[j for _,j in z]
x.sort()
y.sort()
a=10**20
for i in range(N):
    for j in range(i+1,N):
        for k in range(N):
            for l in range(k+1,N):
                l,r,d,u=x[i],x[j],y[k],y[l]
                if sum([1for v,w in z if l<=v<=r and d<=w<=u else 0])>=K:
                    a=min(a,(r-l)*(u-d))
print(a)
Problem p03583 (python)

Fixed submission:
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    if (4*h*n-N*n-N*h)>0:
      w=(N*h*n)/(4*h*n-N*n-N*h)
      if w==int(w) and w>0:
        print(h,n,int(w))
        exit()

Buggy submission (verdict: Runtime Error):
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    w=(N*h*n)/(4*h*n-N*(n+h))
    if w==int(w):
      print(h,n,w)
      exit()
Problem p03593 (python)

Fixed submission:
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a=b=c=0
if h%2and w%2:
    a=h//2*(w//2)
    c=1
    b=(h*w-a*4-c)//2
elif h%2or w%2:
    a=h//2*(w//2)
    b=(h*w-a*4)//2
else:
    a=h*w//4
l=[]
for i in set(s.replace('\n','')):
    l.append(s.count(i))
for i in l:
    if i>3:
        while i>3and a:
            i-=4
            a-=1
    if i>1:
        while i>1and b:
            i-=2
            b-=1
    if i and c:
        i-=1
        c-=1
if all(not t for t in(a,b,c)):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a,b=h//2*(w//2),h%2and w%2
d=[b,(h*w-a*4-b)//2,0,a]
for i in map(s.count,set(s)-{'\n'}):
  for j in(3,1,0):
    while d[j]and i>j:
      i-=j+1
      d[j]-=1
print('YNeos'[sum(d.values())>0::2])

Buggy submission (verdict: Runtime Error):
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
d={}
d[3]=h//2*(w//2)
d[0]=h%2and w%2
d[1]=(h*w-a*4-c)//2
for i in set(s)-{'\n'}:
  i=s.count(i)
  for j in[3,1,0]:
    while d[j]and i>j:
      i-=j+1
      d[j]-=1
print('YNeos'[any(t for t in d.values())::2])
Problem p03598 (python)

Fixed submission:
_,k,*x=map(int,open(0).read().split());print(sum(min(t,k-t)*2for t in x))

Buggy submission (verdict: Runtime Error):
_,k,*x=map(open(0).read().split());print(sum(min(t,k-t)*2for t in x))
Problem p03607 (python)

Fixed submission:
d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=d.get(i,0)^1
print(sum(d.values()))

Buggy submission (verdict: Runtime Error):
d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=!d.get(i,0)
print(sum(d.values()))

Buggy submission (verdict: Runtime Error):
d=set()
for i in[0]*int(input()):d^={input()}
print(len(p))
Problem p03635 (python)

Fixed submission:
print(eval('('+input().replace(' ','-1)*(')+'-1)'))

Buggy submission (verdict: Runtime Error):
print(eval('('+input().replace(' ','-1)*(')+('-1)'))
Problem p03644 (python)

Fixed submission:
print(2**(len(bin(int(input())))-3))

Buggy submission (verdict: Runtime Error):
print(2<<len(bin(int(input())))-4)
Problem p03658 (python)

Fixed submission:
_,k,*l=map(int,open(0).read().split());print(sum(sorted(l)[-k:]))

Buggy submission (verdict: Runtime Error):
t,l=open(0);print(sum(sorted(map(int,l.split()))[-int(t[2:])]))