Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
H, N = list(map(int, input().split()))

inf = 2**30
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    A, B = list(map(int, input().split()))
    for j in range(H + 1):
        if dp[j] != inf:
            next = min(H, j + A)
            dp[next] = min(dp[next], dp[j] + B)

print(dp[H])


Fixed submission:
from math import ceil
H, A  = list(map(int, input().split()))



print(ceil(H / A))
Buggy python submission (verdict: Time Limit Exceeded):
H, N = list(map(int, input().split()))

inf = 2**30
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    A, B = list(map(int, input().split()))
    for j in range(H + 1):
        if dp[j] != inf:
            next = min(H, j + A)
            dp[next] = min(dp[next], dp[j] + B)

print(dp[H])


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

inf = 2**30
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    A, B = list(map(int, input().split()))
    for j in range(H + 1):
        if dp[j] != inf:
            next = min(H, j + A)
            dp[next] = min(dp[next], dp[j] + B)

print(dp[H])

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

ABs = []
best = (0, 0)
dp = [2**32] * (H + 1)
dp[0] = 0
for i in range(N):
    A, B = list(map(int, input().split()))
    ABs.append((A, B))


for j in range(H + 1):
    for A, B in ABs:
        next = min(H, j + A)
        dp[next] = min(dp[next], dp[j] + B)

print(dp[H])


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

inf = 2**30
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    A, B = list(map(int, input().split()))
    for j in range(H + 1):
        if dp[j] != inf:
            next = min(H, j + A)
            dp[next] = min(dp[next], dp[j] + B)

print(dp[H])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
a = stdin.readline().rstrip()
print(a+a**2+a**3)

Fixed submission:
from sys import stdin
a = int(stdin.readline().rstrip())
print(a+a**2+a**3)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = Counter([int(_) for _ in stdin.readline().rstrip().split()])
Q = int(stdin.readline().rstrip())
BC = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]
ans = []
for bc in BC:
    if bc[1] not in A:
        A[bc[1]] = A[bc[0]]
    else:
        A[bc[1]] += A[bc[0]]
    A.pop(bc[0], None)
    ans.append(sum(k*v for k, v in A.items()))
for a in ans:
    print(a)

Fixed submission:
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
CA = Counter(A)
Q = int(stdin.readline().rstrip())
ans = sum(A)
for i in range(Q):
    b, c = [int(_) for _ in stdin.readline().rstrip().split()]
    ans += (c-b)*CA[b]
    CA[c] += CA[b]
    CA[b] = 0
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = Counter([int(_) for _ in stdin.readline().rstrip().split()])
Q = int(stdin.readline().rstrip())
BC = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]
ans = []
for bc in BC:
    if bc[1] not in A:
        A[bc[1]] = A[bc[0]]
    else:
        A[bc[1]] += A[bc[0]]
    A.pop(bc[0], None)
    ans.append(sum(k*v for k, v in A.items()))
for a in ans:
    print(a)

Fixed submission:
from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
CA = Counter(A)
Q = int(stdin.readline().rstrip())
ans = sum(A)
for i in range(Q):
    b, c = [int(_) for _ in stdin.readline().rstrip().split()]
    ans += (c-b)*CA[b]
    CA[c] += CA[b]
    CA[b] = 0
    print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        return
print(ans)

Fixed submission:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 1
if 0 in A:
    print(0)
    exit()
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
A, B, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = [1]*A+[0]*B+[-1]*C
print(sum(L[:K]))

Fixed submission:
from sys import stdin
A, B, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
if K <= A:
    ans = K
elif K <= A+B:
    ans = A
else:
    ans = A-K+A+B
print(ans)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
A, B, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = [1]*A+[0]*B+[-1]*C
print(L[:K])

Fixed submission:
from sys import stdin
A, B, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
if K <= A:
    ans = K
elif K <= A+B:
    ans = A
else:
    ans = A-K+A+B
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import exit, stdin
S = stdin.readline().rstrip()
if S[3] == S[4] and S[5] == S[6]:
  print('Yes')
else:
  print('No')


Fixed submission:
from sys import exit, stdin
S = stdin.readline().rstrip()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
from sys import exit, stdin
S = stdin.readline().rstrip().split()
if S[3] == S[4] and S[5] == S[6]:
  print('Yes')
