Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

before=k
roop=1
cnt={}
nxt=1
mp = []
for i in range(1, k+1):
    mp.append(nxt)
    if nxt not in cnt:
        cnt[nxt] = i
        nxt = a[nxt]
    else:
        roop = i - cnt[nxt]
        before = cnt[nxt]-1
        break
print(mp[before + (k-before)%roop])

Fixed submission:
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

before=k
roop=1
cnt={}
nxt=1
mp = [1]
for i in range(1, k+1):
    if nxt not in cnt:
        cnt[nxt] = i
        nxt = a[nxt]
    else:
        roop = i - cnt[nxt]
        before = cnt[nxt]-1
        break
    mp.append(nxt)
print(mp[before + (k-before)%roop])

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

before=0
roop=0
cnt={}
nxt=1
mp = []
for i in range(1, k+1):
    mp.append(nxt)
    if nxt not in cnt:
        cnt[nxt] = i
        nxt = a[nxt]
    else:
        roop = i - cnt[nxt]
        before = cnt[nxt]-1
        break
    roop=0
if roop == 0:
    print(mp[k])
    exit()
print(mp[before + (k-before)%roop])

Fixed submission:
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

before=k
roop=1
cnt={}
nxt=1
mp = [1]
for i in range(1, k+1):
    if nxt not in cnt:
        cnt[nxt] = i
        nxt = a[nxt]
    else:
        roop = i - cnt[nxt]
        before = cnt[nxt]-1
        break
    mp.append(nxt)
print(mp[before + (k-before)%roop])

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

before=0
roop=0
cnt={}
nxt=1
mp = []
for i in range(1, k+1):
    mp.append(nxt)
    if nxt not in cnt:
        cnt[nxt] = i
        nxt = a[nxt]
    else:
        roop = i - cnt[nxt]
        before = cnt[nxt]-1
        break
    roop=0
    before=0

print(mp[before + (k-before)%roop])

Fixed submission:
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

before=k
roop=1
cnt={}
nxt=1
mp = [1]
for i in range(1, k+1):
    if nxt not in cnt:
        cnt[nxt] = i
        nxt = a[nxt]
    else:
        roop = i - cnt[nxt]
        before = cnt[nxt]-1
        break
    mp.append(nxt)
print(mp[before + (k-before)%roop])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
n,m,q=map(int,input().split())
a=[0] * q
b=[0] * q
c=[0] * q
d=[0] * q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
AA = [0] * n + [1] * (m-1)
A = [0] * n
ans=0
for i in permutations(AA):
    j=1
    p=0
    for k in i:
        if k==0:
            A[p]=j
            p+=1
        elif k==1:
            j+=1
        if p==n:
            break
    point =0
    for k in range(q):

        if A[b[k]-1] - A[a[k]-1] == c[k]:
            point += d[k]
    ans = max(ans, point)
print(ans)



Fixed submission:
from itertools import combinations_with_replacement as cwr
n,m,q=map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(q)]

def calscore(A):
    score = 0
    for a,b,c,d in abcd:
        if A[b-1] -A[a-1] ==c:
            score += d
    return score

ans =0
for A in cwr(range(1,m+1),n):
    ans = max(ans, calscore(A))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
n,m,q=map(int,input().split())
a=[0] * q
b=[0] * q
c=[0] * q
d=[0] * q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
AA = [0] * n + [1] * (m-1)
A = [0] * n
ans=0
for i in permutations(AA):
    j=1
    p=0
    for k in i:
        if k==0:
            A[p]=j
            p+=1
        elif k==1:
            j+=1
        if p==n:
            break
    point =0
    for k in range(q):

        if A[b[k]-1] - A[a[k]-1] == c[k]:
            point += d[k]
    ans = max(ans, point)
print(ans)



Fixed submission:
from itertools import combinations_with_replacement as cwr
n,m,q=map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(q)]

def calscore(A):
    score = 0
    for a,b,c,d in abcd:
        if A[b-1] -A[a-1] ==c:
            score += d
    return score

