Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
H, A = map(int, input().split())

x = 0
while True:
H = H - A
  if H < 0:
    break
  else:
    x += 1
print(x)

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

x = 0
while True:
  if H <= 0:
    break
  if H > 0:
    H -= A
    x += 1
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
H, A = map(int, input().split())

x = 0
while True:
  if H < 0:
    break
  else:
    x += 1
print(x)

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

x = 0
while True:
  if H <= 0:
    break
  if H > 0:
    H -= A
    x += 1
print(x)

Buggy python submission (verdict: Runtime Error):
H, A = int(input().split())

x = 1
while True:
  if 0 =< H/(A*x):
    H -= A
    a += 1
  else:
    break
print(x)
  

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

x = 0
while True:
  if H <= 0:
    break
  if H > 0:
    H -= A
    x += 1
print(x)

Buggy python submission (verdict: Runtime Error):
H, A = int(input().split())

x = 1
while True:
  if 0 <= H/(A*x):
    H -= A
    a += 1
  else:
    break
print(x)

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

x = 0
while True:
  if H <= 0:
    break
  if H > 0:
    H -= A
    x += 1
print(x)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
H, A = map(int,stdin.readline().rstrip().split)

x = 1
while True:
  if 0 <= H/(A*x):
    H -= A
    a += 1
  else:
    break
print(x)

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

x = 0
while True:
  if H <= 0:
    break
  if H > 0:
    H -= A
    x += 1
print(x)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
H, A = map(int,stdin.readline().rstrip().split)

a = 0
while True:
  if x <= H/A:
    H - A
    a += 1
  else:
    break
print(a)

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

x = 0
while True:
  if H <= 0:
    break
  if H > 0:
    H -= A
    x += 1
print(x)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
H, A = map(int,stdin.readline().rstrip().split)

a = 0
while True
  if x <= H/A:
    H - A
    a += 1
  else:
    break
print(a)

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

x = 0
while True:
  if H <= 0:
    break
  if H > 0:
    H -= A
    x += 1
print(x)
Buggy python submission (verdict: Runtime Error):
s = input()
if s[0] == s[1] and s[1] == s[2]:
    print 'no'
    else: print 'yes'

Fixed submission:
s = input()
if s[0] == s[1] and s[1] == s[2]:
    print ('No')
else: 
    print ('Yes')

Buggy python submission (verdict: Runtime Error):
s = input()
if s[0] == s[1] and s[1] == s[2]:
    print 'no'
    else: print 'yes'

Fixed submission:
s = input()
if s[0] == s[1] and s[1] == s[2]:
    print ('No')
else: 
    print ('Yes')
Buggy python submission (verdict: Runtime Error):
N = input()
ans = (N + 1) / 2
print(ans)

Fixed submission:
N = input()
M = int(N)
jud = M % 2
if jud == 1:
    ans = M // 2 + 1
else:
    ans = M // 2
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
jud = N % 2
if jud == 1:
    ans = N // 2 + 1
else:
    ans == N / 2
print(ans)

Fixed submission:
N = input()
M = int(N)
jud = M % 2
if jud == 1:
    ans = M // 2 + 1
else:
    ans = M // 2
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
jud == N % 2
if jud == 1:
    ans = N // 2 + 1
else:
    ans == N / 2
print(ans)

Fixed submission:
N = input()
M = int(N)
jud = M % 2
if jud == 1:
    ans = M // 2 + 1
else:
    ans = M // 2
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
ans = (N + 1) // 2
print(ans)

Fixed submission:
N = input()
M = int(N)
jud = M % 2
if jud == 1:
    ans = M // 2 + 1
else:
    ans = M // 2
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
ans = N // 2
print(ans)

Fixed submission:
N = input()
M = int(N)
jud = M % 2
if jud == 1:
    ans = M // 2 + 1
