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

Fixed submission:
import itertools

n,a,b,c=(input().split())
n,a,b,c=int(n),int(a),int(b),int(c)
l=[int(input()) for i in range(n)]
#print(n,a,b,c,l)

ansans=float('inf')
ans=float('inf')

mylist=list(itertools.product(range(4),repeat=n))
#print(len(mylist))
#mylist=[1,2,2,2,3]
for j in range(len(mylist)):
    x,y,z=0,0,0
    for i in range(n):
        if mylist[j][i]==1:
            x+=l[i]
        elif mylist[j][i]==2:
            y+=l[i]
        elif mylist[j][i]==3:
            z+=l[i]
        
    if mylist[j].count(1)>0 and mylist[j].count(2)>0 and mylist[j].count(3) > 0:
        ans=0
        ans+=abs(a-x)+abs(b-y)+abs(c-z)
        compo=0
        for i in range(1,4):
            compo+=mylist[j].count(i)-1
        ans+=10*compo

    if ans < ansans:
        ansans = ans

print(ansans)

Buggy submission (verdict: Runtime Error):
a,b,q=(input().split())
a,b,q=int(a),int(b),int(q)
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
x=[int(input()) for i in range(q)]
dist=['' for i in range(8)]
dist1=['' for i in range(2)]
dist2=['' for i in range(4)]
sp1=['' for i in range(2)]
tp1=['' for i in range(4)]

import bisect
for k in range(q):

    p1=bisect.bisect_left(s,x[k])

    if 0 < p1 < a:
        dist1[0]=x[k]-s[p1-1]
        dist1[1]=s[p1]-x[k]
        sp1[0]=s[p1-1]
        sp1[1]=s[p1]
    elif p1==0:
        dist1[0]=s[0]-x[k]
        dist1[1]=s[0]-x[k]
        sp1[0]=s[0]
        sp1[1]=s[0]        
    elif p1==a:
        dist1[0]=x[k]-s[a-1]
        dist1[1]=x[k]-s[a-1]
        sp1[0]=s[a-1]
        sp1[1]=s[a-1]
        
    for i in range(2):     
        p11=bisect.bisect_left(t,sp1[i])

        if 0 < p11 < b:
            dist2[0+2*i]=sp1[i]-t[p11-1]
            dist2[1+2*i]=t[p11]-sp1[i]
        if p11==0:
            dist2[0+2*i]=t[0]-sp1[i]
            dist2[1+2*i]=t[0]-sp1[i]
        elif p11==b:
            dist2[0+2*i]=sp1[i]-t[b-1]
            dist2[1+2*i]=sp1[i]-t[b-1]
        
    dist[0]=dist1[0]+dist2[0]
    dist[1]=dist1[0]+dist2[1]
    dist[2]=dist1[1]+dist2[2]
    dist[3]=dist1[1]+dist2[3]
                
    p1=bisect.bisect_left(t,x[k])

    if 0 < p1 < b:
        sp1[0]=t[p1-1]
        sp1[1]=t[p1]
        dist1[0]=x[k]-t[p1-1]
        dist1[1]=t[p1]-x[k]
    elif p1==0:
        sp1[0]=t[0]
        sp1[1]=t[0]
        dist1[0]=t[0]-x[k]
        dist1[1]=t[0]-x[k]
    elif p1==b:
        sp1[0]=t[b-1]
        sp1[1]=t[b-1]
        dist1[0]=x[k]-t[b-1]
        dist1[1]=x[k]-t[b-1]
        
    for i in range(2):    
        p11=bisect.bisect_left(s,sp1[i])

        if 0 < p11 < a:
            dist2[0+2*i]=sp1[i]-s[p11-1]
            dist2[1+2*i]=s[p11]-sp1[i]
        elif p11==0:
            dist2[0+2*i]=s[0]-sp1[i]
            dist2[1+2*i]=s[0]-sp1[i]
        elif p11==a:
            dist2[0+2*i]=sp1[i]-s[a-1]
            dist2[1+2*i]=sp1[i]-s[a-1]

    dist[4]=dist1[0]+dist2[0]
    dist[5]=dist1[0]+dist2[1]
    dist[6]=dist1[1]+dist2[2]
    dist[7]=dist1[1]+dist2[3]
    
    ans=min(dist[0],dist[1],dist[2],dist[3],dist[4],dist[5],dist[6],dist[7])

    print(ans)