ans =0
for A in cwr(range(1,m+1),n):
    ans = max(ans, calscore(A))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import floor
a,b,n = map(int,input().split())
ans=0
for i in range(n+1):
    ans = max(ans, floor(a*i/b)-a*floor(i/b))
print(ans)

Fixed submission:
from math import floor
a,b,n = map(int,input().split())
x=min(b-1,n)
print(floor(a*x/b)-a*floor(x/b))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            if s[i]==s[j] or s[j]==s[k] or s[k]==s[i]:
                continue
            if j-i == k-j :
                continue
            ans+=1
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=0
cnt={}
cnt["R"]=0
cnt["G"]=0
cnt["B"]=0
for i in s:
    cnt[i]+=1
ans = cnt["R"] * cnt["G"] * cnt["B"]
for i in range(n-2):
    for gap in range(1,(n-i+1)//2):
        if s[i] != s[i+gap] and s[i+2*gap] != s[i+gap] and s[i+2*gap] != s[i]:
            ans-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)

def tami(i,j,k):
  if (i == j == k == 0):
    return 0
  else:
    res = 0
    if (i > 0):
      res += dp[i-1][j][k] * i
    if (j > 0):
      res += dp[i+1][j-1][k] * j
    if (k > 0):
      res += dp[i][j+1][k-1] * k
    res += N
    res *= (1 / (i + j + k))
    dp[i][j][k] = res
    return res
  
N = int(input())
a = list(map(float,input().split()))

one = a.count(1)
two = a.count(2)
three = a.count(3)

num = max(one,two,three)

dp = [[[-1]*(N+1) for i in range(N+1)] for i in range(N+1)]

for k in range(0, N + 1):
  for j in range(0, N - k + 1):
    for i in range(0, N - k - j + 1):
      tami(i, j, k)

print(dp[one][two][three]+1)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))

m = d = t = 0
for i in range(len(a)):
  if a[i] == 1:
    m += 1
  elif a[i] == 2:
    d += 1
  else:
    t += 1
    
M = t + d + m
D = [[[0] * (M + 1) for i in range(d + t + 1)] for j in range(t + 1)]

su = 0
D[t][d][m] = 1

divTable = [1]
for i in range(1, 10000):
  divTable.append(1.0 / i)


for i in range(t, -1, -1):
  for j in range(d + t - i, -1, -1):
    for k in range(M - i - j, -1, -1):
      y = D[i][j][k]
      if y != 0:
        div = y * divTable[i + j + k]
        if i + j + k != 0:
          su += N * div
        if i >= 1:
          D[i - 1][j + 1][k] += i * div
        if j >= 1: 
          D[i][j - 1][k + 1] += j * div
        if k >= 1:
          D[i][j][k - 1] += k * div

print(su)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)

def tami(i,j,k):
  if (i == j == k == 0):
    return 0
  else:
    res = 0
    if (i > 0):
      res += dp[i-1][j][k] * i
    if (j > 0):
      res += dp[i+1][j-1][k] * j
    if (k > 0):
      res += dp[i][j+1][k-1] * k
    res += N
    res *= (1 / (i + j + k))
    dp[i][j][k] = res
    return res
  
N = int(input())
a = list(map(float,input().split()))

one = a.count(1)
two = a.count(2)
three = a.count(3)

num = max(one,two,three)

dp = [[[-1]*(three+1) for i in range(N+1)] for i in range(N+1)]

for k in range(0, N + 1):
  for j in range(0, N - k + 1):
    for i in range(0, N - k - j + 1):
      tami(i, j, k)

print(dp[one][two][three])


Fixed submission:
N = int(input())
a = list(map(int, input().split()))

m = d = t = 0
for i in range(len(a)):
  if a[i] == 1:
    m += 1
  elif a[i] == 2:
    d += 1
  else:
    t += 1
    
M = t + d + m
D = [[[0] * (M + 1) for i in range(d + t + 1)] for j in range(t + 1)]

