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

Fixed submission:
import sys

readline = sys.stdin.readline

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    tmp = []
    for i, a in enumerate(A):
        tmp.append((i, a))
    tmp.sort(key=lambda a: a[1])
    ans = []
    for i in tmp:
        ans.append(i[0]+1)
    print(*ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = []
for i in range(1, len(A)+1):
	ans.append(A.index(i+1))
print(*ans)
Problem p02923 (python)

Fixed submission:
import numpy as np
#from numba import jit
import sys

input = sys.stdin.readline

N = int(input())
H = np.array(input().split(), dtype=np.int64)

#@jit(nopython=True)
def main():
    Hdiff = np.diff(H)
    cnt = 0; ans = 0
    for h in Hdiff:
        if h <= 0:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import njit
import sys

input = sys.stdin.readline

N = int(input())
H = np.array(input().split(), dtype=np.int64)

@njit
def main():
    Hdiff = np.diff(H)
    cnt = 0; ans = 0
    for h in Hdiff:
        if h <= 0:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)
    print(ans)

if __name__ == "__main__":
    main()
Problem p02936 (python)

Fixed submission:
# 深さ優先探索の問題
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

N, Q = map(int, input().split())

# 隣接リスト
t = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = [int(i) for i in readline().split()]
    t[a-1].append(b-1)
    t[b-1].append(a-1)

# スコア
s = [0] * N
for _ in range(Q):
    p, x = [int(i) for i in readline().split()]
    #s[p-1] = s[p-1] + x
    s[p-1] += x

ans = [0] * N

# 深さ優先探索
def dfs(v, p, value):
    #value = value + s[v]
    value += s[v]
    ans[v] = value
    for c in t[v]:
        if c == p:
            continue
        dfs(c, v, value)

dfs(0, -1, 0)

print(*ans)

Buggy submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline

def dfs(fr, now, num):
    global graph, addsum, ans
    tmp = num + addsum[now]
    for a in graph[now]:
        if a == fr:
            continue
        dfs(now, a, tmp)
    ans[now] = tmp
    

def main():
    global graph, addsum, ans
    N, Q = map(int, readline().split())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, readline().split())
        a -= 1; b -= 1
        graph[a].append(b)
        graph[b].append(a)
    addsum = [0]*N
    for _ in range(Q):
        p, x = map(int, readline().split())
        p -= 1
        addsum[p] += x
    
    ans = [0]*N
    dfs(-1, 0, 0)

    print(*ans)


if __name__ == "__main__":
    main()
Problem p02995 (python)

Fixed submission:
from fractions import gcd

def main():
    A, B, C, D = map(int, input().split())
    nC = B//C - (A-1)//C
    nD = B//D - (A-1)//D
    CD = (C*D)//gcd(C, D)
    nCD = B//CD - (A-1)//CD
    cnt = nC + nD - nCD
    ans = B - A + 1 - cnt
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math

gcd = math.gcd

def main():
    A, B, C, D = map(int, input().split())
    nC = B//C - (A-1)//C
    nD = B//D - (A-1)//D
    CD = (C*D)//gcd(C, D)
    nCD = B//CD - (A-1)//CD
    cnt = nC + nD - nCD
    ans = B - A + 1 - cnt
    print(ans)

if __name__ == "__main__":
    main()
Problem p03007 (python)

Fixed submission:
from collections import deque
import bisect

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

    plus = []; minus = []
    for a in A:
        if a >= 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
        
    plus.sort()
    minus.sort()
    plus = deque(plus)
    minus = deque(minus)

    if N == 2:
        if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
        return

    anslist = []
    if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        ans = ltmp - stmp
        plus.append(ans)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
    else:
        pass

    for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
    print(ans)
    for s in anslist:
        print(*s)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
import bisect

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

    plus = []; minus = []
    for a in A:
        if a > 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
    
        
    plus.sort()
    minus.sort()
    plus = deque(plus)
    minus = deque(minus)
    anslist = []
    if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        plus.append(ltmp-stmp)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        minus.append(stmp-ltmp)
        N -= 1
    else:
        pass

    for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
    print(ans)
    for s in anslist:
        print(*s)

