Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
　a.append(a[i] + A[i])
for i in range(M):
　b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
　if a[i] > K:
　　break
　while b[j] > K - a[i]:
　　j -= 1
　ans = max(ans, i + j)
print(ans)


Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Runtime Error):
r = int(input())
pritn(3*r**2)

Fixed submission:
r = int(input())
print(3*r**2)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a =< k:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a <= k:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = 0
while True:
  if "10" in s:
    k += s.count("10")*2
    s = s.replace("10","")
  elif "01" in s:
    k += s.count("01")*2
    s = s.replace("01","")
  else:
    print(k)
    break

Fixed submission:
s = input()
print(min(s.count("0"), s.count("1"))*2)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = 0
while True:
  if "10" in s:
    i = s.index("10")
    s = list(s)
    s.pop(i)
    s.pop(i)
    s = "".join(s)
    k += 2
  elif "01" in s:
    i = s.index("01")
    s = list(s)
    s.pop(i)
    s.pop(i)
    s = "".join(s)
    k += 2
  else:
    print(k)
    break

Fixed submission:
s = input()
print(min(s.count("0"), s.count("1"))*2)

Buggy python submission (verdict: Runtime Error):
s = input()
k = 0
while True:
  if "10" in s:
    i = s.index("10")
    s = list(s)
    s.pop(i)
    s.pop(i)
    s = "".join(s)
    k += 2
  elif "01" in s:
    i = s.index("10")
    s = list(s)
    s.pop(i)
    s.pop(i)
    s = "".join(s)
    k += 2
  else:
    print(k)
    break