su = 0
D[t][d][m] = 1

divTable = [1]
for i in range(1, 10000):
  divTable.append(1.0 / i)


for i in range(t, -1, -1):
  for j in range(d + t - i, -1, -1):
    for k in range(M - i - j, -1, -1):
      y = D[i][j][k]
      if y != 0:
        div = y * divTable[i + j + k]
        if i + j + k != 0:
          su += N * div
        if i >= 1:
          D[i - 1][j + 1][k] += i * div
        if j >= 1: 
          D[i][j - 1][k + 1] += j * div
        if k >= 1:
          D[i][j][k - 1] += k * div

print(su)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
seq = list(map(int, input().split()))
a = 10 ** 9 + 7
res = 0
i = 0
j = 1
for i in range(n - 1):
  b = 0
  for j in range(i + 1, n):
    b += seq[j]
  res += (seq[i] * b) % a
print(res % a)

Fixed submission:
n = int(input())
seq = list(map(int, input().split()))
a = 10 ** 9 + 7
s = sum(seq)
res = 0
for i in range(n - 1):
  s -= seq[i]
  res += (seq[i] * s) % a
print(res % a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
seq = list(map(int, input().split()))
a = 10 ** 9 + 7
res = 0
i = 0
j = 1
for i in range(n - 1):
  for j in range(i + 1, n):
    b = seq[i] * seq[j]
    if a < b:
      res += (seq[i] * seq[j]) % (10 ** 9 + 7)
    else:
      res = res + b - a
print(res % (10 ** 9 + 7))

Fixed submission:
n = int(input())
seq = list(map(int, input().split()))
a = 10 ** 9 + 7
s = sum(seq)
res = 0
for i in range(n - 1):
  s -= seq[i]
  res += (seq[i] * s) % a
print(res % a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
seq = list(map(int, input().split()))
res = 0
i = 0
j = 1
for i in range(n - 1):
  for j in range(i + 1, n):
    res += (seq[i] * seq[j]) % (10 ** 9 + 7)
print(res % (10 ** 9 + 7))

Fixed submission:
n = int(input())
seq = list(map(int, input().split()))
a = 10 ** 9 + 7
s = sum(seq)
res = 0
for i in range(n - 1):
  s -= seq[i]
  res += (seq[i] * s) % a
print(res % a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
seq = list(map(int, input().split()))
res = 0
i = 0
j = 1
for i in range(n - 1):
  for j in range(i + 1, n):
    res += (seq[i] * seq[j])
print(res  % (10 ** 9 + 7))

Fixed submission:
n = int(input())
seq = list(map(int, input().split()))
a = 10 ** 9 + 7
s = sum(seq)
res = 0
for i in range(n - 1):
  s -= seq[i]
  res += (seq[i] * s) % a
print(res % a)
Buggy python submission (verdict: Runtime Error):
numberOfMange= int(input()) % 10

if numberOfMange in [2,4,5,7,9]:
  print('hon')
elif numberOfMange in [0,1,6,8]:
  print('pon')
else numberOfMange:
  print('bon')

Fixed submission:
numberOfMange= int(input()) % 10
 
if numberOfMange in [2,4,5,7,9]:
  print('hon')
elif numberOfMange in [0,1,6,8]:
  print('pon')
else:
  print('bon')
Buggy python submission (verdict: Runtime Error):
import math

a b h m = list(map(int, input().split()))
deg = 30 * h - 6 * m
if deg < 0:
  deg += 360
elif deg > 180:
  deg = 360 - deg

cos = math.cos(math.radian(deg))
c_2 = a * a + b * b - 2 * a * b * cos
print(math.sqrt(c_2))

Fixed submission:
import math

a, b, h, m = list(map(int, input().split()))
deg = 30 * h - 6 * m + 30 * (m / 60.0)
if deg < 0:
  deg += 360
elif deg > 180:
  deg = 360 - deg

cos = math.cos(math.radians(deg))
c_2 = a * a + b * b - 2 * a * b * cos
print(math.sqrt(c_2))
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
if (s == t[0:len(s)] && len(s) + 1 == len(t)):
  print('Yes')
else:
  print('No')

Fixed submission:
s = input()
t = input()
if (s == t[0:len(s)] and len(s) + 1 == len(t)):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
def calc(a, b):
  return a ** 5 - b ** 5

x = int(input())
flag = 0
a = 1
b = 0
while (True):
  while (True):
    if calc(a,b) == x:
      flag = 1
      break
    b -= 1
  if flag == 1:
    break
  a += 1
  b = a - 1
print(a, b)
      

Fixed submission:
def calc(a, b):
  return a ** 5 - b ** 5

x = int(input())
even = 0
if x % 2 == 0:
  even = 1
flag = 0
if even:
  a = 2
else:
  a = 1
b = 0
while (True):
  while (True):
    if calc(a,b) == x:
      flag = 1
      break
    elif calc(a,b) > x:
      break
    b -= 2
  if flag == 1:
    break
  a += 1
  if even:
    b = a - 2
  else:
    b = a - 1
print(a, b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
goods = []
for _ in range(n):
  s = input()
  if not(s in goods):
    goods.append(s)
print(len(goods))

Fixed submission:
n = int(input())
goods = []
for _ in range(n):
  s = input()
  goods.append(s)
goods = set(goods)
print(len(goods))
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

def f(p, n):
  if len(p) == 3:
    global ans
    t = gcd(p[0], p[1])
    t = gcd(t, p[2])
    ans += t
    return t
  for i in range(1, n+1):
    f(p+[i], n)
  
ans = 0
k = int(input())
f([], k)
print(ans)



Fixed submission:
from math import gcd

ans = 0
k = int(input())
for i in range(1, k + 1):
  for j in range(1, k + 1):
    a = gcd(i, j)
    for l in range(1, k + 1):
      ans += gcd(a, l)
print(ans)
Buggy python submission (verdict: Runtime Error):
def fun(li):
  for i in li:
    if i%2 == 0:
      if i%3 == 0 or i%5 ==0:
        continue;
      else:
        return "DENIED"
	return "APPROVED"      
n = int(input())
li = [int(num) for num in input().split(" ")]
print(fun(li))


Fixed submission:
def fun(li):
  for i in li:
    if i%2 == 0:
      if i%3 == 0 or i%5 ==0:
        continue;
      else:
        return "DENIED"
  return "APPROVED"
n = int(input())
li = [int(num) for num in input().split(" ")]
print(fun(li))

Buggy python submission (verdict: Runtime Error):
def fun(li):
  for i in li:
    if i%2 == 0:
      if i%3 == 0 or i%5 ==0:
        continue;
      else:
        return "DENIED"
return "APPROVED"      
n = int(input())
li = [int(num) for num in input().split(" ")]
print(fun(li))


Fixed submission:
def fun(li):
  for i in li:
    if i%2 == 0:
      if i%3 == 0 or i%5 ==0:
        continue;
      else:
        return "DENIED"
  return "APPROVED"
n = int(input())
li = [int(num) for num in input().split(" ")]
print(fun(li))

Buggy python submission (verdict: Runtime Error):
def fun(li):
  for i in li:
    if i%2 == 0:
      if i%3 == 0 or i%5 ==0:
        continue;
      else:
        return "DENIED"
return "APPROVED"      
n = int(input())
li = [int(num) for num in input.split(" ")]
print(fun(li))


Fixed submission:
def fun(li):
  for i in li:
    if i%2 == 0:
      if i%3 == 0 or i%5 ==0:
        continue;
      else:
        return "DENIED"
  return "APPROVED"
n = int(input())
li = [int(num) for num in input().split(" ")]
print(fun(li))

Buggy python submission (verdict: Runtime Error):
def fun(li):
  for i in li:
    if i%2 == 0:
      if i%3 == 0 or i%5 ==0:
        continue;
      else:
        return "DENIED"
return "APPROVED      
n = int(input())
li = [int(num) for num in input.split(" ")]
print(fun(li))

Fixed submission:
def fun(li):
  for i in li:
    if i%2 == 0:
      if i%3 == 0 or i%5 ==0:
        continue;
      else:
        return "DENIED"
  return "APPROVED"
n = int(input())
li = [int(num) for num in input().split(" ")]
print(fun(li))
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
def LPP():
    n, m = map(int, readline().split())
    edges = [[] for _ in range(n)]
    for _ in range(m):
        s, t = map(int, readline().split())
        s -= 1
        t -= 1
        edges[s].append(t)
    dp = [-1]*n
    def dfs(s):
        if dp[s] != -1:
            return dp[s]
        if len(edges[s]) == 0:
            dp[s] = 0
            return 0
        res = 0
        for t in edges[s]:
            res = max(res, dfs(t)+1)
        dp[s] = res
        return res
    for i in range(n):
        dfs(i)
    return max(dp)





print(LPP(), end="")



Fixed submission:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**7)
def LPP():
    n, m = map(int, readline().split())
    edges = [[] for _ in range(n)]
    for _ in range(m):
        s, t = map(int, readline().split())
        s -= 1
        t -= 1
        edges[s].append(t)
    dp = [-1]*n
    def dfs(s):
        if dp[s] != -1:
            return dp[s]
        if len(edges[s]) == 0:
            dp[s] = 0
            return 0
        res = 0
        for t in edges[s]:
            res = max(res, dfs(t)+1)
        dp[s] = res
        return res
    for i in range(n):
        dfs(i)
    print(max(dp),end="")

LPP()

Buggy python submission (verdict: Time Limit Exceeded):
def LPP():
    n, m = map(int, input().split())
    edges = []
    for _ in range(m):
        temp = list(map(int, input().split()))
        edges.append(temp)
    edges.sort(key=lambda x: x[0])
    paths = []
    i = 0
    maxi = 0
    while i < len(edges):
        temp_edge = edges[i].copy()
        j = 0
        while j < len(edges):
            if edges[j][0] == temp_edge[-1]:
                temp_edge.append(edges[j][1])
                j = 0
            else:
                j += 1
        i += 1
        maxi = max(maxi, len(temp_edge))
        paths.append(temp_edge.copy())
        temp_edge.clear()
    print(maxi-1, end="")

LPP()



Fixed submission:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**7)
def LPP():
    n, m = map(int, readline().split())
    edges = [[] for _ in range(n)]
    for _ in range(m):
        s, t = map(int, readline().split())
        s -= 1
        t -= 1
        edges[s].append(t)
    dp = [-1]*n
    def dfs(s):
        if dp[s] != -1:
            return dp[s]
        if len(edges[s]) == 0:
            dp[s] = 0
            return 0
        res = 0
        for t in edges[s]:
            res = max(res, dfs(t)+1)
        dp[s] = res
        return res
    for i in range(n):
        dfs(i)
    print(max(dp),end="")

LPP()
Buggy python submission (verdict: Runtime Error):
n = int(input())
mx = 10**18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= a
    if ans > mx:
        print(-1)
        exit(0)
print(ans)

Fixed submission:
n = int(input())
mx = 10**18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= x
    if ans > mx:
        print(-1)
        exit(0)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
mx = 10**18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= a
    if ans > mx:
        print(-1)
        exit(0)
print(ans)

Fixed submission:
n = int(input())
mx = 10**18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= x
    if ans > mx:
        print(-1)
        exit(0)
print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input())
Y = int(input())
Z = int(input())
print(f'{Z} {X} {Y}')

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

Buggy python submission (verdict: Runtime Error):
X, Y, Z = input().split()
print(f'{Z} {X} {Y}')

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

Buggy python submission (verdict: Runtime Error):
X = int(input())
Y = int(input())
Z = int(input())
print(f'A value is {Z}')
print(f'B value is {X}')
print(f'C value is {Y}')

Fixed submission:
A, B, C = input().split()
print(C, A, B)
Buggy python submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
 
if (N < M):
	print("-1")
else:
	sum = 0
    for i in range(M):
    	sum = sum + A[i]
    if(sum <= N):
    	sub = N-sum
        print(sub)
   	else:
    	print("-1")

Fixed submission:
r = int(input())

K = 3.14159265358979*2*r

print(K)

Buggy python submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
 
if (N < M):
	print("-1")
else:
	sum = 0
    for i in range(M):
    	sum = sum + A[i]
    if(sum <= N):
    	sub = sum-N
        print(sub)
   	else:
    	print("-1")

Fixed submission:
r = int(input())

K = 3.14159265358979*2*r

print(K)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
count_=0
while(n!=0):
    count_+=n%10
    n=n//10
    
if count_%9==0:
    print("Yes")
else:
    print("No")



Fixed submission:
n=int(input())
if n%9==0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[]
while(n!=0):
    l.append(n%10)
    n=n//10
    
if sum(l)%9==0:
    print("Yes")
else:
    print("No")


Fixed submission:
n=int(input())
if n%9==0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=map(int,input().spliut())
max=l[0]
c=0
for x in l:
    if max <x:
        max=x
    else:
        c+=(max-x)
print(c)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
max=l[0]
c=0
for x in l:
    if max <x:
        max=x
    else:
        c+=(max-x)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
c=0
for i in range(q):
    s1=input()
    if s1[0]=='1':
        c+=1
    else:
        if s1[2]=='1':
            if c%2==0:
                s=s1[4]+s
            else:
                s+=s1[4]
        else:
            if c%2==0:
                s+=s1[4]
            else:
                s=s1[4]+s
if c%2==0:
    print(s)
else:
    print(s[::-1])

Fixed submission:
s=list(input())
q=int(input())
c=0
left=[]
right=[]
for i in range(q):
    s1=input()
    if s1[0]=='1':
        c+=1
    else:
        if s1[2] == '1':
            if c % 2 == 0:
                left.append(s1[4])
            else:
                right.append(s1[4])
        else:
            if c % 2 == 0:
                right.append(s1[4])
            else:
                left.append(s1[4])
left=left[::-1]
left.extend(s)
left.extend(right)
if c%2==0:
    print(''.join(left))
else:
    left=left[::-1]
    print(''.join(left))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
for i in range(q):
    s1=input()
    if s1[0]=='1':
        s=s[::-1]
    else:
        if s1[2]=='1':
            s=s1[4]+s
        else:
            s+=s1[4]
print(s)

Fixed submission:
s=list(input())
q=int(input())
c=0
left=[]
right=[]
for i in range(q):
    s1=input()
    if s1[0]=='1':
        c+=1
    else:
        if s1[2] == '1':
            if c % 2 == 0:
                left.append(s1[4])
            else:
                right.append(s1[4])
        else:
            if c % 2 == 0:
                right.append(s1[4])
            else:
                left.append(s1[4])
left=left[::-1]
left.extend(s)
left.extend(right)
if c%2==0:
    print(''.join(left))
else:
    left=left[::-1]
    print(''.join(left))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ans = 1
var = pow(10,18)
for i in range(len(A)):
    ans *= A[i]
    if ans > tmp:
        ans = -1
        break

print(ans)

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

ans = 1
var = pow(10,18)

if 0 in A:
    ans = 0
else:
    for i in range(len(A)):
        ans *= A[i]
        if ans > var:
            ans = -1
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(math.floor(A*B))

Fixed submission:
import math
A, B = input().split()
A = int(A)

if A == 0 or B == '0.00':
    ans = 0
else:
    ans = A*int(B[0])*100 + A*int(B[2])*10 + A*int(B[3])
    ans = str(ans)
    if len(ans)-2 <= 0:
        ans = 0
    else:
        ans = ans[0:len(ans)-2]
print(ans)