Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
P = [[] for i in range(N)]
L = [[] for i in range(M)]
for i in range(N):
    I = list(map(int, input().split()))
    for l in I[1:]:
        P[i].append(l-1)
        L[l-1].append(i)

P_visited = [0] * N
L_visited = [0] * M


# flgが立っていれば、人を見ているとする
def dfs(n, flg):
    if flg:
        P_visited[n] = 1
        for l in P[n]:
            if not L_visited[l]:
                dfs(l, flg ^ 1)
    else:
        L_visited[n] = 1
        for p in L[n]:
            if not P_visited[p]:
                dfs(p, flg ^ 1)


dfs(0, 1)
print("YES" if all(P_visited) else "NO")


Fixed submission:
import sys
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
P = [[] for i in range(N)]
L = [[] for i in range(M)]
for i in range(N):
    I = list(map(int, input().split()))
    for l in I[1:]:
        P[i].append(l-1)
        L[l-1].append(i)

P_visited = [0] * N
L_visited = [0] * M


# flgが立っていれば、人を見ているとする
def dfs(n, flg):
    if flg:
        P_visited[n] = 1
        for l in P[n]:
            if not L_visited[l]:
                dfs(l, flg ^ 1)
    else:
        L_visited[n] = 1
        for p in L[n]:
            if not P_visited[p]:
                dfs(p, flg ^ 1)


dfs(0, 1)
print("YES" if all(P_visited) else "NO")
Buggy python submission (verdict: Runtime Error):
a, b, c = map((int, input().split()))
if (a==b+c) or (b==c+a) or (c==a+b):
    print("Yes")
else:
    print("No")

Fixed submission:
a, b, c = map(int, input().split())
if (a==b+c) or (b==c+a) or (c==a+b):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, T = map(int, input().split())
A = list(map(int, input().split()))

B = [max(A[i:]) for i in range(1, N)]

ans = 0
maxv = 0
for i in range(N-1):
    z = B[i] - A[i]
    if maxv > z:
        continue
    elif maxv < z:
        maxv = z
        ans = 1
    else:
        ans += 1

print(ans)

Fixed submission:
N, T = map(int, input().split())
A = list(map(int, input().split()))
B = A[::-1]
C = []

maxv = 0
for i in range(N):
    if maxv > B[i]:
        C.append(maxv)
    else:
        maxv = B[i]
        C.append(maxv)

C = C[::-1]

ans = 0
maxv = 0
for i in range(N-1):
    z = C[i] - A[i]
    if maxv > z:
        continue
    elif maxv < z:
        maxv = z
        ans = 1
    else:
        ans += 1

print(ans)

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

B = [A[i:] for i in range(1, N)]

ans = 0
maxv = 0
for i in range(N-1):
    z = max(B[i]) - A[i]
    if maxv > z:
        continue
    elif maxv < z:
        maxv = z
        ans = 1
    else:
        ans += 1

print(ans)



Fixed submission:
N, T = map(int, input().split())
A = list(map(int, input().split()))
B = A[::-1]
C = []

maxv = 0
for i in range(N):
    if maxv > B[i]:
        C.append(maxv)
    else:
        maxv = B[i]
        C.append(maxv)

C = C[::-1]

ans = 0
maxv = 0
for i in range(N-1):
    z = C[i] - A[i]
    if maxv > z:
        continue
    elif maxv < z:
        maxv = z
        ans = 1
    else:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]

ans = 0
pre_t = 0
pre_a = 0

for t, a in TA:
    gcdd = gcd(t, a)

    t = t * gcdd
    a = a * gcdd

    first_t = t
    first_a = a

    while (pre_t > t) or(pre_a > a):
        t += first_t
        a += first_a

    pre_t = t
    pre_a = a

print(t + a)


Fixed submission:
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]
T, A = 1, 1

for t, a in TA:
    z = max(T//t, A//a)
    if (T > t*z) or (A > a*z):
        z += 1

    T = t * z
    A = a * z

print(T+A)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]

