Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
result = []
for i in range(N):
    C = A[i]
    A[i] = 0
    result.append(max(A))
    A[i] = C

for a in result:
    print(a)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = max(A)
C = [B]*N
D = sorted(A)[-2]
i = A.index(B)
if A.count(B) == 1:
    C[i] = D

for a in C:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
result = []
for i in range(N):
    C = A[i]
    A[i] = 0
    result.append(max(A))
    A[i] = C

for a in result:
    print(a)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = max(A)
C = [B]*N
D = sorted(A)[-2]
i = A.index(B)
if A.count(B) == 1:
    C[i] = D

for a in C:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
B = []
result = []
for i in range(N):
    B = A
    C = B[i]
    B[i] = 0
    result.append(max(B))
    B[i] = C

for a in result:
    print(a)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
B = max(A)
C = [B]*N
D = sorted(A)[-2]
i = A.index(B)
if A.count(B) == 1:
    C[i] = D

for a in C:
    print(a)
Buggy python submission (verdict: Runtime Error):
A,B,C,D =map(int, input().split())
import math
lcm = C * D // math.gcd(C, D)
E = B - (B // C + B // D - B // lcm)
F = (A-1) - ((A-1) // C + (A-1) // D - (A-1) // lcm)
result = E-F
print(result)

Fixed submission:
A,B,C,D =map(int, input().split())
import fractions
lcm = C * D // fractions.gcd(C, D)
E = B - (B // C + B // D - B // lcm)
F = (A-1) - ((A-1) // C + (A-1) // D - (A-1) // lcm)
result = E-F
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()
A = [0]*N
B = [0]*Q

for i in range(N-1):
    if S[i] == "A" and S[i+1] =="C":
        A[i+1] += 1

for i in range(Q):
    a, b = map(int, input().split())
    print(sum(A[:b])-sum(A[:a]))

Fixed submission:
N,Q = map(int, input().split())
S = input()
A = [0]*N


for i in range(1, N):
    if S[i-1] == "A" and S[i] =="C":
        A[i] = A[i-1]+1
    else:
        A[i] = A[i-1]

for i in range(Q):
    a, b = map(int, input().split())
    print(A[b-1] - A[a-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()
A = [0]*N
B = [0]*Q

for i in range(N-1):
    if S[i] == "A" and S[i+1] =="C":
        A[i+1] += 1

for i in range(Q):
    a, b = map(int, input().split())
    B[i] += sum(A[:b])-sum(A[:a])

for a in B:
    print(a)

Fixed submission:
N,Q = map(int, input().split())
S = input()
A = [0]*N


for i in range(1, N):
    if S[i-1] == "A" and S[i] =="C":
        A[i] = A[i-1]+1
    else:
        A[i] = A[i-1]

for i in range(Q):
    a, b = map(int, input().split())
    print(A[b-1] - A[a-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()
A = [0]*N
L = []
R = []
for _ in range(Q):
    l,r = map(int, input().split())
    L.append(l)
    R.append(r)
for i in range(N-1):
    if S[i] == "A" and S[i+1] =="C":
        A[i+1] += 1

for a,b in zip(L,R):
    print(sum(A[:b])-sum(A[:a]))

Fixed submission:
N,Q = map(int, input().split())
S = input()
A = [0]*N


for i in range(1, N):
    if S[i-1] == "A" and S[i] =="C":
        A[i] = A[i-1]+1
    else:
        A[i] = A[i-1]

for i in range(Q):
    a, b = map(int, input().split())
    print(A[b-1] - A[a-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
L = []
R = []
B = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

for a, b in zip(L,R):
    A = S[a-1:b]
    print(A.count("AC"))

Fixed submission:
N,Q = map(int, input().split())
S = input()
A = [0]*N


for i in range(1, N):
    if S[i-1] == "A" and S[i] =="C":
        A[i] = A[i-1]+1
    else:
        A[i] = A[i-1]

for i in range(Q):
    a, b = map(int, input().split())
    print(A[b-1] - A[a-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
L = []
R = []
B = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

for a, b in zip(L,R):
    A = S[a-1:b]
    B.append(A.count("AC"))

for b in B:
    print(b)

Fixed submission:
N,Q = map(int, input().split())
S = input()
A = [0]*N


for i in range(1, N):
    if S[i-1] == "A" and S[i] =="C":
        A[i] = A[i-1]+1
    else:
        A[i] = A[i-1]

for i in range(Q):
    a, b = map(int, input().split())
    print(A[b-1] - A[a-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for _ in range(N)]
count = 0
i = 1
x = 0
osita = [0]*N
while 2 not in osita and count < N + 10:
    osita[x] = i
    i = a[i-1]
    count += 1
    x += 1
    
if count > N:
    print(-1)
else:
    print(count-1)

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]
count = 0
i = 1
x = 0
osita = [0]*(N+1)
for b in range(N+1):
    osita[b] = i
    i = a[i-1]
    
if 2 in osita:
    print(osita.index(2))
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for _ in range(N)]
count = 0
i = 1
osita = []
while 2 not in osita:
    osita.append(i)
    i = a[i-1]
    count += 1
    if count > len(a):
        print(-1)
        exit()
print(count-1)

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]
count = 0
i = 1
x = 0
osita = [0]*(N+1)
for b in range(N+1):
    osita[b] = i
    i = a[i-1]
    
if 2 in osita:
    print(osita.index(2))
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
while len(A) > 1:
    min_A = min(A)
    A = A-min_A
    A = A[A>0]
    A = np.append(A,[min_A])
    answer = min_A
    if answer == 1:
        break
print(min_A)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
while len(A) > 1:
    min_A = min(A)
    A = A%min_A
    A = A[A>0]
    A = np.append(A,[min_A])
    answer = min_A
    if answer == 1:
        break
print(min_A)
Buggy python submission (verdict: Runtime Error):
L = int(input())
A =[]
for i in range(L):
    A.append(int(input()))
def reader(x):
    s = 0
    for i in x:
        if i ==0:
            s = s -1
        else:
            s = s + i
    return s
j = 0
flag = 0
startpoint = []
endpoint = []
for i in A:
    j = j+1
    if i == 0:
        if flag ==1:
            endpoint.append(j-2)
            flag = 0
    else:
        if flag == 0:
            startpoint.append(j-1)
            flag = 1
menseki = []
for s in startpoint:
    for e in endpoint:
        menseki.append(reader(A[s:(e+1)]))
m = max(menseki)
real = reader(A)
print(real-m)
        

Fixed submission:
N,K = map(int ,input().split())
if N%2 == 0:
    if N/2 >= K:
        print("YES")
    else:
        print("NO")
else:
    if (N+1)/2 >= K:
        print("YES")
    else:
        print("NO")

Buggy python submission (verdict: Runtime Error):
x = []
for i in range(3):
    x.append(list(map(int,input().split())))
one,two,three,four = 0,0,0,0
def push(a):
    global one,two,three,four
    if a == 1:
        one = one + 1
    elif a ==2:
        two += 1
    elif a == 3:
        three += 1
    else :
        four +=1
for i in x:
    push(i[0])
    push(i[1])
if one*two*three*four ==0 or one ==3 or two ==3 or three ==3 or four ==3:
    print("NO")
else :
    print("YES")
    

Fixed submission:
N,K = map(int ,input().split())
if N%2 == 0:
    if N/2 >= K:
        print("YES")
    else:
        print("NO")
else:
    if (N+1)/2 >= K:
        print("YES")
    else:
        print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = []
for i in range(N):
  L.append(int(input())

 
maxL = max(L)
sumL = sum(L) - maxL
           
if maxL >= sumL :
           return 'No'
else:
           return 'Yes'

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
m = max(l)
s = sum(l) - m
if m < s:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
def lb(N):
    if N != 0:
        return 2*lb(N-1)+3
    else:
        return 1
def pn(N):
    if N != 0:
        return 2*pn(N-1)+1
    else:
        return 1
def B(N,X):
    if X == 0:
        return 0
    elif lb(N-1)+1 >= X:
        return B(N-1,X-1)
    else:
        return pn(N-1)+1+B(N-1,X-lb(N-1)-2)
print(B(N,X))

Fixed submission:
N,X = map(int,input().split())
def lb(N):
    if N != 0:
        return 2*lb(N-1)+3
    else:
        return 1
def pn(N):
    if N != 0:
        return 2*pn(N-1)+1
    else:
        return 1
def B(N,X):
    if X == 0:
        return 0
    elif N == 0:
      	return 1
    elif lb(N-1)+1 >= X:
        return B(N-1,X-1)
    else:
        return pn(N-1)+1+B(N-1,X-lb(N-1)-2)
print(B(N,X))
Buggy python submission (verdict: Runtime Error):
s = int(input())
if == 3 or 5 or 7:
  print("YES")
else:
  print("NO")


Fixed submission:
X = int(input())
if X == 3 or X ==5 or X == 7:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
s = int(input())
if = 3 or 5 or 7:
  print("YES")
else:
  print("NO")

Fixed submission:
X = int(input())
if X == 3 or X ==5 or X == 7:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
a,b = map(int(),input().split())
print(a+b/2)

Fixed submission:
a,b = map(int,input().split())
c = b/2 + a
print(int(c))
Buggy python submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tem = 1000
for i in h:
  c = t-0.006*i
  d = c - a
  if d**2 < tem:
    tem = c
answer = h.index(tem) + 1
print(answer)


Fixed submission:
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
tem = 1000
z = 0
for i in h:
  c = t-0.006*i
  d = c - a
  e = tem - a
  if d**2 < e**2:
    tem = c
    z = i 
aa = h.index(z) + 1
print(aa)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

N = a[0]
M = a[1]
K = a[2]

count = 0 #読んだ冊数を記録
count_time = 0 #読んだ時間を記録
a = [0]
b = [0]

for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break 
    while b[j] < K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
 


Fixed submission:
# -*- coding: utf-8 -*-
a = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

N = a[0]
M = a[1]
K = a[2]

count = 0 #読んだ冊数を記録
count_time = 0 #読んだ時間を記録
a = [0]
b = [0]

for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break 
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

N = a[0]
M = a[1]
K = a[2]

count = 0 #読んだ冊数を記録
count_time = 0 #読んだ時間を記録

if K<A[0] or K<B[0]:
    pass
 
else:
    while K > count_time:
        if len(A)!=0 and len(B)!=0:
            if A[0] >= B[0]:
                count_time += B[0]
                count += 1
                B.pop(0)

            if A[0] < B[0]:
                count += 1
                count_time += A[0]
                A.pop(0)

        elif len(A)==0 and len(B)!=0:
            count += 1
            count_time += B[0]
            B.pop(0)

        elif len(B)==0 and len(A)!=0:
            count += 1
            count_time += A[0]
            A.pop(0)

        else:
            count += 1
            break

print(count)


Fixed submission:
# -*- coding: utf-8 -*-
a = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

N = a[0]
M = a[1]
K = a[2]

count = 0 #読んだ冊数を記録
count_time = 0 #読んだ時間を記録
a = [0]
b = [0]

for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break 
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import collections

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
xy = [map(int, input().split()) for _ in range(Q)]
x, y = [list(i) for i in zip(*xy)]


def replace_list(num_list):
    num_list = [y[index] if j==i else j for j in num_list]
    return num_list




for index, i in enumerate(x):
    #first_sum = sum(A)
    #c = collections.Counter(A)
    #first_sum = c[i]*(y[index]-i)+first_sum
    while i in A :
        A.remove(i)  #全てのiを削除します。
        A.append(y[index])
    first_sum = sum(A)
    print(first_sum)
    


Fixed submission:
# -*- coding: utf-8 -*-
import collections

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
xy = [map(int, input().split()) for _ in range(Q)]
b, c = [list(i) for i in zip(*xy)]

sum_num = sum(A)
counter = collections.Counter(A)

for i in range(Q):
    sum_num -= counter[b[i]]*b[i] #counter[x]でxの個数をカウント
    sum_num += counter[b[i]]*c[i] #cで上書きされたので、c*counter[b]になる
    counter[c[i]] += counter[b[i]]
    counter[b[i]] = 0
    print(sum_num)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
xy = [map(int, input().split()) for _ in range(Q)]
x, y = [list(i) for i in zip(*xy)]


def replace_list(num_list):
    num_list = [y[index] if j==i else j for j in num_list]
    return num_list

for index, i in enumerate(x):
    A = replace_list(A)
    print(sum(A))


Fixed submission:
# -*- coding: utf-8 -*-
import collections

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
xy = [map(int, input().split()) for _ in range(Q)]
b, c = [list(i) for i in zip(*xy)]

sum_num = sum(A)
counter = collections.Counter(A)

for i in range(Q):
    sum_num -= counter[b[i]]*b[i] #counter[x]でxの個数をカウント
    sum_num += counter[b[i]]*c[i] #cで上書きされたので、c*counter[b]になる
    counter[c[i]] += counter[b[i]]
    counter[b[i]] = 0
    print(sum_num)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import collections
import math
import copy

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

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

max_num = max(A)
data = get_sieve_of_eratosthenes(max_num)
select_prime = list(set(data) & set(A))
remove_prime = sorted(list(set(A).difference(set(data))))

if len(remove_prime)==0:
    print(0)
else:
    for min_num in remove_prime:
        divisor = make_divisors(min_num) 
        remove_max = sorted(divisor)[:-1] 
        if (list(set(remove_prime)&set(remove_max))==[])&(list(set(select_prime)&set(remove_max))==[]):
            select_prime.append(min_num)
    print(len(select_prime))

Fixed submission:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]

    if N == 1:
        print(1)
        return

    ax = max(A)+1
    dp = [0]*ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2
    ans = 0
    for ai in A:
        if dp[ai] == 1:
            ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# 2次元配列
grid = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    grid.append(array)
    
sum_fee = []
comb_pro = list(itertools.product(a, b))
for com in comb_pro:
    sum_fee.append(sum(com))

for l, m , n in grid:
    sum_fee.append(a[l-1] + b[m-1] - n)
    
print(min(sum_fee))

Fixed submission:
import itertools
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#2次元配列
grid = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    grid.append(array)
    
sum_fee = []
a_min = min(a)
b_min = min(b)
sum_fee.append(a_min+b_min)

for l, m, n in grid:
    sum_fee.append(a[l-1] + b[m-1] - n)
    

print(min(sum_fee))

Buggy python submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# 2次元配列
grid = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    grid.append(array)
    
sum_fee = []
comb_pro = list(itertools.product(a, b))
for com in comb_pro:
    sum_fee.append(sum(com))

for l, m , n in grid:
    sum_fee.append(a[l-1] + b[m-1] - n)
    
print(min(sum_fee))

Fixed submission:
import itertools
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#2次元配列
grid = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    grid.append(array)
    
sum_fee = []
a_min = min(a)
b_min = min(b)
sum_fee.append(a_min+b_min)

for l, m, n in grid:
    sum_fee.append(a[l-1] + b[m-1] - n)
    

print(min(sum_fee))

Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# 2次元配列
grid = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    grid.append(array)
    
sum_fee = []
for i in a:
    for j in b:
        sum_fee.append(i+j)

for l, m , n in grid:
    sum_fee.append(a[l-1] + b[m-1] - n)
    
print(min(sum_fee))

Fixed submission:
import itertools
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

#2次元配列
grid = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    grid.append(array)
    
sum_fee = []
a_min = min(a)
b_min = min(b)
sum_fee.append(a_min+b_min)

for l, m, n in grid:
    sum_fee.append(a[l-1] + b[m-1] - n)
    

print(min(sum_fee))
Buggy python submission (verdict: Runtime Error):
def main(n,a,b):
    if 1 <= n <= 20 and 1 <= a <= 50 and 1 <= b <= 50 :
        sum_list = [(n-x)*b + x * a for x in range(1,n)]
    return min(sum_list)

if __name__ == '__main__':
    s = list(map(int, input().split()))
    huga = main(s[0],s[1],s[2])
    print(huga)

Fixed submission:
def main(n,a,b):
    if (1 <= n <= 20 )and (1 <= a <= 50) and (1 <= b <= 50) :
        sum_list = [n * a, b] 
    return min(sum_list)

if __name__ == '__main__':
    s = list(map(int, input().split()))
    huga = main(s[0],s[1],s[2])
    print(huga)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
  z = input()
  num_list = input()
  count = 0
  for i in range(z-3):
    hoge = num_list[i:i+3]
    hoge_sort = hoge.sort()
    if hoge[1]=hoge_sort[1]:
      count += 1
  print(count)

Fixed submission:
if __name__ == '__main__':
  
  z = int(input())
  if 20 >= z and z >= 3:
    num_list = list(map(int, input().strip().split()))
    count = 0
    for i in range(z-2):
      hoge = num_list[i:i+3]
      hoge_sort = sorted(hoge)
      if hoge[1]==hoge_sort[1]:
        count += 1
    print(count)

Buggy python submission (verdict: Runtime Error):
n = 5
num_list = [1,2,3,2,1]
count = 0
for i in range(len(num_list)-3):
	hoge = num_list[i:i+3].sort_values()
    if hoge[1] = num_list[1]:
      count += 1
 
print(count)
 

Fixed submission:
if __name__ == '__main__':
  
  z = int(input())
  if 20 >= z and z >= 3:
    num_list = list(map(int, input().strip().split()))
    count = 0
    for i in range(z-2):
      hoge = num_list[i:i+3]
      hoge_sort = sorted(hoge)
      if hoge[1]==hoge_sort[1]:
        count += 1
    print(count)
Buggy python submission (verdict: Runtime Error):
t = int(input())
s = input()
if(s[0:t//2]==s[t//2:t]:
   print("Yes")
else:
   print("No")

Fixed submission:
t = int(input())
s = input()
if(s[0:t//2]==s[t//2:t]):
   print("Yes")
else:
   print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
q=int(input())
ans=[0]*(10**5+1)
for i in a:
    ans[i]+=1

for i in range(q):
    x=0
    b,c=map(int,input().split())
    ans[c]+=ans[b]
    ans[b]=0
    for j in range(10**5+1):
        if ans[j]==0:
            continue
        x+=(ans[j])*j
    print(x)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
L = [0] * (100001)
s = sum(A)
for a in A:
    L[a] += 1
Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    L[C] += L[B]
    s += L[B] * (C-B)
    L[B] = 0
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted(list(map(int,input().split())))
x=[0]*len(a)

for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if a[i]%a[j]==0:
      x[i]+=1
      continue
print(x.count(0))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
s=list(set(a))
p=[True]*(10**6+1)

for x in s:
    t=x*2
    while t<=10**6:
        p[t]=False
        t+=x
ans=0
for x in a:
    if c[x]==1 and p[x]==True:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
x=[0]*len(a)

for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if a[i]%a[j]==0:
      x[i]+=1
      continue
print(x.count(0))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
s=list(set(a))
p=[True]*(10**6+1)

for x in s:
    t=x*2
    while t<=10**6:
        p[t]=False
        t+=x
ans=0
for x in a:
    if c[x]==1 and p[x]==True:
        ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
x=[0]*len(a)

for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if a[i]%b[j]==0:
      x[i]+=1
      continue
print(x.count(0))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
s=list(set(a))
p=[True]*(10**6+1)

for x in s:
    t=x*2
    while t<=10**6:
        p[t]=False
        t+=x
ans=0
for x in a:
    if c[x]==1 and p[x]==True:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
x=[0]*len(a)

for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if a[i]%a[j]==0:
      x[i]+=1
print(x.count(0))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
s=list(set(a))
p=[True]*(10**6+1)

for x in s:
    t=x*2
    while t<=10**6:
        p[t]=False
        t+=x
ans=0
for x in a:
    if c[x]==1 and p[x]==True:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input)
s=v-w
s*=t
if abs(a-b)<=s:
  print("YES")
else:
  print("NO")

Fixed submission:
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
s=v-w
s*=t
if abs(a-b)<=s:
  print("YES")
else:
  print("NO")