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

Fixed submission:
# -*- coding: utf-8 -*-

min_char = "abcdefghij"

def dtype_tree(tree, max, num):
    for i in range(max+1):
        tgt_tree = [i]
        if num > 0:
            new_max = max
            if new_max < i+1:
                new_max = i+1
            new_tree = dtype_tree([], new_max, num-1)
            tgt_tree.append(new_tree)

        if tree == None:
            tree = tgt_tree
        else:
            tree.append(tgt_tree)
    return tree

def print_tree(tree, prefix):
    new_prefix = prefix
    if len(tree) == 1:
        print(prefix + min_char[tree[0]])
    else:
        for elem in tree:
            if type(elem) != list:
                new_prefix += min_char[elem]
#                print(new_prefix)
            else:
                print_tree(elem, new_prefix)

    return


def abc_XXX(num):
    tree = dtype_tree(None, 0, num-1)
#    print(tree)
    print_tree(tree, "")
    return

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    
    abc_XXX(n)
    
    # output

# else:
    # do nothing

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

min_char = "abcdefghij"

def dtype_tree(tree, start, num):
    for i in range(start+1):
        if num > 0:
            tgt_tree = [i]
            new_tree = dtype_tree([], i+1, num-1)
            tgt_tree.append(new_tree)
            if tree == None:
                tree = tgt_tree
            else:
                tree.append(tgt_tree)
        else:
            tree.append([i])
    return tree

def print_tree(tree, prefix):
    new_prefix = prefix
    if len(tree) == 1:
        print(prefix + min_char[tree[0]])
    else:
        for elem in tree:
            if type(elem) != list:
                new_prefix += min_char[elem]
#                print(new_prefix)
            else:
                print_tree(elem, new_prefix)

    return


def abc_XXX(num):
    tree = dtype_tree(None, 0, num-1)
#    print(tree)
    print_tree(tree, "")
    return

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    
    abc_XXX(n)
    
    # output

# else:
    # do nothing
Problem p02687 (python)

Fixed submission:
s = input()
if s == 'ABC':
	print('ARC')
else:
	print('ABC')

Buggy submission (verdict: Runtime Error):
s = input()
if s == 'ABC:
	print('ARC')
else:
	print('ABC')
Problem p02714 (python)

Fixed submission:
import collections
n = int(input())
a = input()
a = a.replace('R','1')
a = a.replace('G','2')
a = a.replace('B','3')
a = tuple(map(int,list(a)))
b = collections.Counter(a)
ans =b[3]*b[1]*b[2]
for i in range(n-2):
    for j in range(i+1,n):
        if a[i] == a[j]:
            continue
        c = j*2 -i
        if c < n:
            if a[i]+a[j]+a[c]==6:
                ans -= 1
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
s = input()
s = s.replace('R','0')
s = s.replace('G','1')
s = s.replace('B','2')
s = tuple(map(int,s))
rgb = [[0 for _ in range(3)] for _ in range(n+1)]
for i in range(n):
    for j in range(3):
        rgb[i+1][j] = rgb[i][j]
    rgb[i+1][s[i]] = rgb[i][s[i]] +1
rgb = tuple(rgb)
ans = 0
for i in range(n):
    a = s[i]
    for j in range(i+1,n):
        b = s[j]
        if a != b:
            c = 3 -a- b
            ans += rgb[n][c] - rgb[j+1][c]
            if 2*j-i < n and s[2*j-i] == c:
                ans -= 1

print(ans)
Problem p02973 (python)

Fixed submission:
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r :#同じものがある
        if l > 0:#他の色の最大値が上書きできる
            lis[l-1]=a
        elif r ==  len(lis):#全部の色の最大値とaが同じなら追加
            lis.append(a)
        else:#どこかの中に挿入
            lis.appendleft(a)
    elif l == 0:#最小値追加
        lis.appendleft(a)
    else:#最大値更新
        lis[r-1] = a
print(len(lis))

