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

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

t = max(a)
num_list = [0] * (t + 2)

for i in range(n):
    num_list[a[i]] += 1
    if a[i] == 0:
        continue
    else:
        num_list[a[i]-1] += 1
    if a[i] == t:
        continue
    else:
        num_list[a[i]+1] += 1

print(max(num_list))

Buggy submission (verdict: Runtime Error):
import collections

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

c = collections.Counter(a)
d = list(c.keys())
e = list(c.values())

if n == 1:
    print(1)
    exit()
elif n == 2:
    if a[0] == a[1] or abs(a[0] - a[1]) == 1:
        print(2)
        exit()
    else:
        print(1)
        exit()
elif len(d) == 1:
    print(e[0])
    exit()
elif len(d) == 2:
    if d[0] == d[1] or abs(d[0] - d[1]) == 1:
        print(e[0] + e[1])
        exit()
    else:
        print(max(e[0], e[1]))


for i in range(n-2):
    if abs(d[i] - d[i+1]) == 1 and abs(d[i] - d[i+2]) == 2:
        num = e[i] + e[i+1] + e[i+2]
    elif abs(d[i] -d[i+1]) == 1:
        num = e[i] + e[i+1]
    else:
        num = e[i]
    if num > ans:
        ans = num

if d[-2] == d[-1] or abs(d[-2] - d[-1]) == 1:
    num = e[-2] + e[-1]
else:
    num = max(e[-2], e[-1])

if num > ans:
    ans = num

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

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

c = collections.Counter(a)
d = list(c.keys())
e = list(c.values())

if n == 1:
    print(1)
    exit()
elif n == 2:
    if a[0] == a[1] or abs(a[0] - a[1]) == 1:
        print(2)
        exit()
    else:
        print(1)
        exit()


for i in range(n-2):
    if abs(d[i] - d[i+1]) == 1 and abs(d[i] - d[i+2]) == 2:
        num = e[i] + e[i+1] + e[i+2]
    elif abs(d[i] -d[i+1]) == 1:
        num = e[i] + e[i+1]
    else:
        num = e[i]
    if num > ans:
        ans = num

if d[-2] == d[-1] or abs(d[-2] - d[-1]) == 1:
    num = e[-2] + e[-1]
else:
    num = max(e[-2], e[-1])

if num > ans:
    ans = num

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if n == 1:
    print(1)
    exit()

a.sort()
li = []
count = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        count += 1
    else:
        li.append(count)
        count = 1

li.sort()
count2 = 0

if len(li) == 1:
    print(li[0])
    exit()
elif len(li) == 2:
    if abs(a[0] - a[-1]) <= 2:
        print(li[0] + li[1])
    else:
        print(max(li[0], li[1]))
else:

    for i in range(len(li)-2):
        x = li[i] + li[i+1] + li[i+2]
        if x >= count2:
            count2 = x

    print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if n == 1:
    print(1)
    exit()

a.sort()
li = []
count = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        count += 1
    else:
        li.append(count)
        count = 1

li.sort()
count2 = 0
for i in range(len(li)-2):
    x = li[i] + li[i+1] + li[i+2]
    if x >= count2:
        count2 = x

print(x)
Problem p03612 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
i = 0
while i <= (n-1):
    if i == n-1:
        if a[i] == i+1:
            count += 1
            print(count)
            exit()
        else:
            break
    if a[i] == i+1 and a[i+1] == i+2:
        count += 1
        i += 2
    elif a[i] == i+1:
        count += 1
        i += 1
    else:
        i += 1

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0
i = 0
while i <= (n-1):
    if a[i] == i+1 and a[i+1] == i+2:
        count += 1
        i += 2
    elif a[i] == i+1:
        count += 1
        i += 1
    else:
        i += 1

print(count)
Problem p03633 (python)

Fixed submission:
import fractions
from functools import reduce

n = int(input())

clock_list = []
for i in range(n):
    a = int(input())
    clock_list.append(a)

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

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


print(lcm_list(clock_list))

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

n = int(input())

clock_list = []
for i in range(n):
    a = int(input())
    clock_list.append(a)

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

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


print(lcm_list(clock_list))
Problem p03651 (python)

Fixed submission:
import fractions
from functools import reduce

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


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

b = gcd_list(a)
if max(a) >= k and k % b == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

if max(a) < k:
    print('IMPOSSIBLE')
elif k in a:
    print('POSSIBLE')
