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

Fixed submission:
S,T = input(),input()
x,y = len(S),len(T)

dp = [[0]*(y+1) for _ in range(x+1)]

for i,s in enumerate(S):
  for j,t in enumerate(T):
    dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j], dp[i][j] + int(s==t))
    
a = ""
while x > 0 and y > 0:
  if dp[x][y] == dp[x-1][y]:
    x -= 1
  elif dp[x][y] == dp[x][y-1]:
    y -= 1
  else:
    x -= 1
    y -= 1
    a += S[x]

print(a[::-1])

Buggy submission (verdict: Runtime Error):
lenmax = lambda x, y: x if len(x) > len(y) else y
dp = {("","") : ""}

def lcs(x,y):
    if (x,y) in dp:
        return dp[(x,y)]

    if x == "" or y == "":
        a = ""
    elif x[-1] == y[-1]:
        a = lcs(x[:-1],y[:-1]) + x[-1]
    else:
        a = lenmax(lcs(x[:-1],y), lcs(x,y[:-1]))
    dp[(x,y)] = a
    return a

print(lcs(input(),input()))
Problem p03213 (python)

Fixed submission:
from collections import Counter
import math
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
n=int(input())
L=[]
for j in range(2,n+1):
    I=j
    s=0
    R=int(I)
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
C=Counter(L)
c=[0 for i in range(100)]
for i,j in C.most_common():
  c[j]+=1
 
s=0
s+=sum(c[4:])*(sum(c[4:])-1)*(sum(c[2:])-2)//2
s+=sum(c[14:])*(sum(c[4:])-1)
s+=sum(c[24:])*(sum(c[2:])-1)
s+=sum(c[74:])
print(s)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import math
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
n=int(input())
L=[]
for j in range(2,n+1):
    I=j
    s=0
    R=int(I)
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
c=Counter(L)
c=[0 for i in range(100)]
for i,j in c.most_common():
  c[j]+=1
 
s=0
s+=sum(c[4:])*(sum(c[4:])-1)*sum(c[2:]-2)//2
s+=sum(c[14:])*(sum(c[4:])-1)
s+=sum(c[24:])*(sum(c[2:])-1)
s+=sum(c[74:])
print(s)
Problem p03239 (python)

Fixed submission:
I=lambda:map(int,input().split())
n,k=I()
s=1001
for i in range(n):
  a,b=I()
  if b<=k:
    s=min(s,a)
if s==1001:
  print('TLE')
else:
  print(s)

Buggy submission (verdict: Runtime Error):
I=lambda:map(int,input())
n,k=I()
s=1001
for i in range(n):
  a,b=I()
  if b<=k:
    s=min(s,a)
if s==1001:
  print('TLE')
else:
  print(s)
Problem p03240 (python)

Fixed submission:
r=range(int(input()))
p=[[int(i)for i in input().split()] for _ in r]
p.sort(key=lambda x: x[2])
a,b,c=p[-1]
for x in range(101):
  for y in range(101):
    h=c+abs(a-x)+abs(b-y)
    if all(k==max(h-abs(i-x)-abs(j-y),0) for i,j,k in p):
      print(x,y,h)
      exit()

Buggy submission (verdict: Runtime Error):
r = range(int(input()))
p = [[int(i) for i in input().split()] for _ in r]

a,b,c = p[0]
for x in range(101):
  for y in range(101):
    h = c+abs(a-x)+abs(b-y)
	if all(k==h-abs(i-x)-abs(j-y) for i,j,k in p):
      print(x,y,h)
      exit()
Problem p03311 (python)

Fixed submission:
from math import ceil,floor
n=int(input())
if n==1:
  print(0)
  exit()
a=[int(i) for i in input().split()]
for i in range(n):
  a[i]-=(i+1)
a.sort()

b1=a[ceil(n/2)]
b2=a[floor(n/2)]

def c1(x):
    return abs(x-b1)
def c2(x):
    return abs(x-b2)
print(min(sum(list(map(c1,a))),sum(list(map(c2,a)))))

Buggy submission (verdict: Runtime Error):
from math import ceil,floor
n=int(input())
a=[int(i) for i in input().split()]
for i in range(n):
  a[i]-=(i+1)
a.sort()

b1=a[ceil(n/2)]
b2=a[floor(n/2)]

def c1(x):
    return abs(x-b1)
