Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
from operator import itemgetter
input=sys.stdin.readline
n,x=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=list(zip(*a))
t=max(b[0])
a.sort(key=itemgetter(1),reverse=True)
ans=0
for i in range(n):
  if x<=0:
    print(ans)
    break
  if a[1][i]>=t:
    x-=a[1][i]
    ans+=1
  else:
    ans+=(x+t-1)//t
    x=0

Fixed submission:
import sys
from operator import itemgetter
input=sys.stdin.readline
n,x=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=list(zip(*a))
t=max(b[0])
a.sort(key=itemgetter(1),reverse=True)
ans=0
for i in range(n):
  if a[i][1]>=t:
    x-=a[i][1]
    ans+=1
  if x<=0:
    print(ans)
    break
else:
  ans+=(x+t-1)//t
  x=0
  print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
from operator import itemgetter
input=sys.stdin.readline
n,x=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
a=list(zip(*a))
t=max(a[0])
a.sort(key=itemgetter(1),reverse=True)
ans=0
for i in range(n):
  if x<=0:
    print(ans)
    break
  if a[1][i]>=t:
    x-=a[1][i]
    ans+=1
  else:
    ans+=(x+t-1)//t
    x=0

Fixed submission:
import sys
from operator import itemgetter
input=sys.stdin.readline
n,x=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=list(zip(*a))
t=max(b[0])
a.sort(key=itemgetter(1),reverse=True)
ans=0
for i in range(n):
  if a[i][1]>=t:
    x-=a[i][1]
    ans+=1
  if x<=0:
    print(ans)
    break
else:
  ans+=(x+t-1)//t
  x=0
  print(ans)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
for i in range(1,1000):
  x*=2
  if x>y:
    print(i)
    break

Fixed submission:
a,b,c,d=map(int,input().split())
if a+b>c+d:
  print("Left")
elif a+b==c+d:
  print("Balanced")
else:
  print("Right")

Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if a+b>c+d:
  print("Left")
elif a+b=c+d:
  print("Balanced")
else:
  print("Right")

Fixed submission:
a,b,c,d=map(int,input().split())
if a+b>c+d:
  print("Left")
elif a+b==c+d:
  print("Balanced")
else:
  print("Right")