Problem p03161 (python)

Fixed submission:
n,k=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]
#print(n,k,h)
dp=[float('inf') for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])

if k > 1 and n > 2:
  for y in range(2,k):
    dp[y]=abs(h[y]-h[0])
    x=1
    while x < k:
      tmp=dp[x]+abs(h[y]-h[x])
      if tmp < dp[y]:
        dp[y]=tmp
      x+=1
  for y in range(k,n):    
    dp[y]=dp[y-1]+abs(h[y]-h[y-1])
    for x in range(2,k+1):
      tmp=dp[y-x]+abs(h[y]-h[y-x])
      if tmp < dp[y]:
        dp[y]=tmp
        
if k == 1 and n > 2:
  for y in range(2,n):
    dp[y]=dp[y-1]+abs(h[y]-h[y-1])

print(dp[-1])

Buggy submission (verdict: Runtime Error):
#import numpy as np

n,k=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]



a=np.array(h)
b=[[0 for i in range(n)] for j in range(n)]
b=np.array(b)

for j in range(n):
    for i in range(n):
        if j>i:
            b[j][i]=abs(a[j]-a[i])
#print(b)

dp=[int(0) for i in range(n)]
dp0=[[1000000000000000 for i in range(n)] for j in range(n)]

dp0[0]=0
dp[0]=0

dp0[1]=b[1][0]
dp[1]=dp0[1]

if k==1:
    for i in range(2,n):
        dp[i]=dp[i-1]+b[i][i-1]
    
if k > 1:
    for j in range(2,n):
        if j <=k:
            for i in range(j):
                dp0[j][i]=dp[i]+b[j][i]
            dp[j]=min(dp0[j])
        else:
            for i in range(k):
                dp0[j][i+j-k]=dp[i+j-k]+b[j][i+j-k]
            dp[j]=min(dp0[j])

#print(dp0)
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]

import numpy as np

a=np.array(h)
b=[[0 for i in range(n)] for j in range(n)]
b=np.array(b)

for j in range(n):
    for i in range(n):
        if j>i:
            b[j][i]=abs(a[j]-a[i])
#print(b)

dp=[int(0) for i in range(n)]
dp0=[[100000000000 for i in range(n)] for j in range(n)]

dp0[0]=0
dp[0]=0

dp0[1]=b[1][0]
dp[1]=dp0[1]

if k==1:
    for i in range(2,n):
        dp[i]=dp[i-1]+b[i][i-1]
    
if k > 1:
    for j in range(2,n):
        if j <=k:
            for i in range(j):
                dp0[j][i]=dp[i]+b[j][i]
            dp[j]=min(dp0[j])
        else:
            for i in range(k):
                dp0[j][i+j-k]=dp[i+j-k]+b[j][i+j-k]
            dp[j]=min(dp0[j])

#print(dp0)
print(dp[n-1])
Problem p03192 (python)

Fixed submission:
n=input()
ans=0
ans=n.count('2')
print(ans)

Buggy submission (verdict: Runtime Error):
n, p= [int(i) for i in input().split()]
#print(n,p)
ans=0
pp=int(p**(1/n))+1
for i in range(1,pp):
  b=i**n
  c=p/b
  if c.is_integer()==True:
    ans=i
    
print(ans)
Problem p03206 (python)

Fixed submission:
n=int(input())
if n==25:
  print('Christmas') 
elif n==24:
  print('Christmas Eve')
elif n==23:
  print('Christmas Eve Eve') 
elif n==22:
  print('Christmas Eve Eve Eve')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==25:
  print('Christmas') 
elif n==24:
  print('Christmas Eve')
elif n==23:
  print('Christmas Eve Eve') 
