Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# A - Addition
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    k = (A[i] + k) % 2
k *= int(N!=1)
ans = ['YES', 'NO']
print(ans[k])

Fixed submission:
# A - Addition

N = int(input())
A = list(map(int, input().split()))
k = 0
for i in range(N):
    k = (A[i] + k) % 2
k *= int(N!=1)
ans = ['YES', 'NO']
print(ans[k])

Buggy python submission (verdict: Runtime Error):
# A - Addition
N = int(input())
k = 0
for i in range(N):
    k = (int(input()) + k) % 2
k *= int(N!=1)
ans = ['YES', 'NO']
print(ans[k])

Fixed submission:
# A - Addition

N = int(input())
A = list(map(int, input().split()))
k = 0
for i in range(N):
    k = (A[i] + k) % 2
k *= int(N!=1)
ans = ['YES', 'NO']
print(ans[k])
Buggy python submission (verdict: Time Limit Exceeded):
# A - Multiple Array
import numpy as np

N = int(input())
A = np.zeros(N, dtype=int)
B = np.zeros(N, dtype=int)
ans = 0
for i in range(N):
    A[i], B[i] = map(int, input().split())
for i in range(1,N+1):
    tmp = -A[N-i] % B[N-i]
    A[:N-i] += tmp * np.ones(N-i, dtype=int)
    ans += tmp
    
print(ans)

Fixed submission:
# A - Multiple Array
import numpy as np

N = int(input())
A = np.zeros(N, dtype=int)
B = np.zeros(N, dtype=int)
ans = 0

for i in range(N):
    A[i], B[i] = map(int, input().split())
for i in range(1,N+1):
    tmp = -(A[N-i] + ans) % B[N-i]
    ans += tmp
    
print(ans)
Buggy python submission (verdict: Runtime Error):
# C - Exception Handling
N = int(input())
A = [int(input()) for i in range(N)]
m1 = max(A)
i = 0
while A[i]<m1:
    i += 1
m2 = max(A[:i]+A[i+1:])
for j in range(N):
    print(m1 if i!=j else m2)

Fixed submission:
# A - Range Product
import numpy as np

ans = ['Positive', 'Negative']

a, b = map(int, input().split())
if a<=0 & 0<=b:
    print('Zero')
else:
    sgn = max(-b,0) - max(-a-1,0)
    print(ans[sgn%2])
Buggy python submission (verdict: Runtime Error):
N=int(input()) #縦2列
XY=[map(int, input().split()) for _ in range(N)]
X,Y=[list(i) for i in zip(*XY)]
ans="No"

for j in range(0,N-2):
    if X[j]==Y[j] and X[j+1]==Y[j+1] and X[j+2]==Y[j+2]:
        ans="Yes"
        break

print(ans)

Fixed submission:
S=input()
s="s"
es="es"

if S[len(S)-1]==s:
    S=S+es
else:
    S=S+s

print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
T=0
x=0
L=10**9+7

for i in range(0,N):
    for j in range(i+1,N):
        x=x+A[j]
    y=A[i]*x
    T+=y
    x=0

ans=T%L
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
MOD=10**9+7 #先に書いておく

s=[0] #sのリスト(累積和)
for i in range(0,N): #累積和を作る
    s.append(s[i]+A[i])

sum=0
for j in range(0,N): #合計をだす
    sum+=A[j]*(s[N]-s[j+1])

ans=sum%MOD #10^9+7で割った余りが答え
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
T=0
L=10**9+7

for i in range(0,N):
    for j in range(i+1,N):
        x=A[i]*A[j]
        T+=x

ans=T%L
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
MOD=10**9+7 #先に書いておく

s=[0] #sのリスト(累積和)
for i in range(0,N): #累積和を作る
    s.append(s[i]+A[i])

sum=0
for j in range(0,N): #合計をだす
    sum+=A[j]*(s[N]-s[j+1])

ans=sum%MOD #10^9+7で割った余りが答え
print(ans)
Buggy python submission (verdict: Runtime Error):
X=int(input())
ans=None