Buggy submission (verdict: Runtime Error):
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r and l != 0:#同じものがある&更新できる色がないなら追加
        lis2 = list(lis)
        lis=deque(lis2[0:r]+[a]+lis[l:])

        
    elif l == 0:#最小値追加
        lis.appendleft(a)
    else:#最大値更新
        lis[r-1] = a
print(len(lis))

Buggy submission (verdict: Runtime Error):
import bisect
from collections import deque

n = int(input())
lis = deque()

ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        lis.append(a)
        continue
    l = bisect.bisect_left(lis,a)
    r = bisect.bisect_right(lis,a)
    if l != r and l != 0:#同じものがある&更新できる色がないなら追加
        lis.insert(r,a)
        
    elif l == 0:#最小値追加
        lis.appendleft(a)
    else:#最大値更新
        lis[r-1] = a
print(len(lis))
Problem p03309 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    sa = a[i] - (i+1)
    b[i] = sa
b.sort()
idx = int(n/2) 

p = b[idx]
ans = 0
for i in range(n):
    ans += abs(i+1+p-a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    sa = a[i] - (i+1)
    b[i] = sa
b.sort()
idx = int(n/2) -  (n%2)^1

p = b[idx]
ans = 0
for i in range(n):
    ans += abs(i+1+p-a[i])
print(ans)
Problem p02713 (python)

Fixed submission:
import math

K = int(input())

count = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            count += math.gcd(math.gcd(i,j), k)
print(count)

Buggy submission (verdict: Runtime Error):
import math
K = int(input())

count = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for q in range(1, K+1):
            count += math.gcd(math.gcd(i,j),q)
print(count)
Problem p02756 (python)

Fixed submission:
from collections import deque
S = deque(list(input()))
Q = int(input())

count = 0
for i in range(Q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        count += 1
    elif a[0] == '2':
        if count % 2 == 0 and a[1] == '1':
            S.appendleft(a[2])
        elif a[1] == '1':
            S.append(a[2])
        elif count % 2 == 0:
            S.append(a[2])
        else:
            S.appendleft(a[2])


if count % 2 == 0:
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))

Buggy submission (verdict: Runtime Error):
S = list(input())
Q = int(input())

count = 0
for i in range(Q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        count += 1
    elif a[0] == '2':
        if count % 2 == 0 and a[1] == '1':
            S.insert(0, a[2])
        elif a[1] == '1':
            S.append(a[2])
        elif count % 2 == 0:
            S.append(a[2])
        else:
            S.insert(0, a[2])

print(''.join(S) if count % 2 == 0 else ''.join(S[::-1]))
Problem p02797 (python)

Fixed submission:
N, K, S = map(int, input().split())

A = []
A += [S]*K
if S == pow(10, 9):
    A += [1]*(N-K)
else:
    A += [S+1]*(N-K)


A = [str(i) for i in A]
print(' '.join(A))

Buggy submission (verdict: Runtime Error):
N, K, S = map(int, input().split())

if S == 1:
    A = [2]*N
    for i in range(K):
        A[i] = 1
elif S == 10e9:
    A = [2]*N
    for i in range(K+1):
        if i % 2 == 0:
            A[i] = S - 1
        else:
            A[i] = 1
else:
    A = [10**10]*N
    for i in range(K+1):
        if i % 2 == 0:
            A[i] = S - 1
        else:
            A[i] = 1


A = [str(i) for i in A]
print(' '.join(A))

Buggy submission (verdict: Runtime Error):
N, K, S = map(int, input().split())

if S != 10e9:
    A = [S+1]*N
else:
    A = [2]*N


for i in range(K+1):
    if i % 2 == 0:
        A[i] = S - 1
    else:
        A[i] = 1
A = [str(i) for i in A]
print(' '.join(A))

Buggy submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
A = [S+1]*N

for i in range(K+1):
    if i % 2 == 0:
        A[i] = S - 1
    else:
        A[i] = 1
A = [str(i) for i in A]
print(' '.join(A))

Buggy submission (verdict: Runtime Error):
N, K, S = map(int, input().split())
A = [10**10]*N

for i in range(K+1):
    if i % 2 == 0:
        A[i] = S - 1
    else:
        A[i] = 1
A = [str(i) for i in A]
print(' '.join(A))
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())

