Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#入力。参加者数N, 初期得点K ,正解数Q
N, K, Q = list(map(int,input().split()))
#入力。正解した人の番号A[i]
A = [None for _ in range(Q)]
for i in range(Q):
  A[i] = int(input())
#初期得点(hp)をリスト化。
hp = [K for _ in range(N)]
#まず他の人への攻撃力at(各人の正解数)を記録。
at = [0 for _ in range(N)]
#正解した人の攻撃力+1。
for i in range(Q):
  j = A[i]
  at[j-1] += 1
#攻撃力分の数を一度全員のhpからマイナスする。
for i in range(N):
  hp[i] -= sum(at)
#各々自分の攻撃力分は本来受けないはずのダメージなのでhpに戻す(足す)。
for i in range(N):
  hp[i] += at[i]
#結果(生き残り判定)
for i in range(N):
  if hp[i] > 0:
    print('Yes')
  else:
    print('No')

Fixed submission:
#入力。参加者数N, 初期得点K ,正解数Q
N, K, Q = list(map(int,input().split()))
#入力。正解した人の番号A[i]
A = [None for _ in range(Q)]
for i in range(Q):
  A[i] = int(input())
#初期得点(hp)をリスト化。
hp = [K for _ in range(N)]
#まず他の人への攻撃力at(各人の正解数)を記録。
at = [0 for _ in range(N)]
#正解した人の攻撃力+1。
for i in range(Q):
  j = A[i]
  at[j-1] += 1
#攻撃力分の数を一度全員のhpからマイナスする。
s = sum(at)
for i in range(N):
  hp[i] -= s
#各々自分の攻撃力分は本来受けないはずのダメージなのでhpに戻す(足す)。
for i in range(N):
  hp[i] += at[i]
#結果(生き残り判定)
for i in range(N):
  if hp[i] > 0:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S = int(input())
ls = list(str(S))
if ls[0] == ls[1] or ls[1] == ls[2] or ls[2] == ls[3]:
  print('Bad')
else:
  print('Good')

Fixed submission:
#数字でも文字列として扱える。intにすると左一桁目から0がある場合存在しないものとなるので注意
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
  print('Bad')
else:
  print('Good')

Buggy python submission (verdict: Runtime Error):
S = int(input())
ls = list(S)
if ls[0] == ls[1] or ls[1] == ls[2] or ls[2] == ls[3]:
  print('Bad')
else:
  print('Good')

Fixed submission:
#数字でも文字列として扱える。intにすると左一桁目から0がある場合存在しないものとなるので注意
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
  print('Bad')
else:
  print('Good')

Buggy python submission (verdict: Runtime Error):
S = int(input())
ls = list(S)
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
  print('Bad')
else:
  print('Good')

Fixed submission:
#数字でも文字列として扱える。intにすると左一桁目から0がある場合存在しないものとなるので注意
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
  print('Bad')
else:
  print('Good')
Buggy python submission (verdict: Runtime Error):
if input() == 'A':
  print('T')
elif input() == 'T':
  print('A')
elif input() == 'C':
  print('G')
else:
  print('C')

Fixed submission:
s = input()
if s == 'A':
  print('T')
elif s == 'T':
  print('A')
elif s == 'C':
  print('G')
else:
  print('C')
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int,input().split()))
h = [None for _ in range(N)]
MIN = float('inf')
for i in range(N):
  h[i] = int(input())
H = sorted(h)
for i in range(N-2):
  if MIN >= H[i+(K-1)] - H[i]:
    MIN = H[i+(K-1)] - H[i]
print(MIN)

Fixed submission:
N, K = list(map(int,input().split()))
h = [None for _ in range(N)]
MIN = float('inf')
for i in range(N):
  h[i] = int(input())
H = sorted(h)
for i in range(N-(K-1)):
  if MIN >= H[i+(K-1)] - H[i]:
    MIN = H[i+(K-1)] - H[i]
print(MIN)
Buggy python submission (verdict: Runtime Error):
N,T = list(map(int,input().split()))
c = [None for _ in range(N)]
t = [None for _ in range(N)]
A = [None for _ in range(N)]
for i in range(N):
  c[i], t[i] = input().split()
  c[i] = int(c[i])
  t[i] = int(t[i])
