Problem p02630 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
hako = [0]*(10**6)
ind = list(range(10**6))
S = sum(a)
s = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    S += (ind[c] - ind[b])*hako[b]
    s.append(S)
    hako[c] += hako[b]
    hako[b] = 0
for i in range(q):
    print(s[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
hako = [0]*(10^6+1)
ind = list(range(10^6+1))
S = sum(a)
s = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    S += (ind[c] - ind[b])*hako[b]
    s.append(S)
    hako[c] += hako[b]
    hako[b] = 0
for i in range(q):
    print(s[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
hako = [0]*(max(a)+1)
ind = list(range(max(a)+1))
S = sum(a)
s = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    S += (ind[c] - ind[b])*hako[b]
    s.append(S)
    hako[c] += hako[b]
    hako[b] = 0
for i in range(q):
    print(s[i])

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

n = int(input())
a = np.array([int(i) for i in input().split()])
q = int(input())
hako = np.array([0]*(a.max()+1))
ind = np.array(list(range(a.max()+1)))
S = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    hako[c] += hako[b]
    hako[b] = 0
    S.append(np.sum(ind*hako))
for i in range(q):
    print(S[i])

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

n = int(input())
a = np.array([int(i) for i in input().split()])
q = int(input())
hako = np.array([0]*(10^6))
ind = np.array(list(range(10^6)))
S = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    hako[c] += hako[b]
    hako[b] = 0
    S.append(np.sum(ind*hako))
for i in range(q):
    print(S[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
q = int(input())
hako = np.array([0]*(10^6))
ind = np.array(list(range(10^6)))
S = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    hako[c] += hako[b]
    hako[b] = 0
    S.append(np.sum(ind*hako))
for i in range(q):
    print(S[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
q = int(input())
hako = np.array([0]*(10^5+1))
ind = np.array(list(range(10^5+1)))
S = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    hako[c] += hako[b]
    hako[b] = 0
    S.append(np.sum(ind*hako))
for i in range(q):
    print(S[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
q = int(input())
hako = np.array([0]*(10^5+1))
ind = np.array(list(range(10^5+1)))
S = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    hako[c] += hako[b]
    hako[b] = 0
    S.append(np.sum(ind*hako))
for i in range(q):
    print(S[i])