Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
q = int(input())
p = [False]*(10**5)
c = [0]*(10**5)
temp = [True]*(N+1)
temp[0] = False
temp[1] = False
for i in range(2, 10**5):
  c[i] = c[i-1]
  if temp[i]:
    temp[2*i::i] = [False]*(len(temp[i+i::i]))
    if temp[(i+1)//2] and i%2:
      c[i] += 1

for _ in range(q):
  l, r = map(int, input().split())
  print(c[r] - c[l-1])

Fixed submission:
q = int(input())
p = [False]*(10**5)
c = [0]*(10**5)
temp = [True]*(10**5)
temp[0] = False
temp[1] = False
for i in range(2, 10**5):
  c[i] = c[i-1]
  if temp[i]:
    temp[2*i::i] = [False]*(len(temp[i+i::i]))
    if temp[(i+1)//2] and i%2:
      c[i] += 1

for _ in range(q):
  l, r = map(int, input().split())
  print(c[r] - c[l-1])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
if a+b > c+d:
  print("Left")
elif a+b < c+d:
  print("Right")
wlaw:
  print("Balanced")

Fixed submission:
a, b, c, d = map(int, input().split())
if a+b > c+d:
  print("Left")
elif a+b < c+d:
  print("Right")
else:
  print("Balanced")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
c = 0
for i in set(A):
  if A.count(i) >= i:
    c += A.count(i)-i
  else:
    c += A.count(i)
print(c)


Fixed submission:
import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
c = 0
temp = 0
for i in sorted(list(set(A))):
  d = bisect.bisect_right(A, i)
  if d-temp >= i:
    c += d-temp - i
  else:
    c += d-temp
  temp = d
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
c = 0
for i in set(A):
  if A.count(i) >= i:
    c += A.count(i)-i
  else:
    c += A.count(i)
print(c)

Fixed submission:
import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
c = 0
temp = 0
for i in sorted(list(set(A))):
  d = bisect.bisect_right(A, i)
  if d-temp >= i:
    c += d-temp - i
  else:
    c += d-temp
  temp = d
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
c = 0
while True:
  for i in A:
    if i%2:
      print(c)
      exit()
    i //= 2
    
  c += 1


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
c = 0
while True:
  for i in range(n):
    if A[i]%2:
      print(c)
      exit()
    A[i] //= 2
    
  c += 1

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
c = 0
while True:
  for i in A:
    if i%2:
      print(c)
      break
    i //= 2
    
  c += 1


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
c = 0
while True:
  for i in range(n):
    if A[i]%2:
      print(c)
      exit()
    A[i] //= 2
    
  c += 1

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
c = 0
while True:
  for i in range(n):
    if A[i]%2:
      print(c)
      break
    A[i] //= 2
    
  c += 1

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
c = 0
while True:
  for i in range(n):
    if A[i]%2:
      print(c)
      exit()
    A[i] //= 2
    
  c += 1

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
c = 0
while True:
  for i in A:
    if i%2:
      print(c)
      break
    i //= 2
    
  c += 1

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
c = 0
while True:
  for i in range(n):
    if A[i]%2:
      print(c)
      exit()
    A[i] //= 2
    
  c += 1
Buggy python submission (verdict: Runtime Error):
s = input()
if s[0]==s[1]=s[2] or s[1]==s[2]==s[3]:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
if s[0]==s[1]==s[2] or s[1]==s[2]==s[3]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
l = ["A", "B", "C", "D", "E", "F"]
a, b = map(int, input().split())
if l.index(a) < l.index(b):
  print("<")
elif l.index(a) > l.index(b):
  print(">")
else:
  print("=")

Fixed submission:
l = ["A", "B", "C", "D", "E", "F"]
a, b = map(str, input().split())
if l.index(a) < l.index(b):
  print("<")
elif l.index(a) > l.index(b):
  print(">")
else:
  print("=")
Buggy python submission (verdict: Time Limit Exceeded):
"""
dp[t][v] = 時刻tに速度vで走っている時の今までの走行距離の最大値
dp[0][0] = 0, dp[0][i] = -inf(i>0)
条件を考える
  dp[t][v]について、時刻tにおける速度の最大値をM(t)とすると、
  v >  M[t] -> dp[v][t] = -inf
  v <= M[t] -> dp[v][t] = max(dp[t-1][v+1]+(2*v+1)/2, dp[t-1][v]+v, dp[t-1][v-1]+(2*v-1)/2)
ans = max(dp[sum(T)])
"""
from itertools import accumulate
U = 300
n = int(input())
T = [0] + list(map(lambda x:int(x)*2, input().split()))
V = list(map(lambda x:int(x)*2, input().split())) + [0]
S = sum(T)
M = [0]*(S+1)
K = list(accumulate(T))
for i in range(n):
  for j in range(K[i]+1, K[i+1]):
    M[j] = V[i]
  M[K[i+1]] = min(V[i], V[i+1])
dp = [[-float("inf")]*(U+1) for _ in range(S+1)]
dp[0][0] = 0
for t in range(1, S+1):
  for v in range(U+1):
    if v > M[t]:
      continue
    dp[t][v] = dp[t-1][v] + v
    if v > 0:
      dp[t][v] = max(dp[t][v], dp[t-1][v-1]+(2*v-1)/2)
    if v < U:
      dp[t][v] = max(dp[t][v], dp[t-1][v+1]+(2*v+1)/2)
ans = max(dp[S]) / 4
print(ans)

Fixed submission:
"""
dp[t][v] = 時刻tに速度vで走っている時の今までの走行距離の最大値
dp[0][0] = 0, dp[0][i] = -inf(i>0)
条件を考える
  dp[t][v]について、時刻tにおける速度の最大値をM(t)とすると、
  v >  M[t] -> dp[v][t] = -inf
  v <= M[t] -> dp[v][t] = max(dp[t-1][v+1]+(2*v+1)/2, dp[t-1][v]+v, dp[t-1][v-1]+(2*v-1)/2)
ans = max(dp[sum(T)])
"""
from itertools import accumulate
U = 300
n = int(input())
T = [0] + list(map(lambda x:int(x)*2, input().split()))
V = list(map(lambda x:int(x)*2, input().split())) + [0]
S = sum(T)
M = [0]*(S+1)
K = list(accumulate(T))
for i in range(n):
  for j in range(K[i]+1, K[i+1]):
    M[j] = V[i]
  M[K[i+1]] = min(V[i], V[i+1])
dp = [[-float("inf")]*(U+1) for _ in range(S+1)]
dp[0][0] = 0
for t in range(1, S+1):
  for v in range(U+1):
    if v > M[t]:
      continue
    dp[t][v] = dp[t-1][v] + v
    if v > 0:
      dp[t][v] = max(dp[t][v], dp[t-1][v-1]+(2*v-1)/2)
    if v < U:
      dp[t][v] = max(dp[t][v], dp[t-1][v+1]+(2*v+1)/2)
ans = max(dp[S]) / 4
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))
for i in T:
  if i not in D:
    print("NO")
    exit()
  D.remove(i)
