Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# ABC084-B
A, B = map(int, input().split())
S = input()
ans = 'No'
flag = True
num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
if S[A] == '-':
    aa = S[0:A]
    bb = S[A+1:A+B+1]
    for i in range(len(aa)):
        if aa[i] not in num:
            flag  = False
    for k in range(len(bb)):
        if bb[i] not in num:
            flag = False
    if flag:
        ans = 'Yes'
print(ans)

Fixed submission:
# ABC084-B
A, B = map(int, input().split())
S = input()
ans = 'No'
flag = True
num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
if S[A] == '-':
    aa = S[0:A]
    bb = S[A+1:A+B+1]
    for i in range(len(aa)):
        if aa[i] not in num:
            flag  = False
    for k in range(len(bb)):
        if bb[k] not in num:
            flag = False
    if flag:
        ans = 'Yes'
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for b in B:
    a_max = bisect.bisect_left(A, b)
    c_min = bisect.bisect_right(C, b)
    ans += a_max * (N - c_min)
print(ans)

Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for b in B:
    a_max = bisect.bisect_left(A, b)
    c_min = bisect.bisect_right(C, b)
    ans += a_max * (N - c_min)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for i in range(N):
    b_min = bisect.bisect_right(B, A[i])
    for k in range(b_min, N):
        c_min = bisect.bisect_right(C, B[k])
        ans += N - c_min
        ##print(i, k, ans)

print(ans)

Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for b in B:
    a_max = bisect.bisect_left(A, b)
    c_min = bisect.bisect_right(C, b)
    ans += a_max * (N - c_min)
print(ans)
Buggy python submission (verdict: Runtime Error):
# ABC076C
S = input()
T = input()

for i in range(len(S) - len(T) + 1):
    if S[i] == "?" or S[i] == T[0]:
        k = 1
        flag = True
        while k < len(T):
            if S[i+k] == "?":
                k += 1
            else:
                if S[i + k] == T[k]:
                    k += 1
                else:
                    flag = False
                    break
        if k == len(T) and flag == True:
            check = i

if check != -1:
    S = list(S)
    for i in range(len(T)):
        S[check + i] = T[i]
    S = "".join(S)
    ans = S.replace("?", "a")
    print(ans)
else:
    print("UNRESTORABLE")

Fixed submission:
# ABC076C
S = input()
T = input()
check = -1
for i in range(len(S) - len(T) + 1):
    if S[i] == "?" or S[i] == T[0]:
        k = 1
        flag = True
        while k < len(T):
            if S[i+k] == "?":
                k += 1
            else:
                if S[i + k] == T[k]:
                    k += 1
                else:
                    flag = False
                    break
        if k == len(T) and flag == True:
            check = i

if check != -1:
    S = list(S)
    for i in range(len(T)):
        S[check + i] = T[i]
    S = "".join(S)
    ans = S.replace("?", "a")
    print(ans)
else:
    print("UNRESTORABLE")

Buggy python submission (verdict: Runtime Error):
# ABC076C
S = input()
T = input()
check = -1
flag = True
for i in range(len(S)):
    flag = True
    if S[i] != T[0]:
        continue
    k = 1
    while k < len(T):
        if S[i+k] == "?":
            k += 1
        else:
            if S[i+k] == T[k]:
                k += 1
            else:
                flag = False
                break        
    if k == len(T) and flag == True:
        check = i

if check != -1:
    S = list(S)
    for i in range(len(T)):
        S[check + i] = T[i]
    S = "".join(S)
    ans = S.replace("?", "a")
    print(ans)
else:
    print("UNRESTORABLE")

Fixed submission:
# ABC076C
S = input()
T = input()
check = -1
for i in range(len(S) - len(T) + 1):
    if S[i] == "?" or S[i] == T[0]:
        k = 1
        flag = True
        while k < len(T):
            if S[i+k] == "?":
                k += 1
            else:
                if S[i + k] == T[k]:
                    k += 1
                else:
                    flag = False
                    break
        if k == len(T) and flag == True:
            check = i