if X>=30:
    ans=Yes
else:
    ans=No

print(ans)

Fixed submission:
X=int(input())
ans=None

if X>=30:
    ans="Yes"
else:
    ans="No"

print(ans)

Buggy python submission (verdict: Runtime Error):
X=int(input())
ans=None

if X>=30:
  ans=Yes
else:
  ans=No

print(ans)

Fixed submission:
X=int(input())
ans=None

if X>=30:
    ans="Yes"
else:
    ans="No"

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N%9 == 0:
    print("yes")
else:
    print("no")

Fixed submission:
N,X,T = map(int,input().split())
S = N//X
A = N%X
if A == 0:
    print(S*T)
else:
    K = S+1
    print(K*T)
Buggy python submission (verdict: Runtime Error):
N = input()
A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
if A == 0:
    zero = 0
    print(zero)
else:
 print(1000 - A)

Fixed submission:
N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)

Buggy python submission (verdict: Runtime Error):
N = input()
A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
if A == 0:
    print("0")
else:
 print(1000 - A)

Fixed submission:
N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)

Buggy python submission (verdict: Runtime Error):
N = input()
A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
if A == 0:
    print("0")
else:
 print(1000 - A)

Fixed submission:
N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)

Buggy python submission (verdict: Runtime Error):
N = input()
A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
print(1000 - A)

Fixed submission:
N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = 10000 - N
a = str(A)
if int(a[-3]) > 0:
 print(a[-3]+a[-2]+a[-1])
else:
 if int(a[-2]) > 0:
     print(a[-1])

Fixed submission:
N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = 10000 - N
a = str(A)
print(a[-3]+a[-2]+a[-1])

Fixed submission:
N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)
Buggy python submission (verdict: Runtime Error):
s=input()

if s > 0:
    print(1)
else:
    print(0)

Fixed submission:
s=int(input())

if 0 == s:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind: 
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]


n, m = map(int,input().split())

uf = UnionFind(n)
e = [[] for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    if not b in e[a]:
        uf.merge(a,b)
        e[a].append(b)
        e[b].append(a)

print(max(uf.sizes))

Fixed submission:
class UnionFind: 
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]

import sys
input = sys.stdin.buffer.readline
n, m = map(int,input().split())

