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

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
H = LI()
if N==1:
    print('Yes')
    exit()
if N==2:
    print('Yes' if H[0]-1<=H[1] else 'No')
    exit()
for i in range(N-1):
    if i==0:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    print('No')
    break
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
H = LI()
for i in range(N-1):
    print(H)
    if i==0:
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')
Problem p02982 (python)

Fixed submission:
import numpy
N, D = map(int, input().split())
listx = []
count = 0
for i in range(N):
    x = list(map(int, input().split()))
    listx.append(x)

for j in range(0, N):
    for k in range(j+1,N):
        a = numpy.array(listx[j])
        b = numpy.array(listx[k])
        u = b - a
        c = float(numpy.linalg.norm(u))
        if c.is_integer() :
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
def LI(): return list(map(int,input().split()))
N,D = LI()
X = [LI() for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        temp = 0
        for k in range(D):
            temp += (X[j][k]-X[i][k])**2
        if temp **0.5%1==0:
        ans += 1
print(ans)
Problem p02995 (python)

Fixed submission:
import fractions
def main(A,B,C,D):
    allAB = B - A + 1
    divC = B // C - (A-1) // C
    divD = B // D - (A-1) // D
    lcmCD = lcm(C,D)
    divCD = B // (lcmCD) - (A-1) // (lcmCD)
    count = allAB - divC - divD + divCD
    return count

def lcm(x, y):
    return (x*y) // fractions.gcd(x,y)
    
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))

Buggy submission (verdict: Runtime Error):
import math
def main(A,B,C,D):
    allAB = B - A + 1
    divC = B // C - (A-1) // C
    divD = B // D - (A-1) // D
    lcmCD = lcm(C,D)
    divCD = B // (lcmCD) - (A-1) // (lcmCD)
    count = allAB - divC - divD + divCD
    return count

def lcm(x, y):
    return (x*y) // math.gcd(x,y)
    
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))

Buggy submission (verdict: Runtime Error):
import math
def main(A,B,C,D):
    allAB = B - A + 1
    divC = B // C - (A-1) // C
    divD = B // D - (A-1) // D
    lcmCD = lcm(C,D)
    divCD = B // (lcmCD) - (A-1) // (lcmCD)
    count = allAB - divC - divD + divCD
    return count

def lcm(x, y):
    return (x*y) // math.gcd(x,y)
    
    
A,B,C,D = map(int, input().split())
print(main(A,B,C,D))
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())
S = W * H / 2
if W / 2 == x and H / 2 == y:
    res = 1
else:
    res = 0
print(S, res)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
S = W * H / 2
if W / x == 2 and H / y == 2:
    res = 1
else:
    res = 0
print(S, res)
Problem p03086 (python)

Fixed submission:
S = input()
ACGT = 'ACGT'
ans = 0
temp = 0
for x in S:
    if x in ACGT:
        temp += 1
    else:
        ans = max(ans, temp)
        temp = 0
ans = max(ans, temp)
print(ans)

Buggy submission (verdict: Runtime Error):
S = return sys.stdin.readline().rstrip()
ans,temp = 0,0
for x in S:
    if x in 'ACGT':
        temp += 1
        ans = max(ans,temp)
    else:
        temp = 0
print(ans)
Problem p03161 (python)

Fixed submission:
def main(N, K, h):
    dp = [float('INF')] * N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i+j <= N-1:
                dp[i+j] = min(dp[i+j], dp[i] + (abs(h[i+j] - h[i])))
    return dp[-1]

N,K = map(int, input().split())
h = list(map(int,input().split()))
print(main(N, K, h))

Buggy submission (verdict: Runtime Error):
2 100
10 10
Problem p03164 (python)

Fixed submission:
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i,j in itertools.product(range(1,N+1),range(V+1)):
    w,v = wv[i-1]
    if j-v>=0:
        dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
    dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
        for j in range(V+1)):
        if j-v>=0 and dp[i-1][j-v]+w<=W:
            dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
        dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))
Problem p03280 (python)

Fixed submission:
A,B = map(int,input().split())
print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
def I(): return int(input())
N = I()
ans = 0
for i in range(105,N+1,2):
    count_yakusuu = 0
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count_yakusuu += 2
    if count_yakusuu==8:
        ans += 1
