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

Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
for i in range(n):
    H[i]=abs(t-H[i]*0.006-a)
L=list(enumerate(H,start=1))
L=sorted(L,key=lambda x:x[1])
print(L[0][0])

Buggy submission (verdict: Runtime Error):
row=int(input())
T,A=map(int,input().split())
a = list(map(int,input().split()))
ans=10000000000000000000000
for i in range(row):
    ans=min(ans,A-T+.006*a[i])
print(a.index(int((ans-A+T)/.006))+1)

Buggy submission (verdict: Runtime Error):
row=int(input())
T,A=map(int,input().split())
a = list(map(int,input().split()))
ans=1000000000000
for i in range(row):
    ans=min(ans,A-T+.006*a[i])
print(a.index(int((ans-A+T)/.006))+1)

Buggy submission (verdict: Runtime Error):
row=int(input())
T,A=map(int,input().split())
a = list(map(int,input().split()))
ans=100
for i in range(row):
    ans=min(ans,A-T+.006*a[i])
print(a.index(int((ans-A+T)/.006))+1)
Problem p03264 (python)

Fixed submission:
n = int(input())
a= 0
b=0
for i in range(1,n+1):
    if i%2==0:
        a += 1
    else: b+=1
print(a*b)

Buggy submission (verdict: Runtime Error):
print(int(input()**2//4))
Problem p03285 (python)

Fixed submission:
a=int(input())
print("Yes" if [4*x+7*y for x in range(101) for y in range(101)].count(a) else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if [4*x+11*y for x in range(26) for y in range(9)].count(a) else "NO")

Buggy submission (verdict: Runtime Error):
print("Yes" if [4*x+11*y for x in range(26) for y in range(9)].count(a) else "NO")
Problem p03545 (python)

Fixed submission:
N=input()
a,b,c,d=int(N[0]),int(N[1]),int(N[2]),int(N[3])

if a+b+c+d==7 : print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))
elif a+b+c-d==7 : print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))
elif a+b-c+d==7 : print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
elif a+b-c-d==7 : print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
elif a-b+c+d==7 : print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))
elif a-b+c-d==7 : print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))
elif a-b-c+d==7 : print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))
elif a-b-c-d==7 : print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))

Buggy submission (verdict: Runtime Error):
N=list(input())
a,b,c,d=N[0],N[1],N[2],N[3]

if a+b+c+d==7 : print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))
if a+b+c-d==7 : print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))
if a+b-c+d==7 : print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
if a+b-c-d==7 : print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
if a-b+c+d==7 : print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))
if a-b+c-d==7 : print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))
if a-b-c+d==7 : print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))
if a-b-c-d==7 : print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))
Problem p03559 (python)

Fixed submission:
import sys
import bisect
input = sys.stdin.readline
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
top.sort()
mid.sort()
und.sort()
for i in mid:
    a=bisect.bisect_left(top,i)
    c=n-bisect.bisect_right(und,i)
    num+=a*c
print(num)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
input = sys.stdin.readline
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
top.sort()
mid.sort()
und.sort()
for i in mid:
    a=bisect.bisect_left(top,i)
    c=len(c)-bisect.bisect_right(und,i)
    num+=a*c
print(num)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
input = sys.stdin.readline()
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
top.sort()
mid.sort()
und.sort()
for i in mid:
    a=bisect.bisect_left(top,i)
    c=len(c)-bisect.bisect_right(und,i)
    num+=a*c
print(num)
Problem p03574 (python)

Fixed submission:
import numpy as np
h,w=map(int,input().split())
L=[[i for i in input()] for i in range(h)]
L_first=np.zeros((2,w),dtype=str)
L_first2=np.zeros((1,1),dtype=str)
L=np.array(L,dtype=str)
L=np.insert(L_first,1,L,axis=0)
L=np.insert(L,0,L_first2,axis=1)
L=np.insert(L,w+1,L_first2,axis=1)
ans=np.zeros((h,w),dtype=str)
for i in range(1,h+1):
    for j in range(1,w+1):
        num = 0
        if L[i][j]==".":
            L2=L[i-1:i+2,j-1:j+2]
            ans[i-1][j-1]=np.sum(L2=="#")
        else:ans[i-1][j-1]="#"
