Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if (r<0 or r>n):
        return(0)
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2,N+1):
    g1.append(( g1[-1] * i ) % mod)
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
n,k=map(int,input().split())
for i in range(1,K+1):
    ans = cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod)
    print(ans%mod)

Fixed submission:
def cmb(n, r, mod):
    if (r<0 or r>n):
        return(0)
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2,N+1):
    g1.append(( g1[-1] * i ) % mod)
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
n,k=map(int,input().split())
for i in range(1,k+1):
    ans = cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod)
    print(ans%mod)

Buggy python submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if (r<0 or r>n):
        return(0)
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2,N+1):
    g1.append(( g1[-1] * i ) % mod)
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
n,k=map(int,input().split())
for i in range(1,K+1):
    ans = cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod)
    print(ans%mod)

Fixed submission:
def cmb(n, r, mod):
    if (r<0 or r>n):
        return(0)
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2,N+1):
    g1.append(( g1[-1] * i ) % mod)
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
n,k=map(int,input().split())
for i in range(1,k+1):
    ans = cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod)
    print(ans%mod)

Buggy python submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
n,k=map(int,input().split())
for i in range(1,K+1):
    ans = cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod)
    print(ans%mod)

Fixed submission:
def cmb(n, r, mod):
    if (r<0 or r>n):
        return(0)
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2,N+1):
    g1.append(( g1[-1] * i ) % mod)
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
n,k=map(int,input().split())
for i in range(1,k+1):
    ans = cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod)
    print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=list(map(int, input().split()))
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        tmp = (N-(r*R+g*G))
        if tmp>=0:
            if tmp%B==0:
                cnt += 1
print(cnt)

Fixed submission:
R,G,B,N=list(map(int, input().split()))
arr = [R,G,B]
arr = sorted(arr, reverse=True)
R,G,B = arr

cnt = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        tmp = (N-(r*R+g*G))
        if tmp>=0:
            if tmp%B==0:
                cnt += 1
print(cnt)
Buggy python 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))

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 python 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")

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 python 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)

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 python 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)

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 python 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)

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 python 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)

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 python 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)

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 python 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)

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 python 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)

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 python 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")

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 python submission (verdict: Time Limit Exceeded):
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 += g[node]

    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")

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 python 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)


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 python 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))


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 python 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)

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 python 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]


Fixed submission:
import math
n, m = list(map(int, input().split()))
print(m*pow(m-1,n-1))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
a = [['_' for i in range(n)] for i in range(n)]
def dp(i,j):
    if i==n:
        return 0
    if a[i][j] != '_':
        return a[i][j]
    if j==0:
        a[i][j] = dp(i+1,1) + (0 if s[i]=='g' else -1)
        return a[i][j]
    else:
        x = dp(i+1,j+1) + (0 if s[i]=='g' else -1)
        y = dp(i+1,j-1) + (1 if s[i]=='g' else 0)
        a[i][j] = max(x,y)
        return a[i][j]
print(dp(0,0))


Fixed submission:
s=input();n=len(s)//2;m=s.count('p');print(n-m);
Buggy python 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)

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 python 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]


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 python submission (verdict: Runtime Error):
a = input()
b = input()
h = input()
print((a+b)*h/2)

Fixed submission:
a, b, h = [int(input()) for i in range(3)]
print(int((a + b) * h / 2))
Buggy python submission (verdict: Time Limit Exceeded):
import re
n = int(input())
d = input().split()
m = int(input())
t = input().split()

if len(d) < len(t):
    print("NO")
    exit()

t_size = len(t)
t_sorted = sorted(t)
reg = [] 
for i in range(0, t_size-2):
    if t_sorted[i] == t_sorted[i+1]:
        reg.append(t_sorted[i])
    else:
        reg.append(t_sorted[i]+".*")

reg.append(t_sorted[t_size-1])

reg_pattern = re.compile("".join(reg));
match = re.search(reg_pattern,"".join(sorted(d)))    

if match:
    print("YES")
else:
    print("NO")


Fixed submission:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

summary_d = {}
summary_t = {}

for i in range(0, len(d)):
    summary_d[d[i]] = summary_d.get(d[i],0) + 1

for i in range(0, len(t)):
    summary_t[t[i]] = summary_t.get(t[i],0) + 1

result = {}

for k,v in summary_t.items():
    result[k] = summary_d.get(k,0) - v

if min(result.values()) >= 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
p = functools.reduce(lambda x,y: x * y, range(1, n+1)) % (10**9 + 7)
print(p)


Fixed submission:
MOD = 10**9 + 7
n = int(input())

p = 1
for i in range(2, n + 1):
    p = p * i % MOD
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
def find_gcd(x, y):
    while(y): 
        x, y = y, x % y 
    return x


nums = int(input())
result = 0

for i in  range(1, nums+1):
    for j in range(1, nums+1):
        for l in range(1, nums+1):
            result += find_gcd(find_gcd(i, j), l)

print(result)

Fixed submission:
from math import gcd

nums = int(input())
result = 0

gcd_dict = {}

for i in  range(1, nums+1):
    for j in range(1, nums+1):
        for l in range(1, nums+1):
            result += gcd(gcd(i, j), l)

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
def find_gcd(x, y, gcd_dict):
    if (x, y) in gcd_dict.keys():
        return gcd_dict[x, y]
    elif (y, x) in gcd_dict.keys():
        return gcd_dict[y, x]
    else:
        x_first = x
        y_first = y
        gcd_dict[x, y] = x
        while(y): 
            x, y = y, x % y 

        #print(x_first, y_first)
        gcd_dict[x_first, y_first] = x

    return x

nums = int(input())
result = 0

gcd_dict = {}

for i in  range(1, nums+1):
    for j in range(1, nums+1):
        for l in range(1, nums+1):
            gcd = find_gcd(i, j, gcd_dict)
            result += find_gcd(gcd, l, gcd_dict)

print(result)

Fixed submission:
from math import gcd

nums = int(input())
result = 0

gcd_dict = {}

for i in  range(1, nums+1):
    for j in range(1, nums+1):
        for l in range(1, nums+1):
            result += gcd(gcd(i, j), l)

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
def find_gcd(x, y):

    while(y):
        x, y = y, x%y

    return x

nums = int(input())
result = 0

for i in  range(1, nums+1):
    for j in range(1, nums+1):
        for l in range(1, nums+1):
            gcd = find_gcd(i, j)
            result += find_gcd(gcd, l)

print(result)

Fixed submission:
from math import gcd

nums = int(input())
result = 0

gcd_dict = {}

for i in  range(1, nums+1):
    for j in range(1, nums+1):
        for l in range(1, nums+1):
            result += gcd(gcd(i, j), l)

print(result)
Buggy python submission (verdict: Runtime Error):

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

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 python submission (verdict: Runtime Error):
import math
def combination(n, r):
    if n <= 0:
        return 0
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

n, m= input().split(" ")
n = int(n)
m = int(m)

print(combination(n, 2) + combination(m,2))

Fixed submission:
import math
def combination(n, r):
    if n <= 0 or n is 1:
        return 0
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

n, m= input().split(" ")
n = int(n)
m = int(m)

print(combination(n, 2) + combination(m,2))

Buggy python submission (verdict: Runtime Error):
import math
def combination(n, r):
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

n, m= input().split(" ")
n = int(n)
m = int(m)

print(combination(n, 2) + combination(m,2))

Fixed submission:
import math
def combination(n, r):
    if n <= 0 or n is 1:
        return 0
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

n, m= input().split(" ")
n = int(n)
m = int(m)

print(combination(n, 2) + combination(m,2))
Buggy python 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()

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()