if check != -1:
    S = list(S)
    for i in range(len(T)):
        S[check + i] = T[i]
    S = "".join(S)
    ans = S.replace("?", "a")
    print(ans)
else:
    print("UNRESTORABLE")
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
flag = False
for h in range(1, 3501, 1):
    for n in range(1, 3501, 1):
        bumbo = 4 * h * n - N * h - N * n
        bunshi = N * h * n
        if bumbo == 0:
            continue
        wc = math.ceil(bunshi / bumbo)
        wf = math.floor(bunshi / bumbo)
        if wc == wf and wc >= 1:
            ans_h = h
            ans_n = n
            ans_w = wc
            flag = True
            break
    if flag:
        break
print(ans_h, ans_n, ans_w)

Fixed submission:
import math
N = int(input())
flag = False
for h in range(1, 3501, 1):
    for n in range(1, 3501, 1):
        bumbo = 4 * h * n - N * h - N * n
        bunshi = N * h * n
        if bumbo == 0:
            continue
        wc = math.ceil(bunshi / bumbo)
        wf = math.floor(bunshi / bumbo)
        if wc == wf and wc >= 1:
            ans_h = h
            ans_n = n
            ans_w = wc
            flag = True
            break
    if flag:
        break
print(ans_h, ans_n, ans_w)
Buggy python submission (verdict: Runtime Error):
# TLE
N = int(input())
a = list(map(int, input().split()))

cnt = [0] * 100000
for i in a:
    cnt[i] += 1
    cnt[i+1] += 1
    cnt[i-1] += 1

print(max(cnt))

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

cnt = [0] * 1000010
for i in a:
    cnt[i] += 1
    cnt[i+1] += 1
    cnt[i-1] += 1

print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
l1 = [1] * N
a1 = [_ + 1 for _ in a]
a2 = [_ - 1 for _ in a]
lst = a + a1 + a2
set_lst = list(set(lst))
ans = 0

if len(lst) == len(set_lst):
    print(1)
else:
    for i in set_lst:
        tmp = lst.count(i)
        if tmp > ans:
            ans = tmp
    print(ans)

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

cnt = [0] * 1000010
for i in a:
    cnt[i] += 1
    cnt[i+1] += 1
    cnt[i-1] += 1

print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
l1 = [1] * N
a1 = [_ + 1 for _ in a]
a2 = [_ - 1 for _ in a]
lst = a + a1 + a2
lst = list(lst)
set_lst = list(set(lst))
ans = 0
for i in set_lst:
    tmp = lst.count(i)
    if tmp > ans:
        ans = tmp
print(ans)

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

cnt = [0] * 1000010
for i in a:
    cnt[i] += 1
    cnt[i+1] += 1
    cnt[i-1] += 1

print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
l1 = [1] * N
a1 = [_ + 1 for _ in a]
a2 = [_ - 1 for _ in a]
lst = a + a1 + a2
lst = list(lst)
set_lst = list(set(lst))
ans = 0
for i in set_lst:
    tmp = lst.count(i)
    if tmp > ans:
        ans = tmp
print(ans)

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

cnt = [0] * 1000010
for i in a:
    cnt[i] += 1
    cnt[i+1] += 1
    cnt[i-1] += 1

print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
# -*-coding: utf-8 -*-
import numpy as np
def main():
    N = int(input())
    a = np.array(list(map(int, input().split())))
    a1 = a + 1
    a2 = a - 1
    lst = np.concatenate([a, a1, a2], 0)
    lst = list(lst)
    set_lst = list(set(lst))
    ans = 0
    for i in set_lst:
        tmp = lst.count(i)
        if tmp > ans:
            ans = tmp
    print(ans)
if __name__ == '__main__':
    main()

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