for i in range(N):
  if t[i] <= T:
    A[i] = c[i]
A = [a for a in A if type(a) != 'Nonetype']
A = sorted(A)
ans = A[0]
print(ans)

Fixed submission:
N, T = list(map(int,input().split()))
c = [0 for i in range(N)]
t = [0 for i in range(N)]
for i in range(N):
  c[i], t[i] = input().split()
  c[i] = int(c[i])
  t[i] = int(t[i])

ans = float('inf')
for i in range(N):
  if t[i] <= T and c[i] < ans:
    ans = c[i]
if ans == float('inf'):
  print('TLE')
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
def dfs(i, sum, count, unsolve):
 global ans
 if i == D:
  #G点に満たなければunsolveのうち最も大きいものを解く
  if sum < G:
   use = max(unsolve)
  #解く問題が問題数を超えないようにする
   N = min(pc[use-1][0], -(-(g-sum)//(100*use)))
   count += N 
   sum += N * 100 * use
  if sum > G:
   ans = min(ans, count)
 else:
 dfs(i + 1, sum, count, unsolve)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], unsolve - {i + 1})

d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]
ans = float("inf")
dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

Fixed submission:
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100))) #ムダに-演算子を重ねているのは切り上げしたいから
            count += n
            sum += n * use * 100
        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]
ans = float("inf")
dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()

if N % 2 == 0:
  print(int(N))
else:
  print(int(2*N))

Fixed submission:
N = int(input())
 
if N % 2 == 0:
  print(int(N))
else:
  print(int(2*N))

Buggy python submission (verdict: Runtime Error):
n = input()
A = list(map(int, input().split()))
print(int(max(A)) - int(min(A)))

Fixed submission:
N = int(input())
 
if N % 2 == 0:
  print(int(N))
else:
  print(int(2*N))

Buggy python submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split()))
print(int(max(A)) - int(min(A)))

Fixed submission:
N = int(input())
 
if N % 2 == 0:
  print(int(N))
else:
  print(int(2*N))

Buggy python submission (verdict: Runtime Error):
n = input()
A = list(map(int, input().split()))
print(int(max(A))-int(min(A)))

Fixed submission:
N = int(input())
 
if N % 2 == 0:
  print(int(N))
else:
  print(int(2*N))
Buggy python submission (verdict: Runtime Error):
n = input()
A = list(map(int, input().split())
print(int(max(A))-int(min(A)))

Fixed submission:
n = input()
A = list(map(int, input().split()))
print(int(max(A)) - int(min(A)))

Buggy python submission (verdict: Runtime Error):
N = input()
A = [int(i) for input().split()]
int(max) = 0
int(min) = 0
for i in N:
  if int(max) < A[i]:
    max = A[i]
for i in N:
  if int(min) > A[i]:
    min = A[i]

abs = max - min
print(int(abs))

Fixed submission:
n = input()
A = list(map(int, input().split()))
print(int(max(A)) - int(min(A)))
Buggy python submission (verdict: Runtime Error):
def abs(k):
  if k >= 0:
    return k
  else:
    return -k
  
def main():
  a, b, c ,n = list(map(int,input().split()))
  i for i in range(n):
    a = b + c
    b = c + a 
    c = a + b
  res = a - b
  if abs(res) > 10 ** 18:
    print('Unfair')
  else:
    print(res)

Fixed submission:
A, B, C, K = map(int, input().split())
print(A - B if K % 2 == 0 else B - A)

Buggy python submission (verdict: Runtime Error):
def abs(k):
  if k >= 0:
    return k
  else:
    return -k

a, b, c ,n = list(map(int,input().split()))
i for i in range(n):
  a = b + c
  b = c + a 
  c = a + b
res = a - b
if abs(res) > 10 ** 18:
  print('Unfair')
else:
  print(res)

Fixed submission:
A, B, C, K = map(int, input().split())
print(A - B if K % 2 == 0 else B - A)
Buggy python submission (verdict: Runtime Error):
s=input()
n=0
for s in a:
  if a=='o':
    n+=100
sum = 700+n
print(sum)

Fixed submission:
s=input()
n=0
for a in s:
  if a=='o':
    n+=100
sum = 700+n
print(sum)
Buggy python submission (verdict: Runtime Error):
A, B, C, X = [int(input()) for i in range(4)]
count = 0
if 500*a + 100*b + 50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1):
  count += 1