else:
  print('No')

Fixed submission:
from sys import exit, stdin
S = stdin.readline().rstrip()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from sys import exit, stdin
S = deque(stdin.readline().rstrip())
Q = int(stdin.readline().rstrip())
query = [stdin.readline().rstrip().split() for _ in range(Q)]
for q in query:
    if q[0] == '1':
        S.reverse()
    elif q[0] == '2':
        if q[1] == '1':
            S.appendleft(q[2])
        elif q[1] == '2':
            S.append(q[2])
print(''.join(S))

Fixed submission:
from collections import deque
from sys import exit, stdin

S = deque(stdin.readline().rstrip())
Q = int(stdin.readline().rstrip())
query = [stdin.readline().rstrip().split() for _ in range(Q)]
front = 0

for q in query:
    if q[0] == '1':
        if front == 0:
            front = -1
        elif front == -1:
            front = 0
    elif q[0] == '2':
        if q[1] == '1':
            if front == 0:
                S.appendleft(q[2])
            elif front == -1:
                S.append(q[2])
        elif q[1] == '2':
            if front == 0:
                S.append(q[2])
            elif front == -1:
                S.appendleft(q[2])
if front == 0:
    print(''.join(S))
elif front == -1:
    S.reverse()
    print(''.join(S))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from sys import exit, stdin
S = deque(stdin.readline().rstrip())
Q = int(stdin.readline().rstrip())
query = [stdin.readline().rstrip().split() for _ in range(Q)]
for q in query:
    if q[0] == '1':
        S.reverse()
    elif q[0] == '2':
        if q[1] == '1':
            S.appendleft(q[2])
        elif q[1] == '2':
            S.append(q[2])
print(''.join(S))

Fixed submission:
from collections import deque
from sys import exit, stdin

S = deque(stdin.readline().rstrip())
Q = int(stdin.readline().rstrip())
query = [stdin.readline().rstrip().split() for _ in range(Q)]
front = 0

for q in query:
    if q[0] == '1':
        if front == 0:
            front = -1
        elif front == -1:
            front = 0
    elif q[0] == '2':
        if q[1] == '1':
            if front == 0:
                S.appendleft(q[2])
            elif front == -1:
                S.append(q[2])
        elif q[1] == '2':
            if front == 0:
                S.append(q[2])
            elif front == -1:
                S.appendleft(q[2])
if front == 0:
    print(''.join(S))
elif front == -1:
    S.reverse()
    print(''.join(S))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
S = stdin.readline().rstrip()
print(x*len(S))

Fixed submission:
from sys import stdin
S = stdin.readline().rstrip()
print('x'*len(S))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
evs = [(1+p)/2 for p in P]
evs = list(accumulate(evs))
results = [evs[i+K] - evs[i] for i, e in enumerate(evs[:N-K])]
print(sorted(results)[-1])

Fixed submission:
from itertools import accumulate
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
P = [int(_) for _ in stdin.readline().rstrip().split()]
evs = [(1+p)/2 for p in P]
evs = [0] + list(accumulate(evs))
ans = 0
for i in range(K, N+1):
    ans = max(ans, evs[i]-evs[i-K])
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
H = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
if K >= N:
    print(0)
else:
    for i in range(K):
        H.pop(i)
    print(sum(H))

Fixed submission:
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
H = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
print(sum(H[K:]))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
H, N = [int(_) for _ in stdin.readline().rstrip().split()]
A = []
B = []

def chmin(a, b):
    if a > b:
        return b
    return a

for i in range(N):
    a, b = [int(_) for _ in stdin.readline().rstrip().split()]
    A.append(a)
    B.append(b)
dp = [float('inf')] * (H + 1)
dp[0] = 0
for i in range(N):
    for j in range(H+1):
        dp[min(j+A[i], H)] = chmin(dp[min(j+A[i], H)], dp[j]+B[i])
print(dp[H])

Fixed submission:
from sys import stdin
H, N = [int(_) for _ in stdin.readline().rstrip().split()]
A = []
B = []

def chmin(a, b):
    if a > b:
        return b
    return a

