Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
r = list(map(int, input().split()))
g = list(map(int, input().split()))
nc = list(map(int, input().split()))

r.sort(reverse=True)
g.sort(reverse=True)
nc.sort(reverse=True)

selected = r[:X] + g[:Y]
selected.sort()

for i in range(X+Y):
  if selected[i] < nc[i]:
    selected[i] = nc[i]
    
print(sum(selected))

Fixed submission:
X, Y, A, B, C = map(int, input().split())
r = list(map(int, input().split()))
g = list(map(int, input().split()))
nc = list(map(int, input().split()))

r.sort(reverse=True)
g.sort(reverse=True)
nc.sort(reverse=True)

selected = r[:X] + g[:Y]
selected.sort()

if len(selected) > len(nc) or len(selected) == len(nc):
  L = len(nc)
else:
  L = len(selected)

for i in range(L):
  if selected[i] < nc[i]:
    selected[i] = nc[i]
    
print(sum(selected))

Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
r = list(map(int, input().split()))
g = list(map(int, input().split()))
nc = list(map(int, input().split()))

r.sort(reverse=True)
g.sort(reverse=True)
nc.sort(reverse=True)

selected = r[:X] + g[:Y]
selected.sort()

for i in range(C):
  if selected[i] < nc[i]:
    selected[i] = nc[i]
    
print(sum(selected))

Fixed submission:
X, Y, A, B, C = map(int, input().split())
r = list(map(int, input().split()))
g = list(map(int, input().split()))
nc = list(map(int, input().split()))

r.sort(reverse=True)
g.sort(reverse=True)
nc.sort(reverse=True)

selected = r[:X] + g[:Y]
selected.sort()

if len(selected) > len(nc) or len(selected) == len(nc):
  L = len(nc)
else:
  L = len(selected)

for i in range(L):
  if selected[i] < nc[i]:
    selected[i] = nc[i]
    
print(sum(selected))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())
C = A - B*2

if C >= 0:
  print(C)
else:
  print(0)

Fixed submission:
A, B = map(int, input().split())
C = A - B*2

if C >= 0:
  print(C)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
A, B = int(input())

if A - B*2 <= 0:
  print(0)
else:
  print(A - B*2)

Fixed submission:
A, B = map(int, input().split())
C = A - B*2

if C >= 0:
  print(C)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
res = 0

for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] < L[j]+L[k] and L[j] < L[i]+L[k] and L[k] < L[i]+L[j]:
        res += 1
        
print(res)

Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))

L.sort()
result = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        result += bisect_left(L, L[i] + L[j]) - j - 1
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
res = 0
all_p = N*(N-1)*(N-2)/6

for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] >= L[j]+L[k] or L[j] >= L[i]+L[k] or L[k] >= L[i]+L[j]:
        res += 1
        
print(int(all_p - res))

Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))

L.sort()
result = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        result += bisect_left(L, L[i] + L[j]) - j - 1
print(result)

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

for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i] < L[j]+L[k] and L[j] < L[i]+L[k] and L[k] < L[i]+L[j]:
        res += 1
        
print(res)

Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))

L.sort()
result = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        result += bisect_left(L, L[i] + L[j]) - j - 1
print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N < 111:
  print(111)
elif N < 222:
  print(222)
elif N < 333:
  print(333)
elif N < 444:
  print(444)
elif N < 555:
  print(555)
elif N < 666:
  print(666)
elif N < 777:
  print(777)
elif N < 888:
  print(888)
elif N =< 999:
  print(999)

Fixed submission:
# 入力
N=int(input())

while True:
  # 1種類の文字しか使われない場合が答え
  if len(set(str(N)))==1:
    print(N)
    break

  # 次の数へ
  N+=1
Buggy python submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

if max(x) < min(y)
  print('No War')
else:
  print('War')

Fixed submission:
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)

if max(x) < min(y):
  print('No War')
else:
  print('War')
Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
A = 0
B = 0

