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

Fixed submission:
A,B,Q = list(map(int, input().split()))
s,t,xx=[],[],[]

for i in range(A):
    s.append(int(input()))
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    xx.append(int(input()))
    
import bisect
M = 10000000000000

for x in xx:
    i = bisect.bisect_left(s,x)
    j = bisect.bisect_left(t,x)
    
    if (i > 0) and (j > 0):
        ll = abs(min(s[i-1]-x, t[j-1]-x))
    else:
        ll = M
        
    if (i > 0) and (j < B):
        lr = abs(s[i-1]-x) * 2 + (t[j]-x)
    else:
        lr = M
        
    if (i < A) and (j > 0):
        lr_2 = abs(t[j-1]-x) * 2 + (s[i]-x)
    else:
        lr_2 = M
        
    if (i < A) and (j > 0):
        rl = (s[i]-x) * 2 + abs(t[j-1] - x)
    else:
        rl = M
        
    if (i > 0) and (j < B):
        rl_2 = (t[j]-x) * 2 + abs(s[i-1] - x)
    else:
        rl_2 = M
        
    if (i < A) and (j < B):
        rr = max(s[i]-x,t[j]-x)
    else:
        rr = M

    print(min(ll,lr,rl,rr,lr_2,rl_2))

Buggy submission (verdict: Runtime Error):
A,B,Q = list(map(int, input().split()))
s,t,xx=[],[],[]

for i in range(A):
    s.append(int(input()))
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    xx.append(int(input()))
    
import bisect
M = 10000000000000

for x in xx:
    i = bisect.bisect_left(s,x)
    j = bisect.bisect_left(t,x)
    
    if (i > 0) and (j > 0):
        ll = abs(min(s[i-1]-x, t[j-1]-x))
    else:
        ll = M
    if (i > 0) and (j < B):
        lr = abs(s[i-1]-x) * 2 + (t[j]-x)
    else:
        lr = M
    if (i < A) and (j > 0):
        lr_2 = abs(t[j-1]-x) * 2 + (s[i]-x)
    else:
        lr_2 = M
    if (i < A) and (j > 0):
        rl = (s[i]-x) * 2 + abs(t[j-1] - x)
    else:
        rl = M
    if (i > 0) and (j < B):
        rl_2 = (t[j]-x) * 2 + abs(s[i-1] - x)
    else:
        rl_2 = M
    if (i < A) and (j < B):
        rr = max(s[i]-x,t[i]-x)
    else:
        rr = M

    print(min(ll,lr,rl,rr,lr_2,rl_2))

Buggy submission (verdict: Runtime Error):
A,B,Q = list(map(int, input().split()))
s,t,xx=[],[],[]

for i in range(A):
    s.append(int(input()))
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    xx.append(int(input()))
    
import bisect
M = float('inf')

for x in xx:
    i = bisect.bisect_left(s,x)
    j = bisect.bisect_left(t,x)
    
    if (i > 0) and (j > 0):
        ll = abs(min(s[i-1]-x, t[j-1]-x))
    else:
        ll = M
    if (i > 0) and (j < B):
        lr = abs(s[i-1]-x) * 2 + (t[j]-x)
    else:
        lr = M
    if (i < A) and (j > 0):
        lr_2 = abs(t[j-1]-x) * 2 + (s[i]-x)
    else:
        lr_2 = M
    if (i < A) and (j > 0):
        rl = (s[i]-x) * 2 + abs(t[j-1] - x)
    else:
        rl = M
    if (i > 0) and (j < B):
        rl_2 = (t[j]-x) * 2 + abs(s[i-1] - x)
    else:
        rl_2 = M
    if (i < A) and (j < B):
        rr = max(s[i]-x,t[i]-x)
    else:
        rr = M

    print(min(ll,lr,rl,rr,lr_2,rl_2))
Problem p03160 (python)

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

INF = float('Inf')
tbl = [INF] * N
tbl[0] = 0
tbl[1] = abs(hs[1]-hs[0])

