Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,T = map(int,input().split())
Ts = [int(i) for i in input().split()]
flow = set()
for i in range(N):
    flow = set(list(flow)+list(range(Ts[i]+1,Ts[i]+T+1)))
print(len(flow))

Fixed submission:
N,T = map(int,input().split())
t = [int(i) for i in input().split()]
fin = 0
ans = 0
for i in range(N):
    if t[i] <= fin - T:
        continue
    elif fin <= t[i]:
        fin = t[i]+T
        ans += T
    else:
        ans += T+t[i]-fin
        fin += T+t[i]-fin
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(n):
    ans *= i+1
print(ans%(10**9+7))

Fixed submission:
n = int(input())
ans = 1
c = 10**9+7
for i in range(n):
    ans = (ans*(i+1))%c
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()

if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")


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

if a + b == 15:
    print("+")
elif a * b == 15:
    print("*")
else:
    print("x")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = set(map(int, input().split()))

print('Three' if len(S) == 3 else 'Four')


Fixed submission:
N = int(input())
S = set(input().split())

print('Three' if len(S) == 3 else 'Four')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


def next_time(i, t):
    a = S[i]
    while a < t:
        a += F[i]
    return a


for i in range(N):
    time = 0
    for j in range(i, N - 1):
        time = next_time(j, time)
        time += C[j]

    print(time)


Fixed submission:
N = int(input())
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


def next_time(i, t):
    a = S[i]
    if t - a < 0:
        return a
    if t % F[i] == 0:
        return t
    b = (t - a + F[i] - 1) // F[i]
    # print(i, t, a, b, t + b * F[i])
    assert (a + b * F[i]) % F[i] == 0
    return a + b * F[i]


for i in range(N):
    time = 0
    for j in range(i, N - 1):
        time = next_time(j, time)
        time += C[j]

    print(time)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = map(int, input().split())

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0
i = 0

while len(cnt) > K:
    ans += cnt[i][1]
    i += 1

print(ans)


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

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0

for i in range(len(cnt)):
    if len(cnt) - i <= K:
        break
    ans += cnt[i][1]

print(ans)

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

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0

while len(cnt) > K:
    ans += cnt[0][1]
    cnt = cnt[1:]

print(ans)


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

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0

for i in range(len(cnt)):
    if len(cnt) - i <= K:
        break
    ans += cnt[i][1]

print(ans)

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

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0

while len(cnt) > K:
    ans += cnt[0][1]
    cnt = cnt[1:]

print(ans)


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

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0

for i in range(len(cnt)):
    if len(cnt) - i <= K:
        break
    ans += cnt[i][1]

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
l = sorted(map(int, input().split()), reversed=True)
print(sum(l[:K]))

Fixed submission:
N, K = map(int, input().split())
l = sorted(map(int, input().split()), reverse=True)
print(sum(l[:K]))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
l = soted(map(int, input().split()), reversed=True)
print(sum(l[:K]))

Fixed submission:
N, K = map(int, input().split())
l = sorted(map(int, input().split()), reverse=True)
print(sum(l[:K]))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
l = soted(map(int, input().split()))
print(sum(l[:-K]))


Fixed submission:
N, K = map(int, input().split())
l = sorted(map(int, input().split()), reverse=True)
print(sum(l[:K]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

nums = map(int, input().split())

ans = 1

for num in nums:
  ans *= num
  
if ans > 10 ** 18:
  print(-1)
else:
  print(ans)

Fixed submission:
n = int(input())

MAX_NUM = 10 ** 18

nums = list(map(int, input().split()))

for num in nums:
  if num == 0:
    print(0)
    exit()

ans = 1
for num in nums:
  ans *= num
  if ans > MAX_NUM:
    print(-1)
    exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

s = 0
s += min(a, d)
if min(a, d) == d:
  print(s)
elif min(a+b, d) == d
  print(a)
else:
  d -= a + b
  print(a-min(c, d))

Fixed submission:
a, b, c, d = map(int, input().split())

s = 0
s += min(a, d)
if min(a, d) == d:
  print(s)
elif min(a+b, d) == d:
  print(a)
else:
  d -= a + b
  print(a-min(c, d))
Buggy python submission (verdict: Runtime Error):
x, y, A, B, C = map(int, input().split(' '))

a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

a = a[:x]
b = b[:y]

a_index = -1
b_index = -1

a_sum = sum(a)
b_sum = sum(b)

a_target = a[a_index]
b_target = b[b_index]

for i in c:
  if a_target > i and b_target > i:
    # もうりんごの更新はされない
    break
    
  if a_target > b_target:
    b_index -= 1
    b_sum -= b_target
    b_target = b[b_index]
    b_sum += i
  else:
    a_index -= 1
    a_sum -= a_target
    a_target = a[a_index]
    a_sum += i
    
print(a_sum + b_sum)

Fixed submission:
x, y, A, B, C = map(int, input().split(' '))

a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))

