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

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

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
dp[2]=min(abs(h[1]-h[0]),abs(h[2]-h[0]))
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
dp[2]=min(abs(h[1]-h[0]),abs(h[2]-h[0]))
for i in range(3,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])
Problem p03086 (python)

Fixed submission:
a = input()

part = ""
s = ["A","C","G","T"]
ans = [""]

for i in a:
    
    if  i  in s:
        part += i
    else:
        part = ""
    ans.append(part)
ans = [len(i) for i in ans]
print(max(ans))

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


a = input()

part = ""
s = ["A","C","G","T"]
ans = []

for i in a:
    if  i not in s:
        ans.append(part)
        part = ""
    else:
        part += i


print(len(max(ans)))
Problem p03087 (python)

Fixed submission:
n,q = [int(i) for i in input().split()]
s = input()
cumsum = [0]*n
ans = 0
flag = False

for i in range(n):
    if flag:
        if s[i] == "C":
            ans += 1

    cumsum[i] = ans     

    flag = False

    if s[i] == "A":
        flag = True
    


for i in range(q):
    l,r = [int(i) for i in input().split()]
    ans = cumsum[r-1] - cumsum[l-1]
    print(ans)

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

for i in range(q):
    l,r = [int(i) for i in input().split()]
    p = s[l-1:r]
    ans = re.findall("AC",p)
    print(len("AC"))
Problem p03240 (python)

Fixed submission:
n = int(input())
card = []

for i in range(n):
    x,y,h = [int(i) for i in input().split()]
    card.append([x,y,h])


 
def check(cx,cy):
    needH = -1
    for i in range(n):
        x,y,h = card[i]

        if h>0:
            global H
            H = abs(x-cx)+abs(y-cy)+h
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    return False
    
    for i in range(n):
        x,y,h = card[i]

        if h==0:
            dist = abs(x-cx)+abs(y-cy)
            if H > dist:
                return False
    else:
        return True

    
for i in range(101):
    for j in range(101):
        if check(i,j):

            print("{} {} {}".format(i,j,H))

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

for i in range(n):
    x,y,h = [int(i) for i in input().split()]
    card.append([x,y,h])


 
def check(cx,cy):
    needH = -1
    for i in range(n):
        x,y,h = card[i]

        if h>0:
            global H = abs(x-cx)+abs(y-cy)+h
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    return False
    
    for i in range(n):
        x,y,h = card[i]

        if h==0:
            dist = abs(x-cx)+abs(y-cy)
            if H > dist:
                return False
    else:
        return True

    
for i in range(101):
    for j in range(101):
        if check(i,j):

            print("{} {} {}".format(i,j,H))
Problem p03262 (python)

Fixed submission:
from functools import reduce

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def gcd_list(numbers):
    return reduce(gcd, numbers)
    

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

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    

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

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    

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

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))
Problem p03284 (python)

Fixed submission:
a,b = [int(i) for i in input().split()]

if a % b == 0:
  print(0)
else:
  print(1)

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

if a % b == 0:
  print(0)
else:
  print(1)
Problem p03436 (python)

Fixed submission:
from collections import deque
h,w = (int(i) for i in input().split())

M = [input() for i in range(h)]
N = [[False]*w for i in range(h)]

cnt = 0
for i in range(h):
    for j in range(w):
        if M[i][j] == "#":
            cnt += 1


que = deque([[0,0,1]])
while que:
    x,y,c = que.popleft()

    if M[y][x] == "#":
        continue
    elif N[y][x]:
        continue
    elif x == w-1 and y == h-1:
        
        print(h*w-(c+cnt))
        quit()

    else:
        N[y][x]=True
        A = [[x+1,y,c+1],[x-1,y,c+1],[x,y+1,c+1],[x,y-1,c+1]]
        for a in A:
            if 0<=a[0]<=w-1 and 0<=a[1]<=h-1:
                que.append(a)
                
print(-1)

Buggy submission (verdict: Runtime Error):

h,w = (int(i) for i in input().split())
M = [input() for i in range(h)]
N = [[False]*w for i in range(h)]
print(M)
cnt = 0
for i in range(h):
    for j in range(w):
        if M[i][j] == "#":
            cnt += 1