else:
    for i in a:
        if i %2 == 0:
            flag_e = True
        else:
            flag_o = True
    if flag_e is True and flag_o is True:
        for i in a:
            if i == min(a):
                continue
            else:
                if i %2 == 0:
                    if (i-min(a)) % min(a) != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
                else:
                    if i % min(a) != 0:
                        print('POSSIBLE')
                        exit()
                    else:
                        continue
        print('IMPOSSIBLE')
        exit()
    elif flag_e is True:
        if k %2 == 0:
            print('POSSIBLE')
            exit()
        else:
            print('IMPOSSIBLE')
            exit()
    else:
        for i in a:
            if i == min(a):
                continue
            else:
                if i % min(a) != 0:
                    print('POSSIBLE')
                    exit()
                else:
                    continue
        print('IMPOSSIBLE')
        exit()
Problem p03777 (python)

Fixed submission:
a, b = input().split()
if a == 'H':
    if b == 'H':
        print('H')
    else:
        print('D')
else:
    if b == 'H':
        print('D')
    else:
        print('H')

Buggy submission (verdict: Runtime Error):
a, b = map(input())
if a == 'H':
    if b == 'H':
        print('H')
    else:
        print('D')
else:
    if b == 'H':
        print('D')
    else:
        print('H')
Problem p03844 (python)

Fixed submission:
s = list(input().split())

if s[1] == '+':
    print(int(s[0])+int(s[2]))
else:
    print(int(s[0])-int(s[2]))

Buggy submission (verdict: Runtime Error):
s = list(input())

if s[1] == '+':
  print(s[0]+s[2])
else:
  print(s[0]-s[2])
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())

print((a+b)*c//2)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())

print((a+b)*h)
Problem p03999 (python)

Fixed submission:
a = input()
if len(a) == 1:
    print(int(a))
    exit()
ans = 0
for i in range(2**(len(a)-1)):
    b = format(i, 'b').zfill((len(a)-1))
    li = []
    num = [a[0]]
    for i in range(len(b)):
        if b[i] == '1':
            ans += int(''.join(num))
            num = [a[i+1]]
        else:
            num.append(a[i+1])
    ans += int(''.join(num))

print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
ans = 0
for i in range(2**(len(a)-1)):
    b = format(i, 'b').zfill((len(a)-1))
    li = []
    num = [a[0]]
    for i in range(len(b)):
        if b[i] == '1':
            ans += int(''.join(num))
            num = [a[i+1]]
        else:
            num.append(a[i+1])
    ans += int(''.join(num))

print(ans)
Problem p02929 (python)

Fixed submission:
import sys
from math import factorial

N = int(input())
S = input()
mod = 10**9+7

if S[0] == 'W' or S[-1] == 'W':
    print(0)
    sys.exit()

op = "L"
for i in range(1, 2*N):
    if S[i] == S[i-1]:
        op += 'R' if op[i-1] == 'L' else 'L'
    else:
        op += 'R' if op[i-1] == 'R' else 'L'

if op.count('L') != N:
    print(0)
    sys.exit()

ct_L, ans = 0, 1

for i in op:
    if i == 'L':
        ct_L += 1
    else:
        ans *= ct_L
        ct_L -= 1
    ans %= mod


print(factorial(N) * ans % mod)

Buggy submission (verdict: Runtime Error):
import sys
from math import factorial

N = int(input())
S = input()

if S[0] == 'W' or S[-1] == 'W':
    print(0)
    sys.exit()

op = "L"
for i in range(1, 2*N):
    if S[i] == S[i-1]:
        op += 'R' if op[i-1] == 'L' else 'L'
    else:
        op += 'R' if op[i-1] == 'R' else 'L'

if op.count('L') != N:
    print(0)
    sys.exit()

ct_L, ans = 0, 1

for i in op:
    if i == 'L':
        ct_L += 1
    else:
        ans *= ct_L
        ct_L -= 1
    ans %= mod

mod = 10**9+7
print(factorial(N) * ans % mod)
Problem p03000 (python)

Fixed submission:
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

ans = 1
ct = 0
D = 0
while True:
    D += L[ct]
    if D <= X:
        ct += 1
        ans += 1
    else:
        break
    if ct > N - 1:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = [int(i) for i in input().split()]

ans = 0
D = 0
while(D <= X):
    D += L[ans]
    ans += 1

print(ans)
Problem p03061 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]