print(ans)
Problem p03436 (python)

Fixed submission:
import collections,itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
s = [S() for _ in range(H)]
black_count = 0
for i,j in itertools.product(range(H),range(W)):
    if s[i][j]=='#':
        black_count += 1
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
min_dist = [[-1]*W for _ in range(H)]
seen = [[0]*W for _ in range(H)]
queue = collections.deque() #位置[行,列]を入れておく
def bfs():
    seen[0][0] = 1
    queue.append([0,0])
    min_dist[0][0] = 1
    while queue:
        qh,qw = queue.popleft()
        for dh,dw in dhdw:
            nh,nw = qh+dh,qw+dw
            if not(0<=nh<=H-1) or not(0<=nw<=W-1) or seen[nh][nw] or s[nh][nw]=='#':
                continue
            seen[nh][nw] = 1
            queue.append([nh,nw])
            min_dist[nh][nw] = min_dist[qh][qw]+1
bfs()
if min_dist[H-1][W-1]!=-1:
    print(H*W-black_count-min_dist[H-1][W-1])
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import collections,itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
s = [S() for _ in range(H)]
black_count = 0
for i,j in itertools.product(range(H),range(W)):
    if s[i][j]=='#':
        black_count += 1
dhdw = [[-1,0],[1,0],[0,-1],[0,1]]
min_dist = [[-1]*W for _ in range(H)]
seen = [[0]*W for _ in range(H)]
queue = collections.deque() #位置[行,列]を入れておく
def bfs():
    seen[0][0] = 1
    queue.append([0,0])
    min_dist[0][0] = 1
    while queue:
        qh,qw = queue.popleft()
        for dh,dw in dhdw:
            nh,nw = qh+dh,qw+dw
            if not(0<=nh<=H-1) or not(0<=nw<=W-1) or seen[nh][nw] or s[nh][nw]=='#':
                continue
            if [nh,nw]==[H-1][W-1]:
                return min_dist[qh][qw]+1
            seen[nh][nw] = 1
            queue.append([nh,nw])
            min_dist[nh][nw] = min_dist[qh][qw]+1
    else:
        return -1
min_dist = dfs()
print(H*W-black_count-min_dist if min_dist!=-1 else -1)
Problem p03636 (python)

Fixed submission:
s = input()
len = len(s)-2
print(s[0]+str(len)+s[-1])

Buggy submission (verdict: Runtime Error):
s = input()
print(s[0]+(len(s)-2)+s[-1])
Problem p02658 (python)

Fixed submission:
N=input()
a=list(map(int, input().split()))
#print(a)
ans=1
for v in a:
	ans*=v
	if 1000000000000000000 < ans:
		ans = -1
		break
if any([v==0 for v in a]):
	ans=0
print(ans)

Buggy submission (verdict: Runtime Error):
N=input()
if not N:
	break
a=list(map(int, input().split(" ")))
ans=1
for v in a:
	ans*=v
if 1000000000000000000 < ans:
	ans = -1
print(ans)

Buggy submission (verdict: Runtime Error):
while True:
	N=input()
	if not N:
		break
	a=list(map(int, input().split(" ")))
	ans=1
	for v in a:
		ans*=v
	if 1000000000000000000 < ans:
		ans = -1
	print(ans)

Buggy submission (verdict: Runtime Error):
while True:
	N=input()
	if not N:
		break
	a=list(map(int, input().split(" ")))
	ans=1
	for v in a:
		ans*=v
	if 1000000000000000000 < ans:
		ans = -1
	print(ans)
Problem p02645 (python)

Fixed submission:
a = input()
print(a[0:3])

Buggy submission (verdict: Runtime Error):
print input
Problem p02608 (python)

Fixed submission:
from itertools import combinations_with_replacement
def f(N):
    global table
    for x, y, z in combinations_with_replacement(range(1, 100), 3):
        n = x**2+y**2+z**2+x*y+y*z+z*x
        if n>N:
            continue
        if x==y==z:
            table[n] += 1
        elif x==y or y==z or z==x:
            table[n] += 3
        else:
            table[n] += 6