print(cnt)
ans = 0
def dfs(x,y):
    global ans
    if M[x][y] == "#":
        return
    elif N[x][y]:
        return
    elif x == w-1 and y == h-1:
        print(h*w-(ans+1+cnt))
        exit()
    else:
        N[x][y] = True
        ans += 1
        A = [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]
        for a in A:
            if 0<=a[0]<=w-1 and 0<=a[1]<=h-1:
                dfs(a[0],a[1])

dfs(0,0)
print(-1)
Problem p03450 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200002)

def dfs(s):
	global x, G
	for t, d in G[s]:
		if x[t] is None:
			x[t] = x[s] + d
			if not dfs(t):
				return False
		else:
			if x[t] != x[s] + d:
				return False
	return True

N,M = map(int,input().split())
x = [None] * N
G = [[] for _ in range(N)]
for _ in range(M):
	L, R, D = map(int,input().split())
	G[L-1].append([R-1,D])
	G[R-1].append([L-1,-D])

res = True
for i in range(N):
	if x[i] is None:
		x[i] = 0
		res &= dfs(i)

print("Yes" if res == True else "No")

Buggy submission (verdict: Runtime Error):
def dfs(s):
	global x, G
	for t, d in G[s]:
		if x[t] is None:
			x[t] = x[s] + d
			if not dfs(t):
				return False
		else:
			if x[t] != x[s] + d:
				return False
	return True

N,M = map(int,input().split())
x = [None] * N
G = [[] for _ in range(N)]
for _ in range(M):
	L, R, D = map(int,input().split())
	G[L-1].append([R-1,D])
	G[R-1].append([L-1,-D])
print(G)
res = True
for i in range(N):
	if x[i] is None:
		x[i] = 0
		res &= dfs(i)

print("Yes" if res == True else "No")

Buggy submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())

A = [0]*2*100000

for i in range(m):
    xr,xl,d = [int(i) for i in input().split()]
    if xr in A and xl in A:
        if A.index(xr) + d != A.index(xl):
            print("No")
            break
    elif xr in A:
        A[A.index(xr)+d] = xl
    elif xl in A:
        A[A.index(xl)-d] = xr
    else:
        A[xr+n-1] = xr
        A[xr+n-1+d] = xl
else:
    print("Yes")
Problem p03473 (python)

Fixed submission:
t = int(input())

print(24+24-t)

Buggy submission (verdict: Runtime Error):
n = int(input())
t = 0
st = 0
cn = []
sn = []
fn = []

for i in range(n-1):
  c,s,f = map(int,input().split())
  cn.append(c)
  sn.append(s)
  fn.append(f)

for j in range(n-1):
    t = 0
    for i in range(j,n-1):
      st = sn[i]
      if t <= sn[i]:
        t = sn[i]
      if t%fn[i] != 0:
          t += fn[i]-t%fn[i]
      t += cn[i]
    print(t)


print(0)
Problem p03475 (python)

Fixed submission:
n = int(input())
t = 0
st = 0
cn = []
sn = []
fn = []

for i in range(n-1):
  c,s,f = map(int,input().split())
  cn.append(c)
  sn.append(s)
  fn.append(f)

for j in range(n-1):
    t = 0
    for i in range(j,n-1):
      st = sn[i]
      if t <= sn[i]:
        t = sn[i]
      if t%fn[i] != 0:
          t += fn[i]-t%fn[i]
      t += cn[i]
    print(t)


print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
t = 0
st = 0
cn = []
sn = []
fn = []

for i in range(n-1):
  c,s,f = map(int,input().split())
  cn.append(c)
  sn.append(s)
  fn.append(f)

for j in range(n-1):
    for i in range(j,n-1):
      st = sn[i]
      if t <= sn[i]:
        t = sn[i]
      else:
        while t <= st :
          st += fn[i]
      t += cn[i]
    print(t)
    t = 0
        
 print(0)
Problem p03477 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c,d = map[int,input().split()]
right = a + b
left = c + d
 
if right < left:
  print('Right')
elif left < right:
  print('Left')
else:
  print('Balanced')

Buggy submission (verdict: Runtime Error):
a,b,c,d = map[int,input().split()]
right = a + b
left = c + d

