buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
n=int(input())
#a,b=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
q=int(input())
dic={}
for a in al:
dic[a]=dic.get(a,0)+1
total=sum(al)
ansl=[]
for i in range(q):
b,c=map(int,input().split())
b_num=dic.get(b,0)
total=total+b_num*(c-b)
... | n=int(input())
#a,b=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
q=int(input())
dic={}
for a in al:
dic[a]=dic.get(a,0)+1
total=sum(al)
ansl=[]
for i in range(q):
b,c=map(int,input().split())
b_num=dic.get(b,0)
total=total+b_num*(c-b)
... | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70]] | 5 | 144 |
def main():
N, *X = map(int, open(0).read().split())
A = X[:N]
Q = X[N]
s = sum(A)
B = {}
for a in A:
if a not in B:
B[a] = 0
B[a] += 1
ans = []
for i in range(Q):
b, c = X[N + 1 + 2*i], X[N + 1 + 2*i + 1]
if b in B:
num = B[b]
... | def main():
N, *X = map(int, open(0).read().split())
A = X[:N]
Q = X[N]
s = sum(A)
B = {}
for a in A:
if a not in B:
B[a] = 0
B[a] += 1
ans = []
for i in range(Q):
b, c = X[N + 1 + 2*i], X[N + 1 + 2*i + 1]
if b in B:
num = B[b]
... | [["+", 64, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 612]] | 5 | 180 |
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bckt = [0]*(n+1)
for i in a:
bckt[i] += 1
s = sum(a)
for i in range(q):
b, c = map(int, input().split())
q = bckt[b]
bckt[c] += q
bckt[b] -= q
s += (c*q - b*q)
print(s)
| n = int(input())
a = list(map(int, input().split()))
q = int(input())
bckt = [0]*(int(1e5)+1)
for i in a:
bckt[i] += 1
s = sum(a)
for i in range(q):
b, c = map(int, input().split())
q = bckt[b]
bckt[c] += q
bckt[b] -= q
s += (c*q - b*q)
print(s)
| [["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["+", 12, 657, 12, 23, 0, 657, 31, 652, 63, 22], ["+", 12, 23, 0, 657, 31, 652, 3, 4, 0, 24], ["+", 12, 23, 0, 657, 31, 652, 3, 4, 0, 531], ["+", 12, 23, 0, 657, 31, 652, 3, 4, 0, 25]] | 5 | 118 |
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) ... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) ... | [["-", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46]] | 1 | 284 |
n = int(input())
a = list(map(int,input().split()))
q = int(input())
b = [0] * q
c = [0] * q
ans = sum(a)
number = [0] * 100000
for i in range(q):
b[i],c[i] = map(int,input().split())
for i in range(n):
number[a[i]] += 1
for i in range(q):
if number[b[i]] > 0:
ans += (c[i] - b[i]) * number[b[i]]
... | n = int(input())
a = list(map(int,input().split()))
q = int(input())
b = [0] * q
c = [0] * q
ans = sum(a)
number = [0] * 100001
for i in range(q):
b[i],c[i] = map(int,input().split())
for i in range(n):
number[a[i]] += 1
for i in range(q):
if number[b[i]] > 0:
ans += (c[i] - b[i]) * number[b[i]]
... | [["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 175 |
n = gets.chomp.to_i
a = gets.chomp.split(" ").map { |e|e.to_i }
bc = []
q = gets.chomp.to_i
q.times do
bc << gets.chomp.split(" ").map { |e|e.to_i }
end
lsit = a.tally
list.default = 0
sum = a.sum
bc.each do |b, c|
sum += list[b] * (c - b)
list[c] += list[b]
list[b] = 0
puts sum
end | n = gets.chomp.to_i
a = gets.chomp.split(" ").map { |e|e.to_i }
bc = []
q = gets.chomp.to_i
q.times do
bc << gets.chomp.split(" ").map { |e|e.to_i }
end
table = a.tally
table.default = 0
sum = a.sum
bc.each do |b, c|
sum += table[b] * (c - b)
table[c] += table[b]
table[b] = 0
puts sum
end | [["-", 36, 36, 36, 36, 0, 493, 0, 662, 31, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 31, 22], ["-", 36, 36, 0, 493, 0, 662, 31, 652, 486, 22], ["+", 36, 36, 0, 493, 0, 662, 31, 652, 486, 22], ["-", 8, 736, 0, 755, 12, 738, 31, 742, 500, 22], ["+", 8, 736, 0, 755, 12, 738, 31, 742, 500, 22], ["-", 196, 737, 8, 736, 0, ... | 4 | 121 |
# ans
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100000
for i in range(A):
cnt[i] += 1
Q = int(input())
S = sum(A)
for i in range(Q):
B, C = map(int, input().split())
diff = (C - B) * cnt[B]
S += diff
print(S)
cnt[C] += cnt[B]
cnt[B] = 0 | # ans
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * 100001
for i in A:
cnt[i] += 1
Q = int(input())
S = sum(A)
for i in range(Q):
B, C = map(int, input().split())
diff = (C - B) * cnt[B]
S += diff
print(S)
cnt[C] += cnt[B]
cnt[B] = 0 | [["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["-", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25]] | 5 | 119 |
#D more faster method than above see it ..........
l = lambda : list(map(int,input().split().strip()))
n = int(input())
a = l
t = [0]*(10**5+1)
s = 0
for i in a:
s += i
t[i] += 1
q = int(input())
for _ in range(q):
b,c = l
s += (c-b)*t[b]
t[c] += t[b]
t[b] = 0
p... | #D more faster method than above see it ..........
l = lambda : list(map(int,input().strip().split()))
n = int(input())
a = l()
t = [0]*(10**5+1)
s = 0
for i in a:
s += i
t[i] += 1
q = int(input())
for _ in range(q):
b,c = l()
s += (c-b)*t[b]
t[c] += t[b]
t[b] = 0
... | [["-", 0, 652, 63, 319, 500, 652, 63, 319, 319, 22], ["+", 0, 652, 63, 319, 500, 652, 63, 319, 319, 22], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 117 |
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (10**5)
for i in range(len(A)):
# print(A[i], A)
nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
B, C = map(int, input().split())
sumall += (C-B) * nizi[B]
nizi[C] =+ nizi[B]
nizi[B] = 0
print(sumall) |
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
nizi = [0] * (10**5+1)
for i in range(len(A)):
# print(A[i], A)
nizi[A[i]] += 1
sumall = sum(A)
for q in range(Q):
# print(nizi)
B, C = map(int, input().split())
sumall += (C-B) * nizi[B]
nizi[C] += nizi[B]
nizi[B] = 0
... | [["+", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 8, 196, 0, 1, 0, 662, 12, 664, 17, 72], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]] | 5 | 127 |
sum=0
dic={}
n=int(input())
lis=input()
lis=lis.split(' ')
def con(a,b):
if b in dic:
dic[b]=dic[b]+dic[a]
else:
dic[b]=dic[a]
for i in lis:
sum=sum+int(i)
if int(i) in dic:
dic[int(i)]=dic[int(i)]+1
else:
dic[int(i)]=1
#print(dic)
#print(sum)
q=int(input())
for i in ... | sum=0
dic={}
n=int(input())
lis=input()
lis=lis.split(' ')
def con(a,b):
if b in dic:
dic[b]=dic[b]+dic[a]
else:
dic[b]=dic[a]
del dic[a]
for i in lis:
sum=sum+int(i)
if int(i) in dic:
dic[int(i)]=dic[int(i)]+1
else:
dic[int(i)]=1
#print(dic)
#print(sum)
q=int(inp... | [["+", 0, 656, 0, 14, 8, 196, 0, 688, 0, 702], ["+", 0, 14, 8, 196, 0, 688, 0, 206, 51, 22], ["+", 0, 14, 8, 196, 0, 688, 0, 206, 0, 70], ["+", 0, 14, 8, 196, 0, 688, 0, 206, 206, 22], ["+", 0, 14, 8, 196, 0, 688, 0, 206, 0, 73]] | 5 | 268 |
N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
for n in range(N):
B[n+1] = B[n] + A[n]
C = B.pop()
Z = {}
for n in range(N):
Z[A[n]] = 0
for n in range(N):
Z[A[n]] += 1
D = []
Q = int(input())
for q in range(Q):
x, y = map(int, input().split())
if x in Z:
C = C - x*Z[x]... | N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
for n in range(N):
B[n+1] = B[n] + A[n]
C = B.pop()
Z = {}
for n in range(N):
Z[A[n]] = 0
for n in range(N):
Z[A[n]] += 1
D = []
Q = int(input())
for q in range(Q):
x, y = map(int, input().split())
if x in Z:
C = C - x*Z[x]... | [["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 48], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 51, 22], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 0, 70], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 0, 73]] | 5 | 223 |
N = int(input())
a = list(map(int,input().split()))
q = int(input())
num = []
summ = 0
for i in range(10**5):
num.append(0)
for i in range(N):
num[a[i]-1] += 1
summ += a[i]
for i in range(q):
b,c = map(int,input().split())
summ += (c-b)*a[b-1]
a[c-1] += a[b-1]
a[b-1] = 0
print(summ)
| N = int(input())
a = list(map(int,input().split()))
q = int(input())
num = []
summ = 0
for i in range(10**5):
num.append(0)
for i in range(N):
num[a[i]-1] += 1
summ += a[i]
for i in range(q):
b,c = map(int,input().split())
summ += (c-b)*num[b-1]
num[c-1] += num[b-1]
num[b-1] = 0
print(summ)
| [["-", 0, 1, 0, 677, 12, 657, 12, 206, 51, 22], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 51, 22], ["-", 8, 196, 0, 1, 0, 677, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 51, 22], ["-", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["-", 8, 196, 0, 1, 0, 662, 31, 206, 51, ... | 5 | 144 |
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp make_pair
#define loop(a, n) for (long long i = a; i < n; i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
using... | #include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp make_pair
#define loop(a, n) for (long long i = a; i < n; i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
using... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 0, 35], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22]] | 1 | 659 |
n=int(input())
a=list(map(int,input().split()))
q=int(input())
d=dict()
for i in a:
if i not in d:
d[i]=1
else:
d[i]+=1
ans=sum(a)
for i in range(q):
b,c=map(int,input().split())
if b not in d:
continue
if c not in d:
d[c]=0
d[c]+=d[b]
ans+=(c-b)*d[b]
prin... | n=int(input())
a=list(map(int,input().split()))
q=int(input())
d=dict()
for i in a:
if i not in d:
d[i]=1
else:
d[i]+=1
ans=sum(a)
for i in range(q):
b,c=map(int,input().split())
if b not in d:
d[b]=0
if c not in d:
d[c]=0
d[c]+=d[b]
ans+=(c-b)*d[b]
print(... | [["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 6... | 5 | 143 |
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef unsign... | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef unsign... | [["-", 8, 9, 0, 1, 0, 16, 12, 103, 0, 104], ["-", 8, 9, 0, 1, 0, 16, 12, 103, 0, 44], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]] | 1 | 798 |
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CFOR(i, str) for (int i = 0; (str)[i] != '\0'; (i)++)
#define FOR(i, s, r) for (ll i = (s); i < (r); i++)
#define SUM(a) accumulate(a.begin(),... | #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CFOR(i, str) for (int i = 0; (str)[i] != '\0'; (i)++)
#define FOR(i, s, r) for (ll i = (s); i < (r); i++)
#define SUM(a) accumulate(a.begin(),... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 22]] | 1 | 1,151 |
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
D=dict()
s=0
for i in A:
s+=i
if i in D:
D[i]+=1
else:
D[i]=1
for _ in range(Q):
b,c=map(int,input().split())
if b in D:
s+=(c-b)*D[b]
if c in D:
D[c]+=D[b]
else:
D[c]=D[b]
print(s) | N=int(input())
A=list(map(int,input().split()))
Q=int(input())
D=dict()
s=0
for i in A:
s+=i
if i in D:
D[i]+=1
else:
D[i]=1
for _ in range(Q):
b,c=map(int,input().split())
if b in D:
s+=(c-b)*D[b]
if c in D:
D[c]+=D[b]
else:
D[c]=D[b]
del D[b]
print(s) | [["+", 8, 196, 0, 57, 64, 196, 0, 688, 0, 702], ["+", 0, 57, 64, 196, 0, 688, 0, 206, 51, 22], ["+", 0, 57, 64, 196, 0, 688, 0, 206, 0, 70], ["+", 0, 57, 64, 196, 0, 688, 0, 206, 206, 22], ["+", 0, 57, 64, 196, 0, 688, 0, 206, 0, 73]] | 5 | 138 |
/// Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout << endl
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v... | /// Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout << endl
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v... | [["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107]] | 1 | 585 |
n = int(input())
a = list(map(int, input().split()))
q = int(input())
s = [list(map(int, input().split())) for i in range(q)]
ans = sum(a)
from collections import Counter
cnt = Counter(a)
for i, j in s:
if j in cnt:
cnt[j] += cnt[i]
else:
cnt[j] = cnt[i]
ans = ans - i * cnt[i... | n = int(input())
a = list(map(int, input().split()))
q = int(input())
s = [list(map(int, input().split())) for i in range(q)]
ans = sum(a)
from collections import Counter
cnt = Counter(a)
for i, j in s:
if j in cnt:
cnt[j] += cnt[i]
else:
cnt[j] = cnt[i]
ans = ans - i * cnt[i] + cnt[i... | [["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 267], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22]] | 5 | 134 |
n = int(input())
a = list(map(int, input().split()))
q = int(input())
from collections import Counter
dict_a = Counter(a)
s = sum(a)
for i in range(q):
b, c = map(int, input().split())
s -= b*dict_a[b]
s += c*dict_a[c]
dict_a[c] += dict_a[b]
dict_a[b] = 0
print(s)
| n = int(input())
a = list(map(int, input().split()))
q = int(input())
from collections import Counter
dict_a = Counter(a)
s = sum(a)
for i in range(q):
b, c = map(int, input().split())
s -= b*dict_a[b]
s += c*dict_a[b]
dict_a[c] += dict_a[b]
dict_a[b] = 0
print(s)
| [["-", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22]] | 5 | 108 |
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
using namespace std;
int main() {
// 文字列の入力
int N;
cin >> N;
static int A[100001];
int B, C;
static long long S[100001];
int tempA;
for (int i = 0; i < N; i++) {
cin >> tempA;
A[tempA]++;
S[0] ... |
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
using namespace std;
int main() {
// 文字列の入力
int N;
cin >> N;
static int A[100001];
int B, C;
static long long S[100001];
int tempA;
for (int i = 0; i < N; i++) {
cin >> tempA;
A[tempA]++;
S[0]... | [["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]] | 1 | 180 |
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
for a in A:
D[a] += 1
Q = int(input())
SUM = sum(A)
for q in range(Q):
b, c = map(int, input().split())
SUM -= D[b] * b
SUM += D[b] * c
D[c] += D[b]
print(SUM)
| from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
for a in A:
D[a] += 1
Q = int(input())
SUM = sum(A)
for q in range(Q):
b, c = map(int, input().split())
SUM -= D[b] * b
SUM += D[b] * c
D[c] += D[b]
D[b] = 0
print(SUM)
| [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 113 |
n = int(input())
a = list(map(int,input().split()))
dist = [0]*max(a)
ans = sum(a)
for i in a:
dist[i-1] += 1
q = int(input())
for i in range(q):
b,c = map(int,input().split())
if dist[b-1] != 0:
dist[c-1] += dist[b-1]
ans += dist[b-1] * (c-b)
dist[b-1] = 0
print(ans) | n = int(input())
a = list(map(int,input().split()))
dist = [0]*100000
ans = sum(a)
for i in a:
dist[i-1] += 1
q = int(input())
for i in range(q):
b,c = map(int,input().split())
if dist[b-1] != 0:
dist[c-1] += dist[b-1]
ans += dist[b-1] * (c-b)
dist[b-1] = 0
print(ans) | [["-", 0, 1, 0, 662, 12, 657, 12, 652, 63, 22], ["-", 0, 662, 12, 657, 12, 652, 3, 4, 0, 24], ["-", 0, 662, 12, 657, 12, 652, 3, 4, 0, 22], ["-", 0, 662, 12, 657, 12, 652, 3, 4, 0, 25], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 135 |
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
cnt = Counter(a)
s = sum(cnt)
for i in range(q):
b, c = map(int, input().split())
s = s - b*cnt[b]
s = s + c*cnt[b]
cnt[c] += cnt[b]
cnt[b] = 0
print(s) | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
cnt = Counter(a)
s = sum(a)
for i in range(q):
b, c = map(int, input().split())
s = s - b*cnt[b]
s = s + c*cnt[b]
cnt[c] += cnt[b]
cnt[b] = 0
print(s) | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 112 |
n = int(input())
a = list(map(int,input().split()))
b = {}
for x in a:
try:
if b[x]:
b[x] += 1
except:
b[x] = 1
#print(b)
ans = sum(a)
q = int(input())
for _ in range(q):
x,y = map(int,input().split())
try:
if b[x] != -1:
bx = b[x]
b[x] = 0
except:
#print(b)
print(ans)
... | n = int(input())
a = list(map(int,input().split()))
b = {}
for x in a:
try:
if b[x]:
b[x] += 1
except:
b[x] = 1
#print(b)
ans = sum(a)
q = int(input())
for _ in range(q):
x,y = map(int,input().split())
try:
if b[x] != -1:
bx = b[x]
b[x] = 0
except:
#print(b)
print(ans)
... | [["+", 0, 246, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 8, 196, 0, 57, 15, 666, 0, 664, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 664, 28, 612]] | 5 | 162 |
from collections import Counter
n = int(input())
ls = list(map(int, input().split()))
q = int(input())
count = Counter(ls)
sm = sum(ls)
for _ in range(q):
b, q = map(int, input().split())
if b in count:
sm -= count[b] * b
sm += count[b] * q
print(sm)
if q in count:
count[q] ... | from collections import Counter
n = int(input())
ls = list(map(int, input().split()))
q = int(input())
count = Counter(ls)
sm = sum(ls)
for _ in range(q):
b, q = map(int, input().split())
if b in count:
sm -= count[b] * b
sm += count[b] * q
print(sm)
else:
print(sm)
if q... | [["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 135 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i, l, r) for (i = l; i < r; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define P pair<ll, ll>
#define F first
#define S second
signed main() {
ll N;
cin >> N;
string S;
while (N > 0) {
char x = 'a'... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i, l, r) for (i = l; i < r; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define P pair<ll, ll>
#define F first
#define S second
signed main() {
ll N;
cin >> N;
string S;
while (N > 0) {
char x = 'a'... | [["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]] | 1 | 124 |
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define fio ios_base::sync_with_stdio(false)
using namespace std;
int main() {
ll n;
cin >> n;
string k;
while (n > 0) {
if (n % 26 == 0) {
k += (26 + 'a');
n = n / 26 - 1;
} else {
k += (n % 26 - 1 + 'a');
... |
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define fio ios_base::sync_with_stdio(false)
using namespace std;
int main() {
ll n;
cin >> n;
string k;
while (n > 0) {
if (n % 26 == 0) {
k += (25 + 'a');
n = n / 26 - 1;
} else {
k += (n % 26 - 1 + 'a');
... | [["-", 0, 1, 0, 11, 12, 23, 0, 16, 31, 13], ["+", 0, 1, 0, 11, 12, 23, 0, 16, 31, 13]] | 1 | 107 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
string ans = "";
while (n > 0) {
ans.push_back(n % 26 + 'a' - 1);
n /= 26;
}
reverse(ans.rbegin(), ans.rend());
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
string ans = "";
while (n > 0) {
--n;
ans.push_back(n % 26 + 'a');
n /= 26;
}
reverse(ans.rbegin(), ans.rend());
cout << ans << endl;
return 0;
}
| [["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 82 |
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
int i = 0;
long long int N;
string S = "";
cin >> N;
while (N > 0) {
S[i] = (char)('a' + N % 26 - 1);
N /= 26;
i++;
}
for (int j = i - 1; j >= 0; j--)
cout << S[j];
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
int i = 0;
long long int N;
string S = "";
cin >> N;
while (N > 0) {
N--;
S[i] = (char)('a' + N % 26);
N /= 26;
i++;
}
for (int j = i - 1; j >= 0; j--)
cout << S[j];
return 0;
} | [["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 0, 11, 12, 74, 51, 23, 0, 16, 17, 33], ["-", 0, 11, 12, 74, 51, 23, 0, 16, 12, 13]] | 1 | 97 |
#include <bits/stdc++.h>
#define ios std::ios::sync_with_stdio(false)
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", (n))
#define pdd(n, m) printf("%d %d\n", n, m)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) ... | #include <bits/stdc++.h>
#define ios std::ios::sync_with_stdio(false)
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", (n))
#define pdd(n, m) printf("%d %d\n", n, m)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) ... | [["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 1,573 |
#include <bits/stdc++.h>
using namespace std;
void Out(long long X) {
if (X == 0)
return;
long long Rem = X % 26ll;
Out(X / 26ll);
cout << (char)(Rem + 'a');
}
int main() {
long long X;
cin >> X;
Out(X);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
void Out(long long X) {
if (X == 0)
return;
X--;
long long Rem = X % 26ll;
Out(X / 26ll);
cout << (char)(Rem + 'a');
}
int main() {
long long X;
cin >> X;
Out(X);
return 0;
}
| [["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 73 |
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, m, n) for (int i = int(m); i < int(n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define VI vector<int>
#define VP vector<p... | #include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, m, n) for (int i = int(m); i < int(n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define VI vector<int>
#define VP vector<p... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 20]] | 1 | 273 |
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const double PI = acos(-1.0);
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) ... | #include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const double PI = acos(-1.0);
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) ... | [["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25]] | 1 | 1,113 |
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll i, j, m, n, k;
ll t;
string s;
cin >> n;
while (n > 0) {
s.pb((n - 1 + 26) % 26 +... | #include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll i, j, m, n, k;
ll t;
string s;
cin >> n;
while (n > 0) {
s.pb((n - 1 + 26) % 26 +... | [["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25]] | 1 | 118 |
n = int(input())
s = ""
while n > 0:
s = chr(ord('a') + (n%26) - 1) + s
n //= 26
print(s) | n = int(input())
s = ""
while n > 0:
n -= 1
s = chr(ord('a') + (n%26)) + s
n //= 26
print(s) | [["+", 0, 52, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 12, 612], ["-", 12, 657, 31, 652, 3, 4, 0, 657, 17, 33], ["-", 12, 657, 31, 652, 3, 4, 0, 657, 12, 612]] | 5 | 45 |
#include "algorithm"
#include "bitset"
#include "cassert"
#include "climits"
#include "cmath"
#include "cstdio"
#include "ctime"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "str... | #include "algorithm"
#include "bitset"
#include "cassert"
#include "climits"
#include "cmath"
#include "cstdio"
#include "ctime"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "str... | [["-", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22]] | 1 | 193 |
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
... | #include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<int, null_type, less<int>, rb_tree_tag, \
... | [["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 12, 16, 12, 23, 0, 16, 31, 23, 0, 25]] | 1 | 569 |
#include <bits/stdc++.h>
int main() {
using namespace std;
unsigned long N;
cin >> N;
string S;
while (N) {
S.push_back('a' + N % 26 - 1);
N /= 26;
}
reverse(begin(S), end(S));
cout << S << endl;
return 0;
} | #include <bits/stdc++.h>
int main() {
using namespace std;
unsigned long N;
cin >> N;
string S;
while (N) {
--N;
S.push_back('a' + N % 26);
N /= 26;
}
reverse(begin(S), end(S));
cout << S << endl;
return 0;
} | [["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 70 |
import numpy as np
M = 100002
if __name__ == "__main__":
N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
Num = np.zeros((M))
Sum = sum(A)
for i in range(N):
Num[i] += 1
for i in range(Q):
B, C = [int(x) for x in input().split()]
if(Num[B] == 0):
print(int(Sum))
... | import numpy as np
M = 100002
if __name__ == "__main__":
N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
Num = np.zeros((M))
Sum = sum(A)
for i in range(N):
Num[A[i]] += 1
for i in range(Q):
B, C = [int(x) for x in input().split()]
if(Num[B] == 0):
print(int(Sum)... | [["+", 0, 1, 0, 677, 31, 206, 206, 206, 51, 22], ["+", 0, 1, 0, 677, 31, 206, 206, 206, 0, 70], ["+", 0, 1, 0, 677, 31, 206, 206, 206, 0, 73]] | 5 | 161 |
N=int(input())
A=list(map(int,input().split()))
a=[0]*(10**5+1)
num=0
for i in range(N):
s=A[i]
a[s]+=1
num+=s
Q=int(input())
ans=[]
print(num)
for i in range(Q):
B,C=map(int,input().split())
a[C]+=a[B]
num+=(C-B)*a[B]
a[B]=0
ans.append(num)
for i in ans:
print(i) | N=int(input())
A=list(map(int,input().split()))
a=[0]*(10**5+1)
num=0
for i in range(N):
s=A[i]
a[s]+=1
num+=s
Q=int(input())
ans=[]
for i in range(Q):
B,C=map(int,input().split())
a[C]+=a[B]
num+=(C-B)*a[B]
a[B]=0
ans.append(num)
for i in ans:
print(i) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 146 |
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
S = sum(A)
Q = int(input())
for _ in range(Q):
x, y = map(int, input().split())
S += (c[x]*(y-x))
print(S)
c[y] = c[x]
c[x] = 0 | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
S = sum(A)
Q = int(input())
for _ in range(Q):
x, y = map(int, input().split())
S += (c[x]*(y-x))
print(S)
c[y] += c[x]
c[x] = 0 | [["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]] | 5 | 106 |
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int main() {
int N;
cin >> N;
map<int, int> mii;
int tmp;
rep(i, N) {
cin >> tmp;
++mii[tmp];
}
int64 ans = 0;... | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int main() {
int N;
cin >> N;
map<int, int> mii;
int tmp;
rep(i, N) {
cin >> tmp;
++mii[tmp];
}
int64 ans = 0;... | [["-", 12, 16, 31, 16, 31, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 16, 31, 69, 341, 342, 0, 22]] | 1 | 196 |
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
b, c = map(int, input().split())
B.append(b)
C.append(c)
counter = Counter(A)
ans = 0
for num, count in counter.items():
ans += num * count
for i in range(Q):
if ... | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
b, c = map(int, input().split())
B.append(b)
C.append(c)
counter = Counter(A)
ans = 0
for num, count in counter.items():
ans += num * count
for i in range(Q):
if ... | [["-", 12, 657, 12, 652, 3, 4, 0, 634, 0, 70], ["-", 12, 652, 3, 4, 0, 634, 0, 206, 0, 73]] | 5 | 180 |
import collections as cl
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
sum = 0
for i in range(N):
sum += A[i]
dic = cl.Counter(A)
l = []
for _ in range(Q):
b, c = map(int, input().split())
x = dic.get(b)
if x == None:
l.append(sum)
continue
if b < c:
... | import collections as cl
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
sum = 0
for i in range(N):
sum += A[i]
dic = cl.Counter(A)
l = []
for _ in range(Q):
b, c = map(int, input().split())
x = dic.get(b)
if x == None:
l.append(sum)
continue
if b < c:
... | [["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 189 |
#atcoder template
def main():
import sys
imput = sys.stdin.readline
#文字列入力の時は上記はerrorとなる。
#ここにコード
#input
N = int(input())
A = list(map(int, input().split()))
D = Counter(A)
S = sum(A)
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
b, c = map(int, ... | #atcoder template
def main():
import sys
imput = sys.stdin.readline
#文字列入力の時は上記はerrorとなる。
#ここにコード
#input
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
D = Counter(A)
S = sum(A)
Q = int(input())
B = [0] * Q
C = [0] * Q
for i i... | [["+", 0, 656, 0, 14, 8, 196, 0, 686, 0, 314], ["+", 0, 14, 8, 196, 0, 686, 687, 673, 0, 22], ["+", 0, 656, 0, 14, 8, 196, 0, 686, 0, 487], ["+", 0, 14, 8, 196, 0, 686, 141, 673, 0, 22]] | 5 | 155 |
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
ans = sum(A)
C = Counter(A)
for i in range(Q):
b, c = map(int, input().split())
if b in A:
cnt = C[b]
C[c] += cnt
C[b] = 0
ans += (c-b) * cnt
print(ans) | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
ans = sum(A)
C = Counter(A)
for i in range(Q):
b, c = map(int, input().split())
if C[b] != 0:
cnt = C[b]
C[c] += cnt
C[b] = 0
ans += (c-b) * cnt
print(ans) | [["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 70], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 267], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]... | 5 | 109 |
n = int(input())
a =list(map(int, input().split()))
q = int(input())
b = [0]*q
c = [0]*q
for i in range(q):
b[i],c[i]=map(int, input().split())
at = [0]*10**5+100
sum = 0
for i in a:
at[i]= at[i]+1
sum = sum+i
for i in range(q):
m= at[b[i]]
at[b[i]]=0
at[c[i]]=at[c[i]]+m
sum = sum + (c... | n = int(input())
a =list(map(int, input().split()))
q = int(input())
b = [0]*q
c = [0]*q
for i in range(q):
b[i],c[i]=map(int, input().split())
at = [0]*(10**5+100)
sum = 0
for i in a:
at[i]= at[i]+1
sum = sum+i
for i in range(q):
m= at[b[i]]
at[b[i]]=0
at[c[i]]=at[c[i]]+m
sum = sum + ... | [["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 25]] | 5 | 176 |
n=int(input())
elements= input().split()
q=int(input())
actions=[]
for i in range(q):
actions.append(input().split())
dict={}
for e in elements:
count=dict.get(e,0)
count+=1
dict[e]=count
sum=0
for key in dict.keys():
sum+=int(key)* dict[key]
for act in actions:
count=dict.get(act[0],0)
... | n=int(input())
elements= input().split()
q=int(input())
actions=[]
for i in range(q):
actions.append(input().split())
dict={}
for e in elements:
count=dict.get(e,0)
count+=1
dict[e]=count
sum=0
for key in dict.keys():
sum+=int(key)* dict[key]
for act in actions:
count=dict.get(act[0],0)
... | [["-", 0, 656, 0, 7, 8, 196, 0, 688, 0, 702], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 176 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
// Function to print Excel column name for a given column number
int main() {
ll n, i, s = 90LL;
cin >> n;
ll a[n];
map<int, int> ck;
for (i = 0; i < n; i++) {
cin >> a[i];
s += a[i];
ck[a[i]]++;
}
int q;
cin >> q;
while... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
// Function to print Excel column name for a given column number
int main() {
ll n, i, s = 0LL;
cin >> n;
ll a[n];
map<int, int> ck;
for (i = 0; i < n; i++) {
cin >> a[i];
s += a[i];
ck[a[i]]++;
}
int q;
cin >> q;
while ... | [["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 25]] | 1 | 153 |
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
import collections
cca = collections.Counter(a)
for i in range(int(input())):
b,c = map(int,input().split())
num = cca[b]
cca[b] = 0
cca[c] += num
print(ans - num*(b-c)) | n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
import collections
cca = collections.Counter(a)
for i in range(int(input())):
b,c = map(int,input().split())
num = cca[b]
cca[b] = 0
cca[c] += num
ans -= num*(b-c)
print(ans) | [["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 100 |
def main():
import sys
def input(): return sys.stdin.readline().rstrip()
n = int(input())
A = list(map(int, input().split()))
q = int(input())
import numpy as np
A.sort()
ans = sum(A)
from bisect import bisect_left,bisect_right
from collections import Counter
count = Counter(... | def main():
import sys
def input(): return sys.stdin.readline().rstrip()
n = int(input())
A = list(map(int, input().split()))
q = int(input())
import numpy as np
A.sort()
ans = sum(A)
from bisect import bisect_left,bisect_right
from collections import Counter
count = Counter(... | [["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]] | 5 | 152 |
n=int(input())
a=list(map(int,input().split()))
q=int(input())
ans=sum(a)
L=[0]*(10**5+1)
for i in range(n):
L[a[i]]+=1
for i in range(q):
b,c=map(int,input().split())
num=L[b]
L[c]+=num
ans-=num*b
ans+=num*c
print(ans) | n=int(input())
a=list(map(int,input().split()))
q=int(input())
ans=sum(a)
L=[0]*(10**5+1)
for i in range(n):
L[a[i]]+=1
for i in range(q):
b,c=map(int,input().split())
num=L[b]
L[b]=0
L[c]+=num
ans-=num*b
ans+=num*c
print(ans)
| [["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 0, 70]] | 5 | 119 |
from sys import stdin
readline = stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
Q = int(readline())
t = [0] * (N + 1)
s = sum(A)
for a in A:
t[a] += 1
for _ in range(Q):
B, C = map(int, readline().split())
s -= B * t[B]
s += C * t[B]
t[C] += t[B]
t[B] = 0
print(... | from sys import stdin
readline = stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
Q = int(readline())
t = [0] * (10 ** 5 + 1)
s = sum(A)
for a in A:
t[a] += 1
for _ in range(Q):
B, C = map(int, readline().split())
s -= B * t[B]
s += C * t[B]
t[C] += t[B]
t[B] = 0
... | [["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["+", 12, 657, 12, 23, 0, 657, 31, 657, 31, 612], ["+", 12, 657, 12, 23, 0, 657, 31, 657, 17, 578], ["+", 12, 657, 12, 23, 0, 657, 31, 657, 12, 612]] | 5 | 129 |
# -*- coding: utf-8 -*-
import collections
N = int(input())
A = list(map(int, input().split()))
A_amount = dict(collections.Counter(A))
result = sum(A)
Q = int(input())
for q in range(Q):
B, C = map(int, input().split())
B_elem = A_amount.get(B, None)
if B_elem is not None:
C_elem = A_amount.get(C... | # -*- coding: utf-8 -*-
import collections
N = int(input())
A = list(map(int, input().split()))
A_amount = dict(collections.Counter(A))
result = sum(A)
Q = int(input())
for q in range(Q):
B, C = map(int, input().split())
B_elem = A_amount.get(B, None)
if B_elem is not None:
C_elem = A_amount.get(C... | [["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24]] | 5 | 154 |
def sumdic(dic):
s=0
for k, v in dic.items():
s+=int(k)*v
return s
a=int(input())
dic={}
for x in input().split():
if x in dic:
dic[x]+=1
else:
dic[x]=1
s=sumdic(dic)
d=int(input())
for i in range(d):
(b,c)=[x for x in input().split()]
if c in dic:
dic[c]+=dic[b]
s+=(int(c)-int(b))*di... | def sumdic(dic):
s=0
for k, v in dic.items():
s+=int(k)*v
return s
a=int(input())
dic={}
for x in input().split():
if x in dic:
dic[x]+=1
else:
dic[x]=1
s=sumdic(dic)
d=int(input())
for i in range(d):
(b,c)=[x for x in input().split()]
if c in dic and b in dic:
dic[c]+=dic[b]
s+=(int(... | [["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 267]] | 5 | 193 |
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
q = int(input())
info = []
for i in range(q):
info.append(list(map(int, input().split())))
a_dict = dict()
for num in a:
if num in a_dict.keys():
a_dict[num] += 1
else:
a_dict[num] = 1
a_key = list(... | import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
q = int(input())
info = []
for i in range(q):
info.append(list(map(int, input().split())))
a_dict = dict()
for num in a:
if num in a_dict.keys():
a_dict[num] += 1
else:
a_dict[num] = 1
a_key = list(... | [["-", 0, 677, 12, 657, 12, 206, 206, 206, 206, 612], ["+", 0, 677, 12, 657, 12, 206, 206, 206, 206, 612]] | 5 | 340 |
package main
import (
"fmt"
)
func main() {
var n, q int
var a []int
// 特定の値が何個あるか
nums := make(map[int]int, 100005)
var sum int
fmt.Scan(&n)
for i := 0; i < n; i++ {
var temp int
fmt.Scan(&temp)
a = append(a, temp)
nums[temp]++
sum += temp
}
fmt.Scan(&q)
for j := 0; j < q; j++ {
//log.Printl... | package main
import (
"fmt"
)
func main() {
var n, q int
var a []int
// 特定の値が何個あるか
nums := make(map[int]int, 100005)
var sum int
fmt.Scan(&n)
for i := 0; i < n; i++ {
var temp int
fmt.Scan(&temp)
a = append(a, temp)
nums[temp]++
sum += temp
}
fmt.Scan(&q)
for j := 0; j < q; j++ {
//log.Printl... | [["-", 0, 435, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 36, 36, 0, 434, 0, 435, 8, 196, 0, 165], ["+", 0, 435, 8, 196, 0, 7, 8, 196, 0, 165], ["+", 0, 435, 8, 196, 0, 7, 8, 196, 0, 46]] | 7 | 183 |
N = int(input())
A = list(map(int, input().split()))
AA = {}
t = 0
for a in A:
t += a
if a in AA:
AA[a] += 1
else:
AA[a] = 1
Q = int(input())
ans = []
for i in range(Q):
b, c = list(map(int, input().split()))
if b in AA:
if c not in AA:
AA[c] = 0
AA[c] += AA[b]
t += (c - b) * AA[b]
ans += [t]
del... | N = int(input())
A = list(map(int, input().split()))
AA = {}
t = 0
for a in A:
t += a
if a in AA:
AA[a] += 1
else:
AA[a] = 1
Q = int(input())
ans = []
for i in range(Q):
b, c = list(map(int, input().split()))
if b in AA:
if c not in AA:
AA[c] = 0
AA[c] += AA[b]
t += (c - b) * AA[b]
ans += [t]
del... | [["-", 0, 1, 0, 677, 12, 634, 0, 206, 51, 22], ["-", 0, 1, 0, 677, 12, 634, 0, 206, 0, 70], ["-", 0, 677, 12, 634, 0, 206, 206, 664, 17, 33], ["-", 0, 677, 12, 634, 0, 206, 206, 664, 28, 612], ["-", 0, 1, 0, 677, 12, 634, 0, 206, 0, 73], ["+", 8, 196, 0, 1, 0, 677, 12, 634, 0, 22]] | 5 | 167 |
from collections import Counter
n = int(input())
a_list = list(map(int, input().split()))
q = int(input())
bc_list = []
for _ in range(q):
bc_list.append(list(map(int, input().split())))
sum_num = sum(a_list)
counter = Counter(a_list)
for i, (b, c) in enumerate(bc_list):
sum_num = sum_num + ((c - b) * counte... | from collections import Counter
n = int(input())
a_list = list(map(int, input().split()))
q = int(input())
bc_list = []
for _ in range(q):
bc_list.append(list(map(int, input().split())))
sum_num = sum(a_list)
counter = Counter(a_list)
for i, (b, c) in enumerate(bc_list):
sum_num = sum_num + ((c - b) * counte... | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 129 |
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n = ni()
a = na()
q = ni()
l = [na() for _ in range(q)]
import collections
c = collections.Counter(a)
ans = sum(a)
for i in l:
if c[i[0]] >0:
... | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n = ni()
a = na()
q = ni()
l = [na() for _ in range(q)]
import collections
c = collections.Counter(a)
ans = sum(a)
for i in l:
if c[i[0]] >0:
... | [["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 180 |
from collections import Counter
dicy = {}
def swap(a,b):
tmp = 0
try:
tmp = dicy.pop(a)
except Exception:
tmp = 0
try:
dicy[b] += tmp
except Exception:
dicy[b] = tmp
return (int(b)-int(a)) * tmp
max = input()
dicy = dict(Counter(input().split(' ')))
result = 0
for v,k in dicy.items():
result += int... | from collections import Counter
dicy = {}
def swap(a,b):
tmp = 0
try:
tmp = dicy.pop(a)
except Exception:
tmp = 0
try:
dicy[b] += tmp
except Exception:
dicy[b] = tmp
return (int(b)-int(a)) * tmp
max = input()
dicy = dict(Counter(input().split(' ')))
result = 0
for v,k in dicy.items():
result += int... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 163 |
from collections import Counter
n = input()
N = int(n)
A = [int(a) for a in input().split()]
q = input()
Q = int(q)
B, C = [], []
for i in range(Q):
b, c = input().split()
B.append(int(b))
C.append(int(c))
my_dict = Counter(A)
def cals_sum(my_dict):
values = [ my_dict[key]*key for key in my_dict.key... | from collections import Counter
n = input()
N = int(n)
A = [int(a) for a in input().split()]
q = input()
Q = int(q)
B, C = [], []
for i in range(Q):
b, c = input().split()
B.append(int(b))
C.append(int(c))
my_dict = Counter(A)
def cals_sum(my_dict):
values = [ my_dict[key]*key for key in my_dict.key... | [["-", 0, 657, 31, 657, 31, 23, 0, 657, 17, 72], ["-", 0, 657, 31, 657, 31, 23, 0, 657, 12, 22]] | 5 | 209 |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
int main() {
int N, Q, a;
cin >> N;
vector<int> A(N), count(N);
rep(i, N) {
cin >> a;
A[i] = a;
++count[a];
}
cin >> Q;
vector<ll> B(Q), C(Q);
... | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
int main() {
int N, Q, a;
cin >> N;
vector<int> A(N), count(100001);
rep(i, N) {
cin >> a;
A[i] = a;
++count[a];
}
cin >> Q;
vector<ll> B(Q), C(... | [["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]] | 1 | 221 |
n=int(input())
a=list(map(int,input().split()))
d={}
for i in a:
if i in d:
d[i]+=1
else:
d[i]=1
q=int(input())
s=sum(a)
for i in range(q):
b,c=map(int,input().split())
if c in d and b in d:
d[c]+=d[b]
elif b in d:
d[c]=d[b]
if b in d:
s=s+(c-b)*d[b]
p... | n=int(input())
a=list(map(int,input().split()))
d={}
for i in a:
if i in d:
d[i]+=1
else:
d[i]=1
q=int(input())
s=sum(a)
for i in range(q):
b,c=map(int,input().split())
if c in d and b in d:
d[c]+=d[b]
elif b in d:
d[c]=d[b]
if b in d:
s=s+(c-b)*d[b]
... | [["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 146 |
def main():
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
CA = Counter(A)
sumA = 0
for key, value in CA.items():
sumA += key*value
Q = int(input())
for i in ran... | def main():
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
CA = Counter(A)
sumA = 0
for key, value in CA.items():
sumA += key*value
Q = int(input())
for i in ran... | [["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]] | 5 | 142 |
n,a,d = int(input()),list(map(int,input().split())),[0 for i in range(100100)]
for x in a:
d[x] += 1
s,q = sum(a),int(input())
for i in range(q):
b,c = map(int,input().split())
s += (c-b)*d[x]
d[c] += d[b]
d[b] = 0
print(s) | n,a,d = int(input()),list(map(int,input().split())),[0 for i in range(100100)]
for x in a:
d[x] += 1
s,q = sum(a),int(input())
for i in range(q):
b,c = map(int,input().split())
s += (c-b)*d[b]
d[c] += d[b]
d[b] = 0
print(s) | [["-", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22]] | 5 | 120 |
#include <bits/stdc++.h>
#define endl "\n"
#define INF INT_MAX
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
int main() {
ios_base::s... | #include <bits/stdc++.h>
#define endl "\n"
#define INF INT_MAX
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
int main() {
ios_base::s... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 214 |
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#incl... | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#incl... | [["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 12, 16, 12, 23, 0, 16, 12, 23, 0, 25], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32]] | 1 | 502 |
import numpy as np
N=int(input())
A=list(map(int,input().split()))
Adic={}
for i in A:
if Adic.get(i)==None:
Adic[i]=1
else:
Adic[i]+=1
Q=int(input())
ope=[]
for i in range(Q):
ope.append(list(map(int,input().split())))
A=np.array(A)
sum=0
for key,value in Adic.items():
sum+=key*value
for b,c in op... | import numpy as np
N=int(input())
A=list(map(int,input().split()))
Adic={}
for i in A:
if Adic.get(i)==None:
Adic[i]=1
else:
Adic[i]+=1
Q=int(input())
ope=[]
for i in range(Q):
ope.append(list(map(int,input().split())))
A=np.array(A)
sum=0
for key,value in Adic.items():
sum+=key*value
for b,c in ope... | [["-", 0, 662, 12, 657, 12, 657, 12, 206, 206, 22], ["+", 0, 662, 12, 657, 12, 657, 12, 206, 206, 22]] | 5 | 200 |
n = int(input())
a = list(map(int, input().split()))
q = int(input())
d = {}
total = 0
for i in a:
total += i
d[i] = d.get(i, 0) + 1
#クエリによって、それぞれの数値の個数を変更し、
#対象となる個数×差分で合計を修正し出力する
for i in range(q):
b, c = map(int, input().split())
b_cnt = d.get(b, 0)
c_cnt = d.get(c, 0)
total = total + b_cnt * (c - b)
... | n = int(input())
a = list(map(int, input().split()))
q = int(input())
d = {}
total = 0
for i in a:
total += i
d[i] = d.get(i, 0) + 1
#クエリによって、それぞれの数値の個数を変更し、
#対象となる個数×差分で合計を修正し出力する
for i in range(q):
b, c = map(int, input().split())
b_cnt = d.get(b, 0)
c_cnt = d.get(c, 0)
total = total + b_cnt * (c - b)
... | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 146 |
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
arg=[0]*(N+5)
for a in A:
arg[a]+=1
ans=sum(A)
for _ in range(Q):
a,b=map(int,input().split())
ans+=arg[a]*(b-a)
print(ans)
arg[b]+=arg[a]
arg[a]=0
|
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
arg=[0]*(100005)
for a in A:
arg[a]+=1
ans=sum(A)
for _ in range(Q):
a,b=map(int,input().split())
ans+=arg[a]*(b-a)
print(ans)
arg[b]+=arg[a]
arg[a]=0
| [["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["-", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["-", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 612]] | 5 | 116 |
import collections
def calc_sum(c):
sum_val = 0
for key, val in c.items():
sum_val += key * val
return sum_val
N = int(input())
arr = list(map(int, input().split()))
Q = int(input())
actions = []
for i in range(Q):
B, C = map(int, input().split())
actions.append({'B':B, 'C':C})
c = coll... | import collections
def calc_sum(c):
sum_val = 0
for key, val in c.items():
sum_val += key * val
return sum_val
N = int(input())
arr = list(map(int, input().split()))
Q = int(input())
actions = []
for i in range(Q):
B, C = map(int, input().split())
actions.append({'B':B, 'C':C})
c = coll... | [["-", 0, 677, 12, 657, 31, 657, 31, 206, 206, 22], ["+", 0, 677, 12, 657, 31, 657, 31, 206, 206, 22]] | 5 | 191 |
#include <array>
#include <iostream>
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int N;
std::cin >> N;
uint64_t sum = 0;
std::array<int, 100001> A;
for (int i = 0; i != N; i++) {
int a;
std::cin >> a;
sum += a;
A[a]++;
}
int Q;
std::cin >> Q;
int B, C... | #include <iostream>
#include <map>
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int N;
std::cin >> N;
uint64_t sum = 0;
std::map<int, int> A;
for (int i = 0; i != N; i++) {
int a;
std::cin >> a;
sum += a;
A[a]++;
}
int Q;
std::cin >> Q;
int B, C;
for... | [["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 0, 138], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 8, 9, 0, 43, 39, 343, 141, 344, 141, 78], ["+", 8, 9, 0, 43, 39, 343, 141, 344, 141, 78], ["-", 0, 43, 39, 343, 141, 344, 3, ... | 1 | 183 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
int main() {
int N;
cin >> N;
map<ll, ll> hist;
for (int i = 0; i < N; i++) {
int A;
... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
int main() {
int N;
cin >> N;
map<ll, ll> hist;
for (int i = 0; i < N; i++) {
int A;
... | [["-", 0, 11, 12, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 16, 12, 69, 341, 342, 0, 22]] | 1 | 181 |
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#inclu... | //#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#inclu... | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["-", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22]] | 1 | 368 |
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = sum(A)
counter = Counter(A)
for i in range(Q):
B,C = list(map(int,input().split()))
S += counter[B]*C - counter[B]*B
counter[C] += counter[B]
print(S)
| from collections import Counter
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = sum(A)
counter = Counter(A)
for i in range(Q):
B,C = list(map(int,input().split()))
S += counter[B]*C - counter[B]*B
counter[C] += counter[B]
counter[B] = 0
print(S)
| [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 104 |
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
d=dict(Counter(a))
ans=sum(a)
q=int(input())
for _ in range(q):
b,c=map(int,input().split())
if b not in d.keys(): continue
ans+=(c*d[b]-b*d[b])
print(ans)
if c in d.keys(): d[c]+=d[b]
else: d[c]=d[b]
d[b]=0 | from collections import Counter
n=int(input())
a=list(map(int,input().split()))
d=dict(Counter(a))
ans=sum(a)
q=int(input())
for _ in range(q):
b,c=map(int,input().split())
if b not in d.keys():
print(ans)
continue
ans+=(c*d[b]-b*d[b])
print(ans)
if c in d.keys(): d[c]+=d[b]
else... | [["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 143 |
n = int(input())
a = list(map(int, input().split()))
q = int(input())
numl = [0] * 100005
resl = []
suma = sum(a)
for i in range(n):
numl[a[i]]+=1
for i in range(q):
b, c = map(int, input().split())
bn = numl[b]
suma += (c - b)* bn
resl.append(suma)
numl[c] -= bn
numl[c] += bn
for i in resl:... | n = int(input())
a = list(map(int, input().split()))
q = int(input())
numl = [0] * 100005
resl = []
suma = sum(a)
for i in range(n):
numl[a[i]]+=1
for i in range(q):
b, c = map(int, input().split())
bn = numl[b]
suma += (c - b)* bn
resl.append(suma)
numl[b] -= bn
numl[c] += bn
for i in resl:... | [["-", 8, 196, 0, 1, 0, 677, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 206, 22]] | 5 | 133 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll freq[100001] = {0};
int main() {
ll sum = 0, temp;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> temp;
freq[temp]++;
sum += temp;
}
int q;
cin >> q;
while (n--) {
ll a, b;
cin >> a >> b;
sum = sum + ... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll freq[100001];
int main() {
ll sum = 0, temp;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> temp;
freq[temp]++;
sum += temp;
}
int q;
cin >> q;
while (q--) {
ll a, b;
cin >> a >> b;
sum = sum + (b - a... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 0, 32], ["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 45], ["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["-", 0, 30, 0, 43, 49, 50, 51, 83, 0, 46], ["-", 8, 9, 0, 52, 15, 339, 51, 27, 28, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 27, 28, 22]] | 1 | 132 |
n=int(input())
l=list(map(int,input().split()))
num=[0]*(10**5+1)
for i in l:
num[i]+=1
q=int(input())
count=sum(l)
for _ in range(q):
b,c=map(int,input().split())
count+=num[b]*(c-b)
num[c]+=num[b]
num[b]==0
print(count) | n=int(input())
l=list(map(int,input().split()))
num=[0]*(10**5+1)
for i in l:
num[i]+=1
q=int(input())
count=sum(l)
for _ in range(q):
b,c=map(int,input().split())
count+=num[b]*(c-b)
num[c]+=num[b]
num[b]=0
print(count) | [["-", 0, 7, 8, 196, 0, 1, 0, 666, 667, 60], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32]] | 5 | 118 |
N = input()
arr = [int(x) for x in input().split()]
q = int(input())
ans = sum(arr)
hashmap = {}
for val in arr:
if val in hashmap:
hashmap[val] += 1
else:
hashmap[val] = 1
while q > 0:
[x, y] = [int(x) for x in input().split()]
if x in hashmap:
if y in hashmap:
... | N = input()
arr = [int(x) for x in input().split()]
q = int(input())
ans = sum(arr)
hashmap = {}
for val in arr:
if val in hashmap:
hashmap[val] += 1
else:
hashmap[val] = 1
while q > 0:
[x, y] = [int(x) for x in input().split()]
if x in hashmap:
if y in hashmap:
... | [["+", 64, 196, 0, 57, 64, 196, 0, 688, 0, 702], ["+", 0, 57, 64, 196, 0, 688, 0, 206, 51, 22], ["+", 0, 57, 64, 196, 0, 688, 0, 206, 0, 70], ["+", 0, 57, 64, 196, 0, 688, 0, 206, 206, 22], ["+", 0, 57, 64, 196, 0, 688, 0, 206, 0, 73]] | 5 | 172 |
def sum_dict(d, sum, b, c):
val = 0
if b in d:
val = d[b]
sum -= (b * val)
del d[b]
d[c] = d.get(c, 0) + val
sum += (c * val)
return sum, d
n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in a:
d[i] = d.get(i, 0) + 1
s = sum(a)
q = int(inp... | def sum_dict(d, sum, b, c):
val = 0
if b in d:
val = d[b]
sum -= (b * val)
del d[b]
d[c] = d.get(c, 0) + val
sum += (c * val)
return sum, d
n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in a:
d[i] = d.get(i, 0) + 1
s = sum(a)
q = int(inp... | [["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21]] | 5 | 168 |
R = lambda: map(int, input().split())
R()
a = [0] * 100001
s = 0
for x in R():
s += x
a[x] += 1
q, = R()
for _ in range(q):
b, c = R()
s += (c - b) * a[b]
print(s)
a[c]+=d[b]
a[b] = 0
| R = lambda: map(int, input().split())
R()
a = [0] * 100001
s = 0
for x in R():
s += x
a[x] += 1
q, = R()
for _ in range(q):
b, c = R()
s += (c - b) * a[b]
print(s)
a[c]+=a[b]
a[b] = 0
| [["-", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22]] | 5 | 97 |
n = int(input())
m = {}
tot = 0
for a in map(int,input().split()):
tot += m
if a not in m:
m[a]=0
m[a] += 1
q = int(input())
for step in range(q):
b,c = map(int,input().split())
if c not in m:
m[c] = 0
if b in m:
m[c] += m[b]
tot += m[b]*(c-b)
m[b] = 0
print(tot)
| n = int(input())
m = {}
tot = 0
for a in map(int,input().split()):
tot += a
if a not in m:
m[a]=0
m[a] += 1
q = int(input())
for step in range(q):
b,c = map(int,input().split())
if c not in m:
m[c] = 0
if b in m:
m[c] += m[b]
tot += m[b]*(c-b)
m[b] = 0
print(tot) | [["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22]] | 5 | 132 |
import collections
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
l=[]
for _ in range(Q):
l.append(list(map(int,input().split())))
c = collections.Counter(A)
sum=sum(A)
for i in range(Q):
if c[l[i][0]] == 0:
print(sum)
break
else:
sum+=c[l[i][0]]*(l[i][1]-l[i][0... | import collections
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
l=[]
for _ in range(Q):
l.append(list(map(int,input().split())))
c = collections.Counter(A)
sum=sum(A)
for i in range(Q):
if c[l[i][0]] == 0:
print(sum)
continue
else:
sum+=c[l[i][0]]*(l[i][1]-l[i... | [["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]] | 5 | 176 |
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
C = Counter(a)
s = sum(a)
for i in range(q):
b, c = map(int, input().split())
print(s + (c - b) * C[b])
s += (c - b) * C[b]
C[c] += C[b] | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
C = Counter(a)
s = sum(a)
for i in range(q):
b, c = map(int, input().split())
print(s + (c - b) * C[b])
s += (c - b) * C[b]
C[c] += C[b]
C[b] = 0 | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 109 |
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
#print()
#print(N)
#print(A)
#print(Q)
#print()
counterA = dict(Counter(A))
counterAkeys=set(counterA.keys())
#print(counterAkeys)
sumA = sum(A)
#print(sumA,counterA)
for _ in range(Q):
b,c=map(int,input().split())
#pri... | from collections import Counter
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
#print()
#print(N)
#print(A)
#print(Q)
#print()
counterA = dict(Counter(A))
counterAkeys=set(counterA.keys())
#print(counterAkeys)
sumA = sum(A)
#print(sumA,counterA)
for _ in range(Q):
b,c=map(int,input().split())
#pri... | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 149 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
int main(void) {
ll N, Q;
cin >> N;
ll a[N];
map<ll, ll> s;
ll ans... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
int main(void) {
ll N, Q;
cin >> N;
ll a[N];
map<ll, ll> s;
ll ans... | [["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 31, 69, 341, 342, 0, 69, 341, 342, 0, 73]] | 1 | 200 |
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;
int main() {
int N;
cin >> N;
ll S = 0;
unordered_map<ll, ll> cnt;
ll A;
for (int i = 0; i < N; i++) {
cin >> A;
S += A;
cnt... |
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;
int main() {
int N;
cin >> N;
ll S = 0;
unordered_map<ll, ll> cnt;
ll A;
for (int i = 0; i < N; i++) {
cin >> A;
S += A;
cnt... | [["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]] | 1 | 161 |
def main():
import sys
input = sys.stdin.readline
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
Q = int(input())
ans = sum(A)
for _ in range(Q):
b,c = map(int, input().split())
x = C[b]
ans += (c-b) * x
... | def main():
import sys
input = sys.stdin.readline
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
Q = int(input())
ans = sum(A)
for _ in range(Q):
b,c = map(int, input().split())
x = C[b]
ans += (c-b) * x
... | [["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 31, 206, 0, 70]] | 5 | 122 |
n = int(input())
dic = {}
list = [int(i) for i in input().split()]
for i in list:
if i not in dic:
dic[i] = 0
dic[i] += 1
q = int(input())
ans = sum(list)
for j in range(q):
b,c = (int(x) for x in input().split())
if b not in dic:
pass
else:
if c not in dic:
dic[c... | n = int(input())
dic = {}
list = [int(i) for i in input().split()]
for i in list:
if i not in dic:
dic[i] = 0
dic[i] += 1
q = int(input())
ans = sum(list)
for j in range(q):
b,c = (int(x) for x in input().split())
if b not in dic:
print(ans)
continue
else:
if c not in... | [["-", 8, 196, 0, 57, 64, 196, 0, 674, 0, 675], ["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]] | 5 | 154 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, q, a, b, c, i, j, m, bb[100005] = {0};
long long s = 0;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a;
bb[a]++;
s = s + a;
}
cin >> q;
while (q--) {
cin >> b >> c;
m = bb[b];
if (m > 0) {
s = s - m * b;
... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, q, a, b, c, i, j, m, bb[100005] = {0}, s = 0;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a;
bb[a]++;
s = s + a;
}
cin >> q;
while (q--) {
cin >> b >> c;
m = bb[b];
if (m > 0) {
s = s - m * b;
s ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21]] | 1 | 155 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long i, j, n, k = 0, x, y, q;
cin >> n;
long long a[n];
unordered_map<long long, long long> mp;
for (i = 0; i < n; i++) {
cin >> a[i];
mp[a[i]]++;
k += a[i];
}
cin >> q;
while (q--) {
cin >> x >> y;
if (mp.find(x) != mp... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long i, j, n, k = 0, x, y, q;
cin >> n;
long long a[n];
unordered_map<long long, long long> mp;
for (i = 0; i < n; i++) {
cin >> a[i];
mp[a[i]]++;
k += a[i];
}
cin >> q;
while (q--) {
cin >> x >> y;
if (mp.find(x) != mp... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 162 |
import bisect
import collections
n=int(input())
a=sorted(list(map(int,input().split())))
q=int(input())
A=collections.Counter(a)
ans=sum(a)
for _ in range(q):
b,c=map(int,input().split())
k=A[b]
ans=(c-b)*k+ans
print(ans)
del A[b]
A[c]=k | import bisect
import collections
n=int(input())
a=sorted(list(map(int,input().split())))
q=int(input())
A=collections.Counter(a)
ans=sum(a)
for _ in range(q):
b,c=map(int,input().split())
k=A[b]
ans=(c-b)*k+ans
print(ans)
del A[b]
A[c]+=k
| [["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]] | 5 | 110 |
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
s=sum(a)
q=int(input())
for i in range(q):
b,c=map(int,input().split())
t=d[b]
s-=t*b
d[c]+=t
s+=t*c
print(s)
# t=d[b]
# d[b]=0
# d[c]+=t
# ans=0
# for k,v in d.items():
# ans+=k*v
# print(ans)
| n=int(input())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
s=sum(a)
q=int(input())
for i in range(q):
b,c=map(int,input().split())
t=d[b]
d[b]=0
s-=t*b
d[c]+=t
s+=t*c
print(s)
# t=d[b]
# d[b]=0
# d[c]+=t
# ans=0
# for k,v in d.items():
# ans+=k*v
# print(ans)
| [["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]] | 5 | 106 |
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define int lon... | #include <bits/stdc++.h>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define int lon... | [["+", 8, 9, 0, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 44]] | 1 | 236 |
#include "bits/stdc++.h"
#define rep(i, b) for (ll i = 0; i < b; i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First &first, Rest &...rest) {
cin >> first;
IN(rest...);... | #include "bits/stdc++.h"
#define rep(i, b) for (ll i = 0; i < b; i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First &first, Rest &...rest) {
cin >> first;
IN(rest...);... | [["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32]] | 1 | 474 |
#include <bits/stdc++.h>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#define fill(a, val) memset(a, val, sizeof(a))
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii ... |
#include <bits/stdc++.h>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#define fill(a, val) memset(a, val, sizeof(a))
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii ... | [["-", 75, 76, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 76, 0, 1, 0, 11, 12, 16, 17, 33]] | 1 | 293 |
#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define read(n) scanf("%d", &n)
#define f(i, a, b) for (int i = a; i <= b; ++i)
#define N 100005
ll num[N];
int main() {
ll n, q, sum = 0;
read(n);
f(i, 1, n) {
ll x;
read(x);
++num[... | #include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define read(n) scanf("%lld", &n)
#define f(i, a, b) for (int i = a; i <= b; ++i)
#define N 100005
ll num[N];
int main() {
ll n, q, sum = 0;
read(n);
f(i, 1, n) {
ll x;
read(x);
++nu... | [["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59]] | 1 | 161 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.