for i in range(h):
    print("".join(ans[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
L=[[i for i in input()] for i in range(h)]
L_first=np.zeros((2,w),dtype=str)
L_first2=np.zeros((1,1),dtype=str)
L=np.array(L,dtype=str)
L=np.insert(L_first,1,L,axis=0)
L=np.insert(L,0,L_first2,axis=1)
L=np.insert(L,w+1,L_first2,axis=1)
ans=np.zeros((h,w),dtype=str)
for i in range(1,h+1):
    for j in range(1,w+1):
        num = 0
        if L[i][j]==".":
            L2=L[i-1:i+2,j-1:j+2]
            ans[i-1][j-1]=np.sum(L2=="#")
        else:ans[i-1][j-1]="#"
for i in range(h):
    print("".join(ans[i]))
Problem p03679 (python)

Fixed submission:
a,b,c = map(int,input().split())
print("delicious" if b>=c else "safe" if c-b-1<a else "dangerous")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print("delicious" if b=c else "safe" if c-b-1<=a else "dangerous")
Problem p03695 (python)

Fixed submission:
import sys
input=sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))

l = [0] * 9
mn = 0
for i in A:
    t = min(i // 400, 8)
    l[t] += 1
for i in range(8):
    if l[i] != 0:
        mn += 1
if mn == 0:
    mn = 1
    mx = l[8]
else:
    mx = mn + l[8]

print(mn, mx)

Buggy submission (verdict: Runtime Error):

import sys
input=sys.stdin.readline

def atc(atc):
    result=["1","2","3","4","5","6","7","8","9"][atc//400]
    return result
num=0
L1=[]
n=int(input())
L=list(map(int,input().split()))
for i in L:
    a=atc(i)
    if a=="9":
        num+=1
    else:L1.append(a)
b=len(set(L1))
print(b,b+num)

Buggy submission (verdict: Runtime Error):

import sys
input=sys.stdin.readline

def atc(atc):
    result=["1","2","3","4","5","6","7","8","9"][atc//400]
    return result
num=0
L1=[]
n=int(input())
L=list(map(int,input().split()))
for i in L:
    a=atc(i)
    if a=="9":
        num+=1
    else:L1.append(a)
b=len(set(L1))
print(b,b+num)
Problem p03712 (python)

Fixed submission:
import sys
input = sys.stdin.readline
h,w=map(int,input().split())
answer=["#"*(w+2)]
for _ in range(h):
    answer.append("#"+input()[:-1]+"#")
answer.append("#"*(w+2))
print(*answer,sep="\n")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
L=[list(map(str,input())) for i in rage(a)]
L.insert(0,[*]*(a+2))])
L.insert(-1,[*]*(a+2))])
for i in L
print("".join(i))
Problem p03761 (python)

Fixed submission:
from collections import Counter
n=int(input())
s=Counter(input())
for i in range(n-1):
    s&=Counter(input())
print("".join(sorted(s.elements())))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
L=[]
for i in range(N):
   L.append(list(input()))
L1=Counter(L[0])&Counter(L[1])
for i in range(2,N):
    L1=Counter(L[i])&L1
ans=[i*L1[i] for i in L1]
print("".join((ans)))
Problem p04030 (python)

Fixed submission:
S=list(input())
stack=[]
for s in S:
    if s!="B":
        stack.append(s)
    elif len(stack)!=0:
        stack.pop()


print("".join(stack))

Buggy submission (verdict: Runtime Error):
S=list(input())
stack=[]
for s in S:
    if s!="B":
        stack.append(s)
    else:
        stack.pop()
print("".join(stack))
Problem p02645 (python)

Fixed submission:
S = input()
print(S[:3])

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