ans = 0
pre_t = 0
pre_a = 0

for t, a in TA:
    gcd = gcd(t, a)

    t = t * gcd
    a = a * gcd

    first_t = t
    first_a = a

    while (pre_t > t) or(pre_a > a):
        t += first_t
        a += first_a

    pre_t = t
    pre_a = a
    
print(t + a)


Fixed submission:
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]
T, A = 1, 1

for t, a in TA:
    z = max(T//t, A//a)
    if (T > t*z) or (A > a*z):
        z += 1

    T = t * z
    A = a * z

print(T+A)

Buggy python submission (verdict: Runtime Error):
from fractions import _gcd
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]

ans = 0
pre_t = 0
pre_a = 0

for t, a in TA:
    gcd = _gcd(t, a)

    t = t * gcd
    a = a * gcd

    first_t = t
    first_a = a

    while (pre_t > t) or(pre_a > a):
        t += first_t
        a += first_a

    pre_t = t
    pre_a = a
    
print(t + a)


Fixed submission:
N = int(input())
TA = [list(map(int, input().split())) for i in range(N)]
T, A = 1, 1

for t, a in TA:
    z = max(T//t, A//a)
    if (T > t*z) or (A > a*z):
        z += 1

    T = t * z
    A = a * z

print(T+A)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())


Costs = {chr(98 + i): (25 - i) for i in range(25)}
Costs['a'] = 0


ans = ""
for i in range(len(S) - 1):
    s = S[i]
    if K >= Costs[s]:
        K -= Costs[s]
        ans += 'a'
    else:
        ans += s

if K:
    tail = ans[-1]
    tail_ord = ord(tail)
    ans = ans[:-1] + chr((tail_ord + K) % 97 + 97)

print(ans)


Fixed submission:
S = input()
K = int(input())
cost = [(ord("z") - ord(s) + 1) % 26 for s in S]
A = [chr(ord("a") + i) for i in range(26)]

ans = ""
for i in range(len(S)-1):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans += A[(A.index(S[-1]) + K) % 26]
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
cost = [ord("z") - ord(s) + 1 for s in S]

ans = ""
for i in range(len(S)-1):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans = ans[:-1] + chr(ord(ans[-1]) + K % 26)
print(ans)


Fixed submission:
S = input()
K = int(input())
cost = [(ord("z") - ord(s) + 1) % 26 for s in S]
A = [chr(ord("a") + i) for i in range(26)]

ans = ""
for i in range(len(S)-1):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans += A[(A.index(S[-1]) + K) % 26]
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
cost = [ord("z") - ord(s) + 1 for s in S]

ans = ""
for i in range(len(S)):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans = ans[:-1] + chr(ord(ans[-1]) + K)
print(ans)


Fixed submission:
S = input()
K = int(input())
cost = [(ord("z") - ord(s) + 1) % 26 for s in S]
A = [chr(ord("a") + i) for i in range(26)]

ans = ""
for i in range(len(S)-1):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans += A[(A.index(S[-1]) + K) % 26]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, x = map(int, input().split())
A = list(map(int, input().split())) * 2
A = A[::-1]

effective_costs = [float('inf')] * N
ans = float('inf')

# 魔法を使う回数
for k in range(N):
    cost = 0
    for i in range(N):
        effective_costs[i] = min(effective_costs[i], A[i+k])
        cost += effective_costs[i]
    ans = min(ans, cost + k * x)

print(ans)


Fixed submission:
N, x = map(int, input().split())
A = list(map(int, input().split()))
lowest_costs = A[:]
ans = float('inf')

