Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Left = []
Right = []
Reverse = False
for q in range(Q):
    query = input().split()
    if query[0]=="1":
        Reverse = not Reverse
    elif (query[1]=="1") ^ Reverse:#左側にくっつく
        S = query[2] + S
    else:
        S = S + query[2]
if Reverse:
    ans = "".join(reversed(S))
else:
    ans = S
print(ans)

Fixed submission:
import sys
fastinput = sys.stdin.readline
from collections import deque
S = input()
Q = int(input())
ans = deque([S])
Reverse = False
for q in range(Q):
    query = fastinput().split()
    if query[0]=="1":
        Reverse = not Reverse
    elif (query[1]=="1") ^ Reverse:#左側にくっつく
        ans.appendleft(query[2])
    else:
        ans.append(query[2])
SS = "".join(list(ans))
if Reverse:
    SS = "".join(reversed(SS))
print(SS)
Buggy python submission (verdict: Time Limit Exceeded):
H,N = [int(i) for i in input().split()]
AB = [[int(i) for i in input().split()] for j in range(N)]
DP = [10000000000]*(H+1)#DP[h] = 体力をh削るのに必要な魔力のmin
DP[0] = 0
for h,curmp in enumerate(DP):
    for a,b in AB:
        goal = min(h+a,H)
        DP[goal] = min(DP[goal],curmp+b)
print(DP[-1])

Fixed submission:
H,N = [int(i) for i in input().split()]
AB = [[int(i) for i in input().split()] for j in range(N)]
DP = [10000000000]*(H+1)#DP[h] = 体力をh削るのに必要な魔力のmin
DP[0] = 0
for h,curmp in enumerate(DP):
    for a,b in AB:
        goal = min(h+a,H)
        DP[goal] = min(DP[goal],curmp+b)
