Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
A = list(map(int,input().split()))
for d in range(X+1):
  for i in [-1, +1]:
    B = X + d*i
    if A.count(B) == 0:
      print(B)
      exit(0)

Fixed submission:
llist = list(map(int,input().split()))
print(llist.index(0)+1)

Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
A = list(map(int,input().split()))
for d in range(X+1):
  for i in [+1,-1]:
    B = X + d*i
    if A.count(B) == 0:
      print(B)
      exit(0)

Fixed submission:
llist = list(map(int,input().split()))
print(llist.index(0)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
cc = list(map(int,input().split()))
aa = [1]
flag = True
a = 1
while flag:
  aa.append(cc[a-1])
  a = cc[a-1]
  if aa.count(a) == 2 or len(aa)==K+1:
    flag = False
if len(aa) == K+1:
  print(aa[-1])
else:
  b = aa.index(a)
  m = len(aa)-b-1
  mm = (K-b) % m
  del aa[:b]
  del aa[-1]
  print(aa[mm])

Fixed submission:
N,K = map(int,input().split())
cc = list(map(int,input().split()))
memo = []
aa = ['.']*N
a = 1
while aa[a-1] == '.':
  memo.append(a)
  aa[a-1] = 'v'
  a = cc[a-1]
if len(memo)>K:
  print(memo[K])
else:
  b = memo.index(a)
  m = len(memo)-b
  mm = (K-b) % m
  del memo[:b]
  print(memo[mm])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cc = []
for i in range(N):
  a = input()
  if a in  cc:
    continue
  cc.append(a)
print(len(cc))

Fixed submission:
N = int(input())
cc = []
for i in range(N):
  a = input()
  cc.append(a)
aa = set(cc)
print(len(aa))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from itertools import product
K = int(input())
cc = [i for i in range(1,K+1)]
count = 0
for i in product(cc,repeat = 3):
  aa = i[0]
  for j in [1,2]:
    aa = math.gcd(aa,i[j])
  count += aa
print(count)

Fixed submission:
from math import gcd
K = int(input())
count = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      count += gcd(gcd(i,j),k)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
List_R,List_G,List_B = [],[],[]
for i,j in enumerate(S):
  if j == 'R':
    List_R.append(i+1)
  elif j == 'G':
    List_G.append(i+1)
  else:
    List_B.append(i+1)
count = 0
for i in List_R:
  for j in List_G:
    for k in List_B:
      aa = [i,j,k]
      aa.sort()
      if aa[2]-aa[1] != aa[1]-aa[0]:
        count += 1
print(count)

Fixed submission:
N = int(input())
S = input()
abc = S.count('R')*S.count('G')*S.count('B')
L = (N-1)//2
for i in range(1,L+1):
  for j in range(N-2*i):
    if S[j]!=S[j+i] and S[j+i]!=S[j+2*i] and S[j]!=S[j+2*i]:
      abc -= 1
print(abc)
Buggy python submission (verdict: Time Limit Exceeded):
N,X,Y = map(int,input().split())
cc = []
for i in range(1,N+1):
  for j in range(i+1,N+1):
    cc.append(min(j-i,abs(X-i)+1+abs(Y-j)))
for i in range(1,N):
  print(cc.count(i))

Fixed submission:
N,X,Y = map(int,input().split())
cc = [0]*(N-1)
for i in range(1,N+1):
  for j in range(i+1,N+1):
    cc[min(j-i,abs(X-i)+1+abs(Y-j))-1] += 1
for i in cc:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
Q = int(input())
flip = 0
for i in range(Q):
  j = input()
  if len(j) == 1:
    flip += 1
    continue
  else:
    if j[2] == '1' and flip % 2 == 0:
      S = j[4] + S
      continue
    elif j[2] == '2' and flip % 2 == 0:
      S = S + j[4]
      continue
    elif j[2] == '1' and flip % 2 ==1:
      S = S + j[4]
      continue
    elif j[2] == '2' and flip % 2 ==1:
      S = j[4] + S
      continue
if flip % 2 == 1:
  S = S[::-1]
print(S)

Fixed submission:
S = str(input())
Q = int(input())
flip = 0
front,back = '',''
for i in range(Q):
  j = input()
  if len(j) == 1:
    flip += 1
    continue
  else:
    if j[2] == '1' and flip % 2 == 0:
      front = j[4] + front
      continue
    elif j[2] == '2' and flip % 2 == 0:
      back = back + j[4]
      continue
    elif j[2] == '1' and flip % 2 ==1:
      back= back + j[4]
      continue
    elif j[2] == '2' and flip % 2 ==1:
      front = j[4] + front
      continue
S = front + S + back
if flip % 2 == 1:
  S = S[::-1]
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
Q = int(input())
flip = 0
for i in range(Q):
  j = input()
  if len(j) == 1:
    flip += 1
    continue
  else:
    if j[2] == '1' and flip % 2 == 0:
      S = j[4] + S
    elif j[2] == '2' and flip % 2 == 0:
      S = S + j[4]
    elif j[2] == '1' and flip % 2 ==1:
      S = S + j[4]
    elif j[2] == '2' and flip % 2 ==1:
      S = j[4] + S
if flip % 2 == 1:
  S = S[::-1]
print(S)

Fixed submission:
S = str(input())
Q = int(input())
flip = 0
front,back = '',''
for i in range(Q):
  j = input()
  if len(j) == 1:
    flip += 1
    continue
  else:
    if j[2] == '1' and flip % 2 == 0:
      front = j[4] + front
      continue
    elif j[2] == '2' and flip % 2 == 0:
      back = back + j[4]
      continue
    elif j[2] == '1' and flip % 2 ==1:
      back= back + j[4]
      continue
    elif j[2] == '2' and flip % 2 ==1:
      front = j[4] + front
      continue
S = front + S + back
if flip % 2 == 1:
  S = S[::-1]
print(S)
Buggy python submission (verdict: Runtime Error):
import sys
N,M = map(int,input().split())
cc = [list(map(int, input().split())) for i in range(M)]
if [0,1] in cc:
  if N!= 1:
    print(-1)
    sys.exit()
a,b = [0]*N,['v']*N
for [i,j] in cc:
  a[i-1] = j
  if b[i-1] != 'v' or b[i-1] != j:
    print(-1)
    sys.exit
  b[i-1] = j
if a[0] = 0:
  a[0] = 1
c = ''
for i in a:
  c = c + str(i)
print(c)
  
  
    

Fixed submission:
import sys
N,M = map(int,input().split())
cc = [list(map(int, input().split())) for i in range(M)]
if [1,0] in cc:
  if N!= 1:
    print(-1)
    sys.exit()
a,b = [0]*N,['v']*N
for [i,j] in cc:
  a[i-1] = j
  if b[i-1] != 'v' and b[i-1] != j:
    print(-1)
    sys.exit()
  b[i-1] = j
if a[0] == 0:
  if N != 1:
    a[0] = 1
c = ''
for i in a:
  c = c + str(i)
print(c)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
cc = list(map(int,input().split()))
dic = set()
for i in cc:
  if i in dic:
    print('NO')
    sys.exit()
  else:
    dic.append(i)
print('YES')

    

Fixed submission:
import sys
N = int(input())
cc = list(map(int,input().split()))
dic = set()
for i in cc:
  if i in dic:
    print('NO')
    sys.exit()
  else:
    dic.add(i)
print('YES')
Buggy python submission (verdict: Runtime Error):
N = int(input())
judge = 'No'
for i in range(1:10):
  for j in range(1:10):
    if i * j == N:
      judge = 'Yes'
      break
    else:
      continue
  break
print(judge)

Fixed submission:
N = int(input())
judge = 'No'
for i in range(1,10):
  for j in range(1,10):
    if i * j == N:
      judge = 'Yes'
      break
  else:
    continue
  break
print(judge)
Buggy python submission (verdict: Runtime Error):
from itertools import product
N,M = map(int,input().split())
cc = []
for i in range(M):
  ll = list(map(int,input().split()))
  cc.append(ll)
p = list(map(int,input().split()))
count = 0
for i in product('01',repeat = N):
  on = 0
  bulb = 0
  for j in range(M):
    for k in range(cc[j][0]):
      if i[cc[m][l+1]-1] == 1:
        on += 1
    if on % 2 == p[j]:
      bulb += 1
  if bulb == M:
    count += 1
print(count)
    
      
  


Fixed submission:
from itertools import product
N,M = map(int,input().split())
cc = []
for i in range(M):
  ll = list(map(int,input().split()))
  cc.append(ll)
p = list(map(int,input().split()))
count = 0
for i in product([0,1],repeat = N):
  bulb = []
  for j in range(M):
    on = 0
    for k in range(cc[j][0]):
      if i[cc[j][k+1]-1] == 1:
        on += 1
    if on % 2 == p[j]:
      bulb.append(1)
  if sum(bulb) == M:
    count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a_li = list(map(int,input().split()))
ruiseki = [0]*n
ruiseki[0] = a_li[0]
for i in range(1,n):
    ruiseki[i] = ruiseki[i - 1]*a_li[i]
num = ruiseki[k-1]
for i in range(k,n):
    dum = ruiseki[i]//ruiseki[i-k]
    if dum > num:
        print("Yes")
    else:
        print("No")
    num = dum

Fixed submission:
n,k = map(int,input().split())
a_li = list(map(int,input().split()))

for i in range(k,n):
    if a_li[i-k] < a_li[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a_li = list(map(int,input().split()))
ans = 1
for i in range(k):
    ans *= a_li[i]
for i in range(k,n):
    num = ans // a_li[i-k]
    num *= a_li[i]
    if num > ans:
        print("Yes")
    else:
        print("No")
    ans = num

Fixed submission:
n,k = map(int,input().split())
a_li = list(map(int,input().split()))

for i in range(k,n):
    if a_li[i-k] < a_li[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a_li = list(map(int,input().split()))
ans = 1
for i in range(k):
    ans *= a_li[i]
for i in range(k,n):
    num = ans // a_li[i-k]
    num *= a_li[i]
    if num > ans:
        print("Yes")
    else:
        print("No")
    ans = num

Fixed submission:
n,k = map(int,input().split())
a_li = list(map(int,input().split()))

for i in range(k,n):
    if a_li[i-k] < a_li[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_li = list(map(int,input().split()))
a_li.sort(reverse=1)
if n == 2:
    print(a_li[0])
if n == 3:
    print(a_li[0]+a_li[1])

m = a_li[0]
l = a_li[1]
r = a_li[2]
ans = 0
ans += a_li[0]+a_li[1]
for i in range(3,n):
    if l < r:
        ans += l
        l = a_li[i]
    else:
        ans += r
        r = a_li[i]
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
b = a+a+b
b.sort(reverse=1)
print(sum(b[2:n])+b[0])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a_li = list(map(int,input().split()))
a_counter = Counter(a_li)
q = int(input())
for i in range(q):
    ans = 0
    a,b = map(int,input().split())
    dum = a_counter[a]
    a_counter[a] = 0
    a_counter[b] += dum
    for j in a_counter:
        ans += j * a_counter[j]
    print(ans)


Fixed submission:
from collections import Counter
n = int(input())
a_li = list(map(int,input().split()))
ans = sum(a_li)
a_counter = Counter(a_li)
q = int(input())
for i in range(q):
    a,b = map(int,input().split())
    dum = a_counter[a]
    ans -= dum*a
    ans += dum*b
    a_counter[a] = 0
    a_counter[b] += dum
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a_li = list(map(int,input().split()))
a_counter = Counter(a_li)
q = int(input())
for i in range(q):
    ans = 0
    a,b = map(int,input().split())
    dum = a_counter[a]
    a_counter[a] = 0
    a_counter[b] += dum
    for j in a_counter:
        ans += j * a_counter[j]
    print(ans)


Fixed submission:
from collections import Counter
n = int(input())
a_li = list(map(int,input().split()))
ans = sum(a_li)
a_counter = Counter(a_li)
q = int(input())
for i in range(q):
    a,b = map(int,input().split())
    dum = a_counter[a]
    ans -= dum*a
    ans += dum*b
    a_counter[a] = 0
    a_counter[b] += dum
    print(ans)
Buggy python submission (verdict: Runtime Error):
check

Fixed submission:
n,k_ = map(int,input().split())
a_li = list(map(int,input().split()))
a_li_o = [0]*n
for i in range(k_):
    for l in range(n):
        a_li_o[l] = a_li[l]
    dum_li = [0]*n
    for j in range(n):
        left = j - a_li[j]
        right = j + a_li[j] + 1
        if left < 0:
            left = 0
        dum_li[left] += 1
        if right > n-1:
            continue
        dum_li[right] -= 1
    total = 0
    for k in range(n):
        total += dum_li[k]
        dum_li[k] = total
    for k in range(n):
        a_li[k] = dum_li[k]
    if a_li_o == a_li:
        break
print(" ".join(map(str,a_li)))
Buggy python submission (verdict: Runtime Error):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
dum = prime_factorize(int(input()))
print(dum)
print(len(dum))
dum1 = 0
ans = 0
for i in range(len(dum)):
    if dum[i] == dum[i+1]:
        cnt += 1
    else:
        dum1 = 0
        cnt = 0
    if cnt > dum1:
        ans += 1
        cnt = 0
        dum1 += 1
print(ans)

Fixed submission:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
dum = prime_factorize(int(input()))
dum_len = len(dum)

num = 0
ans = 0
cnt = 0
check = 0
for i in range(dum_len):
    if num == dum[i]:
        cnt += 1
        if cnt >= check:
            check += 1
            ans += 1
            cnt = 0
    else:
        num = dum[i]
        ans += 1
        cnt = 0
        check = 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_len = len(s)
ans = ""
for i in range(s_len):
    if s[i] == "?":
        ans += "D"
    else:
        ans += s[i]
print(ans)

Fixed submission:
s = input()
s_len = len(s)
li = [0]*s_len
for i in range(s_len):
    if s[i] == "?":
        li[i] = "D"
    else:
        li[i] = s[i]
print("".join(li))
Buggy python submission (verdict: Runtime Error):
import math
a,b,n = map(int,input().split())
ans = 0
baketu = [0]*(n+1)
for i in range(1,n+1):
    dum = math.floor(a*i/b)-(a*math.floor(i/b))
    if baketu[dum] >= 1:
        break
    baketu[dum] += 1
    ans = max(ans,dum)
print(ans)

Fixed submission:
import math
a,b,n = map(int,input().split())
if b-1 <= n:
    print(math.floor((a*(b-1))/b)-(a*math.floor((b-1)/b)))
else:
    print(math.floor((a * (n)) / b) - (a * math.floor((n) / b)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = map(int,input().split())
ans = 0
for i in range(1,n+1):
    dum = math.floor(a*i/b)-(a*math.floor(i/b))
    if dum < ans:
        break
    ans = dum
print(ans)

Fixed submission:
import math
a,b,n = map(int,input().split())
if b-1 <= n:
    print(math.floor((a*(b-1))/b)-(a*math.floor((b-1)/b)))
else:
    print(math.floor((a * (n)) / b) - (a * math.floor((n) / b)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = map(int,input().split())
ans = 0
start =  b // a
count = 0
check = start % b
count = 0
for i in range(start,n+1):
    dum1 = (a * i / b) // 1
    dum2 = a * ((i / b)//1)
    dum3 = dum1 - dum2
    #print(dum1,dum2)
    ans = max(ans,dum3)
    if i % b == check and count != 0:
        break
    count += 1
print(math.ceil(ans))

Fixed submission:
import math
a,b,n = map(int,input().split())
if b-1 <= n:
    print(math.floor((a*(b-1))/b)-(a*math.floor((b-1)/b)))
else:
    print(math.floor((a * (n)) / b) - (a * math.floor((n) / b)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = map(int,input().split())
ans = 0
start =  b // a
for i in range(start,n+1):
    dum1 = (a * i / b) // 1
    dum2 = a * ((i / b)//1)
    dum3 = dum1 - dum2
    #print(dum1,dum2)
    ans = max(ans,dum3)
print(math.ceil(ans))

Fixed submission:
import math
a,b,n = map(int,input().split())
if b-1 <= n:
    print(math.floor((a*(b-1))/b)-(a*math.floor((b-1)/b)))
else:
    print(math.floor((a * (n)) / b) - (a * math.floor((n) / b)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    if s[i] != s[j]:  
      for k in range(j+1,n):
        #print(s[i],s[j],s[k])
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i] and j-i != k-j:
          #print(i,j,k)
          count += 1
          #print(s[i],s[j],s[k])
print(count)

Fixed submission:
n = int(input())
s = input()
ans = s.count("R")
ans *= s.count("G")
ans *= s.count("B")
for i in range(n):
    for d in range(n):
        j = i+d
        k = j+d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      #print(s[i],s[j],s[k])
      if s[i] != s[j] and s[j] != s[k] and s[k] != s[i] and j-i != k-j:
        #print(i,j,k)
        count += 1
        #print(s[i],s[j],s[k])
print(count)

Fixed submission:
n = int(input())
s = input()
ans = s.count("R")
ans *= s.count("G")
ans *= s.count("B")
for i in range(n):
    for d in range(n):
        j = i+d
        k = j+d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
a_list = list(map(int,input().split()))
same = 0
for a,b in combinations(a_list,2):
    if a == b:
        same += 1
for i in range(n):
    print(same - a_list.count(a_list[i])+1)

Fixed submission:
from collections import Counter
n = int(input())
num_list = list(map(int,input().split()))
a = Counter(num_list)
count = 0
for i in a.values():
  count += (i*(i-1))//2
for j in num_list:
  print(count-(a[j]-1))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
a_list = list(map(int,input().split()))
same = 0
for a,b in combinations(a_list,2):
    if a == b:
        same += 1
for i in range(n):
    print(same - a_list.count(a_list[i])+1)

Fixed submission:
from collections import Counter
n = int(input())
num_list = list(map(int,input().split()))
a = Counter(num_list)
count = 0
for i in a.values():
  count += (i*(i-1))//2
for j in num_list:
  print(count-(a[j]-1))

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
num_list = list(map(int,input().split()))
a = Counter(num_list)
count = 0
for i in a.values():
  count += (i*(i-1))//2
for j in num_list:


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




Fixed submission:
mlist = 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])
b = int(input())
print(mlist[b-1])

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




Fixed submission:
mlist = 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])
b = int(input())
print(mlist[b-1])

Buggy python submission (verdict: Runtime Error):
import math
import decimal

num = decimal.Decimal(0)
a, b, c = map(int, input().split())
#a = decimal.Decimal(a)
#b = decimal.Decimal(b)
#c = decimal.Decimal(c)
ab =  decimal.Decimal(a) + decimal.Decimal(b) + decimal.Decimal(2 * (math.sqrt(a*b)))
#num = a + b + ab
if ab < c:
  print("Yes")
else:
  print("No")



Fixed submission:
mlist = 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])
b = int(input())
print(mlist[b-1])
Buggy python submission (verdict: Runtime Error):
import Decimal
a, b, c = list(map(int,input().split()))
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")


Fixed submission:
from decimal import Decimal
a, b, c = list(map(int,input().split()))
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
temp = input()
s = ["tikan"]
flag = "off"
q = int(input())
dummy = ""
for i in range(q):
  q_list = input().split()
  if q_list[0] == "1":
    if flag == "on":
      flag = "off"
    else:
      flag = "on"
  else:
    if q_list[1] == "1":
      if flag == "off":
        s.insert(0,q_list[2])
      else:
        s.append(q_list[2])
    else:
      if flag == "off":
        s.append(q_list[2])
      else:
        s.insert(0,q_list[2])
#  print(s)
ans = ""
for i in s:
  if i == "tikan":
    i = temp
    if flag == "on":
      i = list(i)
      i.reverse()
      i = "".join(i)
  ans += i
if flag == "on":
  ans = list(ans)
  ans.reverse()
  ans = "".join(ans)
print(ans)v

Fixed submission:
s = input()
q = int(input())
turn = 1
start = []
end = []
for i in range(q):
    q_list = list(input().split())
    if q_list[0] == "1":
        turn *= -1
    else:
        if q_list[1] == "1":
            if turn == 1:
                start.append(q_list[2])
            else:
                end.append(q_list[2])
        else:
            if turn == -1:
                start.append(q_list[2])
            else:
                end.append(q_list[2])

dum1 = "".join(start)
dum2 = "".join(end)
if turn == 1:
    print(dum1[::-1]+s+dum2)
else:
    print(dum2[::-1] + s[::-1] + dum1)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
dummy = ""
for i in range(q):
  q_list = input().split()
  if q_list[0] == "1":
    s.reverse()
  else:
    if q_list[1] == "1":
      s.insert(0,q_list[2])
    else:
      s.append(q_list[2])
print("".join(s))

Fixed submission:
s = input()
q = int(input())
turn = 1
start = []
end = []
for i in range(q):
    q_list = list(input().split())
    if q_list[0] == "1":
        turn *= -1
    else:
        if q_list[1] == "1":
            if turn == 1:
                start.append(q_list[2])
            else:
                end.append(q_list[2])
        else:
            if turn == -1:
                start.append(q_list[2])
            else:
                end.append(q_list[2])

dum1 = "".join(start)
dum2 = "".join(end)
if turn == 1:
    print(dum1[::-1]+s+dum2)
else:
    print(dum2[::-1] + s[::-1] + dum1)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
if b / a == 1 and c / a == 1:
  print("No")
else:
  print("Yes)

Fixed submission:
a,b,c = map(int, input().split())
count = 0
if a == b:
  count = count + 1
if b == c:
  count = count + 1
if c == a:
  count = count + 1
if count != 1:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
flag = “ok”
for i in a_list:
  if i%2 == 0: 
    if i%3 != 0 or i%5 != 0:
      flag = “ng”
if flag == “ok”
  print(“APPROVED”) 
else:
  print(“ DENIED”)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
flag = "ok"
for i in a_list:
  #print(i)
  if i%2 == 0: 
    if i%3 != 0 and i%5 != 0:
      flag = "ng"
if flag == "ok":
  print("APPROVED") 
else:
  print("DENIED")
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
for i in range(n-k+1):
    dum = 0
    for j in range(k):
        dum += p_list[i+j]
    if dum > ans:
        save = i
        ans = dum
for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)

Fixed submission:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))
ans = 0
save = 0
sum = 0
ans_o = 0
ans_check = 0
for j in range(k):
    ans_check += p_list[0 + j]
    ans_o += p_list[0 + j]
for i in range(1,n-k+1):
    ans = ans_o-p_list[i-1]+p_list[i+k-1]
#    print(ans)
    if ans > ans_check:
        save = i
        ans_check = ans
    ans_o = ans
    #print(save)

for i in range(save,save+k):
    sum += p_list[i]*0.5 + 0.5
print(sum)