cnt = [0] * 1000010
for i in a:
    cnt[i] += 1
    cnt[i+1] += 1
    cnt[i-1] += 1

print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())))

a1 = a + 1
a2 = a - 1

lst = np.concatenate([a, a1, a2], 0)
lst = list(lst)

set_lst = list(set(lst))
ans = 0
for i in set_lst:
    tmp = lst.count(i)
    if tmp > ans:
        ans = tmp

print(ans)

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

cnt = [0] * 1000010
for i in a:
    cnt[i] += 1
    cnt[i+1] += 1
    cnt[i-1] += 1

print(max(cnt))
Buggy python submission (verdict: Runtime Error):
# ABC071-C　
N = int(input())
A_list = list(map(int, input().split()))

A_set = set(A_list)
A_set = sorted(A_set, reverse=True)

side_list = [0, 0]

for i in range(len(A_set)):   # 大きい順に取っていき，リストで個数を確認する
    if len(side_list) >= 4:
        break
    count = A_list.count(A_set[i])    # リストの個数を確認
    if count == 2 or count == 3:
        side_list.append(A_set[i])
    if count >= 4:
        side_list.append(A_set[i])
        side_list.append(A_set[i])
        
side_list.sort(reverse = True)
print(side_list[0] * side_list[1])

Fixed submission:
# ABC071-A
x, a, b = map(int, input().split())
if abs(x-a) > abs(x-b):
    print('B')
else:
    print('A')
Buggy python submission (verdict: Runtime Error):
# ABC070-C
import math
from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def lcm_base(x, y):
    return (x * y ) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers)
print(lcm_list(T))

Fixed submission:
# ABC070-C
import fractions
from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def lcm_base(x, y):
    return (x * y ) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers)
print(lcm_list(T))
Buggy python submission (verdict: Time Limit Exceeded):
# ABC067-C
N = int(input())
a = list(map(int, input().split()))
a_sum = sum(a)
x = 0
y = 0
diff = []
for i in range(0, N-1):
    x_a = a[0:i+1]
    x = sum(x_a)
    y = a_sum - x
    diff.append(abs(x-y))
print(min(diff))    

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int, input().split()))

res = np.cumsum(a)
# print(res)
sum_a = np.sum(a)
ans = 100000000000
for i in range(N - 1):
    tmp = abs((sum_a - res[i]) - res[i])
    # print(tmp)
    if tmp < ans:
        ans = tmp

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC066-C
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = list(reversed(b))
print(' '.join(map(str, b)))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = []
start = n // 2 
if n % 2 == 0:
    for i in range(n-1, 0, -2):
        b.append(a[i])
    for i in range(0, n, +2):
        b.append(a[i])
else:
    for i in range(n-1, -1, -2):
        b.append(a[i])
    for i in range(1, n, +2):
        b.append(a[i])

print(" ".join(map(str, b)))
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
import math
mod = 10**9 + 7

N, M = map(int, input().split())
if abs(N - M) > 1:
    print(0)
else:
    if abs(N - M) == 1:
        print(((math.factorial(N) % mod) * (math.factorial(M) % mod)) % mod)
    else:
        print(((math.factorial(N) % mod) * ((math.factorial(M) * 2) % mod)) % mod)

Fixed submission:
from scipy.misc import comb
import math
mod = 10**9 + 7

N, M = map(int, input().split())
if abs(N - M) > 1:
    print(0)
else:
    if abs(N - M) == 1:
        print(((math.factorial(N) % mod) * (math.factorial(M) % mod)) % mod)
    else:
        print(((math.factorial(N) % mod) * ((math.factorial(M) * 2) % mod)) % mod)
Buggy python submission (verdict: Runtime Error):
v# A
r, g, b = map(int, input().split())
N = 10 * g + b 
if N % 4 == 0:
    print('YES')
else:
    print('NO')

Fixed submission:
# A
r, g, b = map(int, input().split())
N = 10 * g + b 
if N % 4 == 0:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int, input().split()))

