Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

c = combinations(x, k)

# print(list(c))

ans = 10 ** 10

for g in c:
    a = max(0, max(g))
    b = min(0, min(g))
    # print(a, b)
    if (a * b) < 0:
        tmp = min(2 * abs(a) + abs(b), 2 * abs(b) + abs(a))
    else:
        tmp = abs(a) + abs(b)
    ans = min(ans, tmp)

print(ans)


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

# c = combinations(x, k)
c = []
for i in range(n - k + 1):
    l = x[i]
    r = x[i + k - 1]
    c.append([l, r])


# print(list(c))

ans = 10 ** 10

for l, r in c:
    tmp = min(abs(l) + abs(r - l), abs(r) + abs(r - l))
    ans = min(ans, tmp)

# for g in c:
#     a = max(0, max(g))
#     b = min(0, min(g))
#     # print(a, b)
#     if (a * b) < 0:
#         tmp = min(2 * abs(a) + abs(b), 2 * abs(b) + abs(a))
#     else:
#         tmp = abs(a) + abs(b)
#     ans = min(ans, tmp)

print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import exit

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

if A == B == C:
    print(0)
    exit()

if abs(A - B) > 10 ** 18:
    print("Unfair")
    exit()

sign = A - B // abs(A - B)

if K % 2 == 0:
    print(abs(A - B) * sign)
else:
    print(abs(A - B) * sign * (-1))


Fixed submission:
from sys import exit

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


if A == B:
    print(0)
    exit()

if abs(A - B) > 10 ** 18:
    print("Unfair")
    exit()

sign = (A - B) // abs(A - B)


if K % 2 == 0:
    print(abs(A - B) * sign)
else:
    print(abs(A - B) * sign * (-1))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print('YES' if 0 < x-a < b else 'NO')


Fixed submission:
a, b, x = map(int, input().split())
print("YES" if 0 <= x - a < b else "NO")
Buggy python submission (verdict: Runtime Error):
import copy

a, b, k = map(int, input().split())

num = copy.deepcopy(list(range(a, b + 1)))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k + k_e)
ans_list = copy.deepcopy(list(ans_set))
ans_list.sort()
for i in ans_list:
    print(i)


Fixed submission:
a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):
  print(i)

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

num = list(range(a, b + 1))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k + k_e)
ans_list = list(ans_set)
ans_list.sort()
for i in ans_list:
    print(i)


Fixed submission:
a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):
  print(i)

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

num = list(range(a, b + 1))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k + k_e)
ans_list = list(ans_set)
ans_list.sort()
for i in ans_list:
    print(i)


Fixed submission:
a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):
  print(i)

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

num = list(range(a, b + 1))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k) | set(k_e)
for i in sorted(ans_set):
    print(i)


Fixed submission:
a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):
  print(i)

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

num = list(range(a, b + 1))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k) | set(k_e)
for i in sorted(list(ans_set)):
    print(i)


Fixed submission:
a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):
  print(i)

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

num = list(range(a, b + 1))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k + k_e)
for i in sorted(list(ans_set)):
    print(i)


Fixed submission:
a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):
  print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 2
b = 1
if n < 2:
    print(n)
else:
    for i in range(n - 1):
        c = a + b
        a = b
        b = c
print(c)


Fixed submission:
n = int(input())
a = 2
b = 1
if n == 0:
    print(2)
elif n == 1:
    print(1)
else:
    for i in range(n - 1):
        c = a + b
        a = b
        b = c
    print(c)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

# print(a, b, c)

ans = 0
for i in range(n):
    idx_b = bisect_right(b, a[i])
    # select_b = n - idx_b
    for j in range(idx_b, n):
        idx_c = bisect_right(c, b[j])
        select_c = n - idx_c
        ans += select_c
print(ans)



Fixed submission:
from bisect import bisect_left, bisect_right

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

# print(a, b, c)

ans = 0

for i in range(n):
    idx_a = bisect_left(a, b[i])
    select_b = idx_a

    idx_c = bisect_right(c, b[i])
    select_c = n - idx_c
    ans += select_b * select_c

# for i in range(n):
#     idx_b = bisect_right(b, a[i])
#     # select_b = n - idx_b
#     for j in range(idx_b, n):
#         idx_c = bisect_right(c, b[j])
#         select_c = n - idx_c
#         ans += select_c
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