for i in range(min(math.ceil(math.log(N))+10, K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

for i in range(min(math.ceil(math.log(N)+5), K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))
Problem p03047 (python)

Fixed submission:
N, M = map(int, input().split())
print(N-M+1)

Buggy submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())
R, G, B = sorted([R, G, B])

i = 0
for r in range(N // R + 1):
    for g in range((N - r) // G + 1):
        bb = (N - r*R - g*G)
        if bb >= 0 and bb % B == 0:
            i += 1

print(i)
Problem p03061 (python)

Fixed submission:

def gcd(a, b):
	while b > 0:
		a, b = b, a % b
	return a


N = int(input())
A = list(map(int, input().split()))

if N == 2:
  print(max(A))
else:

  L = [0 for j in range(N+1)]
  R = [0 for j in range(N+1)]
  
  for j in range(N):
    L[j+1] = gcd(L[j], A[j])
  for j in reversed(range(N)):
    R[j] = gcd(R[j+1], A[j])

    m = -1
  for j in range(N):
    m = max(m, gcd(L[j], R[j+1]))
  print(m)

Buggy submission (verdict: Runtime Error):
import math

def gcd(a, b):
	while b > 0:
		a, b = b, a % b
	return a

def list_gcd(l):
    if len(l) == 0:
      return 0
    elif len(l) == 1:
      return l[0]
    elif len(l) == 2:
      return gcd(l[0], l[1])
    else:
      m = l[1:]
      return gcd(l[0], list_gcd(m))

N = int(input())
A = list(map(int, input().split()))

if N == 2:
  print(max(A))
else:
  m = -1
  for i in range(N):
    L = [A[j] for j in range(0, i)]
    R = [A[j] for j in range(i+1, N)]
    m = max(m, gcd(list_gcd(L),list_gcd(R)))
  print(m)

Buggy submission (verdict: Runtime Error):
import fractions

def list_gcd(l):
    if len(l) == 0:
      return 0
    elif len(l) == 1:
      return l[0]
    elif len(l) == 2:
      return fractions.gcd(l[0], l[1])
    else:
      m = l[1:]
      return fractions.gcd(l[0],list_gcd(m))

N = int(input())
A = list(map(int, input().split()))

if N == 2:
  print(max(A))
else:
  m = -1
  for i in range(N):
    L = [A[j] for j in range(0, i)]
    R = [A[j] for j in range(i+1, N)]
    m = max(m, fractions.gcd(list_gcd(L),list_gcd(R)))
  print(m)

Buggy submission (verdict: Runtime Error):
import math

def gcd(l):
    if len(l) == 0:
      return 0
    elif len(l) == 1:
      return l[0]
    elif len(l) == 2:
      return math.gcd(l[0], l[1])
    else:
      m = l[1:]
      return math.gcd(l[0],gcd(m))

N = int(input())
A = list(map(int, input().split()))

if N == 2:
  print(max(A))
else:
  m = -1
  for i in range(N):
    L = [A[j] for j in range(0, i)]
    R = [A[j] for j in range(i+1, N)]
    m = max(m, math.gcd(gcd(L),gcd(R)))
  print(m)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int, input().split()))

if N == 2:
  print(max(A))
else:
  G = math.gcd(A[0], A[1])
  H = math.gcd(A[1], A[2])
  I = math.gcd(A[2], A[0])

  print(max(G, H, I))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int, input().split()))

if N == 2:
  print(max(A))
  exit()

G = math.gcd(A[0], A[1])
H = math.gcd(A[1], A[2])
I = math.gcd(A[2], A[0])

print(max(G, H, I))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int, input().split()))

M = max(A)
ans = 1

G = math.gcd(A[0], A[1])
for i in range(2, N):
  G = math.gcd(G, A[i])

for i in reversed(range(G, M+1, G)):
  l = 0
  for j in range(N):
    if A[j] % i > 0:
      l += 1
  
  if l <= 1:
    ans = i
    break

print(ans)
Problem p03071 (python)

Fixed submission:
A, B = map(int, input().split())
i = 0
 
for j in range(2):
	if A > B:
	  i += A
	  A -= 1
	else:
	  i += B
	  B -= 1
 
print(i)

Buggy submission (verdict: Runtime Error):
A, B = map(int, imput().split())
i = 0

for j in range(2):
	if A > B:
	  i += A
	  A -= 1
	else:
	  i += B
	  B -= 1

print(i)
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().split())
n %= k
m = n
m -= k
m = abs(m)
n = min(n, m)
print(n)

Buggy submission (verdict: Runtime Error):
n, k = int(input())
print(n % k)
Problem p03574 (python)

Fixed submission:
h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    l=""
    for j in range(w):
        if s[i][j]=="#":
            l+="#"
        else:
            l+=str(sum([t[max(0,j-1):min(w,j+2)].count("#") for t in s[max(0,i-1):min(h,i+2)]]))
    print(l)