print(count)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
print(sum(500*a+100*b+50*c==X for a in range(A+1) for b in range(B+1) for c in range(C+1)))

Buggy python submission (verdict: Runtime Error):
A, B, C, X = [for i in range(4) int(input())]
count = 0
if 500*a + 100*b + 50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1):
  count += 1
print(count)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
print(sum(500*a+100*b+50*c==X for a in range(A+1) for b in range(B+1) for c in range(C+1)))

Buggy python submission (verdict: Runtime Error):
for i in range(4):
   A, B, C, X = int(input())
count = 0
if 500*a + 100*b + 50*c == X for a in range(A+1) for b for range(B+1) for c in range(C+1):
  count += 1
print(count)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
print(sum(500*a+100*b+50*c==X for a in range(A+1) for b in range(B+1) for c in range(C+1)))

Buggy python submission (verdict: Runtime Error):
i for range(4):
  A, B, C, X = [int(input())]
count = 0
if 500*a + 100*b +50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1):
  count += 1
print(count)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
print(sum(500*a+100*b+50*c==X for a in range(A+1) for b in range(B+1) for c in range(C+1)))

Buggy python submission (verdict: Runtime Error):
A, B, C, X = [int(input()) for i in range(4)]
print(sum(500*a + 100*b + 50*c == X for a in range(A+1) and b in range(B+2) and c in range(C+1)))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
print(sum(500*a+100*b+50*c==X for a in range(A+1) for b in range(B+1) for c in range(C+1)))

Buggy python submission (verdict: Runtime Error):
A, B, C, X = [int(input()) for i in range(4)]
print(sum(500a + 100b + 50c == X for a in range(A+1) and b in range(B+2) and c in range(C+1)))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
print(sum(500*a+100*b+50*c==X for a in range(A+1) for b in range(B+1) for c in range(C+1)))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 積の計算と余りの判別
mod = (b*c)%2
# 出力
if(mod==0)
	print('Even')
else
	print('Odd')

Fixed submission:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
b, c = map(int, input().split())
#席の余り
mod =  (b*c)%2
# 出力
if mod == 0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
N, Y = int(input().split())
ans = [-1,-1,-1]
for x in range(N+1):
  for y in range(N+1):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      ans[0] = x
      ans[1] = y
      ans[2] = z
print(ans[0],ans[1],ans[2])

Fixed submission:
N, Y = map(int, input().split())
 
ans = [-1,-1,-1]
for x in range(0,N+1):
    for y in range(0,N-x+1):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y:
            ans[0] = x
            ans[1] = y
            ans[2] = z
print(ans[0],ans[1],ans[2])

Buggy python submission (verdict: Runtime Error):
N, Y = int(input().split())
ans = [-1,-1,-1]
for x in range(N+1):
  for y in range(N+1):
    z = N - x - y
    if 10000 * x + 5000 * y + 1000 * z == Y:
      ans[0] = x
      ans[1] = y
      ans[2] = z
print(ans)

Fixed submission:
N, Y = map(int, input().split())
 
ans = [-1,-1,-1]
for x in range(0,N+1):
    for y in range(0,N-x+1):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y:
            ans[0] = x
            ans[1] = y
            ans[2] = z
print(ans[0],ans[1],ans[2])

Buggy python submission (verdict: Runtime Error):
N, Y = int(input().split())
if 10000*a + 5000*b +1000*c == Y for a in range(N + 1) for b in range(N + 1) for c in range(N + 1):
  print('{}{}{}', a,b,c)
else:
  print('{}{}{}',-1,-1,-1)

Fixed submission:
N, Y = map(int, input().split())
 