res_plus = np.cumsum(A)
res_minus = np.cumsum(A)
ans_plus = 0
ans_minus = 0

tmp_tmp = 0
# 奇数項を正とする
for i in range(N):
    res_plus[i] += tmp_tmp
    if i % 2 == 0:         # 奇数項   
        if res_plus[i] > 0:
            pass
        else:
            tmp = 1 - res_plus[i]
            ans_plus += tmp
            tmp_tmp += tmp
    else:                  # 偶数項
        if res_plus[i] < 0:
            pass
        else:
            tmp = res_plus[i] + 1
            ans_plus += tmp
            tmp_tmp -= tmp


tmp_tmp = 0
# 奇数項を負とする
for i in range(N):
    res_minus[i] += tmp_tmp
    if i % 2 == 0:      # 奇数項
        if res_minus[i] < 0:
            pass
        else:
            tmp = res_minus[i] + 1
            ans_minus += tmp
            tmp_tmp -= tmp
    else:               # 偶数項
        if res_minus[i] > 0:
            pass
        else:
            tmp = 1 - res_minus[i]
            ans_minus += tmp
            tmp_tmp += tmp

##print(ans_minus, ans_plus)
print(min(ans_plus, ans_minus))

Fixed submission:
import numpy as np
N = int(input())
A = list(map(int, input().split()))

res_plus = np.cumsum(A)
res_minus = np.cumsum(A)
ans_plus = 0
ans_minus = 0

tmp_tmp = 0
# 奇数項を正とする
for i in range(N):
    res_plus[i] += tmp_tmp
    if i % 2 == 0:         # 奇数項   
        if res_plus[i] > 0:
            pass
        else:
            tmp = 1 - res_plus[i]
            ans_plus += tmp
            tmp_tmp += tmp
    else:                  # 偶数項
        if res_plus[i] < 0:
            pass
        else:
            tmp = res_plus[i] + 1
            ans_plus += tmp
            tmp_tmp -= tmp


tmp_tmp = 0
# 奇数項を負とする
for i in range(N):
    res_minus[i] += tmp_tmp
    if i % 2 == 0:      # 奇数項
        if res_minus[i] < 0:
            pass
        else:
            tmp = res_minus[i] + 1
            ans_minus += tmp
            tmp_tmp -= tmp
    else:               # 偶数項
        if res_minus[i] > 0:
            pass
        else:
            tmp = 1 - res_minus[i]
            ans_minus += tmp
            tmp_tmp += tmp

##print(ans_minus, ans_plus)
print(min(ans_plus, ans_minus))
Buggy python submission (verdict: Runtime Error):
# AGC013
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    if A[i] == A[i+1]:
        pass
    elif A[i] > A[i+1]:
        now = "N"
        break
    else:
        now = "P"
        break
ans = 1
for i in range(N-1):
    if now == "?":
        if A[i] == A[i+1]:
            pass
        elif A[i] > A[i+1]:
            now = "N"
        else:
            now = "P"
    elif now == "P":
        if A[i] <= A[i+1]:
            pass
        else:
            ans += 1
            now = "?"
    else:
        if A[i] >= A[i+1]:
            pass
        else:
            ans += 1
            now = "?"
print(ans)

Fixed submission:
# AGC013
N = int(input())
A = list(map(int, input().split()))
if N == 1:
    print(1)
    exit()
for i in range(N):
    if A[i] == A[i+1]:
        pass
    elif A[i] > A[i+1]:
        now = "N"
        break
    else:
        now = "P"
        break
ans = 1
for i in range(N-1):
    if now == "?":
        if A[i] == A[i+1]:
            pass
        elif A[i] > A[i+1]:
            now = "N"
        else:
            now = "P"
    elif now == "P":
        if A[i] <= A[i+1]:
            pass
        else:
            ans += 1
            now = "?"
    else:
        if A[i] >= A[i+1]:
            pass
        else:
            ans += 1
            now = "?"