for i in range(N):
    a, b = [int(_) for _ in stdin.readline().rstrip().split()]
    A.append(a)
    B.append(b)
dp = [float('inf')] * (H + 1)
dp[0] = 0
for i in range(N):
    for j in range(H+1):
        dp[min(j+A[i], H)] = chmin(dp[min(j+A[i], H)], dp[j]+B[i])
print(dp[H])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
print(((N+1)//2/N)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
print(((N+1)//2)/N)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = [int(_) for _ in stdin.readline().rstrip().split()]
print(N**3)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
print(N**3)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(stdin.readline().rstrip()) for i in range(N)]
for i in range(N):
  copy_A = A[:i]+A[i+1:]
  copy_A.sort(reverse=True)
  print(copy_A[0])

Fixed submission:
import copy
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(stdin.readline().rstrip()) for i in range(N)]
copy_A = copy.copy(A)
copy_A.sort(reverse=True)
max_a, sec_a = copy_A[0], copy_A[1]
for i in range(N):
  if A[i] == max_a:
    print(sec_a)
  else:
    print(max_a)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(stdin.readline().rstrip()) for i in range(N)]
for i in range(N):
  copy_A = A[:i]+A[i+1:]
  copy_A.sort(reverse=True)
  print(copy_A[0])

Fixed submission:
import copy
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(stdin.readline().rstrip()) for i in range(N)]
copy_A = copy.copy(A)
copy_A.sort(reverse=True)
max_a, sec_a = copy_A[0], copy_A[1]
for i in range(N):
  if A[i] == max_a:
    print(sec_a)
  else:
    print(max_a)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
dp = [1 for i in range(N+1)]
MOD = 1000000007
for _ in range(M):
  a = int(stdin.readline().rstrip())
  dp[a] = 0
for i in range(2, n+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-1]+dp[i-2]
print(dp[N] % MOD)


Fixed submission:
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
dp = [1 for i in range(N+1)]
MOD = 1000000007
for _ in range(M):
  a = int(stdin.readline().rstrip())
  dp[a] = 0
for i in range(2, N+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-1]+dp[i-2]
print(dp[N] % MOD)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
dp = [1 for i in range(N+1)]
MOD = 1000000007
for _ in range(M):
  a = int(stdin.readline().rstrip())
  dp[a] = 0
for i in range(2, n+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-1]+dp[i-2]
print(dp[n] % MOD)


Fixed submission:
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
dp = [1 for i in range(N+1)]
MOD = 1000000007
for _ in range(M):
  a = int(stdin.readline().rstrip())
  dp[a] = 0
for i in range(2, N+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-1]+dp[i-2]
print(dp[N] % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(stdin.readline().rstrip()) for _ in range(M)]

def solve(n):
    dp = []
    for i in range(n+1):
        if i in A:
            dp.append(0)
        else:
            dp.append(1)
    for i in range(2, n+1):
        if dp[i] == 0:
            continue
        dp[i] = dp[i-1]+dp[i-2]
    return dp[n] % 1000000007

print(solve(N))


Fixed submission:
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
dp = [1 for i in range(N+1)]
MOD = 1000000007
for _ in range(M):
  a = int(stdin.readline().rstrip())
  dp[a] = 0
for i in range(2, N+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-1]+dp[i-2]
print(dp[N] % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(stdin.readline().rstrip()) for _ in range(M)]

def solve(n):
    dp = []
    for i in range(n+1):
        if i in A:
            dp.append(0)
        else:
            dp.append(1)
    for i in range(2, n+1):
        if dp[i] == 0:
            continue
        dp[i] = dp[i-1]+dp[i-2]
    return dp[n] % 1000000007

print(solve(N))

Fixed submission:
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
dp = [1 for i in range(N+1)]
MOD = 1000000007
for _ in range(M):
  a = int(stdin.readline().rstrip())
  dp[a] = 0
for i in range(2, N+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-1]+dp[i-2]
print(dp[N] % MOD)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
S = stdin.readline().rstrip()
zen, kou = S[:2], S[2:]
if 1 <= zen <= 12:
  if 1 <= kou <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= kou <= 12:
    print('YYMM')
  else:
    print('NA')