def gcd(a: int, b: int) -> int:
    while a % b != 0:
        r = a % b
        a = b
        b = r
    return b


L = [0] * N
R = [0] * N
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i-1])
    R[N-i-1] = gcd(R[N-i], A[N-i])

for i in range(N):
    if i == 0:
        ans = R[i]
    elif i == N-1:
        ans = max(ans, L[i])
    else:
        ans = max(ans, gcd(L[i], R[i]))

print(ans)

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

N = int(input())
A = [int(i) for i in input().split()]


ans = -1
for i in range(N):
    flg = 0
    tmp = A[:i] + A[i+1:]
    Gcd = tmp[0]
    for j in range(N-2):
        g = gcd(tmp[j], tmp[j+1])
        Gcd = gcd(Gcd, g)
        if Gcd < ans:
            flg = 1
            break
    if flg:
        continue
    ans = max(ans, Gcd)

print(ans)
Problem p03076 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ae = [a, b, c, d, e]

time = 0

for i in ae:
    if i % 10 == 0:
        time += i

ae = [i for i in ae if i % 10 != 0]

if ae:
    idx = 0
    for i in ae:
        time += i
        time += 10 - (i % 10)

    one = []
    for i in ae:
        i = [j for j in str(i)]
        one.append(int(i[-1]))

    print(time-10+min(one))

else:
    print(time)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ae = [a, b, c, d, e]

time = 0

for i in ae:
    if i % 10 == 0:
        time += i

ae = [i for i in ae if i % 10 != 0]

idx = 0
for i in ae:
    time += i
    time += 10 - (i % 10)

one = []
for i in ae:
    i = [j for j in str(i)]
    one.append(int(i[-1]))

print(time-10+min(one))
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().rstrip().split())
S = [i for i in input()]

list_lr = [list(map(int, input().rstrip().split())) for i in range(Q)]

t = [0]
ct = 0
for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
        ct += 1
    t.append(ct)