def c2(x):
    return abs(x-b2)
print(min(sum(list(map(c1,a))),sum(list(map(c2,a)))))
Problem p03312 (python)

Fixed submission:
from bisect import bisect
n = int(input())
a = [int(x) for x in input().split()]
 
r = 0
s = []
for i in a:
  r += i
  s.append(r)

def bs(x,y):
  b = bisect(x, y)
  if abs(x[b-1] - y) < abs(x[b] - y):
    b = b-1
  return b
 
m = 10**20
for i in range(1, n-1):
  k = bs(s, s[i] / 2)
  l = bs(s, (s[n-1] + s[i]) / 2)
  s4 = [s[k],s[i]-s[k],s[l]-s[i],s[n-1]-s[l]]
  m = min(m, max(s4) - min(s4))

print(m)

Buggy submission (verdict: Runtime Error):
from bisect import bisect
n = int(input())
a = [int(x) for x in input().split()]

r = 0
s = []
for i in a:
  r += i
  s.append(r)

def bs(x,y):
  b = bisect(x, y)
  if abs(x[b-1] - y) < abs(x[b] - y):
    b = b-1
  return b

m = 10**20
for i in range(2, n-1):
  k = bs(s, s[i] / 2)
  l = bs(s, (s[n] + s[i]) / 2)
  s4 = [s[k],s[i]-s[k],s[l]-s[i],s[n]-s[l]]
  m = min(m, max(s4) - min(s4))

print(m)
Problem p03316 (python)

Fixed submission:
s=input()
print("Yes" if int(s) % sum(list(map(int,list(s)))) ==0 else "No")

Buggy submission (verdict: Runtime Error):
s=input()
print("Yes" if int(s) % sum(list(s)) ==0 else "No")
Problem p03352 (python)

Fixed submission:
n=int(input())
ans=1
for i in range(1,32):
  for j in range(2,10):
    if i**j <=n and i**j >ans:
      ans=i**j
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input()):
ans=1
for i in range(1,32):
  for j in range(2,10):
    if i**j <=n and i**j >ans:
      ans=i**j
print(ans)
Problem p03353 (python)

Fixed submission:
s=input().strip()
k=int(input())
A=[]
for i in range(len(s)):
  for j in range(1,6):
    if i+j<=len(s):
      A.append(s[i:i+j])
B=sorted(list(set(A)))
print(B[k-1])

Buggy submission (verdict: Runtime Error):
s=input().strip()
k=int(input())
A=[]
for i in range(len(s)):
  for j in range(1,6):
    if i+j<=len(s):
      A.append(s[i:i+j])
B=sorted(list(set(A)))
print(B[k])
Problem p03354 (python)

Fixed submission:
I=lambda:[int(i) for i in input().split()]
n, m = I()
P = I()
D = {i:i for i in range(n+1)}

def U(x):
  if D[x] != x:
    D[x] = U(D[x])
  return D[x]

for _ in range(m):
  x, y = I()
  D[U(x)] = U(y)

print(sum(U(i)==U(p) for i, p in enumerate(P,1)))

Buggy submission (verdict: Runtime Error):
I=lambda:[int(i)for i in input().split()]
n,m=I()
P=I()
D={i:i for i in range(n+1)}
def U(x):
  if D[x]!=x:D[x]=U(D[x])
  return D[x]
for _ in [0]*m:
  x, y= I():D[U(x)]=U(y)
print(sum(U(i)==U(p)for i,p in enumerate(P,1)))
Problem p03364 (python)

Fixed submission:
import numpy as np
n=int(input())
s=[chr(i) for i in range(97, 97+26)]
 
aa_cij=np.array([[s.index(i)+1  for i in list(input())] for _ in range(n)],dtype='int8')
z=np.zeros((n,n),dtype='int8')
ans=0
for i in range(n):
  aa_cij=np.concatenate( [ aa_cij[1:,:], aa_cij[[0],:] ], axis=0)
  if np.allclose(aa_cij - aa_cij.T, z ):
    ans+=1 
print(ans*n)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
s=[chr(i) for i in range(97, 97+26)]
 
aa_cij=np.array([[s.index(i)+1  for i in list(input())] for _ in range(n)],dtype='int8')

