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

Fixed submission:
n, m = map(int, input().split())
flag = []
for _ in range(m): flag.append(0)
for _ in range(n):
    line = list(map(int, input().split()))
    for i in range(line[0]): flag[line[i+1]-1] += 1
count = 0
for j in range(m):
    if(flag[j] == n): count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
flag = []
for _ in range(m): flag.append(True)
for _ in range(n):
    line = list(map(int, input()))
    for i in range(line[0]): flag[line[i+1]] = False
count = 0
for j in range(m):
    if(flag[j]): count += 1
print(count)
Problem p03240 (python)

Fixed submission:
N = int(input())
lis = []
lstipt = []
cnt = 0
h = 0
while h == 0:
    x, y, h = map(int, input().split())
    if h == 0:
        lstipt.append([x,y,h])
    cnt += 1

for Cx in range(101):
    for Cy in range(101):
        Ph = abs(x-Cx) + abs(y-Cy) + h
        lis.append([Cx,Cy,Ph])

for _ in range(N-cnt):
    x, y, h = map(int, input().split())
    newlis = []
    if h == 0: 
        for l in lis:
            if abs(x-l[0]) + abs(y-l[1]) + h >= l[2]:
                newlis.append(l)
    else:
        for l in lis:
            if abs(x-l[0]) + abs(y-l[1]) + h == l[2]:
                newlis.append(l)
    lis = newlis

for ipt in lstipt:
    x, y, h = ipt[0], ipt[1], ipt[2]
    newlis = []
    if h == 0: 
        for l in lis:
            if abs(x-l[0]) + abs(y-l[1]) + h >= l[2]:
                newlis.append(l)
    else:
        for l in lis:
            if abs(x-l[0]) + abs(y-l[1]) + h == l[2]:
                newlis.append(l)
    lis = newlis

print(" ".join(map(str,lis[0])))

Buggy submission (verdict: Runtime Error):
def f(n, x):
    if n >= 0: return n//x+1
    else: return 0

a,b,x = map(int, input().split())
print(f(b,x)-f(a-1,x))
Problem p03287 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
t = [0]
v = 0
b = {0:1}
for i in range(n):
    v = (v + a[i]) % m
    if v in b.keys():
        b[v] += 1
    else:
        b[v] = 1
ans = 0
for i in b.values():
    ans += i * (i-1) / 2
print(int(ans))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
t = [0]
v = 0
if n * n / 2 > m:
    mod = [0] * m
    for i in range(len(a)):
        v += a[i]
        mod[v%m] += 1
    ans = mod[0]
    for i in range(m):
        ans += mod[i] * (mod[i]-1) / 2
    print(int(ans))
else:
    ans = 0
    for i in range(len(a)):
        v += a[i]
        t.append(v)
    for i in range(len(t)-1):
        for j in range(i+1, len(t)):
            if (t[j]-t[i]) % m == 0:
                ans += 1
    print(ans)
Problem p03424 (python)

Fixed submission:
i = int(input())
l = input().split()
print("Four" if l.count("Y")>0 else "Three")

Buggy submission (verdict: Runtime Error):
i = int(input())
l = list(map(int,input().split()))
print("Four" if l.count("Y")>0 else "Three")
Problem p03597 (python)

Fixed submission:
n = int(input())**2
print(n-int(input()))