for i in list_lr:
    l, r = i[0], i[1]
    print(t[r-1]-t[l-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
Sum = [0]*(N+1)
for i in range(N):
	if S[i] == 'A' and S[i+1] == 'C':
		Sum[i+1] = Sum[i] + 1
	else:
		Sum[i+1] = Sum[i]

for i in range(Q):
	l, r = map(int, input().split())
	print(Sum[r-1] - Sum[l-1])
Problem p03240 (python)

Fixed submission:
import sys

N = int(input())
H = [list(map(int, input().split())) for i in range(N)]

H.sort(key=lambda x: x[2], reverse=True)

for i in H:
    x, y, h = i
    for c_x in range(101):
        for c_y in range(101):
            Height = h + abs(x-c_x) + abs(y-c_y)
            for j in range(N):
                if H[j][2] != max(Height-abs(H[j][0]-c_x)-abs(H[j][1]-c_y), 0):
                    break
                if j == N-1:
                    print(c_x, c_y, Height)
                    sys.exit()

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
H = [list(map(int, input().split())) for i in range(N)]

H.sort(key=lambda x: x[2], reverse=True)

for i in H:
    x, y, h = i
    for c_x in range(101):
        for c_y in range(101):
            Height = h + abs(x-c_x) + abs(y-c_y)
            for j in range(N):
                if Height[j][2] != max(Height-abs(H[j][0]-c_x)-abs(H[j][1]-c_y), 0):
                    break
                if j == N-1:
                    print(c_x, c_y, Height)
                    sys.exit()

Buggy submission (verdict: Runtime Error):
import copy

N = int(input())

Height = []
tmp = []
for i in range(N):
    x, y, h = map(int, input().split())
    if i == 0:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                if h != 0:
                    H = h + abs(x-c_x) + abs(y-c_y)
                    d = (c_x, c_y, H)
                    Height.append(d)
                else:
                    pass
    else:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                if h != 0:
                    H = h + abs(x-c_x) + abs(y-c_y)
                    d = (c_x, c_y, H)
                    if d in Height:
                        if d not in tmp:
                            tmp.append(d)
                else:
                    pass
        if i == N-1:
            Height.clear()
            break
        else:
            Height = copy.deepcopy(tmp)
            tmp.clear()

tmp[0] = [str(i) for i in tmp[0]]

print(' '.join(tmp[0]))

Buggy submission (verdict: Runtime Error):
import copy

N = int(input())

Height = []
tmp = []
for i in range(N):
    x, y, h = map(int, input().split())
    if i == 0:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                H = h + abs(x-c_x) + abs(y-c_y)
                d = (c_x, c_y, H)
                Height.append(d)
    else:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                H = h + abs(x-c_x) + abs(y-c_y)
                d = (c_x, c_y, H)
                if d in Height:
                    if d not in tmp:
                        tmp.append(d)
        if i == N-1:
            Height.clear()
            break
        else:
            Height = copy.deepcopy(tmp)
            tmp.clear()

tmp[0] = [str(i) for i in tmp[0]]

print(' '.join(tmp[0]))
Problem p03282 (python)

Fixed submission:
import sys

S, K = [int(i) for i in input()], int(input())

if S[0] == 1:
    length = 1
    for i in range(1, len(S)):
        if S[i] == 1:
            length += 1
            pass
        else:
            idx = i
            break
else:
    print(S[0])
    sys.exit()

if len(S) == length:
    print(1)
else:
    if K-1 < idx:
        print(1)
    else:
        print(S[idx])

Buggy submission (verdict: Runtime Error):
import sys

S, K = [int(i) for i in input()], int(input())

if S[0] == 1:
    for i in range(1, len(S)):
        if S[i] == 1:
            pass
        else:
            idx = i
            break
else:
    print(S[0])
    sys.exit()

if K-1 < idx:
    print(1)
else:
    print(S[idx])
Problem p03319 (python)

Fixed submission:
N, K = map(int, input().split())
A = input().split()
count = 0
if N == K:
    print(1)
else:
    count += 1
    rem = N-K
    add = 1 if (N-K)%(K-1) else 0
    count += (N-K)//(K-1) + add
    print(count)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = input().split()
count = 0
if N = K:
    print(1)
else:
    count += 1
    rem = N-K
    add = 1 if (N-K)%(K-1) else 0
    count += (N-K)//(K-1) + add
    print(count)
Problem p03355 (python)

Fixed submission:
s = input()
K = int(input())

ct = 0
alp = 'abcdefghijklmnopqrstuvwxyz'
for i in alp:
    ct += s.count(i)
    if ct >= K:
        break

key = i

list_rank = []
for i in range(len(s)):
    if s[i] > key:
        continue
    if i < len(s) - K + 1:
        for j in range(K):
            if s[i:i+j+1] not in list_rank:
                list_rank.append(s[i:i+j+1])
    else:
        for j in range(len(s)-i):
            if s[i:i+j+1] not in list_rank:
                list_rank.append(s[i:i+j+1])

list_rank.sort()
print(list_rank[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())

ct = 0
alp = 'abcdefghijklmnopqrstuvwxyz'
for i in alp:
    ct += s.count(i)
    if ct >= K:
        key = i
        break

list_rank = []
for i in range(len(s)):
    if s[i] > key:
        continue
    if i < len(s) - K + 1:
        for j in range(K):
            if s[i:i+j+1] not in list_rank:
                list_rank.append(s[i:i+j+1])
    else:
        for j in range(len(s)-i):
            if s[i:i+j+1] not in list_rank:
                list_rank.append(s[i:i+j+1])

list_rank.sort()
print(list_rank[K-1])
Problem p03401 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
A.append(0)

Sum = 0
for i in range(N+1):
    Sum += abs(A[i+1] - A[i])

for i in range(1, N+1):
    if (A[i-1] < A[i] < A[i+1]) or (A[i+1] < A[i] < A[i-1]):
        ans = Sum
    elif A[i] > A[i-1]:
        ans = Sum - 2 * abs(A[i] - max(A[i-1], A[i+1]))
    elif A[i] < A[i-1]:
        ans = Sum - 2 * abs(A[i] - min(A[i-1], A[i+1]))
    else:
        ans = Sum
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
A.append(0)

Sum = 0
for i in range(N+1):
    Sum += abs(A[i+1] - A[i])

for i in range(1, N+1):
    if (A[i-1] < A[i] < A[i+1]) or (A[i+1] < A[i] < A[i-1]):
        ans = Sum
    elif A[i] > A[i-1]:
        ans = Sum - 2 * abs(A[i] - max(A[i-1], A[i+1]))
    elif A[i] < A[i-1]:
        ans = Sum - 2 * abs(A[i] - min(A[i-1], A[i+1]))
    print(ans)
Problem p03597 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(inout())
print(N**2 - A)
Problem p03625 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
ct = list(Counter(A).items())
flg = 0
ct. sort(key=lambda x: x[0], reverse=True)
for i in ct:
    if i[1] >= 4 and flg == 0:
        flg = 2
        ans = i[0]**2
        break
    if i[1] >= 2 and flg == 0:
        flg = 1
        ans = i[0]
    elif i[1] >= 2 and flg == 1:
        flg = 2
        ans *= i[0]
        break

if flg != 2:
    print(0)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
ct = list(Counter(A).items())
flg = 0
ct. sort(key=lambda x: x[0], reverse=True)
for i in ct:
    if i[1] >= 4 and flg == 0:
        ans = i[0]**2
        break
    if i[1] >= 2 and flg == 0:
        flg = 1
        ans = i[0]
    elif i[1] >= 2 and flg == 1:
        ans *= i[0]
        break
print(ans)
Problem p03643 (python)

Fixed submission:
print('ABC' + input())

Buggy submission (verdict: Runtime Error):
print('ABC' + input())print('ABC' + input())
Problem p02616 (python)

Fixed submission:
MOD = 10 ** 9 + 7

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

S = []
T = []

for a in A:
    if a < 0:
        T.append(a)
    else:
        S.append(a)

lenS = len(S)
lenT = len(T)

ok = False
if lenS > 0:
    if N == K:
        ok = lenT % 2 == 0
    else:
        ok = True
else:
    ok = K % 2 == 0

ans = 1
if not ok:
    A.sort(key=lambda x: abs(x))
    for i in range(K):
        ans *= A[i]
        ans %= MOD
else:
    S.sort()
    T.sort(reverse=True)
    if K % 2 == 1:
        ans *= S.pop()
    P = []
    while len(S) >= 2:
        x = S.pop()
        x *= S.pop()
        P.append(x)
    while len(T) >= 2:
        x = T.pop()
        x *= T.pop()
        P.append(x)
    P.sort(reverse=True)
    for i in range(K//2):
        ans *= P[i]
        ans %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7

N, K = mii()
A = lmii()

S = []
T = []

for a in A:
    if a < 0:
        T.append(a)
    else:
        S.append(a)

lenS = len(S)
lenT = len(T)

ok = False
if lenS > 0:
    if N == K:
        ok = lenT % 2 == 0
    else:
        ok = True
else:
    ok = K % 2 == 0

ans = 1
if not ok:
    A.sort(key=lambda x: abs(x))
    for i in range(K):
        ans *= A[i]
        ans %= MOD
else:
    S.sort()
    T.sort(reverse=True)
    if K % 2 == 1:
        ans *= S.pop()
    P = []
    while len(S) >= 2:
        x = S.pop()
        x *= S.pop()
        P.append(x)
    while len(T) >= 2:
        x = T.pop()
        x *= T.pop()
        P.append(x)
    P.sort(reverse=True)
    for i in range(K//2):
        ans *= P[i]
        ans %= MOD

print(ans)
Problem p02617 (python)

Fixed submission:
N = int(input())
V = 0
E = 0
for i in range(N+1):
    V += i * (N-i+1)
for i in range(N-1):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    E += a * (N-b+1)
ans = V - E
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
V = 0
E = 0
for i in range(N+1):
    V += i * (N-i+1)
for i in range(N):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    E += a * (N-b+1)
ans = V - E
print(ans)
Problem p02642 (python)

Fixed submission:

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

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

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

if A[0] == A[1] == 1:
    print(0)
    exit()
if A[0] == 1:
    print(1)
    exit()


S = set()

for a in A:
    i = 2
    while a * i <= 10 ** 6:
        S.add(a * i)
        i += 1

ans = []
for a in A:
    if not a in S:
       ans.append(a)


D = defaultdict(int)
for a in ans:
    D[a] += 1

L = []
for k, v in D.items():
    if v > 1:
        continue
    L.append(k)


print(len(L))

Buggy submission (verdict: Runtime Error):

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


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

D = defaultdict(int)
for a in A:
    D[a] += 1

L = []
for k, v in D.items():
    if v > 1:
        continue
    L.append(k)

if len(L) == 0:
    print(0)
    exit()

L.sort()

ans = set()
for n in L:
    if is_prime(n):
        ans.add(n)
    flg = True
    for s in ans:
        if n % s == 0:
            flg = False
            break
    if flg is False:
        continue
    ans.add(n)

print(len(ans))