if right > left:
  print('Right')
elif left > right:
  print('Left')
else:
  print('Balanced')
Problem p03485 (python)

Fixed submission:
import math
numbers = input().rstrip().split()
number1 = int(numbers[0])
number2 = int(numbers[1])
 
mean = (number1+number2) / 2
 
print(math.ceil(mean))

Buggy submission (verdict: Runtime Error):
N = int(input().rstrip())
numbers =[ int(i) for i in input().rstrip().split()]
  

n_dic = {str(i):0 for i in set(numbers)}


for i in numbers:
    n_dic[str(i)] += 1
   
count = 0

for i,j in n_dic.items():
    if int(i) < j:
        count += j - int(i)
    
    elif int(i) > j:
        count += j
        
print(count)

Buggy submission (verdict: Runtime Error):
import string

alphabet = {}
n  = 0
for i in string.ascii_lowercase:
    alphabet[i] = n
    n += 1
    
s = list(input().rstrip())
t = list(input().rstrip())



for i in range(len(s)):
    s[i] = alphabet[s[i]]
    
for i in range(len(t)):
    t[i] = alphabet[t[i]]
    

s.sort()
t.sort(reverse=True)

if s < t:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
numbers = input().rstrip().split()
number1 = numbers[0]
number2 = numbers[1]

mean = (number1+number2) / 2

print(math.ceil(mean))
Problem p03494 (python)

Fixed submission:
N = int(input())
numbers =map(int,input().split())
ans = 10000
for i in numbers:
  count = 0
  while i % 2 == 0:
    i /= 2
    count += 1
  ans = min(ans,count)

print(ans)

Buggy submission (verdict: Runtime Error):
import math as m
n = int(input())
numbers = map(int,input().split())
order = []
 
for i in range(n):
  if numbers[i] == 0:
    a = 0
  else:
    a = m.floor(m.log(numbers[i],2))
  order.append(a)
print(min(order))

Buggy submission (verdict: Runtime Error):
import math as m
n = int(input())
numbers = map(int,input().split())
order = []

for i in range(6):
  if numbers[i] == 0:
    a = 0
  else:
    a = m.floor(m.log(numbers[i],2))
  order.append(a)
print(min(order))
Problem p03547 (python)

Fixed submission:
x,y = input().split()
if x == y:
  print('=')
elif x > y:
  print('>')
else:
  print('<')

Buggy submission (verdict: Runtime Error):
x,y = [input().split()]
if x == y:
  print('=')
elif x > y:
  print('>')
else:
  print('<')
Problem p03555 (python)

Fixed submission:
a = input()
b = input()
c = a[::-1]
d = b[::-1]

if a == d and b == c:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

count = 0


for c in C:
    for b in B:
        if b >= c:
            continue
        else:
            saidan = filter(lambda x: x<b ,A)
            count+=len(list(saidan))
                
print(count)
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F = map(int,input().split())
c_max = 0
sw_max = 0
s_max = 0

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D
                
                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if water + sugar <= F and sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max ==0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())
c_max = 0
sw_max = 0
s_max = 0

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D
                
                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if water + sugar <= F and sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max = 0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)
Problem p03699 (python)

Fixed submission:
n = int(input())
A = [int(input()) for i in range(n)]

B = []

for a in A:
    if a % 10 != 0:
        B.append(a)

ans = sum(A)
if ans % 10 == 0 and len(B) != 0:
    ans -= min(B)
elif ans % 10 == 0 and len(B) == 0:
    ans = 0
    

print(ans)

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

B = []

for a in A:
    if a % 10 != 0:
        B.append(a)

ans = sum(A)
if ans % 10 == 0:
    ans -= min(B)
    

print(ans)
Problem p02613 (python)

Fixed submission:
n = int(input())
a = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0
for s in a:
  if s=='AC':
    ac+=1
  if s=='WA':
    wa+=1
  if s=='TLE':
    tle+=1
  if s=='RE':
    re+=1
print(f'AC x {ac}')
print(f'WA x {wa}')
print(f'TLE x {tle}')
print(f'RE x {re}')

Buggy submission (verdict: Runtime Error):
from collections imort Counter