Buggy submission (verdict: Runtime Error):
N=int(input())
v=[int(x) for x in input().split()]
cnt=0
while cnt<N-1:
    v.sort()
    v[0]=(v[0]+v.pop(1))/2
    cnt+=1
print(v[0])
Problem p03436 (python)

Fixed submission:
R,C=map(int,input().split())
sx,sy=1,1
gx,gy=R,C
count=0
mp = [[i for i in input().rstrip()] for i in range(R)]
for i in range(R):
  mp[i]=list(mp[i])
for i in range(R):
	for j in range(C):
		if(mp[i][j]=='#'):
			count+=1
ans=[[3000 for i in range(C)] for j in range(R)]
ans[sx-1][sy-1]=0
start=[sx-1,sy-1]
goal=[gx-1,gy-1]
nsx=[1,0,-1,0]
nsy=[0,1,0,-1]

def bfs(graph,st,end):
  queue=[st]
  while queue:
    nw=queue.pop(0)
    if nw==end:
      return ans[end[0]][end[1]]
    else:
      for i in range(4):
        ns1=nw[0]+nsx[i]
        ns2=nw[1]+nsy[i]
        if (0 <= ns1)and(ns1<=(R-1))and(0<=ns2)and(ns2<=(C-1)) and ans[ns1][ns2]==3000 and mp[ns1][ns2]=='.':
          ans[ns1][ns2]=ans[nw[0]][nw[1]]+1
          queue.append([ns1,ns2])
  return

while True:
	try:
		print(R*C-bfs(mp,start,goal)-1-count)
		break
	except (RuntimeError,TypeError,NameError):
		print(-1)
		break

Buggy submission (verdict: Runtime Error):
R,C=map(int,input().split())
sx,sy=1,1
gx,gy=R,C
count=0
mp = [[i for i in input().rstrip()] for i in range(R)]
for i in range(R):
  mp[i]=list(mp[i])
for i in range(R):
	for j in range(C):
		if(mp[i][j]=='#'):
			count+=1
ans=[[3000 for i in range(C)] for j in range(R)]
ans[sx-1][sy-1]=0
start=[sx-1,sy-1]
goal=[gx-1,gy-1]
nsx=[1,0,-1,0]
nsy=[0,1,0,-1]

def bfs(graph,st,end):
  queue=[st]
  while queue:
    nw=queue.pop(0)
    if nw==end:
      return ans[end[0]][end[1]]
    else:
      for i in range(4):
        ns1=nw[0]+nsx[i]
        ns2=nw[1]+nsy[i]
        if (0 <= ns1)and(ns1<=(R-1))and(0<=ns2)and(ns2<=(C-1)) and ans[ns1][ns2]==3000 and mp[ns1][ns2]==".":
          ans[ns1][ns2]=ans[nw[0]][nw[1]]+1
          queue.append([ns1,ns2])
  return

print(R*C-bfs(mp,start,goal)-1-count)

Buggy submission (verdict: Runtime Error):
from collections import Counter
R,C=map(int,input().split())
sx,sy=1,1
gx,gy=R,C
count=0
mp = [[i for i in input().rstrip()] for i in range(R)]
for i in range(R):
  mp[i]=list(mp[i])
for i in range(R):
	for j in range(C):
		if(mp[i][j]=='#'):
			count+=1
ans=[[3000 for i in range(C)] for j in range(R)]
ans[sx-1][sy-1]=0
start=[sx-1,sy-1]
goal=[gx-1,gy-1]
nsx=[1,0,-1,0]
nsy=[0,1,0,-1]

def bfs(graph,st,end):
  queue=[st]
  while queue:
    nw=queue.pop(0)
    if nw==end:
      return ans[end[0]][end[1]]
    else:
      for i in range(4):
        ns1=nw[0]+nsx[i]
        ns2=nw[1]+nsy[i]
        if (0 <= ns1)and(ns1<=(R-1))and(0<=ns2)and(ns2<=(C-1)) and ans[ns1][ns2]==3000 and mp[ns1][ns2]==".":
          ans[ns1][ns2]=ans[nw[0]][nw[1]]+1
          queue.append([ns1,ns2])
  return