Buggy submission (verdict: Runtime Error):
n = int(input())**2
print(n-int(input())
Problem p03633 (python)

Fixed submission:
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
ns = []
for _ in range(n):
    ns.append(int(input()))

print(lcm(ns))

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
ns = []
for _ in range(n):
    ns.append(int(input()))

print(lcm(ns))
Problem p03635 (python)

Fixed submission:
r = list(map(lambda x:int(x)-1, input().split()))
print(r[0]*r[1])

Buggy submission (verdict: Runtime Error):
r = map(lambda x:int(x)-1, input().split())
print(r[0]*r[1])
Problem p03680 (python)

Fixed submission:
n = int(input())
a = [[int(input())-1, False] for _ in range(n)]
a[0][1] = True
now = 0
cnt = 0
while True:
    now = a[now][0]
    if a[now][1]:
        print(-1)
        break
    a[now][1] = True
    cnt += 1
    if now == 1:
        print(cnt)
        break

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [[int(input())-1, False] for _ in range(n)]
a[0][1] = True
now = 0
cnt = 0
while True:
    now = a[now][0]
    if a[now][1]:
        print(f"now={now}") 
        print(-1)
        break
    a[now][1] = True
    cnt += 1
    if now == 1:
        print(cnt)
        break
Problem p03695 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
flag = [False for _ in range(8)]
flex = 0
for x in a:
    if x >= 3200:
        flex += 1
    else:
        flag[int(x/400)] = True
les = flag.count(True)
if les == 0 and flex > 0:
    print("1 {}".format(flex))
else:
    print("{} {}".format(les, les+flex))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
flag = [False for _ in range(8)]
flex = 0
for x in a:
    if x >= 3200:
        flex += 1
    else:
        flag[int(x/400)] = True
les = flag.count(True)
if les == 0 and flex > 0:
    print("1 " + flex)
else:
    print("{} {}".format(les, les+flex))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
flag = [False for _ in range(8)]
flex = 0
for x in a:
    if x >= 3200:
        flex += 1
    else:
        flag[int(x/400)] = True
les = flag.count(True)
print(f"{les} {min([8,les+flex])}")
Problem p03697 (python)

Fixed submission:
a, b = map(int, input().split())
if a + b >= 10: print("error")
else: print(a+b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a + b >= 10: print("error")
else: print(x+y)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if x + y >= 10: print("error")
else: print(x+y)
Problem p02702 (python)

Fixed submission:
from collections import Counter

MOD = 2019
S = input()[::-1]
n = 0
x = 1
c = Counter()
ans = 0

for s in S:
    c[n] += 1
    n += int(s) * x
    n %= MOD
    ans += c[n]
    x = x * 10 % MOD
    
print(ans)

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

def main():
    MOD = 2019
    S = input()[::-1]
    n = 0
    x = 1
    c = Counter()
    ans = 0
    
    for s in S:
        c[n] += 1
        n += int(s) * x
        n %= MOD
        ans += c[n]
        x = x * 10 % MOD
                
    print(ans)
        
if __name__ == '__main__':
    main()
Problem p02838 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    x = np.max(A)
    n = 1 if x == 0 else int(np.log2(x))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = 0
    MOD = 10**9+7
    k = 1
    n = int(np.log2(np.max(A)))+1

    for i in range(n):
        c = np.count_nonzero(A%2)
        A >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)

if __name__ == '__main__':
    main()

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

from math import * 

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

    ans = 0
    MOD = 10**9+7
    k = 1
    n = ceil(log2(max(A)))
    for i in range(n):
        c = 0
        for j in range(N):
            c += A[j] & 1
            A[j] >>= 1
        ans = (ans + c * (N-c) * k) % MOD
        k = (2*k) % MOD

    print(ans)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from math import ceil, log2

input = sys.stdin.readline

def main():
    MOD = 10**9 + 7
    
    N = int(input())
    A = list(map(int, input().split()))
    K = ceil(log2(max(A)))
    
    nums = [[0,0] for i in range(K)]
    ks = [(i, 2**i) for i in range(K)]
    
    A_ = [[] for i in range(N)]
    
    for i, a in enumerate(A):
        for j, k in ks:
            n = a & k > 0
            A_[i].append(n)
            nums[j][n] += 1
            
    ans = 0
    
    for a in A_:
        for i, n in enumerate(a):
            nums[i][n] -= 1
            ans += ks[i][1] * nums[i][not n] % MOD
            
    print(ans%MOD)

if __name__ == '__main__':
    main()
Problem p02901 (python)

Fixed submission:
def main():
    N, M = map(int, input().split())
    INF = float('inf')
    
    L = 2 ** N
    dp = [INF] * L
    dp_next = [INF] * L
    
    nums = [2 ** i for i in range(N)]
    
    for i in range(M):
        a, b = map(int, input().split())
        b = sum([nums[c-1] for c in list(map(int, input().split()))])            
    
        dp[b] = min(dp[b], a)
        for j in range(L):
            n = j | b
            dp_next[n] = min(dp[n], dp_next[n], dp[j]+a)
        
        for j in range(L):
            dp[j] = dp_next[j]
            
    if dp[-1] == INF: print(-1)
    else: print(dp[-1])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
A = [0] * M
C = [0] * M
for i in range(M):
    a, b = list(map(int, input().split()))
    A[i] = a
    c = list(map(int, input().split()))
    n = ['0'] * N
    for j in range(b):
        n[N-c[j]-2] = '1'
    C[i] = int(''.join(n), 2)

INF = float('inf')

dp = [[INF for i in range(2**N)] for j in range(M+1)]
dp[0][0] = 0

for i in range(1, M+1):
    for j in range(2**N):
        dp[i][j] = dp[i-1][j]

    for j in range(2**N):
        dp[i][j | C[i-1]] = min(dp[i][j | C[i-1]], dp[i-1][j | C[i-1]], dp[i-1][j]+A[i-1])

ans = dp[M][-1]
if ans == INF: ans = -1
print(ans)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()

ans = 0

for s, t in zip(S, T):
    ans += s == t
print(ans)

Buggy submission (verdict: Runtime Error):
print(sum([s == t fot s, t in zip(input(), input())]))
Problem p02936 (python)

Fixed submission:
from collections import deque

def main():
  N, Q = map(int, input().split())
  visited = [False] * (N+1)
  graph = {i:deque() for i in range(N+1)}

  for i in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

  visited[1] = True

  c = [0] * (N+1)
  for i in range(Q):
    p, x = map(int, input().split())
    c[p] += x
    
  q = [1]
  while q:
    per = q.pop()
    for child in graph[per]:
      if not visited[child]:
        visited[child] = True
        c[child] += c[per]
        q.append(child)

  for i in range(1, N+1):
    print(c[i], '', end='')

if __name__ == '__main__':
  main()

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

def dfs(v, p=-1):
    for u in to[v]:
        if u == p: continue
        ans[u] += ans[v]
        dfs(u, v)
    
def main():
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
        
    for i in range(Q):
        p, x = map(int, input().split())
        ans[p-1] += x
        
    dfs(0)
    
    for a in ans: print(a)

if __name__ == '__main__':
    N, Q = map(int, input().split())
    to = [[] for i in range(200005)]
    ans = [0] * N
    
    main()

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

def dfs(v, p=-1):
    for u in to[v]:
        if u == p: continue
        ans[u] += ans[v]
        dfs(u, v)
    
def main():
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
        
    for i in range(Q):
        p, x = map(int, input().split())
        ans[p-1] += x
        
    dfs(0)
    
    for a in ans: print(a)

if __name__ == '__main__':
    N, Q = map(int, input().split())
    to = [[] for i in range(N)]
    ans = [0] * N
    
    main()

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

def dfs(v, p=-1):
    for u in to[v]:
        if u == p: continue
        ans[u] += ans[v]
        dfs(u, v)
    
def main():
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
        
    for i in range(Q):
        p, x = map(int, input().split())
        ans[p-1] += x
        
    dfs(0)
    
    print(' '.join(map(str, ans)))

if __name__ == '__main__':
    N, Q = map(int, input().split())
    to = [[] for i in range(N)]
    ans = [0] * N
    
    main()

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
child_per = {1:0}
for i in range(N-1):
  a, b = map(int, input().split())
  child_per[b] = a
  
c = [0] * (N+1)
for i in range(Q):
  p, x = map(int, input().split())
  c[p] += x

for i in range(1, N+1):
  c[i] += c[child_per[i]]
  print(c[i], '', end='')
Problem p02937 (python)

Fixed submission:
import sys
from bisect import bisect_right

def main():
    s = input()
    t = input()
    
    table = {a : [] for a in 'abcdefghijklmnopqrstuvwxyz'}
    N = len(s)
    
    for idx, a in enumerate(s): table[a].append(idx+1)
    
    length = {a : len(table[a]) for a in 'abcdefghijklmnopqrstuvwxyz'}
    
    loop, idx = 0, 0
    for a in t:
        if not table[a]: 
            print(-1)
            sys.exit()
        
        i = bisect_right(table[a], idx)
        
        if i != length[a]:
            idx = table[a][i]
            if idx == N:
                loop += 1
                idx = 0
        else:
            loop += 1
            idx = table[a][0]
            
    print(loop * len(s) + idx)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_right

def main():
    s = input()
    t = input()
    
    table = {a : [] for a in 'abcdefghijklmnopqrstuvwxyz'}
    N = len(s)
    
    for idx, a in enumerate(s): table[a].append(idx+1)
    
    length = {a : len(table[a]) for a in 'abcdeghijklmnopqrstuvwxyz'}
    
    loop, idx = 0, 0
    for a in t:
        if not table[a]: 
            print(-1)
            sys.exit()
        
        i = bisect_right(table[a], idx)
        
        if i != length[a]:
            idx = table[a][i]
            if idx == N:
                loop += 1
                idx = 0
        else:
            loop += 1
            idx = table[a][0]
            
    print(loop * len(s) + idx)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_left

def main():
    s = input()
    t = input()
    
    table = {a : [] for a in 'abcdefghijklmnopqrstuvwxyz'}
    
    for idx, a in enumerate(s): table[a].append(idx+1)
    
    length = {a : len(table[a]) for a in 'abcdeghijklmnopqrstuvwxyz'}
    
    loop, idx = 0, 1
    for a in t:
        if not table[a]: 
            print(-1)
            sys.exit()
            
        i = bisect_left(table[a], idx)
    
        if i == length[a]:
            loop += 1
            idx = table[a][0]
        else:
            idx = table[a][i]
            
    print(loop * len(s) + idx)

if __name__ == '__main__':
    main()
Problem p02995 (python)

Fixed submission:
#import math
import fractions as math

A, B, C, D = list(map(int, input().split()))
ans = []
x = int((C*D)/math.gcd(C,D))

for n in [A-1, B]:
    c = n // C
    d = n // D
    cd = n // x
    ans.append(n-c-d+cd)
print(ans[1]-ans[0])

Buggy submission (verdict: Runtime Error):
import fractions as gcd

def lcm(x, y):
    return (x*y) // gcd(x, y)

A, B, C, D = map(int, input().split())

c = B // C - A // C + (not A % C)
d = B // D - A // D + (not A % D)

x = lcm(C, D)
x = B // x - A // x + (not A % x)

print(B-A+1-c-d+x)

Buggy submission (verdict: Runtime Error):
from math import gcd

def lcm(x, y):
    return (x*y) // gcd(x, y)

A, B, C, D = map(int, input().split())

c = B // C - A // C + (not A % C)
d = B // D - A // D + (not A % D)

x = lcm(C, D)
x = B // x - A // x + (not A % x)

print(B-A+1-c-d+x)
Problem p03001 (python)

Fixed submission:
W, H, x, y = list(map(int, input().split()))
z = [0, 1]
print(W*H/2, z[x*2 == W and y*2 == H])

Buggy submission (verdict: Runtime Error):
def check(ans, ans_, n):
    if ans == n:
        ans_ = 1
    elif ans < n:
        ans = n
    return ans, ans_

W, H, x, y = list(map(int, input().split()))
total = W * H

ans = min(H*x, total-H*x)
ans_ = 0
ans, ans_ = check(ans, ans_, min(W*y, total-W*y))

for w, h, y_ in [(0, 0, H), (W, 0, H)]:
    a = (y-h) / (x-w)
    x_ = abs(y_ / a)
    if x_ < H/2:
        n = W * y_ / 2
    else:
        n = H * x_ / 2
    ans, ans_ = check(ans, ans_, min(n, total-n))

for w, h, x_ in [(0, H, W), (W, H, W)]:
    a = (y-h) / (x-w)
    y_ = x_ * a
    if y_ >= 0:
        n = (H - y_) * x_ / 2
    else:
        n = y_ * x_ / 2
    ans, ans_ = check(ans, ans_, min(n, total-n))

print(ans, ans_)
Problem p03061 (python)

Fixed submission:
#import math
import fractions as math

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

gcd_l, gcd_r = [0], [0]

for l, r in [(A[i], A[N-i-1]) for i in range(N)]:
    gcd_l.append(math.gcd(gcd_l[-1], l))
    gcd_r.append(math.gcd(gcd_r[-1], r))
gcd_r.reverse()

gcd_nums = [gcd_l[-1]] + [math.gcd(gcd_l[i], gcd_r[i+1]) for i in range(N)]
print(max(gcd_nums))

Buggy submission (verdict: Runtime Error):
import math

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

gcd_l, gcd_r = [0], [0]

for l, r in [(A[i], A[N-i-1]) for i in range(N)]:
    gcd_l.append(math.gcd(gcd_l[-1], l))
    gcd_r.append(math.gcd(gcd_r[-1], r))
gcd_r.reverse()

gcd_nums = [gcd_l[-1]] + [math.gcd(gcd_l[i], gcd_r[i+1]) for i in range(N)]
print(max(gcd_nums))

Buggy submission (verdict: Runtime Error):
#import math
import fraction as math

N = int(input())
A = list(map(int, input().split()))
memo = {}
x = A[1]
for a in A[2:]:
    n = math.gcd(x, a)
    memo[(x, a)] = n
    x = n
max_gcd = x

for i in range(N):
    x = A[0]
    for j in range(N):
        if i == j:
            pass
        else:
            if (x, A[j]) in memo:
                x = memo[(x, A[j])]
            else:
                n = math.gcd(x, A[j])
                memo[(x, A[j])] = n
                x = n
    max_gcd = max(max_gcd, x)
print(max_gcd)
Problem p03088 (python)

Fixed submission:
import itertools

s = 'ACGT'
s = [a+b+c for a,b,c in itertools.product(s,s,s)]
n = {s_:1 for s_ in s}
n['AGC'] = 0
n['GAC'] = 0
n['ACG'] = 0

N = int(input())
if N == 3:
    count = n
else:
    for i in range(N-3):
        count = {s_:0 for s_ in s}
        for _ in s:
            for a in 'ACGT':
                x = _+a
                if 'GAC' in x or 'ACG' in x or ('A' == x[0] and 'GC' == x[2:]) or ('AG' == x[:2] and 'C' == x[3]):
                    pass
                else:
                    count[x[1:]] += n[_]
        count['AGC'] = 0
        count['GAC'] = 0
        count['ACG'] = 0
        n = count
print(sum([value for value in count.values()])%(10**9+7))

Buggy submission (verdict: Runtime Error):
import itertools

s = 'ACGT'
s = [a+b+c for a,b,c in itertools.product(s,s,s)]
n = {s_:1 for s_ in s}
n['AGC'] = 0
n['GAC'] = 0
n['ACG'] = 0

N = int(input())

for i in range(N-3):
    count = {s_:0 for s_ in s}
    for _ in s:
        for a in 'ACGT':
            x = _+a
            if 'GAC' in x or 'ACG' in x or ('A' == x[0] and 'GC' == x[2:]) or ('AG' == x[:2] and 'C' == x[3]):
                pass
            else:
                count[x[1:]] += n[_]
    count['AGC'] = 0
    count['GAC'] = 0
    count['ACG'] = 0
    n = count
print(sum([value for value in count.values()])%(10**9+7))
Problem p03111 (python)

Fixed submission:
def search(idx, a, b, c):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**20
            
    n0 = search(idx+1, a, b, c)
    n1 = search(idx+1, a+l[idx], b, c) + 10
    n2 = search(idx+1, a, b+l[idx], c) + 10
    n3 = search(idx+1, a, b, c+l[idx]) + 10
    
    return min(n0, n1, n2, n3)
    
N, A, B, C = list(map(int, input().split()))
l = [int(input()) for i in range(N)]

print(search(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
import bisect

ans = 10**20

N, K = list(map(int, input().split()))
x = [-10**20] + list(map(int, input().split())) + [10**20]

zero = bisect.bisect_left(x, 0)

left = x[:zero] + [0] 
right = [0] + x[zero:]
left.reverse()
l = len(left)
r = len(right)

idxs = [[K-i, i] for i in range(K+1) if K-i < l and i < r]

for l, r in idxs:
    n = abs(left[l]) + right[r] + min(abs(left[l]), right[r])
    ans = min(ans, n)
print(ans)
Problem p03128 (python)

Fixed submission:
a = [2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = list(map(int, input().split()))
A = sorted(set(list(map(int, input().split()))), reverse=True)
B = sorted([a[i-1] for i in A])

dp = [-1] * (N+1)
for b in B:
    if b < N+1:
        dp[b] = 1

for i in range(1, N+1):
    for b in B:
        if i < b:
            break
        else:
            dp[i] = max(dp[i], dp[i-b]+1)
digit = dp[-1]

for n in A:
    x = a[n-1]
    if N-x >= 0:
        while dp[N-x] == digit-1:
            print(n, end='')
            N -= x
            digit -= 1
        if N == x:
            print(n, end='')
            N -= x

Buggy submission (verdict: Runtime Error):
a = [2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = list(map(int, input().split()))
A = sorted(set(list(map(int, input().split()))), reverse=True)
B = sorted([a[i-1] for i in A])

dp = [-1] * (N+1)
for b in B:
    dp[b] = 1

for i in range(1, N+1):
    for b in B:
        if i < b:
            break
        else:
            dp[i] = max(dp[i], dp[i-b]+1)
digit = dp[-1]

for n in A:
    x = a[n-1]
    while dp[N-x] == digit-1:
        print(n, end='')
        N -= x
        digit -= 1
    if N == x:
        print(n, end='')
        N -= x

Buggy submission (verdict: Runtime Error):
a = [2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = list(map(int, input().split()))
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted([a[i-1] for i in A])

dp = [-1] * (N+1)
for b in B:
    dp[b] = 1

for i in range(1, N+1):
    for b in B:
        if i < b:
            break
        else:
            dp[i] = max(dp[i], dp[i-b]+1)
digit = dp[-1]

for n in A:
    x = a[n-1]
    while dp[N-x] == digit-1:
        print(n, end='')
        N -= x
        digit -= 1
    if N == x:
        print(n, end='')
        N -= x

Buggy submission (verdict: Runtime Error):
def search(N, idx):
    global a, M, count

    if N == 0:
        return True
    elif N < 0:
        return False
    elif idx == M:
        return False

    loop = N // a[idx][0]
    for i in range(loop, -1, -1):
        flag = search(N-a[idx][0]*i, idx+1)
        if flag:
            if i:
                count.append([a[idx][1], i])
            return True

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

if 6 in A and 9 in A:
    A.remove(6)

if 5 in A or 3 in A:
    if 2 in A:
        A.remove(2)
    if 5 in A and 3 in A:
        A.remove(3)

x = [2,5,5,4,5,6,3,7,6]
a = [[x[A[i]-1],i] for i in range(len(A))]
count = []
a.sort()

search(N, 0)

nums = [[A[count[i][0]], count[i][1]] for i in range(len(count))]

nums.sort(reverse=True)

for i in range(len(nums)):
    print(str(nums[i][0]) * nums[i][1], end='')
Problem p03211 (python)

Fixed submission:
s = input()

min_num = 753

for i in range(len(s)-2):
    num = abs(int(s[i:i+3]) - 753)
    if num < min_num:
        min_num = num
print(min_num)

Buggy submission (verdict: Runtime Error):
s = np.array(list(map(int, input())))
     
idx = np.array([[i, i+1, i+2] for i in range(len(s)-2)])

total = np.sum(np.abs(s[idx] - [7,5,3])*[100,10,1], axis=1)
        
print(np.min(total))