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

Fixed submission:
D,G = list(map(int,input().split()))
pc = [list(map(int,input().split())) for i in range(D)]

ans = sum([p for p,c in pc])
for i in range(2**D-1):
    score = 0
    unused_max = D-1
    sum_p = 0
    for j in range(D-1,-1,-1):
        if (i>>j)%2:
            score += pc[j][1] + pc[j][0]*(j+1)*100
            sum_p += pc[j][0]
            if unused_max == j:
                unused_max -= 1
    if G - score <= (pc[unused_max][0]-1)*(unused_max+1)*100:
        ans = min(ans,sum_p+max(0,(G-score-1)//(100*(unused_max+1))+1))
print(ans)

Buggy submission (verdict: Runtime Error):
D,G = list(map(int,input().split()))
pc = [[i]+list(map(int,input().split())) for i in range(D)]

for i,row in enumerate(pc):
    s = (i+1)*row[1] * 100 + row[2]
    ave = s/row[1]
    pc[i].append(s)
    pc[i].append(ave)

out = 0
while 1:
    check=False
    i_list = []
    for i,row in enumerate(pc):
        if G<row[3]:
            check=True
            i_list.append(i)
    if check == False:
        #どれをコンプリートしても目標を超えない
        #問題数当たり平均が最高の問題セットを解く
        tmp = [row[4] for row in pc]
        i = tmp.index(max(tmp))
        out += pc[i][1]
        G -= pc[i][3]
        pc.pop(i)
    else:
        #どれかをコンプリートすると目標を達成
        #最小問題数のセット または 最高得点問題での必要数
        tmp = [pc[i][1] for i in i_list]
        m = min(tmp)
        if pc[-1][3] > G:
            m = min(m,(G-1)//((pc[-1][0]+1)*100)+1)
        out += m
        break
print(out)

Buggy submission (verdict: Runtime Error):
D,G = list(map(int,input().split()))
pc = [[i]+list(map(int,input().split())) for i in range(D)]

for i,row in enumerate(pc):
    s = (i+1)*row[1] * 100 + row[2]
    ave = s/row[1]
    pc[i].append(s)
    pc[i].append(ave)

out = 0
while 1:
    check=False
    i_list = []
    for i,row in enumerate(pc):
        if G<row[3]:
            check=True
            i_list.append(i)
    if check == False:
        #どれをコンプリートしても目標を超えない
        #問題数当たり平均が最高の問題セットを解く
        tmp = [row[4] for row in pc]
        i = tmp.index(max(tmp))
        out += pc[i][1]
        G -= pc[i][3]
        pc.pop(i)
    else:
        #どれかをコンプリートすると目標を達成
        #最小問題数のセット または 最高得点問題での必要数
        tmp = [pc[i][1] for i in i_list]
        m = min(tmp)
        if pc[-1][3] > G:
            m = min(m,G//((pc[-1][0]+1)*100))
        out += m
        break
print(out)
Problem p03309 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
b = sorted([a-i for i,a in enumerate(A,1)])

minus = 0
plus = 0
for c in b:
    if c <0:
        minus +=1
    elif c >0:
        plus +=1

m1 = b[N//2]
m2 = b[0] if N==1 else b[N//2+1]
out = min(sum([abs(c-m1) for c in b]),sum([abs(c-m2) for c in b]))
print(out)

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

minus = 0
plus = 0
for c in b:
    if c <0:
        minus +=1
    elif c >0:
        plus +=1

m1 = b[N//2]
m2 = b[N//2+1]
out = min(sum([abs(c-m1) for c in b]),sum([abs(c-m2) for c in b]))
print(out)

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

minus = 0
plus = 0
for i,c in enumerate(b,1):
    if c <0:
        minus +=1
    elif c >0:
        plus +=1

m = b[(N-minus+plus)//2]
out = sum([abs(c-m) for c in b])
print(out)
Problem p03480 (python)

Fixed submission:
S = input()
l = len(S)
i = 0
if l%2:
    c = S[l//2]
    for i in range(1,l//2+1):
        if S[l//2-i] != c or S[l//2 + i] != c:
            break
    else:
        i += 1
    print(l//2+i)
else:
    c = S[l//2]
    for i in range(l//2):
        if S[l//2-1-i] != c or S[l//2 + i] != c:
            break
    else:
        i += 1
        pass
    print(l//2 + i)

Buggy submission (verdict: Runtime Error):
S = input()
l = len(S)
if l%2:
    c = S[l//2]
    for i in range(1,l//2+1):
        if S[l//2-i] != c or S[l//2 + i] != c:
            break
    else:
        i += 1
    print(l//2+i)
else:
    c = S[l//2]
    for i in range(l//2+1):
        if S[l//2-i] != c or S[l//2 - 1 + i] != c:
            break
    else:
        i += 1
    print(l//2 + i)
Problem p03496 (python)

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

Amax = max(A)
Amin = min(A)
ans = []
if Amax >= -Amin:
    im = A.index(Amax)+1
    i = 2
    while i <= N:
        if A[i-2] > A[i-1]:
            ans.append(str(im) + " " + str(i))
            A[i-1] += Amax
            if Amax < A[i-1]:
                im = i
                Amax = A[i-1]
        else:
            i += 1
else:
    im = A.index(Amin)+1
    i = N-1
    while i >= 1:
        if A[i-1] > A[i]:
            ans.append(str(im) + " " + str(i))
            A[i-1] += Amin
            if Amin > A[i-1]:
                im = i
                Amin = A[i-1]
        else:
            i -= 1
print(len(ans))
for out in ans:
    print(out)

Buggy submission (verdict: Runtime Error):
Amax = max(A)
Amin = min(A)
ans = []
if Amax >= -Amin:
    im = A.index(Amax)+1
    i = 2
    while i <= N:
        if A[i-2] > A[i-1]:
            ans.append(str(im) + " " + str(i))
            A[i-1] += Amax
            if Amax < A[i-1]:
                im = i
                Amax = A[i-1]
        else:
            i += 1
else:
    im = A.index(Amin)+1
    i = N-1
    while i >= 1:
        if A[i-1] > A[i]:
            ans.append(str(im) + " " + str(i))
            A[i-1] += Amin
        if Amin > A[i-1]:
            im = i
            Amin = A[i-1]
        else:
            i -= 1
print(len(ans))
for out in ans:
    print(out)
Problem p03576 (python)

Fixed submission:
N,K = map(int,input().split())
xy = sorted([list(map(int,input().split())) for _ in range(N)],key = lambda x:(x[0],x[1]))

ans = 10**20

for i in range(K,N+1):
    for j in range(0,N-i+1):
        xy2 = sorted(xy[j:j+i],key = lambda x:(x[1]))
        for k in range(0,i-K+1):
            xy3 = xy2[k:k+K]
            Y_wid = xy3[-1][1] - xy3[0][1]
            x3 = [tmp for tmp,_ in xy3]
            X_wid = max(x3) - min(x3)
            ans = min(ans,X_wid*Y_wid)
print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    N,K = map(int,input().split())
    XY = [list(map(int,input().split())) for _ in [0]*N]
    iX = [0]*N
    iY = [0]*N
    for i,xy in enumerate(XY):
        x,y = xy
        iX[i] = x
        iY[i] = y
    iX.sort()
    iY.sort()
    X = {x:i for i,x in enumerate(iX)}
    Y = {y:i for i,y in enumerate(iY)}

    c = [[0]*(N+1) for i in [0]*(N+1)]
    for x,y in XY:
        c[Y[y]+1][X[x]+1] = 1

    for i in range(N):
        ci1 = c[i+1
        for j in range(N):
            ci1[j+1] += ci1[j]
    for i in range(N):
        ci1 = c[i+1]
        ci = c[i]
        for j,cij in enumerate(ci[1:],1):
            ci1[j] += cij

    ans = 10**20
    for u in range(N):
        for d in range(u+K-1,N):
            l = 0
            r = K-1
            dY = iY[d]-iY[u]
            cd = c[d+1]
            cu = c[u]
            while r<N:
                if cd[r+1]+cu[l]-cu[r+1]-cd[l] >=K:
                    ans = min(ans, (iX[r] - iX[l])*dY)
                    l+=1
                else:r+=1

    print(ans)
main()
Problem p03583 (python)

Fixed submission:
N = int(input())
flg = False
for a in range(1,3501):
  for b in range(a,3501):
    A = 4*a*b - N*(a+b)
    B = N*a*b
    if A==B==0:
      c = 1
      flg = True
      break
    elif A!=0 and B%A==0 and B//A>0:
      c = B//A
      flg = True
      break
  if flg:break
print(a,b,c)

Buggy submission (verdict: Runtime Error):
N = int(input())
flg = False
for a in range(1,3501):
  for b in range(a,3501):
    A = 4*a*b - N*(a+b)
    B = N*a*b
    if B%A==0 and A//B>0:
      c = B//A
      flg = True
      break
  if flg:break
print(a,b,c)
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F = map(int,input().split())
ans = ["0","0"]
M = -1
for a in range(31):
    if F < a*A*100:
        break
    for b in range(31-a):
        if a == 0 and b == 0:
            continue
        W = (a*A+b*B)*100
        if F < W:
            break
        CD_max = min((E * W) // 100,F-W)
        for c in range(CD_max//C+1):
            d = max(0,(CD_max-c*C)//D)
            CD = c*C+d*D
            con = CD/(W+CD)
            if con > M:
                M = con
                ans = [str(W+CD),str(CD)]
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())
ans = [0,0]
M = 0
for a in range(31):
    if F < a*A*100:
        break
    for b in range(31-a):
        if a == 0 and b == 0:
            continue
        W = (a*A+b*B)*100
        if F < W:
            break
        CD_max = min((E * W) // 100,F-W)
        for c in range(CD_max//C+1):
            d = max(0,(CD_max-c*C)//D)
            CD = c*C+d*D
            con = CD/(W+CD)
            if con > M:
                M = con
                ans = [str(W+CD),str(CD)]
print(" ".join(ans))
Problem p03651 (python)

Fixed submission:
N,K = map(int,input().split())
*A, = sorted(set(map(int,input().split())))
if A[-1]<K:print("IMPOSSIBLE");exit()
if len(A)==1:
    if A[0]==K:print("POSSIBLE")
    else:print("IMPOSSIBLE")
    exit()
d = min(A[i+1]-a for i,a in enumerate(A[:-1]))
K%=d
for a in A:
    if a%d==K:print("POSSIBLE");break
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
*A, = sorted(set(map(int,input().split())))
if A[-1]<K:print("IMPOSSIBLE");exit()
d = min(A[i+1]-a for i,a in enumerate(A[:-1]))
K%=d
for a in A:
    if a%d==K:print("POSSIBLE");break
else:
    print("IMPOSSIBLE")
Problem p03714 (python)

Fixed submission:
import heapq
N = int(input())
*A, = map(int,input().split())
q = []
for a in A[:N]:
    heapq.heappush(q,a)
S1 = [sum(q)]
for a in A[N:N*2]:
    if a>q[0]:
        S1.append(S1[-1] + a - q[0])
        heapq.heapreplace(q,a)
    else:
        S1.append(S1[-1])
q = []
for a in A[2*N:]:
    heapq.heappush(q,-a)
S2 = [sum(q)]
for a in A[N:N*2][::-1]:
    if a<-q[0]:
        S2.append(S2[-1] - a - q[0])
        heapq.heapreplace(q,-a)
    else:
        S2.append(S2[-1])
S2 = S2[::-1]
print(max(map(sum,zip(S1,S2))))

Buggy submission (verdict: Runtime Error):
N = int(input())
*A, = map(int,input().split())
q = []
for a in A[:N]:
    heapq.heappush(q,a)
S1 = [sum(q)]
for a in A[N:N*2]:
    if a>q[0]:
        S1.append(S1[-1] + a - q[0])
        heapq.heapreplace(q,a)
    else:
        S1.append(S1[-1])
q = []
for a in A[2*N:]:
    heapq.heappush(q,-a)
S2 = [sum(q)]
for a in A[N:N*2][::-1]:
    if a<-q[0]:
        S2.append(S2[-1] - a - q[0])
        heapq.heapreplace(q,-a)
    else:
        S2.append(S2[-1])
S2 = S2[::-1]
print(max(map(sum,zip(S1,S2))))
Problem p03721 (python)

Fixed submission:
N,K = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in [0]*N])
for a,b in ab:
    K -= b
    if K <= 0:
        print(a)
        break

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
ab = sorted([map(int,input().split()) for _ in [0]*N])
for a,b in ab:
    K -= b
    if K <= 0:
        print(a)
        break
Problem p03722 (python)

Fixed submission:
N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*M]

E = [{} for _ in [0]*N]
for a,b,c in ABC:
    E[a-1][b-1] = -c


INFTY = 10**18
d = [INFTY]*N
d[0] = 0

def update():
    done = [False]*N
    done[0] = True
    q = [0]
    qp = q.pop
    qa = q.append
    while q:
        i = qp()
        di = d[i]
        for j,c in E[i].items():
            d[j] = min(d[j],d[i]+c)
            if not done[j]:
                qa(j)
                done[j] = True

for _ in range(N-1):update()
dc = d[:]
for _ in range(N):update()
if dc[-1]!=d[-1]:
    print("inf")
else:
    print(-d[-1])

Buggy submission (verdict: Runtime Error):
def connect_dfs(N,E,start):
    connect = {start}
    q = [start]
    while q:
        i = q.pop()
        for j in E[i]:
            if j in connect:continue
            connect.add(j)
            q.append(j)
    return connect

def remove_Edge(N,Ef,Eb,start,goal):
    v = connect_dfs(N,Ef,start) & connect_dfs(N,Eb,goal)
    for i in range(N):
        if i in v:continue
        for j in Eb[i]:
            E[j].pop(i)

def Bellman_Ford(N,E,start,INFTY=10**18):
    def update(dist,N,E,start):
        done = [False]*N
        done[start] = True
        q = [start]
        d = dist[:]
        while q:
            i = q.pop()
            di = d[i]
            for j,c in E[i].items():
                d[j] = min(d[j],d[i]+c)
                if not done[j]:
                    q.append(j)
                    done[j] = True
        return d
    #
    d = [INFTY]*N
    d[start] = 0
    for _ in range(N-1):
        d = update(d,N,E,start)
    if d!=update(d,N,E,start):
        return None
    else:
        return d

def main():
    N,M = map(int,input().split())
    ABC = [list(map(int,input().split())) for _ in [0]*M]
    E = [{} for _ in [0]*N]
    Eb = [{} for _ in [0]*N]
    for a,b,c in ABC:
        E[a-1][b-1] = -c
        Eb[b-1][a-1] = c
    
    remove_Edge(N,E,Eb,0,N-1)
    d = Bellman_Ford(N,E,0)
    if d == None:
        print("inf")
    else:
        print(-d[-1])
    
main()
Problem p03739 (python)

Fixed submission:
N = int(input())
*A, = map(int,input().split())
ans1 = 0
S = A[0]
if S <= 0:
    ans1 = abs(S)+1
    S = 1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans1 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
ans2 = 0
S = A[0]
if S >= 0:
    ans2 = abs(S)+1
    S = -1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans2 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
print(min(ans1,ans2))

Buggy submission (verdict: Runtime Error):
N = int(input())
*A, = map(int,input().split())
ans1 = 0
S = A[0]
if S <= 0:
    S = 1
    ans1 = abs(S)+1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans1 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
ans2 = 0
S = A[0]
if S >= 0:
    S = -1
    ans2 = abn(S)+1
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans2 += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
print(min(ans1,ans2))

Buggy submission (verdict: Runtime Error):
N = int(input())
*A, = map(int,input().split())
ans = 0
S = A[0]
for a in A[1:]:
    S1 = S+a
    if S1*S >= 0:
        ans += abs(S1)+1
        S1 = -S//abs(S)
    S = S1
print(ans)
Problem p03759 (python)

Fixed submission:
a,b,c = map(int,input().split())
if b-a==c-b:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
if b-a==c-b:
    print("YES")
else:
    print("NO")
Problem p03807 (python)

Fixed submission:
input()
print("YNEOS"[sum(map(int,input().split()))%2::2])

Buggy submission (verdict: Runtime Error):
input()
print("YNEOS"[sum(map(int,input()))%2::2])
Problem p03993 (python)

Fixed submission:
input();*A,=map(int,input().split());print(sum(A[a-1]==i+1for i,a in enumerate(A))//2)

Buggy submission (verdict: Runtime Error):
input();*A,=map(int,input());print(sum(A[a]==i for i,a in enumerate(A))//2)
Problem p04035 (python)

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

S = [0]*(N+1)
for i,a in enumerate(A): S[i+1] = S[i] + a
ans = []
i=0
j=N-1
while i<j:
    if S[j+1]-S[i] < L:
        print("Impossible")
        break
    if A[i]+A[i+1] <= A[j]+A[j-1]:
        ans.append(i+1)
        i+=1
    else:
        ans.append(j)
        j-=1
else:
    print("Possible")
    for a in ans: print(a)

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

S = [0]*(N+1)
for i,a in enumerate(A): S[i+1] = S[i] + a
ans = []
i=0
j=N-1
while i<j:
    if S[j+1]-S[i] < L:
        1/0
        print("Impossible")
        break
    if A[i] <= A[j]:
        ans.append(i+1)
        i+=1
    else:
        ans.append(j)
        j-=1
else:
    print("Possible")
    for a in ans: print(a)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
a,b,c,d = map(int,input().split())
a-=1
print((b-a)-(b//c+b//d-a//c-a//d-(b//lcm(c,d))+(a//lcm(c,d))))

Buggy submission (verdict: Runtime Error):
from fraction import lcm

a,b,c,d = map(int,input().split())
a-=1
print(b//c+b//d-a//c-a//d-b//(c*d/lcm(c,d)))
Problem p02996 (python)

Fixed submission:
n = int(input())
sche = []
for i in range(n):
    a,b = map(int,input().split())
    sche.append((b,a))
sche.sort(reverse = True)
now = 1e18
for dead,ti in sche:
    if(dead < now):
        now = dead
    now -= ti

if now < 0:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
sche = []
for i in range(n):
    a,b = map(int,input().split())
    sche.append((b,a))
sche.sort(reverse = True)
now = 1e18
for dead,ti in :
    if(dead > now):
        dead = now
    now -= ti

if now < 0:
    print("No")
else:
    print("Yes")
Problem p03337 (python)

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

Buggy submission (verdict: Runtime Error):
import numpy as np
a=int(input())
b=int(input())
print(max(a+b,a-b,a*b))
Problem p03399 (python)

Fixed submission:
a = (int)(input())
b = (int)(input())
c = (int)(input())
d = (int)(input())
print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a,b)+min(c+d))
Problem p03401 (python)

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
lis = []
lis.append(0)
for hoge in li:
    lis.append(hoge)
lis.append(0)
sumpo = 0
sumpo += abs(li[0])
for i in range(1,n+1):
    sumpo += abs(lis[i]-lis[i+1])
for i in range(1,n+1):
    print(sumpo + abs(lis[i+1]-lis[i-1]) - (abs(lis[i]-lis[i-1])+abs(lis[i+1]-lis[i])))

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
lis = []
lis.append(0)
for hoge in li:
    lis.append(hoge)
lis.append(0)
sumpo = 0
sumpo += abs(li[0])
for i in range(0,n):
    sumpo += abs(li[i]-li[i+1])
for i in range(1,n+1):
    print(sumpo + abs(li[i+1]-li[i-1]) - (abs(li[i]-li[i-1])+abs(li[i+1]-li[i])))
Problem p03447 (python)

Fixed submission:
a = (int)(input())
b = (int)(input())
c = (int)(input())
a-=b
print(a%c)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
a -= b
print(a%c)
Problem p03505 (python)

Fixed submission:
p,a,b = map(int,input().split())
if(a<=b):
  if(a>=p):
    print(1)
  else:
  	print(-1)
else:
  p-=a
  up=a-b
  if(p<=0):
    print(1)
  else:
  	num=p//up+(p%up!=0)
  	print(num*2+1)

Buggy submission (verdict: Runtime Error):
p,a,b = map(int,input().split())
if(a<=b):
  print(-1)
else:
  p-=a
  up=a-b
  if(p<=0):
    print(1)
  else
  	num=p//up+(p%up!=0)
  	print(num*2+1)
Problem p03549 (python)

Fixed submission:
a,b = map(int,input().split())
print(100*(a-b)*pow(2,b)+pow(2,b)*1900*b)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(100*b+pow(2,m)*1900)
Problem p03633 (python)

Fixed submission:
def gcd(a,b):
  a = int(a)
  b = int(b)
  r = (int)(a%b)
  while(r!=0):
    a=(int)(b)
    b=(int)(r)
    r=(int)(a%b)
  return b
def lcm(a,b):
    return int((a*b)//gcd(a,b))
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  a = int(a)
  b = int(b)
  r = (int)(a%b)
  while(r!=0):
    a=(int)(b)
    b=(int)(r)
    r=(int)(a%b)
  return b
def lcm(a,b):
    return int((a*b)/gcd(a,b))
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  a = int(a)
  b = int(b)
  r = (int)(a%b)
  while(r!=0):
    a=(int)(b)
    b=(int)(r)
    r=(int)(a%b)
  return b
def lcm(a,b):
    return (a*b)/gcd(a,b)
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  r = (int)(a%b)
  while(r!=0):
    a=(int)(b)
    b=(int)(r)
    r=(int)(a%b)
  return b
def lcm(a,b):
    return (a*b)/gcd(a,b)
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  r = (int)(a%b)
  while(r!=0):
    a=(int)b
    b=(int)r
    r=(int)a%b
  return b
def lcm(a,b):
    return (a*b)/gcd(a,b)
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  r = a%b
  while(r==0):
    a=b
    b=r
    r=a%b
  return b
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = gcd(max(ans,num),min(ans,num))
print(ans)
Problem p03759 (python)

Fixed submission:
a,b,c = map(int,input().split())
if(c-b == b-a):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if(c-b and b-a):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if c-b and b-a:
    print("YES")
else:
    print("NO")
Problem p03761 (python)

Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
    cnt = 1e10
    for ss in s:
        cnt = min(cnt,ss.count(a))
    for i in range(cnt):
        ans += a
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
s2 = input()
s3 = input()
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
  for i in range(min(s.count(a),s2.count(a),s3.count(a))):
    ans += a
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
s2 = input()
s3 = input()
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
  for i in range(min(s.count(a),s2.count(a),s3.count(a))):
    ans += a
print(ans)
Problem p03945 (python)

Fixed submission:
s = input()
ans = 0
for i in range(1,len(s)):
    if(s[i]!=s[i-1]):
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
for i in range(1,n):
    if(s[i]!=s[i-1]):
        ans += 1
print(ans)
Problem p02534 (python)

Fixed submission:
print(eval("'ACL'*"+input()))

Buggy submission (verdict: Runtime Error):
print(eval("'ACL'*input()"))
Problem p02618 (python)

Fixed submission:
for i in range(365):print((19-i)%26+1)

Buggy submission (verdict: Runtime Error):
def calc_score(sch):
    d=[0]*26
    score=0
    for i in range(dur):
        j=sch[i]-1
        s=S[i]
        score+=s[j]+c[j]*(i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
        d[j]=i+1
    return score

def greedy(dur,c,S,r):
    sch=[]
    d=[0]*26
    for i in range(dur):
        t=0
        s=S[i]
        m=-1<<64
        for j in range(26):
            alt=s[j]+r*c[j]*(i+1-d[j])+sum([-r*c[k]*(i+1-d[k]) for k in range(26)])
            #alt=s[j]-(-c[j]*(i+1-d[j])+sum([c[k]*(i+1-d[k]) for k in range(26)]))**r
            if alt>m:
                m=alt
                t=j
        sch.append(t+1)
        d[t]=i+1
    return sch

dur=int(input())
c=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(dur)]

T=50
a,b=1,8
R=1
tmp=-inf

for r in [a+i*(b-a)/T for i in range(T)]:
    alt_sch=greedy(dur,c,S,r)
    alt=calc_score(alt_sch)
    if tmp<alt:
        tmp=alt
        sch=alt_sch
        R=r

for i in sch:
    print(i)

Buggy submission (verdict: Runtime Error):
import random
dur=int(input())
c=list(map(int,input().split()))
cM=max(c)
for i in range(26):
  if c[i]==cM:M=i
d=[0]*26
for i in range(dur):
  t=0
  s=list(map(int,input().split()))
  m=-1<<64
  for j in range(26):
    alt=s[j]+c[j]*(i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  r=randint(1,1000)
  if r<50:
    print(M+1)
    d[M]=i+1
  else:
    print(t+1)
    d[t]=i+1

Buggy submission (verdict: Runtime Error):
d=int(input())
c=map(int,input().split())
d=[0]*26
for i in range(365):
  s=map(int,input().split())
  m=-1<<64
  for j in range(26):
    alt=s[j]+c[j](i+1-d[j])+sum([-c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  print(j+1)
  d[j]=i+1