elif n==22;
  print('Christmas Eve Eve Eve')
Problem p03227 (python)

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

Buggy submission (verdict: Runtime Error):
from collections import deque
n = int(input())
listx = [int(input()) for i in range(n)]
listx.sort()
listx = deque(listx)
listy = deque([])
ans=0

x=listx.popleft()
listy.appendleft(x)
x=listx.pop()
listy.append(x)
ans+=int(listy[1])-int(listy[0])

while len(listx)>=1:
    abs1=abs(listx[0]-listy[-1])
    abs2=abs(listx[-1]-listy[0])

    if abs1 < abs2:
        x=listx.pop()
        listy.appendleft(x)
        ans+=abs2

    else:
        x=listx.popleft()
        listy.append(x)
        ans+=abs1
        
    if listy[0] > listy[-1]:
        listy.reverse()

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n=int(input())
x=[int(input()) for i in range(n)]
listX = list(itertools.permutations(x, n))

listY = []
for j in range(len(listX)):
  y = 0
  for i in range(n-1):
    y = y + abs(listX[j][i]-listX[j][i+1])
  listY.append(y)

print(max(listY))
Problem p03243 (python)

Fixed submission:
n=int(input())
ans=999
for i in range(n,1000):
  if i%111==0:
    if i<=ans:
      ans=i
      
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())

if n%111==0:
  print(n)
else:
  while n%111>0:
    ans=n
    n+=1
print(ans+1)
Problem p03262 (python)

Fixed submission:
n,x = (int(i) for i in input().split())
listx=[int(i) for i in input().split()]
#print(n,x,listx)
listy=[abs(listx[i]-x) for i in range(n)]
listy.reverse()
#print(listy)

def gcd(y, x):
    if x == 0:
        return y
    else:
        return gcd(x, y % x) #再帰定義
if n==1:
  ans=listy[0]
else:
  if listy[1]==0:
    ans=listy[0]
  else:
    ans=gcd(listy[0],listy[1])
    if n > 2:
      for i in range(0,n-2):
        if listy[i+2]==0:
          ans=ans
        else:
          ans=gcd(ans,listy[i+2])
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,x = (int(i) for i in input().split())
listx=[int(i) for i in input().split()]
#print(n,x,listx)
listy=[abs(listx[i]-x) for i in range(n)]
listy.reverse()
#print(listy)

def gcd(y, x):
    if x == 0:
        return y
    else:
        return gcd(x, y % x) #再帰定義
if x==1:
  ans=listy[0]
else:
  if listy[1]==0:
    ans=listy[0]
  else:
    ans=gcd(listy[0],listy[1])
    if n > 2:
      for i in range(n-2):
        if listy[i+2]==0:
          ans=ans
        else:
          ans=gcd(ans,listy[i+2])
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,x = (int(i) for i in input().split())
listx=[int(i) for i in input().split()]
#print(n,x,listx)
listy=[abs(listx[i]-x) for i in range(n)]
listy.sort()
#print(listy)

def gcd(y, x):
    if x == 0:
        return y
    else:
        return gcd(x, y % x) #再帰定義
if x==1:
  ans=listy[0]
else:
  ans=gcd(listy[0],listy[1])
  if n > 2:
    for i in range(n-2):
      ans=gcd(ans,listy[i+2])
  
print(ans)
Problem p03280 (python)

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

Buggy submission (verdict: Runtime Error):
a,b=input().split()
print((int(a)-1)*(int(b)-))
Problem p03284 (python)

Fixed submission:
n,k=input().split()
if int(n)%int(k)==0:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
n,k=input().split()
if n%k==0:
  print(0)
else:
  print(1)
Problem p03288 (python)

Fixed submission:
r=int(input())

name=('ABC', 'ARC', 'AGC')
if r<1200:
  print(name[0])
elif 1200<=r<2800:
  print(name[1])
else:
  print(name[2])

Buggy submission (verdict: Runtime Error):
r=int(input())
data=(1200,2800)
name=('ABC', 'ARC', 'AGC')