N = int(input())
table = [0 for _ in range(N+1)]
f(N)
for n in range(1, N+1):
    print(table[n])

Buggy submission (verdict: Runtime Error):
def f(N):
    global table
    for x, y, z in combinations_with_replacement(range(1, 100), 3):
        n = x**2+y**2+z**2+x*y+y*z+z*x
        if n>N:
            continue
        if x==y==z:
            table[n] = 1
        elif x==y or y==z or z==x:
            table[n] = 3
        else:
            table[n] = 6
N = int(input())
table = [0 for _ in range(N+1)]
f(N)
for n in range(1, N+1):
    print(table[n])

Buggy submission (verdict: Runtime Error):
from itertools import combinations_with_replacement
from math import floor

def f(N):
    global table
    for x, y, z in combinations_with_replacement(range(1, 100), 3):
        n = x**2+y**2+z**2+x*y+y*z+z*x
        if n>N+1:
            continue
        if x==y==z:
            table[n] = 1
        elif x==y or y==z or z==x:
            table[n] = 3
        else:
            table[n] = 6
N = int(input())
table = [0 for _ in range(N+1)]
f(N)
for n in range(1, N+1):
    print(table[n])
Problem p02677 (python)

Fixed submission:
from math import pi, cos,  sqrt
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))

Buggy submission (verdict: Runtime Error):
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))
Problem p02696 (python)

Fixed submission:
from math import floor
A, B, N = map(int, input().split())
print(floor(A*min(B-1, N)/B))

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B, N, = map(int, input().split())
def f(x):
    global A, B
    return np.floor(A*x/B)-A*np.floor(x/B)
print(int(np.max(f(np.arange(N+1)))))

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B, N, = map(int, input().split())
def f(x):
    global A, B
    return np.floor(A*x/B)-A*np.floor(x/B)
x = np.arange(N+1)
print(int(np.max(f(np.arange(N+1)))))
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())
if c>=a+b and (c-(a+b))*(c-(a+b))-4*a*b>0: print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if c-(a+b)>sqrt(a*b): print('Yes')
else: print('No')
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
ans = ["?" for _ in range(N)]
for _ in range(M):
    s, c = map(int, input().split())
    if N>1 and s==1 and c==0:
        ans = [-1]
        break
    if ans[s-1]!="?" and ans[s-1]!=str(c):
        ans = [-1]
        break
    ans[s-1] = str(c)
if ans==[-1]:
    print(-1)
else:
    if ans[0]=="?" and N>1:
        ans[0] = "1"
    ans = "".join(ans)
    ans = ans.replace("?", "0")
    print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = [0]*N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s-1]==c:
        continue
    if ans[s-1]!=0 or (s==0 and c==0):
        ans = -1
        break
    else:
        ans[s-1] = c
print("".join(map(str, ans)))
Problem p02900 (python)

Fixed submission:
def gcd(a, b):
    return gcd(b, a%b) if b!=0 else a

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)
    return divisors

def isprime(n):
    sup = int(n**0.5)
    for i in range(2, sup+1):
        if n%i==0:
            return False
    return True

A, B = map(int, input().split())
g = gcd(A, B)
divs = make_divisors(g)
ans = 0
for d in divs:
    ans += 1 if isprime(d) else 0
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from fractions import gcd
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)
    return set(divisors)

def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return set([i for i in range(n + 1) if is_prime[i]])

A, B = map(int, input().split())
g = gcd(A, B)
if g==1:
    print(1)
else:
    nums = make_divisors(g)
    pn = primes(g)
    ans = set.intersection(nums, pn)
    print(len(ans)+1)

Buggy submission (verdict: Runtime Error):
import math
from fractions import gcd
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while True:
        if search_list[0] > math.sqrt(number):
            prime_list.extend(search_list)
            break
        else:
            head_num = search_list[0]
            prime_list.append(head_num)
            search_list.pop(0)
            search_list = [num for num in search_list if num % head_num != 0]
    return prime_list

A, B = map(int, input().split())
g = gcd(A, B)
if g==1:
    print(1)
else:
    pn = get_primenumber(int(math.sqrt(g)))
    print(len(pn))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