for i in range(2,N):
    tbl[i] = min(tbl[i-2]+abs(hs[i]-hs[i-2]),
                 tbl[i-1]+abs(hs[i]-hs[i-1]))

print(tbl[N-1])

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

INF = float('Inf')
tbl = [INF] * N
tbl[0] = 0
tbl[1] = abs(hs[1]-hs[0])

def dp(i):
    if tbl[i] != INF:
        return tbl[i]
    else:
        res = min(dp(i-2)+abs(hs[i]-hs[i-2]),
                 dp(i-1)+abs(hs[i]-hs[i-1]))
        tbl[i] = res
        return res

print(dp(N-1))
Problem p03195 (python)

Fixed submission:
N = int(input())
ais = []
for i in range(N):
    ais.append(int(input()))
bis = list(map(lambda x: x%2, ais))
if bis==[0]*N:
    print("second")
else:
    print("first")

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

N = int(input())
ais = []
for i in range(N):
    ai = int(input())
    ais.append(ai)
ais.sort(reverse=True)

if ((ais[0] - ais[1]) % 2) == 0:
    print("second")
else:
    print("first")
Problem p03231 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, M = list(map(int, input().split()))
S = input()
T = input()

if S[0]!=T[0]:
    print(-1)
else:
    if N==M:
        print(int(N*M)) if S==T else print(-1)
    else:
        g = gcd(N, M)
        if g==1:
            print(int(N*M))
        else:
            flag = False
            s, t = N//g, M//g
            ss = list(map(lambda x: int(x*s), list(range(0,g))))
            tt = list(map(lambda x: int(x*t), list(range(0,g))))
            for i,j in zip(ss,tt):
                if S[i]!=T[j]:
                    flag = True
            if flag:
                print(-1)
            else:
                print(int(s*t*g))

Buggy submission (verdict: Runtime Error):
import math

N, M = list(map(int, input().split()))
S = str(input())
T = str(input())

if N==M:
    print(int(N*M)) if S==T else print(-1)
else:
    g = math.gcd(N, M)
    if g==1:
        print(int(N*M))
    else:
        flag = False
        s, t = N//g, M//g
        ss = list(map(lambda x: int(x*s), list(range(0,g))))
        tt = list(map(lambda x: int(x*t), list(range(0,g))))
        for i,j in zip(ss,tt):
            if S[i]!=T[j]:
                flag = True
        if flag:
            print(-1)
        else:
            print(int(s*t*g))

Buggy submission (verdict: Runtime Error):
import math

N, M = list(map(int, input().split()))
S = str(input())
T = str(input())

if N==M:
    print(int(N*M)) if S==T else print(-1)
else:
    g = math.gcd(N, M)
    if g==1:
        print(int(N*M))
    else:
        flag = False
        s, t = N/g, M/g
        ss = list(map(lambda x: int(x*s), list(range(0,g))))
        tt = list(map(lambda x: int(x*t), list(range(0,g))))
        for i,j in zip(ss,tt):
            if S[i]!=T[j]:
                flag = True
        if flag:
            print(-1)
        else:
            print(int(s*t*g))

Buggy submission (verdict: Runtime Error):
import math

N, M = list(map(int, input().split()))
S = input()
T = input()

if N==M:
    print(int(N*M)) if S==T else print(-1)
else:
    g = math.gcd(N, M)
    if g==1:
        print(int(N*M))
    else:
        flag = False
        s, t = N/g, M/g
        ss = list(map(lambda x: int(x*s), list(range(0,g))))
        tt = list(map(lambda x: int(x*t), list(range(0,g))))
        for i,j in zip(ss,tt):
            if S[i]!=T[j]:
                flag = True
        if flag:
            print(-1)
        else:
            print(int(s*t*g))
Problem p03309 (python)

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

# ずらす
for i in range(N):
    A[i] = A[i] - (i+1)

A = sorted(A)
m = float('inf')
bs = []

