Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())
min_mod = 10**9
for i in range(L, min(L + 2019, R + 1)):
    for j in range(i + 1, min(L + 2019, R + 1)):
        min_mod = min(min_mod, (i * j) % 2019)
print(min_mod)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
mod = 2019
ans = 10**9 + 7
for i in range(L, min(L + mod, R)):
  for j in range(i + 1, min(i + mod, R)):
    ans = min((i * J) % mod, ans)
print(ans)
Problem p02993 (python)

Fixed submission:
s = list(input())
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
S = list(input())
s = set(S)
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
    print("Bad")
else:
    print("Good")
Problem p02995 (python)

Fixed submission:
A, B, C, D = map(int, input().split())


def start(num: int) -> int:
    if A % num == 0:
        num_start = A + (A % num)
    else:
        num_start = A + (num - A % num)
    return num_start


def count_in_range(num_start: int, num: int) -> int:
    r = B - num_start
    return r // num + 1


def calc(num: int) -> int:
    return count_in_range(start(num), num)


def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)


c = calc
print((B - A + 1) - (calc(C) + calc(D) - calc(lcm(C, D))))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


A, B, C, D = map(int, input().split())
ans_b = B - (B // C) - (B // D) + (B // lcm_base(C, D))
ans_a = (A - 1) - ((A - 1) // C) - ((A - 1) // D) + ((A - 1) // lcm_(A - 1)ase(C, D))
print(ans_b - ans_a)

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())


def start(num: int) -> int:
    if A % num == 0:
        num_start = A + (A % num)
    else:
        num_start = A + (num - A % num)
    return num_start


def count_in_range(num_start: int, num: int) -> int:
    r = B - num_start
    return r // num + 1


def calc(num: int) -> int:
    return count_in_range(start(num), num)


def lcm(x, y):
    import math
    return (x * y) // math.gcd(x, y)


c = calc
print((B - A + 1) - (calc(C) + calc(D) - calc(lcm(C, D))))
Problem p03031 (python)

Fixed submission:
from copy import deepcopy
N,M = map(int,input().split())
s_list = []
for _ in range(M):
    s_list.append(tuple(map(int,input().split()[1:])))
plist = tuple(map(int,input().split()))

counter = 0
TF = [0]*N
TFlist = []
def make_bbb(long,number):
    b_n = bin(number)[2:]
    bbb = "0"*(long-len(b_n))+b_n
    return bbb
for _ in range(2**N):
    number = list(map(int,list(make_bbb(N,_))))
    TFlist.append(number)


for TF in TFlist:
    flg = False
    ok = 0
    for num,s in enumerate(s_list):
        sum_on = 0
        #各スイッチ
        for ele in s:
            sum_on += TF[ele-1]
        if sum_on%2 != plist[num]:
            flg = False
            break
        else:
            ok += 1
    if ok == M:
        counter += 1


print(counter)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
slist = [list(map(int, input().split()))[1:] for _ in range(M)]
plist = list(map(int, input().split()))

def count_on_switch(switch_array: list, on: set):
    return sum([int(sw in on) for sw in switch_array])

ans: int = 0
# print("---")
for i in range(2**N):
    on = set()
    for j in range(N):
        if ((i >> j) & 1):
             on.add(j+1)
    temp = 0
    for _ in range(M):
        cou_on = count_on_switch(slist[_], on)
        # print(i, cou_on)
        if cou_on % 2 != plist[_]:
            break
    else:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
slist = [list(map(int, input().split()))[1:] for _ in range(M)]
plist = list(map(int, input().split()))

def count_on_switch(switch_array: list, on: set):
    return sum([int(sw in on) for sw in switch_array])

ans: int = 0
# print("---")
for i in range(2**N):
    on = set()
    for j in range(N):
        if ((i >> j) & 1):
             on.add(j+1)
    temp = 0
    for _ in range(M):
        cou_on = count_on_switch(slist[_], on)
        # print(i, cou_on)
        if cou_on % 2 != plist[_]:
            break
    else:
        ans += 1
print(ans)
Problem p03050 (python)

Fixed submission:
from math import floor, sqrt
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors

N = int(input())
div = make_divisors(N)
max_div = sqrt(N)
ans = 0
if N == 2:
    print(0)
    exit()
if N == 6:
    print(5)
    exit()
if N == 12:
    print(16)
    exit()
if N == 20:
    print(28)
    exit()
if N == 30:
    print(52)
    exit()
if N == 42:
    print(74)
    exit()
if N == 56:
    print(95)
    exit()
if N == 72:
    print(157)
    exit()
if N == 90:
    print(193)
    exit()
for d in div:
    if d < max_div:
        ans += (N-d)//d
        # print(d, (N-d)//d, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import floor, sqrt
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors
div = make_divisors(N)
max_div = floor(sqrt(N))
ans = 0

for d in div:
    if N % 
    if d <= max_div:
        ans += (N-d)//d
        print(d, (N-d)//d, ans)
print(ans+1)
Problem p03062 (python)

Fixed submission:
N = int(input())
Alist = list(map(int, input().split()))
dp = [[0, 0] for i in range(N+1)]
dp[0][1] = -(3*10**9)
for i in range(1, N+1):
    Ai = Alist[i-1]
    dp[i][0] = max(dp[i-1][0]+Ai, dp[i-1][1]-Ai)
    dp[i][1] = max(dp[i-1][0]-Ai, dp[i-1][1]+Ai)
print(dp[N][0])

Buggy submission (verdict: Runtime Error):
N = int(input())
Alist = list(map(int, input().split()))
dp = [[0, 0] for i in range(N+1)]
dp[0][1] = -(3*10**9)
for i in range(1, N+1):
    dp[i][0] = max(dp[i-1][0]+Alist[i], dp[i-1][1]-Alist[i])
    dp[i][1] = max(dp[i-1][0]-Alist[i], dp[i-1][1]+Alist[i])
print(dp[N][0])
Problem p03085 (python)

Fixed submission:
vocab = {"A":"T","T":"A","C":"G","G":"C"}
print(vocab[input()])

Buggy submission (verdict: Runtime Error):
vocab = {"A":"T","T":"A","C":"G","G","C"}
print(vocab[input()])
Problem p03089 (python)

Fixed submission:
N = int(input())
blist = list(map(int, input().split()))
ans = []
for i in range(N):
    for index in range(N-i-1, -1, -1):
        if blist[index] == index + 1:
            ans.append(blist.pop(index))
            break
    else:
        print(-1)
        break
else:
    for num in ans[::-1]:
        print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
blist = list(map(int, input().split()))
ans = []
for i in range(N):
    for index in range(N-1, -1, -1):
        if blist[index] == index + 1:
            ans.append(blist.pop(index))
            break
    else:
        print(-1)
        break
else:
    for num in ans:
        print(num)
Problem p03139 (python)

Fixed submission:
N,A,B = map(int,input().split())

sum = A+B
if A+B <= N:
    min = 0
else:
    min = (A+B)-N

#max
if A >= B:
    max=B
else:
    max = A

print(max,min)

Buggy submission (verdict: Runtime Error):
N = int(input())
Nlist=[]
Takalist=[]
Aokilist=[]
for n in range(N):
    Nlist.append(n)
    a,b = map(int,input().split())
    Takalist.append(a)
    Aokilist.append(b)

Taka = 0
Aoki = 0


flg = 0
for n in range(N):
    if flg == 0:
        big = max(Takalist)
        Taka += big
        num = Takalist.index(big)
        Aokilist[num]=0
        Takalist[num]=0
        flg=1

    elif flg == 1:
        big = max(Aokilist)
        Aoki += big
        num = Aokilist.index(big)
        Aokilist[num]=0
        Takalist[num]=0
        flg=0

print(Taka-Aoki)
Problem p03161 (python)

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
inf = 10**9
dp = [inf] * N
dp[0] = 0


def chmin(num: int, sbn: int):
    dp[num + sbn] = min((dp[num + sbn], dp[num] + abs(h[i + sbn] - h[num])))


for i in range(N):
    for sbn in range(K):
        try:
            chmin(i, sbn + 1)
        except IndexError:
            break
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
hlist = list(map(int, input().split())) + [0] * K
inf = float("inf")
dp = [inf] * (N * K)


def abs_sbn(a, b):
    return abs(hlist[b] - hlist[a])


dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        dp[i + j] = min(dp[i + j], dp[i] + abs_sbn(i, i + j))

print(dp[N - 1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split()))
inf = 10**9
dp = [inf] * N
dp[0] = 0


def chmin(num: int, sbn: int):
    dp[num + sbn] = min((dp[num + sbn], dp[num] + abs(h[i + sbn] - h[num])))


for i in range(N):
    for sbn in range(K):
        try:
            chmin(dp, i, sbn + 1)
        except IndexError:
            break
print(dp[-1])
Problem p03206 (python)

Fixed submission:
D = int(input())
if D == 25:
    print("Christmas")
elif D == 24:
    print("Christmas Eve")
elif D == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
D = input()
date_dict = {"25": "Christmas", 
"24": "Christmas Eve",
"23": "Christmas Eve Eve", 
"22": "Christmas Eve Eve Eve"}

print(date_dict(D))

Buggy submission (verdict: Runtime Error):
D = int(input())
date_dict = {25: "Christmas", 
24: "Christmas Eve",
23: "Christmas Eve Eve", 
22: "Christmas Eve Eve Eve"}

print(date_dict(D))
Problem p03282 (python)

Fixed submission:
S = list(input())
K = int(input())
for i in range(K):
    if S[i] != "1":
        print(S[i])
        break
else:
    print("1")

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] == "1":
    print(list(set(S))[1])
else:
    print(S[0])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] == "1":
    print(S[1])