n = int(input())
s = [input() for _ in range(n)]
counter = Counter(s)
output = ['AC', 'WA', 'TLE', 'RE']

for key in output:
  print(f'{key} x {counter[key]}')
Problem p02614 (python)

Fixed submission:
from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if c[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
	for col_bit in product(range(2), repeat=w):
		cnt = 0
    for row in range(h):
    	for col in range(w):
    		if c[row][col] == '#' and (row_bit[row] and col_bit[col]):
        		cnt += 1
	if cnt == k:
    	ans += 1
      
print(ans)
Problem p02778 (python)

Fixed submission:
s = input()
print('x'*len(s))

Buggy submission (verdict: Runtime Error):
s = input()
print(str(x)*len(s))

Buggy submission (verdict: Runtime Error):
print(x * len(input()))
Problem p03086 (python)

Fixed submission:
s=input()
clist=['A','C','G','T']
count=0
a=[]
for i in s:
  if i in clist:
    count+=1
  else:
    a.append(count)
    count=0
a.append(count)
print(max(a))

Buggy submission (verdict: Runtime Error):
s = list(input())
acgt = ['A', 'C', 'G', 'T']
cnt = 0
i, j = 0, 0
maxv = -1

for j in range(len(s)):
  maxv = max(maxv, cnt)
  cnt = 0
  i = j
  while s[i] in acgt:
    cnt += 1
    i += 1
maxv = max(maxv, cnt)
print(maxv)

Buggy submission (verdict: Runtime Error):
s = list(input())
acgt = ['A', 'C', 'G', 'T']
cnt = 0
i, j = 0, 0
maxv = 0

for j in range(len(s)):
  maxv = max(maxv, cnt)
  cnt = 0
  i = j
  while s[i] in acgt:
    cnt += 1
    i += 1
maxv = max(maxv, cnt)
print(maxv)

Buggy submission (verdict: Runtime Error):
s = list(input())
acgt = ['A', 'C', 'G', 'T']
cnt = 0
i, j = 0, 0
maxv = 0

for j in range(len(s)):
  maxv = max(maxv, cnt)
  cnt = 0
  while s[j] in acgt:
    cnt += 1
    j += 1
maxv = max(maxv, cnt)
print(maxv)

Buggy submission (verdict: Runtime Error):
s=input()
clist=['A','C','G','T']
count=0
a=[]
for i in s:
  if i in clist:
    count+=1
  else:
    a.append(count)
    count=0

print(max(a))

Buggy submission (verdict: Runtime Error):
s=input()
clist=['A','C','G','T']
count=0
a=[]
for i in s:
  if i in clist:
    count+=1
  else:
    a.append(count)
    count=0
print(max(a))
Problem p03457 (python)

Fixed submission:
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
    count += 1
  T, X, Y = t, x, y
  
print('Yes' if count == N else 'No')

Buggy submission (verdict: Runtime Error):
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
    count += 1
  T, X, Y = t, x, y
  
 print('Yes' if count == N else 'No')

Buggy submission (verdict: Runtime Error):
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  if t % 2 == (x+y) % 2 and abs(x-X)+abs(y-Y) <= t-T:
    count += 1
  T, X, Y = t, x, y
  
 print('Yes' if count == N else 'No')

Buggy submission (verdict: Runtime Error):
N = input()
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  if t % 2 == (x+y) % 2 and abs(x-X)+abs(y-Y) <= t-T:
    count += 1
  T, X, Y = t, x, y
  
 print('Yes' if count == N else 'No')

Buggy submission (verdict: Runtime Error):
N = input()
T, X, Y = 0, 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  if t % 2 == (x+y) % 2 and abs(x-X)+abs(y-Y) <= t-T:
    count += 1
  T, X, Y = t, x, y
  
 print('Yes' if count==N else 'No')
Problem p03470 (python)

Fixed submission:
N = int(input())
d = [input() for i in range(N)]
print(len(set(d)))

Buggy submission (verdict: Runtime Error):
N = int(input())
d = [input() for i in range(N)]
print(len(list(set(d)))
Problem p03478 (python)

Fixed submission:
N, A, B = map(int, input().split())
print(sum(i for i in range(N+1) if A <= sum(map(int, str(i))) <= B))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
print(sum(i for i in range(N+1) if A <= sum(map(int, str(i))) <= B)
Problem p03729 (python)

Fixed submission:
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
  break
else:
  print('NO')
Problem p03081 (python)

Fixed submission:
from collections import defaultdict
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
s = input()
q = []
for _ in range(Q):
  q.append(input().split())
q.reverse()

l = 0
r = N-1
for i in range(Q):
  t, d = q[i]
  if l-1 >= 0 and t == s[l-1] and d == 'R':
    l -= 1
  elif t == s[l] and d == 'L':
    l += 1

  if r+1 <= N-1 and t == s[r+1] and d == 'L':
    r += 1
  elif t == s[r] and d == 'R':
    r -= 1

print(max(0, r-l+1))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
s = input()
q = []
for _ in range(Q):
  q.append(input().split())
q.reverse()

dp = [[] for _ in range(N)]
for i in range(N):
  t, d = q[i]
  if t == s[0] and d == 'L':
    dp[i].append(0)
  elif t == s[N-1] and d == 'R':
    dp[i].append(N-1)
  
  if i == 0:
    continue

  for p in dp[i-1]:
    if p-1 >= 0 and t == s[p-1] and d == 'R':
      dp[i].append(p-1)
    elif p+1 <= N-1 and t == s[p+1] and d == 'L':
      dp[i].append(p+1)

print(N-len(dp[N-1]))
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
INF = 10**5
COST = [INF,2,5,5,4,5,6,3,7,6]
digit = [-INF]*(N+1)
digit[0] = 0
for i in range(1, N+1):
    for a in A:
        c = COST[a]
        if i - c < 0:
            continue
        digit[i] = max(digit[i], 1 + digit[i-c])
ans = ''
n = N
for i in range(digit[N], 0, -1):
    for a in A:
        new_n = n - COST[a]
        if new_n < 0 or digit[new_n] < i - 1:
            continue
        ans += str(a)
        n = new_n
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
INF = 10**(10**4)
COST = [INF,2,5,5,4,5,6,3,7,6]

min_cost = min(list(map(lambda a: COST[a], A)))
max_digits = N // min_cost

def dfs(n, digits):
    if digits * min_cost > n:
        return -INF
    if digits == 0:
        if n == 0:
            return 0
        else:
            return -INF
    elif digits < 0:
        return - INF
    results = []
    for a in A:
        res = a * 10 ** (digits - 1) + dfs(n-COST[a], digits-1)
        results.append(res)
    return max(results)

print(dfs(N, max_digits))
Problem p03138 (python)

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

fmax = 0
for i in range(40, 0, -1):
  x = 2 ** (i - 1)
  f1 = 0
  f0 = 0
  for a in A:
    a_ = a & x
    f1 += x ^ a_
    f0 += a_
  #print(i, f0, f1)
  if f0 >= f1:
    fmax += f0
  else:
    if k >= x:
      fmax += f1
      k -= x
    else:
      fmax += f0
print(fmax)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))

F = [0]*(k+1)
for x in range(k):
  for a in A:
    F[x] += x ^ a
print(max(F))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))

F = [0]*(k+1)
for x in range(k):
  for a in A:
    F[x] += x ^ a
print(max(F))
Problem p03280 (python)

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

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
 
n, m, q = map(int, input().split())
LR = [0]*m
for i in range(m):
    LR[i] = list(map(int, input().split()))
P = [0]*q
Q = [0]*q
for i in range(q):
    P[i], Q[i] = map(int, input().split())
 
LR.sort(key=lambda x: (x[0], x[1]))
L = list(map(lambda x: x[0], LR))
#print(LR)
 
C = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    l = bisect_left(L, i)
    r = bisect_left(L, i+1)-1
    R2 = list(map(lambda x: x[1], LR[l:r+1]))
    #print(l, r, R2)
    for j in range(i,n+1):
        C[i][j] = bisect_left(R2, j+1)
    #print(i, C[i])
 
for i in range(q):
    ans = 0
    for j in range(P[i], Q[i]+1):
        ans += C[j][Q[i]]
    print(ans)