print(ans)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main(){
    char a, b;
    cin >> a >> b;
    bool flag = false;
    if (a == 'H' && b == 'H'){
        flag = true;
    }
    if (a == 'D' && b == 'D'){
        flag = true;
    }
    if (flag){
        cout << 'H' << endl;
    }else{
        cout << 'D' << endl;
    }
    
}

Fixed submission:
# A問題
a, b = map(str, input().split())
if a == "H":
    if b == "H":
        print("H")
    else:
        print("D")
else:
    if b == "H":
        print("D")
    else:
        print("H")
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    if (A == B) cout << "Draw" << endl;
    else if (A == 1) cout << "Alice" << endl;
    else if (B == 1) cout << "Bob" << endl;
    else if (A > B) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}

Fixed submission:
# A問題
a, b = map(int, input().split())
if a == 1:
    a = 14
if b == 1:
    b = 14
if a > b:
    print("Alice")
elif a == b:
    print("Draw")
else:
    print("Bob")
Buggy python submission (verdict: Runtime Error):
# ABC054C
# 方針：階乗の全探索

import itertools
N, M = map(int, input().split())
# Graph の作成
graph = [[] * N for _ in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

# パターンの全列挙
lst = [_ for _ in range(0, N)]
search_list = itertools.permutations(lst)

ans = 0
for lst in search_list:
    flag = True
    if lst[0] != 0:    # 1度でも先頭が0以外ならそれ以降は全てダメ
        break
    for i in range(M-1):
        if lst[i+1] in graph[lst[i]]:   # 今の数字が次の数字と繋がっているかどうか
            pass
        else:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

Fixed submission:
# ABC054C
# 方針：階乗の全探索

import itertools
N, M = map(int, input().split())
# Graph の作成
graph = [[] * N for _ in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

# パターンの全列挙
num_lst = [_ for _ in range(0, N)]
search_list = itertools.permutations(num_lst)

ans = 0
for lst in search_list:
    flag = True
    if lst[0] != 0:    # 1度でも先頭が0以外ならそれ以降は全てダメ
        break
    for i in range(N-1):
        if lst[i+1] in graph[lst[i]]:   # 今の数字が次の数字と繋がっているかどうか
            pass
        else:
            flag = False
            break
    if flag:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#ABC951B/Sum_of_Three_Integers

K, S = map(int, input().split())
ans = 0
for X in range(0, K+1):
    for Y in range(X, K+1):
        for Z in range(Y, K+1):
            if X == Y == Z and X + Y + Z == S:
                ans += 1
            elif X == Y and X + Y + Z == S:
                ans += 3
            elif Y == Z and X + Y + Z ==S:
                ans += 3
            elif X + Y + Z == S:
                ans += 6
print(ans)

Fixed submission:
#ABC951B/Sum_of_Three_Integers

K, S = map(int, input().split())
ans = 0
for x in range(0, K+1):
    for y in range(0, K+1):
        z = S - x - y
        if 0 <= z and z <= K:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#ABC951B/Sum_of_Three_Integers

K, S = map(int, input().split())
ans = 0
for X in range(0, K+1):
    Y = X
    Z = X
    if X + Y + Z == S:
        ans += 1
for X in range(0, K+1):
    Y = X
    for Z in range(0, K+1):
        if X != Z and X + Y + Z == S:
            ans += 3
for X in range(0, K-1):
    for Y in range(X+1, K):
        for Z in range(Y+1, K+1):
            if X + Y + Z == S:
                ans += 6
print(ans)

Fixed submission:
#ABC951B/Sum_of_Three_Integers

K, S = map(int, input().split())
ans = 0
for x in range(0, K+1):
    for y in range(0, K+1):
        z = S - x - y
        if 0 <= z and z <= K:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ans = 0
for X in range(0, K+1):
    for Y in range(0, K+1):
        for Z in range(0, K+1):
            if X + Y + Z == S:
                ans += 1

print(ans)

Fixed submission:
#ABC951B/Sum_of_Three_Integers

K, S = map(int, input().split())
ans = 0
for x in range(0, K+1):
    for y in range(0, K+1):
        z = S - x - y
        if 0 <= z and z <= K:
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))