else:
    ans = M // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_b

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    al = list(map(int, input().split()))

    cum_len = [0] * len(al)
    cum_len[0] = al[0]
    for i in range(1, len(al)):
        cum_len[i + 1] = cum_len[i] + al[i]

    ans = 1000000
    for i in range(len(al)-1):
        left = cum_len[i]
        right = cum_len[-1] - cum_len[i]
        ans = min(ans, abs(left - right))

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_b

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    al = list(map(int, input().split()))

    cum_len = [0] * len(al)
    cum_len[0] = al[0]
    for i in range(1, len(al)):
        cum_len[i] = cum_len[i-1] + al[i]

    # print(sum(al))
    ans = 10**10
    for i in range(len(al)):
        left = cum_len[i]
        right = cum_len[-1] - cum_len[i]
        # print(left, right)
        ans = min(ans, abs(left - right))

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    s = input()
    ans = 1

    for i in range(1, n):
        if s[i-1] != s[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
v

Fixed submission:
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    s = input()
    ans = 1

    for i in range(1, n):
        if s[i-1] != s[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    ll = list(map(int, input().split()))
    ll.sort()

    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            rest = ll[j + 1:]
            a_plus_b = ll[i] + ll[j]
            pos_right = bisect.bisect_left(rest, a_plus_b)

            b_minus_a = ll[j] - ll[i]
            pos_left = bisect.bisect_right(rest, b_minus_a)
            count = pos_right - pos_left

            ans += count
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    ll = list(map(int, input().split()))
    ll.sort()

    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            rest = ll[j + 1:]
            a_plus_b = ll[i] + ll[j]
            pos_right = bisect.bisect_left(rest, a_plus_b)
            count = pos_right

            ans += count
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    s = input()
    if len(set(s)) == n:
        print(0)
        return

    if len(set(s)) == 1:
        print(n // 2)
        return 

    def same_length(i1, i2):
        i = 0
        count = 0
        while i1 + i < i2 and i2 + i < n:
            if s[i1 + i] != s[i2 + i]:
                break

            count += 1
            i += 1

        return count

    char_positions = defaultdict(list)
    for i, c in enumerate(s):
        char_positions[c].append(i)

    ans = 0
    for char in char_positions:
        char_count = len(char_positions[char])
        # print(char, char_count)
        if char_count < 2:
            continue
        for i in range(char_count - 1):
            for j in range(i + 1, char_count):
                ans = max(ans, same_length(char_positions[char][i], char_positions[char][j]))
                # print(char_positions[char][i], char_positions[char][j], ans)

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    s = input()
    if len(set(s)) == n:
        print(0)
        return

    dp = [[0] * n for _ in range(n)]
    for i in range(n):
        dp[i][i] = -10**4

    for i in range(n):
        for j in range(i, n):
            if i == j:
                continue
            if s[i] == s[j]:
                if i > 0 and j > 0:
                    length = dp[i-1][j-1]
                    if j - length > i:
                        dp[i][j] = dp[i-1][j-1] + 1
                else:
                    dp[i][j] = 1

    ans = 0
    for d in dp:
        ans = max(ans, max(d))
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    mod = 10 ** 9 + 7
    s = list(input())
    n = len(s)
    s.reverse()

    dp = [[0] * 13 for _ in range(n + 1)]
    dp[0][0] = 1

    mul = 1
    for i, c in enumerate(s):
        for j in range(10):
            if (c.isdigit() and int(c) == j) or c == '?':
                m = (j * mul) % 13
                for k in range(13):
                    dp[i + 1][(m + k) % 13] += dp[i][k]
        for k in range(13):
            dp[i + 1][k] = dp[i + 1][k] % mod
        mul *= 10
    print(dp[n][5])


if __name__ == '__main__':
    main()


Fixed submission:
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    mod = 10 ** 9 + 7
    s = list(input())
    n = len(s)
    s.reverse()

    dp = [[0] * 13 for _ in range(n + 1)]
    dp[0][0] = 1

    mul = 1
    for i, c in enumerate(s):
        for j in range(10):
            if (c.isdigit() and int(c) == j) or c == '?':
                m = (j * mul) % 13
                for k in range(13):
                    dp[i + 1][(m + k) % 13] += dp[i][k]
        for k in range(13):
            dp[i + 1][k] = dp[i + 1][k] % mod
        mul *= 10
        mul %= 13
    print(dp[n][5])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    # 5-1292 で一周
    mod = 10 ** 9 + 7
    s = list(input())
    n = len(s)
    s.reverse()

    dp = [[0] * 13 for _ in range(n + 1)]
    dp[0][0] = 1

    for i, c in enumerate(s):
        for j in range(10):
            if (c.isdigit() and int(c) == j) or c == '?':
                m = (j * 10 ** i) % 13
                for k in range(13):
                    dp[i + 1][(m + k) % 13] += dp[i][k]
        for k in range(13):
            dp[i + 1][k] = dp[i + 1][k] % mod

    print(dp[n][5])


if __name__ == '__main__':
    main()


Fixed submission:
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    mod = 10 ** 9 + 7
    s = list(input())
    n = len(s)
    s.reverse()

    dp = [[0] * 13 for _ in range(n + 1)]
    dp[0][0] = 1

    mul = 1
    for i, c in enumerate(s):
        for j in range(10):
            if (c.isdigit() and int(c) == j) or c == '?':
                m = (j * mul) % 13
                for k in range(13):
                    dp[i + 1][(m + k) % 13] += dp[i][k]
        for k in range(13):
            dp[i + 1][k] = dp[i + 1][k] % mod
        mul *= 10
        mul %= 13
    print(dp[n][5])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
import math

def main():
    n = int(input())
    al = list(map(int, input().split()))

    ans = [0] * n

    half = math.ceil(n/2)
    for i in range(half, n):
        ans[i] = al[i]

    for i in range(half, -1, -1):
        num = i + 1
        val = 0
        for j in range(num * 2 - 1, n, num):
            # print(j)
            val += ans[j]

        val %= 2
        ans[i] = 0 if val == al[i] else 1

    c = ans.count(1)
    print(c)
    if c > 0:
        boxes = []
        for i in range(len(ans)):
            if ans[i] == 1:
                boxes.append(i + 1)
        print(' '.join(map(str, boxes)))


if __name__ == '__main__':
    main()


Fixed submission:
#

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
import math

def main():
    n = int(input())
    al = list(map(int, input().split()))

    ans = [0] * n

    half = math.ceil(n/2)
    for i in range(half, n):
        ans[i] = al[i]

    for i in range(half-1, -1, -1):
        num = i + 1
        val = 0
        for j in range(num * 2 - 1, n, num):
            # print(j)
            val += ans[j]

        val %= 2
        ans[i] = 0 if val == al[i] else 1

    c = ans.count(1)
    print(c)
    if c > 0:
        boxes = []
        for i in range(len(ans)):
            if ans[i] == 1:
                boxes.append(i + 1)
        print(' '.join(map(str, boxes)))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    al = [int(input()) for _ in range(n)]

    lsbs = []
    for a in al:
        if len(lsbs) == 0:
            lsbs.append([a])
        else:
            added = False
            for lsb in lsbs:
                if lsb[-1] < a:
                    lsb.append(a)
                    added = True
                    break
            if not added:
                lsbs.append([a])
    print(len(lsbs))


if __name__ == '__main__':
    main()


Fixed submission:
#

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    al = [int(input()) for _ in range(n)]

    lsbs = deque()
    for a in al:
        pos = bisect.bisect_left(lsbs, a)
        if pos == 0:
            lsbs.appendleft(a)
        else:
            if pos == len(lsbs):
                lsbs[-1] = a
            else:
                lsbs[pos-1] = a
        # print(lsbs)
    print(len(lsbs))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N = int(input())
    xy = []
    for _ in range(N):
        x, y = map(int, input().split())
        xy.append((x, y))

    xy.sort(key=lambda p: (p[0], p[1]))
    # print(xy)

    cand = defaultdict(lambda:0)

    for i in range(N-1):
        for j in range(i+1, N):
            p = xy[j][0] - xy[i][0]
            q = xy[j][1] - xy[i][1]
            key = '{},{}'.format(p, q)
            cand[key] += 1
    counter = Counter(cand)
    pq_count = counter.most_common()[0][1]
    # print(counter.most_common()[0])
    print(N - pq_count)


if __name__ == '__main__':
    main()


Fixed submission:
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N = int(input())
    xy = []
    for _ in range(N):
        x, y = map(int, input().split())
        xy.append((x, y))

    if N == 1:
        print(1)
        exit()

    xy.sort(key=lambda p: (p[0], p[1]))
    # print(xy)

    cand = defaultdict(lambda:0)

    for i in range(N-1):
        for j in range(i+1, N):
            p = xy[j][0] - xy[i][0]
            q = xy[j][1] - xy[i][1]
            key = '{},{}'.format(p, q)
            cand[key] += 1
    counter = Counter(cand)
    pq_count = counter.most_common()[0][1]
    # print(counter.most_common()[0])
    print(N - pq_count)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N = int(input())
    xy = []
    for _ in range(N):
        x, y = map(int, input().split())
        xy.append((x, y))

    xy.sort(key=lambda p: (p[0], p[1]))
    # print(xy)

    cand = defaultdict(lambda :0)
    ans = 0
    for i in range(N-1):
        for j in range(1, N):
            p = xy[j][0] - xy[i][0]
            q = xy[j][1] - xy[i][1]
            key = '{},{}'.format(p, q)
            cand[key] += 1
    counter = Counter(cand)
    pq_count = counter.most_common()[0][1]
    # print(counter.most_common()[0])
    print(N - pq_count)




if __name__ == '__main__':
    main()


Fixed submission:
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N = int(input())
    xy = []
    for _ in range(N):
        x, y = map(int, input().split())
        xy.append((x, y))

    if N == 1:
        print(1)
        exit()

    xy.sort(key=lambda p: (p[0], p[1]))
    # print(xy)

    cand = defaultdict(lambda:0)

    for i in range(N-1):
        for j in range(i+1, N):
            p = xy[j][0] - xy[i][0]
            q = xy[j][1] - xy[i][1]
            key = '{},{}'.format(p, q)
            cand[key] += 1
    counter = Counter(cand)
    pq_count = counter.most_common()[0][1]
    # print(counter.most_common()[0])
    print(N - pq_count)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N = int(input())
    d = [0] * N
    multi = [0] * N

    edges = defaultdict(list)
    edges_l = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        d[a-1] += 1
        d[b-1] += 1
        multi[a-1] += 1
        multi[b-1] += 1

        edges_l.append((a-1, b-1))
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    for i in range(len(d)):
        d[i] = (d[i], i)
    d.sort(key=lambda v: v[0], reverse=True)

    C = list(map(int, input().split()))
    C.sort(reverse=True)
    # print(d)
    # print(C)
    used = [False] * N
    ans = [0] * N
    count = 0
    que = d[i]
    while que:
        dub, index = que.pop()
        if not used[index]:
            # print('i = {}, Ci = {}'.format(i, C[i]))
            ans[index] = C[count]
            used[index] = True
            count += 1

        # print(edges[i])
        for nei in edges[index]:
            if not used[nei]:
                que.append(d[nei])

    val = 0
    for a, b in edges_l:
        node_val = min(ans[a], ans[b])
        val += node_val

    print(val)
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Fixed submission:
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    N = int(input())
    d = [0] * N
    multi = [0] * N

    edges = defaultdict(list)
    edges_l = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        d[a-1] += 1
        d[b-1] += 1
        multi[a-1] += 1
        multi[b-1] += 1

        edges_l.append((a-1, b-1))
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    for i in range(len(d)):
        d[i] = (d[i], i)
    d.sort(key=lambda v: v[0], reverse=True)

    C = list(map(int, input().split()))
    C.sort(reverse=True)
    # print(d)
    # print(C)
    used = [False] * N
    ans = [0] * N
    count = 0
    que = []
    que.append(d[0][1])
    while que:
        index = que.pop()
        if not used[index]:
            # print('i = {}, Ci = {}'.format(i, C[i]))
            ans[index] = C[count]
            used[index] = True
            count += 1

        # print(edges[i])
        for nei in edges[index]:
            if not used[nei]:
                que.append(nei)

    val = 0
    for a, b in edges_l:
        node_val = min(ans[a], ans[b])
        val += node_val

    print(val)
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())

    A = list(map(int, input().split()))  # 使っていい数字

    match_dic = {9: 6, 8: 7, 7: 3, 6: 6, 5: 5, 4: 4, 3: 5, 2: 5, 1: 2}
    available_dic = {k: v for k, v in match_dic.items() if k in A }
    availables = sorted(available_dic.items(), key=lambda x: x[1])

    def dfs(cost, nums):
        if cost == 0:
            nums.sort(key=lambda x: -x)
            return int(''.join(map(str, nums)))

        candidates = [dfs(cost - avs[1], nums + [avs[0]]) for avs in availables if cost >= avs[1]]
        if len(candidates) == 0:
            return 0
        else:
            return max(candidates)

    print(dfs(N, []))


main()

Fixed submission:
# https://atcoder.jp/contests/abc118/tasks/abc118_d


def main():
    N, M = map(int, input().split())

    A = list(map(int, input().split()))  # 使っていい数字

    costs = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]  # 各数字のマッチの数

    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for i in range(1, N + 1):
        for a in A:
            if i < costs[a]:
                continue
            dp[i] = max(dp[i], dp[i - costs[a]] * 10 + a)
    print(dp[N])


main()

Buggy python submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())

    A = list(map(int, input().split()))  # 使っていい数字

    match_dic = {9: 6, 8: 7, 7: 3, 6: 6, 5: 5, 4: 4, 3: 5, 2: 5, 1: 2}
    available_dic = {k: v for k, v in match_dic.items() if k in A }
    availables = sorted(available_dic.items(), key=lambda x: x[1])

    def dfs(cost, nums):
        if cost == 0:
            nums.sort(key=lambda x: -x)
            return int(''.join(map(str, nums)))

        cand = [dfs(cost - avs[1], nums + [avs[0]]) for avs in availables if cost >= avs[1]]
        if len(cand) == 0:
            return 0
        else:
            return max(dfs(cost - avs[1], nums + [avs[0]]) for avs in availables if cost >= avs[1])

    print(dfs(N, []))


main()

Fixed submission:
# https://atcoder.jp/contests/abc118/tasks/abc118_d


def main():
    N, M = map(int, input().split())

    A = list(map(int, input().split()))  # 使っていい数字

    costs = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]  # 各数字のマッチの数

    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for i in range(1, N + 1):
        for a in A:
            if i < costs[a]:
                continue
            dp[i] = max(dp[i], dp[i - costs[a]] * 10 + a)
    print(dp[N])


main()