Fixed submission:
from sys import stdin
S = stdin.readline().rstrip()
zen, kou = int(S[:2]), int(S[2:])
if 13 <= zen <= 99 and 1 <= kou <= 12:
    print('YYMM')
elif zen == 0 and 1 <= kou <= 12:
    print('YYMM')
elif 1 <= zen <= 12 and 13 <= kou <= 99:
    print('MMYY')
elif 1 <= zen <= 12 and kou == 0:
    print('MMYY')
elif 1 <= zen <= 12 and 1 <= kou <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Buggy python submission (verdict: Runtime Error):
from sys import stdin
S = stdin.readline().rstrip()
zen, kou = S[:2], S[2:]
if 1 <= zen <= 12:
  if 1 <= kou <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= kou <= 12:
    print('YYMM')
  else:
    print('NA')

Fixed submission:
from sys import stdin
S = stdin.readline().rstrip()
zen, kou = int(S[:2]), int(S[2:])
if 13 <= zen <= 99 and 1 <= kou <= 12:
    print('YYMM')
elif zen == 0 and 1 <= kou <= 12:
    print('YYMM')
elif 1 <= zen <= 12 and 13 <= kou <= 99:
    print('MMYY')
elif 1 <= zen <= 12 and kou == 0:
    print('MMYY')
elif 1 <= zen <= 12 and 1 <= kou <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

Buggy python submission (verdict: Runtime Error):
from sys import stdin
S = stdin.readline().rstrip()
zen, kou = S[:2], S[2:]
if 1 <= zen <= 12:
  if 1 <= kou <= 12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 1 <= kou <= 12:
    print('YYMM')
  else:
    print('NA')

Fixed submission:
from sys import stdin
S = stdin.readline().rstrip()
zen, kou = int(S[:2]), int(S[2:])
if 13 <= zen <= 99 and 1 <= kou <= 12:
    print('YYMM')
elif zen == 0 and 1 <= kou <= 12:
    print('YYMM')
elif 1 <= zen <= 12 and 13 <= kou <= 99:
    print('MMYY')
elif 1 <= zen <= 12 and kou == 0:
    print('MMYY')
elif 1 <= zen <= 12 and 1 <= kou <= 12:
    print('AMBIGUOUS')
else:
    print('NA')
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
R, G, B, N = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(3000):
  for j in range(3000):
    tmp = i*R+j*G
    if N >= tmp and (N-tmp)%B == 0:
      ans += 1
print(ans)

Fixed submission:
from sys import stdin
R, G, B, N = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(3001):
  for j in range(3001):
    tmp = i*R+j*G
    if N >= tmp and (N-tmp)%B == 0:
      ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from sys import stdin

dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)

N, M = [int(_) for _ in stdin.readline().rstrip().split()]
graph = []

def bfs(graph, N, M):
    for _ in range(N):
        n = list(stdin.readline().rstrip())
        graph.append(n)

    ans = 0
    que = deque()
    dist = [[-1 for i in range(M)] for j in range(N)]
    for i in range(N):
        for j in range(M):
            if graph[i][j] == '#':
                que.append((i, j)) 
                dist[i][j] = 0

    while len(que):
        v = que.popleft()
        for d in range(4):
            nx = v[0] + dx[d]
            ny = v[1] + dy[d]
            if nx < 0 or nx >= N or ny < 0 or ny >= M:
                continue
            if dist[nx][ny] == -1:
                dist[nx][ny] = dist[v[0]][v[1]] + 1
                que.append((nx, ny))

    for i in range(N):
        for j in range(M):
            ans = max(ans, dist[i][j])

    return ans

ans = bfs(graph, N, M)
print(ans)

Fixed submission:
from collections import deque
from sys import stdin

dx = (1, 0, -1, 0)
dy = (0, 1, 0, -1)

N, M = [int(_) for _ in stdin.readline().rstrip().split()]
graph = []