ans=0
for i in range(n):
  aa_cij=np.concatenate( [ aa_cij[1:,:], aa_cij[[0],:] ], axis=0)
  if np.allclose(aa_cij 、aa_cij.T):
    ans+=1 
print(ans*n)
Problem p03374 (python)

Fixed submission:
n,c= [int(i) for i in input().split()]
t_tk_r=0
t_md_r=0
g_tk_r=0
g_md_r=0
t_tk_m=0
t_md_m=0
g_tk_m=0
g_md_m=0
t_tk=[]
t_md=[]
g_tk=[]
g_md=[]
a=[]
d1=0

for i in range(n):
  a.append([int(i) for i in input().split()])

for d0,v0 in a:
  t_tk_r += v0-(d0-d1)
  t_md_r += v0-(d0-d1)*2
  t_tk_m = max(t_tk_m,t_tk_r)
  t_md_m = max(t_md_m,t_md_r)
  t_tk.append(t_tk_m)
  t_md.append(t_md_m)
  d1=d0
  
d1=0  
for d0,v0 in a[::-1]:
  g_tk_r += v0-((c-d0)-d1)
  g_md_r += v0-((c-d0)-d1)*2
  g_tk_m = max(g_tk_m,g_tk_r)
  g_md_m = max(g_md_m,g_md_r)
  g_tk.append(g_tk_m)
  g_md.append(g_md_m)
  d1=(c-d0) 
mx=max(max(t_tk),max(g_tk),0)

for i in range(n-1):
  mx=max(mx,t_tk[i]+g_md[n-2-i],t_md[i]+g_tk[n-i-2])
print(mx)

Buggy submission (verdict: Runtime Error):
n,c= [int(i) for i in input().split()]
t_tk_r=0
t_md_r=0
g_tk_r=0
g_md_r=0
t_tk=[]
t_md=[]
g_tk=[]
g_md=[]
a=[]
d1=0
for i in range(n):
  a.append([int(i) for i in input().split()])
for d0,v0 in a:
  t_tk_r+=v0-(d0-d1)
  t_md_r+=v0-(d0-d1)*2
  t_tk.append(t_tk_r)
  t_md.append(t_md_r)
  d1=d0
d1=0  
for d0,v0 in a[::-1]:
  g_tk_r+=v0-((c-d0)-d1)
  g_md_r+=v0-((c-d0)-d1)*2
  g_tk.append(g_tk_r)
  g_md.append(g_md_r)
  d1=(c-d0)
  
mx=max(max(t_tk),max(g_tk),0)
for i in range(1,mx[n].index()):
  mx=max(mx,max(t_tk[:i])+max(g_md[:n-i]),max(t_md[:i])+max(g_tk[:n-i]))
print(mx)
Problem p03380 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
m=max(a)
m2 = m / 2

f = m
ans = -m
for i in a:
  if i != m and abs(m2 - i) <=f:
    f = abs(m2 - i)
    ans = i
print(m,ans)

Buggy submission (verdict: Runtime Error):
import bisect
import math

n=int(input())
a=[int(i) for i in input().split()]
a.sort()
m=0
ans1=max(a)
ams2=min(a)

for i in range(1,n):
  b = bisect.bisect_left(a[:i],a[i]/2)
  r = math.factorial(a[i])/(math.factorial(a[b])*math.factorial(a[i]-a[b]))
  if b-1<=0:
    j=b
  else:
    if abs(a[b]-a[i]/2)<=abs(a[b-1]-a[i]/2):
      j=b
    else:
      j=b-1
      
  r = math.factorial(a[i])/(math.factorial(a[j])*math.factorial(a[i]-a[j]))
  if r>m:
    ans1=a[i]
    ans2=a[j]
print(ans1,ans2)

Buggy submission (verdict: Runtime Error):
import bisect
import math
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
m=0
for i in range(1,n):
  b=bisect.bisect_left(a[:i],a[i]/2)

  r=math.factorial(a[i])/(math.factorial(a[b])*math.factorial(a[i]-a[b]))
  if b-1>=0:
    l=math.factorial(a[i])/(math.factorial(a[b-1])*math.factorial(a[i]-a[b-1]))
  else:
    l=0
  if max(r,l)>m:
    m=max(r,l)
    ans1=a[i]
    if r>l:
      ans2=a[b]
    else:
      ans2=a[b-1]
print(ans1,ans2)
Problem p03399 (python)