g = gcd(A, B)
pn = [2]
for L in range(3, g):
    chk=True
    for L2 in pn:
        if L%L2==0:chk=False
    if chk==True and gcd(g,L)!=1:pn.append(L)
print(len(pn)+1)
Problem p02923 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = []
c = 0
for i in range(1, N):
    if H[i-1]>=H[i]:
        c += 1
    else:
        ans.append(c)
        c = 0
ans.append(c)
print(max(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = map(int, input().split())
cnt = 0
ans = []
prev = 0
for i,h in enumerate(H):
    if i==0:
        pass
    else:
        if prev>=h:
            cnt += 1
        else:
            ans.append(cnt)
            cnt = 0
    prev = h
print(max(ans))
Problem p02995 (python)

Fixed submission:
A, B, C, D = map(int, input().split())
import fractions
def lcm(x, y):
    return (x*y)//fractions.gcd(x,y)
ret = 0
ret += B//C - (A-1)//C
ret += B//D - (A-1)//D
L = lcm(C, D)
ret -= B//L - (A-1)//L
print(B-A+1-ret)

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
import math
def lcm(x, y):
    return (x*y)//math.gcd(x,y)
ret = 0
ret += B//C - (A-1)//C
ret += B//D - (A-1)//D
L = lcm(C, D)
ret -= B//L - (A-1)//L
print(B-A+1-ret)
Problem p03037 (python)

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
Lmax = max(L)
Rmin = min(R)
if Lmax>Rmin:
    print(0)
else:
    print(Rmin-Lmax+1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = 0
st = {*list(range(1, N+1))}
for _ in range(M):
    a, b = map(int, input().split())
    st.intersection_update({*list(range(a, b+1))})
print(len(st))
Problem p03043 (python)

Fixed submission:
from math import log2
N, K = map(int, input().split())
p = 0.0
if N >= K:
    p1 = (N-K+1)/N
    p2 = 1.0
    p += p1
    temp = 0.0
    for i in range(1, K): # 1 to K-1
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p2 *= temp*(1/N)
    p += p2
else:
    temp = 0
    for i in range(1, N+1): # 1 to N
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p = temp*(1.0/N)
print(p)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
p = 0.0
if N >= K:
    p1 = (N-K+1)/N
    p2 = 1.0
    p += p1
    temp = 0.0
    for i in range(1, K): # 1 to K-1
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p2 *= temp*(1/N)
    p += p2
else:
    temp = 0
    for i in range(1, N+1): # 1 to N
        n = int(log2(K-1)-log2(i))+1
        temp += (0.5)**n
    p = temp*(1.0/N)
print(p)
Problem p03076 (python)

Fixed submission:
from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
idx = 0
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)

Buggy submission (verdict: Runtime Error):
from math import ceil
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
rA.pop(idx)
tA = [ceil(A[i]/10)*10 for i in range(len(A))]
print(sum(tA)+ans)

Buggy submission (verdict: Runtime Error):
A= [int(input()) for _ in range(5)]
rA = list(map(lambda x:x%10, A))
res = float('inf')
for i, r in enumerate(rA):
    if res>r>0:
        idx = i
        res = r
ans = A.pop(idx)
rA.pop(idx)
tA = [A[i]+10-rA[i] for i in range(len(A))]
print(sum(tA)+ans)
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(c[r-1]-c[l-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
c = [0]*N
for i in range(1, N):
    c[i] = c[i-1]
    if S[i-1]=="A" and S[i]=="C":
        c[i] = c[i-1] + 1
for l,r in lr:
    print(c[r-1]-c[l-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
lr = []
for i in range(Q)
    l,r = map(int, input().split())
    print(S[l-1:r].count('AC'))
Problem p03109 (python)

Fixed submission:
import datetime
S = input()
dt = datetime.date(*list(map(int, S.split('/'))))
base = datetime.date(2019, 4, 30)
if dt<=base:
    print("Heisei")
else:
    print("TBD")

Buggy submission (verdict: Runtime Error):
import dateutil
S = dateutil.parser.parse(input())
base = dateutil.parser.parse('2019/04/30')
if S<=base:
    print("Heisei")
else:
    print("TBD")
Problem p03162 (python)

Fixed submission:
N = int(input())
H = []
for _ in range(N):
    H.append(list(map(int, input().split())))
dp = [[0, 0, 0] for _ in range(N)]
dp[0] = H[0]
for i,h in enumerate(H[1:], start=1):
    dp[i][0] = h[0]+max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = h[1]+max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = h[2]+max(dp[i-1][0], dp[i-1][1])
print(max(dp[-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
M = []
for _ in range(N):
    M.append(list(map(int, input().split())))
h = [0]*N
c = 0
for i,m in enumerate(M):
    if i==0:
        h[i] = max(m)
        c = m.index(h[i])
    else:
        h[i] = h[i-1]+max(map(lambda x: 0 if m.index(x)==c else x, m))
        c = m.index(h[i]-h[i-1])
print(h[-1])
Problem p03557 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect_left(A, b)
    c = bisect_right(C, b)
    ans += a*(N-c)
print(ans)
Problem p03633 (python)

Fixed submission:
from functools import reduce
def gcd(a, b):
    return gcd(b, a%b) if b!=0 else a

def lcd(a, b):
    return (a*b)//gcd(a,b)

N = int(input())
T = [int(input()) for _ in range(N)]
l = reduce(lcd, T)
print(l)

Buggy submission (verdict: Runtime Error):
from functools import reduce
def gcd(a, b):
    return gcd(b, a%b) if b!=0 else a

def lcd(a, b):
    return int(a*b/gcd(a,b))

N = int(input())
T = [int(input()) for _ in range(N)]
l = reduce(lcd, T)
print(l)
Problem p02813 (python)

Fixed submission:
import itertools
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
lis = range(1, n+1)

#permulations(l,n)でリストlの要素のうちn個を選んで並べる
a = list(itertools.permutations(lis))

print(abs(a.index(p) - a.index(q)))

Buggy submission (verdict: Runtime Error):
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
lis = range(1,n+!)
#permulations(l,n)でリストlの要素のうちn個を選んで並べる
a = list(itertools.permulations(lis))

#abs絶対値
print(abs(a.index(p) - a.index(q)))
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a*b)%2 = 1:
  print(odd)
else:
  print(even)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a*b)%2 = 1:
    print(odd)
print(even)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a*b)%2 = 1
    print(odd)
print(even)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a*b%2 = 1
    print(odd)
print(even)
Problem p02669 (python)

Fixed submission:
T = int(input())
for _ in range(T):
  N,a,b,c,d = map(int, input().split())
  
  memo = {}
  def solve(n):
    if n == 0:
      return 0
    if n == 1:
      return d
    if n in memo:
      return memo[n]
    tmp = n * d
    if n % 2 == 0:
      tmp = min(tmp, a + solve(n//2))
    else:
      tmp =  min(tmp, a + d + solve(n//2), a + d + solve(n//2+1))
    if n % 3 == 0:
      tmp = min(tmp, b + solve(n//3))
    else:
      ret1 = n % 3
      ret2 = 3 - ret1
      tmp = min(tmp, b + d*ret1 + solve(n//3), b + d*ret2 + solve(n//3+1))
    if n % 5 == 0:
      tmp = min(tmp, c + solve(n//5))
    else:
      ret1 = n % 5
      ret2 = 5 - ret1
      tmp = min(tmp, c + d*ret1 + solve(n//5), c + d*ret2 + solve(n//5+1))
    memo[n] = tmp
    return memo[n]
    
  print(solve(N))

Buggy submission (verdict: Runtime Error):
T = int(intput())

def solve(N, A, B, C, D):
  def pay(x, coin=0):
    if x == 0:
      return 0
    out1 = x/2 if x%2==0 else float('inf')
    out2 = x/3 if x%3==0 else float('inf')
    out3 = x/5 if x%5==0 else float('inf')
    out4 = x+1 if x%8==0 else float('inf')
    out5 = x-1 if x%8==0 else float('inf')
    return min(pay(out1, coin+A), pay(out2, coin+B), pay(out3, coin+C), pay(out4, coin+D), pay(out5, coin+D))
  return pay(N)

for _ in range(T):
  N, A, B, C, D = map(int, input().split())
  print(solve(N, A, B, C, D))