Fixed submission:
s = input()
print(min(s.count("0"), s.count("1"))*2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 0:
    return b
  else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c or c == 0:
      c = c_
print(c)


Fixed submission:
a,b = list(map(int,input().split()))
if b%a == 0:
  print(a+b)
else:
  print(b-a)

Buggy python submission (verdict: Runtime Error):
n,m = list(map(int,input().split()))
b = [0 for i in range(m)]
for i in range(n):
  ka = list(map(int,input().split()))
  k = ka[0]
  a = ka[1:]
  for j in range(k):
    b[a[j]-1] += 1
c = 0
for i in range(m):
  if b[i] == n:
    c += 1
print(c)


Fixed submission:
a,b = list(map(int,input().split()))
if b%a == 0:
  print(a+b)
else:
  print(b-a)

Buggy python submission (verdict: Runtime Error):
a,b = list(map(int,input().split()))
if b%a = 0:
  print(a+b)
else:
  print(a-b)

Fixed submission:
a,b = list(map(int,input().split()))
if b%a == 0:
  print(a+b)
else:
  print(b-a)
Buggy python submission (verdict: Runtime Error):
n,m = list(map(int,input().split()))
b = [0 for i in range(m)]
for i in range(n):
  ka = list(map(int,input().split()))
  k = ka[0]
  a = ka[1:]
  for j in range(k):
    b[a[j]-1] += 1
c = 0
for i in range(n):
  if b[i] == 10:
    c += 1
print(c)

Fixed submission:
n,m = list(map(int,input().split()))
b = [0 for i in range(m)]
for i in range(n):
  ka = list(map(int,input().split()))
  k = ka[0]
  a = ka[1:]
  for j in range(k):
    b[a[j]-1] += 1
c = 0
for i in range(m):
  if b[i] == n:
    c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 0:
    return b
  0else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c or c == 0:
      c = c_
print(c)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 0:
    return b
  else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c or c == 0:
      c = c_
print(c)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 1:
    return b
  else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c:
      c = c_
print(c)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
def gcd(a,b):
  c = a%b
  if c == 0:
    return b
  else:
    return gcd(b,c)
c = 0
for i in a[1:]:
  c_ = gcd(i,a[0])
  if c_ == 1:
    c = 1
    break
  else:
    if c_ < c or c == 0:
      c = c_
print(c)
Buggy python submission (verdict: Runtime Error):
a = []
b = []
c = [0,0,0,0]
for i in range(3):
  ab = list(map(int,input().split()))
  a.append(ab[0])
  b.append(ab[1])
  c[ab[0]] += 1
  c[ab[1]] += 1
k = c.index(1)
for i in range(3):
  if k in a:
    j = a.index(k)
    k = b[j]
  else:
    print("NO")
    break
else:
  print("YES")

Fixed submission:
a = []
b = []
c = [0,0,0,0]
for i in range(3):
  ab = list(map(int,input().split()))
  a.append(ab[0])
  b.append(ab[1])
  a.append(ab[1])
  b.append(ab[0])
  c[ab[0]-1] += 1
  c[ab[1]-1] += 1
k = c.index(1)+1
for i in range(3):
  if k in a:
    j = a.index(k)
    k = b[j]
    a.pop(j)
    a.pop(j+-1*(j%2))
    b.pop(j)
    b.pop(j+-1*(j%2))
  else:
    print("NO")
    break
else:
  print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
c = 0
for i in range(n):
  for j in range(n-i-1):
    if s[j] == "B" and s[j+1] == "W":
      s[j] = "W"
      s[j+1] = "B"
      c +=1
print(c)

Fixed submission:
s = list(input())
n = len(s)
i = []
for j in range(n):
  if s[j] == "W":
    i.append(j)
c = 0
for k in range(len(i)):
  c += i[k]-k
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
c = 0
while True:
  k = 0
  can = False
  for i in range(n-1):
    if k < n-1:
      if s[k] == "B" and s[k+1] == "W":
        s[k] = "W"
        s[k+1] = "B"
        can = True
        c += 1
        k += 2
      else:
        k += 1
  if not can:
    print(c)
    break

Fixed submission:
s = list(input())
n = len(s)
i = []
for j in range(n):
  if s[j] == "W":
    i.append(j)
c = 0
for k in range(len(i)):
  c += i[k]-k
print(c)
Buggy python submission (verdict: Runtime Error):
N,T = list(map(int, input().split()))
max = 10000
for i in range(N):
    c,t = list(map(int, input().split()))
    if t <= T and c < max:
        max = c
if max == 10000:
    print("TLE")
else:
    print(max)

Fixed submission:
n = input()
if n == "1":
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy python submission (verdict: Runtime Error):
n = input()
if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

Fixed submission:
n = input()
if n == "1":
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)
Buggy python submission (verdict: Runtime Error):
n = input()
n = n.replace("1","a")
n = n.replace("9","1")
n = n.replace("a,"9")
print(n)

Fixed submission:
n = input()
n = n.replace("1","a")
n = n.replace("9","1")
n = n.replace("a","9")
print(n)
Buggy python submission (verdict: Runtime Error):
abc = list(map(int, input().split()))
abc = sort(abc)
abc = abc[:,:,-1]
print(abc[0]*10+abc[1]+abc[2])

Fixed submission:
abc = list(map(int, input().split()))
abc = sorted(abc)
print(abc[2]*10+abc[1]+abc[0])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a2 = []
for i in range(n):
    a2.append(a[i]-i-1)
a3 = []
for i in range(n):
    m = min(a2)
    a3.append(m)
    a2.remove(m)
if n % 2 == 0:
    b = (a3[n//2-1]+a3[n//2])//2
else:
    b = a3[n//2]
s = 0
for i in a3:
    s += abs(i-b)
print(s)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a2 = []
mi = 0
for i in range(n):
    a2.append(a[i]-i-1)
a3 = sorted(a2)
if n % 2 == 0:
    b = (a3[n//2-1]+a3[n//2])//2
else:
    b = a3[n//2]
s = 0
for i in a3:
    s += abs(i-b)
print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(n):
  while a[i] % 2 == 0:
    count += 1
    a[i] /= 2
print(count)

Fixed submission:
a,b = list(map(int, input().split()))
if max(a,b) > 8:
  print(":(")
else:
  print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  if a[i] % 2 == 0:
    b.append(a[i])
a = b
count = 0
while True:
  if len(a) == 0:
    break
  i = a.index(max(a))
  a[i] /= 2
  count += 1
  if a[i] % 2 == 1:
    a.remove(a[i])
print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(n):
  while a[i] % 2 == 0:
    count += 1
    a[i] = a[i]//2
print(count)
Buggy python submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))
k = int(input())
m = max(a,b,c)
l = m
for i in range(k):
    l *= 2
print(sum([a,b,c].remove(m))+l)

Fixed submission:
a,b,c = list(map(int, input().split()))
k = int(input())
m = max(a,b,c)
l = m
for i in range(k):
    l *= 2
print(sum([a,b,c])-m+l)
Buggy python submission (verdict: Runtime Error):
S = input()
if “a” in S and “b” in S and “c” in S:
    print(“Yes”)
else:
    print(“No”)


Fixed submission:
s = input()
if "a" in s and "b" in s and "c" in s:
	print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
S = input()
If “a” in S and “b” in S and “c” in S:
    print(“Yes”)
else:
    print(“No”)

Fixed submission:
s = input()
if "a" in s and "b" in s and "c" in s:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
blue = []
plus = [0]*n
for i in range(n):
    s = input()
    if s in blue:
        plus[blue.index(s)] += 1
    else:
        blue.append(s)
        plus[blue.index(s)] += 1
m = int(input())
for i in range(m):
    s = input()
    if s in blue:
        plus[blue.index(s)] -= 1
    else:
        blue.append(s)
        plus[blue.index(s)] -= 1
print(max(0, max(plus)))

Fixed submission:
#coding:utf-8
n = int(input())
blue = []
plus = []
for i in range(n):
    s = input()
    if s in blue:
        plus[blue.index(s)] += 1
    else:
        blue.append(s)
        plus.append(1)
m = int(input())
for i in range(m):
    s = input()
    if s in blue:
        plus[blue.index(s)] -= 1
    else:
        blue.append(s)
        plus.append(-1)
print(max(0, max(plus)))

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
blue = []
plus = [0]*n
for i in range(n):
    s = input()
    if s in blue:
        plus[blue.index(s)] += 1
    else:
        blue.append(s)
m = int(input())
for i in range(m):
    s = input()
    if s in blue:
        plus[blue.index(s)] -= 1
print(plus.max())

Fixed submission:
#coding:utf-8
n = int(input())
blue = []
plus = []
for i in range(n):
    s = input()
    if s in blue:
        plus[blue.index(s)] += 1
    else:
        blue.append(s)
        plus.append(1)
m = int(input())
for i in range(m):
    s = input()
    if s in blue:
        plus[blue.index(s)] -= 1
    else:
        blue.append(s)
        plus.append(-1)
print(max(0, max(plus)))
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
n, m = list(map(int, input().split()))
count = 0
for i in range(n):
    for j in range(m):
        around = 0
        for w in range(-1, 2):
            for h in range(-1, 2):
                if i+w >= 0 and i+w < n and j+h >= 0 and j+h < m:
                    around += 1
        if around % 2 == 1:
            count += 1
print(count)

Fixed submission:
#coding:utf-8
n, m = list(map(int, input().split()))
count = 0
if n == 1 and m == 1:
    print("1")
elif n == 1 or m == 1:
    print(n*m-2)
else:
    print((n-2)*(m-2))
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
num = len(str(n))
tmp = pow(10, num)-1
s = 0
for i in range(num+1):
    if i == num:
        s = sum(list(map(int, str(tmp-9*pow(10, num-1)+(int(str(n)[0])-1)*pow(10, num-1)))))
        break
    elif tmp-pow(10, i) <= n:
        s = sum(list(map(int, str(tmp-pow(10, i)))))
        break
if sum(list(map(int, str(n)))) > s:
    print(sum(list(map(int. str(n)))))
else:
    print(s)

Fixed submission:
#coding:utf-8
n = int(input())
num = len(str(n))
tmp = pow(10, num)-1
s = 0
for i in range(num+1):
    if i == num:
        s = sum(list(map(int, str(tmp-9*pow(10, num-1)+(int(str(n)[0])-1)*pow(10, num-1)))))
        break
    elif tmp-pow(10, i) <= n:
        s = sum(list(map(int, str(tmp-pow(10, i)))))
        break
if sum(list(map(int, str(n)))) > s:
    print(sum(list(map(int, str(n)))))
else:
    print(s)

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
num = len(str(n))
tmp = pow(10, num)-1
s = 0
for i in range(num+1):
    if i == num:
        s = sum(list(map(int, str(tmp-9*pow(10, num-1)+(int(str(n)[0])-1)*pow(10, num-1)))))
        break
    elif tmp-pow(10, i) <= n:
        s = sum(list(map(int, str(tmp-pow(10, i)))))
        break
if sum(list(map(int. str(n)))) > s:
    print(sum(list(map(int. str(n)))))
else:
    print(s)

Fixed submission:
#coding:utf-8
n = int(input())
num = len(str(n))
tmp = pow(10, num)-1
s = 0
for i in range(num+1):
    if i == num:
        s = sum(list(map(int, str(tmp-9*pow(10, num-1)+(int(str(n)[0])-1)*pow(10, num-1)))))
        break
    elif tmp-pow(10, i) <= n:
        s = sum(list(map(int, str(tmp-pow(10, i)))))
        break
if sum(list(map(int, str(n)))) > s:
    print(sum(list(map(int, str(n)))))
else:
    print(s)

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
num = len(str(n))
tmp = pow(10, num)-1
s = 0
for i in range(num+1):
    if i == num:
        s = sum(list(map(int, str(tmp-9*pow(10, num-1)+(int(str(n)[0])-1)*pow(10, num-1)))))
        break
    elif tmp-pow(10, i) <= n:
        s = sum(list(map(int, str(tmp-pow(10, i)))))
        break
if sum(list(map(int. str(n)))) > s:
    print(sum(list(map(int. str(n)))))
else:
    print(s)

Fixed submission:
#coding:utf-8
n = int(input())
num = len(str(n))
tmp = pow(10, num)-1
s = 0
for i in range(num+1):
    if i == num:
        s = sum(list(map(int, str(tmp-9*pow(10, num-1)+(int(str(n)[0])-1)*pow(10, num-1)))))
        break
    elif tmp-pow(10, i) <= n:
        s = sum(list(map(int, str(tmp-pow(10, i)))))
        break
if sum(list(map(int, str(n)))) > s:
    print(sum(list(map(int, str(n)))))
else:
    print(s)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import numpy as np

white = "."
black = "#"
w, h = list(map(int, input().split()))
map = np.zeros([w, h])
s = []
for i in range(h):
    try:
        while True:
            s.append(input())
    except EOFError:
        pass
for i in range(h):
    for j in range(w):
        if s[j] == white:
            map[j, i] += 1
can = False
for i in range(w):
    sm1 = np.sum(map[0:i+1, 0])
    for j in range(w-i):
        sm2 = 0
        if(j > 0):
            sm2 += np.sum(map[i+1:i+1+j, 1])-1
        if(i+j+1 < w-1):
            sm2 += np.sum(map[i+1+j:w, 2])-1
        if sm1+sm2 == w+h-1:
            can = True
if can == True:
    mx = int(np.sum(map)-(w+h-1))
    print(mx)
else:
    print("-1")

Fixed submission:
#coding:utf-8
n = int(input())
a = int(input())
if n%500 <= a:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import numpy as np
c = []
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c = np.array(c)
if np.sum(c)/3 == c[0]+c[4]+c[8]:
    print("Yes")
else:
    print("No")

Fixed submission:
#coding:utf-8
n = int(input())
a = int(input())
if n%500 <= a:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import numpy as np
c = np.array(list(map(int, input().split())))
if np.sum(c)/3 == c[0]+c[4]+c[8]:
    print("Yes")
else:
    print("No")

Fixed submission:
#coding:utf-8
n = int(input())
a = int(input())
if n%500 <= a:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
d = defaultdict(list)
n = int(input())
for i in range(n):
    city, point = input().split()
    d[city].append((int(point), i))

d2 = sorted(d.items())
for i in range(len(d2)):
    sorted(d2[i][1])
    for j in range(len(d2[i])):
        print(d2[i][1][j][1] + 1)



Fixed submission:
from collections import defaultdict
d = defaultdict(list)
n = int(input())
for i in range(n):
    city, point = input().split()
    d[city].append((int(point), i+1))

d2 = sorted(d.items())
for i in range(len(d2)):
    d2[i] = list(d2[i])
    d2[i][1] = sorted((d2[i][1]), reverse = True)
    for j in range(len(d2[i][1])):
        print(d2[i][1][j][1])
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
count = 0
for i in range(A, B+1):
    count += (str(i) == str(i)[::-1])
print(count)

Fixed submission:
A,B=map(int,input().split())
count = 0
for i in range(A, B+1):
    count += (str(i) == str(i)[::-1])
print(count)
Buggy python submission (verdict: Runtime Error):
S = input()
S = sorted(S)
i = 0
if S[0] != "a":
    print("a")
    exit(1)
while i<len(S)-1:
    if ord(S[i]) == ord(S[i+1]) or ord(S[i]) == ord(S[i+1])-1:
        i += 1
    else:
        print(chr(ord(S[i])+1))
        exit(0)

if S[-1] == "z":
    print("None")
else:
    print(chr(ord(S[i])+1))

Fixed submission:
S = input()
S = sorted(S)
i = 0
if S[0] != "a":
    print("a")
    exit(0)
while i<len(S)-1:
    if ord(S[i]) == ord(S[i+1]) or ord(S[i]) == ord(S[i+1])-1:
        i += 1
    else:
        print(chr(ord(S[i])+1))
        exit(0)

if S[-1] == "z":
    print("None")
else:
    print(chr(ord(S[i])+1))
Buggy python submission (verdict: Runtime Error):
n = int(input())

for i in range(1, n+1):
    if i%3==0 or i%5==0:
        sum += i
print(sum)

Fixed submission:
n = int(input())

sum = 0
for i in range(1, n+1):
    if not(i%3==0 or i%5==0):
        sum += i
print(sum)
Buggy python submission (verdict: Runtime Error):
import math

a, b, c = input().split()
a = math.sqrt(int(a))
b = math.sqrt(int(b))
c = math.sqrt(int(c))
d = a + b - c

if d < 0:
    if math.isclose(d, 0.0):
        print('No')
    else:
        print('Yes')
else:
    print('No')


Fixed submission:
from decimal import Decimal

a, b, c = input().split()
a = Decimal(int(a)).sqrt()
b = Decimal(int(b)).sqrt()
c = Decimal(int(c)).sqrt()

d = a + b

if d < c:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n, a, b = input().split()
 
d = n // (a + b)
m = n % (a + b)
 
blue = a * d
if m >= a:
  blue = blue + a
else:
  blue = blue + m
  
print(blue)

Fixed submission:
n, a, b = input().split()
n = int(n)
a = int(a)
b = int(b)
 
d = n // (a + b)
m = n % (a + b)
 
blue = a * d
if m >= a:
  blue = blue + a
else:
  blue = blue + m
  
print(blue)

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

n, a, b = input().split()

d = n // (a + b)
m = n % (a + b)

blue = a * k
if m >= a:
  blue = blue + a
else:
  blue = blue + m
  
print(blue)


Fixed submission:
n, a, b = input().split()
n = int(n)
a = int(a)
b = int(b)
 
d = n // (a + b)
m = n % (a + b)
 
blue = a * d
if m >= a:
  blue = blue + a
else:
  blue = blue + m
  
print(blue)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

reverse = 0

for i in range(q):
    inp = input()
    if len(inp) <= 1:
        reverse += 1
    else:
        dmy, f, c = inp.split()
        f = int(f)
        if reverse & 1:
            if f == 1:
                s = s + c
            else:
                s = c + s
        else:
            if f == 1:
                s = c + s
            else:
                s = s + c

if reverse & 1:
    print(s[::-1])
else:
    print(s)



Fixed submission:
s = input()
q = int(input())

reverse = 0
sento = ''
matsubi = ''

for i in range(q):
    inp = input()
    if len(inp) <= 1:
        reverse += 1
    else:
        dmy, f, c = inp.split()
        f = int(f)
        if reverse & 1:
            if f == 1:
                matsubi = matsubi + c
            else:
                sento = c + sento
        else:
            if f == 1:
                sento = c + sento
            else:
                matsubi = matsubi + c

s = sento + s + matsubi

if reverse & 1:
    print(s[::-1])
else:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q):
    inp = input()
    o = int(inp.split()[0])
    if o == 1: 
        s = s[::-1]
    else:
        dmy, f, c = inp.split()
        f = int(f)
        if f == 1:
            s = c + s
        else:
            s = s + c

print(s)


Fixed submission:
s = input()
q = int(input())

reverse = 0
sento = ''
matsubi = ''

for i in range(q):
    inp = input()
    if len(inp) <= 1:
        reverse += 1
    else:
        dmy, f, c = inp.split()
        f = int(f)
        if reverse & 1:
            if f == 1:
                matsubi = matsubi + c
            else:
                sento = c + sento
        else:
            if f == 1:
                sento = c + sento
            else:
                matsubi = matsubi + c

s = sento + s + matsubi

if reverse & 1:
    print(s[::-1])
else:
    print(s)
Buggy python submission (verdict: Runtime Error):
import math
n = []
n = int(input().split())

def caldis(x, y):
    l = math.sqrt(x ** 2 + y ** 2)
    return l

ans = 0


for i in n[0]:
    input_num = []
    input_num = int(input().split())

    if caldis(input_num[0], input_num[1]) <= n[1]:
        ans += 1

print(ans)

Fixed submission:
import math
a = list(map(int,input().split()))
xy = [map(int, input().split()) for _ in range(a[0])]
x, y = [list(i) for i in zip(*xy)]


def caldis(x, y):
    l = math.sqrt(x ** 2 + y ** 2)
    return l

ans = 0

i = 0
for i in range(a[0]):

    if caldis(x[i], y[i]) <= a[1]:
        ans += 1
    i += 1

print(ans)