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

Fixed submission:
k,x=map(int,input().split())
for i in range(k):
	print(x+i-k+1,end=" ")
if k != 1:
	print("",end="")
	for s in range(k)[1:]:
		print(x+s,end=" ")

Buggy submission (verdict: Runtime Error):
ko,x=map(int,input().split())
s=max(x-ko+1,-1000000)
while True:
  print(s,end=" ")
  s+=1
  if s>min(ko+k-1,1000000):break

Buggy submission (verdict: Runtime Error):
ko,x=map(int,input().split())
s=max(x-ko+1,-1000000)
while True:
  print(s,end==" ")
  s+=1
  if s>min(ko+k-1,1000000):break

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
for i in range(k):
	print(x+i-k+1,end="")
if k != 1:
	print(" ",end="")
	for s in range(k)[1:]:
    	print(x+s,end="")

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
for i in range(k)
	print(x+i-k+1,end="")
if k != 1:
	print(" ",end="")
	for s in range(k)[1:]
    	print(x+s,end="")

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
for i in range(k)
	print(x+i-k+1,end="")
if k!=1:
	print(" ",end="")
	for i in range(k)[1:]
    	print(x+i,end="")

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
for i in range(k)
	print(x+i-k+1,end="")
if k!=i:
	print(" ",end="")
	for i in range(k)[1:]
    	print(x+i,end="")
Problem p02947 (python)

Fixed submission:
from collections import Counter as co
from operator import mul
from functools import reduce

def combinations_count(n, r):
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer//denom


n=int(input())
a=0
l=[''.join(list(map(str,sum(sorted(list(map(list,co(input()).items()))),[])))) for i in range(n)]
for d,s in co(l).items():
  if s>=2:a+=combinations_count(s, 2)
print(a)

Buggy submission (verdict: Runtime Error):
from collections import Counter as co
from itertools import combinations as com
from operator import mul
from functools import reduce

def combinations_count(n, r):
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer//denom

n=int(input())
a=0
l=co([set(co(input())) for i in range(n)])
for d,s in l.items():
  if d>=2:a+=combinations_count(d, 2)
print(a)

Buggy submission (verdict: Runtime Error):
from collections import Counter as co
from itertools import combinations as com
from operator import mul
from functools import reduce

def combinations_count(n, r):
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer//denom

n=int(input())
a=0
l=co([set(co(input())) for i in range(n)])
for d,s in l.items():
  if s>=2:a+=combinations_count(s, 2)
print(a)

Buggy submission (verdict: Runtime Error):
from collections import Counter as co
from itertools import combinations as com
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

n=int(input())
a=0
l=co([set(co(input())) for i in range(n)])
for d,s in l.items():
  if s>=2:a+=combinations_count(s, 2)
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[input() for j in range(n)]
for i in range(n)[:-1]:
	f=l[i]
	for s in range(n)[i1:]:
    	if s != i:
			a=[f[k] for k in range(10)]
            g=l[s]
            b=[g[c] for c in range(10)]
            q +=1 if sorted(a)==sorted(b)
print(q)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[input() for j in range(n)]
for i in range(n)[:-1]:
	f=l[i]
	for s in range(n)[i+1:]:
		a=[f[k] for k in range(10)]
        g=l[s]
        b=[g[c] for c in range(10)]
        q +=1 if sorted(a)==sorted(b)
print(q)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list()
q=0
for k in range(n):
	st=input()
    l.append(st)
for i in range(n)[:-1]:
	f=l[i]
	for s in range(n)[i+1:]:
		a=[f[k] for k in range(10)]
        g=l[s]
        b=[g[c] for c in range(10)]
        q +=1 if sorted(a)==sorted(b)
print(q)

Buggy submission (verdict: Runtime Error):
n=input()
l=list()
q=0
for k in range(n):
	st=input()
    l.append(st)
for i in range(n)[:-1]:
	f=l[i]
	for s in range(n)[i+1:]:
		a=[f[k] for k in range(10)]
        g=l[s]
        b=[g[c] for c in range(10)]
        q +=1 if sorted(a)==sorted(b)
print(q)
Problem p02953 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
before=l[0];d=0
for i in range(n):
  if before-l[i]>1:print('No');exit()
  elif before-l[i]==1:
    if d:print("No");exit()
    else:d+=1
  elif before-l[i]==0:continue
  else:d=0
  before=l[i]
print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
before=l[0]
for i in l:
  if before-i>1:print('No');exit()
  elif before-i==1:
print("Yes")
Problem p02957 (python)