print("YES")

Fixed submission:
from collections import Counter
n = int(input())
D = Counter(input().split())
m = int(input())
T = Counter(input().split())
for i in T.keys():
  if i not in D or D[i] < T[i]:
    print("NO")
    exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)

C = [-1]*n
def is_bipartite(v, color):
  C[v] = color
  for nv in G[v]:
    if C[nv] != -1 and color == C[nv]:
      return False
    if C[nv] == -1:
      if not is_bipartite(nv, color ^ 1):
        return False
  return True

if is_bipartite(0, 0):
  b = C.count(0)
  w = n - b
  ans = b*w - m
else:
  ans = n*(n-1)//2 - m
print(ans)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)

C = [-1]*n
def is_bipartite(v, color):
  C[v] = color
  for nv in G[v]:
    if C[nv] != -1 and color == C[nv]:
      return False
    if C[nv] == -1:
      if not is_bipartite(nv, color ^ 1):
        return False
  return True

if is_bipartite(0, 0):
  b = C.count(0)
  w = n - b
  ans = b*w - m
else:
  ans = n*(n-1)//2 - m
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for h in range(1, 3500):
  for n in range(1, 3500):
    a = N*h*n
    b = 4*h*n - n*N - N*h
    if b > 0 and a%b == 0:
      print(h, n, a//b)
      exit()

Fixed submission:
N = int(input())
for h in range(1, 3500):
  for n in range(1, 3500):
    a = N*h*n
    b = 4*h*n - n*N - N*h
    if b > 0 and a%b == 0:
      print(h, n, a//b)
      exit()
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())
Swater, sugar, percent = 0, 0, 0
for k in range(F//(100*A) + 1):
  for l in range(F//(100*B) + 1):
    if k == 0 and l == 0:
      continue
    M = k*A + l*B
    if 100 * M > F:
      continue
    for x in range(M*E//C + 1):
      for y in range(M*E//D + 1):
        S = C*x + D*y
        if 100*M+S > F:
          continue
        if S > M*E:
          continue
        t = 100*S / (100*M+S)
        if t > percent:
          percent = t
          Swater = 100*M+S
          suger = S
print(Swater, suger)

Fixed submission:
A, B, C, D, E, F = map(int, input().split())
Swater, sugar, percent = 100*A, 0, 0
for k in range(F//(100*A) + 1):
  for l in range(F//(100*B) + 1):
    if k == 0 and l == 0:
      continue
    M = k*A + l*B
    if 100 * M > F:
      continue
    for x in range(M*E//C + 1):
      for y in range(M*E//D + 1):
        S = C*x + D*y
        if 100*M+S > F:
          continue
        if S > M*E:
          continue
        t = 100*S / (100*M+S)
        if t > percent:
          percent = t
          Swater = 100*M+S
          sugar = S
print(Swater, sugar)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for s in range(n):
  for g in range(n):
    b = 0
    for via in range(n):
      if A[s][g] > A[s][via] + A[via][g]:
        print(-1)
        exit()
      if A[s][g] == A[s][via] + A[via][g]:
        b += 1
    if b == 2:
      ans += A[s][g]
print(ans//2)

Fixed submission:
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for s in range(n):
  for g in range(n):
    b = 0
    for via in range(n):
      if A[s][g] > A[s][via] + A[via][g]:
        print(-1)
        exit()
      if A[s][g] == A[s][via] + A[via][g]:
        b += 1
    if b == 2:
      ans += A[s][g]
print(ans//2)
Buggy python submission (verdict: Runtime Error):
if 9 in input():
  print("Yes")
else:
  print("No")

Fixed submission:
if "9" in input():
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

x = int(input())
k = int(input())
R = [(_r, i%2) for i, _r in enumerate(map(int, input().split()))]
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]
T, A = zip(*TA)
L = [None]*n
b = 0
for i, t in enumerate(T, 1):
  R.append((t, -i))
R.sort()
dx = 1
l, r, p, q = 0, x, 0, x
for _r, i in R:
  d = _r-b
  b = _r
  if dx == 1:
    if d <= p:
      p -= d
      q -= d
    elif d < q:
      q -= d
      l = r-q
      p = 0
    else:
      l = 0
      r = 0
      p = 0
      q = 0
  else:
    if d <= x-q:
      p += d
      q += d
    elif d < x-p:
      p += d
      r = l+(x-p)
      q = x
    else:
      l = x
      r = x
      p = x
      q = x
  if i >= 0:
    dx = i
  else:
    a = A[-i-1]
    if a < l:
      res = p
    elif a <= r:
      res = (a-l)+p
    else:
      res = q
    L[-i-1] = res
print(*L, sep="\n")

Fixed submission:
import sys
input = sys.stdin.readline

x = int(input())
k = int(input())
R = [(_r, i%2) for i, _r in enumerate(map(int, input().split()))]
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]
T, A = zip(*TA)
L = [None]*n
b = 0
for i, t in enumerate(T, 1):
  R.append((t, -i))
R.sort()
dx = 1
l, r, p, q = 0, x, 0, x
for _r, i in R:
  d = _r-b
  b = _r
  if dx == 1:
    if d <= p:
      p -= d
      q -= d
    elif d < q:
      q -= d
      l = r-q
      p = 0
    else:
      l = 0
      r = 0
      p = 0
      q = 0
  else:
    if d <= x-q:
      p += d
      q += d
    elif d < x-p:
      p += d
      r = l+(x-p)
      q = x
    else:
      l = x
      r = x
      p = x
      q = x
  if i >= 0:
    dx = i
  else:
    a = A[-i-1]
    if a < l:
      res = p
    elif a <= r:
      res = (a-l)+p
    else:
      res = q
    L[-i-1] = res
print(*L, sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

n = int(input())
l = [[0]*n for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  l[a-1][b-1] = c
  l[b-1][a-1] = c
csr = csr_matrix(l)
q, k = map(int, input().split())
A = dijkstra(csr, indices=k-1)
for _ in range(q):
  x, y = map(int, input().split())
  print(int(A[x-1] + A[y-1]))

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n = int(input())
l = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  l[a-1].append([b-1, c])
  l[b-1].append([a-1, c])
q, k = map(int, input().split())
dist = [-1]*n
dist[k-1] = 0
def dfs(v):
  for nv, c in l[v]:
    if dist[nv] == -1:
      dist[nv] = dist[v]+c
      dfs(nv)
dfs(k-1)
for _ in range(q):
  x, y = map(int, input().split())
  print(dist[x-1] + dist[y-1])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = float("inf")
for i in range(n-1):
  c = min(c, a[i+1]-a[i])
  if c == 1:
    break
if k > a[-1]:
  print("IMPOSSIBLE")
else:
  kr = k%c
  for i in a:
    if kr == i%c:
      print("POSSIBLE")
      exit()
  print("IMPOSSIBLE")


Fixed submission:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = float("inf")
for i in range(n-1):
  if a[i] == a[i+1]:
    continue
  else:
    c = min(c, a[i+1]-a[i])
    if c == 1:
      break
if k > a[-1]:
  print("IMPOSSIBLE")
else:
  kr = k%c
  for i in a:
    if kr == i%c:
      print("POSSIBLE")
      exit()
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = float("inf")
for i in range(n-1):
  c = min(c, a[i+1]-a[i])
  if c == 1:
    break
if k > a[-1]:
  print("IMPOSSIBLE")
else:
  kr = k%c
  for i in a:
    if kr == i%c:
      print("POSSIBLE")
      exit()
  print("IMPOSSIBLE")

Fixed submission:
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = float("inf")
for i in range(n-1):
  if a[i] == a[i+1]:
    continue
  else:
    c = min(c, a[i+1]-a[i])
    if c == 1:
      break
if k > a[-1]:
  print("IMPOSSIBLE")
else:
  kr = k%c
  for i in a:
    if kr == i%c:
      print("POSSIBLE")
      exit()
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
E = B - A
for m in range(N):
  if C*(N-1-m) - D*m <= E <= -C*m + (N-1-m)*D:
    print("YES")
    break
else
print("NO")

Fixed submission:
N, A, B, C, D = map(int, input().split())
E = B - A
for m in range(N):
  if C*(N-1-m) - D*m <= E <= -C*m + (N-1-m)*D:
    print("YES")
    break
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
import sys
n=int(input())
sys.setrecursionlimit(n)
T=[[]for _ in"_"*(n+1)]
for _ in range(n-1):a,b=map(int,input().split());T[a]+=b,;T[b]+=a,
def d(v,p):
 r=0
 for s in T[v]:
  if s!=p:r^=d(s,v)+1
 return r
print("ABloibc e"[d(1,1)<1::2])

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
def dfs(v, par=-1):
  res = 0
  for nv in T[v]:
    if nv == par:
      continue
    res ^= dfs(nv, v)+1
  return res
if dfs(0) == 0:
  print("Bob")
else:
  print("Alice")

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(k:=2*n)
n=int(input())
T=[[]for _ in"_"*k]
for _ in range(n-1):a,b=map(int,input().split());T[a]+=b,;T[b]+=a,
def d(v,p):
 r=0
 for s in T[v]:
  if s!=p:r^=d(s,v)+1
 return r
print("ABloibc e"[d(1,1)<1::2])

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
def dfs(v, par=-1):
  res = 0
  for nv in T[v]:
    if nv == par:
      continue
    res ^= dfs(nv, v)+1
  return res
if dfs(0) == 0:
  print("Bob")
else:
  print("Alice")
Buggy python submission (verdict: Runtime Error):
from collections import Counter

U = 10**5
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
    
def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z
  
n = int(input())
A = list(map(int, input().split()))
x = Counter(A).most_common()[0][0]
left = A.index(x)
right = A[::-1].index(x)
print(n)
for k in range(2, n+2):
  ans = comb(n+1, k) - comb(left+right, k-1)
  ans %= MOD
  print(ans)

Fixed submission:
from collections import Counter

U = 10**5+1
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
    
def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z
  
n = int(input())
A = list(map(int, input().split()))
x = Counter(A).most_common()[0][0]
left = A.index(x)
right = A[::-1].index(x)
print(n)
for k in range(2, n+2):
  ans = comb(n+1, k) - comb(left+right, k-1)
  ans %= MOD
  print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [ int(input()) for i in range(n) ]
c = 0
temp = 1
s = {1}
while temp not in s:
  temp = A[temp-1]
  c += 1
  i temp == 2:
    print(c)
    exit()
  s.add(temp)
print(-1)

  

Fixed submission:
n = int(input())
A = [ int(input()) for i in range(n) ]
c = 0
temp = 1
s = set()
while temp not in s:
  s.add(temp)
  temp = A[temp-1]
  c += 1
  if temp == 2:
    print(c)
    exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
  N, constW = map(int, input().split())
  WV = [list(map(int, input().split())) for _ in range(N)]
  W0 = WV[0][0]
  L = [[] for _ in range(4)]
  for w, v in WV:
    w -= W0
    L[w].append(v)
  L[0].sort(reverse=True)
  L[1].sort(reverse=True)
  L[2].sort(reverse=True)
  L[3].sort(reverse=True)
  ans = 0
  for i in range(1, constW//W0 + 1):
    rest = constW - i*W0
    for j in range(min(rest//3, i) + 1):
      rest1 = rest - 3*j
      for k in range(min(rest1//2, i-j) + 1):
        rest2 = rest1 - 2*k
        for l in range(min(rest2, i-j-k) + 1):
          temp = sum(L[3][:j]) + sum(L[2][:k]) + sum(L[1][:l]) + sum(L[0][:i-j-k-l])
          ans = max(ans, temp)
  print(ans)

if __name__ == "__main__":
  main()

Fixed submission:
N, constW = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]
W0 = WV[0][0]
L = [[] for _ in range(4)]
for w, v in WV:
  w -= W0
  L[w].append(v)
L[0].sort(reverse=True)
L[1].sort(reverse=True)
L[2].sort(reverse=True)
L[3].sort(reverse=True)
ans = 0
for i in range(1, constW//W0 + 1):
  rest = constW - i*W0
  for j in range(min(rest//3, i) + 1):
    rest1 = rest - 3*j
    for k in range(min(rest1//2, i-j) + 1):
      rest2 = rest1 - 2*k
      for l in range(min(rest2, i-j-k) + 1):
        temp = sum(L[3][:j]) + sum(L[2][:k]) + sum(L[1][:l]) + sum(L[0][:i-j-k-l])
        ans = max(ans, temp)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(str.upper(a[0]+b[0]+c[0]))

Fixed submission:
a, b, c = map(str, input().split())
print(str.upper(a[0]+b[0]+c[0]))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
seen = [False]*n
def dfs(v, rep):
  seen[v] = True
  for nv in G[v]:
    if seen[nv]:
      continue
    rep.append(nv+1)
    dfs(nv, rep)
    break
  else:
    return rep
L1, L2 = [], []
dfs(0, L1)
dfs(0, L2)
ANS = L2[::-1] + [1] + L1
print(len(ANS))
print(*ANS)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
seen = [False]*n
def dfs(v, rep):
  seen[v] = True
  for nv in G[v]:
    if seen[nv]:
      continue
    rep.append(nv+1)
    dfs(nv, rep)
    break
  else:
    return rep
L1, L2 = [], []
dfs(0, L1)
dfs(0, L2)
ANS = L2[::-1] + [1] + L1
print(len(ANS))
print(*ANS)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(n):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
seen = [False]*n
def dfs(v, rep):
  seen[v] = True
  for nv in G[v]:
    if seen[nv]:
      continue
    rep.append(nv+1)
    dfs(nv, rep)
    break
  else:
    return rep
L1, L2 = [], []
dfs(0, L1)
dfs(0, L2)
ANS = L2[::-1] + [1] + L1
print(len(ANS))
print(*ANS)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
seen = [False]*n
def dfs(v, rep):
  seen[v] = True
  for nv in G[v]:
    if seen[nv]:
      continue
    rep.append(nv+1)
    dfs(nv, rep)
    break
  else:
    return rep
L1, L2 = [], []
dfs(0, L1)
dfs(0, L2)
ANS = L2[::-1] + [1] + L1
print(len(ANS))
print(*ANS)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(n):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
seen = [False]*n
def dfs(v, rep):
  seen[v] = True
  for nv in G[v]:
    if seen[nv]:
      continue
    rep.append(nv+1)
    dfs(nv, rep)
    break
  else:
    return rep
L1, L2 = [], []
dfs(0, L1)
dfs(0, L2)
ANS = L2[::-1] + [1] + L1
print(len(ANS))
print(*ANS)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
seen = [False]*n
def dfs(v, rep):
  seen[v] = True
  for nv in G[v]:
    if seen[nv]:
      continue
    rep.append(nv+1)
    dfs(nv, rep)
    break
  else:
    return rep
L1, L2 = [], []
dfs(0, L1)
dfs(0, L2)
ANS = L2[::-1] + [1] + L1
print(len(ANS))
print(*ANS)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, l, t = map(int, input().split())
XW = [list(map(int, input().split())) for _ in range(n)]
L = []
for i, xw in enumerate(XW):
  x, w = xw
  if w == 1:
    L.append((x+t)%l)
  else:
    L.append((x-t)%l)
L.sort()
x_0, w_0 = XW[0]
b = 0
for x, w in XW[1:]:
  if w_0 == w:
    continue
  if w_0 == 1:
    if x-x_0 > 2*t:
      continue
    b += 1 + (2*t - (x-x_0)) // l
  else:
    if l-(x-x_0) > 2*t:
      continue
    b -= 1 + (2*t - (l-(x-x_0))) // l
m = L.index(L[b])
for i in range(m, m+n):
  print(L[i%n])

Fixed submission:
import sys
input = sys.stdin.readline

n, l, t = map(int, input().split())
XW = [list(map(int, input().split())) for _ in range(n)]
L = []
cnt = 0
for i, xw in enumerate(XW):
  x, w = xw
  L.append((x+t*(3-2*w))%l)
  cnt += (x+t*(3-2*w))//l
L.sort()
for i in range(cnt, cnt+n):
  print(L[i%n])