# いもす法 imos法

imos = [0] * (10 ** 5 + 1)

for i in range(N):
    l, r, s = a[i] - 1, a[i] + 1, 1
    l += 1
    r += 1
    # print(l, r)
    imos[l] += s
    imos[r + 1] -= s

for i in range(N + 1):
    imos[i + 1] = imos[i] + imos[i + 1]

# print(imos[: max(a) + 3])

print(max(imos[: max(a) + 3]))


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

imos = [0] * (10 ** 5 + 10)

for i in range(N):
    l, r, s = a[i] - 1, a[i] + 1, 1
    l += 1
    r += 1
    # print(l, r)
    imos[l] += s
    imos[r + 1] -= s

for i in range(N + 1):
    imos[i + 1] = imos[i] + imos[i + 1]

# print(imos[: max(a) + 3])

print(max(imos[: max(a) + 3]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

b = []

for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(*b)


Fixed submission:
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()


for i in range(n):
    if i % 2 == 0:
        b.appendleft(a[i])
    else:
        b.append(a[i])
if n % 2 == 0:
    b = list(b)[::-1]
print(*b)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right
from collections import Counter

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

rate = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]

idx = []

for a in A:
    idx.append(bisect_right(rate, a))

# print(idx)

c = Counter(idx)

print(c)/

min_c = len(c.keys())
if (7 in c.keys()) and (8 in c.keys()):
    min_c -= 1
max_c = 0
for i in range(8):
    if i in c.keys():
        max_c += 1
if 8 in c.keys():
    # min_c -= 1
    # max_c += min(8, c[8])
    max_c += c[8]
    # if max_c > 8:
    #     max_c = 8

print(min_c, max_c)


Fixed submission:
from bisect import bisect_right
from collections import Counter

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

rate = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]

idx = []

for a in A:
    idx.append(bisect_right(rate, a))

# print(idx)

c = Counter(idx)



min_c = len(c.keys())
if (7 in c.keys()) and (8 in c.keys()):
    min_c -= 1
max_c = 0
for i in range(8):
    if i in c.keys():
        max_c += 1
if 8 in c.keys():
    # min_c -= 1
    # max_c += min(8, c[8])
    max_c += c[8]
    # if max_c > 8:
    #     max_c = 8

print(min_c, max_c)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

if (A / 2) % 2 == 1 and (B / 2) % 2 == 1 and (C / 2) % 2 == 1:
    print(-1)
    sys.exit()

cnt = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    a = B // 2 + C // 2
    b = A // 2 + C // 2
    c = A // 2 + B // 2
    A = a
    B = b
    C = c
    cnt += 1
print(cnt)


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