Fixed submission:
a,s=map(int,input().split())
if a%2==s%2:
  print((a+s)//2)
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
a,s=map(int,input().split())
if a%2==b%2:
  print((a+s)//2)
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
a,s=map(int,input().split())
if a%2==b%2:
  print((a+s)//2)
alse:
  print("IMPOSSIBLE")
Problem p02969 (python)

Fixed submission:
print(3*(int(input())**2))

Buggy submission (verdict: Runtime Error):
print(3*(int(input()**2))
Problem p02975 (python)

Fixed submission:
n=int(input())
l=sorted(list(map(int,input().split())))
if len(set(l))==3:
  h=sorted(list(set(l)),reverse=1)
  ff=len(bin(h[0]))
  p=["0"*(ff-len(bin(s)))+bin(s)[2:] for s in h]
  y=p[0]
  dfg,dgf=p[1],p[2]
  for i in range(ff-2):
    q,w=dfg[i],dgf[i]
    if (q!=w and y[i]=="0") or (q==w and y[i]=="1"):print("No");exit()
  else:
    from collections import Counter as cou
    if len(set(cou(l).values()))==1:print("Yes")
    else:print("No")
elif len(set(l))>=4 or 0 not in set(l):
  print("No")
elif set(l)==set([0]):
  print("Yes")
else:
  if n%3:print("No");exit()
  from collections import Counter as cou
  fl,fll=0,0
  for g,gh in cou(l).items():
    if g==0 and gh==n//3:fl=1
    if g!=0 and gh==2*n//3:fll=1
  print("Yes" if fl and fll else "No")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=sorted(list(map(int,input().split())))
if len(set(l))==3:
  h=sorted(list(set(l)),reverse=1)
  ff=len(bin(h[0]))
  p=["0"*(ff-len(bin(s)))+bin(s)[2:] for s in h]
  y=p[0]
  dfg,dgf=p[1],p[2]
  for i in range(ff-2):
    q,w=dfg[i],dgf[i]
    if (q!=w and y[i]=="0") or (q==w and y[i]=="1"):print("No");exit()
  else:
    from collections import Counter as cou
    if len(set(cou(l).values()))==1:print("Yes")
    else:print("No")
elif len(set(l))>=4 or 0 not in set(l):
  print("No")
elif set(l)==set([0]):
  print("Yes")
else:
  if n%3:print("No");exit()
  from collections import Counter as cou
  fl,fll=0,0
  for g,gh in cou(l).items():
    if g==0 and gh==n//3:fl=1
    if g!=0 and gh==2*n//3:fll=1
  print("Yes" if fl and fll else "No"))
Problem p02988 (python)

Fixed submission:
n=int(input())
ans=0
l=list(map(int,input().split()))
for i in range(1,n-1):
  p=max(l[i-1],l[i+1])
  q=min(l[i-1],l[i+1])
  if q<=l[i]<=p:ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(1,n-1):
  p=max(l[i-1],l[i+1])
  q=min(l[i-1],l[i+1])
  if q<=l[i]<=p:ans+=1
print(ans)
Problem p02991 (python)

Fixed submission:
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
edges=[[] for i in range(3+3*n)]
o=inputs()
s,T=map(int,o.pop().split())
for i in o:
    _,__=map(int,i.split())
    _*=3;__*=3
    edges[_].append(__+1)
    edges[_+1].append(__+2)
    edges[_+2].append(__)

from collections import deque
dq=deque([])
dq.append((3*s,0))
T*=3
seen=[0]*(3*n+3)
seen[3*s]=1
while dq:
    now,c=dq.popleft()
    if now==T :print(c//3);exit()
    for t in edges[now]:
        if seen[t]==0:
            dq.append((t,c+1))
            seen[t]=1
print("-1")

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
edges=[[] for i in range(3+3*n)]
o=inputs()
s,T=map(int,o.pop().split())
for i in o:
    _,__=map(int,input().split())
    _*=3;__*=3
    edges[_].append(__+1)
    edges[_+1].append(__+2)
    edges[_+2].append(__)

from collections import deque
dq=deque([])
dq.append((3*s,0))
T*=3
seen=[0]*(3*n+3)
seen[3*s]=1
while dq:
    now,c=dq.popleft()
    if now==T :print(c//3);exit()
    for t in edges[now]:
        if seen[t]==0:
            dq.append((t,c+1))
            seen[t]=1
print("-1")
Problem p02996 (python)

Fixed submission:
n=int(input())
l=sorted([list(map(int,input().split())) for nd in range(n)],key=lambda x: x[1])
now=0
for a,s in l:
  if a+now>s:print("No");exit()
  now+=a
else:print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=sorted(list(map(int,input().split())) for nd in range(n),key=lambda x:x[1])
now=0
for a,s in l:
  if a+now>s:print("No");exit()
  now+=a
else:print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(inuput())
l=sorted(list(map(int,input().split())) for nd in range(n),key=lambda x:x[1])
now=0
for a,s in l:
  if a+now>s:print("No");exit()
  now+=a
else:print("Yes")
Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())
p=w*h/2
a=1 if 2*x==w and 2*y==h else 0
print(p,a)

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
p=w*h/2
a=1 if w/h==x/y else 0
print(p,a)
Problem p03006 (python)

Fixed submission:
ans=float("INF")
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
if n==1:print(1);exit()
for i in range(n):
    for j in range(n):
        if i==j:continue
        p,q=l[i][0]-l[j][0],l[i][1]-l[j][1]
        ret=0
        pre=sorted(l,reverse=1,key=lambda x:p*x[0]+q*x[1])
        while pre:
            ret+=1
            x,y=pre.pop()
            while  [x+p,y+q] in pre:
                pre.remove([x+p,y+q])
                x,y=[x+p,y+q]
        ans=min(ans,ret)
print(ans)

Buggy submission (verdict: Runtime Error):
ans=float("INF")
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
if n==1:print(1);exit()
for i in range(n):
    for j in range(n):
        if i==j:continue
        p,q=l[i][0]-l[j][0],l[i][1]-l[j][1]
        ret=0
        pre=sorted(l,reverse=1,key=lambda x:p*x[0]+q*x[1])
        while pre:
            ret+=1
            x,y=pre.pop()
            while  [x+p,y+q] in pre:
                pre.remove([x+p,y+q])
                x,y=[x+p,y+q]
        ans=min(ans,ret)
print(ans)ans=float("INF")
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
if n==1:print(1);exit()
for i in range(n):
    for j in range(n):
        if i==j:continue
        p,q=l[i][0]-l[j][0],l[i][1]-l[j][1]
        ret=0
        pre=sorted(l,reverse=1,key=lambda x:p*x[0]+q*x[1])
        while pre:
            ret+=1
            x,y=pre.pop()
            while  [x+p,y+q] in pre:
                pre.remove([x+p,y+q])
                x,y=[x+p,y+q]
        ans=min(ans,ret)
print(ans)ans=float("INF")
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
if n==1:print(1);exit()
for i in range(n):
    for j in range(n):
        if i==j:continue
        p,q=l[i][0]-l[j][0],l[i][1]-l[j][1]
        ret=0
        pre=sorted(l,reverse=1,key=lambda x:p*x[0]+q*x[1])
        while pre:
            ret+=1
            x,y=pre.pop()
            while  [x+p,y+q] in pre:
                pre.remove([x+p,y+q])
                x,y=[x+p,y+q]
        ans=min(ans,ret)
print(ans)
Problem p03007 (python)

Fixed submission:
n=int(input())
p,m=[],[]
z=0
for i in list(map(int,input().split())):
    if i<0:m.append(i)
    elif i==0:
        z+=1
    else:p.append(i)
if p and m:
    print(sum(p)-sum(m))
    if z:
        for h in range(z-1):
            print("0 0")
        now=0
    else:now=p.pop()
    for j in m[1:]:
        print(now,j)
        now-=j
    if p:
        print(m[0],now)
        now=-now+m[0]
        for j in p[1:]:
            print(now,j)
            now-=j
        print(p[0],now)
    else:
        print(now,m[0])
elif p:
    if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now)
else:
    if z:
        print(-sum(m))
        for h in  range(z-1):
            print("0 0")
        now=0
    else:
        m.sort()
        print(-sum(m)+2*max(m))
        now=m.pop()
    for i in m:
        print(now,i)
        now-=i

Buggy submission (verdict: Runtime Error):
n=int(input())
p,m=[],[]
z=0
for i in list(map(int,input().split())):
    if i<0:m.append(i)
    elif i==0:
        z+=1
    else:p.append(i)
if p and m:
    print(sum(p)-sum(m))
    if z:
        for h in range(z-1):
            print("0 0")
        now=0
    else:now=p.pop()
    for j in m[1:]:
        print(now,j)
        now-=j
    print(m[0],now)
    now=-now+m[0]
    for j in p[1:]:
        print(now,j)
        now-=j
    print(p[0],now)
elif p:
    if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now)
else:
    if z:
        print(-sum(m))
        for h in  range(z-1):
            print("0 0")
        now=0
    else:
        m.sort()
        print(-sum(m)+2*max(m))
        now=m.pop()
    for i in p:
        print(now,i)
        now-=i
Problem p03044 (python)

Fixed submission:
n=int(input())
edges=[[] for i in range(n)]
import sys

sys.setrecursionlimit(10**9)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
edges=[[] for i in range(n)]
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
edges=[[] for i in range(n)]
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
edges=[[] for i in range(n)]
import sys

sys.setrecursionlimit(10**10)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
edges=[[] for i in range(n)]
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
edges=[[] for i in range(n)]
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy submission (verdict: Runtime Error):
n=int(input())
edges=[[] for i in range(n)]
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")
Problem p03062 (python)

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

    # 要素の絶対値
B = list(map(abs, A))

    # 負の要素の個数
C = [a for a in A if a < 0]
if len(C) % 2 == 0:
  print(sum(B))
else:
        # 最小値を負として計算する
  print(sum(B) - min(B)*2)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
d=l.copy()
ans=-float("INF")
for i in range(1,n-1):
    if 0>=d[i]+d[i+1]:
        if d[i]<0:
            d[i]*=-1
            d[i+1]*=-1
        

ans=max(ans,sum(d))
l[0]*=-1
l[1]*=-1
for i in range(1,n-1):
    if 0>=l[i]+l[i+1]:
        if l[i]<0:
            l[i]*=-1
            l[i+1]*=-1
print(max(ans,sum(l)))
Problem p03085 (python)

Fixed submission:
print({"A":"T","T":"A","G":"C","C":"G"}[input()])

Buggy submission (verdict: Runtime Error):
print(input().lower().replace("a","T").replace("t","A")replace("c","G")replace("g","C"))
Problem p03125 (python)

Fixed submission:
a,s=map(int,input().split())
if s%a:
  print(s-a)
else:
  print(a+s)

Buggy submission (verdict: Runtime Error):
a,s=map(int,input().spit())
if s%a:
  print(s-a)
else:
  print(a+s)
Problem p03128 (python)

Fixed submission:
n,m=map(int,input().split())
from collections import defaultdict
a=list(map(int,input().split()))
dic={i:[2,5,5,4,5,6,3,7,6][i-1]for i in range(1,10)}
s={}
for i in a:
    if dic[i] in s:
        s[dic[i]]=max(s[dic[i]],i)
    else:
        s[dic[i]]=i
ok=list(s.items())#hon,digit
dp=[-float('inf')]*(n+1)
dp[0]=0
for i in range(1,n+1):
    for h,d in ok:
        if h<=i:
            dp[i]=max(dp[i],dp[i-h]+1)
from operator import itemgetter as it 
ok.sort(reverse=1,key=it(1))
ans=''
now=n
keta=dp[n]
while keta>1:
    for h,d in ok:
        if now>h and dp[now]==dp[now-h]+1:
            ans+=str(d);now-=h;keta-=1;break
print(ans+str(s[now]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
from collections import defaultdict
a=list(map(int,input().split()))
dic={i:[2,5,5,4,5,6,3,7,6][i-1]for i in range(1,10)}
s={}
for i in a:
    if dic[i] in s:
        s[dic[i]]=max(s[dic[i]],i)
    else:
        s[dic[i]]=i
ok=list(s.items())#hon,digit
dp=[0]*(n+1)
for i in range(1,n+1):
    for h,d in ok:
        if h<=i:
            dp[i]=max(dp[i],dp[i-h]+1)
from operator import itemgetter as it 
ok.sort(reverse=1,key=it(1))
ans=''
now=n
keta=dp[n]
while keta>1:
    for h,d in ok:
        if now>h and dp[now]==dp[now-h]+1:
            ans+=str(d);now-=h;keta-=1;break
print(ans+str(s[now]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
from collections import defaultdict
a=list(map(int,input().split()))
dic={i:[2,5,5,4,5,6,3,7,6][i-1]for i in range(1,10)}
s={}
for i in a:
    if dic[i] in s:
        s[dic[i]]=max(s[dic[i]],i)
    else:
        s[dic[i]]=i
ok=list(s.items())#hon,digit
dp=defaultdict(int)
for i in range(1,n+1):
    for h,d in ok:
        if h<=i:
            dp[i]=max(dp[i],dp[i-h]+1)
from operator import itemgetter as it 
ok.sort(reverse=1,key=it(1))
ans=''
now=n
keta=dp[n]
while keta>1:
    for h,d in ok:
        if now>h and dp[now]==dp[now-h]+1:
            ans+=str(d);now-=h;keta-=1;break
print(ans+str(s[now]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
from collections import defaultdict
a=list(map(int,input().split()))
dic={i:[2,5,5,4,5,6,3,7,6][i-1]for i in range(1,10)}
s={}
for i in a:
    if dic[i] in s:
        s[dic[i]]=max(s[dic[i]],i)
    else:
        s[dic[i]]=i
ok=list(s.items())#hon,digit
dp=defaultdict(int)
for i in range(1,n+1):
    for h,d in ok:
        if h<=i:
            dp[i]=max(dp[i],dp[i-h]+1)
from operator import itemgetter as it 
ok.sort(reverse=1,key=it(1))
ans=''
now=n
keta=dp[n]
while keta>1:
    for h,d in ok:
        if now>=h and dp[now]==dp[now-h]+1:
            ans+=str(d);now-=h;keta-=1;break
print(ans+str(s[now]))
Problem p03130 (python)

Fixed submission:
l=[list(map(int,input().split()))for i in range(3)]
from itertools import permutations as pe
for i in pe(l,r=None):
    #rは長さ、Noneでiteraterの長さ
    for j in range(2):
        now=i[0][j]
        seen=set([now])
        for a,b in i:

            if b!=now and now!=a:break
            now=b+a-now
            seen.add(now)
        else:
            if len(seen)==4:print('YES');exit()

print("NO")

Buggy submission (verdict: Runtime Error):
print('YNEOS'[len({*map(int,input().split())for i in range(3)})!=4::2])
Problem p03161 (python)

Fixed submission:
n,k=map(int,input().split())
dp=[10**10]*n
h=list(map(int,input().split()))
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,1+min(k,i)))

print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
dp=[10**4*n]*n
l=list(map(int,input().split()))
dp[0]=0
for i in range(n):
  dp[i]=min(dp[j]+abs(l[j]-l[i]) for j in range(min(i,k)))
print(dp[-1])
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000000000)
n,m=map(int,input().split())
v=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  v[a-1].append(b-1)

memo=[-1]*n
def dp(x):
  if memo[x]!=-1:return memo[x]
  r=0
  for i in v[x]:
    r=max(r,dp(i)+1)
  memo[x]=r
  return r
print(max(dp(i) for i in range(n)))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
v=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  v[a-1].append(b-1)

memo=[-1]*n
def dp(x):
  if memo[x]!=-1:return memo[x]
  r=0
  for i in v[x]:
    r=max(r,dp(i)+1)
  memo[x]=r
  return r
print(max(dp(i) for i in range(n)))
Problem p03206 (python)

Fixed submission:
print("Christmas", *["Eve"]*(25-int(input())))

Buggy submission (verdict: Runtime Error):
print("Christmas", "Eve"*(25-int(input()))
Problem p03210 (python)

Fixed submission:
print("YES"if input()in"357"else"NO")

Buggy submission (verdict: Runtime Error):
print("YNEOS"[1-input()in"357"::2])

Buggy submission (verdict: Runtime Error):
print("YES"if input()in"357"else"NO")
print("YNEOS"[1-input()in"357"::2])
Problem p03231 (python)

Fixed submission:
a,s=map(int,input().split())
sa,ss=[input() for i in range(2)]
if a<s:
    a,s=s,a
    sa,ss=ss,sa
from fractions import gcd
g=gcd(a,s)
x,y=a//g,s//g
for i in range(g):
    if sa[x*i]!=ss[y*i]:print(-1);break
else:print(x*s)

Buggy submission (verdict: Runtime Error):
a,s=map(int,input().split())
sa,ss=[input() for i in range(2)]
if a<s:
    a,s=s,a
    sa,ss=ss,sa
from math import gcd
g=gcd(a,s)
x,y=a//g,s//g
for i in range(1,s//x):
    if sa[y*i]!=ss[x*i]:print(-1);break
else:print(x*s)
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:print("Hello World")
else:
    a,s=int(input()),int(input())
    print(a+s)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==1:print("Hello world")
else:
    a,s=map(int,input().split())
    print(a+s)
Problem p03241 (python)

Fixed submission:
n,m=map(int,input().split())
ans=1
ps=[]
for i in range(1,int(m**(1/2))+1):
    if m%i:continue
    if n*(i)<=m:ans=max(i,ans)
    if n*(m//i)<=m:ans=max(ans,m//i)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=1
for i in range(1,int(m**(1/2))+1):
    if m%i==0:
        if i>=n:ans=max(m//i*,ans)
        if m//i>=n:
            ans=max(i,ans)
print(ans)