ans = [-1,-1,-1]
for x in range(0,N+1):
    for y in range(0,N-x+1):
        z = N - x - y
        if x*10000 + y*5000 + z*1000 == Y:
            ans[0] = x
            ans[1] = y
            ans[2] = z
print(ans[0],ans[1],ans[2])
Buggy python submission (verdict: Runtime Error):
N , A, B = int(input().split())
S = str(N)
count = 0
s for a in S:
  s = [a for a in S]
i for i in range(S):
  Ns = sum(s[i])
if A <= Ns <= B:
  count += N
print(count)

Fixed submission:
N, A, B = list(map(int, input().split()))
print(sum(i for i in range(1,N+1) if A<=sum(map(int,str(i)))<=B))

Buggy python submission (verdict: Runtime Error):
N, A, B = list(map(int,input().split()))
res = 0
for i in range(N+1):
  if A <= sum(int(s) for s in str(s)) <= B:
    res += i
print(res)

Fixed submission:
N, A, B = list(map(int, input().split()))
print(sum(i for i in range(1,N+1) if A<=sum(map(int,str(i)))<=B))

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

Fixed submission:
N, A, B = list(map(int, input().split()))
print(sum(i for i in range(1,N+1) if A<=sum(map(int,str(i)))<=B))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# スペース区切りでの入力
a, b = map(int,input().split)
#平均値の計算
ave = float((a+b)/2)
#数字の切り上げ
N = round(ave)
print({},"N")

Fixed submission:
a,b = map(int,input().split())
x = -(-(a+b)//2)
print(x)
Buggy python submission (verdict: Runtime Error):
s = map(int, input().split())
n = 0
i = 0
cout = 0
for i in s:
  if s[i] % 2 == 0:
    cout += 1
  else:
    cout += 0
print(cout)

Fixed submission:
s = input()
n = 0
for a in s:
  if a =='1':
    n += 1
print(n)
Buggy python submission (verdict: Runtime Error):
n = input()
A = list(map(int,input().split()))
count = 0
while all(a % 2 == 0 for a in A):
  A = [a/2]
  count += 1
print(count)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
i = 0
odd = 0
while odd == 0:
    for n in range(N):
        if a[n] % 2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
while a % 2 == 0 in A:
  a /= 2
  count += 1
print(count)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
i = 0
odd = 0
while odd == 0:
    for n in range(N):
        if a[n] % 2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
  A = [a / 2]
  count += 1
print(count)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
i = 0
odd = 0
while odd == 0:
    for n in range(N):
        if a[n] % 2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
for i in input().split():
  if A[i] % 2 == 0:
    A[i] /= 2
  else:
    print(int(A[i]))

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
i = 0
odd = 0
while odd == 0:
    for n in range(N):
        if a[n] % 2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)

Buggy python submission (verdict: Runtime Error):
s = map(int(input().split()))
n = 0
i = 0
cout = 0
for i in s:
  if s[i] % 2 == 0:
    cout += 1
  else:
    cout += 0
print(cout)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
 
i = 0
odd = 0
while odd == 0:
    for n in range(N):
        if a[n] % 2 == 0:
            a[n] /= 2
        else:
            odd = 1
            break
    if odd == 0:
        i += 1
print(i)
Buggy python submission (verdict: Runtime Error):
N = input()
op_cnt = len(N) - 1 #隙間の個数
for i in range(2 ** op_cnt):
     op = ['-'] * op_cnt #とりあえず演算子は-を3つとしておく
     for j in range(op_cnt):
          if((i >> j) | 1):
               

Fixed submission:
a = list(input())
 
sign = "+-"
 
for i in range(2):  #1つめの正負
 for j in range(2):  #2つ目の正負
  for k in range(2):  #3つ目の正負
    if eval(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3] ) == 7:
     print(str(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3])+'=7')
     exit()

Buggy python submission (verdict: Runtime Error):
a = int(input())
a = list(str(a))

sign = "+-"

for i in range(2):  #1つめの正負
 for j in range(2):  #2つ目の正負
  for k in range(2):  #3つ目の正負
    if eval(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3] ) == 7:
     print(str(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3])+'=7')

Fixed submission:
a = list(input())
 