def F(a, b, c):
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        return 0
    if a == b == c:
        return -1
    return F((a + b) // 2, (b + c) // 2, (c + a) // 2) + 1


print(F(A, B, C))
Buggy python submission (verdict: Runtime Error):
o = list(input())
e = list(input())=['']

for i in range( len(o) ) :
  print(o[i]+e[i],end="")

Fixed submission:
o = list(input())
e = list(input())+['']

for i in range( len(o) ) :
  print(o[i]+e[i],end="")

Buggy python submission (verdict: Runtime Error):
o = list(input())
e = list(input())

for i in range( len(o) ) :
  print(o[i]+e[i],end="")

Fixed submission:
o = list(input())
e = list(input())+['']

for i in range( len(o) ) :
  print(o[i]+e[i],end="")
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = factorial(n) % (10 ** 9 + 7)
print(ans)


Fixed submission:
from math import factorial

n = int(input())
ans = factorial(n) % (10 ** 9 + 7)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        for z in range(0, k + 1):
            if x + y + z == s:
                ans += 1
print(ans)


Fixed submission:
k, s = map(int, input().split())

ans = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        if 0 <= s - (x + y) <= k:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N, X, M = map(int, input().split())

A = [X]
vis = [-1] * M
vis[X] = 0
for i in range(1, M):
    X = X ** 2 % M
    if vis[X] != -1:
        pref = A[:vis[X]]
        cycle = A[vis[X]:]
        break
    A.append(X)
    vis[X] = i

n_full_period = (N - len(pref)) // len(cycle)
suffix_length = N - len(pref) - n_full_period * len(cycle)

ans = 0
ans += sum(pref)
ans += sum(cycle) * n_full_period
ans += sum(cycle[:suffix_length])
print(ans)

Fixed submission:
'''
Doubling

nxt[i][r] = the value of r mod M after 2 ** i squaring
dp[i][r] = the sum of sequence of lenght 2 ** i starting from r

We split sequence A into multiple disjoint parts, 
where the lengths of each parts are the binary decomposition of N.

e.g.
N = 11 = 1 + 2 + 8
A = A[0:1], A[1:3], A[3:11]
Sum of each parts are:
sum(A[0:1]) = dp[0][A[0] % M]
sum(A[1:3]) = dp[1][A[1] % M]
sum(A[3:11]) = dp[3][A[3] % M]
'''

import math

N, X, M = map(int, input().split())

H = math.ceil(math.log2(N)) + 1

nxt = [[0] * M for _ in range(H)]
dp = [[0] * M for _ in range(H)]
nxt[0] = [r ** 2 % M for r in range(M)]
dp[0] = list(range(M))

for i in range(1, H):
    for r in range(M):
        nxt[i][r] = nxt[i - 1][nxt[i - 1][r]]
        dp[i][r] = dp[i - 1][r] + dp[i - 1][nxt[i - 1][r]]

ans = 0
r = X % M
for i in range(H):
    if N & (1 << i):
        ans += dp[i][r]
        r = nxt[i][r]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = 10**9 + 7

dp = [0] * (N + 1)

dp[3] = 1
dp[4] = 1
dp[5] = 1
for i in range(6, N + 1):
    dp[i] = sum(dp[3:i - 3 + 1]) + 1
    dp[i] %= M

print(dp[-1] % M)

Fixed submission:
N = int(input())
M = 10**9 + 7

if N < 3:
    print(0)
elif N < 6:
    print(1)
else:
    dp = [0] * (N + 1)

    dp[3] = 1
    dp[4] = 1
    dp[5] = 1
    for i in range(6, N + 1):
        dp[i] = sum(dp[3:i - 3 + 1]) + 1
        dp[i] %= M

    print(dp[-1] % M)
Buggy python submission (verdict: Runtime Error):
def solve():
    N = int(input())

    xs, ys = [], []
    for _ in range(N):
        x, y = map(int, input().split())
        xs.append(x)
        ys.append(y)
    
    T, B = max(ys), min(ys)
    L, R = min(xs), max(xs)

    # print(T, B, L, R)

    if T == B:
        return abs(R - L)

    if L == R:
        return abs(T - B)

    # T, B
    top_l, top_r = 10**10, -1
    bot_l, bot_r = 10**10, -1
    for i in range(N):
        if ys[i] == T:
            top_l = min(top_l, xs[i])
            top_r = max(top_r, xs[i])
        if ys[i] == B:
            bot_l = min(bot_l, xs[i])
            bot_r = max(bot_r, xs[i])

    # print(top_l, top_r)
    # print(bot_l, bot_r)

    # L, R
    left_t, left_b = -1, 10**10
    right_t, right_b = -1, 10**10
    for i in range(N):
        if xs[i] == L:
            left_t = max(left_t, ys[i])
            left_b = min(left_b, ys[i])
        if xs[i] == R:
            right_t = max(right_t, ys[i])
            right_b = min(right_b, ys[i])

    # print(left_t, left_b)
    # print(right_t, right_b)

    ans = -1
    for i in range(N):
        if ys[i] == T:
            d1 = abs(T - B) + abs(xs[i] - bot_l)
            d2 = abs(T - B) + abs(xs[i] - bot_r)
            ans = max(ans, max(d1, d2))
        if ys[i] == B:
            d1 = abs(T - B) + abs(xs[i] - top_l)
            d2 = abs(T - B) + abs(xs[i] - top_r)
            ans = max(ans, max(d1, d2))
        if xs[i] == L:
            d1 = abs(R - L) + abs(ys[i] - right_t)
            d1 = abs(R - L) + abs(ys[i] - right_b)
            ans = max(ans, max(d1, d2))
        if xs[i] == R:
            d1 = abs(R - L) + abs(ys[i] - left_t)
            d1 = abs(R - L) + abs(ys[i] - left_b)
            ans = max(ans, max(d1, d2))
    return ans


print(solve())
            

Fixed submission:
N = int(input())
xs, ys = [], []
for _ in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
A = [x + y for x, y in zip(xs, ys)]
B = [x - y for x, y in zip(xs, ys)]
ans = max([max(A) - min(A), max(B) - min(B)])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def prod(X):
    val = 1
    for x in X:
        val = val * x
    return val

N, K = map(int, input().split())
A = list(map(int, input().split()))
G = [prod(A[:K])]
for i in range(K, N):
    val = G[-1] // A[i - K] * A[i]
    G.append(val)
# print(G)

for i in range(1, len(G)):
    print('Yes' if G[i] > G[i - 1] else 'No')

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

for i in range(K, N):
    print('Yes' if A[i] > A[i - K] else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

ttl = sum(A)
cnt = Counter(A)

Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())
    
    if b in cnt:
        occ = cnt.pop(b)
        ttl = ttl - b * occ
        cnt = cnt + Counter({c: occ})
        ttl = ttl + c * occ
    
    print(ttl)

Fixed submission:
from collections import defaultdict

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

cnt = defaultdict(int)
for a in A:
    cnt[a] += 1
ttl = sum(A)

Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())
    
    if b in cnt:
        occ = cnt.pop(b)
        cnt[c] += occ
        ttl = ttl - b * occ + c * occ
    
    print(ttl)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = np.int32(A) - 1