m1 = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        a = (i*j) % 2019
        if a == 0:
            print(0)
            exit()
        if a < m1:
            m1 = a
print(m1)

Buggy submission (verdict: Runtime Error):
N = R - L + 1
l = L % 2019

if N >= 2019:
    print(0)
    exit()

m = 2018
for i in range(N):
    a = (l + i) % 2019
    if a < m:
        m = a

print(m * (m + 1))
Problem p02996 (python)

Fixed submission:
N = int(input())

A = [0]*N
B = [0]*N

for i in range(N):
    A[i], B[i] = map(int, input().split())


indexes = [i for i in range(N)]
sorted_indexes = sorted(indexes, key=lambda i: B[i])

sorted_A = [A[i] for i in sorted_indexes]
sorted_B = [B[i] for i in sorted_indexes]

total = 0
for i in range(N):
    total += sorted_A[i]
    if total <= sorted_B[i]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
N = int(input())

A = [0]*N
B = [0]*N

for i in range(N):
    A[i], B[i] = map(int, input().split())


indexes = [*range(N)]
sorted_indexes = sorted(indexes, key=lambda i: B[i])

sorted_A = [A[i] for i in sorted_indexes]
sorted_B = [B[i] for i in sorted_indexes]

total = 0
for i in range(N):
    total += sorted_A[i]
    if total <= sorted_B[i]:
        continue
    else:
        print('No')
        exit()
print('Yes')
Problem p03043 (python)

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


def tell_power_number(number):
    i = 0
    while number * (2 ** i) < K:
        i += 1
    return i


ans = 0
if N <= K - 1:
    for k in range(1, N + 1):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
else:
    for k in range(1, K):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
    ans += (N - K + 1) / N

print(ans)

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


def tell_power_number(number):
    i = 0
    while number * (2 ** i) < K:
        i += 1
    return i


ans = 0
if N <= K - 1:
    for k in range(1, N + 1):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
else:
    for k in range(1, K):
        ans += 1 / N * (1 / 2) ** tell_power_number(k)
    ans += (N - K + 1) / N

print(ans)
Problem p03262 (python)

Fixed submission:
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))
y = []
x.insert(0, X)
x.sort()
for i in range(1, N+1):
    x1 = x[i] - x[i-1]
    y.append(x1)

d = y[0]

for i in range(1, len(y)):
    d = fractions.gcd(y[i], d)

print(d)

Buggy submission (verdict: Runtime Error):
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))

y = []

x.sort()
for i in range(1, N):
    x1 = x[i] - x[i-1]
    y.append(x1)

d = x[0] - X if X == 1 else y[0]

for i in range(1, N-1):
    d = fractions.gcd(y[i], d)

print(d)
Problem p03308 (python)

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

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

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

if A <= 8 and B <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int A, B;
  cin >> A >> B;
  if (A > 8 || B > 8)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
}
Problem p03425 (python)

Fixed submission:
from collections import Counter
from itertools import combinations

n = int(input())
s = [input()[0] for _ in range(n)]
lc = Counter(s)

con = []
for c in 'MARCH':
    if c in lc:
        con.append(lc[c])

ans = 0
for a, b, c in combinations(con, 3):
    ans += a * b * c

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [0] * N
d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s[i] = input()
    if s[i][0] == "M":
        d['M'] += 1
    elif s[i][0] == "A":
        d['A'] += 1
    elif s[i][0] == "R":
        d['R'] += 1
    elif s[i][0] == "C":
        d['C'] += 1
    elif s[i][0] == "H":
        d['H'] += 1