print(R*C-bfs(mp,start,goal)-1-count)
Problem p03437 (python)

Fixed submission:
x,y=map(int,input().split())
if y==1:
    print('-1')
    exit()
elif x%y==0:
    print('-1')
    exit()
for i in range(x,10**18//x,x):
    if i%y!=0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if x==y:
    print('-1')
    break
for i in range(x,10**9//x,x):
    if i%y!=0:
        print(i)
        break
Problem p03838 (python)

Fixed submission:
x,y=map(int,input().split())

count=0
xlist=[x,-x,x,-x]
ylist=[y,y,-y,-y]
numlist=[0,1,1,2]
ans=10**9+7

for i in range(4):
    if xlist[i] <= ylist[i]:
        ans=min(ans,numlist[i]+ylist[i]-xlist[i])

print(ans)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())

count=0
xlist=[x,-x,x,-x]
ylist=[y,y,-y,-y]
numlist=[0,1,1,2]
ans=10**9+7

for i in range(4):
    if xlist[i] <= ylist(i):
        ans=min(ans,numlist[i]+ylist[i]-xlist[i])

print(ans)
Problem p03852 (python)

Fixed submission:
c=str(input())
if(c=='a'):
    print('vowel')
elif(c=='i'):
    print('vowel')
elif(c=='u'):
    print('vowel')
elif(c=='e'):
    print('vowel')
elif(c=='o'):
    print('vowel')
else:
    print('consonant')

Buggy submission (verdict: Runtime Error):
c=str(input())
print(['consonant','vowel'][c=='a'or'i'or'u'or'e'or'o'])
Problem p02732 (python)

Fixed submission:

import collections

N = int(input())
A = list(map(int, input().split()))

ct = collections.Counter(A)

ret = []
total = 0
for k,count in ct.items():
    if count > 1:
        total += count * (count-1) // 2

for i,v in enumerate(A):
    if ct[v] > 1:
        count = ct[v]
        adjust = (count-1) * (count-2) // 2 - (count-1) * count // 2
        val = total + adjust
    else:
        val = total
    print(val)

Buggy submission (verdict: Runtime Error):

N = int(input())
A = list(map(int, input().split()))

ct = collections.Counter(A)

ret = []
total = 0
for k,count in ct.items():
    if count > 1:
        total += count * (count-1) // 2

for i,v in enumerate(A):
    if ct[v] > 1:
        count = ct[v]
        adjust = (count-1) * (count-2) // 2 - (count-1) * count // 2
        val = str(total + adjust)
    else:
        val = '0'
    print(val)
Problem p02742 (python)

Fixed submission:

from math import ceil, sqrt, floor


H, W = list(map(int, input().split()))

if H == 1 or W == 1:
    print(1)
    exit(0)

areas = [ceil(H / 2), H // 2]

ret = areas[0] * (ceil(W / 2)) + areas[1] * (W // 2)

print(ret)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
from typing import List
import collections
import bisect
import itertools
import functools
from fractions import gcd
import heapq
from math import ceil, sqrt, floor

import sys
sys.setrecursionlimit(50000)

import collections

from collections import defaultdict, deque
import collections

import bisect
import collections
from sortedcontainers import SortedList, SortedDict


H, W = list(map(int, input().split()))

areas = [ceil(H / 2), H // 2]

ret = areas[0] * (ceil(W / 2)) + areas[1] * (W // 2)

print(ret)

Buggy submission (verdict: Runtime Error):


H, W = list(map(int, input().split()))

areas = [ceil(H / 2), H // 2]

ret = areas[0] * (ceil(W / 2)) + areas[1] * (W // 2)

print(ret)

Buggy submission (verdict: Runtime Error):


H, W = list(map(int, input().split()))

areas = [ceil(H / 2), H // 2]

ret = areas[0] * (ceil(W / 2)) + areas[1] * (W // 2)

print(ret)
Problem p02755 (python)

Fixed submission:


from math import ceil, sqrt, floor

A, B = list(map(int, input().split()))

for i in range(1, 2000):
    if floor(i * 0.08) == A and floor(i*0.1) == B:
        print(i)
        exit(0)
print(-1)

Buggy submission (verdict: Runtime Error):


A, B = list(map(int, input().split()))

for i in range(1, 2000):
    if floor(i * 0.08) == A and floor(i*0.1) == B:
        print(i)
        exit(0)
print(-1)
Problem p02756 (python)

Fixed submission:


import collections

S = input()
Q = int(input())

rev = False
deque = collections.deque()
for c in S:
    deque.append(c)
for _ in range(Q):
    read = input()
    if read == '1':
        rev = not rev
    else:
        _, f, c = read.split()
        if not rev:
            if f == '1':
                deque.appendleft(c)
            else:
                deque.append(c)
        else:
            if f == '1':
                deque.append(c)
            else:
                deque.appendleft(c)

ret = ''.join(deque if not rev else reversed(deque))
print(ret)

Buggy submission (verdict: Runtime Error):
ions

S = input()
Q = int(input())

rev = False
deque = collections.deque()
for c in S:
    deque.append(c)
for _ in range(Q):
    read = input()
    if read == '1':
        rev = not rev
    else:
        _, f, c = read.split()
        if not rev:
            if f == '1':
                deque.appendleft(c)
            else:
                deque.append(c)
        else:
            if f == '1':
                deque.append(c)
            else:
                deque.appendleft(c)

ret = ''.join(deque if not rev else reversed(deque))
print(ret)

Buggy submission (verdict: Runtime Error):
from typing import List
import collections

import bisect
import itertools
import functools
from collections import defaultdict
import collections

from fractions import gcd
import heapq
from math import ceil, sqrt, floor

import sys
sys.setrecursionlimit(50000)
from collections import defaultdict


S = input()
Q = int(input())

rev = False
deque = collections.deque()
deque.append(S)
for _ in range(Q):
    read = input()
    if read == '1':
        rev = not rev
    else:
        _, f, c = read.split()
        if f == '1':
            if not rev:
                deque.appendleft(c)
            else:
                deque.append(c)
        else:
            if rev:
                deque.appendleft(c)
            else:
                deque.append(c)
ret = ''.join(deque if not rev else reversed(deque))
print(ret)
Problem p02783 (python)

Fixed submission:
from math import ceil
H, A  = list(map(int, input().split()))



print(ceil(H / A))

Buggy submission (verdict: Runtime Error):
H, N = list(map(int, input().split()))

inf = 2**30
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    A, B = list(map(int, input().split()))
    for j in range(H + 1):
        if dp[j] != inf:
            next = min(H, j + A)
            dp[next] = min(dp[next], dp[j] + B)

print(dp[H])
Problem p02621 (python)

Fixed submission:
from sys import stdin
a = int(stdin.readline().rstrip())
print(a+a**2+a**3)

Buggy submission (verdict: Runtime Error):
from sys import stdin
a = stdin.readline().rstrip()
print(a+a**2+a**3)
Problem p02658 (python)

Fixed submission:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 1
if 0 in A:
    print(0)
    exit()
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        return
print(ans)
Problem p02778 (python)

Fixed submission:
from sys import stdin
S = stdin.readline().rstrip()
print('x'*len(S))

Buggy submission (verdict: Runtime Error):
from sys import stdin
S = stdin.readline().rstrip()
print(x*len(S))
Problem p02780 (python)

Fixed submission:
from itertools import accumulate
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
evs = [(1+p)/2 for p in P]
evs = [0] + list(accumulate(evs))
ans = 0
for i in range(K, N+1):
    ans = max(ans, evs[i]-evs[i-K])
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
evs = [(1+p)/2 for p in P]
evs = list(accumulate(evs))
results = [evs[i+K] - evs[i] for i, e in enumerate(evs[:N-K])]
print(sorted(results)[-1])
Problem p03060 (python)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(_) for _ in stdin.readline().rstrip().split()]
C = [int(_) for _ in stdin.readline().rstrip().split()]
ans=0
for i in range(N):
    if V[i]-C[i] > 0:
        ans+=V[i]-C[i]
print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(_) for _ in stdin.readline().rstrip().split()]
V_c =V.copy()
C = [int(_) for _ in stdin.readline().rstrip().split()]
C_c =C.copy()
for i in range(N):
    if V[i]<C[i]:
        V_c.pop(i)
        C_c.pop(i)
print(sum(V_c)-sum(C_c))