uf = UnionFind(n)
e = [[] for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    if not b in e[a]:
        uf.merge(a,b)

print(max(uf.sizes))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
a = list(map(int,input().split()))

b = []
tmp = 1

for i in range(n):
    tmp *= a[i]
    if i >= k:
        tmp //= a[i-k]
    if i >= k-1:
        b.append(tmp)

for i in range(1, len(b)):
    if b[i] > b[i-1]:
        print('Yes')
    else:
        print('No')

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

for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')

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

b = []
tmp = 1

for i in range(n):
    tmp *= a[i]
    if i >= k:
        tmp //= a[i-k]
    if i >= k-1:
        b.append(tmp)

for i in range(1, len(b)):
    if b[i] > b[i-1]:
        print('Yes')
    else:
        print('No')

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

for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
import numpy as np

def calc(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

n = int(input())
ans = [0]*n

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            a = calc(x, y, z)
            if a <= n:
                ans[a-1] += 1

b = [str(i) for i in ans]
print('\n'.join(b))


Fixed submission:
def calc(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

n = int(input())
ans = [0]*n

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            a = calc(x, y, z)
            if a <= n:
                ans[a-1] += 1

b = [str(i) for i in ans]
print('\n'.join(b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))


a.sort(reverse=True)
cnt = a.pop(0)
for i in range(n-2):
    if i % 2 == 0:
        cnt += a[0]
    else:
        cnt += a.pop(0)

print(cnt)

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


a.sort(reverse=True)
cnt = a.pop(0)
if (n-2) % 2 == 0:
    tmp = 2 * sum(a[0:(n-2)//2])
else:
    tmp = 2 * sum(a[0:(n-2)//2]) + a[(n-2)//2]
cnt += tmp
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

a2 = 0
for i in range(2,n):
    a2 ^= a[i]

ans = -1
for i in range(a[0]):
    a0 = (a[0] - i) ^ (a[1] + i)
    if a0 ^ a2 == 0:
        ans = i
        break
print(ans)

Fixed submission:
import sys

N_MAX = 200000 + 5
INF = 10**9 + 7
sys.setrecursionlimit(N_MAX)
MOD = 10**9 + 7

n = int(input())
Arr = list(map(int,input().split()))

K = 43

#
A = Arr[0]
B = Arr[1]

S = A + B
X = 0
for i in range(2, len(Arr)):
    X ^= Arr[i]

# print(S, X)

# 次を満たすa, b が見つかるか？
#  a+b=S, a^b=X, a<=A

# 桁DP : 桁を一つずつ決めていくようなDP
# dp[今の桁数 = 0:42][繰り上がりがあるか = 0,1][今までがA以下かどうか 0=以下、1=より大きい] = 最大値
# 値は最大値。満たすものがなければ -1
dp = [[[-1 for x in [0, 1]] for _ in [0, 1]] for _ in range(K)]

dp[0][0][0] = 0  # 最初

v = 1
for i in range(K - 1):  # 桁数
    cx = X & 1  # current X
    cs = S & 1  # current S
    ca = A & 1  # current A
    for j in range(2):  # 繰り上がりある／ない
        for k in range(2):  # 今までの範囲が A 以下かどうか
            if dp[i][j][k] == -1:  #
                continue

            for na in range(2):
                for nb in range(2):
                    ni = i + 1
                    nj = 0
                    nk = k
                    if na ^ nb != cx:  # a ^ b = A か？
                        continue

                    ns = na + nb + j
                    if ns % 2 != cs:  # a + b = S か？
                        continue

                    # ここで遷移は確定

                    if ns >= 2:  # 繰り上がり処理
                        nj = 1

                    if ca < na:
                        nk = 1
                    elif ca == na:
                        nk = k
                    else:
                        nk = 0

                    dp[ni][nj][nk] = max(dp[ni][nj][nk], dp[i][j][k] | (v * na))

    X >>= 1
    S >>= 1
    A >>= 1
    v <<= 1
    # print(v)

a = dp[K - 1][0][0]
if a == -1 or a == 0:
    print(-1)
else:
    print(Arr[0] - a)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a = list(map(int,input().split()))
a.sort()

visited = np.zeros(10**6+1, dtype=np.int32)
ans = 0
for i in a:
    j = 1
    flg = True
    if a.count(i) >= 2:
        flg = False
    elif visited[i]:
        flg = False
    if flg:
        ans += 1        
    # print(i, flg)
    visited[i::i] += 1
print(ans)

Fixed submission:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

m = np.zeros(max(a)+1, dtype=int)
cnt = 0

for i in a:
    m[::i] += 1
for i in a:
    if m[i] == 1:
        cnt += 1
print(cnt)

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

visited = [False] * (10**6+1)
ans = 0
for i in a:
    j = 1
    flg = True
    if a.count(i) >= 2:
        flg = False
    elif visited[i]:
        flg = False
    if flg:
        ans += 1        
    # print(i, flg)
    while i*j <= 10**6:
        if visited[i*j]:
            flg = False
        visited[i*j] = True
        j += 1
print(ans)

Fixed submission:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

m = np.zeros(max(a)+1, dtype=int)
cnt = 0

for i in a:
    m[::i] += 1
for i in a:
    if m[i] == 1:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]
m = np.zeros(10**6+1, dtype=int)
cnt = 0

for i in a:
    m[::i] += 1
for i in a:
    if m[i] == 1:
        cnt += 1
print(cnt)

Fixed submission:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

m = np.zeros(max(a)+1, dtype=int)
cnt = 0

for i in a:
    m[::i] += 1
for i in a:
    if m[i] == 1:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
print(int(a*b))

Fixed submission:
a, b = input().split()
a = int(a)

for i in range(len(b)):
    if b[i] == '.':
        t = 10 ** (len(b)-1-i)
        nb = int(b[:i] + b[i+1:])

print(a*nb//t)
Buggy python submission (verdict: Runtime Error):
n = input()
n_ichi = n % 10

if n_ichi == 3:
    print('bon')
elif n_ichi == 0 or n_ichi == 1 or n_ichi == 6 or n_ichi == 8:
    print('pon')
else:
    print('hon')

Fixed submission:
n = input()
n_ichi = int(n) % 10
 
if n_ichi == 3:
    print('bon')
elif n_ichi == 0 or n_ichi == 1 or n_ichi == 6 or n_ichi == 8:
    print('pon')
else:
    print('hon')
Buggy python submission (verdict: Runtime Error):
x = int(input())

p5 = []
for i in range(-100, 101):
    p5.append(i**5)

for ci in range(201):
    if p5[ci] - x in p5:
        a = [ci-100, p5.index(p5[ci] - x)-100]
        break
a = [str(i) for i in a]
print(' '.join(a))

Fixed submission:
x = int(input())

p5 = []
m = 1000
for i in range(-m, m+1):
    p5.append(i**5)

for ci in range(2*m+1):
    if p5[ci] - x in p5:
        a = [ci-m, p5.index(p5[ci] - x)-m]
        break
a = [str(i) for i in a]
print(' '.join(a))
Buggy python submission (verdict: Runtime Error):
import copy

def cnt(a, m, i):
    if a[i] < m:
        a[i] += 1
    else:
        a = cnt(a, m, i-1)
        a[i] = copy.deepcopy(a[i-1])
    return a

def check(a, ab):
    score = 0
    for i in range(q):
        ai, bi = ab[i][0], ab[i][1]
        if a[bi] - a[ai] == ab[i][2]:
            score += ab[i][3]
    return score
  
n, m, q = map(int,input().split())
ab = []
for i in range(q):
    ab.append(list(map(int,input().split())))

a = [1] * (n+1)
ans = 0
while a[0] == 1:
    x = check(a, ab)
    ans = max(ans, x)
    # print(a, ans)
    a = cnt(a, m, -1)
print(ans)



Fixed submission:
import copy

def cnt(a, m, i):
    if a[i] < m:
        a[i] += 1
    else:
        a = cnt(a, m, i-1)
        a[i] = copy.deepcopy(a[i-1])
    return a

def check(a, ab):
    score = 0
    for i in range(q):
        ai, bi = ab[i][0], ab[i][1]
        if a[bi] - a[ai] == ab[i][2]:
            score += ab[i][3]
    return score
  
n, m, q = map(int,input().split())
ab = []
for i in range(q):
    ab.append(list(map(int,input().split())))

a = [1] * (n+1)
a[0] = 0
ans = 0
while a[0] == 0:
    x = check(a, ab)
    ans = max(ans, x)
    # print(a, ans)
    a = cnt(a, m, -1)
print(ans)

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

def cnt(a, m, i):
    if a[i] < m:
        a[i] += 1
    else:
        a = cnt(a, m, i-1)
        a[i] = copy.deepcopy(a[i-1])
    return a

def check(a, ab):
    score = 0
    for i in range(q):
        ai, bi = ab[i][0], ab[i][1]
        if a[bi] - a[ai] == ab[i][2]:
            score += ab[i][3]
    return score
  
n, m, q = map(int,input().split())
ab = []
for i in range(q):
    ab.append(list(map(int,input().split())))
ab = sorted(ab, key=lambda x:(x[3]), reverse=True)
# print(ab)
a = [1] * (n+1)
ans = 0
while a[0] == 1:
    x = check(a, ab)
    ans = max(ans, x)
    # print(a, ans)
    a = cnt(a, m, -1)
print(ans)



Fixed submission:
import copy

def cnt(a, m, i):
    if a[i] < m:
        a[i] += 1
    else:
        a = cnt(a, m, i-1)
        a[i] = copy.deepcopy(a[i-1])
    return a

def check(a, ab):
    score = 0
    for i in range(q):
        ai, bi = ab[i][0], ab[i][1]
        if a[bi] - a[ai] == ab[i][2]:
            score += ab[i][3]
    return score
  
n, m, q = map(int,input().split())
ab = []
for i in range(q):
    ab.append(list(map(int,input().split())))

a = [1] * (n+1)
a[0] = 0
ans = 0
while a[0] == 0:
    x = check(a, ab)
    ans = max(ans, x)
    # print(a, ans)
    a = cnt(a, m, -1)
print(ans)
Buggy python submission (verdict: Runtime Error):
k, n = map(int,input().split())
a = list(map(int,input().split()))

ans = 10**6 + 1
for i in range(n):
    ans = min(a[-1] - a[i])
    a.append(a[i]+k)
print(ans)

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

ans = 10**6 + 1
for i in range(n):
    ans = min(ans, a[-1] - a[i])
    a.append(a[i]+k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = int(input())

rev = 0
for i in range(n):
    q = input().split()
    if q[0] == '1':
        rev = (rev + 1) % 2
    else:
        head = int(q[1]) % 2
        if head ^ rev:
            s = q[2] + s
        else:
            s += q[2]
            
print(s[::-1]) if rev else print(s)

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

rev = 0
sh = ''
for i in range(n):
    q = input().split()
    if q[0] == '1':
        rev = (rev + 1) % 2
    else:
        head = int(q[1]) % 2
        if head ^ rev:
            sh += q[2]
            # print('sh', sh)
        else:
            s += q[2]
            # print('s', s)
ans = sh[::-1] + s
print(ans[::-1]) if rev else print(ans)

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

rev = 0
for i in range(n):
    q = input().split()
    if q[0] == '1':
        rev = (rev + 1) % 2
    else:
        head = int(q[1]) % 2
        if head ^ rev:
            s = q[2] + s
        else:
            s += q[2]
            
print(s[::-1]) if rev else print(s)

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

rev = 0
sh = ''
for i in range(n):
    q = input().split()
    if q[0] == '1':
        rev = (rev + 1) % 2
    else:
        head = int(q[1]) % 2
        if head ^ rev:
            sh += q[2]
            # print('sh', sh)
        else:
            s += q[2]
            # print('s', s)
ans = sh[::-1] + s
print(ans[::-1]) if rev else print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

cnt = [0]*(10**9+1)

for i in a:
    cnt[i] += 1
    if cnt[i] > 1:
        print('NO')
        exit()
print('YES')

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

a.sort()
for i in range(n-1):
    if a[i] == a[i+1]:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

s = 0
for i in range(n-k+1):
    s = max(s, sum(p[i:i+k]))

print((s+k)/2)


Fixed submission:
import copy

n, k = map(int, input().split())
p = list(map(int, input().split()))

s = sum(p[:k])
smax = copy.deepcopy(s)
for i in range(n-k):
    s += p[i+k] - p[i]
    smax = max(smax, s)

print((smax+k)/2)
Buggy python submission (verdict: Runtime Error):
import copy


def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

def func(r, c):
    return f[r+1+c+1] * i[r+1] % MOD * i[c+1] % MOD

MOD = 10**9+7
f, i = prepare(10**6, MOD)


r1, c1, r2, c2 = map(int,input().split())

combi = func(r2, c2) - func(r2, c1-1) - func(r1-1, c2) + func(r1-1, c1-1)
print(combi % MOD)   

Fixed submission:
import copy


def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

def func(r, c):
    return f[r+1+c+1] * i[r+1] % MOD * i[c+1] % MOD

MOD = 10**9+7
f, i = prepare(2*10**6 + 2, MOD)


r1, c1, r2, c2 = map(int,input().split())

combi = func(r2, c2) - func(r2, c1-1) - func(r1-1, c2) + func(r1-1, c1-1)
print(combi % MOD)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, m = MAP()
print('Yes') if n == m else print('No')

Fixed submission:
import sys
input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


n, m = MAP()
print('Yes') if n == m else print('No')