total = 1
count = 0
del_keys = []
for k, v in d.items():
    if v == 0:
        del_keys.append(k)
    else:
        total *= v
        count += 1

for key in del_keys:
    del d[key]

if count < 3:
    print(0)
    exit()
elif count == 3:
    print(total)
    exit()
elif count == 4:
    ans = 0
    for k, v in d.items():
        ans += total / v
    print(int(ans))
    exit()
elif count == 5:
    ans = 0
    d_lst = list(d)
    for i in range(4):
        for j in range(i+1, 5):
            ans += total / (d_lst[i] * d_lst[j])
    print(int(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [0] * N
d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s[i] = input()
    if s[i][0] == "M":
        d['M'] += 1
    elif s[i][0] == "A":
        d['A'] += 1
    elif s[i][0] == "R":
        d['R'] += 1
    elif s[i][0] == "C":
        d['C'] += 1
    elif s[i][0] == "H":
        d['H'] += 1

total = 1
count = 0
del_keys = []
for k, v in d.items():
    if v == 0:
        del_keys.append(k)
    else:
        total *= v
        count += 1

print(d)
for key in del_keys:
    del d[key]

if count < 3:
    print(0)
    exit()
elif count == 3:
    print(total)
    exit()
elif count == 4:
    ans = 0
    for k, v in d.items():
        ans += total / v
    print(int(ans))
    exit()
elif count == 5:
    ans = 0
    d_lst = list(d)
    for i in range(4):
        for j in range(i+1, 5):
            ans += total / (d_lst[i] * d_lst[j])
    print(int(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [0] * N
d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s[i] = input()
    if s[i][0] == "M":
        d['M'] += 1
    elif s[i][0] == "A":
        d['A'] += 1
    elif s[i][0] == "R":
        d['R'] += 1
    elif s[i][0] == "C":
        d['C'] += 1
    elif s[i][0] == "H":
        d['H'] += 1

total = 1
count = 0
del_keys = []
for k, v in d.items():
    if v == 0:
        del_keys.append(k)
    else:
        total *= v
        count += 1

for key in del_keys:
    del d[key]

if count < 3:
    print(0)
    exit()
elif count == 3:
    print(total)
    exit()
elif count == 4:
    ans = 0
    for k, v in d.items():
        ans += total / v
    print(ans)
    exit()
elif count == 5:
    ans = 0
    d_lst = list(d)
    for i in range(4):
        for j in range(i+1, 5):
            ans += total / (d_lst[i] * d_lst[j])
    print(ans)
Problem p03632 (python)

Fixed submission:
A, B, C, D = (int(x) for x in input().split())
ans = min(B, D) - max(A, C)
if ans < 0:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
A, B, C, D = (int(x) for x in input().split())
ans = min(B, D) - max(A - C)
if ans < 0:
    ans = 0
print(ans)
Problem p03659 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
x = a[0]
total = sum(a)
y = total - x
ans = abs(x - y)
for i in range(1, N-1):
    x += a[i]
    y -= a[i]
    m = abs(x-y)
    if ans > m:
        ans = m
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

if len(a) == 2:
    x = a[0]
    y = a[-1]
    print(abs(x-y))
    exit()


total = sum(a)
mid = total//2

for i in range(1, N):
    x += a[i]
    if x <= mid:
        continue
    else:
        print(min(abs(x-a[i]-(total - (x-a[i]))), abs(x-(total - x))))
        exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

if len(a) == 2:
    x = a[0]
    y = a[-1]
    print(abs(x-y))
    exit()


total = sum(a)
mid = total//2

print(mid)
for i in range(1, N):
    x += a[i]
    if x <= mid:
        continue
    else:
        print(x-(total - x))
        print(min(abs(x-a[i]-(total - (x-a[i]))), abs(x-(total - x))))
        exit()
Problem p03730 (python)

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

for i in range(1, B + 1):
    if A * i % B == C:
        print("YES")
        exit()

print("NO")

Buggy submission (verdict: Runtime Error):
import math
A, B, C = map(int, input().split())
q = math.gcd(A, B)

if A == 1:
    print("YES")
    exit()
if A % 2 == 0 and B % 2 == 0 and C % 2 == 1:
    print("NO")
    exit()
if math.gcd(q, C) == 1 and C != 1:
    print("NO")
else:
    print("YES")
Problem p02664 (python)

Fixed submission:
T = input()

for i, v in enumerate(T):
    if v == '?':
        print('D', end='')
    else:
        print(v, end='')
print('\n')

Buggy submission (verdict: Runtime Error):
T = input()

if T[0] == '?':
    T[0] = 'D'

for i, v in enumerate(T):
    if v == '?':
        if T[i - 1] == 'D':
            print('P', end='')
        else:
            print('D', end='')
    else:
        print(v, end='')

print('\n')
Problem p02755 (python)

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

a = int(A // 0.08) + 1
b = int(B // 0.1) + 1

ab = []
ab.append(min(a, b))
ab.append(max(a, b))

for i in ab:
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(i)
        exit(0)

print('-1')

Buggy submission (verdict: Runtime Error):
import sys

A, B = map(int, input().split())

a = int(A // 0.08) + 1
b = int(B // 0.1) + 1

ab = []
ab.append(min(a, b))
ab.append(max(a, b))

for i in ab:
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(f'{i}')
        sys.exit(0)

print('-1')

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

a = int(A // 0.08) + 1
b = int(B // 0.1) + 1

ab = []
ab.append(min(a, b))
ab.append(max(a, b))

for i in ab:
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(f'{i}')
        exit(0)
        
print('-1')
Problem p03457 (python)

Fixed submission:
n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]

ans = 'Yes'

for line in lst:
    t, x, y = line
    c1 = t < x + y
    c2 = t % 2 == 0 and (x + y) % 2 != 0
    c3 = t % 2 != 0 and (x + y) % 2 == 0
    
    if c1 or c2 or c3:
        ans = 'No'
        break

print(ans)

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

ans = 'Yes'

for line in lst:
    t, x, y = line
    c1 = t < x + y
    c2 = t % 2 == 0 and (x + y) % 2 != 0:
    c3 = t % 2 != 0 and (x + y) % 2 == 0:
    
    if c1 or c2 or c3:
        ans = 'No'
        break

print(ans)
Problem p04030 (python)

Fixed submission:
s=input()
l=list()
for i in str(s):
  if i == "B":
    if len(l) > 0:
      del l[-1]
    else:
      continue
  else:
    l.append(i)
a="".join(l)
print(a)

Buggy submission (verdict: Runtime Error):
s=input()
l=list()
for i in str(s):
  if i == "B":
    del l[-1]
  else:
    l.append(i)
a="".join(l)
print(a)
Problem p04044 (python)

Fixed submission:
N,L=map(int, input().split())
a=list(input() for i in range(N))
b=sorted(a)
c=''.join(b)
print(c)

Buggy submission (verdict: Runtime Error):
N,L=map (str(), input().split())
a=［str(i) for i in input().split()］
b=a.sort(a)
c=b.join()
print(c)
Problem p03485 (python)

Fixed submission:
a, b = map(int, input().split())
print(-(-(a+b)//2))

Buggy submission (verdict: Runtime Error):
a, b = int(input().split())
print((a+b)//2)
Problem p03493 (python)

Fixed submission:
s = input()

print(s.count("1"))

Buggy submission (verdict: Runtime Error):
N = int(input())
listA = list(map(int, input()))
cnt = 0

while(True):
    for A in listA:
        if A % 2 != 0:
            break
        else:
            A = A / 2
    
    cnt += 1
print(cnt)
Problem p03597 (python)

Fixed submission:
N, A = [int(input()) for i in range(2)]
print(N ** 2 - A)

Buggy submission (verdict: Runtime Error):
N, A = [input() for i in range(2)]
print(N ** 2 - A)
Problem p03671 (python)

Fixed submission:
a = list(map(int, input().split()))
a.sort()
print(a[0]+a[1])

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())
a.sort()
print(a[0]+a[1])
Problem p03773 (python)

Fixed submission:
A, B = map(int, input().split())
print(A+B -24*((A+B)//24) if A+B >=24 else A+B)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(A+B -24*((A+B)//24) if A+B > =24 else A+B)
Problem p02755 (python)

Fixed submission:
import sys
import numpy as np
A, B = map(int,input().split())
amin, amax = A / 0.08, (A + 1) / 0.08
bmin, bmax = B / 0.10, (B + 1) / 0.10

if amax <= bmin or bmax <= amin:#解なし：区間重なりなし
    print(-1)
    sys.exit()

ans = np.ceil(max(amin, bmin)).astype(int)

if ans >= amax or ans >= bmax:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
A, B = map(int,input().split())
amin, amax = A / 0.08, (A + 1) / 0.08
bmin, bmax = B / 0.10, (B + 1) / 0.10

if amax <= bmin or bmax <= amin:#解なし：区間重なりなし
    print(-1)
    sys.exit()

ans = np.ceil(max(amin, bmin)).astype(int)

if ans >= amax or ans >= bmax:
    print(-1)
else:
    print(ans)
Problem p02900 (python)

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

import fractions
gcd = fractions.gcd(A, B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if gcd == 1:
    print(1)
else:
    fact = factorization(gcd) 
    print(len(fact) + 1)

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

import math
gcd = math.gcd(A, B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if gcd == 1:
    print(1)
else:
    fact = factorization(gcd) 
    print(len(fact) + 1)
Problem p02972 (python)

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

res = [0] * N
for idx, ai in zip(range(N-1, -1, -1), As[::-1]):
    oe = sum([res[i] for i in range(idx, N, idx+1)]) % 2#
    res[idx] = ai ^ oe

print(sum(res))
idxs = []
for i, val in enumerate(res):
    if val:
        idxs += [i + 1]
print(*idxs)

Buggy submission (verdict: Runtime Error):
N = int(input())
As = list(map(int, input().split()))

res = [0] * N
for idx, ai in zip(np.arange(N-1, -1, -1), As[::-1]):
    oe = sum([res[i] for i in range(idx, N, idx+1)]) % 2#
    res[idx] = ai ^ oe

print(sum(res))
idxs = []
for i, val in enumerate(res):
    if val:
        idxs += [i + 1]
print(*idxs)
Problem p03109 (python)

Fixed submission:
import numpy as np
y, m, d = map(int, input().split("/"))

if y > 2019:
    print("TBD")
elif m > 4:
    print("TBD")
elif d > 30:
    print("TBD")
else:
    print("Heisei")

Buggy submission (verdict: Runtime Error):
import numpy as np
from functools import lru_cache

A, B, Q = map(int, input().split())
adisps = np.array([int(input()) for _ in range(A)])
bdisps = np.array([int(input()) for _ in range(B)])
qdisps = np.array([int(input()) for _ in range(Q)])

@lru_cache(maxsize=100000)
def nearest(now, flag):
    disps = adisps if flag == 0 else bdisps
    idx = np.argmin(np.abs(disps - now))
    nearest_point = disps[idx]
    cost = np.abs(now - nearest_point)
    return nearest_point, cost

for qdisp in qdisps:

    #A→B
    pos_a1, cost_a1 = nearest(qdisp, 0)
    pos_b1, cost_b1 = nearest(pos_a1, 1)
    cost1 = cost_a1 + cost_b1

    #B→A
    pos_b2, cost_b2 = nearest(qdisp, 1)
    pos_a2, cost_a2 = nearest(pos_b2, 0)
    cost2 = cost_a2 + cost_b2

    ans = min(cost1, cost2)
    print(ans)