Fixed submission:
a=[0]*4
for i in range(4):
  a[i]=int(input())
print(min(a[:2]) + min(a[2:4]))

Buggy submission (verdict: Runtime Error):
a=[0]*4
for i in range(4):
  a[i]=int(input())
print(min(a[2])+min(a[2:4]))
Problem p03415 (python)

Fixed submission:
a=input().strip()
b=input().strip()
c=input().strip()
print("".join([a[0],b[1],c[2]]))

Buggy submission (verdict: Runtime Error):
a=input().strip()
b=input().strip()
c=input().strip()
print("".join([a[0],b[1],c[0]])
Problem p03448 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
m=int(input())
s=0
for i in range(a+1):
  for j in range(b+1):
    x,y=divmod(m-i*500-j*100,50)
    if y==0 and 0<=x<=c:
      s+=1
print(s)

Buggy submission (verdict: Runtime Error):
=int(input())
b=int(input())
c=int(input())
m=int(input())
s=0
for i in range(a+1):
  for j in range(b+1):
    x,y=divmod(m-i*500-j*100,50)
    if y==0 and 0<=x<=c:
      s+=1
print(s)
Problem p03457 (python)

Fixed submission:
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,y
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,
else:
  print('Yes')
Problem p03472 (python)

Fixed submission:
import math
n,m=[int(i) for i in input().split()]
a=[]
b=[]
for i in range(n):
  a0,b0=[int(i) for i in input().split()]
  a.append(a0)
  b.append(b0)
a.sort(reverse=True)
b.sort(reverse=True)
x=0
while m>0:
  if b==[]:
    x+=math.ceil(m/a[0])
    break
  else:
    if b[0]>a[0]:
      m-=b[0]
      del b[0] 
      x+=1
    else:
      x+=math.ceil(m/a[0])
      break
    
print(x)

Buggy submission (verdict: Runtime Error):
mport math
n,m=[int(i) for i in input().split()]
a=[]
b=[]
for i in range(n):
  a0,b0=[int(i) for i in input().split()]
  a.append(a0)
  b.append(b0)
a.sort(reverse=True)
b.sort(reverse=True)
x=0
while m>0:
  if b==[]:
    x+=math.ceil(m/a[0])
    break
  else:
    if b[0]>a[0]:
      m-=b[0]
      del b[0] 
      x+=1
    else:
      x+=math.ceil(m/a[0])
      break
    
print(x)

Buggy submission (verdict: Runtime Error):
import math
n,m=[int(i) for i in input().split()]
a=[]
b=[]
for i in range(n):
  a0,b0=[int(i) for i in input().split()]
  a.append(a0)
  b.append(b0)
a.sort(reverse=True)
b.sort(reverse=True)
x=0
while m>0:
  if b[0]>a[0]:
    m-=b[0]
    del b[0] 
    x+=1
  else:
    x+=math.ceil(m/a[0])
    break
    
  
print(x)
Problem p03480 (python)

Fixed submission:
l=input()
n=len(l)
x = n
for i in range(1,n):
  if l[i-1] != l[i]:
    nx = max(i, n-i)
    x = min(x,nx)
print(x)

Buggy submission (verdict: Runtime Error):
l=input()
n=len(l)

for i in range(1,n):
  x = n
  nx=0
  if l[i-1] != l[i]:
    nx = max(i, n-i)
  x = min(x,nx)
print(x)
Problem p03496 (python)

Fixed submission:
import numpy as np

n= int(input())
a= [int(i) for i in input().split(' ')]

if abs(max(a)) >= abs(min(a)):
  ma  = max(a)
  ma_i= np.argmax(a)
  mi  = 0
  mi_i= 0
else:
  mi  = min(a)
  mi_i= np.argmin(a)
  ma  = 0
  ma_i= 0

xa=[]
if ma == 0:
  for i in range(n):
    if a[i] > 0:
      a[i] = a[i] + mi
      xa.append([mi_i+1, i+1])
  for i in reversed(range(1,n)):
    if a[i-1] > a[i]:
      a[i-1] = a[i-1] + a[i]
      xa.append([i+1, i-1+1])
else:
  for i in range(n):
    if a[i] < 0:
      a[i] = a[i] + ma
      xa.append([ma_i+1, i+1])
  for i in range(1,n):
    if a[i-1] > a[i]:
      a[i] = a[i] + a[i-1]
      xa.append([i-1+1,i+1])

print(len(xa))
for i in range(len(xa)):
  print(xa[i][0],xa[i][1])

Buggy submission (verdict: Runtime Error):
imput numpy as np

n= int(input())
a= [int(i) for i in input().split(' ')]

if abs(max(a)) >= abs(min(a)):
  ma  = max(a)
  ma_i= np.argmax(a)
  mi  = 0
  mi_i= 0
else:
  mi  = min(a)
  mi_i= np.argmin(a)
  ma  = 0
  ma_i= 0

if ma==0:
  for i in range(n):
    if a[i] > 0:
      a[i] = a[i] + mi
      print(mi_i,i)
  for i in reversed(range(1,n)):
    if a[i-1] > a[i]:
      a[i-1] = a[i-1] + a[i]
      print(i-1, i)
else:
  for i in range(n):
    if a[i] < 0:
      a[i] = a[i] + ma
      print(mi_a,i)
  for i in range(1,n):
    if a[i-1] > a[i]:
      a[i] = a[i] + a[i-1]
      print(i-1,i)
Problem p03502 (python)

Fixed submission:
a=input()
x=int(a)

y=0
for i in a:
  y+=int(i)

if x % y==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a=input()
x=int(a)

y=0
for i in len(a):
  y+=int(a[i])

if x % y==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a=input()
x=int(a)

y=0
for i in len(n):
  y+=int(i)

if x % y==0:
  print('Yes')
else:
  print('No')
Problem p03547 (python)

Fixed submission:
a,b=[int(i,16) for i in input().split(' ')]
if a==b:
  print('=')
elif a>b:
  print('>')
else:
  print('<')

Buggy submission (verdict: Runtime Error):
a,b=[int('x',i) for i in input.split(' ')]
if a==b:
  print('=')
else a>b:
  print('>')
else:
  print('<')
Problem p03550 (python)

Fixed submission:
n,z,w=[int(i) for i in input().split(' ')]
a=[int(i) for i in input().split(' ')]

if len(a)>1:
  l0=abs(a[-1]-a[-2])
else:
  l0=-1000000000000000000
l1=abs(a[-1]-w)

if l1>l0:
  print(l1)
else:
  print(l0)

Buggy submission (verdict: Runtime Error):
n,z,w=[int(i) for i in input().split(' ')]
a=[int(i) for i in input().split(' ')]

l0=abs(a[-1]-a[-2])
l1=abs(a[-1]-w)

if l1>l0:
  print(l1)
else:
  print(l0)
Problem p03608 (python)

Fixed submission:
from scipy.sparse import*
from itertools import permutations as pm

n,m,h = map(int,input().split())
r = [int(i) for i in input().split()]

u,v,l = zip(*[map(int,input().split()) for i in range(m)])

A=csgraph.dijkstra(csr_matrix((l,(u,v)),(n+1,n+1)),0)

s=min(sum(A[i][j] for i,j in zip(a[:-1],a[1:])) for a in pm(r))
print(int(s))

Buggy submission (verdict: Runtime Error):
from scipy.sparse import*
from itertools import permutations as pm

n,m,h = map(int,input().split())
r = [int(i) for i in input().split()]

A = lil_matrix((n+1,n+1))
for i in range(m):
  u,v,l = map(int,input().split())
  A[u,v] = l

A=csgraph.shortest_path(A,method='D')

s=min(sum([A[i][j] for i,j in zip(a[:-1],a[1:])]) for a in pm(r))
print(int(s))
Problem p03644 (python)

Fixed submission:
a=int(input())
k=0
x=0
while x<=a:
  x=2**k
  k+=1
print(int(x/2))

Buggy submission (verdict: Runtime Error):
a=int(input())
k=0
while x<a:
  x=2**k
  k+=1
print(x)
Problem p03651 (python)

Fixed submission:
from fractions import gcd

n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
b=a[0]
for i in range(1,n):
  b=gcd(b,a[i])

if c > a[n-1]:
  print('IMPOSSIBLE')
else:
  print('POSSIBLE' if c % b==0 else "IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,c= [int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
a1=max(a)
s=a1
for a0 in a:
  s = min(s,abs(a0-a1))
  a1=a0
  
ma=max(a)
if s==0:
  print('IMPOSSIBLE')
if all([i % s==0 for i in a])==False:
  print('POSSIBLE')
else:
  while c<=ma:
    ma-=s
    if c==ma:
      print('POSSIBLE')
      break
  else:
    print('IMPOSSIBLE')
Problem p03712 (python)

Fixed submission:
h,w=map(int,input().split())
print("#"*(w+2))
for i in range(h):
  print("#"+input().strip()+"#")
print("#"*(w+2))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input())
print("#"*(w+2))
for i in range(h):
  print("#"+input().strip()+"#")
print("#"*(w+2))
Problem p03715 (python)

Fixed submission:
h, w = map(int,input().split())
m = h * w
  
def d(a,b,c):
  return max(abs(a - b), abs(b - c), abs(a - c))

def c(h,w):
  a = m
  for i in range(1, h):
    l = i * w
    y = (h - i) // 2 * w
    t = (h - i) * (w // 2)
    a = min(a, d(l, y , m - l - y), d(l, t, m - l - t))
  return a

print(min(c(h, w), c(w, h)))

Buggy submission (verdict: Runtime Error):
h, w=map(int,input().split())
m = h * w

if h % 3 == 0 or w % 3 == 0:
  print(0)
  exit()

def chk(h,w):
  a = m
  for i in range(1, h):
    l = i * w
    o = (h - i) // 2 * w
    g = m - l - o
    a = min(a, max(abs(l - o), abs(g - o), abs(g - l)))

  for i in range(1, h):
    l = i * w
    o = (h - i) * (w // 2)
    g = m - i - o
    a = min(a, max(abs(l - o), abs(g - o), abs(g - l)))

  return a

print(min(chk(h, w), cck(w, h)))
Problem p03729 (python)

Fixed submission:
a,b,c=input().split()
print("YES" if a[-1]==b[0] and b[-1]== c[0] else "NO")

Buggy submission (verdict: Runtime Error):
a,b,c=[int(i) for i in input().split()]
print("YES" if a[-1]==b[0] and b[-1]== c[0] else "NO")
Problem p03746 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
I=lambda:map(int,input().split())
n,m=I()
g=[set() for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a].add(b)
  g[b].add(a)

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      l=dfs(j)
      l.append(j)
      return l
      break
  else:
    return []
z=dfs(1)+[1]+dfs(1)[::-1]
print(len(z))
print(*z)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(50000)
I=lambda:map(int,input().split())
n,m=I()
g=[[]for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a]+=[b]
  g[b]+=[a]

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      return [j]+dfs(j)
      break
  else:
    return []
z=dfs(1)[::-1]+[1]+dfs(1)
print(len(z))
print(*z)

Buggy submission (verdict: Runtime Error):
I=lambda:map(int,input().split())
n,m=I()
g=[[]for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a]+=[b]
  g[b]+=[a]

def D(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      return [j]+D(j)
      break
  else:
    return []
z=D(1)[::-1]+[1]+D(1)
print(len(z))
print(*z)

Buggy submission (verdict: Runtime Error):
I=lambda:map(int,input().split())
n,m=I()
g=[[]for _ in range(n+1)]
v=[0 for _ in range(n+1)]
v[1]=1

for _ in range(m):
  a,b=I()
  g[a]+=[b]
  g[b]+=[a]
  
def dfs(x):
  for j in g[x]:
    if v[j]==0:
      v[j]=1
      return [j]+dfs(j)
      break
  else:
    return []
z=dfs(1)[::-1]+[1]+dfs(1)
print(len(z))
print(*z)

Buggy submission (verdict: Runtime Error):
I=lambda:map(int,input().split())
n,m=I()
n+=1
g=[[] for _ in range(n)]
v=[0  for _ in range(n)]

for _ in range(m):
  a,b=I()
  g[a]+=[b]
  g[b]+=[a]
l=[]
v[1]=1
def bfs(x,l):
  for j in g[x]:
    if v[j]==0:
      v[j]=1
      return [j]+bfs(j,l)
      break
  else:
    return l
z=bfs(1,l)[::-1]+[1]+bfs(1,l)
print(len(z))
print(*z)

Buggy submission (verdict: Runtime Error):
I=lambda:map(int,input().split())
n,m=I()
n+=1
g=[[] for _ in range(n)]
v=[0  for _ in range(n)]

for _ in range(m):
  a,b=I()
  g[a]+=[b]
  g[b]+=[a]
l=[]
v[1]=1
def bfs(x,l):
  for j in g[x]:
    if v[j]==0:
      v[j]=1
      return [j]+bfs(j,l)
      break
  else:
    return l
z=[1]+bfs(1,l)
print(len(z))
print(*z)
Problem p03759 (python)

Fixed submission:
a,b,c=map(int,input().split())
print("YES" if b-a==c-b else "NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print("YES" if b-a=c-b else "NO")
Problem p03762 (python)

Fixed submission:
I=lambda:[int(i)for i in input().split()]
n,m=I()
N=I()
M=I()
F=lambda x,y:sum(j*(y-1-2*i)for i,j in enumerate(x))
print(F(N,n)*F(M,m)%(10**9+7))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m=[int(i) for i in input().split()]
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]

def kk(z):
  zk=[]
  zi=z[0]
  ns=0
  nl=len(z)
  
  for i in z:
    if zi!=i:
      zk.append(abs(i-zi) *(ns*(nl-ns))% (10**9 + 7))
    zi=i
    ns+=1
  return zk

nx=np.array(kk(x), dtype = 'int64').reshape(len(x)-1,1)
ny=np.array(kk(y), dtype = 'int64')
nxy=nx*ny
print((nxy.sum()) % (10**9 + 7))
Problem p03797 (python)

Fixed submission:
s,c=[int(i) for i in input().split()]

def cul(s,c):
  if s < c // 2:
    x = min(s,c//2)
    x += max(c - s * 2, 0)//4
  else:
    x = min(s,c//2)
  return x
print(cul(s,c))

Buggy submission (verdict: Runtime Error):
s,c=[int(i) for i in input().split()]

def cul(s,c):
  if s >= c // 2:
    x = s
    c = c - s * 2, 0
    x += c//4
  else:
    x = c//2
  return x
print(cul(s,c))
Problem p03838 (python)

Fixed submission:
a,b=[int(i) for i in input().split()]
abab=abs(abs(a) - abs(b))
saab=abs(b-a)
if b < a and b * a >0:
  print(saab + 2)
elif b > a and b * a >=0:
  print(saab)
elif b < a and b * a <=0:
  print(min(saab + 1,abab+1))
elif b > a and b * a <0:
  print(min(saab,abab+1))

Buggy submission (verdict: Runtime Error):
a,b=[int(i) in i for input().split()]
abab=abs(abs(a) - abs(b))
saab=abs(b-a)
if b < a and b * a >0:
  print(saab + 2)
elif b > a and b * a >0:
  print(saab)
elif b < a and b * a <0:
  print(saab + 1)
elif b > a and b * a >0:
  print(max(saab,abab+1))
Problem p04030 (python)

Fixed submission:
a=list(input())
x=[]
for ai in a:
  if x !=[] and ai=="B":
    x.pop()
  elif ai in ["0","1"]:
    x.append(ai)
print("".join(x))

Buggy submission (verdict: Runtime Error):
a=list(input())
x=[]
for ai in a:
  if x !=[] and ai="B":
    l=len(x)
    del x[l-1]
  elif ai in ["0","1"]:
    x.append(ai)
print("".join(x))
Problem p04043 (python)

Fixed submission:
print("YES" if sorted(input().split())==["5","5","7"] else "NO")

Buggy submission (verdict: Runtime Error):
print("YES" if sorted(input().split())==["5","5","7"] else "NO"]
Problem p02675 (python)

Fixed submission:
def main():
    N = input()
    N = int(N[len(N) - 1])
    ans = ""
    if N in {2, 4, 5, 7, 9}:
        ans = "hon"
    elif N in {0, 1, 6, 8}:
        ans = "pon"
    else:
        ans = "bon"
    print(ans)
    return


main()

Buggy submission (verdict: Runtime Error):
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln             PIC X(30).
01 N              PIC 9(10).
01 Q              PIC 9(10).
01 R              PIC 9(10).

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO N.
  DIVIDE N BY 10 GIVING Q REMAINDER R.
  IF R = 2 OR 4 OR 5 OR 7 OR 9
      DISPLAY "hon"
  ELSE IF R = 0 OR 1 OR 6 OR 8
      DISPLAY "pon"
  ELSE
      DISPLAY "bon"
  END-IF.
  STOP RUN.