z=[name[0] if r < 1200 else name[1] if 1200 <= r < 2800 else name(2) if 2800 <= r else i for i in range(1)]
print(z[0])

Buggy submission (verdict: Runtime Error):
r=int(input())
data=(1200,2800)
name=('ABC', 'ARC', 'AGC')
z=[name[0] if r < data[0] else name[1] if data[0] <= r < data[1] else name(2) if data[1] <= r else i for i in range(1)]
print(z[0])

Buggy submission (verdict: Runtime Error):
r=int(input())
data=(1200,2800)
name=('ABC', 'ARC', 'AGC')
if r<data[1]:
  print(name[0])
elif data[1]<=r<data[2]:
  print(name[1])
else:
  print(name[2])

Buggy submission (verdict: Runtime Error):
r=int(input())
data1=1200
dara2=2800
name=('ABC', 'ARC', 'AGC')
if r<data1:
  print(name[0])
elif data1<=r<data2:
  print(name[1])
else:
  print(name[2])
Problem p03323 (python)

Fixed submission:
a,b = input().split()
#print(a)
#print(b)

if int(a)>8 or int(b)>8:
    print(':(')
else:
    print('Yay!')

Buggy submission (verdict: Runtime Error):
a,b = input().split()
#print(a)
#print(b)

if a>8 or b>8:
    print(':(')
else:
    print('Yay!')

Buggy submission (verdict: Runtime Error):
a,b = input().split()
#print(a)
#print(b)

if a>8 or b>8:
    print(':(')
else:
  print('Yay!')
Problem p03337 (python)

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b)

print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())
print(a+b,a-b,a*b)

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())

print(max(a+b,a-b,a*b))
Problem p03355 (python)

Fixed submission:
from collections import deque
s=input()
length=len(s)

K=int(input())
#print(s,K)

left=0
right=0
#ss=s[left:right]
#print(ss)

ss=deque()
for left in range(length+1):
    for right in range(left+1,length+1):
      if len(s[left:right]) <= K:
        ss.append(s[left:right])

myset=set(ss)
for i in range(K):
    tmp=min(myset)
    myset.remove(tmp)
print(tmp)

Buggy submission (verdict: Runtime Error):
from collections import deque
s=input()
length=len(s)

K=int(input())
#print(s,K)

left=0
right=0
#ss=s[left:right]
#print(ss)

ss=deque()
for left in range(length+1):
    for right in range(left+1,length+1):
      if right-left+1 <= K:
        ss.append(s[left:right])

myset=set(ss)
for i in range(K):
    tmp=min(myset)
    myset.remove(tmp)
print(tmp)

Buggy submission (verdict: Runtime Error):
from collections import deque
s=input()
length=len(s)

K=int(input())
#print(s,K)

left=0
right=0
#ss=s[left:right]
#print(ss)

ss=deque()
for left in range(length+1):
    for right in range(left+1,length+1):
        ss.append(s[left:right])

myset=set(ss)
for i in range(k):
    tmp=min(myset)
    myset.remove(tmp)
print(tmp)
Problem p03455 (python)

Fixed submission:
a,b=[int(i) for i in input().split()]
print('Odd' if a*b%2==1 else 'Even')

Buggy submission (verdict: Runtime Error):
a,b=[int(i) for i in imput().split()]
print('Odd' if a*b%2==1 else 'Even')
Problem p03544 (python)

Fixed submission:
n=int(input())

l=[2,1]
for i in range(2,87):
  l.append(l[i-1]+l[i-2])

print(l[n])

Buggy submission (verdict: Runtime Error):
n=int(input())

l=[2,1]
for i in range(2,86):
  l.append(l[i-1]+l[i-2])

print(l[n])
Problem p03565 (python)

Fixed submission:
s=input()
t=input()
#print(s,t)

if len(s) < len(t):
    print('UNRESTORABLE') 
elif len(s) == len(t):
  cnt=0
  for i in range(len(s)):
    if s[i] == t[i]:
      cnt+=1
    elif s[i] == '?':
      cnt+=1
  if len(t)==cnt:
    print(t)
  else:
    print('UNRESTORABLE') 