print(DP[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
mod = 10**9+7
def LCM(a,b):
    return a*b//fractions.gcd(a,b)

N=int(input())
A = [int(i) for i in input().split()]
curLCM = A[0]
for i in range(1,N):
    curLCM = LCM(curLCM,A[i])
ans = 0
for a in A:
    ans += curLCM//a 
    ans %= mod
print(ans)

Fixed submission:
import fractions
mod = 10**9+7
def LCM(a,b):
    return a*b//fractions.gcd(a,b)

N=int(input())
A = [int(i) for i in input().split()]
curLCM = A[0]
for i in range(1,N):
    curLCM = LCM(curLCM,A[i])
ans = 0
for a in A:
    ans += curLCM//a 
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A = [int(hoge) for hoge in input().split()]
print(*[A.index(j)+1 for j in range(1,N+1)] )

Fixed submission:
N=int(input())
A = [int(hoge) for hoge in input().split()]
ans = [0]*N
for n,a in enumerate(A):
    ans[a-1] = n+1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
def NextAmari(prev,d):
    return((prev*10+d)%13)

S = input()
mod = 10**9 + 7
DP = [[0]*13 for i in range(len(S)+1)]#DP[i][j] = 上位i桁目まで見たときの、j(mod13)の数　0<=j<13

DP[0][0] = 1
for n,s in enumerate(S):
    i = n
    if s != "?":
        d = int(s)
        for j,num in enumerate(DP[i]):
            DP[i+1][NextAmari(j,d)] += num
    else:
        for d in range(10):
            for j,num in enumerate(DP[i]):
                DP[i+1][NextAmari(j,d)] += num
    for a in range(13):
        DP[i+1][a] %= mod
print(DP[-1][5])

Fixed submission:
def NextAmari(prev,d):
    return((prev*10+d)%13)

S = input()
mod = 10**9 + 7
DP = [[0]*13 for i in range(len(S)+1)]#DP[i][j] = 上位i桁目まで見たときの、j(mod13)の数　0<=j<13

DP[0][0] = 1
for n,s in enumerate(S):
    i = n
    if s != "?":
        d = int(s)
        for j,num in enumerate(DP[i]):
            DP[i+1][NextAmari(j,d)] += num
    else:
        for d in range(10):
            for j,num in enumerate(DP[i]):
                DP[i+1][NextAmari(j,d)] += num
    for a in range(13):
        DP[i+1][a] %= mod
print(DP[-1][5])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
A = [int(i) for i in input().split()]
G = [[int(i in (j,(j+1)%N)) for i in range(N)] for j in range(N)]
kakudai = np.array(G)
X=np.linalg.solve(G,A)
print(*[int(x*2) for x in X])


Fixed submission:
N=int(input())
A = [int(i) for i in input().split()]
Rzero = sum(A)
#雨[0]を求める
for i in range(1,N,2):
    Rzero -= A[i]*2
Rain = [0]*N
Rain[0] = Rzero
for i in range(1,N):
    Rain[i] = (2*A[i-1] - Rain[i-1])
print(*Rain)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
A = [int(i) for i in input().split()]
G = [[int(i in (j,(j+1)%N)) for i in range(N)] for j in range(N)]
kakudai = np.array(G)
X=np.linalg.solve(G,A)
print(*[int(x*2) for x in X])


Fixed submission:
N=int(input())
A = [int(i) for i in input().split()]
Rzero = sum(A)
#雨[0]を求める
for i in range(1,N,2):
    Rzero -= A[i]*2
Rain = [0]*N
Rain[0] = Rzero
for i in range(1,N):
    Rain[i] = (2*A[i-1] - Rain[i-1])
print(*Rain)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
A = list(map(int,input().split()))
G = [[int(i in (j,(j+1)%N)) for i in range(N)] for j in range(N)]
kakudai = np.array(G)
X=np.linalg.solve(G,A)
print(*[int(x*2) for x in X])

Fixed submission:
N=int(input())
A = [int(i) for i in input().split()]
Rzero = sum(A)
#雨[0]を求める
for i in range(1,N,2):
    Rzero -= A[i]*2
Rain = [0]*N
Rain[0] = Rzero
for i in range(1,N):
    Rain[i] = (2*A[i-1] - Rain[i-1])
print(*Rain)
Buggy python submission (verdict: Runtime Error):
import math
def LCM(a,b):
    return int(a*b/math.gcd(a,b))
A,B,C,D = map(int,input().split())#A以上B以下
L = LCM(C,D)
Cbaisu = B//C - A//C
Dbaisu = B//D - A//D
Lbaisu = B//L - A//L
print(B-A+1 - Cbaisu - Dbaisu + Lbaisu)


Fixed submission:
import fractions
def LCM(a,b):
    return int(a*b/fractions.gcd(a,b))
A,B,C,D = map(int,input().split())#A以上B以下
L = LCM(C,D)
Cbaisu = (B//C) - ((A-1)//C)
Dbaisu = (B//D) - ((A-1)//D)
Lbaisu = (B//L) - ((A-1)//L)
print(B-A+1 - Cbaisu - Dbaisu + Lbaisu)
Buggy python submission (verdict: Runtime Error):
a,b= [int(i) for i in input().split()]
if x<a:print(0)
else:print(10)

Fixed submission:
x,a= [int(i) for i in input().split()]
if x<a:print(0)
else:print(10)
Buggy python submission (verdict: Runtime Error):
2 2 1 1

Fixed submission:
w,h,x,y= [int(i) for i in input().split()]
print(w*h/2)
print(int(2*x==w and 2*y ==h))
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9 + 7
def add(a,b):#mod下の加算
    return (a+b)%mod

N,K = [int(i) for i in input().split()]
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]
Slen = len(S);Tlen=len(T)
DP = [[0 for j in range(Tlen)] for i in range(Slen)]#DP[i][j]は、Sのi文字目、Tのj文字目までで一致する部分和
DP[0][0] = 1 + (S[0] == T[0])
for i,s in enumerate(S):
    for j,t in enumerate(T):
        if i==0 and j==0:continue
        if s == t:
            if i==0:
                DP[i][j]=DP[i][j-1]+1
            elif j==0:
                DP[i][j]=DP[i-1][j]+1
            else:
                DP[i][j]=(DP[i-1][j]+ DP[i][j-1])%mod
        else:
            if i==0:
                DP[i][j]=DP[i][j-1]
            if j==0:
                DP[i][j]=DP[i-1][j]
            else:
                DP[i][j]=(DP[i-1][j] + DP[i][j-1] - DP[i-1][j-1])%mod
print(DP[Slen-1][Tlen-1]%mod)
            

Fixed submission:
mod = 10**9 + 7
def add(a,b):#mod下の加算
    return (a+b)%mod

N,K = [int(i) for i in input().split()]
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]
Slen = len(S);Tlen=len(T)
DP = [[0 for j in range(Tlen)] for i in range(Slen)]#DP[i][j]は、Sのi文字目、Tのj文字目までで一致する部分和
DP[0][0] = 1 + (S[0] == T[0])
for i,s in enumerate(S):
    for j,t in enumerate(T):
        if i==0 and j==0:continue
        if s == t:
            if i==0:
                DP[i][j]=DP[i][j-1]+1
            elif j==0:
                DP[i][j]=DP[i-1][j]+1
            else:
                DP[i][j]=(DP[i-1][j]+ DP[i][j-1])%mod
        else:
            if i==0:
                DP[i][j]=DP[i][j-1]
            if j==0:
                DP[i][j]=DP[i-1][j]
            else:
                DP[i][j]=(DP[i-1][j] + DP[i][j-1] - DP[i-1][j-1])%mod
print(DP[Slen-1][Tlen-1]%mod)
Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
xy=[tuple([int(i) for i in input().split()])  for j in range(N)]
dist = []
for n,(x,y) in enumerate(xy):
    for j in range(n+1,N):
        gx,gy = xy[j]
        dx,dy = gx-x,gy-y
        dist.append((dx,dy))
zerocost = max(collections.Counter(dist).values())
print(N-zerocost)

Fixed submission:
import collections
N=int(input())
xy=[tuple([int(i) for i in input().split()])  for j in range(N)]
dist = []
if N!=1:
    for n,(x,y) in enumerate(xy):
        for m,(gx,gy) in enumerate(xy):
            if n==m:continue
            dx,dy = gx-x,gy-y
            dist.append((dx,dy))
    zerocost = max(collections.Counter(dist).values())
    print(N-zerocost)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())
#xR+yG+zB=Nの自然数解の個数
ans=0
for x in range(int(N/R)+1):
    for y in range(int(N/G)+1):
        nokori=N-x*R-y*G
        if nokori>=0 and nokori%B==0:
            ans+=1
print(ans)

Fixed submission:
R,G,B,N=map(int,input().split())
#xR+yG+zB=Nの自然数解の個数
ans=0
for x in range(int(N/R)+1):
    for y in range(int(N/G)+1):
        nokori=N-x*R-y*G
        if nokori>=0 and nokori%B==0:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
XA=0
BA=0
BX=0
internalAB=0
for t in range(N):
    i=input()
    headUsed=False
    footUsed=False
    for x,j in enumerate(i):
        if x==len(i)-1:break
        if j=="A" and i[x+1]=="B":
            internalAB+=1
            if x==0:headUsed=True
            if x==len(i)-2:footUsed=True
    if i[0]=="B" and not headUsed:
        if i[-1]=="A" and not footUsed:
            BA+=1
        else:BX+=1
    elif i[-1]=="A" and not footUsed:
        XA+=1
ans=internalAB+BA+min(XA,BX)
if XA=BX=0:ans-=1
print(ans)


Fixed submission:
N=int(input())
XA=0
BA=0
BX=0
internalAB=0
for t in range(N):
    i=input()
    headUsed=False
    footUsed=False
    for x,j in enumerate(i):
        if x==len(i)-1:break
        if j=="A" and i[x+1]=="B":
            internalAB+=1
            if x==0:headUsed=True
            if x==len(i)-2:footUsed=True
    if i[0]=="B" and not headUsed:
        if i[-1]=="A" and not footUsed:
            BA+=1
        else:BX+=1
    elif i[-1]=="A" and not footUsed:
        XA+=1
if XA or BX:
    externalAB=max(0,BA+min(XA,BX))
else:externalAB=max(0,BA-1)
ans=internalAB+externalAB
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
root=math.ceil(math.sqrt(N)+1)
ans=0
for i in range(root,N+1):
    if not N%i:
        ans+=i-1
print(ans)

Fixed submission:
import math
N=int(input())
root=math.ceil(math.sqrt(N))
ans=0
for i in range(1,root):
    if not N%i:
        if N//i>i+1:
            ans+=N//i-1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[int(i) for i in input().split()]
def CountMinusAndZeroAndMin(lis):#マイナスの個数とabs挿話とabs最小の値を返す
    curmin=1000000000000000
    plussum=0
    minus=0
    for i in lis:
        j=abs(i)
        plussum+=j
        curmin=min(j,curmin)
        if i<0:
           minus+=1
        elif i==0:
            zeros+=1
    return(minus,plussum,curmin)
minus,plussum,minabs=CountMinusAndZeroAndMin(A)
if minabs==0 or minus%2==0:
    print(plussum)
else:
    print(plussum-2*minabs)

Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]
def CountMinusAndZeroAndMin(lis):#マイナスの個数とabs挿話とabs最小の値を返す
    curmin=1000000000000000
    plussum=0
    minus=0
    for i in lis:
        j=abs(i)
        plussum+=j
        curmin=min(j,curmin)
        if i<0:
           minus+=1
    return(minus,plussum,curmin)
minus,plussum,minabs=CountMinusAndZeroAndMin(A)
if minabs==0 or minus%2==0:
    print(plussum)
else:
    print(plussum-2*minabs)
Buggy python submission (verdict: Runtime Error):
#最後のやつがjならはj番目にできたと確定する
dead=0
N=int(input())
b=list(map(int,input().split()))
ans=[0 for i in range(N)]#k番目にans[k-1]が入ったよの表
for i in reversed(range(1,N+1)):
    num=b[i-1]#頭からi番目の数
    sa_left=i-num#n-saleftから検証
    for j in reversed(range(1,N-sa_left+1)):
        if ans[j-1]==0:
            ans[j-1]=num
            break
if all(k!=0 in ans):
    for i in ans:
        print(ans)
else:
    print("-1")

Fixed submission:
N=int(input())
b=list(map(int,input().split()))
sa=[i-b[i-1] for i in range(1,N+1)]
ans=[0 for i in range(N)]#k番目にans[k-1]が入ったよの表
for i in reversed(range(1,N+1)):#頭からi番目
    cnt=0
    for j in range(1,N+1):
        if ans[-1*j]==0:
            if cnt!=sa[i-1]:
                cnt+=1
            else:
                ans[-1*j]=b[i-1]
                break
if all(k!=0 for k in ans):
    for i in ans:
        print(i)
else:
    print("-1")
Buggy python submission (verdict: Runtime Error):
H,W=input().split()
h,w=input().split()
print((H-h)*(W-w))

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M,C=map(int,input().split())
B=np.array([int(i) for i in input().split()]).T
A=[[int(i) for i in input().split()] for j in range(N)]
A=np.matrix(A)
print(sum([i+C>0 for i in (np.dot(A,B).T).A1]))

Fixed submission:
import numpy as np
N,M,C=map(int,input().split())
B=np.array([int(i) for i in input().split()]).T
A=[[int(i) for i in input().split()] for j in range(N)]
A=np.matrix(A)
print(sum([i+C>0 for i in (np.dot(A,B).T).A1]))
Buggy python submission (verdict: Runtime Error):
import math,functools
input()
A = [int(hoge) for hoge in input().split()]
print(functools.reduce(math.gcd,A))

Fixed submission:
import fractions,functools
input()
A = [int(hoge) for hoge in input().split()]
print(functools.reduce(fractions.gcd,A))
Buggy python submission (verdict: Runtime Error):
def itinokazu(A,i):#配列Aのi桁目の１の数を調べる
    kazu=0
    for a in A:
        bina=bin(a)
        if a>=2**(i-1):
            if bina[i*-1]=='1':
                kazu=kazu+1
    return kazu

import math
N,K=[int(i) for i in input().split()]
A=list(map(int,input().split()))
Maxkazu=max(max(A),K)#桁の上限を探す(Kの2進数での桁数を考える)
Keta=math.floor(math.log2(Maxkazu))+1
presentA=0
print(Keta)
presentAns=0
for i in reversed(range(Keta+1)):#i桁目(2^i-1)の位について
    ichinokazu=itinokazu(A,i)
    if (2*ichinokazu>N) or presentA+2**(i-1)>K:#i桁目が1のほうが多い、もしくは1にすると超えちゃう場合はAのi桁目は0
        presentAns=presentAns+((2**(i-1))*ichinokazu)
    else:
        presentA=presentA+2**(i-1)#そうでなければAのi桁目は1
        presentAns=presentAns+((2**(i-1))*(N-ichinokazu))
print(int(presentAns))

Fixed submission:
T,X=[int(i)for i in input().split()]
print(T/X)
Buggy python submission (verdict: Runtime Error):
print([1, 3, 3, 8, 3, 6, 9, 17, 4, 20, 7, 15, 10, 10, 18, 18, 5, 13, 21, 21, 8, 8, 16, 16, 11, 24, 11, 112, 19, 19, 19, 107, 6, 27, 14, 14, 22, 22, 22, 35, 9, 110, 9, 30, 17, 17, 17, 105, 12, 25, 25, 25, 12, 12, 113, 113, 20, 33, 20, 33, 20, 20, 108, 108, 7, 28, 28, 28, 15, 15, 15, 103, 23, 116, 23, 15, 23, 23, 36, 36, 10, 23, 111, 111, 10, 10, 31, 31, 18, 31, 18, 93, 18, 18, 106, 106, 13, 119, 26, 26][int(input())]+1)

Fixed submission:
from collections import Counter
def collatz(n):
    if n%2:
        return n*3 + 1
    else:
        return n//2
    
i = int(input())
dic = dict()
dic[i] = 1
cur = i
for n in range(1,10000):
    cur = collatz(cur)
    if cur in dic:
        print(n+1)
        break
    else:
        dic[cur] = 1
Buggy python submission (verdict: Runtime Error):
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212

Fixed submission:
N = int(input())
A = [int(hoge) for hoge in input().split()]
B = [int(hoge) for hoge in input().split()]
#Aiの総和を変えずに、なるべく少ない量のAiを変えて全部合格を目指す
if sum(B) > sum(A):
    print(-1)
else:
    diff = 0
    points = []
    ans = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        if a < b:
            diff += b - a
            ans += 1
        elif a > b:
            points.append(a-b)
    for p in sorted(points,reverse = True):
        if diff <= 0:
            print(ans)
            exit()
        diff -= p
        ans += 1 
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N,M = [int(hoge) for hoge in input().split()]
S = input()
T = input()
G = math.gcd(N,M)
print(N*M//G) if S[::N//G] == T[::M//G] else print(-1)

Fixed submission:
import fractions
N,M = [int(hoge) for hoge in input().split()]
S = input()
T = input()
G = fractions.gcd(N,M)
print(N*M//G) if S[::N//G] == T[::M//G] else print(-1)
Buggy python submission (verdict: Runtime Error):
N,x = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
#x個のお菓子を配る。
#和がxを越えないように最も多い数のaを選ぶ
A.sort()
ans = 0
cur = 0
for a in A:
    cur += a
    if cur > x:
        print(ans)
        exit()
    ans += 1
if cur == X:print(N)
else:print(ans-1)

Fixed submission:
N,x = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
#x個のお菓子を配る。
#和がxを越えないように最も多い数のaを選ぶ
A.sort()
ans = 0
cur = 0
for a in A:
    cur += a
    if cur > x:
        print(ans)
        exit()
    ans += 1
if cur == x:print(N)
else:print(ans-1)
Buggy python submission (verdict: Runtime Error):
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(abs(list(itertools.accumulate(X,func = fractions.gcd))[-1]))


Fixed submission:
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(abs(list(itertools.accumulate(X,func = fractions.gcd))[-1]))

Buggy python submission (verdict: Runtime Error):
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(list(itertools.accumulate(X,math.gcd))[-1])

Fixed submission:
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(abs(list(itertools.accumulate(X,func = fractions.gcd))[-1]))

Buggy python submission (verdict: Runtime Error):
import math,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(list(itertools.accumulate(X,math.gcd))[-1])

Fixed submission:
import fractions,itertools
N,S = [int(hoge) for hoge in input().split()]
X = [int(hoge) - S for hoge in input().split()]
print(abs(list(itertools.accumulate(X,func = fractions.gcd))[-1]))
Buggy python submission (verdict: Runtime Error):
N=input()
print(sum([int(a) for a in input().split()])-N)

Fixed submission:
input()
print(sum([int(a)-1 for a in input().split()]))
Buggy python submission (verdict: Runtime Error):
N=int(input);print(N*(N%2+1))

Fixed submission:
N=int(input());print(N*(N%2+1))
Buggy python submission (verdict: Runtime Error):
N=int(input())
X=[int(i) for i in input().split()
Y=sorted(X)
MidL=X[N//2-1]#ちっちゃいほう(変化なしの場合)
MidR=X[N//2]#でかいほう(下が減った場合)
for y in Y:
	if >=MidR:print(MidL)
	else:print(MidR)


Fixed submission:
N=int(input())
X=[int(i) for i in input().split()]
Y=sorted(X)
MidL=Y[N//2-1]#ちっちゃいほう(変化なしの場合)
MidR=Y[N//2]#でかいほう(下が減った場合)
for x in X:
	if x>=MidR:print(MidL)
	else:print(MidR)
Buggy python submission (verdict: Runtime Error):
R=int(input())
print((int(input())*2-R)

Fixed submission:
R=int(input())
print((int(input()))*2-R)
Buggy python submission (verdict: Runtime Error):
N=int(input)
print(N**2-int(input()))

Fixed submission:
print((int(input()))**2-int(input()))
Buggy python submission (verdict: Runtime Error):
from math import gcd
def lcm(a,b):
    return(a*b//gcd(a,b))
N=int(input())
curlcm=1
for _ in range(N):
    curlcm=lcm(curlcm,int(input()))
print(curlcm)

Fixed submission:
def gcd(a,b):
    if b<a:
        x=b 
        y=a
    else:
        x=a
        y=b
    #x>y
    while x%y!=0:
        newy=x%y
        x=y
        y=newy
    return y
def lcm(a,b):
    return(a*b//gcd(a,b))
N=int(input())
curlcm=1
for _ in range(N):
    curlcm=lcm(curlcm,int(input()))
print(curlcm)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
inf=100000000000000000000
fastinput=sys.stdin.readline
N=int(fastinput())
path=[[0]*N for hoge in range(N)]
for fuga in range(N-1):
    a,b,c=[int(hoge) for hoge in fastinput().split()]
    path[a-1][b-1]=c
    path[b-1][a-1]=c
Q,K=[int(hoge) for hoge in fastinput().split()]
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in enumerate(path[cur]):
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=[int(hoge) for hoge in fastinput().split()]
    print(Kcost[x-1]+Kcost[y-1])
    

Fixed submission:
import sys
from collections import deque
inf=100000000000000000000
fastinput=sys.stdin.readline
N=int(fastinput())
path=[[] for hoge in range(N)]
for fuga in range(N-1):
    a,b,c=[int(hoge) for hoge in fastinput().split()]
    path[a-1].append([b-1,c])
    path[b-1].append([a-1,c])
Q,K=[int(hoge) for hoge in fastinput().split()]
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in path[cur]:
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=[int(hoge) for hoge in fastinput().split()]
    print(Kcost[x-1]+Kcost[y-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
inf=100000000000000000000
fastinput=sys.stdin.readline
N=int(fastinput())
path=[[0]*N for hoge in range(N)]
for fuga in range(N-1):
    a,b,c=[int(hoge) for hoge in fastinput().split()]
    path[a-1][b-1]=c
    path[b-1][a-1]=c
Q,K=[int(hoge) for hoge in fastinput().split()]
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in enumerate(path[cur]):
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=[int(hoge) for hoge in fastinput().split()]
    print(Kcost[x-1]+Kcost[y-1])
    

Fixed submission:
import sys
from collections import deque
inf=100000000000000000000
fastinput=sys.stdin.readline
N=int(fastinput())
path=[[] for hoge in range(N)]
for fuga in range(N-1):
    a,b,c=[int(hoge) for hoge in fastinput().split()]
    path[a-1].append([b-1,c])
    path[b-1].append([a-1,c])
Q,K=[int(hoge) for hoge in fastinput().split()]
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in path[cur]:
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=[int(hoge) for hoge in fastinput().split()]
    print(Kcost[x-1]+Kcost[y-1])
Buggy python submission (verdict: Runtime Error):
s=input()
print(f"{s[0]}{len(s)-2}{s[-1]}")

Fixed submission:
s=input()
print("{}{}{}".format(s[0],len(s)-2,s[-1]))
Buggy python submission (verdict: Runtime Error):
j=int(input())
print([2**i for i in range(8) if 2**i<=N][-1])


Fixed submission:
N=int(input())
print([2**i for i in range(8) if 2**i<=N][-1])
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
print(["Possible","Impossible][bool(A*B*(A+B))])

Fixed submission:
A,B=map(int,input().split())
print(["Possible","Impossible"][bool(A*B*(A+B)%3)])