if N % 2 == 0:
    for i in range(1, N, 2):
        if A.count(i) == 2:
            pass
        else:
            print(0)
            exit()
    ans = (2 ** (N // 2))%mod

else:
    for i in range(0, N, 2):
        if i == 0:
            if A.count(i) == 1:
                pass
            else:
                print(0)
                exit()
        else:
            if A.count(i) == 2:
                pass
            else:
                print(0)
                exit()
        ans = (2 ** (N // 2)) % mod

print(ans)

Fixed submission:
import collections
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
a = collections.Counter(A)
a = a.most_common()[::-1]

if N % 2 == 0:
    for i in range(len(a)):
        if a[i][0] % 2 == 1 and a[i][1] == 2:
            pass
        else:
            print(0)
            exit()
    ans = (2 ** (N // 2)) % mod

else:
    for i in range(len(a)):
        if a[i][0] == 0:
            if a[i][1] == 1:
                pass
            else:
                print(0)
                exit()
        else:
            if a[i][0] % 2 == 0 and a[i][1] == 2:
                pass
            else:
                print(0)
                exit()
    ans = (2 ** (N // 2)) % mod 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# C問題
n, x = map(int, input().split())
a = list(map(int, input().split()))
new_a = []
new_a += a
if a[0] > x:
    new_a[0] = x
for i in range(n-1):
    while True:
        if new_a[i] + new_a[i+1] > x:
            new_a[i+1] -= 1
        if new_a[i] + new_a[i+1] <= x:
            break

print(sum(a) - sum(new_a))

Fixed submission:
# C問題
n, x = map(int, input().split())
a = list(map(int, input().split()))
new_a = []
new_a += a
if a[0] > x:
    new_a[0] = x
for i in range(n-1):
    while True:
        if new_a[i] + new_a[i+1] > x:
            new_a[i+1] = x-new_a[i]
        if new_a[i] + new_a[i+1] <= x:
            break

print(sum(a) - sum(new_a))
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    set<int> st{a, b, c};
    cout << st.size() << endl;
}

Fixed submission:
# A problem
a, b, c = map(int, input().split())
print(len(set([a, b, c])))
Buggy python submission (verdict: Time Limit Exceeded):
# C問題
N = int(input())
TA = []
for i in range(N):
    TA.append(list(map(int, input().split())))
#T, A互いに素なので1枚目はそのまま取ってきて良い
t = TA[0][0]
a = TA[0][1]
flag = True
for i in range(1,  N+1):
    tmp_t = 0
    tmp_a = 0
    if i == N:
        flag = False        
    while flag:
        tmp_t += TA[i][0]
        tmp_a += TA[i][1]
        if tmp_t >= t and tmp_a >= a:
            t = tmp_t
            a = tmp_a
            break
    
print(t+a)        

Fixed submission:
# C問題
N = int(input())
TA = []
for i in range(N):
    TA.append(list(map(int, input().split())))
#T, A互いに素なので1枚目はそのまま取ってきて良い
t = TA[0][0]
a = TA[0][1]
flag = True
for i in range(1,  N+1):
    tmp_t = 0
    tmp_a = 0
    if i == N:
        flag = False
        break
    k = max(t // TA[i][0], a // TA[i][1])   # 整数k
    while flag:   # 整数倍(足していく)していって両方がが超えた時の値が得票数になる
        tmp_t = k * TA[i][0]
        tmp_a = k * TA[i][1]
        if tmp_t >= t and tmp_a >= a:
            t = tmp_t
            a = tmp_a
            break
        k += 1
    
print(t+a)