Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = []
for i in range(M):
     a, b = map(int, input().split())
    S.append([a, b])
    
from operator import itemgetter
S = sorted(S, key=itemgetter(1))
ans = 0
last = -1*float('Inf')
for si in S:
    if si[0] >= last:
        ans += 1
        last = si[1]
print(ans)

Fixed submission:
from operator import itemgetter

n, m = map(int, input().split())

# 区間の終端でソート
ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a, b in ab:
    # a が removed より大きい = まだ取り除いてない
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
def bfs(maze, sy, sx, gy, gx):
    d = [[-1] * w for _ in range(h)]
    que = deque([[sy, sx]])
    #print(que)
    d[sy][sx] = 0
    while que:
        y, x = que.popleft()
        if y == gy and x == gx:
            break
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            ny, nx = y + j, x + k
            if 0 <= nx < w  and 0 <= ny < h  and d[ny][nx] == -1 and maze[ny][nx] != "#":
                d[ny][nx] = d[y][x] + 1
                que.append([ny, nx])
                
    return d
gx, gy = w - 1, h - 1
def counting(maze, h, w, aim):
    cnt = 0
    for i in range(h):
        for j in range(w):
            if maze[i][j] == aim:
                cnt += 1
    return cnt
a = bfs(maze, 0, 0, gy, gx)
if a[gy][gx] == -1:
    print(-1)
else:
    print(h * w - (counting(maze, h, w, '#') + (a[gy][gx] + 1)))

Fixed submission:
from collections import deque

def bfs():
    flag = False
    d = [[float('inf')] * W for i in range(H)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((0, 0))
    d[0][0] = 0

    while que:
        p = que.popleft()
        if p[0]==H-1 and p[1]==W-1:
            flag = True
            break

        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            if 0<=nx<W and 0<=ny<H and maze[ny][nx]!='#' and d[ny][nx]==float("inf"):
                que.append((ny, nx))
                d[ny][nx] = d[p[0]][p[1]] + 1

    if flag==False:
        return False

    return d[H-1][W-1]

def notcount(H, W, maze):
    cnt = 0

    for i in range(H):
        for j in range(W):
            if maze[i][j]=='#':
                cnt += 1

    return cnt

H, W = map(int, input().split())
maze = [list(input()) for i in range(H)]
if bfs()==False:
    print(-1)
else:
    s = (H * W - notcount(H, W, maze)) - (bfs() + 1)
    #bfs()
    print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())
#maze = [[0] * (N + 10) for _ in range(2)]
maze = [list(map(int, input().split())) for _ in range(2)]

dp = [[0] * N for _ in range(2)]

dp[0][0] = maze[0][0]
for j in range(1, N):
    dp[0][j] = dp[0][j - 1] + maze[0][j]]

dp[1][0] = dp[0][0] + maze[1][0]
for i in range(1, N):
    dp[1][i] = max(dp[0][i] + maze[1][i], dp[1][i - 1] + maze[1][i])

print(dp[1][N - 1])

Fixed submission:
N = int(input())
#maze = [[0] * (N + 10) for _ in range(2)]
maze = [list(map(int, input().split())) for _ in range(2)]

dp = [[0] * N for _ in range(2)]

dp[0][0] = maze[0][0]
for j in range(1, N):
    dp[0][j] = dp[0][j - 1] + maze[0][j]

dp[1][0] = dp[0][0] + maze[1][0]

for i in range(1, N):
    dp[1][i] = max(dp[0][i] + maze[1][i], dp[1][i - 1] + maze[1][i])