else:
    print(S[0])
Problem p03324 (python)

Fixed submission:
D, N = map(int, input().split())
nums = []
for i in range(120):
    if i % 100 == 0:
        continue
    nums.append(100**D * i)

print(nums[N - 1])

Buggy submission (verdict: Runtime Error):
D, N = map(int, input().split())
nums = []
for i in range(1, 10**6):
    num = 100 ** D * i
    if num % 100 == D:
        nums.append(num)

print(nums[N - 1])

Buggy submission (verdict: Runtime Error):
D, N = map(int, input().split())
nums = []
for i in range(1, 10**3):
    num = 100 ** D * i
    if num % 100 == D:
        nums.append(num)

print(num[N - 1])
Problem p03360 (python)

Fixed submission:
nums = list(map(int, input().split()))
K = int(input())
for i in range(K):
    nums[nums.index(max(nums))] *= 2

print(sum(nums))

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
K = int(input())

X = [A,B,C]
for i in range(K):
  max(X) *= 2

print(sum(X))
Problem p03363 (python)

Fixed submission:
from itertools import accumulate
from collections import Counter
N = int(input())
Alist = [0]+list(map(int, input().split()))
cumsum = Counter(sorted(list(accumulate(Alist)))).most_common()
ans = 0

for k, v in cumsum:
    if v > 1:
        ans += v*(v-1)//2
    else:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