else:
  flag1=0
  for j in range(len(s)-len(t),-1,-1):
    cnt=0
    for i in range(len(t)):
      if s[i+j]==t[i]:
        cnt+=1
      elif s[i+j]=='?':
        cnt+=1
    if cnt==len(t):
      flag1=1
      if j==0:
        s=t+s[len(t):]
      if 0 < j < len(s)-len(t)+1:
        s=s[0:j]+t+s[j+len(t):]
      if j == len(s)-len(t)+1:
        s=s[0:j]+t      
      s=s.replace('?','a')
      print(s)
    
  if flag1==0:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
#print(s,t)

if len(s) < len(t):
    print('UNRESTORABLE') 
elif len(s) == len(t):
  cnt=0
  for i in range(len(s)):
    if s[i] == t[i]:
      cnt+=1
    elif s[i] == '?':
      cnt+=1
  if len(t)==cnt:
    print(t)
  else:
    print('UNRESTORABLE') 
else:
  flag1=0
  for j in range(len(s)):
    cnt=0
    for i in range(len(t)):
      if s[i+j]==t[i]:
        cnt+=1
      elif s[i+j]=='?':
        cnt+=1
    if cnt==len(t):
      flag1=1
      if j==0:
        s=t+s[len(t):]
      if 0 < j < len(s)-len(t)+1:
        s=s[0:j]+t+s[j+len(t):]
      if j == len(s)-len(t)+1:
        s=s[0:j]+t      
      s=s.replace('?','a')
      print(s)
    
  if flag1==0:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
#import re

s=input()
t=input()
#print(s,t)

flag1=0
for j in range(len(s)-len(t)+1):
  flag=0
  for i in range(len(t)):
    if s[i+j]=='?' or s[i+j]==t[i]:
      flag+=1
  if flag==len(t):
    flag1=1
    s=s[0:j]+t[j-2:j+len(t)-2]+s[j+len(t):]
    s=s.replace('?','a')
    print(s)
    
if flag1==0:
  print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
#import re

s=input()
t=input()
#print(s,t)

flag1=0
for j in range(len(s)-len(t)+1):
  flag=0
  for i in range(len(t)):
    if s[i+j]=='?' or s[i+j]==t[i]:
      flag+=1
  if flag==len(t):
    flag1=1
    s=s[0:j]+t[j-1:j+len(t)]+s[j+len(t):]
    s=s.replace('?','a')
    print(s)
    
if flag1==0:
  print('UNRESTORABLE')
Problem p03583 (python)

Fixed submission:
N=int(input())

flag=0
for h in range(1,3501):
  for n in range(h,3501):
    if flag==0:
      val=4*h*n-n*N-h*N
      if val != 0:
        w=N*h*n/val
        if int(w)==w and w > 0:
          print(h,n,int(w))
          flag=1

Buggy submission (verdict: Runtime Error):
N=int(input())

flag=0
for h in range(1,3501):
  if flag==1:
      break:  
  for n in range(h,3501):
    if flag==1:
      break:
    else:
      val=4*h*n-n*N-h*N
      if val != 0:
        w=N*h*n/val
        if int(w)==w and w > 0:
          print(h,n,int(w))
          flag=1
Problem p03597 (python)

Fixed submission:
n = int(input())
a = int(input())

print(n*n-a)

Buggy submission (verdict: Runtime Error):
A, B, C, D, E, F= (int(i) for i in input().split())

dens=0
for a in range(30+1):
  for b in range(30+1):
    waterA=100*a*A
    waterAB=waterA+100*b*B
    if  waterA<= F and 0 < waterAB <= F:
      for c in range(100+1):
        for d in range(100+1):
          if waterAB+c*C+d*D <= F:
            if c*C+d*D <= (a*A+b*B)*E:
              if dens < (c*C+d*D)/(waterAB+c*C+d*D):
                dens=(c*C+d*D)/(waterAB+c*C+d*D)
                max=waterAB+c*C+d*D
              