Buggy python submission (verdict: Runtime Error):
import math
x,y=int(input())
print(int(math.log2(y//x)+1))

Fixed submission:
x,y=map(int,input().split())
for i in range(1,1000):
  x*=2
  if x>y:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
import sys
s = input()
gx,gy = map(int, input().split(' '))
x_d = [0]
y_d = []
cnt = 0
for i in range(len(s)):
    if s[i] == "T":
        cnt += 1
        if cnt % 2 == 0:
            x_d.append(0)
        elif cnt % 2 == 1:
            y_d.append(0)
    if s[i] == "F":
        if cnt % 2 == 0:
            x_d[-1] += 1
        elif cnt % 2 == 1:
            y_d[-1] += 1
x_d.append(0)
y_d.append(0)
if (sum(x_d)-gx) % 2 or (sum(y_d)-gy) % 2:
    print("No")
    sys.exit()
x_n = (sum(x_d)-gx)//2
y_n = (sum(y_d)-gy)//2
DPx = [[False for i in range(x_n+2)] for j in range(len(x_d))]
DPy = [[False for i in range(y_n+2)] for j in range(len(y_d))]
for x in DPx:
    x[0] = True
for y in DPy:
    y[0] = True
for i in range(len(x_d)-1):
    for j in range(x_n+1):
        if DPx[i][j]:
            DPx[i+1][j] = True
            if j+x_d[i] <= x_n:
                DPx[i+1][j+x_d[i]] = True
for i in range(len(y_d)-1):
    for j in range(y_n+1):
        if DPy[i][j]:
            DPy[i+1][j] = True
            if j+y_d[i] <= y_n:
                DPy[i+1][j+y_d[i]] = True

if DPx[len(x_d)-1][x_n] and DPy[len(y_d)-1][y_n]:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b=map(int,input().split())
print((a+b+1)//2)

Buggy python submission (verdict: Runtime Error):
import sys
s = input()
gx,gy = map(int, input().split(' '))
x_d = [0]
y_d = []
cnt = 0
for i in range(len(s)):
    if s[i] == "T":
        cnt += 1
        if cnt % 2 == 0:
            x_d.append(0)
        elif cnt % 2 == 1:
            y_d.append(0)
    if s[i] == "F":
        if cnt % 2 == 0:
            x_d[-1] += 1
        elif cnt % 2 == 1:
            y_d[-1] += 1
x_d.append(0)
y_d.append(0)
if (sum(x_d)-gx) % 2 or (sum(y_d)-gy) % 2:
    print("No")
    sys.exit()
x_n = (sum(x_d)-gx)//2
y_n = (sum(y_d)-gy)//2
DPx = [[False for i in range(x_n+1)] for j in range(len(x_d))]
DPy = [[False for i in range(y_n+1)] for j in range(len(y_d))]
for x in DPx:
    x[0] = True
for y in DPy:
    y[0] = True
for i in range(len(x_d)-1):
    for j in range(x_n+1):
        if DPx[i][j]:
            DPx[i+1][j] = True
            if j+x_d[i] <= x_n:
                DPx[i+1][j+x_d[i]] = True
for i in range(len(y_d)-1):
    for j in range(y_n+1):
        if DPy[i][j]:
            DPy[i+1][j] = True
            if j+y_d[i] <= y_n:
                DPy[i+1][j+y_d[i]] = True

if DPx[-2][x_n] and DPy[-2][y_n]:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b=map(int,input().split())
print((a+b+1)//2)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
s.sort()
t.sort(reverse=True)
if s>t:
  print("No")
else:
  print("Yes")

Fixed submission:
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
if s>=t:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
c=list(c)
ans=0
for k in range(len(c)):
  i=c[k][0]
  x=c[k][1]
  if i>x:
    ans+=x
  elif i<x:
    ans+=x-i
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
c=list(c.items())
ans=0
for k in range(len(c)):
  i=c[k][0]
  x=c[k][1]
  if i>x:
    ans+=x
  elif i<x:
    ans+=x-i
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=list(Counter(a))
ans=0
for k in range(len(c)):
  i=c[k][0]
  x=c[k][1]
  if i>x:
    ans+=x
  elif i<x:
    ans+=x-i
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
c=list(c.items())
ans=0
for k in range(len(c)):
  i=c[k][0]
  x=c[k][1]
  if i>x:
    ans+=x
  elif i<x:
    ans+=x-i
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=list(Counter(a))
ans=0
for (i,x) in c:
  if i>x:
    ans+=x
  elif i<x:
    ans+=x-i
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
c=list(c.items())
ans=0
for k in range(len(c)):
  i=c[k][0]
  x=c[k][1]
  if i>x:
    ans+=x
  elif i<x:
    ans+=x-i
print(ans)
Buggy python submission (verdict: Runtime Error):
N,C = map(int,input().split())
p = [list(map(int,input().split())) for i in range(N)]
p.sort()
ch = [[0,0] for i in range(C+1)]
p_true = []
for i in range(N):
  [s,t,c] = p[i]
  if ch[c][1] == s:
    ch[c][1] = t
  elif ch[c] == [0,0]:
    ch[c] = [s,t]
  else:
    p_true.append([*ch[c],c])
    ch[c] = [s,t]
for i in range(1,C+1):
  if ch[i] != [0,0]:
    p_true.append([*ch[i],i])
p_true.sort()

Fixed submission:
from itertools import accumulate
import sys
input = sys.stdin.readline
N,C = map(int,input().split())
p = [list(map(int,input().split())) for i in range(N)]
p.sort()
ch = [[0,0] for i in range(C+1)]
p_true = []
for i in range(N):
  [s,t,c] = p[i]
  if ch[c][1] == s:
    ch[c][1] = t
  elif ch[c] == [0,0]:
    ch[c] = [s,t]
  else:
    p_true.append([ch[c][0],ch[c][1],c])
    ch[c] = [s,t]
for i in range(1,C+1):
  if ch[i] != [0,0]:
    p_true.append([ch[i][0],ch[i][1],i])
p_true.sort()
time = [0 for i in range(100002)]
for i in range(len(p_true)):
  [s,t,c] = p_true[i]
  time[s] += 1
  time[t+1] -= 1
print(max(accumulate(time)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
d.sort()
time=[0]*24
time[0]=1
if n==0:
  print(0)
  exit()
for i in range(n):
  if i%2:
    time[d[i]]+=1
  else:
    time[24-d[i]]+=1
if max(time)>1:
  print(0)
  exit()
flg=0
ans=0
cnt=0
for i in range(25):
  i=i%24
  if time[i]==0 and not flg:
    flg=1
    cnt=1
  elif time[i]==0:
    cnt+=1
  else:
    ans=max(ans,cnt)
    cnt=0
    flg=0
print(ans)
    
    

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
d.sort()
time=[0]*24
time[0]=1
for i in range(n):
  if i%2:
    time[d[i]]+=1
  else:
    time[-d[i]]+=1
if max(time)>1:
  print(0)
  exit()
ans=[]
cnt=1
for i in range(1,25):
  i=i%24
  if time[i]==0:
    cnt+=1
  else:
    ans.append(cnt)
    cnt=1
print(min(ans))
Buggy python submission (verdict: Runtime Error):
a=int(input())
print("YNeos"[(a//10)%11*(a%1000)%11>0::2]

Fixed submission:
n=input()
if int(n[:3])%111==0 or int(n[1:])%111==0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
h,w = map(int, input().split(' '))
tbl = [list(map(int, input().split(' '))) for i in range(10)]
wf = [[10**18 for i in range(10)] for j in range(10)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            wf[i][j] = min(tbl[i][j], tbl[i][k]+tbl[k][j])
wall = [list(map(int, input().split(' '))) for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        num = wall[i][j]
        if num == -1:
            continue
        else:
            ans += wf[num][1]
print(ans)

Fixed submission:
n=input()
if int(n[:3])%111==0 or int(n[1:])%111==0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
h,w=map(int, input().split(' '))
tbl = [list(map(int, input().split(' '))) for i in range(10)]
tbli = list(zip(*tbl))
cost = [10**18]*10
cost[1]=0
sorttool = [0,1,2,3,4,5,6,7,8,9]
order = list(zip(tbli[1],sorttool))
order.sort()
del order[0]
for i,(c,x) in enumerate(order):
    cost[x] = min(cost[x],tbli[1][x])
    if i == 0:
        continue
    for j in range(i):
        cost[x]=min(cost[x],cost[order[j][1]]+tbli[order[j][1]][x])
cost.append(0)
wall = [list(map(int, input().split(' '))) for i in range(h)]
ans =0
for i in range(h):
    for j in range(w):
        ans += cost[wall[i][j]]
print(ans)

Fixed submission:
n=input()
if int(n[:3])%111==0 or int(n[1:])%111==0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
x, y = map(input().split(' '))
if x>y:
  print(">")
elif x<y:
  print("<")
else:
  print("=")

Fixed submission:
x, y = input().split(' ')
if x>y:
  print(">")
elif x<y:
  print("<")
else:
  print("=")
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())
mins = [1000 for i in range(n+1)]
used = [0 for i in range(n+1)]
deq = deque()
deq.append((1,1))
while deq:
  x,cnt = deq.popleft()
  mins[x] = min(mins[x],cnt)
  used[x] = 1
  if used[10*x%n] == 0:
    deq.appendleft((10*x%n,cnt))
  if used[(x+1)%n] == 0:
    deq.append(((x+1)%n,cnt+1))
print(mins[0])

Fixed submission:
a=input()
b=input()
if a == b[::-1]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
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 i in range(n):
  x=b[i]
  y=bisect.bisect_left(a,x)
  z=bisect.bisect_right(c,x)
    ans+=(n-z)*y
print(ans)

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 i in range(n):
  x=b[i]
  y=bisect.bisect_left(a,x)
  z=bisect.bisect_right(c,x)
  ans+=(n-z)*y
print(ans)

Buggy python submission (verdict: Runtime Error):
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 i in range(n):
  x=a[i]
  y=bisect.bisect_right(x)
  if y<n:
    z=bisect.bisect_right(b[y])
    ans+=n-z
print(ans)

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 i in range(n):
  x=b[i]
  y=bisect.bisect_left(a,x)
  z=bisect.bisect_right(c,x)
  ans+=(n-z)*y
print(ans)

Buggy python submission (verdict: Runtime Error):
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 i in range(n):
  x=a[i]
  y=bisect.bisect_right(x)
  z=bisect.bisect_right(b[y])
  ans+=n-z
print(ans)

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 i in range(n):
  x=b[i]
  y=bisect.bisect_left(a,x)
  z=bisect.bisect_right(c,x)
  ans+=(n-z)*y
print(ans)
Buggy python submission (verdict: Runtime Error):
k,n = map(int,input().split())
if k%2 == 0:
  ans = [k//2]+[k//2+1]*(n-1)
else:
  print(2/0)
  t = n//2
  ans = [k//2+1]*n
  for i in range(t):
    if len(ans) < n:
      ans[-1] -= 1
      ans.append(k)
    elif ans[-1] > 1:
      ans[-1] -= 1
    else:
      ans.pop()
print(*ans)

Fixed submission:
k,n = map(int,input().split())
if k%2 == 0:
  ans = [k//2]+[k]*(n-1)
else:
  t = n//2
  ans = [k//2+1]*n
  for i in range(t):
    if ans[-1] == 1:
      ans.pop()
    else:
      ans[-1] -= 1
      while len(ans) < n:
        ans.append(k)
print(*ans)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
ls=len(s)
lt=len(t)
if ls<lt:
  print("UNRESTORABLE")
  exit()
for i in range(ls-lt,-1,-1):
  for j in range(i,i+lt):
    if s[j]==t[j] or s[j]=="?":
      continue
    else:
      break
  else:
    for k in range(i,i+lt):
      s[k]=t[k]
    for l in range(ls):
      if s[l]=="?":
        s[l]="a"
    print(s)
    exit()
else:
  print("UNRESTORABLE")

Fixed submission:
s=list(input())
t=list(input())
ls=len(s)
lt=len(t)
if ls<lt:
  print("UNRESTORABLE")
  exit()
for i in range(ls-lt,-1,-1):
  for j in range(i,i+lt):
    if s[j]==t[j-i] or s[j]=="?":
      continue
    else:
      break
  else:
    for k in range(i,i+lt):
      s[k]=t[k-i]
    for l in range(ls):
      if s[l]=="?":
        s[l]="a"
    print(*s,sep="")
    exit()
else:
  print("UNRESTORABLE")
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
t = s.replace("x","")
if not t:
  print(0)
  exit()
l = len(t)
if t != t[::-1]:
  print(-1)
  exit()
plc = [-1]
for i in range(n):
  if s[i] != x:
    plc.append(i)
plc.append(n)
l = len(plc)
if l%2 == 0:
  fm = plc[:l//2]
  lt = plc[l//2:]
else:
  fm = plc[l//2+1]
  lt = plc[l//2:]
lt = lt[::-1]
ans = 0
for i in range(1,len(fm)):
  ans += abs((fm[i]-fm[i-1])-(lt[i]-lt[i-1]))
print(ans)
  

Fixed submission:
s = input()
n = len(s)
t = s.replace("x","")
if not t:
  print(0)
  exit()
l = len(t)
if t != t[::-1]:
  print(-1)
  exit()
plc = [-1]
for i in range(n):
  if s[i] != "x":
    plc.append(i)
plc.append(n)
l = len(plc)
if l%2 == 0:
  fm = plc[:l//2]
  lt = plc[l//2:]
else:
  fm = plc[:l//2+1]
  lt = plc[l//2:]
lt = lt[::-1]
ans = 0
for i in range(1,len(fm)):
  ans += abs((fm[i]-fm[i-1])-(lt[i-1]-lt[i]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
s = input()
n = len(s)
dp = defaultdict(int)
dp[0] = 1
ls = [1<<(ord(s[0])-97)]
for i in range(1,n):
  ls.append(ls[-1]^(1<<(ord(s[i])-97)))
if ls[-1] == 0:
  print(1)
  exit()
for i in range(n):
  for b in range(26):
    bit = 1<<b
    if dp[ls[i]^bit] == 0:
      continue
    if dp[ls[i]] == 0:
      dp[ls[i]] = dp[ls[i]^bit]+1
    else:
      dp[ls[i]] = min(dp[ls[i]^bit]+1,dp[ls[i]])
print(dp[ls[n-1]]-1)

Fixed submission:
from collections import defaultdict
s = input()
n = len(s)
dp = defaultdict(int)
dp[0] = 1
ls = [1<<(ord(s[0])-97)]
for i in range(1,n):
  ls.append(ls[-1]^(1<<(ord(s[i])-97)))
if ls[-1] == 0:
  print(1)
  exit()
for i in range(n):
  for b in range(26):
    bit = 1<<b
    if dp[ls[i]^bit] == 0:
      continue
    if dp[ls[i]] == 0:
      dp[ls[i]] = dp[ls[i]^bit]+1
    else:
      dp[ls[i]] = min(dp[ls[i]^bit]+1,dp[ls[i]])
print(dp[ls[n-1]]-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())

for x in range(1, 3501):
    for y in range(1, 3501):
        if N*x*y/(4*x*y-N*(x+y)) == int(N*x*y/(4*x*y-N*(x+y))) and int(N*x*y/(4*x*y-N*(x+y))) > 0:
            print(x, y, int(N*x*y/(4*x*y-N*(x+y))))
            break
    else:
        continue
    break


Fixed submission:
N = int(input())

for x in range(1, 3501):
    for y in range(1, 3501):
        if 4*x*y-N*(x+y) != 0:
            if N*x*y/(4*x*y-N*(x+y)) == int(N*x*y/(4*x*y-N*(x+y))) and int(N*x*y/(4*x*y-N*(x+y))) > 0:
                print(x, y, int(N*x*y/(4*x*y-N*(x+y))))
                break
    else:
        continue
    break
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = []
l = k.bit_length()
for i in range(l-1,-1,-1):
  if i == 0:
    x = k
  elif k & 1 << i:
    x = (k >> (i+1)) << i+1 | (1 << i)-1
  sm = 0
  for j in range(n):
    if a[j][0] | x == x:
      sm += a[j][1]
  ans.append(sm)
print(max(ans))

Fixed submission:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = [0]
l = max(k.bit_length(),1)
for i in range(l-1,-1,-1):
  if i == 0:
    x = k
  elif k & 1 << i:
    x = (k >> (i+1)) << i+1 | (1 << i)-1
  sm = 0
  for j in range(n):
    if a[j][0] | x == x:
      sm += a[j][1]
  ans.append(sm)
print(max(ans))

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = []
l = k.bit_length()
for i in range(l-1,-1,-1):
  if i == 0:
    x = k
  elif k & 1 << i:
    x = (k >> (i+1)) << i+1 | (1 << i)-1
  sm = 0
  for j in range(n):
    if a[j][0] | x == x:
      sm += a[j][1]
  ans.append(sm)
print(max(ans))

Fixed submission:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = [0]
l = max(k.bit_length(),1)
for i in range(l-1,-1,-1):
  if i == 0:
    x = k
  elif k & 1 << i:
    x = (k >> (i+1)) << i+1 | (1 << i)-1
  sm = 0
  for j in range(n):
    if a[j][0] | x == x:
      sm += a[j][1]
  ans.append(sm)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
print("NYoe s"[int(input())[:4]=="YAKI"::2])

Fixed submission:
print("NYoe s"[input()[:4]=="YAKI"::2])

Buggy python submission (verdict: Runtime Error):
print("NYoe s"[int(input())[:4]::2])

Fixed submission:
print("NYoe s"[input()[:4]=="YAKI"::2])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
s=list(input())
n=len(s)
c=s.Counter()
ans=1+n*(n-1)//2
for i in c.values():
  ans-=i*(i-1)//2
print(ans)

Fixed submission:
from collections import Counter
s=list(input())
n=len(s)
c=Counter(s)
ans=1+n*(n-1)//2
for i in c.values():
  ans-=i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=np.ndarray([int(input()) for i in range(n)])
print(np.lcm.reduce(a))

Fixed submission:
from functools import reduce, partial
from fractions import gcd
def lcm(a,b):
  return a*b//gcd(a,b)
n=int(input())
a=[int(input()) for i in range(n)]
lcmmulti = partial(reduce,lcm)
print(lcmmulti(a))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
tr=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  if a!=1 and b!=n:
    continue
  tr[a].append(b)
  tr[b].append(a)
for i in range(n):
  if len(tr[i])==2:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")


Fixed submission:
n,m=map(int,input().split())
tr=[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  if a!=1 and b!=n:
    continue
  tr[a].append(b)
  tr[b].append(a)
for i in range(2,n):
  if len(tr[i])==2:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
tr=[[] for i in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  if a!=1 and b!=n:
    continue
  tr[a].append(b)
  tr[b].append(a)
for i in range(m):
  if len(tr[m])==2:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

Fixed submission:
n,m=map(int,input().split())
tr=[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  if a!=1 and b!=n:
    continue
  tr[a].append(b)
  tr[b].append(a)
for i in range(2,n):
  if len(tr[i])==2:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input())
if a%3 and b%3 and (a+b)%3:
  print("Impossible")
else:
  print("Possible")

Fixed submission:
a,b = map(int, input().split())
if a%3 and b%3 and (a+b)%3:
  print("Impossible")
else:
  print("Possible")
Buggy python submission (verdict: Runtime Error):
from collections import Counter

mod = 10**9+7
rng = 100001
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<=0 or k<0 or n<k:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod

n = int(input())
a = list(map(int,input().split()))
same = []
c = Counter(a)
x = c.most_common()[0][0]
for i in range(n+1):
  if a[i] == x:
    same.append(i+1)
y = same[1]-same[0]+1
print(n)
for k in range(2,n+2):
  print((cmb(n+1,k)-cmb(n+1-y,k-1))%mod)

Fixed submission:
from collections import Counter

mod = 10**9+7
rng = 100002
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<=0 or k<0 or n<k:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod

n = int(input())
a = list(map(int,input().split()))
same = []
c = Counter(a)
x = c.most_common()[0][0]
for i in range(n+1):
  if a[i] == x:
    same.append(i+1)
y = same[1]-same[0]+1
print(n)
for k in range(2,n+2):
  print((cmb(n+1,k)-cmb(n+1-y,k-1))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
buttons = int(input())
next = []
impossible = []
for i in range(buttons):
    next.append(int(input()))
now_button = 1
ans = 1
while next[now_button - 1] != 2:
    if next[now_button - 1] not in impossible:
        impossible.append(next[now_button - 1])
        now_button = next[now_button - 1]
        ans += 1
    else:
        ans = -1
        break
        
print(ans)
    

Fixed submission:
buttons = int(input())
next_ = []
impossible = []
for i in range(buttons):
    next_.append(int(input()))
now_button = 1
ans = 1
while next_[now_button - 1] != 2:
    if ans <= buttons:
        now_button = next_[now_button - 1]
        ans += 1
        
#    if next_[now_button - 1] not in impossible:
#        impossible.append(next_[now_button - 1])
#        now_button = next_[now_button - 1]
#        ans += 1
    else:
        ans = -1
        break

        
print(ans)
Buggy python submission (verdict: Runtime Error):
import queue
n=int(input())
s=input()
q=queue.Queue(s)
def br(a):
  for i in range(1,len(a)+1):
    if a[:i].count("(")<a[:i].count(")"):
      return ")"
  if a.count("(")==a.count(")"):
    return "0"
  else:
    return "("
for i in range(1,len(s)+1):
  if s[:i].count("(")<s[:i].count(")"):
    s.append("(")
  

Fixed submission:
from collections import deque
n=int(input())
s = input()
cnt = [0]
ans = deque(list(s))
for i in range(n):
  if s[i]=="(":
    cnt.append(cnt[-1]+1)
  else:
    cnt.append(cnt[-1]-1)
rt = min(cnt)
if rt<0:
  ans.extendleft("("*(-rt))
if cnt[-1]-rt>0:
  ans.extend(")"*(cnt[-1]-rt))
print(*ans,sep="")