for k in range(N):
    lowest_costs = [min(lowest_costs[i], A[i-k]) for i in range(N)]
    ans = min(sum(lowest_costs) + x * k, ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = map(int, input().split())
A = list(map(int, input().split()))
lowest_costs = A[:]
ans = float('inf')

for k in range(N):
    cost = 0
    for i in range(N):
        lowest_costs[i] = min(lowest_costs[i], A[(i-k) % N])
        cost += lowest_costs[i]
    ans = min(cost + x * k, ans)

print(ans)

Fixed submission:
N, x = map(int, input().split())
A = list(map(int, input().split()))
lowest_costs = A[:]
ans = float('inf')

for k in range(N):
    lowest_costs = [min(lowest_costs[i], A[i-k]) for i in range(N)]
    ans = min(sum(lowest_costs) + x * k, ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = map(int, input().split())
A = list(map(int, input().split()))
lowest_costs = A.copy()
A.extend(A)
ans = float('inf')

for k in range(N):
    cost = 0
    for i in range(N):
        lowest_costs[i] = min(lowest_costs[i], A[i+k])
        cost += lowest_costs[i]
    ans = min(cost + x * k, ans)

print(ans)

Fixed submission:
N, x = map(int, input().split())
A = list(map(int, input().split()))
lowest_costs = A[:]
ans = float('inf')

for k in range(N):
    lowest_costs = [min(lowest_costs[i], A[i-k]) for i in range(N)]
    ans = min(sum(lowest_costs) + x * k, ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.extend(A)

ans = float('inf')
for k in range(N):
    cost = 0
    for i in range(N):
        cost += min(A[i:i+k+1])
    ans = min(cost + x * k, ans)

print(ans)



Fixed submission:
N, x = map(int, input().split())
A = list(map(int, input().split()))
lowest_costs = A[:]
ans = float('inf')

for k in range(N):
    lowest_costs = [min(lowest_costs[i], A[i-k]) for i in range(N)]
    ans = min(sum(lowest_costs) + x * k, ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
N, A = map(int, input().split())
X = list(map(int, input().split()))
x_max = max(X)
dp = [[[0]*(N*x_max+1) for i in range(N+1)] for i in range(N+1)]
dp[0][0][0] = 1

for j in range(1, N+1):
    for k in range(N+1):
        for s in range(N*x_max+1):
            if X[j-1] <= s:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-X[j-1]]
            else:
                dp[j][k][s] = dp[j-1][k][s]

ans = 0
for i in range(1, N+1):
    ans += dp[N][i][A*i]

print(ans)

Fixed submission:
N, A = map(int, input().split())
X = list(map(int, input().split()))
x_max = max(X)
Y = [x-A for x in X]

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

for j in range(N+1):
    for t in range(2*N*x_max+1):
        if j >= 1 and 0 <= t - Y[j-1] <= 2*N*x_max:
            dp[j][t] = dp[j-1][t] + dp[j-1][t-Y[j-1]]
        elif j >= 1:
            dp[j][t] = dp[j-1][t]

print(dp[N][N*x_max]-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = int(input())

# コーナーケース
if N == S:
    print(N + 1)
    exit()


# x進数
def encode_x_base(n, x):
    ret = []
    while n:
        ret.append(n % x)
        n //= x
    return ret[::-1]


# 桁和
def digit_sum(n):
    if isinstance(n, (int, str)):
        return sum([int(d) for d in str(n)])
    if isinstance(n, list):
        return sum([int(d) for d in n])


# Bが小さいとき
for b in range(2, int(N ** 0.5) + 1):
    encoded_N = encode_x_base(N, b)
    d_sum = digit_sum(encoded_N)
    if d_sum == S:
        print(b)
        exit()

# Bが大きいときはpを全探索
for p in range(1, int(N ** 0.5) + 1):
    b = (N - S) // p + 1
    encoded_N = encode_x_base(N, b)
    d_sum = digit_sum(encoded_N)
    if d_sum == S:
        print(b)
        break
else:
    print(-1)


Fixed submission:
N = int(input())
S = int(input())

# コーナーケース
if N == S:
    print(N + 1)
    exit()


# x進数
def encode_x_base(n, x):
    ret = []
    while n:
        ret.append(n % x)
        n //= x
    return ret[::-1]


# 桁和
def digit_sum(n):
    if isinstance(n, (int, str)):
        return sum([int(d) for d in str(n)])
    if isinstance(n, list):
        return sum([int(d) for d in n])


# Bが小さいとき
for b in range(2, int(N ** 0.5) + 1):
    encoded_N = encode_x_base(N, b)
    d_sum = digit_sum(encoded_N)
    if d_sum == S:
        print(b)
        exit()

# Bが大きいときはpを全探索
for p in range(int(N ** 0.5) + 1, 0, -1):
    b = (N - S) // p + 1
    if b < 2:
        continue
    encoded_N = encode_x_base(N, b)
    d_sum = digit_sum(encoded_N)
    if d_sum == S:
        print(b)
        break
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
from collections import deque

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


def bfs(n):
    visited = [False] * N
    dist = [0] * N
    queue = deque([n])
    while queue:
        node = queue.pop()
        if visited[node]:
            continue
        visited[node] = True
        for n in T[node]:
            if not visited[n]:
                dist[n] = dist[node] + 1
                queue.appendleft(n)
    return dist


dist = []
for i in range(N):
    dist.append(bfs(i))

ans = float('inf')
if K % 2 == 0:
    # 全ての頂点について全探索
    for i in range(N):
        ans = min(ans, len([d for d in dist[i] if d > K / 2]))
else:
    # 全ての辺について全探索
    for a, b in E:
        adist = [(1 if min(d1, d2) > (K-1) / 2 else 0) for d1, d2 in zip(dist[a], dist[b])]
        ans = min(ans, sum(adist))

print(ans)


Fixed submission:
N = int(input())
L = sorted(list(map(int, input().split())))
print(sum(L[::2]))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = list(map(int,input().split()))

result = ['' for _ in range(N)]

for i in range(N//2):
    if i < N -2:
        s_1 = A[2*i+1]
        s_2 = A[2*i]
        for j in range(2*i+2, N):
            s_1 = s_1 ^ A[j]
            s_2 = s_2 ^ A[j]
        result[2*i] = str(s_1)
        result[2*i+1] = str(s_2)
        m = s_1^s_2
        for j in range(2*i+2, N):
            A[j] = m^A[j]
 
    else:
        result.append(str(A[N-1]))
        result.append(str(A[N-2]))
        break

print(' '.join(result))

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

result = ['' for _ in range(N)]
s = A[0]
for i in range(1,N):
    s = s ^ A[i]

for i in range(N):
    result[i] = str(s ^ A[i])

print(' '.join(result))

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = list(map(int,input().split()))
B = copy.copy(A)

result = []

for i in range(N//2):
    if i < N -2:
        s_1 = A[2*i+1]
        s_2 = A[2*i]
        for j in range(2*i+2, N):
            s_1 = s_1 ^ A[j]
            s_2 = s_2 ^ A[j]
        result.append(str(s_1))
        result.append(str(s_2))
        for j in range(2*i+1, N):
            A[j] = int(result[-1])^int(result[-2])^A[j]
 
    else:
        result.append(str(A[N-1]))
        result.append(str(A[N-2]))
        break

print(' '.join(result)) 

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

result = ['' for _ in range(N)]
s = A[0]
for i in range(1,N):
    s = s ^ A[i]

for i in range(N):
    result[i] = str(s ^ A[i])

print(' '.join(result))

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

result = []

for i in range(N//2):
    if i < N -2:
        s = A[2*i+1]
        for j in range(2*i+2, N):
            s = s ^ A[j]
        result.append(str(s))
        s = A[2*i]
        for j in range(2*i+2, N):
            s = s ^ A[j]
        result.append(str(s))
        
    else:
        result.append(str(A[N-1]))
        result.append(str(A[N-2]))
        break
    
    for j in range(2*i+1, N):
        A[j] = int(result[-1])^int(result[-2])^A[j]

print(' '.join(result)) 

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

result = ['' for _ in range(N)]
s = A[0]
for i in range(1,N):
    s = s ^ A[i]

for i in range(N):
    result[i] = str(s ^ A[i])

print(' '.join(result))

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

result = []

for i in range(N):
    if i == 0:
        s = A[1]
        for j in range(2,N):
            s = s ^A[j]
    else:
        s = A[0]
        for j in range(1, N):
            if j != i:
                s = s ^ A[j]  
    result.append(str(s))

print(' '.join(result)) 

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

result = ['' for _ in range(N)]
s = A[0]
for i in range(1,N):
    s = s ^ A[i]

for i in range(N):
    result[i] = str(s ^ A[i])

print(' '.join(result))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
A = np.array(A)
res_list = np.zeros(N)
for j in range(N):
    A_copy = A.copy()
    A_copy = A_copy % A[j]
    A_copy[j] += 1
    A_copy = np.where(A_copy > 0, 1, 0)
    res_list += A_copy
res_list /= len(A)
print(np.count_nonzero(res_list == 1)) 

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

max_A = A[-1]
# df[i]...数字iが条件満たす:1、条件満たさない:0
df = [True for _ in range(max_A + 1)]

for i, a in enumerate(A):
    if i > 0:
        if A[i] == A[i - 1]:
            df[a] = False
            continue
    if df[a]:
        for num in range(2*a, max_A+1, a):
            df[num] = False
count = 0
for a in A:
    if df[a]:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(input())
p_origin = x.count('1')

def bit_count(x):
    count = 0
    while x > 0:
        if x & 1:
            count += 1
        x = x >> 1
    return count


def get_ans(i):
    ans = 1
    if x[i] == '0':
        p_first = (sum_plus + p_plus[i]) % (p_origin+1)
    else:
        p_first = (sum_minus - p_minus[i]) % (p_origin-1)
    while p_first != 0:
        p_first = p_first % bit_count(p_first)
        ans += 1
    return ans

p_minus = [0]*n # x%(p-1)
p_plus = [0]*n # x%(p+1)

t1 = 1
t2 = 1
for i in range(n):
    p_minus[n-1-i] = t1
    p_plus[n-1-i] = t2
    t1 *= 2
    t2 *= 2
    t1 %= p_origin-1
    t2 %= p_origin+1

sum_plus = 0
sum_minus = 0
for i in range(n):
    if x[i] == '1':
        sum_plus += p_plus[i]
        sum_minus += p_minus[i]

for i in range(n):
    print(get_ans(i))


Fixed submission:
n = int(input())
x = list(input())
p_origin = x.count('1')

def bit_count(x):
    count = 0
    while x > 0:
        if x & 1:
            count += 1
        x = x >> 1
    return count


def get_ans(i):
    ans = 1
    if x[i] == '0':
        p_first = (sum_plus + p_plus[i]) % (p_origin+1)
    else:
        if p_origin-1 == 0:
            return 0
        p_first = (sum_minus - p_minus[i]) % (p_origin-1)
    while p_first != 0:
        p_first = p_first % bit_count(p_first)
        ans += 1
    return ans

p_minus = [0]*n # x%(p-1)
p_plus = [0]*n # x%(p+1)

t1 = 1
t2 = 1
for i in range(n):
    p_minus[n-1-i] = t1
    p_plus[n-1-i] = t2
    t1 *= 2
    t2 *= 2
    if p_origin == 1:
        t1 = 0
    else:
        t1 %= p_origin-1
    t2 %= p_origin+1

sum_plus = 0
sum_minus = 0
for i in range(n):
    if x[i] == '1':
        sum_plus += p_plus[i]
        sum_minus += p_minus[i]

for i in range(n):
    print(get_ans(i))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math

n = int(input())

f_list = [[]]*(10**7+1) # すべて素数扱い

def get_ans(t):
    c = collections.Counter(t)
    v_list = c.values()
    ans = 1
    for v in v_list:
        ans *= v+1
    return ans

ans = 0
for i in range(2, n+1):
    tmp = [i] # 約数のリスト
    if i % 2 == 0:
        tmp = f_list[i//2]+[2]
    else:
        f = 3
        while f*f <= i:
            if i % f == 0:
                tmp = f_list[i//f]+[f]
                break
            else:
                f += 2
    f_list[i] = tmp
    ans += i*get_ans(tmp)
print(ans+1)

Fixed submission:
import collections
import math

n = int(input())
ans = 0

for i in range(1,n+1):
    tail = (n // i)
    ans += (tail)*(tail+1)//2*i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math

n = int(input())

f_list = [[]]*(10**7+1) # すべて素数扱い
ans = [1]*(10**7+1)

def get_ans(t):
    c = collections.Counter(t)
    v_list = c.values()
    ans = 1
    for v in v_list:
        ans *= v+1
    return ans

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

for i in range(2, n+1):
    tmp = [] # 約数のリスト
    if is_prime(i):
        tmp = [i]
    elif i % 2 == 0:
        tmp = f_list[i//2].copy()
        tmp.append(2)
    else:
        f = 3
        while f*f <= i:
            if i % f == 0:
                tmp = f_list[i//f].copy()
                tmp.append(f)
                break
            else:
                f += 2
    f_list[i] = tmp
    ans[i] = i*get_ans(tmp)
print(sum(ans[1:n+1]))


Fixed submission:
import collections
import math

n = int(input())
ans = 0

for i in range(1,n+1):
    tail = (n // i)
    ans += (tail)*(tail+1)//2*i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
ans_len = 10**6+10
is_ans = [0]*(ans_len)

for a in a_list:
    if is_ans[a] == 0:
        b = 2*a
        while b < ans_len:
            is_ans[b] += 1
            b += a

ans = 0
for a in a_list:
    if a_list.count(a) == 1:
        ans += (is_ans[a] == 0)
print(ans)


Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
ans_len = 10**6+10
is_ans = [0]*(ans_len)

for a in a_list:
    is_ans[a] += 1
    if is_ans[a] == 1:
        b = 2*a
        while b < ans_len:
            is_ans[b] += 2
            b += a

ans = 0
for a in a_list:
    # print(a, is_ans[a])
    ans += (is_ans[a] == 1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
ans_len = 10**6+10
is_ans = [0]*(ans_len)

for a in a_list:
    b = 2*a
    while b < ans_len:
        if is_ans[b] == 0:
            is_ans[b] += 1
        b += a

ans = 0
for a in a_list:
    # print(a, a_list.count(a), is_ans[a])
    if a_list.count(a) == 1:
        ans += (is_ans[a] == 0)
print(ans)


Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
ans_len = 10**6+10
is_ans = [0]*(ans_len)

for a in a_list:
    is_ans[a] += 1
    if is_ans[a] == 1:
        b = 2*a
        while b < ans_len:
            is_ans[b] += 2
            b += a

ans = 0
for a in a_list:
    # print(a, is_ans[a])
    ans += (is_ans[a] == 1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
ans_len = 10**6+10
is_ans = [0]*(ans_len)

for a in a_list:
    b = a
    while b < ans_len:
        # if is_ans[b] == 0:
        is_ans[b] += 1
        b += a

ans = 0
for a in a_list:
    ans += (is_ans[a] == 1)
print(ans)


Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
ans_len = 10**6+10
is_ans = [0]*(ans_len)

for a in a_list:
    is_ans[a] += 1
    if is_ans[a] == 1:
        b = 2*a
        while b < ans_len:
            is_ans[b] += 2
            b += a

ans = 0
for a in a_list:
    # print(a, is_ans[a])
    ans += (is_ans[a] == 1)
print(ans)