if __name__ == "__main__":
    main()
Problem p03231 (python)

Fixed submission:
import math

class common_function():
    """
        1. よく使いそうで予め用意しておいた変数をまとめた
        2. よく使いそうな関数群をまとめた
    """
    def lcm(self, x:int, y:int):
        """
            最小公倍数を返すメソッド
            math をインポートする
        """
        return (x * y) // math.gcd(x, y)
        

def main():
    common = common_function()
    N, M = map(int, input().split())
    S = input()
    T = input()
    lengthX = common.lcm(N, M)
    XdivS = lengthX//N
    XdivT = lengthX//M
    X = []
    for i in range(N):
        j = XdivS*i
        X.append((j, S[i]))
    X.sort(key=lambda x: x[0], reverse=True)
    
    k, x = X.pop()
    for i in range(M):
        j = XdivT*i
        for a in range(lengthX):
            if len(X) == 0:
                break
            if k < j:
                k, x = X.pop()
            else:
                break
        if k == j:
            if x != T[i]:
                print(-1)
                return
    print(lengthX)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math

class common_function():
    """
        1. よく使いそうで予め用意しておいた変数をまとめた
        2. よく使いそうな関数群をまとめた
    """
    def lcm(self, x:int, y:int):
        """
            最小公倍数を返すメソッド
            math をインポートする
        """
        return (x * y) // math.gcd(x, y)
        

def main():
    common = common_function()
    N, M = map(int, input().split())
    S = input()
    T = input()
    lengthX = common.lcm(N, M)
    XdivS = lengthX//N
    XdivT = lengthX//M
    X = ['0'] * lengthX
    for i in range(N):
        j = XdivS*i
        X[j] = S[i]
    
    for i in range(M):
        j = XdivT*i
        if X[j] == '0':
            continue
        if X[j] != T[i]:
            print(-1)
            return
    print(lengthX)

if __name__ == "__main__":
    main()
Problem p03274 (python)

Fixed submission:
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))

    ans = float('inf')
    for i in range(N-K+1):
        L = x[i]
        R = x[i+K-1]
        if R < 0:
            ans = min(ans, abs(L))
        elif L <= 0 <= R:
            ans = min(2*abs(R)+abs(L), 2*abs(L)+abs(R), ans)
        elif 0 < L:
            ans = min(ans, abs(R))
        else:
            continue
    
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import bisect

input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))
    if 0 in x:
        K -= 1
        x.remove(0)
    idx = bisect.bisect_left(x, 0)
    x.insert(idx, 0)
    ans1 = float('inf'); ans2 = float('inf')
    if N-idx >= K:
        ans1 = x[idx + K]
    if idx >= K:
        ans2 = abs(x[idx - K])
    ans3 = float('inf')
    for m in range(1, min(N-idx, K)+1):
        tmp = 2*x[idx+m] + abs(x[idx-(K-m)])
        ans3 = min(tmp, ans3)
    ans4 = float('inf')
    for m in range(1, min(idx, K)+1):
        tmp = 2*abs(x[idx-m]) + abs(x[idx+(K-m)])
        ans4 = min(tmp, ans4)
    ans = min(ans1, ans2, ans3, ans4)
    print(ans)

if __name__ == "__main__":
    main()
Problem p03359 (python)

Fixed submission:

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

if a <= b:
    ans = a
else:
    ans = a-1

print(ans)

Buggy submission (verdict: Runtime Error):

# import
import numpy as np
import sys
sys.setrecursionlimit(10**6)

# input
H, W = map(int, input().split())

Mtmp = []
for _ in range(H):
    tmp = list(input())
    Mtmp.append(tmp)

M = np.array(Mtmp)
S = np.array([[0]*W]*H)

#print(M)

digtmp = np.array([[0, 1], [1, 0], [0, -1], [-1, 0]])

