Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
N, M = map(int,input().split())
bridge = []
for i in range(M):
    A, B = map(int,input().split())
    bridge.append((A - 1, B - 1))
    
uf = UnionFind(N)
ans = N * (N - 1) // 2
cnt = 0
for i in range(M):
    A, B = bridge[i]
    if not same(A, B):
        cnt += size(A) * size(B)
        union(A, B)
    print(ans - cnt)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
N, M = map(int,input().split())
bridge = []
for i in range(M):
    A, B = map(int,input().split())
    bridge.append((A - 1, B - 1))
    
uf = UnionFind(N)
ans = [N * (N - 1) // 2]
cnt = 0
for i in range(M - 1):
    A, B = bridge[-i-1]
    if not uf.same(A, B):
        cnt += uf.size(A) * uf.size(B)
        uf.union(A, B)
    ans.append(ans[0] - cnt)
for i in range(M):
    print(ans[-i-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
for i in range(M // N, 0, -1):
    if M % i == 0:
        print(i)
        break

Fixed submission:
N, M = map(int,input().split())
for i in range(M // N, 0, -1):
    if M % i == 0:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
s = input()
S = []
xid = [0] * (10 ** 5)
xcnt = 0
for c in s:
    if c != "x":
        S.append(c)
        xcnt += 1
    else:
        xid[xcnt] += 1
xid = xid[:xcnt + 1]
ans = 0
if S[0:xcnt // 2] == S[-1:-(xcnt // 2) - 1:-1]:
    for i in range(-(-xcnt // 2)):
        ad = xid[i] - xid[xcnt - i]
        if ad < 0:
            ad = -ad
        ans += ad
    print(ans)
else:
    print(-1)

Fixed submission:
s = input()
S = []
xid = [0] * (10 ** 5 + 1)
xcnt = 0
for c in s:
    if c != "x":
        S.append(c)
        xcnt += 1
    else:
        xid[xcnt] += 1
xid = xid[:xcnt + 1]
ans = 0
if S[0:xcnt // 2] == S[-1:-(xcnt // 2) - 1:-1]:
    for i in range(-(-xcnt // 2)):
        ad = xid[i] - xid[xcnt - i]
        if ad < 0:
            ad = -ad
        ans += ad
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if (N * h * n) % (4 * h * n - N * n - N * h) == 0:
            w = (N * h * n) // (4 * h * n - N * n - N * h)
            print(h, n, w)
            break

Fixed submission:
N = int(input())
end = False
for h in range(1, 3501):
    if end:
        break
    for n in range(1, 3501):
        if (4 * h * n - N * n - N * h):
            if (N * h * n) % (4 * h * n - N * n - N * h) == 0:
                w = (N * h * n) // (4 * h * n - N * n - N * h)
                if w > 0:
                    print(h, n, w)
                    end = True
                    break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
c = []
for i in A:
    if i in c:
        c.remove(i)
    else:
        c.append(i)
print(len(c))

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
count = 1
ans = 0
for i in range(1,N):
    if A[i - 1] == A[i]:
        count += 1
    else:
        if count % 2 == 1:
            ans += 1
        count = 1
if count % 2 == 1:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b > a:
        return gcd(b,a)
    if b == 0:
        return a
    c = a % b
    return gcd(b,c)

N = int(input())
ans = int(input())
for i in range(N - 1):
    a = int(input())
    ans = ans * a / gcd(ans,a)
print(int(ans))

Fixed submission:
def gcd(a,b):
    if b > a:
        return gcd(b,a)
    if b == 0:
        return a
    c = a % b
    return gcd(b,c)

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
for i in T:
    ans = ans * i // gcd(ans,i)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b > a:
        return gcd(b,a)
    if b == 0:
        return a
    c = a % b
    return gcd(b,c)

N = int(input())
ans = int(input())
for i in range(N - 1):
    a = int(input())
    ans = ans * a / gcd(ans,a)
print(int(ans))

Fixed submission:
def gcd(a,b):
    if b > a:
        return gcd(b,a)
    if b == 0:
        return a
    c = a % b
    return gcd(b,c)

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
for i in T:
    ans = ans * i // gcd(ans,i)
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = []
for i in range(N):
    x,y = list(map(int,input().split()))
    a = [x] * y
    A += a
A.sort()
print(A[K - 1])

Fixed submission:
from heapq import heappop,heappush
N,K = map(int,input().split())
A = []
for i in range(N):
    a = list(map(int,input().split()))
    heappush(A,a)
count = 0
while count < K:
    x,y = heappop(A)
    count += y
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, L = map(int,input().split())
data = [[0, 0] for _ in range(N)]
Lpath = [[] for _ in range(N)]
Tpath = [[] for _ in range(N)]

for _ in range(K):
    p, q = map(int,input().split())
    p -= 1
    q -= 1
    Lpath[p].append(q)
    Lpath[q].append(p)
    
for _ in range(L):
    r, s = map(int,input().split())
    r -= 1
    s -= 1
    Tpath[r].append(s)
    Tpath[s].append(r)
    
for i in range(N):
    if data[i][0]:
        continue
    data[i][0] = i + 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in Lpath[s]:
            if data[to][0]:
                continue
            data[to][0] = i + 1
            stack.append(to)

for i in range(N):
    if data[i][1]:
        continue
    data[i][1] = i + 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in Tpath[s]:
            if data[to][1]:
                continue
            data[to][1] = i + 1
            stack.append(to)

ans = [0] * N
            
for i in range(N):
    ans[i] = data.count(data[i])

print(*ans)

Fixed submission:
from collections import defaultdict
N, K, L = map(int,input().split())
data = [[0, 0] for _ in range(N)]
Lpath = [[] for _ in range(N)]
Tpath = [[] for _ in range(N)]

for _ in range(K):
    p, q = map(int,input().split())
    p -= 1
    q -= 1
    Lpath[p].append(q)
    Lpath[q].append(p)
    
for _ in range(L):
    r, s = map(int,input().split())
    r -= 1
    s -= 1
    Tpath[r].append(s)
    Tpath[s].append(r)
    
for i in range(N):
    if data[i][0]:
        continue
    data[i][0] = i + 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in Lpath[s]:
            if data[to][0]:
                continue
            data[to][0] = i + 1
            stack.append(to)

for i in range(N):
    if data[i][1]:
        continue
    data[i][1] = i + 1
    stack = [i]
    while stack:
        s = stack.pop()
        for to in Tpath[s]:
            if data[to][1]:
                continue
            data[to][1] = i + 1
            stack.append(to)

ans = [0] * N
d = defaultdict(int)         
for i in range(N):
    d[tuple(data[i])] += 1
for i in range(N):
    ans[i] = d[tuple(data[i])]

print(*ans)
Buggy python submission (verdict: Runtime Error):
S = input()
print("A" + a[8] + "C")

Fixed submission:
S = input()
print("A" + S[8] + "C")
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int,input().split())
ans = False
if a == b + c or b = a + c or c = a + b:
    ans = True
if ans:
    print("Yes")
else:
    print("No")

Fixed submission:
a, b, c = map(int,input().split())
ans = False
if a == b + c or b == a + c or c == a + b:
    ans = True
if ans:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
g = 0
p = 0
for i in s:
    if i = "g":
        g += 1
    if i = "p":
        p += 1
print((g - p) // 2)

Fixed submission:
s = input()
g = 0
p = 0
for i in s:
    if i == "g":
        g += 1
    if i == "p":
        p += 1
print((g - p) // 2)

Buggy python submission (verdict: Runtime Error):
s = input()
g = 0
p = 0
for i in s:
    if i = "g":
        g += 1
    if i = "p":
        p += 1
print((g - p) // 2)

Fixed submission:
s = input()
g = 0
p = 0
for i in s:
    if i == "g":
        g += 1
    if i == "p":
        p += 1
print((g - p) // 2)
Buggy python submission (verdict: Runtime Error):
w = input()
a = "abcdefghijklmnopqrstuvwxyz"
co = 0
ch = True
for i in a:
    for j in w:
        if i == j:
            co += 1:
    if co % 2:
        ch = False
        break
    co = 0
    
    
if ch:
    print("yes")
else:
    print("No")

Fixed submission:
w = input()
a = "abcdefghijklmnopqrstuvwxyz"
co = 0
ch = True
for i in a:
    for j in w:
        if i == j:
            co += 1
    if co % 2:
        ch = False
        break
    co = 0
    
    
if ch:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
w = input()
a = "abcdefghijklmnopqrstuvwxyz"
co = 0
ch = True
for i in a:
    for j in w:
        if i = j:
            co += 1:
    if co % 2:
        ch = False
        break
    co = 0
    
    
if ch:
    print("yes")
else:
    print("No")

Fixed submission:
w = input()
a = "abcdefghijklmnopqrstuvwxyz"
co = 0
ch = True
for i in a:
    for j in w:
        if i == j:
            co += 1
    if co % 2:
        ch = False
        break
    co = 0
    
    
if ch:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
w = input()
a = "abcdefghijklmnopqrstuvwxyz"
co = 0
ch = True
for i in a:
    for j in w:
        if i = j:
            co += 1:
    if co % 2:
        ch = False
        break
    co = 0
    
    
if ch:
    print("yes")
else:
    print("No")

Fixed submission:
w = input()
a = "abcdefghijklmnopqrstuvwxyz"
co = 0
ch = True
for i in a:
    for j in w:
        if i == j:
            co += 1
    if co % 2:
        ch = False
        break
    co = 0
    
    
if ch:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
w = input()
a = abcdefghijklmnopqrstuvwxyz
co = 0
ch = True
for i in a:
    for j in w:
        if i = j:
            co += 1:
    if co % 2:
        ch = False
        break
if ch:
    print("yes")
else:
    print("No")

Fixed submission:
w = input()
a = "abcdefghijklmnopqrstuvwxyz"
co = 0
ch = True
for i in a:
    for j in w:
        if i == j:
            co += 1
    if co % 2:
        ch = False
        break
    co = 0
    
    
if ch:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
B = int(input())
L = list(map(int, input().split()))
d=L[0]
mod=1000000007
for i in range(B):
  d=lcm(d,L[i])
ans=0
for i in range(B):
  ans+=d//L[i]
  ans%=mod
print(ans)

Fixed submission:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
B = int(input())
L = list(map(int, input().split()))
d=L[0]
mod=1000000007
for i in range(B):
  d=lcm(d,L[i])
ans=0
for i in range(B):
  ans+=d//L[i]
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
B = int(input())
L = list(map(int, input().split()))
d=L[0]
mod=1000000007
for i in range(B):
  d=lcm(d,L[i])
ans=0
for i in range(B):
  ans+=d//L[i]
  ans%=mod
print(ans)

Fixed submission:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
B = int(input())
L = list(map(int, input().split()))
d=L[0]
mod=1000000007
for i in range(B):
  d=lcm(d,L[i])
ans=0
for i in range(B):
  ans+=d//L[i]
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort(reverse=True)
F.sort()
ng=-1
ok=10**18+1
while ok-ng>1:
             mid=(ng+ok)//2
             k=K
             for a,f in zip(A,F):
                     k-=max(0,a-mid//f)
             if k<0:
                 ng=mid
             else:
                ok=mid
print(ok)

Fixed submission:
n,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort(reverse=True)
F.sort()
ng=-1
ok=10**18+1
while ok-ng>1:
             mid=(ng+ok)//2
             k=K
             for a,f in zip(A,F):
                     k-=max(0,a-mid//f)
             if k<0:
                 ng=mid
             else:
                ok=mid
print(ok)
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
print((a*3+b)/2)

Fixed submission:
a,p=map(int,input().split())
print((a*3+p)//2)

Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
print((a*3+b)/2)

Fixed submission:
a,p=map(int,input().split())
print((a*3+p)//2)
Buggy python submission (verdict: Time Limit Exceeded):
int1 = lambda x: int(x) - 1

N, K = map(int, input().split())
P = tuple(map(int1, input().split()))
C = tuple(map(int, input().split()))

visited = set()
cycles = []
for i in range(N):
    if i not in visited:
        cur = P[i]
        cycle = [i]
        while cur != i:
            visited.add(cur)
            cycle.append(cur)
            cur = P[cur]
        cycles.append(cycle)

ans = -float('inf')
for cycle in cycles:
    score = [0]
    for x in cycle * 2:
        score.append(score[-1] + C[x])

    # i回進めるときのスコア最大値
    lst = [0] * (min(K, len(cycle)) + 1)
    lst[0] = -float('inf')
    for i in range(1, min(K, len(cycle)) + 1):
        tmp = -float('inf')
        for j in range(len(cycle)):
            tmp = max(tmp, score[j + i] - score[j])
        lst[i] = tmp

    lap = K // len(cycle)
    if lap == 0:
        ans = max(ans,
                  max(lst))
    else:
        around_score = lst[len(cycle)]
        ans = max(ans,
                  max(lst),
                  around_score * (lap - 1) + max(lst),
                  around_score * lap + max(lst[:K % len(cycle) + 1]))
print(ans)


Fixed submission:
int1 = lambda x: int(x) - 1

N, K = map(int, input().split())
P = tuple(map(int1, input().split()))
C = tuple(map(int, input().split()))

visited = set()
cycles = []
for i in range(N):
    if i not in visited:
        cur = P[i]
        cycle = [i]
        while cur != i:
            visited.add(cur)
            cycle.append(cur)
            cur = P[cur]
        cycles.append(cycle)

ans = -float('inf')
for cycle in cycles:
    l = len(cycle)
    score = [0]
    for x in cycle * 2:
        score.append(score[-1] + C[x])

    # i回進めるときのスコア最大値
    lst = [0] * (min(K, l) + 1)
    lst[0] = -float('inf')
    for i in range(1, min(K, l) + 1):
        tmp = -float('inf')
        for j in range(l):
            tmp = max(tmp, score[j + i] - score[j])
        lst[i] = tmp

    lap = K // l
    if lap == 0:
        ans = max(ans,
                  max(lst))
    else:
        around_score = lst[l]
        ans = max(ans,
                  max(lst),
                  around_score * (lap - 1) + max(lst),
                  around_score * lap + max(lst[:K % l + 1]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

ceil = lambda a, b: (a + b - 1) // b

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

h = [(-a, a, 1) for a in A]
heapq.heapify(h)
for _ in range(K):
    l, a, ct = heapq.heappop(h)
    ct += 1
    heapq.heappush(h, (-a / ct, a, ct))
_, a, ct = heapq.heappop(h)
print(ceil(a, ct))


Fixed submission:
ceil = lambda a, b: (a + b - 1) // b

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

# bisect
l, r = 0, max(A)
while r - l > 1:
    m = (l + r) // 2
    if sum(ceil(x, m) - 1 for x in A) > K:
        l = m
    else:
        r = m
print(r)
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = input()
Xi = int(X, 2)

c0 = X.count('1')
Xp = Xi % (c0 + 1)
Xm = Xi % (c0 - 1)

for i, x in enumerate(X):
    if x == '1':
        if c0 == 1:
            print(0)
            continue
        y = (Xm - pow(2, N - 1 - i, c0 - 1)) % (c0 - 1)
    else:
        y = (Xp + pow(2, N - 1 - i, c0 + 1)) % (c0 + 1)

    ans = 1
    while y:
        y %= bin(y).count('1')
        ans += 1
    print(ans)


Fixed submission:
N = int(input())
X = input()
Xi = int(X, 2)

c0 = X.count('1')
Xp = Xi % (c0 + 1)

if c0 != 1:
    Xm = Xi % (c0 - 1)

for i, x in enumerate(X):
    if x == '1':
        if c0 == 1:
            print(0)
            continue
        y = (Xm - pow(2, N - 1 - i, c0 - 1)) % (c0 - 1)
    else:
        y = (Xp + pow(2, N - 1 - i, c0 + 1)) % (c0 + 1)

    ans = 1
    while y:
        y %= bin(y).count('1')
        ans += 1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = input()
Xi = int(X, 2)

c0 = X.count('1')
for i, x in enumerate(X):
    if x == '1':
        y = Xi - (1 << (N - 1 - i))
        c = c0 - 1
    else:
        y = Xi + (1 << (N - 1 - i))
        c = c0 + 1

    if not y:
        print(0)
        continue
    y %= c
    ans = 1
    while y:
        y %= bin(y).count('1')
        ans += 1
    print(ans)


Fixed submission:
N = int(input())
X = input()
Xi = int(X, 2)

c0 = X.count('1')
Xp = Xi % (c0 + 1)

if c0 != 1:
    Xm = Xi % (c0 - 1)

for i, x in enumerate(X):
    if x == '1':
        if c0 == 1:
            print(0)
            continue
        y = (Xm - pow(2, N - 1 - i, c0 - 1)) % (c0 - 1)
    else:
        y = (Xp + pow(2, N - 1 - i, c0 + 1)) % (c0 + 1)

    ans = 1
    while y:
        y %= bin(y).count('1')
        ans += 1
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
S = input()
L = len(S)

MOD = 10 ** 9 + 7
modinv = lambda a, mod=MOD: pow(a, -1, mod)

# x: 26^k*25^(K-k)
x = pow(26, K, MOD)

# comb: C(L+K-i-1, L-1)
comb = 1

ans = 0
for i in range(K, -1, -1):
    ans = (ans + comb * x) % MOD
    x = x * 25 * modinv(26) % MOD
    comb = comb * (L + K - i) * modinv(K - i + 1) % MOD
print(ans)


Fixed submission:
K = int(input())
S = input()
L = len(S)

MOD = 10 ** 9 + 7
modinv = lambda a, mod=MOD: pow(a, MOD - 2, mod)

# x: 26^k*25^(K-k)
x = pow(26, K, MOD)

# comb: C(L+K-i-1, L-1)
comb = 1

ans = 0
for i in range(K, -1, -1):
    ans = (ans + comb * x) % MOD
    x = x * 25 * modinv(26) % MOD
    comb = comb * (L + K - i) * modinv(K - i + 1) % MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

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

MAX = 10 ** 6
is_divisible = [True] * (MAX + 1)
is_divisible[0] = False
for i in A:
    if not is_divisible[i]:
        continue
    for j in range(i * 2, MAX + 1, i):
        is_divisible[j] = False

for k, v in Counter(A).items():
    if v > 1:
        is_divisible[k] = False

st = {i for i in range(MAX + 1) if is_divisible[i]}
print(len(st & set(A)))


Fixed submission:
from collections import Counter

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

MAX = 10 ** 6
is_divisible = [True] * (MAX + 1)
is_divisible[0] = False
for i in S:
    if not is_divisible[i]:
        continue
    for j in range(i * 2, MAX + 1, i):
        is_divisible[j] = False

for k, v in Counter(A).items():
    if v > 1:
        is_divisible[k] = False

ans = len([a for a in A if is_divisible[a]])
print(ans)

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

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

MAX = 10 ** 6
is_divisible = [True] * (MAX + 1)
is_divisible[0] = False
for i in A:
    if not is_divisible[i]:
        continue
    for j in range(i * 2, MAX + 1, i):
        is_divisible[j] = False

for k, v in Counter(A).items():
    if v > 1:
        is_divisible[k] = False

st = {i for i in range(MAX + 1) if is_divisible[i]}
print(len(st & set(A)))


Fixed submission:
from collections import Counter

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

MAX = 10 ** 6
is_divisible = [True] * (MAX + 1)
is_divisible[0] = False
for i in S:
    if not is_divisible[i]:
        continue
    for j in range(i * 2, MAX + 1, i):
        is_divisible[j] = False

for k, v in Counter(A).items():
    if v > 1:
        is_divisible[k] = False

ans = len([a for a in A if is_divisible[a]])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = map(int, input().split())
A = list(map(int, input().split()))
end = [N] * N

for _ in range(K):
    lst = [0] * N
    for i, a in enumerate(A):
        lst[max(0, i - a)] += 1
        if i + a + 1 < N:
            lst[i + a + 1] -= 1
    A = list(itertools.accumulate(lst))
    if A == end:
        break
print(*A)


Fixed submission:
import itertools

N, K = map(int, input().split())
A = list(map(int, input().split()))
end = [N] * N

for _ in range(K):
    lst = [0] * N
    for i, a in enumerate(A):
        lst[max(0, i - a)] += 1
        if i + a + 1 < N:
            lst[i + a + 1] -= 1
    A = list(itertools.accumulate(lst))
    if A == end:
        break
print(*A)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from fractions import Fraction

N = int(input())
X = [tuple(map(int, input().split())) for _ in range(N)]

MOD = 1000000007
d_plus = defaultdict(int)  # + or ∞
d_minus = defaultdict(int)  # - or 0
ans = 1

for i, (a, b) in enumerate(X):
    if a == 0 and b == 0:
        continue
    elif a == 0:
        d_minus[0] += 1
    elif b == 0:
        d_plus[float('inf')] += 1
    elif a * b > 0:
        d_plus[Fraction(a, b)] += 1
    else:
        d_minus[Fraction(a, b)] += 1


def pair(p):
    if p == 0:
        return float('inf')
    elif p == float('inf'):
        return 0
    else:
        return -1 / p


for m in d_minus:
    d_plus[pair(m)] += 0
for p in d_plus:
    ans = ans * (pow(2, d_plus[p], MOD) + pow(2, d_minus[pair(p)], MOD) - 1)
    ans %= MOD
print((ans - 1) % MOD)


Fixed submission:
N = int(input())
if N % 10 in {2, 4, 5, 7, 9}:
    print('hon')
elif N % 10 in {0, 1, 6, 8}:
    print('pon')
else:
    print('bon')