print(dp[1][N - 1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = []
s = []
f = []
for i in range(n - 1):
    ci, si, fi = map(int, input().split())
    c.append(ci)
    s.append(si)
    f.append(fi)
for i in range(n - 1):
    time = s[i] + c[i]
    for j in range(i + 1, n - 1):
        if time % f[j] == 0 and time >= s[j]:
            time += c[j]
        else:
            while time % f[j] != 0 or s[j] > time:
                time += 1
            time += c[j]
    print(time)
print(0)

Fixed submission:
n = int(input())
c = []
s = []
f = []
for i in range(n - 1):
    ci, si, fi = map(int, input().split())
    c.append(ci)
    s.append(si)
    f.append(fi)
#c, s, f
for i in range(n - 1):
    time = s[i] + c[i]
    for j in range(i + 1, n - 1):
        if time < s[j]:
            time = s[j] + c[j]
        elif time % f[j] != 0:
            time += f[j] - time % f[j] + c[j]
        else:
            time += c[j]
    print(time)
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
while all(A % 2 == 0 for A in a):
    A = [i / 2 for i in a]
    ans += 1
print(ans)


Fixed submission:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
    for i in range(n):
        if a[i] % 2 == 1:
            print(cnt)
            quit()
        a[i] /= 2
    cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
ans = 0
while all(A % 2 == 0 for A in a):
    A = [i / 2 for i in a]
    ans += 1
print(ans)

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
    for i in range(n):
        if a[i] % 2 == 1:
            print(cnt)
            quit()
        a[i] /= 2
    cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
a = list(map(int, input().split()))

a_cnt = {}
for i in a:
    if i in a_cnt:
        a_cnt[i] += 1
    else:
        a_cnt[i] = 1

cnt_list = [0] * len(a_cnt)
for i, value in enumerate(a_cnt.values()):
    cnt_list[i] = value

cnt_list.sort()

ans = 0
while len(cnt_list) > K:
    ans += cnt_list[0]
    cnt_list.pop(0)
print(ans)


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

a_cnt = {}
for i in a:
    if i in a_cnt:
        a_cnt[i] += 1
    else:
        a_cnt[i] = 1
from  operator import itemgetter

a_cnt = sorted(a_cnt.items(), key=itemgetter(1))

from collections import deque
cnt_list = deque([])
for i, j in a_cnt:
    cnt_list.append(j)

ans = 0
while len(cnt_list) > K:
    ans += cnt_list[0]
    cnt_list.popleft()
print(ans)

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

a_cnt = {}
for i in a:
    if i in a_cnt:
        a_cnt[i] += 1
    else:
        a_cnt[i] = 1

cnt_list = [0] * len(a_cnt)
for i, value in enumerate(a_cnt.values()):
    cnt_list[i] = value

cnt_list.sort()

ans = 0
while len(cnt_list) > K:
    ans += cnt_list[0]
    cnt_list.pop(0)
print(ans)

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

a_cnt = {}
for i in a:
    if i in a_cnt:
        a_cnt[i] += 1
    else:
        a_cnt[i] = 1
from  operator import itemgetter

a_cnt = sorted(a_cnt.items(), key=itemgetter(1))

from collections import deque
cnt_list = deque([])
for i, j in a_cnt:
    cnt_list.append(j)

ans = 0
while len(cnt_list) > K:
    ans += cnt_list[0]
    cnt_list.popleft()
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
def multi_lcm(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = ans * a[i] // fractions.gcd(ans, a[i])
    return ans

N = int(input())
T = [int(input()) for _ in range(N)]
print(multi_lcm(T))


Fixed submission:
import fractions
def multi_lcm(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = ans * a[i] // fractions.gcd(ans, a[i])
    return ans

N = int(input())
T = [int(input()) for _ in range(N)]
print(multi_lcm(T))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

print(' '.join([str(i) for i in b]))

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

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        #print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        #print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

print(' '.join([str(i) for i in b]))

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

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

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

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        #print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        #print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

print(' '.join([str(i) for i in b]))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
mod = 10**9 + 7
if abs(N - M) > 1:
    print(0)
elif abs(N - M) == 0:
    ans = mod_factorial(N, mod) * mod_factorial(M, mod) * 2
    print(ans % mod)
else:
    ans = mod_factorial(N, mod) * mod_factorial(M, mod)
    print(ans % mod)
def mod_factorial(a, mod):
    ans = 1
    while a != 1:
        ans *= a
        ans = ans % mod
        a -= 1
    return ans

Fixed submission:
N, M = map(int, input().split())
def mod_factorial(a, mod):
    ans = 1
    while a != 1:
        ans *= a
        ans = ans % mod
        a -= 1
    return ans

mod = 10**9 + 7
if abs(N - M) > 1:
    print(0)
elif abs(N - M) == 0:
    ans = mod_factorial(N, mod) * mod_factorial(M, mod) * 2
    print(ans % mod)
else:
    ans = mod_factorial(N, mod) * mod_factorial(M, mod)
    print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

que1 = []
S = [0] * (2*N + 1)
for i in range(N):
    S[i + 1] = S[i] + a[i]
    que1.append(a[i])
    
que2 = []
T = [0] * (2*N + 1)
for i in range(N):
    T[i + 1] = T[i] + a[3*N - i - 1]
    que2.append(a[3*N - i - 1])

for i in range(N, 2*N):
    mi = min(que1)
    if a[i] > mi:
        S[i + 1] = S[i] - mi + a[i]
        que1.remove(mi)
        que1.append(a[i])
    else:
        S[i + 1] = S[i]
        
for i in range(N, 2*N):
    ma = max(que2)
    if a[3*N - i - 1] < ma:
        T[i + 1] = T[i] - ma + a[3*N - i - 1]
        que2.remove(ma)
        que2.append(a[3*N - i - 1])
    else:
        T[i + 1] = T[i]

res = -float('Inf')
for i in range(N, 2*N + 1):
    res = max(res, S[i] - T[3*N - i])
print(res)

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

import heapq
que1 = []
heapq.heapify(que1)
S = [0] * (2*N + 1)
for i in range(N):
    S[i + 1] = S[i] + a[i]
    #que1.append(a[i])
    heapq.heappush(que1, a[i])
que2 = []
heapq.heapify(que2)
T = [0] * (2*N + 1)
for i in range(N):
    T[i + 1] = T[i] + a[3*N - i - 1]
    #que2.append(-a[3*N - i - 1])
    heapq.heappush(que2, -a[3*N - i - 1])

for i in range(N, 2*N):
    mi = heapq.heappop(que1)
    #print(mi)
    if a[i] > mi:
        S[i + 1] = S[i] - mi + a[i]
        #heapq.heappop(que1)
        heapq.heappush(que1, a[i])
    else:
        S[i + 1] = S[i]
        heapq.heappush(que1, mi)
for i in range(N, 2*N):
    ma = heapq.heappop(que2) * -1
    #print(ma)
    if a[3*N - i - 1] < ma:
        T[i + 1] = T[i] - ma + a[3*N - i - 1]
        #heapq.heappop(que2)
        #que2.append(-a[3*N - i - 1])
        heapq.heappush(que2, -a[3*N - i - 1])
    else:
        T[i + 1] = T[i]
        heapq.heappush(que2, -ma)

res = -float('Inf')
for i in range(N, 2*N + 1):
    res = max(res, S[i] - T[3*N - i])
print(res)
Buggy python submission (verdict: Runtime Error):
X = int(input())
a = [i for i in range(1, 10**5)]

from collections import deque
s = deque([])
s.append(0)
i = 0
while s[i] < 10 ** 9:
    s.append(s[i] + a[i])
    i += 1

print(bisect.bisect_left(s, X))

Fixed submission:
X = int(input())
a = [i for i in range(1, 10**5)]
import bisect
from collections import deque
s = deque([])
s.append(0)
i = 0
while s[i] < 10 ** 9:
    s.append(s[i] + a[i])
    i += 1

print(bisect.bisect_left(s, X))

Buggy python submission (verdict: Runtime Error):
X = int(input())

sum_ = [0] * (X // 2 + 1)
a = [i for i in range(1, X//2 + 1)]
for i in range(X//2):
    sum_[i + 1] = sum_[i] + a[i]
import bisect
print(bisect.bisect_left(sum_, X))


Fixed submission:
X = int(input())
a = [i for i in range(1, 10**5)]
import bisect
from collections import deque
s = deque([])
s.append(0)
i = 0
while s[i] < 10 ** 9:
    s.append(s[i] + a[i])
    i += 1

print(bisect.bisect_left(s, X))

Buggy python submission (verdict: Runtime Error):
X = int(input())

sum_ = [0] * (X + 1)
a = [i for i in range(1, X + 1)]
for i in range(X):
    sum_[i + 1] = sum_[i] + a[i]
import bisect
print(bisect.bisect_left(sum_, X))

Fixed submission:
X = int(input())
a = [i for i in range(1, 10**5)]
import bisect
from collections import deque
s = deque([])
s.append(0)
i = 0
while s[i] < 10 ** 9:
    s.append(s[i] + a[i])
    i += 1

print(bisect.bisect_left(s, X))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = [1] * N
for i in range(1, N):
    ans[i] = ans[i - 1] * (i + 1)

big = 10 ** 9 + 7
print(ans[N - 1] % big)


Fixed submission:
N = int(input())
big = 10 ** 9 + 7
import math
print(math.factorial(N) % big)

Buggy python submission (verdict: Runtime Error):
N = int(input())

import math
print(math.factorial(N) % big)

Fixed submission:
N = int(input())
big = 10 ** 9 + 7
import math
print(math.factorial(N) % big)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = [1] * N
for i in range(1, N):
    ans[i] = ans[i - 1] * (i + 1)

big = 10 ** 9 + 7
print(ans[N - 1] % big)

Fixed submission:
N = int(input())
big = 10 ** 9 + 7
import math
print(math.factorial(N) % big)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s[::-1]
lis = ['remaerd', 'resare', 'esare', 'maerd']
i = 0
j = 0
#s = s[::-1]
while i < len(s):
    while True:
        tmp = s[i : j]
        #print(s[i : j])
        if len(tmp) == 8:
            print('NO')
            #quit()
        elif tmp in lis:
            i = j
            j = i + 5
            break
        else:
            j += 1
print('YES')

Fixed submission:
s = input()
s = s[::-1]
lis = ['remaerd', 'resare', 'esare', 'maerd']
i = 0
j = 0
#s = s[::-1]
while i < len(s):
    tmp = ''
    while j < len(s):
        tmp += s[j]
        #print(tmp)
        if len(tmp) == 8:
            print('NO')
            quit()
        elif tmp in lis:
            i = j + 1
            j = i
            break
        else:
            j += 1
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s[::-1]
lis = ['remaerd', 'resare', 'esare', 'maerd']
i = 0
j = 0
#s = s[::-1]
while i < len(s):
    while True:
        #print(s[i : j])
        if len(s[i : j]) == 8:
            print('NO')
            #quit()
        elif s[i : j] in lis:
            i = j
            j = i + 5
            break
        else:
            j += 1
print('YES')


Fixed submission:
s = input()
s = s[::-1]
lis = ['remaerd', 'resare', 'esare', 'maerd']
i = 0
j = 0
#s = s[::-1]
while i < len(s):
    tmp = ''
    while j < len(s):
        tmp += s[j]
        #print(tmp)
        if len(tmp) == 8:
            print('NO')
            quit()
        elif tmp in lis:
            i = j + 1
            j = i
            break
        else:
            j += 1
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s = s[::-1]
lis = ['remaerd', 'resare', 'esare', 'maerd']
i = 0
j = 0
#s = s[::-1]
while i < len(s):
    while True:
        #print(s[i : j])
        if len(s[i : j]) == 8:
            print('NO')
            #quit()
        elif s[i : j] in lis:
            i = j
            break
        else:
            j += 1
print('YES')

Fixed submission:
s = input()
s = s[::-1]
lis = ['remaerd', 'resare', 'esare', 'maerd']
i = 0
j = 0
#s = s[::-1]
while i < len(s):
    tmp = ''
    while j < len(s):
        tmp += s[j]
        #print(tmp)
        if len(tmp) == 8:
            print('NO')
            quit()
        elif tmp in lis:
            i = j + 1
            j = i
            break
        else:
            j += 1
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
count_h = [0 for i in range(h)]
count_w = [0 for i in range(w)]
bit = list([0 for i in range(w)] for _ in range(h))
for j,k in l:
    count_h[j-1] += 1
    count_w[k-1] += 1
    bit[j-1][k-1] = 1
h_max = max(count_h)
w_max = max(count_w)
h_kouho = []
w_kouho = []
ans = h_max + w_max - 1
for i in range(h):
    if count_h[i]==h_max:
        h_kouho.append(i)
for j in range(w):
    if count_w[j]==w_max:
        w_kouho.append(j)

for i in w_kouho:
    for j in h_kouho:
        if bit[j][i] == 0:
            ans += 1
            print(ans)
            exit()
print(ans)


Fixed submission:
h,w,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
count_h = [0 for i in range(h)]
count_w = [0 for i in range(w)]

for j,k in l:
    count_h[j-1] += 1
    count_w[k-1] += 1

h_max = max(count_h)
w_max = max(count_w)
h_kouho = []
ko_hh = [0 for _ in range(h)]
ko_ww = [0 for _ in range(w)]
w_kouho = []
ans = h_max + w_max -1
for i in range(h):
    if count_h[i]==h_max:
        h_kouho.append(i)
        ko_hh[i] = 1
for j in range(w):
    if count_w[j]==w_max:
        w_kouho.append(j)
        ko_ww[j] = 1


ans_kouho = len(h_kouho) * len(w_kouho)
su = 0
for j,k in l:
    if ko_hh[j-1]==1 and ko_ww[k-1]==1:
        su += 1
if su==ans_kouho:
    print(ans)
else:
    print(ans+1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
count_h = [0 for i in range(h)]
count_w = [0 for i in range(w)]
bit = list([0 for i in range(w)] for _ in range(h))
for j,k in l:
    count_h[j-1] += 1
    count_w[k-1] += 1
    bit[j-1][k-1] = 1
h_max = max(count_h)
w_max = max(count_w)
h_kouho = []
w_kouho = []
ans = h_max + w_max - 1
for i in range(h):
    if count_h[i]==h_max:
        h_kouho.append(i)
for j in range(w):
    if count_w[j]==w_max:
        w_kouho.append(j)

for i in w_kouho:
    for j in h_kouho:
        if bit[j][i] == 0:
            ans += 1
            print(ans)
            exit()
print(ans)

Fixed submission:
h,w,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
count_h = [0 for i in range(h)]
count_w = [0 for i in range(w)]

for j,k in l:
    count_h[j-1] += 1
    count_w[k-1] += 1

h_max = max(count_h)
w_max = max(count_w)
h_kouho = []
ko_hh = [0 for _ in range(h)]
ko_ww = [0 for _ in range(w)]
w_kouho = []
ans = h_max + w_max -1
for i in range(h):
    if count_h[i]==h_max:
        h_kouho.append(i)
        ko_hh[i] = 1
for j in range(w):
    if count_w[j]==w_max:
        w_kouho.append(j)
        ko_ww[j] = 1


ans_kouho = len(h_kouho) * len(w_kouho)
su = 0
for j,k in l:
    if ko_hh[j-1]==1 and ko_ww[k-1]==1:
        su += 1
if su==ans_kouho:
    print(ans)
else:
    print(ans+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
su = 0
for i in range(1,n+1):
  a = i
  l = (n//i)*i
  m = (n//i)/2
  su += m*(a+l)
print(int(su))

Fixed submission:
n = int(input())
su = 0
for i in range(1,n+1):
  t = n//i
  l = t*i
  m = t/2
  su += m*(i+l)
print(int(su))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int,input().split())))

l = []
l.append(a[0])
cou =[]



for i in range(1,n):
    b = a[i]
    for j in range(len(l)):
      if b==l[j]:
        cou.append(b)
        break
      if b%l[j]==0:
        break
    else:
      l.append(b)

print(len(l)-len(set(cou)))


Fixed submission:
counter = [0 for i in range(10**6+1)]
n = int(input())
a = sorted(list(map(int,input().split())))
for i in a:
  counter[i] += 1
l  = [0 for i in range(10**6+1)]
cou = 0
for i in range(n):
  b = a[i]
  if l[b]==0:
    cou += 1
    for j in range(b,10**6+1,b):
      l[j] = 1
    if counter[b]>=2:
      cou -=1
print(cou)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int,input().split())))

l = []
l.append(a[0])
cou =[]
for i in range(1,n):
    b = a[i]
    for j in range(len(l)):
      if b==l[j]:
        cou.append(b)
        break
      if b%l[j]==0:
          break
    else:
        l.append(b)
print(len(l)-len(set(cou)))

Fixed submission:
counter = [0 for i in range(10**6+1)]
n = int(input())
a = sorted(list(map(int,input().split())))
for i in a:
  counter[i] += 1
l  = [0 for i in range(10**6+1)]
cou = 0
for i in range(n):
  b = a[i]
  if l[b]==0:
    cou += 1
    for j in range(b,10**6+1,b):
      l[j] = 1
    if counter[b]>=2:
      cou -=1
print(cou)

Buggy python submission (verdict: Time Limit Exceeded):
from  math import gcd
n = int(input())
a = sorted(list(map(int,input().split())))

l = []
l.append(a[0])
cou =[]
for i in range(1,n):
    b = a[i]
    for j in range(len(l)):
      if b==l[j]:
        cou.append(b)
      if b%l[j]==0:
          break
    else:
        l.append(b)
print(len(l)-len(set(cou)))

Fixed submission:
counter = [0 for i in range(10**6+1)]
n = int(input())
a = sorted(list(map(int,input().split())))
for i in a:
  counter[i] += 1
l  = [0 for i in range(10**6+1)]
cou = 0
for i in range(n):
  b = a[i]
  if l[b]==0:
    cou += 1
    for j in range(b,10**6+1,b):
      l[j] = 1
    if counter[b]>=2:
      cou -=1
print(cou)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
# 目印置くリスト
me = [0 for _ in range(n+1)]
me[1] = 1
miti = [[] for _ in range(n+1)]
tansaku = [0 for i in range(n+1)]
tansaku[1]=1
for i,j in l:
  miti[j].append(i)
  miti[i].append(j)
a = deque()
for i in miti[1]:
  a.append(i)
  me[i] = 1
while len(a)!=0:
#  print(a)
  w = a.popleft()
  tansaku[w] = 1
  for j in miti[w]:
    if tansaku[j]==0 and j not in a:
          a.append(j) 
          me[j] = w
#  print(w,tansaku,me)
  
print("Yes")
for i in range(len(miti)-2):
  print(me[i+2])

Fixed submission:
from collections import deque
n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
# 目印置くリスト
me = [0 for _ in range(n+1)]
me[1] = 1
miti = [[] for _ in range(n+1)]
tansaku = [0 for i in range(n+1)]
tansaku[1]=1
for i,j in l:
  miti[j].append(i)
  miti[i].append(j)
a = deque()
for i in miti[1]:
  a.append(i)
  me[i] = 1
  tansaku[i]=1
while len(a)!=0:
#  print(a)
  w = a.popleft()
  for j in miti[w]:
    if tansaku[j]==0 :
          a.append(j) 
          tansaku[j] = 1
          me[j] = w
 # print(w,tansaku,me,a)
  
print("Yes")
for i in range(len(miti)-2):
  print(me[i+2])