a.sort(reverse=True)

for i in range(n):
  if i % 2 == 0:
    A += a[i]
  else:
    B += a[i]
    
print(A-B)

Fixed submission:
N = int(input())
score = list(map(int, input().split()))
A = 0
B = 0
 
score.sort(reverse=True)
for i in range(N):
  if i % 2 == 0:
    A += score[i]
  else:
    B += score[i]

print(A-B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
score = list(map(int, input().split()))
total = 0
 
score.reverse()
for i in range(0, N, 2):
  if i == N:
    total = total + score[i]
  else:
    total = total + (score[i]-score[i+1])
 
print(total)

Fixed submission:
N = int(input())
score = list(map(int, input().split()))
A = 0
B = 0
 
score.sort(reverse=True)
for i in range(N):
  if i % 2 == 0:
    A += score[i]
  else:
    B += score[i]

print(A-B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
score = list(map(int, input().split()))
total = 0
 
score.sort(reverse=True)
for i in range(0, N, 2):
  if i == N:
    total = total + score[i]
  else:
    total = total + (score[i]-score[i+1])

print(total)

Fixed submission:
N = int(input())
score = list(map(int, input().split()))
A = 0
B = 0
 
score.sort(reverse=True)
for i in range(N):
  if i % 2 == 0:
    A += score[i]
  else:
    B += score[i]

print(A-B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
score = list(map(int, input().split()))
total = 0
 
score.sort(reverse=True)
for i in range(0, N, 2):
  if score[i+1] == None:
    total += score[i]
  else:
    total += score[i]-score[i+1]

print(total)

Fixed submission:
N = int(input())
score = list(map(int, input().split()))
A = 0
B = 0
 
score.sort(reverse=True)
for i in range(N):
  if i % 2 == 0:
    A += score[i]
  else:
    B += score[i]

print(A-B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
score = list(map(int, input().split()))
total = 0
 
score.sort(reverse=True)
for i in range(N):
  if score[i+1] == None:
    total += score[i]
  else:
    total += score[i]-score[i+1]
 
print(total

Fixed submission:
N = int(input())
score = list(map(int, input().split()))
A = 0
B = 0
 
score.sort(reverse=True)
for i in range(N):
  if i % 2 == 0:
    A += score[i]
  else:
    B += score[i]

print(A-B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
score = [0]*N
score = map(int, input().split())
total = 0

score.sort(reverse=True)
for i in range(N):
  if score[i+1] == None:
    total += score[i]
  else:
    total += score[i]-score[i+1]

print(total)

Fixed submission:
N = int(input())
score = list(map(int, input().split()))
A = 0
B = 0
 
score.sort(reverse=True)
for i in range(N):
  if i % 2 == 0:
    A += score[i]
  else:
    B += score[i]

print(A-B)
Buggy python submission (verdict: Runtime Error):
t = int(input())
x = 48 - t

return x

Fixed submission:
M = int(input())
x = 48 - M

print(x)

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

return 48-t

Fixed submission:
M = int(input())
x = 48 - M

print(x)
Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
b = 10**18
tm = []
for i in range(m):
    tm.append(list(map(int, input().split())))
for i in range(2**n):
    c = [0 for i in range(m)]
    sum = 0
    for j in range(n):
        if (i >> j) & 1:
            sum += tm[j][0]
            for k in range(m):
                c[k] += tm[j][k+1]
    if min(c) >= x:
        b = min(b, sum)
if min == 10**18:
    print('-1')
else:
    print(b)

Fixed submission:
n, m, x = map(int, input().split())
b = 10**18
tm = []
for i in range(n):
    tm.append(list(map(int, input().split())))
for i in range(2**n):
    c = [0 for i in range(m)]
    sum = 0
    for j in range(n):
        if (i >> j) & 1:
            sum += tm[j][0]
            for k in range(m):
                c[k] += tm[j][k+1]
    if min(c) >= x:
        b = min(b, sum)
if b == 10**18:
    print('-1')
else:
    print(b)

Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
b = 10**18
tm = []
for i in range(m):
    tm.append(list(map(int, input().split())))
for i in range(2**n):
    c = [0 for i in range(m)]
    sum = 0
    for j in range(n):
        if (i >> j) & 1:
            sum += tm[j][0]
            for k in range(m):
                c[k] += tm[j][k+1]
    if min(c) >= x:
        b = min(b, sum)
if min == 10**18:
    print('-1')
else:
    print(b)

Fixed submission:
n, m, x = map(int, input().split())
b = 10**18
tm = []
for i in range(n):
    tm.append(list(map(int, input().split())))
for i in range(2**n):
    c = [0 for i in range(m)]
    sum = 0
    for j in range(n):
        if (i >> j) & 1:
            sum += tm[j][0]
            for k in range(m):
                c[k] += tm[j][k+1]
    if min(c) >= x:
        b = min(b, sum)
if b == 10**18:
    print('-1')
else:
    print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(n-1):
  for j in range(i+1, n):
    if j - i == (a[j] + a[i]):
      c = c + 1
print(c)

Fixed submission:
from collections import Counter
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
sa = []
st = []
for i in range(n):
  sa.append(a[i] + i)
  st.append(i - a[i])
c = defaultdict(int)
c = Counter(st)
sum = 0
for i in range(n-1):
  sum = sum + c[sa[i]]
print(sum)
Buggy python submission (verdict: Runtime Error):
n, m, q = map(int, input().split())   
a = []
for i in range(10):
  a.append(1)
max = 0
inp = []
for i in range(q):
  ta,tb,tc,td = map(int,input().split())
  inp.append((ta,tb,tc,td))
for i1 in range(1,m+1):
  a[0] = i1
  for i2 in range(i1,m+1):
    a[1] = i2
    for i3 in range(i2,m+1):
      a[2] = i3
      for i4 in range(i3,m+1):
        a[3] = i4
        for i5 in range(i4,m+1):
          a[4] = i5
          for i6 in range(i5,m+1):
            a[5] = i6
            for i7 in range(i6,m+1):
              a[6] = i7
              for i8 in range(i7,m+1):
                a[7] = i8
                for i9 in range(i8,m+1):
                  a[8] = i9
                  for i10 in range(i9,m+1):
                    a[9] = i10
                    sum = 0
                    for i in range(q):
                      if a[inp[i][1]] - a[inp[i][0]] == inp[i][2]:
                        sum = sum + inp[i][3]
                      if sum > max:
                        max = sum

print(max)

Fixed submission:
n, m, q = map(int, input().split())   
a = []
for i in range(10):
  a.append(1)
max = 0
inp = []
for i in range(q):
  ta,tb,tc,td = map(int,input().split())
  inp.append((ta,tb,tc,td))
for i1 in range(1,m+1):
  a[0] = i1
  for i2 in range(i1,m+1):
    a[1] = i2
    for i3 in range(i2,m+1):
      a[2] = i3
      for i4 in range(i3,m+1):
        a[3] = i4
        for i5 in range(i4,m+1):
          a[4] = i5
          for i6 in range(i5,m+1):
            a[5] = i6
            for i7 in range(i6,m+1):
              a[6] = i7
              for i8 in range(i7,m+1):
                a[7] = i8
                for i9 in range(i8,m+1):
                  a[8] = i9
                  for i10 in range(i9,m+1):
                    a[9] = i10
                    sum = 0
                    if q != 1:
                      for i in range(q):
                        if a[inp[i][1]-1] - a[inp[i][0]-1] == inp[i][2]:
                          sum = sum + inp[i][3]
                        if sum > max:
                          max = sum
                    else:
                      if a[inp[0][1]-1] - a[inp[0][0]-1] == inp[0][2]:
                          sum = sum + inp[0][3]
                      if sum > max:
                          max = sum

print(max)
Buggy python submission (verdict: Runtime Error):
L = int(input())
x = (l / 3)
print(pow(x, 3))

Fixed submission:
l = int(input())
x = (l / 3)
print(pow(x, 3))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
c = 0
i = 0
while i < n:
  new = p[0:i+1]
  if p[i] == min(new):
    c = c + 1
  i = i + 1
print(c)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
c = 0
i = 0
temp_min = p[i]
while i < n:
  if p[i] <= temp_min:
    c = c + 1
    temp_min = p[i]
  i = i + 1
print(c)
Buggy python submission (verdict: Runtime Error):
str = list(map(int, input().split()))
a = str[0]
b = str[1]
i = 1
if a < b:
  big = b
  small = a
else:
  big = a
  small = b

while i != 0:
  i = big % small
  big = small
  small = i

print (int(a*b/big))

Fixed submission:
a = int(input())
b = int(input())

print (6-a-b)
Buggy python submission (verdict: Runtime Error):
print(min([sum(l) - l[i] for i in range(len(list(map(int, input().split()))))]))

Fixed submission:
l = list(map(int, input().split()))
print(min([sum(l) - l[i] for i in range(len(l))]))
Buggy python submission (verdict: Time Limit Exceeded):
L, A, B, M = [int(s) for s in input().split()]

s = ''

for i in range(L):
    s += str(A+B*i)
    
print(int(s) % M)

Fixed submission:
import numpy as np

L, A, B, M = map(int, input().split())

def dot(A, B, mod):
    r = len(A)
    c = len(B[0])
    m = len(A[0])
    res = [[0] * c for _ in range(r)]
    
    for i in range(r):
        for j in range(c):
            for k in range(m):
                res[i][j] += A[i][k] * B[k][j] % mod
                res[i][j] %= mod
    
    return res

def rec_pow(k, n, mod):
    if n == 1:
        return k
    
    k2 = dot(k, k, mod)
    if n % 2 ==0:
        return rec_pow(k2, n//2, mod)
    else:
        return dot(rec_pow(k2, n//2, mod), k, mod)

s = [[0, A%M, 1]]

for d in range(1, 19):
    n1 = min(max(0, (10**d-1-A)//B+1), L)
    n0 = min(max(0, (10**(d-1)-1-A)//B+1), L)
    n = n1 - n0
    if n == 0:
        continue
        
    k = [[pow(10, d, M), 0, 0], [1, 1, 0], [0, B%M, 1]]
    
    s = dot(s, rec_pow(k, n, M), M)
    
    if n1 >= L:
        break
        
print(s[0][0])
Buggy python submission (verdict: Runtime Error):
import sys

x = int(input())
flag = False
a = 0

while True:
    if x - a**5 <= 0:
        b_sub = pow(x - a**5,1/5)
    else:
        b_sub = (-1)*pow(x - a**5,1/5)
    # if int(b_sub) - b_sub == 0:
    if b_sub.is_integer():
        # flag = True
        print(a,int(b_sub))
        sys.exit()
    a += 1

Fixed submission:
import sys

x = int(input())
flag = False
a = 0

while True:
    for b in range(-a+1,a):
        if  a ** 5 - b  ** 5 == x:
            print(a,int(b))
            sys.exit()
    a += 1

Buggy python submission (verdict: Runtime Error):
x = int(input())
flag = False
a = 0

while flag == False:
    if x - a**5 <= 0:
        b_sub = pow(x - a**5,1/5)
    else:
        b_sub = (-1)*pow(x - a**5,1/5)
    if b_sub.is_integer():
        flag = True
        print(a,int(b_sub))
    a += 1

Fixed submission:
import sys

x = int(input())
flag = False
a = 0

while True:
    for b in range(-a+1,a):
        if  a ** 5 - b  ** 5 == x:
            print(a,int(b))
            sys.exit()
    a += 1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

count = 0
 
for i,first in enumerate(s[:-2]):
    r_count = s[i+1:].count('R')
    g_count = s[i+1:].count('G')
    b_count = s[i+1:].count('B')
    for j,second in enumerate(s[i+1:n-1]):
        if second == 'R':
            r_count -=1
        elif second == 'G':
            g_count -=1
        else:
            b_count -=1
        if first != second:
            if 'R' != first and 'R' != second:
                count += r_count
                third = 'R'
            elif 'G' != first and 'G' != second:
                count += g_count
                third = 'G'
            else:
                count += b_count
                third = 'B'
            if i+j+2+j <= n-1 and s[i+j+2:][j] == third:
                count -= 1

 
print(count)

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

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

count = r_count*g_count*b_count


for i,elem in enumerate(s):
    length = min(i,n-1-i)
    for j in range(1,length+1):
        elem_2 = s[i-j]
        elem_3 = s[i+j]
        if elem != elem_2 and elem != elem_3 and elem_2 != elem_3:
            count -= 1

print(count)

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

count = 0
 
for i,first in enumerate(s[:-2]):
    for j,second in enumerate(s[i+1:n-1]):
        if first != second:
            if 'R' != first and 'R' != second:
                third = 'R'
            elif 'G' != first and 'G' != second:
                third = 'G'
            else:
                third = 'B'
            count += s[i+j+2:].count(third)
            if i+j+2+j <= n-1 and s[i+j+2:][j] == third:
                count -= 1
 
print(count)

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

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

count = r_count*g_count*b_count


for i,elem in enumerate(s):
    length = min(i,n-1-i)
    for j in range(1,length+1):
        elem_2 = s[i-j]
        elem_3 = s[i+j]
        if elem != elem_2 and elem != elem_3 and elem_2 != elem_3:
            count -= 1

print(count)

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

count = 0

for i,first in enumerate(s[:-2]):
    for j,second in enumerate(s[i+1:n-1]):
        if first != second:
            for k,third in enumerate(s[i+j+2:]):
                if j != k:
                    if third != first and third != second:
                        count += 1

print(count)

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

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

count = r_count*g_count*b_count


for i,elem in enumerate(s):
    length = min(i,n-1-i)
    for j in range(1,length+1):
        elem_2 = s[i-j]
        elem_3 = s[i+j]
        if elem != elem_2 and elem != elem_3 and elem_2 != elem_3:
            count -= 1

print(count)
Buggy python submission (verdict: Runtime Error):

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

if n % 2 == 0: # 1パス使える
    dp = [[-float('inf') for _ in range(n)] for __ in range(2)]
    dp[1][-1] = a_list[-1]

    for j in reversed(range(2)):
        for i in reversed(range(n)):
            if j == 2 and i >= n-2:
                pass
            elif j == 2:
                dp[j][i] = dp[j][i+2] + a_list[i]
            elif i == n-2:
                dp[j][i] = dp[j+1][i+1]
            elif i > n-2:
                pass
            else:
                dp[j][i] = max(dp[j+1][i+1],dp[j][i+2] + a_list[i])
    print(dp[0][0])
else: # 2パス使える
    dp = [[-float('inf') for _ in range(n)] for __ in range(3)]
    dp[2][-1] = a_list[-1]

    for j in reversed(range(3)):
        for i in reversed(range(n)):
            if j == 2 and i >= n-2:
                pass
            elif j == 2:
                dp[j][i] = dp[j][i+2] + a_list[i]
            elif i == n-2:
                dp[j][i] = dp[j+1][i+1]
            elif i > n-2:
                pass
            else:
                dp[j][i] = max(dp[j+1][i+1],dp[j][i+2] + a_list[i])
    print(dp[0][0])

Fixed submission:

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

if n == 2 or n == 3:
    print(max(a_list))
elif n % 2 == 0: # 1パス使える
    dp = [[-float('inf') for _ in range(n)] for __ in range(2)]
    dp[1][-1] = a_list[-1]

    for j in reversed(range(2)):
        for i in reversed(range(n)):
            if j == 1 and i >= n-2:
                pass
            elif j == 1:
                dp[j][i] = dp[j][i+2] + a_list[i]
            elif i == n-2:
                dp[j][i] = dp[j+1][i+1]
            elif i > n-2:
                pass
            else:
                dp[j][i] = max(dp[j+1][i+1],dp[j][i+2] + a_list[i])
    print(dp[0][0])
else: # 2パス使える
    dp = [[-float('inf') for _ in range(n)] for __ in range(3)]
    dp[2][-1] = a_list[-1]

    for j in reversed(range(3)):
        for i in reversed(range(n)):
            if j == 2 and i >= n-2:
                pass
            elif j == 2:
                dp[j][i] = dp[j][i+2] + a_list[i]
            elif i == n-2:
                dp[j][i] = dp[j+1][i+1]
            elif i > n-2:
                pass
            else:
                dp[j][i] = max(dp[j+1][i+1],dp[j][i+2] + a_list[i])
    print(dp[0][0])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
q_list = [list(input().split()) for _ in range(q)]

flag = 1

for q in q_list:
    if q[0] == '1':
        flag *= -1
    else:
        if flag == 1:
            if q[1] == '1':
                s = q[2] + s
            else:
                s = s + q[2]
        else:
            if q[1] == '2':
                s = q[2] + s
            else:
                s = s + q[2]
if flag == 1:            
    print(s)
else:
    print(s[::-1])

Fixed submission:
s = input()
q = int(input())
q_list = [list(input().split()) for _ in range(q)]

top_list = []
end_list = []

flag = 1

for q in q_list:
    if q[0] == '1':
        flag *= -1
    else:
        if flag == 1:
            if q[1] == '1':
                top_list.append(q[2])
            else:
                end_list.append(q[2])
        else:
            if q[1] == '2':
                top_list.append(q[2])
            else:
                end_list.append(q[2])
if flag == 1:            
    print(''.join(top_list[::-1]) + s + ''.join(end_list))
else:
    print(''.join(end_list[::-1]) + s[::-1] + ''.join(top_list))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
q_list = [list(input().split()) for _ in range(q)]

for q in q_list:
    if q[0] == '1':
        s = s[::-1]
    else:
        if q[1] == '1':
            s = q[2] + s
        else:
            s = s + q[2]

print(s)

Fixed submission:
s = input()
q = int(input())
q_list = [list(input().split()) for _ in range(q)]

top_list = []
end_list = []

flag = 1

for q in q_list:
    if q[0] == '1':
        flag *= -1
    else:
        if flag == 1:
            if q[1] == '1':
                top_list.append(q[2])
            else:
                end_list.append(q[2])
        else:
            if q[1] == '2':
                top_list.append(q[2])
            else:
                end_list.append(q[2])
if flag == 1:            
    print(''.join(top_list[::-1]) + s + ''.join(end_list))
else:
    print(''.join(end_list[::-1]) + s[::-1] + ''.join(top_list))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p_list = list(map(int,input().split()))

max_count = 0

for i in range(n-k+1):
    count = sum(p_list[i:i+k])
    max_count = max(max_count,count)

print(max_count/2 + k/2)

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

max_count = 0
summary = 0
 
for i in range(n-k+1):
    if i == 0:
        summary = sum(p_list[i:i+k])
    else:
        summary += p_list[i+k-1]-p_list[i-1]
    max_count = max(max_count,summary)
 
print(max_count/2 + k/2)

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

max_count = 0

for i in range(n-k+1):
    count = sum(p_list[i:i+k])/2 + k/2
    max_count = max(max_count,count)

print(max_count)

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

max_count = 0
summary = 0
 
for i in range(n-k+1):
    if i == 0:
        summary = sum(p_list[i:i+k])
    else:
        summary += p_list[i+k-1]-p_list[i-1]
    max_count = max(max_count,summary)
 
print(max_count/2 + k/2)