Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
input()

def no_Divisible(num,num_list):
    for row in set(num_list):
        if num%row==0:
            return 0
    return 1

input_list = np.array(sorted(list(map(lambda x:int(x),input().split(" "))),reverse=True))
count = 0
prev_num = 0
for i,num in enumerate(input_list):
    if num == prev_num:
        continue
    #print(num)
    #print(input_list[i+1:]%num)
    #if sum(input_list[i+1:]%num==0):
    if no_Divisible(num,input_list[i+1:]):
        count += 1
    prev_num = num
print(count)



Fixed submission:
x,y = map(lambda x:int(x),input().split(" "))
if y==0:
    print(x)
else:
    input_list = list(map(lambda x:int(x),input().split(" ")))
    for i in range(y+2):
        if x-i not in input_list:
            print(x-i)
            break
        elif x+i not in input_list:
            print(x+i)
            break
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

print(a*b)

Fixed submission:
input_num = input()
a,b = list(map(lambda x:int(x),input_num.split(" ")))
print(a*b)
Buggy python submission (verdict: Runtime Error):
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
  if total_pow > 10**18:
  	if "0" in input_list.split(" "):
      print("0")
    else:
      print("-1")
  	sys.exit()

print(total_pow)


Fixed submission:
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
    total_pow *= int(num)
    if total_pow > 10**18:
        if "0" in input_list.split(" "):
            print("0")
        else:
            print("-1")
        sys.exit()

print(total_pow)

Buggy python submission (verdict: Runtime Error):
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
  if total_pow > 10**18:
  	if "0" in input_list.split(" "):
      print("0")
    else:
      print("-1")
  	sys.exit()
print(total_pow)

Fixed submission:
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
    total_pow *= int(num)
    if total_pow > 10**18:
        if "0" in input_list.split(" "):
            print("0")
        else:
            print("-1")
        sys.exit()

print(total_pow)

Buggy python submission (verdict: Time Limit Exceeded):
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
 
if total_pow > 10**18:
  print("-1")
else:
  print(total_pow)

Fixed submission:
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
    total_pow *= int(num)
    if total_pow > 10**18:
        if "0" in input_list.split(" "):
            print("0")
        else:
            print("-1")
        sys.exit()

print(total_pow)

Buggy python submission (verdict: Runtime Error):
input_num = input()
input_list = input()

total_pow = 1
[total_pow*=int(num) for num in input_list.split(" ")]

if total_pow > 10**18:
  print("-1")
else:
  print(total_pow)

Fixed submission:
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
    total_pow *= int(num)
    if total_pow > 10**18:
        if "0" in input_list.split(" "):
            print("0")
        else:
            print("-1")
        sys.exit()

print(total_pow)
Buggy python submission (verdict: Runtime Error):
first_str = input()
second_str = input()

if first_str == secofirst_str = input()
second_str = input()


if first_str == second_str[:len(first_str)] and len(first_str)+1 == len(second_str) and second_str[-1].islower():
    print("Yes")
else:
    print("No")

Fixed submission:
first_str = input()
second_str = input()


if first_str == second_str[:len(first_str)] and len(first_str)+1 == len(second_str) and second_str[-1].islower():
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
answer = input()

answer = answer.split(' ')

if answer[2]*answer[1]>=answer[0]:
  print(Yes)
else :
  print(No)

Fixed submission:
answer = input()
 
answer = answer.split(' ')
 
if int(answer[2])*int(answer[1])>=int(answer[0]):
  print("Yes")
else :
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
H,W,D=list(map(int,input().split()))
X=[(0,0) for i in range(H*W+1)]

for i in range(1,H+1):
	A=list(map(int,input().split()))
	for idx,a in enumerate(A):
		X[a]=(i,idx+1)

Q=int(input())
for i in range(Q):
	L,R=list(map(int,input().split()))
	S=[0]*(H*W+1)
	for i in range(D+1,H*W+1):
		S[i]=S[i-D]+abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])
	print(S[R]-S[L])

Fixed submission:
H,W,D=list(map(int,input().split()))
X=[(0,0) for i in range(H*W+1)]