def dfs(i, j):
    global ngflag
    global searchflag
    if S[i, j] == 1:
        return
    S[i, j] = 1
    if M[i, j] == '.':
        return
    #print("i:{}, j:{}".format(i, j))
    searchflag = 1
    dig = digtmp + np.array([i, j])
    for d in dig:
        if 0 <= d[0] < H and 0 <= d[1] < W:
            if M[d[0], d[1]] == '#':
                ngflag = 0
                dfs(d[0], d[1])

searchflag = 0
ngflag = 1

while True:
    if 0 not in S:
        if M[target[0], target[1]] == '.':
            ngflag = 0
        break
    target = list(zip(*np.where(S == 0)))[0]
    #print("sf:{}, ng:{}".format(searchflag, ngflag))
    if M[target[0], target[1]] == '#':
        ngflag = 1
    dfs(target[0], target[1])
    if M[target[0], target[1]] == '#' and searchflag == 1 and ngflag == 1:
        break


#print("sf:{}, ng:{}".format(searchflag, ngflag))

if searchflag == 1 and ngflag == 0:
    ans = 'Yes'
elif searchflag == 1 and ngflag == 1:
    ans = 'No'
else:
    ans = 'Yes'

print(ans)

Buggy submission (verdict: Runtime Error):

# import
import numpy as np
import sys
sys.setrecursionlimit(10**6)

# input
H, W = map(int, input().split())

Mtmp = []
for _ in range(H):
    tmp = list(input())
    Mtmp.append(tmp)

M = np.array(Mtmp)
S = np.array([[0]*W]*H)

print(M)

digtmp = np.array([[0, 1], [1, 0], [0, -1], [-1, 0]])

def dfs(i, j):
    global ngflag
    global searchflag
    if S[i, j] == 1:
        return
    S[i, j] = 1
    if M[i, j] == '.':
        return
    print("i:{}, j:{}".format(i, j))
    searchflag = 1
    dig = digtmp + np.array([i, j])
    for d in dig:
        if 0 <= d[0] < H and 0 <= d[1] < W:
            if M[d[0], d[1]] == '#':
                ngflag = 0
                dfs(d[0], d[1])

searchflag = 0
ngflag = 1

while True:
    if 0 not in S:
        if M[target[0], target[1]] == '.':
            ngflag = 0
        break
    target = list(zip(*np.where(S == 0)))[0]
    print("sf:{}, ng:{}".format(searchflag, ngflag))
    if M[target[0], target[1]] == '#':
        ngflag = 1
    dfs(target[0], target[1])
    if M[target[0], target[1]] == '#' and searchflag == 1 and ngflag == 1:
        break


print("sf:{}, ng:{}".format(searchflag, ngflag))

if searchflag == 1 and ngflag == 0:
    ans = 'Yes'
elif searchflag == 1 and ngflag == 1:
    ans = 'No'
else:
    ans = 'Yes'

print(ans)
Problem p03377 (python)

Fixed submission:
A, B, X = map(int, input().split())
T = A+B

if A <= X and X <= T:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A, B, X = input().split()

if A <= X <= (A+B):
    print('Yes')
else
    print('No')
Problem p03425 (python)

Fixed submission:
import sys
import itertools

input = sys.stdin.readline

def main():
    N = int(input())
    l = ['M', 'A', 'R', 'C', 'H']
    m = [0]*5
    for _ in range(N):
        S = input()[:-1]
        Shead = S[0]
        for i, s0 in enumerate(l):
            if Shead == s0:
                m[i] += 1
                break
    ll = []
    for i, n in enumerate(m):
        if n >= 1:
            ll.append(l[i])
    if len(ll) <= 2:
        print(0)
        return
    ans = 0
    for i, j, k in itertools.combinations(ll, 3):
        ans += m[l.index(i)] * m[l.index(j)] * m[l.index(k)]

    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import itertools

input = sys.stdin.readline

def main():
    common = common_function()
    N = int(input())
    l = ['M', 'A', 'R', 'C', 'H']
    m = [0]*5
    for _ in range(N):
        S = input()[:-1]
        Shead = S[0]
        for i, s0 in enumerate(l):
            if Shead == s0:
                m[i] += 1
                break
    ll = []
    for i, n in enumerate(m):
        if n >= 1:
            ll.append(l[i])
    if len(ll) <= 2:
        print(0)
        return
    ans = 0
    for i, j, k in itertools.combinations(ll, 3):
        ans += m[l.index(i)] * m[l.index(j)] * m[l.index(k)]

    print(ans)