sign = "+-"
 
for i in range(2):  #1つめの正負
 for j in range(2):  #2つ目の正負
  for k in range(2):  #3つ目の正負
    if eval(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3] ) == 7:
     print(str(a[0]+sign[i]+a[1]+sign[j]+a[2]+sign[k]+a[3])+'=7')
     exit()
Buggy python submission (verdict: Runtime Error):
s = input()
a = len(s)-2
print(s[0]+a+s[len(s)-1])

Fixed submission:
n,m = list(map(int,input().split()))
print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
N ,K = map(int, input().split())
L = list(map(int, input().split()))
snake = 0
for i in range(K+1):
  snake += L[i]
print(snake)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
snake=0
for i in range(k):
  snake+=l[i]
print(snake)

Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
L = llst(map(int, input().split()))
sort.L(reverse = True)
print(sum(l in L for k in range(K+1)))

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
snake=0
for i in range(k):
  snake+=l[i]
print(snake)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = list(map(int,input().split()))
count = 0
for X in range(K+1):
  for Y in range(K+1):
    for Z in range(K+1):
      if X + Y + Z == S:
        count += 1
print(count)

Fixed submission:
K, S = list(map(int,input().split()))
count = 0
#ZはXとYが決まった時点で自動的に決まる。
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y 
#範囲が条件ないならOK
    if 0 <= Z and Z <= K:
        count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
K, S = list(map(int,input().split()))
count = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if X + Y + Z == S:
        count += 1
print(count)

Fixed submission:
K, S = list(map(int,input().split()))
count = 0
#ZはXとYが決まった時点で自動的に決まる。
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y 
#範囲が条件ないならOK
    if 0 <= Z and Z <= K:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
    s = input()
    ans = ''
    for i in range(len(s)):
        if s[i] == '0':
            ans += '0'
            
        elif s[i] == '1':
            ans += '1'
            
        else:
            if ans != '':
                ans = ans[:-1]
                
    print(ans)

Fixed submission:
s = input()
ans = ''
for i in range(len(s)):
	if s[i] == '0':
		ans += '0'    
	elif s[i] == '1':
		ans += '1'    
	else:
		if ans != '':
			ans = ans[:-1]    
print(ans)

Buggy python submission (verdict: Runtime Error):
ans = []
a = list(input())
for i in range(len(a)):
	if(a[i] == '1'):
		ans.append('1')
	elif(a[i] == '0'):
		ans.append('0')
	elif(a[i] == 'B'):
		ans.pop()
print(''.join(ans))

Fixed submission:
s = input()
ans = ''
for i in range(len(s)):
	if s[i] == '0':
		ans += '0'    
	elif s[i] == '1':
		ans += '1'    
	else:
		if ans != '':
			ans = ans[:-1]    
print(ans)

Buggy python submission (verdict: Runtime Error):
ans = []
a = list(input())
for i in range(len(a)):
	if(a[i] == '1'):
		ans.append('1')
	elif(a[i] == '0'):
		ans.append('0')
	elif(a[i] == 'B'):
		ans.pop()
print(''.join(ans))

Fixed submission:
s = input()
ans = ''
for i in range(len(s)):
	if s[i] == '0':
		ans += '0'    
	elif s[i] == '1':
		ans += '1'    
	else:
		if ans != '':
			ans = ans[:-1]    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())