for i in range(1,H+1):
	A=list(map(int,input().split()))
	for idx,a in enumerate(A):
		X[a]=(i,idx+1)

Q=int(input())
L=[]
R=[]
S=[0]*(H*W+1)

for i in range(Q):
	l,r=list(map(int,input().split()))
	L.append(l)
	R.append(r)

for i in range(D+1,H*W+1):
	S[i]=S[i-D]+abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])

for i in range(Q):
	print(S[R[i]]-S[L[i]])

Buggy python submission (verdict: Time Limit Exceeded):
H,W,D=list(map(int,input().split()))
X=[(0,0) for i in range(H*W+1)]

for i in range(1,H+1):
	A=list(map(int,input().split()))
	for idx,a in enumerate(A):
		X[a]=(i,idx+1)

Q=int(input())
memo=[[0 for i in range(H*W+1)] for j in range(H*W+1)]
for i in range(Q):
	mp=0
	L,R=list(map(int,input().split()))
	now=L
	if memo[L][R]!=0:
		print(memo[L][R])
	else:
		while now!=R:
			mp+=abs(X[now+D][0]-X[now][0])+abs(X[now+D][1]-X[now][1])
			memo[L][R]=mp
			now+=D
		print(mp)
	

Fixed submission:
H,W,D=list(map(int,input().split()))
X=[(0,0) for i in range(H*W+1)]

for i in range(1,H+1):
	A=list(map(int,input().split()))
	for idx,a in enumerate(A):
		X[a]=(i,idx+1)

Q=int(input())
L=[]
R=[]
S=[0]*(H*W+1)

for i in range(Q):
	l,r=list(map(int,input().split()))
	L.append(l)
	R.append(r)

for i in range(D+1,H*W+1):
	S[i]=S[i-D]+abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])

for i in range(Q):
	print(S[R[i]]-S[L[i]])

Buggy python submission (verdict: Time Limit Exceeded):
H,W,D=list(map(int,input().split()))
X=[(0,0) for i in range(H*W+1)]

for i in range(1,H+1):
	A=list(map(int,input().split()))
	for idx,a in enumerate(A):
		X[a]=(i,idx+1)

Q=int(input())

for i in range(Q):
	mp=0
	L,R=list(map(int,input().split()))
	now=L
	while now!=R:
		mp+=abs(X[now+D][0]-X[now][0])+abs(X[now+D][1]-X[now][1])
		now+=D
	print(mp)
	

Fixed submission:
H,W,D=list(map(int,input().split()))
X=[(0,0) for i in range(H*W+1)]

for i in range(1,H+1):
	A=list(map(int,input().split()))
	for idx,a in enumerate(A):
		X[a]=(i,idx+1)

Q=int(input())
L=[]
R=[]
S=[0]*(H*W+1)

for i in range(Q):
	l,r=list(map(int,input().split()))
	L.append(l)
	R.append(r)

for i in range(D+1,H*W+1):
	S[i]=S[i-D]+abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])

for i in range(Q):
	print(S[R[i]]-S[L[i]])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))

ans=0
for i in set(a):
	x = a.count(i)
	if x-i>=0:
		ans += x-i
	else:
		ans += x
print(ans)


Fixed submission:
N = int(input())
a = map(int,input().split())
dic={}

ans=0
for i in a:
	dic.setdefault(i,0)
	dic[i]+=1
for a,b in dic.items():	
	if b-a>=0:
		ans += b-a
	else:
		ans += b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))

ans=0
for i in range(max(a),0,-1):
	x = a.count(i)
	if x-i>=0:
		ans += x-i
	else:
		ans += x
print(ans)


Fixed submission:
N = int(input())
a = map(int,input().split())
dic={}

ans=0
for i in a:
	dic.setdefault(i,0)
	dic[i]+=1
for a,b in dic.items():	
	if b-a>=0:
		ans += b-a
	else:
		ans += b
print(ans)
Buggy python submission (verdict: Runtime Error):
x = input()
fxsum = sum(map(int, list(x))) 
if int(x)%fxsum==0:
	print("Yes")
else:
	print("No")