nxt = np.zeros((60, N), dtype=int)
nxt[0] = A
for i in range(0, 59):
    for j in range(N):
        nxt[i + 1, j] = nxt[i, nxt[i, j]]

bits = reversed(bin(K)[2:])
pos = 0
for i, v in enumerate(bits):
    if v == '1':
        pos = nxt[i, pos]

print(pos + 1)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = np.int32(A) - 1

nxt = np.zeros((70, N), dtype=int)
nxt[0] = A
for i in range(0, 69):
    nxt[i + 1] = nxt[i, nxt[i]]

pos = 0
for i, v in enumerate(reversed(bin(K)[2:])):
    if v == '1':
        pos = nxt[i, pos]

print(pos + 1)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import maxsize
from itertools import product

n, k = map(int, input().split())
p = list(map(lambda x: int(x)-1, input().split()))
c = list(map(int, input().split()))

used = [0] * n
ss = []
for i in range(n):
    if used[i]:
        continue
    now = i
    s = []
    while not used[now]:
        used[now] = 1
        s.append(c[now])
        now = p[now]
    ss.append(s)

res = -maxsize
for s in ss:
    s_len = len(s)
    cumsum = [0]
    # 2周分の累積和
    for i in range(2*s_len):
        cumsum.append(cumsum[-1] + s[i%s_len])

    max_sum = [-maxsize] * s_len
    for i, j in product(range(s_len), repeat=2):
        max_sum[j] = max(max_sum[j], cumsum[i+j] - cumsum[i])

    for i in range(s_len):
        if i > k:
            continue
        v = (k - i) // s_len
        if i == 0 and v == 0:
            continue
        if cumsum[s_len] > 0:
            res = max(res, max_sum[i] + cumsum[s_len] * v)
        elif i > 0:
            res = max(res, max_sum[i])
print(res)


Fixed submission:
from sys import maxsize
from itertools import product

n, k = map(int, input().split())
p = list(map(lambda x: int(x)-1, input().split()))
c = list(map(int, input().split()))

used = [0] * n
ss = []
for i in range(n):
    if used[i]:
        continue
    now = i
    s = []
    while not used[now]:
        used[now] = 1
        s.append(c[now])
        now = p[now]
    ss.append(s)

res = -maxsize
for s in ss:
    s_len = len(s)
    cumsum = [0]
    # 2周分の累積和
    for i in range(2*s_len):
        cumsum.append(cumsum[-1] + s[i%s_len])

    max_sum = [-maxsize] * s_len
    for i, j in product(range(s_len), repeat=2):
        max_sum[j] = max(max_sum[j], cumsum[i+j] - cumsum[i])

    for i in range(s_len):
        if i > k:
            continue
        v = (k - i) // s_len
        if i == 0 and v == 0:
            continue
        if cumsum[s_len] > 0:
            res = max(res, max_sum[i] + cumsum[s_len] * v)
        elif i > 0:
            res = max(res, max_sum[i])
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    i = 7
    while True:
        if i % k == 0:
            print(len(str(i)))
            break
        i *= 10
        i += 7