def yakusu(n):
    a = []
    for i in range(1, int(math.sqrt(2*n))+2):
        if(2*n % i == 0):
            a.append(i)
    for i in range(len(a)):
        a.append(2*n // a[i])
    return sorted(list(set(a)))

def exgcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = exgcd(b % a, a)
        return g, x - (b // a) * y, y
    
def CRT(b1, m1, b2, m2):
    # 中国剰余定理
    # x ≡ b1 (mod m1) ∧ x ≡ b2 (mod m2) <=> x ≡ r (mod m)
    # となる(r. m)を返す
    # 解無しのとき(0, -1)
    d, p, q = exgcd(m1, m2)
    if (b2 - b1) % d != 0:
        return 0, -1
    m = m1 * (m2 // d)  # m = lcm(m1, m2)
    tmp = (b2-b1) // d * p % (m2 // d)
    r = (b1 + m1 * tmp) % m
    return r, m
x = yakusu(n)
a = 1e16
for i in range(len(x)):
    r, m = CRT(-1, 2*n//x[i], 0, x[i])
    if(r > 0):
        a = min(a, r)
print(a)

Fixed submission:
import math
n = int(input())

def yakusu(n):
    a = []
    for i in range(1, int(math.sqrt(2*n))+2):
        if(2*n % i == 0):
            a.append(i)
    for i in range(len(a)):
        a.append(2*n // a[i])
    return sorted(list(set(a)))

def exgcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = exgcd(b % a, a)
        return g, x - (b // a) * y, y
    
def CRT(b1, m1, b2, m2):
    # 中国剰余定理
    # x ≡ b1 (mod m1) ∧ x ≡ b2 (mod m2) <=> x ≡ r (mod m)
    # となる(r. m)を返す
    # 解無しのとき(0, -1)
    d, p, q = exgcd(m1, m2)
    if (b2 - b1) % d != 0:
        return 0, -1
    m = m1 * (m2 // d)  # m = lcm(m1, m2)
    tmp = (b2-b1) // d * p % (m2 // d)
    r = (b1 + m1 * tmp) % m
    return r, m
x = yakusu(n)
a = 1e16
for i in range(len(x)):
    r, m = CRT(-1, 2*n//x[i], 0, x[i])
    if(r > 0):
        a = min(a, r)
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n, x, m = map(int, input().split())
def am(a, b):
    return (a * a) % b
l = [x]
u = []
now = x
for i in range(n):
    s = am(now, m)
    if(s in l):
        break
    l.append(s)
    now = s
c = l.index(s)
k = 0
if(0 in l):
    print(sum(l))
else:
    for i in range(c):
        u.append(l.pop(0))
    a = (n-len(u)) // len(l)
    b = (n-len(u)) % len(l)
    print(sum(u) + a * sum(l) + sum(l[:b]))

Fixed submission:
n, x, m = map(int, input().split())
def am(a, b):
    return (a * a) % b
l = [x]
u = []
now = x
for i in range(n):
    s = am(now, m)
    if(s in l):
        break
    l.append(s)
    now = s
c = l.index(s)
k = 0
if(0 in l):
    print(sum(l))
else:
    for i in range(c):
        u.append(l.pop(0))
    a = (n-len(u)) // len(l)
    b = (n-len(u)) % len(l)
    print(sum(u) + a * sum(l) + sum(l[:b]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
print((10**n-9**n*2+8**n)%(1e9+7))

Fixed submission:
n = int(input())
print((10**n-2*9**n+8**n)%1000000007)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = sorted(b, reverse=True)
ans = 0
for i in range(n):
    ans += b[(i+1)//2]
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = sorted(a, reverse=True)
ans = 0
for i in range(n-1):
    ans += b[(i+1)//2]
print(ans)
Buggy python submission (verdict: Runtime Error):
x, y = int(map, input().split())

if(2*x <= y <= 4*x and y%2==0 and x <= 50):
    print("Yes")
else:
    print("No")

Fixed submission:
x, y = map(int, input().split())

if(2*x <= y <= 4*x and y%2==0 and x <= 50):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
x, y = int(map, input().split())

if((2*x <= y <= 4*x) and (y%2==0)):
    print("Yes")
else:
    print("No")


Fixed submission:
x, y = map(int, input().split())

if(2*x <= y <= 4*x and y%2==0 and x <= 50):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
x, y = int(map, input().split())

if(2*x <= y <= 4*x and y%2==0):
    print("Yes")
else:
    print("No")

Fixed submission:
x, y = map(int, input().split())

if(2*x <= y <= 4*x and y%2==0 and x <= 50):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
x, y = int(map, input().split())

if(2*x <= y <= 4*x):
    print("Yes")
else:
    print("No")

Fixed submission:
x, y = map(int, input().split())

if(2*x <= y <= 4*x and y%2==0 and x <= 50):
    print("Yes")
else:
    print("No")