Fixed submission:
n, a, b = map(int, input().split())
print(min(n * a, b))
Buggy python submission (verdict: Runtime Error):
N = int(input())

F = [int(input().replace(" ",""),2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]


profit = float("-inf")

for i in range(1,1024):
	tmp = 0
	for j in range(N):
		tmp = tmp + (bin(i & F[j]).count('1'))
		tmp2 = P[j][tmp]
	profit = max(profit, tmp2)

print(profit)

Fixed submission:
n = int(input())
     
f = [int(input().replace(" ", ""), 2) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
     
ans = float('-inf')
     
for i in range(1, 1024):
    price = 0
    for j in range(n):
        price += p[j][bin(i & f[j]).count('1')]
    ans = max(ans, price)
     
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())

F = [int(input().replace(" ",""),2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]


profit = float("-inf")

for i in range(1,1024):
	tmp = 0
	for j in range(N):
		if i & F[j] :
			tmp = tmp + 1
			tmp2 = P[tmp]
	profit = max(profit, tmp2)

print(profit)

Fixed submission:
n = int(input())
     
f = [int(input().replace(" ", ""), 2) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]
     
ans = float('-inf')
     
for i in range(1, 1024):
    price = 0
    for j in range(n):
        price += p[j][bin(i & f[j]).count('1')]
    ans = max(ans, price)
     
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())

pair=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
graph=[[0]*N for _ in range(N)] #隣接行列の初期化


for p in pair:
	graph[p[0]][p[1]]= graph[p[1]][p[0]]=1
	
def DFS(v):
	if visited[v]:
		return 
	visited[v]=True
	for j in [j for j,v2 in enumerate(graph[v]) if v2==1]:
		DFS(j)
		
res = 0

for i in range(M):
	visited=[False for _ in range(N)] #訪問済みリストの初期化
	x,y=pair[i]
	graph[x][y]=graph[y][x]=0 #辺を取り除く
	DFS(0 if i>0 else 1)
	
	if not all(visited): #全ての頂点が訪問済みでなかった場合
		res+=1
	
	graph[x][y]=graph[y][x]=1

print(res)

Fixed submission:
A,B,C=list(input().split())

if A==B:
	print(C)
elif B==C:
	print(A)
else:
	print(B)

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

pair=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
graph=[[0]*N for _ in range(N)] #隣接行列の初期化


for p in pair:
	graph[p[0]][p[1]]= graph[p[1]][p[0]]=1
	
def DFS(v):
	if visited[v]:
		return 
	visited[v]=True
	for i in [i for i,v2 in enumerate(graph[v]) if v2==1]:
		DFS(i)
		
res = 0

for i in range(M):
	visited=[False for _ in range(N)] #訪問済みリストの初期化
	x,y=pair[i]
	graph[x][y]=graph[y][x]=0 #辺を取り除く
	DFS(0 if i>0 else 1)
	
	if not all(visited): #全ての頂点が訪問済みでなかった場合
		res+=1
	
	graph[x][y]=graph[y][x]=1

print(res)

Fixed submission:
A,B,C=list(input().split())

if A==B:
	print(C)
elif B==C:
	print(A)
else:
	print(B)

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

pair=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
graph=[[0]*N for _ in range(N)] #隣接行列の初期化

print(pair)

for p in pair:
	graph[p[0]][p[1]]= graph[p[1]][p[0]]=1
	
def DFS(v):
	if visited[v]:
		return 
	visited[v]=True
	for i in [i for i,v2 in enumerate(graph[v]) if v2==1]:
		DFS(i)
		
res = 0

for i in range(M):
	visited=[False for _ in range(N)] #訪問済みリストの初期化
	x,y=pair[i]
	graph[x][y]=graph[y][x]=0 #辺を取り除く
	DFS(0 if i>0 else 1)
	
	if not all(visited): #全ての頂点が訪問済みでなかった場合
		res+=1
	
	graph[x][y]=graph[y][x]=1

print(res)

Fixed submission:
A,B,C=list(input().split())

if A==B:
	print(C)
elif B==C:
	print(A)
else:
	print(B)

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

pair=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
graph=[[0]*N for _ in range(N)] #隣接行列の初期化

print(pair)

for p in pair:
	graph[p[0]][p[1]]= graph[p[1]][p[0]]=1
	
def DFS(v):
	if visited[v]:
		return 
	visited[v]=True
	for i in [i for i,v2 in enumerate(graph[v]) if v2==1]:
		DFS(i)
		
res = 0

for i in range(M):
	visited=[False for _ in range(N)] #訪問済みリストの初期化
	x,y=pair[i]
	graph[x][y]=graph[y][x]=0 #辺を取り除く
	DFS(0)
#	DFS(0 if i>0 else 1)
	
	if not all(visited): #全ての頂点が訪問済みでなかった場合
		res+=1
	
	graph[x][y]=graph[y][x]=1

print(res)

Fixed submission:
A,B,C=list(input().split())

if A==B:
	print(C)
elif B==C:
	print(A)
else:
	print(B)
Buggy python submission (verdict: Runtime Error):
N=input()

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

Rate=[]
for i in range(9):
    Rate.append(0)

for i in A:
    index=i/400
    if index>8:
        index=8
    Rate[index]=Rate[index]+1

a=0

for i in range(8):
    if Rate[i]>0:
        a=a+1

Max=a+Rate[8]
Min=min(a,1)

print(Min, Max)



Fixed submission:
import math
N=input()

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

Rate = []
for i in range(9):
    Rate.append(0)

for i in A:
    index=math.floor(i/400)
    if index > 8:
        index = 8
    Rate[index] = Rate[index] + 1

a = 0

for i in range(8):
    if Rate[i] > 0:
        a=a+1

Max = a + Rate[8]
Min = max(a, 1)

print(Min, Max)
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B=list(map(int,input().split()))
h = [int(input()) for i in range(N)]
count=0

while max(h)>0:
    h=sorted(h,reverse=True)
    h[0]-=A
    for j in range(len(h)-1):
        h[j+1]-=B
    count+=1

print(count)


Fixed submission:

import math

N, A, B = map(int, input().split())
h = [int(input()) for i in range(N)]


def enough(T):
    atack = B * T
    diff = A - B
    count = 0
    for i in h:
        tmp = math.ceil((i - atack) / diff)
        if tmp > 0:
            count += tmp

    return count<=T


def tree():
    low = 0
    high = 10 ** 9
    while high - low > 1:
        mid = (low + high) // 2
        if enough(mid):
            high = mid
        else:
            low = mid
    return high


print(tree())
Buggy python submission (verdict: Time Limit Exceeded):
from sys import exit
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A: print(0)
else:
    for i in A:
        ans *= i
    if ans > 10 ** 18:
        print(-1)
    else:         
        print(ans)        


Fixed submission:
from sys import exit
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A: print(0)
else:
    for i in A:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import exit
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in A:
    ans *= i
if ans > 10 ** 18:
    print(-1)
else: print(ans)


Fixed submission:
from sys import exit
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A: print(0)
else:
    for i in A:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
T = input()
ans = ""
for i in T: 
  if i == "P": ans += "P"
  elif i == "D": ans += "D"
  else: ans += "D"
print(ans)    

Fixed submission:
T = input()
print(T.replace("?","D"))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = []
for i in range(N):
    S = input()
    if S not in ans: ans.append(S)
print(len(ans))


Fixed submission:
N = int(input())
ans = []
for i in range(N):
    ans.append(input())
print(len(set(ans)))
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
if N < sum(A): print(-1)
else: print(N - sum(A))


Fixed submission:
from math import pi
print(2 * int(input()) * pi)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
for i in range(1,N + 1):
    if (i) not in A: print(0)
    else: print(c[i])


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
for i in range(N): print(c[i + 1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N + 1):
    if (i) not in A: print(0)
    else: print(A[i - 1:].count(i))


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
for i in range(N): print(c[i + 1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    print(A[i:].count(i + 1))


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
for i in range(N): print(c[i + 1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    print(A.count(i + 1))


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
for i in range(N): print(c[i + 1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
sum = 0
count = []
for i in set(A):
    j = A.count(i)
    sum += j * (j - 1) // 2
for i in A:
    print(sum - A.count(i) + 1)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c= Counter(A)
sum = 0
for i in c.values():
    sum += i * (i - 1) // 2
for i in A:
    print(sum - c[i] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
min = min(A)
max = max(A)
sum = 0
for i in range(min,max + 1):
    j = A.count(i)
    sum += j * (j - 1) // 2
for i in A:
    print(sum - A.count(i) + 1)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c= Counter(A)
sum = 0
for i in c.values():
    sum += i * (i - 1) // 2
for i in A:
    print(sum - c[i] + 1)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
a, b, c = map(int,input().split())
if 4*a*b < (c - a - b)**2: print("Yes")
else: print("No")


Fixed submission:
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(list[K-1])

Buggy python submission (verdict: Runtime Error):
from math import sqrt
a, b, c = map(int,input().split())
if a + b + 2*sqrt(a*b) < c: print("Yes")
else: print("No")


Fixed submission:
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(list[K-1])
Buggy python submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
disc = []
for i in range(M):
  disc.append(list(map(int,input().split())))
ans = a[0] + b[0]
for i in range(M):
  ans = min(a[disc[i][0]-1] + b[disc[i][1]-1] - disc[i][2], ans)     
    
print(ans)


Fixed submission:
S = input()
if S == "hi" or S == "hihi" or S == "hihihi" or S == "hihihihi" or S == "hihihihihi" : print("Yes") 
else: print("No")
Buggy python submission (verdict: Runtime Error):
from collections import deque
S = deque(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:S.insert(0,query[4])
if rev == 1: S.reverse()  
print("".join(S))    

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:S.appendleft(query[4])
if rev == 1: S.reverse()  
print("".join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:
    S.reverse()
    S.append(query[4])
    rev = 1 - rev
if rev == 1: S.reverse()  
print("".join(S))    

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:S.appendleft(query[4])
if rev == 1: S.reverse()  
print("".join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:  S.insert(0,query[4])
if rev == 1: S.reverse()  
print("".join(S))    

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:S.appendleft(query[4])
if rev == 1: S.reverse()  
print("".join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev += 1
  elif query[2] == "1" and rev % 2 == 0 or query[2] == "2" and rev % 2 == 1: S = query[4] + S
  else: S = S + query[4]
    
if rev % 2 == 1: S = S[::-1]
print(S)    
    

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:S.appendleft(query[4])
if rev == 1: S.reverse()  
print("".join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
  query = input()
  if query == "1": S = S[::-1]
  elif query[2] == "1": S = query[4] + S
  else: S = S + query[4]
print(S)  

Fixed submission:
from collections import deque
S = deque(input())
Q = int(input())
rev = 0
for i in range(Q):
  query = input()
  if query == "1": rev = 1 - rev 
  elif int(query[2]) + rev == 2: S.append(query[4])
  else:S.appendleft(query[4])
if rev == 1: S.reverse()  
print("".join(S))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
p = list(map(int, input().split()))
exp = list(map(lambda x : (x+1)/2, p))         
ans = 0
for i in range(N-K+1):
  if sum(exp[i:i+K]) > ans: ans = sum(exp[i:i+K])
print(ans)

Fixed submission:
N, K = map(int,input().split())
p = list(map(int, input().split()))
s = [0]
for i in range(N):
  s.append(s[i]+p[i])
num = 0
ans = 0
exp = 0
for i in range(N-K+1):
  sum = s[i+K]-s[i]
  if num<sum: 
    num = sum
    ans = i
for i in range(K):
  exp += (p[ans+i]+1)/2
print(exp)
Buggy python submission (verdict: Runtime Error):
from math import ceil()
H, A = map(int,input().split())

print(ceil(H/A))

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

print(ceil(H/A))
Buggy python submission (verdict: Runtime Error):
H, N = map(int,input().split())
A = list(map(int,input().split())
         
if H <= sum(A): print("Yes")
else: print("No")   

Fixed submission:
H, N = map(int,input().split())
A = list(map(int,input().split()))
         
if H <= sum(A): print("Yes")
else: print("No")