print(max,int(max*dens))
Problem p03609 (python)

Fixed submission:
x, t= (int(i) for i in input().split())
print(x-t if x > t else 0)

Buggy submission (verdict: Runtime Error):
#import sys
#input = sys.stdin.readline
n=int(input())
a=[int(i) for i in input().split()]
maxa=max(a)

#print(a)
ans=0
if n==1:
  ans=1
else:
  for i in range(1,maxa+1):
    cnt=0
    for j in range(len(a)):
      if a[j]==i or a[j]==i-1 or a[j]==i+1:
        cnt+=1
      if ans <= cnt:
        ans = cnt

print(ans)
Problem p03625 (python)

Fixed submission:
from collections import Counter
n=int(input())
data=[int(aa) for aa in input().split()]

dct=Counter(data)
dct=dct.items()

dct2=[item for item in dct if item[1] > 1]
dct2.sort(reverse=True)

dct4=[item for item in dct if item[1] > 3]
dct4.sort(reverse=True)

ans=0
if len(dct2) > 1:
  ans=dct2[0][0]*dct2[1][0]
if len(dct4) > 0: 
  ans=max(ans,dct4[0][0]*dct4[0][0])

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
data=[int(aa) for aa in input().split()]
d=[0 for aa in range(100010+1)]
for aa in data:
    d[aa]+=1
#print(d)
mylist=[0,0]
ans1=0
for aa in range(100010+1):
    if d[aa] >3 and ans1 < aa:
        ans1=aa
    if d[aa] >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)

print(max(ans1*ans1,mylist[0]*mylist[1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
data=[int(aa) for aa in input().split()]
d=[0 for aa in range(100000+1)]
for aa in data:
    d[aa]+=1
#print(d)
mydata=0
mylist=[0,0]
for aa in range(100000+1):
    if d[aa] >3:
        mydata=aa
    if d[aa] >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)
 
print(max(mydata*mydata,mylist[0]*mylist[1]))
n=int(input())
data=[int(aa) for aa in input().split()]
d=[0 for aa in range(100000+1)]
for aa in data:
    d[aa]+=1
#print(d)
mydata=0
mylist=[0,0]
for aa in range(100000+1):
    if d[aa] >3:
        mydata=aa
    if d[aa] >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)

print(max(mydata*mydata,mylist[0]*mylist[1]))

Buggy submission (verdict: Runtime Error):
n=int(input())
data=[int(aa) for aa in input().split()]
d=[0 for aa in range(100000+1)]
for aa in data:
    d[aa]+=1
#print(d)
mydata=0
mylist=[0,0]
for aa in range(100000+1):
    if d[aa] >3:
        mydata=aa
    if d[aa] >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)

print(max(mydata*mydata,mylist[0]*mylist[1]))
Problem p03633 (python)

Fixed submission:
import fractions
n=int(input())

ans=1
for i in range(n):
  x=int(input())
  ans=ans//fractions.gcd(ans,x)*x

print(int(ans))

Buggy submission (verdict: Runtime Error):
#標準入力の読み込み
n=int(input())
x=[int(input()) for i in range(n)]
x.sort(reverse=True)
n=len(x)

#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


if n==1:
    ans=x[0]
else:
    element = x[0]/gcd(x[0], x[1])*x[1]
    if n==2:ans=element
    else:
        for i in range(2,n):
            element=element/gcd(element,x[i])*x[i]
        ans=element
print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
t=[int(input()) for i in range(n)]
#print(n,t)
t.sort(reverse=True)

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
        
if n==1:
  ans=t
elif n==2:
  ans=t[0]/gcd(t[0],t[1])*t[1]
else:
  tmp=t[0]/gcd(t[0],t[1])*t[1]
  n=2
  while n < len(t):
    tmp=tmp/gcd(tmp,t[n])*t[n]
    n+=1  
  ans=tmp
  
print(int(ans))

Buggy submission (verdict: Runtime Error):
#標準入力の読み込み
n=int(input())
x=[int(input()) for i in range(n)]
x.sort(reverse=True)
n=len(x)