if __name__ == "__main__":
    main()
Problem p03436 (python)

Fixed submission:
import sys
from collections import deque

input = sys.stdin.readline
digtmp = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    H, W = map(int, input().split())
    grid = []; cnt = 0
    grid.append(['#'] * (W+2))
    for _ in range(H):
        tmp = list(input())
        cnt += sum([1 for x in tmp if x == '#'])
        grid.append(['#'] + tmp + ['#'])
    grid.append(['#'] * (W+2))

    que = deque([(1, 1)])
    grid[1][1] = 1
    for _ in range(10000):
        a, b = que.popleft()
        for dx, dy in digtmp:
            x, y = (a + dx, b + dy)
            if grid[x][y] == '.':
                grid[x][y] = grid[a][b] + 1
                que.append((x, y))
        if len(que) == 0:
            break
    if grid[H][W] in ['#', '.']:
        print(-1)
        return
    ans = H*W - grid[H][W] - cnt
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque

input = sys.stdin.readline
digtmp = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    H, W = map(int, input().split())
    grid = []; cnt = 0
    grid.append(['#'] * (W+2))
    for _ in range(H):
        tmp = list(input())
        cnt += sum([1 for x in tmp if x == '#' ])
        grid.append(['#'] + tmp + ['#'])
    grid.append(['#'] * (W+2))

    que = deque([(1, 1)])
    grid[1][1] = 1
    for _ in range(10000):
        a, b = que.popleft()
        for dx, dy in digtmp:
            x, y = (a + dx, b + dy)
            if grid[x][y] == '.':
                grid[x][y] = grid[a][b] + 1
                que.append((x, y))
        if len(que) == 0:
            break
    if grid[H][W] == '#':
        print(-1)
        return
    ans = H*W - grid[H][W] - cnt
    print(ans)

if __name__ == "__main__":
    main()
Problem p03633 (python)

Fixed submission:
import fractions
import sys
#import numpy as np

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

def main():
    N = int(input())
    for i in range(N):
        if i == 0:
            tmp = int(input())
        else:
            a = int(input())
            b = lcm_base(a, tmp)
            tmp = b
    if N == 1:
        print(tmp)
    else:
        print(b)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions
import sys
#import numpy as np

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

def main():
    N = int(input())
    for i in range(N):
        if i == 0:
            tmp = int(input())
        else:
            a = int(input())
            b = lcm_base(a, tmp)
            tmp = b
    print(b)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions
import sys
#import numpy as np

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

def main():
    N = int(input())
    for i in range(N):
        if i == 0:
            tmp = int(input())
        else:
            a = int(input())
            b = lcm_base(a, tmp)
            tmp = b
    print(b)

if __name__ == "__main__":
    main()

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

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

def main():
    N = int(input())
    for i in range(N):
        if i == 0:
            tmp = int(input())
        else:
            a = int(input())
            b = lcm_base(a, tmp)
            tmp = b
    print(b)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math

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

def main():
    N = int(input())
    for i in range(N):
        if i == 0:
            b = int(input())
        else:
            a = int(input())
            b = lcm_base(a, b)
    print(b)

if __name__ == "__main__":
    main()
Problem p03830 (python)

Fixed submission:
import sys
import collections

sys.setrecursionlimit(10**6)
MOD = pow(10,9)+7

def kaijo(n):
    if n <= 1:
        return 1
    else:
        return n * kaijo(n-1)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    N = int(input())
    if N == 1:
        print(1)
        return
    counter = collections.Counter([])
    for n in range(N, 0, -1):
        counter += collections.Counter(prime_factorize(n))
    items = list(zip(*counter.items()))
    ans = 1
    for i in items[1]:
        ans *= i+1
        ans %= MOD
    print(ans)

    #n = kaijo(N)
    #print(n)
    #m = make_divisors(n)
    ##m.sort()
    #print(m)
    #print(len(m)%MOD)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import collections