a.sort(reverse=True)
b.sort(reverse=True)

a = a[:x]
b = b[:y]

d = a + b + c
d.sort(reverse=True)

print(sum(d[:x+y]))
Buggy python submission (verdict: Runtime Error):
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

n = int(input())
  
print(l[n])

Fixed submission:
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

n = int(input())
  
print(l[n-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
w = list(map(int, input().split(' ')))


border = N // 2
w1 = sum(w[:border])
w2 = sum(w[border:])

sub = w1 - w2
direction = None
if sub > 0:
  # w1が大きい
  direction = -1
elif sub < 0:
  # w2が大きい
  direction = 1
else:
  # 両者等しい
  print('0')
  return

prev_sub = 0
while(True):
  prev_sub = sub
  w1 += direction * w[border]
  w2 += -direction * w[border]
  border += direction

  sub = w1 - w2
  if abs(sub) >= abs(prev_sub):
    print(abs(prev_sub))
    exit()

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


border = N // 2
w1 = sum(w[:border])
w2 = sum(w[border:])

sub = w1 - w2
direction = None
if sub > 0:
  # w1が大きい
  direction = -1
  border -= 1
elif sub < 0:
  # w2が大きい
  direction = 1
else:
  # 両者等しい
  print('0')
  exit()

prev_sub = 0
while(True):
  prev_sub = sub
  w1 += direction * w[border]
  w2 += -direction * w[border]
  border += direction

  sub = w1 - w2
  if abs(sub) >= abs(prev_sub):
    print(abs(prev_sub))
    exit()

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


border = N // 2
w1 = sum(w[:border])
w2 = sum(w[border:])

sub = w1 - w2
direction = None
if sub < 0:
  # w1が大きい
  direction = -1
elif sub > 0:
  # w2が大きい
  direction = 1
else:
  # 両者等しい
  print('0')
  return

prev_sub = 0
while(True):
  prev_sub = sub
  w1 += direction * w[border]
  w2 += -direction * w[border]
  border += direction

  sub = w1 - w2
  if abs(sub) >= abs(prev_sub):
    print(abs(sub))
    return
    
  
  
      

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


border = N // 2
w1 = sum(w[:border])
w2 = sum(w[border:])

sub = w1 - w2
direction = None
if sub > 0:
  # w1が大きい
  direction = -1
  border -= 1
elif sub < 0:
  # w2が大きい
  direction = 1
else:
  # 両者等しい
  print('0')
  exit()

prev_sub = 0
while(True):
  prev_sub = sub
  w1 += direction * w[border]
  w2 += -direction * w[border]
  border += direction

  sub = w1 - w2
  if abs(sub) >= abs(prev_sub):
    print(abs(prev_sub))
    exit()
Buggy python submission (verdict: Runtime Error):
def lcm(a, b):
  if b > a:
    a, b = b, a
  
  while b != 0:
    a, b = b, a % b
  
  return a

city_num, start = map(int, input().split())

cities = list(map(int, input().split()))

for i in range(len(cities)):
  cities[i] = abs(start - cities[i])

cities.sort()
  
a = reduce(lcm, cities)  

print(a)


Fixed submission:
def lcm(a, b):
  if b > a:
    a, b = b, a
  
  while b != 0:
    a, b = b, a % b
  
  return a

city_num, start = map(int, input().split())

cities = list(map(int, input().split()))

for i in range(len(cities)):
  cities[i] = abs(start - cities[i])

cities.sort()

a = cities[0]
for num in cities[1:]:
  a = lcm(a, num)
  
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

cnt = 0

if k % 2 == 0:
  k_2 = k // 2
else:
  k_2 = k

for a in range(k_2, n+1, k_2):
  for b in itertools.product(range(k-(a%k), n+1, k), repeat=2):
    cnt += len(b) // 2
        
print(cnt)


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

cnt = 0

if k % 2 == 0:
  k_2 = k // 2
else:
  k_2 = k

for a in range(k_2, n+1, k_2):
  cnt += len(range(k-(a%k), n+1, k)) ** 2
        
print(cnt)

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

cnt = 0

if k % 2 == 0:
  k_2 = k // 2
else:
  k_2 = k

for a in range(k_2, n+1, k_2):
  for b in range(k-(a%k), n+1, k):
    for c in range(k-(a%k), n+1, k):
      cnt += 1
        
print(cnt)


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

cnt = 0

if k % 2 == 0:
  k_2 = k // 2
else:
  k_2 = k

for a in range(k_2, n+1, k_2):
  cnt += len(range(k-(a%k), n+1, k)) ** 2
        
print(cnt)

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

cnt = 0

if k % 2 == 0:
  k_2 = k // 2
else:
  k_2 = k

for a in range(k_2, n+1, k_2):
  for b in range(k-(a%k), n+1, k):
    for c in range(k-(a%k), n+1, k):
      if (b + c) % k == 0:
        cnt += 1
        
print(cnt)

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

cnt = 0

if k % 2 == 0:
  k_2 = k // 2
else:
  k_2 = k

for a in range(k_2, n+1, k_2):
  cnt += len(range(k-(a%k), n+1, k)) ** 2
        
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  k = input().upper()
  if k == 'AC':
    ac +=1
  elif k == 'WA':
    wa +=1
  elif k == 'TLE':
    tle +=1
  elif k == 'RE':
    re +=1
    
print('AC x ' + ac + '\n' + 'WA x ' + wa + '\n' + 'TLE x ' + tle + '\n' + 'RE x ' + re)

Fixed submission:
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  k = input().upper()
  if k == 'AC':
    ac +=1
  elif k == 'WA':
    wa +=1
  elif k == 'TLE':
    tle +=1
  elif k == 'RE':
    re +=1
    
print('{} x {}'.format('AC',ac))
print('{} x {}'.format('WA',wa))
print('{} x {}'.format('TLE',tle))
print('{} x {}'.format('RE',re))
Buggy python submission (verdict: Runtime Error):
a = input()
if a = a.upper():
  print('A')
else:
  print('a')

Fixed submission:
a = input()
if a == a.upper():
  print('A')
else:
  print('a')
Buggy python submission (verdict: Runtime Error):
a,b = input().split(" ")
if int(a) >= 13:
  print(b)
elif int(a) in range(6,13):
  print(b/2)
elif int(a) <= 5:
  print(0)

Fixed submission:
a,b = input().split(" ")
if int(a) >= 13:
  print(b)
elif int(a) in range(6,13):
  print(int(b)//2)
elif int(a) <= 5:
  print(0)
Buggy python submission (verdict: Runtime Error):
N = str(input())
print()
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if hon in int(N[len(N)-1]):
  print(

Fixed submission:
N = str(input())
hon = ["2","4","5","7","9"]
pon = ["0","1","6","8"]
bon = ["3"]
if N[len(N)-1] in hon:
  print("hon")
elif N[len(N)-1] in pon:
  print("pon")
elif N[len(N)-1] in bon:
  print("bon")
Buggy python submission (verdict: Runtime Error):
N = str(input())
if N in 7:
  print("Yes")
else:
  print("No")

Fixed submission:
import sys
A = 1
N = str(input())
for i in N:
  if int(i) == 7:
    print("Yes")
    exit()
  else:
    A = 0
    
if A == 0:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
num = []
for i in range(N+1):
  if i % 3 == 0 and i % 5 == 0 or i % 3 == 0 or i % 5 == 0:
    num.sort()
  else:
    num.append(i)
print(sum(num))

Fixed submission:
N = int(input())
num = []
num2= []
for i in range(N+1):
  if i % 3 == 0 and i % 5 == 0:
    num.append(i)
  if i % 5 == 0:
    num.append(i)
  elif i % 3 == 0:
    num.append(i)
  else:
    num2.append(i)

print(sum(num2))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

m_cur = 1
for i in range(1, K+1):
    m_cur *= A[i]

for i in range(K+1, N+1):
    a_latest, a_last = A[i], A[i-K]
    m_last, m_cur = m_cur, (m_cur // a_last) * a_latest
    if m_last < m_cur:
        print("Yes")
    else:
        print("No")


Fixed submission:
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

for i in range(K+1, N+1):
    a_latest, a_last = A[i], A[i-K]
    if a_latest > a_last:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N + 1):
    max_xyz = 1
    for k in range(1, N + 1):
        if k * k > n:
            break
        max_xyz = k
    c = 0
    for x in range(1, k + 1):
        for y in range(1, k - x + 1):
            for z in range(1, k - x - y + 1):
                p = x * x + y * y + z * z + x * y + y * z + z * x
                if p == n:
                    c += 1
    print(c)


Fixed submission:
from collections import Counter

N = int(input())

counter = [0] * 10001
for x in range(1, N+1):
    n1 = x * x
    if n1 >= N:
        continue
    for y in range(x, N+1):
        n2 = n1 + y * y + x * y
        if n2 >= N:
            continue
        for z in range(y, N+1):
            n = n2 + z * z + y * z + z * x
            if 1 <= n <= 10000:
                s = len(Counter([x, y, z]))
                if s == 1:
                    counter[n] += 1
                elif s == 2:
                    counter[n] += 3
                elif s == 3:
                    counter[n] += 6
for i in range(1, N+1):
    print(counter[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1, N + 1):
    max_xyz = 1
    for k in range(1, N + 1):
        if k * k > n:
            break
        max_xyz = k
    c = 0
    for x in range(1, k + 1):
        for y in range(1, k - x + 1):
            for z in range(1, k - x - y + 1):
                p = x * x + y * y + z * z + x * y + y * z + z * x
                if p == n:
                    c += 1
    print(c)


Fixed submission:
from collections import Counter

N = int(input())

counter = [0] * 10001
for x in range(1, N+1):
    n1 = x * x
    if n1 >= N:
        continue
    for y in range(x, N+1):
        n2 = n1 + y * y + x * y
        if n2 >= N:
            continue
        for z in range(y, N+1):
            n = n2 + z * z + y * z + z * x
            if 1 <= n <= 10000:
                s = len(Counter([x, y, z]))
                if s == 1:
                    counter[n] += 1
                elif s == 2:
                    counter[n] += 3
                elif s == 3:
                    counter[n] += 6
for i in range(1, N+1):
    print(counter[i])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
K = list(sorted(map(int, input().split()), reverse=True))

max1 = K[0]
max2 = K[1]
if N == 2:
    print(max1)
else:
    max3 = K[2]
    count = max1 + max2
    cands = [(max1, max2), (max2, max3)]
    for k in K[3:]:
        max_cand = (0, 0)
        max_i = -1
        for i, cand in enumerate(cands):
            if min(cand) > min(max_cand):
                max_cand = cand
                max_i = i
        hi, lo = max_cand
        count += lo
        cands.pop(max_i)
        cands.append((hi, k))
        cands.append((lo, k))
    print(count)


Fixed submission:
from collections import deque
N = int(input())
K = list(sorted(map(int, input().split()), reverse=True))

max1 = K[0]
max2 = K[1]
if N == 2:
    print(max1)
else:
    max3 = K[2]
    count = max1 + max2
    cands = deque([max2, max3, max3])
    for k in K[3:]:
        cand = cands.popleft()
        count += cand
        cands.append(k)
        cands.append(k)
    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA, sumB = [0], [0]
sa, sb = 0, 0
for a in A:
    sa += a
    sumA.append(sa)
for b in B:
    sb += b
    sumB.append(sb)

n_max = 0
for na in range(N+1):
    for nb in range(M+1):
        k = sumA[na] + sumB[nb]
        if k > K:
            break
        n = na + nb
        n_max = max(n_max, n)
print(n_max)


Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA, sumB = [0], [0]
sa, sb = 0, 0
for a in A:
    sa += a
    sumA.append(sa)
for b in B:
    sb += b
    sumB.append(sb)


n_max = 0
nb_max = M
for na in range(0, N+1):
    for nb in range(nb_max, -1, -1):
        k = sumA[na] + sumB[nb]
        if k <= K:
            n = na + nb
            n_max = max(n_max, n)
            nb_max = nb
            break
print(n_max)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
sys.setrecursionlimit(300000)

N, M, K = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))


def calc(k, n):
    if k > K:
        return n - 1
    else:
        if len(A) and len(B):
            a = A.popleft()
            na = calc(k+a, n+1)
            A.appendleft(a)
            b = B.popleft()
            nb = calc(k+b, n+1)
            B.appendleft(b)
            return max(na, nb)
        elif len(A):
            a = A.popleft()
            na = calc(k + a, n + 1)
            A.appendleft(a)
            return na
        elif len(B):
            b = B.popleft()
            nb = calc(k + b, n + 1)
            B.appendleft(b)
            return nb
        else:
            return n


print(calc(0, 0))


Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA, sumB = [0], [0]
sa, sb = 0, 0
for a in A:
    sa += a
    sumA.append(sa)
for b in B:
    sb += b
    sumB.append(sb)


n_max = 0
nb_max = M
for na in range(0, N+1):
    for nb in range(nb_max, -1, -1):
        k = sumA[na] + sumB[nb]
        if k <= K:
            n = na + nb
            n_max = max(n_max, n)
            nb_max = nb
            break
print(n_max)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())
Q = int(input())

change_pair = []
for i in range(Q):
    b, c = map(int, input().split())
    change_pair.append((b, c))

# Aの出現値毎に回数をカウント
counts = {}
for a in A:
    if a in counts:
        counts[a] += 1
    else:
        counts[a] = 1

# 置き換え毎に回数を移動
for b, c in change_pair:
    if b in counts:
        count = counts[b]
        counts[b] = 0
    else:
        count = 0
    if c in counts:
        counts[c] += count
    else:
        counts[c] = count

    # 総和を求める
    total = 0
    for a, count in counts.items():
        total += a * count
    print(total)


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

change_pair = []
for i in range(Q):
    b, c = map(int, input().split())
    change_pair.append((b, c))

# Aの出現値毎に回数をカウント
counts = {}
total = 0
for a in A:
    if a in counts:
        counts[a] += 1
    else:
        counts[a] = 1
    total += a

# 置き換え毎に回数を移動
for b, c in change_pair:
    if b in counts:
        count = counts[b]
        counts[b] = 0
        total -= b * count
    else:
        count = 0
    if c in counts:
        counts[c] += count
    else:
        counts[c] = count
    total += c * count
    print(total)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(sorted(map(int, input().split())))

flags = [True] * N

count = 0
for i in range(N):
    if flags[i]:
        for j in range(i+1, N):
            if A[j] % A[i] == 0:
                flags[j] = False
            if A[j] == A[i]:
                flags[i] = False
        if flags[i]:
            count += 1
print(count)


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

mindiff = 1000
minval = None
for i in range(0, 101+1):
    diff = abs(X- i)
    if i not in P and diff < mindiff:
        mindiff = diff
        minval = i
print(minval)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(sorted(map(int, input().split())))

flags = [True for i in range(N)]

count = 0
for i in range(N):
    if flags[i]:
        for j in range(i+1, N):
            if A[j] % A[i] == 0:
                flags[j] = False
            if A[j] == A[i]:
                flags[i] = False
        if flags[i]:
            count += 1
print(count)


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

counts = [0 for i in range(Amax+1)]

for a in A:
    counts[a] += 1

count = 0
for i in range(1, Amax+1):
    if counts[i] == 1:
        count += 1
    if counts[i]:
        for j in range(i*2, Amax+1, i):
            counts[j] = 0
print(count)

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

flags = [True] * N

count = 0
for i in range(N):
    if flags[i]:
        for j in range(i+1, N):
            if A[j] % A[i] == 0:
                flags[j] = False
            if A[j] == A[i]:
                flags[i] = False
        if flags[i]:
            count += 1
print(count)


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

counts = [0 for i in range(Amax+1)]

for a in A:
    counts[a] += 1

count = 0
for i in range(1, Amax+1):
    if counts[i] == 1:
        count += 1
    if counts[i]:
        for j in range(i*2, Amax+1, i):
            counts[j] = 0
print(count)