#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


if n==1:
    ans=x[0]
else:
    element = x[0]*x[1]/gcd(x[0], x[1])
    if n==2:ans=element
    else:
        for i in range(2,n):
            element=element*x[i]/gcd(element,x[i])
        ans=element
print(int(ans))

Buggy submission (verdict: Runtime Error):
#標準入力の読み込み
n=int(input())
x=[int(input()) for i in range(n)]
n=len(x)

#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


if n==1:
    ans=x[0]
else:
    element = x[0]*x[1]/gcd(x[0], x[1])
    if n==2:ans=element
    else:
        for i in range(2,n):
            element=element*x[i]/gcd(element,x[i])
        ans=element
print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
t=[int(input()) for i in range(n)]
#print(n,t)
t.sort(reverse=True)

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
        
if n==1:
  ans=t[0]
elif n==2:
  ans=t[0]*t[1]/gcd(t[0],t[1])
else:
  tmp=t[0]*t[1]/gcd(t[0],t[1])
  n=2
  while n < len(t):
    tmp=tmp*t[n]/gcd(tmp,t[n])
    n+=1  
  ans=tmp
  
print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
t=[int(input()) for i in range(n)]
#print(n,t)
t.sort(reverse=True)

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
        
if n==1:
  ans=t
elif n==2:
  ans=t[0]*t[1]/gcd(t[0],t[1])
else:
  tmp=t[0]*t[1]/gcd(t[0],t[1])
  n=2
  while n < len(t):
    tmp=tmp*t[n]/gcd(tmp,t[n])
    n+=1  
  ans=tmp
  
print(int(ans))
Problem p03699 (python)

Fixed submission:
n=int(input())
s=[int(input()) for i in range(n)]
#print(n,s)
t=[[float('-inf') for i in range(10000+1)] for i in range(n+1)]

t[0][0]=0
for j in range(1,n+1):
    t[j]=t[j-1]
    tmp=[]
    for i in range(10000+1):
        if t[j-1][i]>=0:
            tmp.append(t[j-1][i])
    for i in tmp:
        t[j][i+s[j-1]]=i+s[j-1]

for i in range(len(t[n])):
    if t[n][i]%10==0:
        t[n][i]=0

print(max(t[n]))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[int(input()) for i in range(n)]
#print(n,s)

dp=[float('-inf') for i in range(10000+1)]
#print(dp)

dp[0]=0
k=0
for j in range(n):
    k+=s[j]
    for i in range(k):
        dp[i+k]=dp[i]+s[j]
#print(dp)

for i in range(len(dp)):
    if dp[i]%10==0:
        dp[i]=0
        
print(max(dp))
Problem p03738 (python)

Fixed submission:
a=input()
b=input()

flag=0

if len(a)==1 and len(b)==1:
  if int(b) < int(a):
    print('GREATER')
    flag=1
  elif int(b) > int(a):
    print('LESS')
    flag=1
  else:
    print('EQUAL')
    flag=1
    
if len(a)==1 and len(b) > 1:
    print('LESS')
    flag=1
    
if len(a) > 1 and len(b)==1:
    print('GREATER')
    flag=1

if len(b) < len(a) and flag==0:
  print('GREATER')
  flag=1
if len(b) > len(a) and flag==0:
  print('LESS')
  flag=1

  
if len(a)==len(b):  
  for i in range(len(a)):
    if b[i] < a[i] and flag==0:
      print('GREATER')
      flag=1
    elif b[i] > a[i] and flag==0:
      print('LESS')
      flag=1
    
if flag==0:
  print('EQUAL')

Buggy submission (verdict: Runtime Error):
a=input()
b=input()

flag=0
if len(b) < len(a):
  print('GREATER')
  flag=1
if len(b) > len(a):
  print('LESS')
  flag=1

for i in range(len(a)):
  if b[i] < a[i] and flag==0:
    print('GREATER')
    flag=1
  elif b[i] > a[i] and flag==0:
    print('LESS')
    flag=1
    
if flag==0:
  print('EQUAL')