sys.setrecursionlimit(10**6)
MOD = pow(10,9)+7

def kaijo(n):
    if n <= 1:
        return 1
    else:
        return n * kaijo(n-1)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    N = int(input())
    counter = collections.Counter([])
    for n in range(N, 0, -1):
        counter += collections.Counter(prime_factorize(n))
    items = list(zip(*counter.items()))
    ans = 1
    for i in items[1]:
        ans *= i+1
        ans %= MOD
    print(ans)

    #n = kaijo(N)
    #print(n)
    #m = make_divisors(n)
    ##m.sort()
    #print(m)
    #print(len(m)%MOD)

if __name__ == "__main__":
    main()
Problem p04045 (python)

Fixed submission:
def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))
    numset = set(range(0,10))
    d = numset.difference(D)

    for n in range(N, pow(10, 6) + 10):
        check = set(list(str(n)))
        ngflag = False
        for i in check:
            if int(i) in D:
                ngflag = True
                break
        if not ngflag:
            break
    print(n)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def minN(N:int, usable:list, restrict=True):
    usable.sort()
    if restrict:
        for i in usable:
            if i >= N:
                return str(i)
    else:
        return str(usable[0])


def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))
    numset = set(range(0,10))
    d = list(numset.difference(D))
    d.sort()

    Nstr = list(str(N))
    ans = ''
    flag = True
    for n in Nstr:
        n = int(n)
        if flag:
            if n in D:
                ans += minN(n, d)
                flag = False
            else:
                ans += str(n)
        else:
            ans += str(min(d))
    print(int(ans))

if __name__ == "__main__":
    main()
Problem p02576 (python)

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

if n%x==0:
  print(t*(n//x))
else:
  print(((n//x)+1)*t)

Buggy submission (verdict: Runtime Error):
from collections import deque
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())

maze = [list(input()) for i in range(h)]
ans = [[-1]*w for i in range(h)]
ans[ch-1][cw-1]=0

qu = deque([])
qu.append((cw-1,ch-1))
while qu:
  x,y=qu.popleft()

  for i in range(max(x-2,0),min(x+3,w)):
    for j in range(max(y-2,0),min(y+3,h)):
      if (x==i and y==j):
        continue
      if maze[j][i]=="." and (ans[j][i]>ans[y][x] or ans[j][i]==-1):
        if (x==i and y==j+1) or (x==i+1 and y==j) or (x==i-1 and y==j) or (x==i and y==j-1):
          qu.appendleft((i,j))
          ans[j][i] = ans[y][x]
        elif ans[j][i]>ans[y][x]+1 or ans[j][i]==-1:
          ans[j][i]=(ans[y][x]+1)
          qu.appendleft((i,j))

print(ans[dh-1][dw-1])
Problem p02642 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = [int(v) for v in input().split()]
 
M = max(a)
d = [1 for i in range(M+1)]
for v in sorted(a):
    for j in range(2*v, M+1, v):
        d[j] = 0
ans = 0
c = Counter(a)
for i in a:
    if c[i]==1:
      ans += d[i]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
ab=list(map(int,input().split()))
M=max(ab)
a=[]
for i in Counter(ab):
  if Counter(ab)[i]==1:
    a.append(i)
ans=set([])
a.sort()
ans_count=0
N=0
if len(a)==0:
  print(0)
else:
  for i in range(n):
    if not a[i] in ans:
      N=a[i]
      count=1
      ans.add(N)
      ans_count+=1
      for j in range(2*N,M+1,N):
        ans.add(j)
  print(ans_count)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
ab=list(map(int,input().split()))
a=[]
for i in Counter(ab):
  if Counter(ab)[i]==1:
    a.append(i)
ans=set([])
a.sort()
ans_count=0
N=10**9+1
if len(a)==0:
  print(0)
else:
  for i in range(n):
    if not a[i] in ans:
      N=a[i]
      count=1
      ans.add(N)
      ans_count+=1
      while N*count<10**6+1:
        count+=1
        ans.add(N*count)
  print(ans_count)