# 探索対象
if N//2-1<N:
    bs.append(A[N//2-1])
if N//2<N:
    bs.append(A[N//2])
if N//2+1<N:
    bs.append(A[N//2+1])

for b in bs:
    diff = sum(list(map(lambda x: abs(x-b),A)))
    m = min(m,diff)

print(m)

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

A = sorted(A)
m = float('inf')
for b in [A[N//2-1], A[N//2], A[N//2+1]]:
    diff = sum(list(map(lambda x: abs(x-b),A)))
    m = min(m,diff)

print(m)
Problem p03550 (python)

Fixed submission:
N,Z,W = list(map(int,input().split()))
a = list(map(int,input().split()))
if len(a)>1:
    ans = max(abs(a[-1]-a[-2]), abs(W-a[-1]))
else:
    ans = abs(W-a[-1])
print(ans)

Buggy submission (verdict: Runtime Error):
N,Z,W = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = max(abs(a[-1]-a[-2]), abs(W-a[-1]))
print(ans)
Problem p03633 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N = int(input())
ans = 1

for i in range(0,N):
    t = int(input())
    ans = t * ans // gcd(ans, t)

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N = int(input())
ans = 1

for i in range(0,N):
    t = int(input())
    ans = int((ans / gcd(ans, t) * t))

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N = int(input())
ans = 1
for i in range(0,N):
    t = int(input())
    if t == 1000000000000000000:
        ans = 1000000000000000000
        break
    ans = int((ans * t) / gcd(ans, t))
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N = int(input())
ans = 1
for i in range(0,N):
    t = int(input())
    ans = int(t * (ans / gcd(ans, t)))
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N = int(input())
ans = 1
for i in range(0,N):
    t = int(input())
    ans = int((ans * t) / gcd(ans, t))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = 1
for i in range(0,N):
    t = int(input())
    ans = int((ans * t) / math.gcd(ans, t))
print(ans)
Problem p03660 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
g = [[] for i in range(N)]
 
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a,b = a-1,b-1
    g[a] += [b]
    g[b] += [a]
    
def bfs(g, st):
    queue = [st]
    distances = [-1 for i in range(N)]
    distances[st] = 0
    
    while queue:
        node = queue.pop(0)
        for h in g[node]:
            if distances[h] == -1:
                distances[h] = distances[node] + 1
                queue += [h]
 
    return distances
 
dB = bfs(g, 0)
dW = bfs(g, N-1)
 
B, W = 0, 0
for i in range(N):
    if dB[i] <= dW[i]:
        B += 1
    else:
        W += 1
print("Fennec" if B > W else "Snuke")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
g = [[] for i in range(N)]
 
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a,b = a-1,b-1
    g[a] += [b]
    g[b] += [a]
    
def bfs(g, st):
    queue = [st]
    distances = [-1 for i in range(N)]
    distances[st] = 0
    
    while queue:
        node = queue.pop(0)
        for h in g[node]:
            if distances[h] == -1:
                distances[h] = distances[node] + 1
                queue += h
 
    return distances
 
dB = bfs(g, 0)
dW = bfs(g, N-1)
 
B, W = 0, 0
for i in range(N):
    if dB[i] <= dW[i]:
        B += 1
    else:
        W += 1
print("Fennec" if B > W else "Snuke")
Problem p03827 (python)

Fixed submission:
n = int(input())
s = list(map(lambda x: 1 if x == "I" else -1, list(input())))
x = 0
m = 0
for i in s:
    x += i
    m = max(m,x)
print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(map(lambda x: 1 if x == "I" else -1, list(input()))
x = 0
m = 0
for i in s:
    x += i
    m = max(m,x)
print(m)
Problem p03828 (python)

Fixed submission:
from functools import reduce
MOD = 10**9 + 7
primes = list(map(int, "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997".split(" ")))

N = int(input())
arr = []

for p in primes:
    if p <= N:
        pow_p = p
        s = 0
        while pow_p <= N:
            s += N // pow_p
            pow_p *= p
        arr.append(s+1)

if N == 1:
    print(1)
else:
    print(reduce(lambda a, b: (a * b) % MOD, arr))

Buggy submission (verdict: Runtime Error):
from functools import reduce
MOD = 10**9 + 7
primes = list(map(int, "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997".split(" ")))

N = int(input())
arr = []

for p in primes:
    if p <= N:
        pow_p = p
        s = 0
        while pow_p <= N:
            s += N // pow_p
            pow_p *= p
        arr.append(s+1)

print(reduce(lambda a, b: (a * b) % MOD, arr))
Problem p03837 (python)

Fixed submission:
from collections import defaultdict
from heapq import heappop, heappush

class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]

g = Graph()
N,M = list(map(int, input().split()))
INF = 10**9+7
A = [[INF if i!=j else 0 for i in range(N)] for j in range(N)]
S=[]
E=[]
W=[]

for i in range(M):
    s,e,w=list(map(int,input().split()))
    g.add_edge(s-1, e-1, w)
    g.add_edge(e-1, s-1, w)
    S.append(s-1)
    E.append(e-1)
    W.append(w)

for i in range(N):
    d = Dijkstra(g, i)
    for j in range(i+1,N):
        dist = d.shortest_distance(j)
        A[i][j] = dist
        A[j][i] = dist
        
ans=M
for i in range(M):
    shortest = False
    for j in range(N):
        if A[j][S[i]] + W[i] == A[j][E[i]]:
            shortest = True
    if shortest:
        ans-=1

print(ans)

Buggy submission (verdict: Runtime Error):
g = Graph()
N,M = list(map(int, input().split()))
INF = 10**9+7
A = [[INF if i!=j else 0 for i in range(N)] for j in range(N)]
S=[]
E=[]
W=[]

for i in range(M):
    s,e,w=list(map(int,input().split()))
    g.add_edge(s-1, e-1, w)
    g.add_edge(e-1, s-1, w)
    S.append(s-1)
    E.append(e-1)
    W.append(w)

for i in range(N):
    d = Dijkstra(g, i)
    for j in range(i+1,N):
        dist = d.shortest_distance(j)
        A[i][j] = dist
        A[j][i] = dist
        
ans=M
for i in range(M):
    shortest = False
    for j in range(N):
        if A[j][S[i]] + W[i] == A[j][E[i]]:
            shortest = True
    if shortest:
        ans-=1

print(ans)
Problem p03963 (python)

Fixed submission:
import math
n, m = list(map(int, input().split()))
print(m*pow(m-1,n-1))

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = [input() for i in range(n)]
print(n,m)

##
## Template
##

## map, filter, reduce

# map(lambda x: x*2, range(10))
# filter(lambda x: x % 2, range(10))
# from functools import reduce
# reduce(lambda sum,x: sum+x, range(10))
# [x * 2 for x in range(1, 10) if x % 3 == 1]
# => [2, 8, 14]
Problem p03973 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
arr = []
for i in range(n):
    arr.append(int(input()))
count = max(arr[0]-1,0)
index = 2
for i in range(1,n):
    if arr[i] > index:
        count += (arr[i] - 1) // index
    if arr[i] == index:
        index += 1
print(count)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
arr = [int(input()) for _ in range(N)]
count = arr[0]-1
m = 1
for a in arr[1:]:
    if a == m:
        m += 1
    if a > m:
        count += (a - 1) // (m+1)
print(count)
Problem p03992 (python)

Fixed submission:
n = input();print(n[0:4]+" "+n[4:12])

##
## Template
##

## map, filter, reduce

# map(lambda x: x*2, range(10))
# filter(lambda x: x % 2, range(10))
# from functools import reduce
# reduce(lambda sum,x: sum+x, range(10))
# [x * 2 for x in range(1, 10) if x % 3 == 1]
# => [2, 8, 14]

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = [input() for i in range(n)]
print(n,m)

##
## Template
##

## map, filter, reduce

# map(lambda x: x*2, range(10))
# filter(lambda x: x % 2, range(10))
# from functools import reduce
# reduce(lambda sum,x: sum+x, range(10))
# [x * 2 for x in range(1, 10) if x % 3 == 1]
# => [2, 8, 14]
Problem p03997 (python)

Fixed submission:
a, b, h = [int(input()) for i in range(3)]
print(int((a + b) * h / 2))

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
h = input()
print((a+b)*h/2)
Problem p02741 (python)

Fixed submission:
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
th = K-1
print(elements[th])

Buggy submission (verdict: Runtime Error):
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = raw_input()
th = K-1
print(elements[th])

Buggy submission (verdict: Runtime Error):
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = input()
th = K-1
print(elements[th])

Buggy submission (verdict: Runtime Error):
th = K-1
print(elements[th])

Buggy submission (verdict: Runtime Error):
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
th = K-1
print(elements[th])

Buggy submission (verdict: Runtime Error):
th = K-1
print(elements[th])

Buggy submission (verdict: Runtime Error):
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
th = K-1
print(elements[th])

Buggy submission (verdict: Runtime Error):
K -= 1
for i, val in enumerate(elements):
    if i is K:
        print(val)
        break

Buggy submission (verdict: Runtime Error):
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51

for i, val in enumerate(elements):
    if i is K:
        print(val)
        break

Buggy submission (verdict: Runtime Error):
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

th = K-1
print(elements[th])

Buggy submission (verdict: Runtime Error):
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

if K < 16:
    th = K-1
    print(elements[th])
else:
    th = -(32-K)-1
    print(elements[th])

Buggy submission (verdict: Runtime Error):
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

if K < 16:
    print(elements[K-1])
else:
    print(elements[-(32-K)-1])

Buggy submission (verdict: Runtime Error):
elements = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


if K < 16:
    print(elements[K-1])
else:
    print(elements[-(32-K)-1])
Problem p02743 (python)

Fixed submission:
a, b, c = input().split()

a, b, c = int(a), int(b), int(c)

if c-a-b > 0 and 4*a*b < (c-a-b)**2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

if a**2 + b**2 < c**2:
    print(Yes)
else:
    print(No)
Problem p02741 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    i = int(input())
    print(s[i-1])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    a,b,c = map(int,input().split())
    if (a ** (1/2)+b **(1/2) - c **(1/2)) > 1e-12:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Problem p02900 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n,m = map(int,input().split())

from fractions import gcd
a = gcd(n,m)

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

t = factorization(a) 

if (n == 1) or (m == 1):
    print(1)
else:
    print(len(t)+1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,m = map(int,input().split())

from fractions import gcd
a = gcd(n,m)

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

t = seachPrimeNum(10*8)
for item in t:
    if a % item == 0:
        c += 1

print(c)
Problem p02972 (python)

Fixed submission:
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = [0] * n
    for i in range(n,n//2,-1):
        if s[i-1] == 1:
            r[i-1] = 1
    for i in range(n//2,0,-1):
        p = n // i
        c = 0
        for j in range(1,p+1):
            if r[(j * i) - 1] == 1:
                c += 1
        if c % 2 != s[i-1]:
            r[i-1] = 1

    o = sum(r)
    print(o)
    if o > 0:
        u = []
        for i in range(len(r)):
            if r[i] == 1:
                u.append(str(i+1))
        print(" ".join(u))
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = []
    for i in range(n,0,-1):
        c = sum(x % i == 0 for x in r)
        c1 = c % 2
        if c1 != s[i-1]:
            r.append(str(i))

    print(len(r))
    if len(r) > 0:
        print(" ".join(r))
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = list(map(int,input().split()))
    r = []
    for i in range(n,0,-1):
        c = sum(x % i == 0 for x in r)
        c1 = c % 2
        if c1 != s[i-1]:
            r.append(str(i))
            
    print(len(r))
    print(" ".join(r))
    

if __name__ == "__main__":
    main()