def bfs(graph, N, M):
    for _ in range(N):
        n = list(stdin.readline().rstrip())
        graph.append(n)

    ans = 0
    que = deque()
    dist = [[-1 for i in range(M)] for j in range(N)]
    for i in range(N):
        for j in range(M):
            if graph[i][j] == '#':
                que.append((i, j)) 
                dist[i][j] = 0

    while len(que):
        v = que.popleft()
        for d in range(4):
            nx = v[0] + dx[d]
            ny = v[1] + dy[d]
            if nx < 0 or nx >= N or ny < 0 or ny >= M:
                continue
            if dist[nx][ny] == -1:
                dist[nx][ny] = dist[v[0]][v[1]] + 1
                que.append((nx, ny))

    for i in range(N):
        for j in range(M):
            ans = max(ans, dist[i][j])

    return ans

ans = bfs(graph, N, M)
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(_) for _ in stdin.readline().rstrip().split()]
V_c =V.copy()
C = [int(_) for _ in stdin.readline().rstrip().split()]
C_c =C.copy()
for i in range(N):
    if V[i]<C[i]:
        V_c.pop(i)
        C_c.pop(i)
print(sum(V_c)-sum(C_c))

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
V = [int(_) for _ in stdin.readline().rstrip().split()]
C = [int(_) for _ in stdin.readline().rstrip().split()]
ans=0
for i in range(N):
    if V[i]-C[i] > 0:
        ans+=V[i]-C[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from fractions import gcd
from functools import reduce
def gcd_list(numbers):
    return reduce(gcd, numbers)
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
set_A = set(A)
ans=0

for i in range(N):
    for j in set_A:
        tmp = gcd_list([j]+A[0:i]+A[i+1:])
        if tmp > ans:
            ans = tmp
print(ans)

Fixed submission:
from fractions import gcd
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
L=[0]
R=[0]
MAX=0
for i in range(N-1):
    L.append(gcd(L[i],A[i]))
    R.append(gcd(R[i],A[-1-i]))
for i in range(N):
    MAX=max(MAX,gcd(L[i],R[-1-i]))
print(MAX)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
minus = []
for i in range(N):
  if A[i] < 0:
    minus.append(A[i])
abs_A = (abs(i) for i in A)
if len(minus) % 2 == 0:
  print(sum(abs_A))
else:
  print(sum(abs_A)-min(abs_A)*2)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
minus = []
for i in range(N):
  if A[i] < 0:
    minus.append(A[i])
abs_A = [abs(i) for i in A]
if len(minus) % 2 == 0:
  print(sum(abs_A))
else:
  print(sum(abs_A)-min(abs_A)*2)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
s = list(stdin.readline().rstrip())
counts=[]
count=0
for i in s:
    if i in ['A','G','C','T']:
        count+=1
    else:
        counts.append(count)
        count=0
print(max(counts))

Fixed submission:
from sys import stdin
s = list(stdin.readline().rstrip())
counts=[]
count=0
for i in s:
    if i in ['A','G','C','T']:
        count+=1
        counts.append(count)
    else:
        count=0
        counts.append(count)
print(max(counts))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
n, q = [int(_) for _ in stdin.readline().rstrip().split()]
s = list(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)]
for d in data:
    l = [0]
    sub_s = s[d[0]-1:d[1]]
    sub_n = len(sub_s)
    for i in range(sub_n):
        l.append(l[i]+1 if i+1 < sub_n and sub_s[i] == 'A' and sub_s[i+1] == 'C' else l[i])
    print(l[-1])

Fixed submission:
from sys import stdin
n, q = [int(_) for _ in stdin.readline().rstrip().split()]
s = list(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)]
l = [0]
for i in range(n):
    l.append(l[i]+1 if i+1 < n and s[i] == 'A' and s[i+1] == 'C' else l[i])
for d in data:
    print(l[d[1]-1]-l[d[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
data = [stdin.readline().rstrip().split() for _ in range(q)]
data = [[int(i) for i in l] for l in data]
for d in data:
    sub=s[d[0]-1:d[1]]
    sub=sub.replace('T','').replace('G','')
    print(sub.count('AC'))

Fixed submission:
from sys import stdin
n, q = [int(_) for _ in stdin.readline().rstrip().split()]
s = list(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(q)]
l = [0]
for i in range(n):
    l.append(l[i]+1 if i+1 < n and s[i] == 'A' and s[i+1] == 'C' else l[i])
for d in data:
    print(l[d[1]-1]-l[d[0]-1])