from collections import Counter
N = int(input())
Alist = [0]+list(map(int, input().split()))
cumsum = Counter(sorted(list(accumulate(Alist)))).most_common()
ans = 0

for k, v in cumsum:
    if v > 1:
        ans += n*(n-1)//2
    else:
        break
print(ans)
Problem p03380 (python)

Fixed submission:
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn and a != m:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)

Buggy submission (verdict: Runtime Error):
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

n = int(input())
alist = list(map(int, input().split()))
m = max(alist)
ans = 0
ans_ = (0, 0)
sbn = 10**10
for a in alist:
    if a == b:
        continue
    sbn_ = abs(m//2-a)
    if sbn_ < sbn :
        sbn = sbn_
        nck = nCk(m, a)
        # print(nck)
        ans = nck
        ans_ = (m, a)
print(ans_[0], ans_[1])

Buggy submission (verdict: Runtime Error):
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

n = int(input())
alist = list(map(int, input().split()))
m = max(alist)
ans = 0
ans_ = (0, 0)
sbn = 10**10
for a in alist:
    if a == b:
        continue
    sbn_ = abs(m//2-a)
    if sbn_ < sbn :
        sbn = sbn_
        nck = nCk(m, a)
        # print(nck)
        ans = nck
        ans_ = (m, a)
print(ans_[0], ans_[1])
Problem p03386 (python)

Fixed submission:
A, B, K = map(int, input().split())
num_range = range(A, B + 1)
for i in sorted(set(num_range[:K]) | set(num_range[-K:])):
    print(i)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = []
num_range = list(range(A, B + 1))
if A == B:
    print(A)
else:
    for i in range(K if len(num_range) > K else len(num_range)):
        nums.append(num_range[i])
        nums.append(num_range[- (i + 1)])
    for num in sorted(list(set(nums))):
        print(num)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = []
num_range = list(range(A, B + 1))
if A == B:
    print(A)
else:
    for i in range(K if (B + 1 - A) > K else (B + 1 - A)):
        nums.append(num_range[i])
        nums.append(num_range[- (i + 1)])
    for num in sorted(list(set(nums))):
        print(num)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = []
num_range = list(range(A, B + 1))
for i in range(K if (B + 1 - A) > K else (B + 1 - A)):
    nums.append(num_range[i])
    nums.append(num_range[- (i + 1)])
for num in sorted(list(set(nums))):
    print(num)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
try:
    small = list(range(A, B + 1))[:K]
    big = list(range(A, B + 1))[-K:]
    nums = small + big
except:
    nums = list(range(A, B + 1))
for num in sorted(list(set(nums))):
    print(num)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
try:
    small = list(range(A, B + 1))[:K]
    big = list(range(A, B + 1))[-K:]
    nums = small + big
except:
    nums = list(range(A, B + 1))
for num in set(nums):
    print(num)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = list(range(A, B + 1))[:K] + list(range(A, B + 1))[-K:]
for num in nums:
    print(num)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
print("\n".join(list(range(A, B + 1))[:K] + list(range(A, B + 1))[-K:]))
Problem p03416 (python)

Fixed submission:
A, B = map(int, input().split())
counter = 0
for num in range(A, B + 1):
    if str(num) == str(num)[::-1]:
        counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
counter = 0
for _ in range(A,B+1):
    str = str(_)
    alist = list(str)
    list_ = []
    long = len(alist)
    for i in range(long-1,-1,-1):
        list_.append(alist[i])
    num = "".join(list_)
    if num == str:
        counter += 1
        continue
    else:
        continue

print(counter)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
counter = 0
for _ in range(A,B+1):
    str = str(_)
    alist = list(str)
    print(alist)
    list_ = []
    long = len(alist)
    for i in range(long-1,-1,-1):
        list_.append(alist[i])
    num = "".join(list_)
    if num == str:
        counter += 1
        continue
    else:
        continue

print(counter)
Problem p03435 (python)

Fixed submission:
c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([line[2] for line in c]) - sum([line[1] for line in c])) % 3 == 0
    assert (sum([line[1] for line in c]) - sum([line[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")

Buggy submission (verdict: Runtime Error):
c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([c[2] for line in c]) - sum([c[1] for line in c])) % 3 == 0
    assert (sum([c[1] for line in c]) - sum([c[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")
Problem p03457 (python)

Fixed submission:
N = int(input())
txy = [(0, 0, 0)] + [tuple(map(int, input().split())) for _ in range(N)]


for i in range(N):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    if N == 1:
        root = txy[1][1] + txy[1][2]
        time = txy[1][0]
        if time < root:
            print("No")
        else:
            if (time - root) % 2 == 0:
                print("Yes")
            else:
                print("No")
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
txy = [tuple() for _ in range(N)]
for i in range(N - 1):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    print("Yes")
Problem p03524 (python)

Fixed submission:
from collections import Counter
S = input()
Sc = Counter(S)
if len(Sc.keys()) == 1:
    print("YES" if len(S)==1 else "NO")
elif len(Sc.keys()) == 2:
    if (list(Sc.values())[0] != list(Sc.values())[1]) or (list(Sc.values())[0] > 2 or  list(Sc.values())[1] > 2):
        print("NO")
    else:
        print("YES")
else:
    temp = list(Sc.values())
    if max(temp) - min(temp) <= 1:
        print("YES")
    else:
        print("NO")

Buggy submission (verdict: Runtime Error):
S = input()
from collections import Counter
C = Counter(S)
if len(C.keys()) == 1:
    if C.values()[0] >= 2:
        print("No")
    else:
        print("Yes")
elif len(C.keys()) == 2:
    if sum(C.values()) < 3:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")
Problem p03567 (python)

Fixed submission:
S = input()
for _ in range(len(S) - 1):
    if S[_:_ + 2] == "AC":
        print("Yes")
        break
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
for _ in range(S - 1):
    if S[_:_ + 2] == "AC":
        print("Yes")
        break
else:
    print("No")
Problem p03574 (python)

Fixed submission:
H, W = map(int, input().split())
Slist = [["."] * (W + 2), ]
for _ in range(H):
    line = list(input())
    line.insert(0, ".")
    line.append(".")
    Slist.append(line)
Slist.append(["."] * (W + 2))
# print(Slist)
point_tuple = ((-1, -1), (-1, 0), (-1, 1),
               (0, -1), (0, 1),
               (1, -1), (1, 0), (1, 1))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        # print(Slist[i][j], i, j)
        if Slist[i][j] == ".":
            counter = 0
            for a, b in point_tuple:
                if Slist[i - a][j - b] == "#":
                    counter += 1
            Slist[i][j] = str(counter)

for i in range(1, H + 1):
    print("".join(Slist[i][1:-1]))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
graph = [list(input()) for _ in range(H)]


def count_bomb(x, y):
    bomb = 0
    one_steps = ((1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1))
    for dx, dy in one_steps:
        nx, ny = x + dx, y + dy
        if (0 <= nx < H) and (0 <= ny <= W):
            if graph[nx][ny] == "#":
                bomb += 1
    return bomb


for x in range(H):
    for y in range(W):
        if graph[x][y] == ".":
            graph[x][y] = count_bomb(x, y)
for line in graph:
    print(line)
Problem p03612 (python)

Fixed submission:
N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if plist[i] == i + 1:
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
        ans += 1
if plist[-1] == N:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N):
    if plist[i] == i + 1:
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
        ans += 1
if plist[-1] == N:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N):
    if p[i] == i + 1:
        ans += 1
        p[i], p[i + 1] = p[i + 1], p[i]
if p[-1] == N:
    ans += 1
print(ans)
Problem p03623 (python)

Fixed submission:
def ABC():
    x,a,b = map(int,input().split())
    if abs(x-a) < abs(x-b):
        print("A")
    else:
        print("B")

ABC()

Buggy submission (verdict: Runtime Error):
program name

    implicit none
    integer x,a,b
    integer xa,xb
    read*, x,a,b
    xa = abs(x-a)
    xb = abs(x-b)
    if ( xa<xb ) then
        print*, "A"
    else
        print*, "B"
    end if

end program
Problem p03627 (python)

Fixed submission:
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))
over2 = [ele for ele in Ac.items() if ele[1]>=2]
if len(over2) == 0:
  print(0)
elif len(over2) == 1:
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
else:
  over2.sort(reverse=True)
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
  else:
    print(over2[0][0]*over2[1][0])

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))

ans = []
for k in sorted(Ac.keys())[::-1]:
  if len(ans) == 2:
    break
  if Ac[k] >=4:
    if ans:
      ans.append(k)
    else:
      ans.append(k)
      ans.append(k)
  elif Ac[k] >= 2:
    ans.append(k)
print(ans[0]*ans[1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))
over2 = [ele for ele in Ac.items() if ele[1]>=2]
if len(over2) == 0:
  print(0)
elif len(over2) == 1:
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
else:
  over2.sort()[::-1]
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
  else:
    print(over2[0][0]*over2[1][0])