Fixed submission:
from itertools import count

k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    m = 0
    for i in count(0):
        m += pow(10, i, k) * 7
        m %= k
        if m == 0:
            print(i+1)
            break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = input()

popcount = x.count('1')
p = int(x, 2) % (popcount + 1)
q = int(x, 2) % (popcount - 1) if popcount != 1 else 0
for i in range(n):
    if x[i] == '0':
        y = (p + 2**(n-i-1) % (popcount + 1)) % (popcount + 1)
    else:
        if popcount != 1:
            y = (q - 2**(n-i-1) % (popcount - 1)) % (popcount - 1)
        else:
            print(0)
            continue
    cnt = 1
    while y != 0:
        y %= bin(y).count('1')
        cnt += 1
    print(cnt)


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

popcount = x.count('1')
p = int(x, 2) % (popcount + 1)
q = int(x, 2) % (popcount - 1) if popcount != 1 else 0
for i in range(n):
    if x[i] == '0':
        y = (p + pow(2, n-i-1, popcount+1)) % (popcount + 1)
    else:
        if popcount != 1:
            y = (q - pow(2, n-i-1, popcount-1)) % (popcount - 1)
        else:
            print(0)
            continue
    cnt = 1
    while y != 0:
        y %= bin(y).count('1')
        cnt += 1
    print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import deque

n, m, k = map(int, input().split())
a = deque(map(int, input().split()))
b = deque(map(int, input().split()))

t = 0
res = 0
while a or b:
    if not a:
        if t + b[0] > k:
            break
        else:
            t += b.popleft()
    elif not b:
        if t + a[0] > k:
            break
        else:
            t += a.popleft()
    else:
        if t + a[0] > k and t + b[0] > k:
            break
        if a[0] < b[0]:
            t += a.popleft()
        elif a[0] > b[0]:
            t += b.popleft()
        else:
            if a[1] < b[1]:
                t += a.popleft()
            else:
                t += b.popleft()
    res += 1
print(res)


Fixed submission:
from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_cumsum = [0] + list(accumulate(a))
b_cumsum = [0] + list(accumulate(b))
j = m
res = 0
for i in range(n+1):
    if a_cumsum[i] > k:
        break
    while a_cumsum[i] + b_cumsum[j] > k:
        j -= 1
    if (v := i + j) > res:
        res = v
print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted([int(i) for i in input().split()])

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    prev = a[i-1] if i > 0 else -1
    next = a[i+1] if i < n-1 else -1
    if a[i] == prev or a[i] == next:
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))


Fixed submission:
import numpy as np

n = int(input())
a = sorted(list(map(int, input().split())))

non_divisible = np.ones(a[-1]+1, dtype=np.int8)
non_divisible[0] = 0
for i in range(n):
    if i != 0 and a[i] == a[i-1]:
        non_divisible[a[i]] = 0
    elif non_divisible[a[i]]:
        non_divisible[a[i]*2::a[i]] = 0

res = 0
for aa in a:
    if non_divisible[aa]:
        res += 1

print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    prev = a[i-1] if i > 0 else -1
    next = a[i+1] if i < n-1 else -1
    if a[i] == prev or a[i] == next:
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))


Fixed submission:
import numpy as np

n = int(input())
a = sorted(list(map(int, input().split())))

non_divisible = np.ones(a[-1]+1, dtype=np.int8)
non_divisible[0] = 0
for i in range(n):
    if i != 0 and a[i] == a[i-1]:
        non_divisible[a[i]] = 0
    elif non_divisible[a[i]]:
        non_divisible[a[i]*2::a[i]] = 0

res = 0
for aa in a:
    if non_divisible[aa]:
        res += 1

print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    if a[i] == a[i-1]:
        if res and a[i] == res[-1]:
            res.pop()
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))


Fixed submission:
import numpy as np

n = int(input())
a = sorted(list(map(int, input().split())))

non_divisible = np.ones(a[-1]+1, dtype=np.int8)
non_divisible[0] = 0
for i in range(n):
    if i != 0 and a[i] == a[i-1]:
        non_divisible[a[i]] = 0
    elif non_divisible[a[i]]:
        non_divisible[a[i]*2::a[i]] = 0

res = 0
for aa in a:
    if non_divisible[aa]:
        res += 1

print(res)