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
import sys readline = sys.stdin.readline N = int(readline()) A = list(map(int, readline().split())) x = [0] * (10**5+5) for a in A: x[a] += 1 s = sum(A) Q = int(readline()) for _ in range(Q): b, c = map(int, readline().split()) s += (c - b) * x[b] print(s) x[c] += x[b]
import sys readline = sys.stdin.readline N = int(readline()) A = list(map(int, readline().split())) x = [0] * (10**5+5) for a in A: x[a] += 1 s = sum(A) Q = int(readline()) for _ in range(Q): b, c = map(int, readline().split()) s += (c - b) * x[b] print(s) x[c] += x[b] x[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
121
import collections N = int(input()) A = list(map(int, input().split())) Q = int(input()) BC = [list(map(int, input().split())) for i in range(Q)] ans = sum(A) cnt = collections.Counter(A) dp = [0]*(10**5+1) for i in cnt.items(): dp[i[0]] = i[1] for i in range(Q): ans += (BC[i][1] - BC[i][0]) * dp[BC[i][0]] ...
import collections N = int(input()) A = list(map(int, input().split())) Q = int(input()) BC = [list(map(int, input().split())) for i in range(Q)] ans = sum(A) cnt = collections.Counter(A) dp = [0]*(10**5+1) for i in cnt.items(): dp[i[0]] = i[1] for i in range(Q): ans += (BC[i][1] - BC[i][0]) * dp[BC[i][...
[["-", 0, 7, 8, 196, 0, 1, 0, 666, 667, 60], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32]]
5
184
n=int(input()) *a,=map(int, input().split()) from collections import Counter ca=Counter(a) q=int(input()) sm=sum(a) for _ in range(q): bi,ci=map(int, input().split()) if ci in ca: if bi in ca: sm+=(ci-bi)*ca[ci] ca[ci]+=ca[bi] del ca[bi] else: if bi in ca:...
n=int(input()) *a,=map(int, input().split()) from collections import Counter ca=Counter(a) q=int(input()) sm=sum(a) for _ in range(q): bi,ci=map(int, input().split()) if ci in ca: if bi in ca: sm+=(ci-bi)*ca[bi] ca[ci]+=ca[bi] del ca[bi] else: if bi in ca:...
[["-", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22], ["+", 0, 1, 0, 677, 12, 657, 12, 206, 206, 22]]
5
145
_ = gets.chomp.to_i arr = gets.chomp.split(' ').map(&:to_i) map = Hash.new(0) total = 0 arr.each do |i| map[i] += 1 total += i end q = gets.chomp.to_i q.times do b, c = gets.chomp.split(' ').map(&:to_i) count_b = map[b] map[c] += count_b total += (c - b) * count_b puts total end
_ = gets.chomp.to_i arr = gets.chomp.split(' ').map(&:to_i) map = Hash.new(0) total = 0 arr.each do |i| map[i] += 1 total += i end q = gets.chomp.to_i q.times do b, c = gets.chomp.split(' ').map(&:to_i) count_b = map[b] map[c] += count_b map[b] = 0 total += (c - b) * count_b puts total end
[["+", 196, 737, 8, 736, 0, 662, 31, 742, 500, 22], ["+", 196, 737, 8, 736, 0, 662, 31, 742, 0, 70], ["+", 196, 737, 8, 736, 0, 662, 31, 742, 0, 22], ["+", 196, 737, 8, 736, 0, 662, 31, 742, 0, 73], ["+", 0, 652, 196, 737, 8, 736, 0, 662, 0, 32], ["+", 0, 652, 196, 737, 8, 736, 0, 662, 12, 612]]
4
108
n=int(input()) a=list(map(int,input().split())) q=int(input()) dic={} for i in range(len(a)): dic.setdefault(a[i],1) dic[a[i]]+=1 answer=sum(a) for i in range(q): b,c=map(int,input().split()) dic.setdefault(b,0) dic.setdefault(c,dic[b]) dic[c]+=dic[b] answer=answer+dic[b]*c-dic[b]*b dic[b] =...
n=int(input()) a=list(map(int,input().split())) q=int(input()) dic={} for i in range(len(a)): dic.setdefault(a[i],0) dic[a[i]]+=1 answer=sum(a) for i in range(q): b,c=map(int,input().split()) dic.setdefault(b,0) dic.setdefault(c,0) dic[c]+=dic[b] answer=answer+dic[b]*c-dic[b]*b dic[b] = ...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
153
n = int(input()) # w = list(map(int, input().split())) #n, k = list(map(int, input().split())) a = list(map(int, input().split())) # data = [list(map(int, input().split())) for i in range(n)] q = int(input()) #p = list(map(int, input().split())) #a = list(map(int, input().split())) # ab_sorted = sorted(ab, key=lambda x...
import collections n = int(input()) # w = list(map(int, input().split())) #n, k = list(map(int, input().split())) a = list(map(int, input().split())) # data = [list(map(int, input().split())) for i in range(n)] q = int(input()) #p = list(map(int, input().split())) #a = list(map(int, input().split())) # ab_sorted = sort...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
153
import collections n = int(input()) l = list(map(int, input().split())) a = int(input()) c = collections.Counter(l) answer = sum(l) for i in range(a): j,k = map(int, input().split()) save = c[j] del c[j] c[k] += save answer = answer + c[k] -save print(answer)
import collections n = int(input()) l = list(map(int, input().split())) a = int(input()) c = collections.Counter(l) answer = sum(l) for i in range(a): j,k = map(int, input().split()) save = c[j] del c[j] c[k] += save answer = answer + k*save - j*save print(answer)
[["-", 0, 662, 12, 657, 31, 657, 12, 206, 51, 22], ["-", 0, 662, 12, 657, 31, 657, 12, 206, 0, 70], ["-", 0, 662, 12, 657, 31, 657, 12, 206, 0, 73], ["+", 0, 662, 12, 657, 31, 657, 12, 657, 17, 48], ["+", 0, 662, 12, 657, 31, 657, 12, 657, 12, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 31, 22], ["+", 0, 1, 0, 662, 12, ...
5
104
N = int(input()) A = list(map(int, input().split())) Q = int(input()) table = [0] * 100001 c = 0 s = 0 for i in A: table[i] += 1 sum += i for i in range(Q): B, C = map(int,input().split()) c = table[B] s += (C - B) * c table[C] += table[B] table[B] = 0 print(s)
N = int(input()) A = list(map(int, input().split())) Q = int(input()) table = [0] * 100001 c = 0 s = 0 for i in A: table[i] += 1 s += i for i in range(Q): B, C = map(int,input().split()) c = table[B] s += (C - B) * c table[C] += table[B] table[B] = 0 print(s)
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22]]
5
118
from collections import defaultdict N = int(input()) raw_numbers = list(map(int, input().split())) numbers = defaultdict(int) for num in raw_numbers: numbers[num] += 1 total = sum(raw_numbers) Q = int(input()) for _ in range(Q): a, b = list(map(int, input().split())) taken = numbers[a] total...
from collections import defaultdict N = int(input()) raw_numbers = list(map(int, input().split())) numbers = defaultdict(int) for num in raw_numbers: numbers[num] += 1 total = sum(raw_numbers) Q = int(input()) for _ in range(Q): a, b = list(map(int, input().split())) taken = numbers[a] total...
[["+", 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
119
def main(): N = int(input()) A = list(map(int, input().split())) Q = int(input()) map_ = [] for _ in range(Q): b, c = list(map(int, input().split())) map_.append([b, c]) mem = {} for a in A: if not(a in mem): mem[a] = 0 mem[a] += 1 sum_ = sum(A) for i in range(Q): from_, to...
def main(): N = int(input()) A = list(map(int, input().split())) Q = int(input()) map_ = [] for _ in range(Q): b, c = list(map(int, input().split())) map_.append([b, c]) mem = {} for a in A: if not(a in mem): mem[a] = 0 mem[a] += 1 sum_ = sum(A) for i in range(Q): from_, to...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612], ["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117]]
5
210
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); long S = 0; long A[] = new long[N]; Map<Long, Long> p = new HashMap(); for (int i = 0; i < ...
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); long S = 0; long A[] = new long[N]; Map<Long, Long> p = new HashMap(); for (int i = 0; i < ...
[["+", 0, 16, 31, 492, 3, 4, 0, 504, 516, 22], ["+", 0, 16, 31, 492, 3, 4, 0, 504, 0, 70], ["+", 0, 16, 31, 492, 3, 4, 0, 504, 0, 73]]
3
390
# # #################################################################### # import io # import sys # _INPUT = """\ # 1 # 10 # 3 # 10 1 # 1 2 # 3 1 # """ # sys.stdin = io.StringIO(_INPUT) #################################################################### N = int(input()) A = [int(i) for i in input().split()] Q = int...
# # #################################################################### # import io # import sys # _INPUT = """\ # 1 # 10 # 3 # 10 1 # 1 2 # 3 1 # """ # sys.stdin = io.StringIO(_INPUT) #################################################################### N = int(input()) A = [int(i) for i in input().split()] Q = int...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]]
5
164
N = int(input()) A = list(map(int, input().split())) S = sum(A) L = [0] * 100001 for i in A: L[i] += 1 Q = int(input()) for i in range(Q): B, C = map(int, input().split()) S += (C - B) * L[B] L[C] += Ct[B] L[B] = 0 print(S)
N = int(input()) A = list(map(int, input().split())) S = sum(A) L = [0] * 100001 for i in A: L[i] += 1 Q = int(input()) for i in range(Q): B, C = map(int, input().split()) S += (C - B) * L[B] L[C] += L[B] L[B] = 0 print(S)
[["-", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22]]
5
112
N = int(input()) A = list(map(int, input().split())) Q = int(input()) S = [] c = 0 s = sum(A) table = [0] * 100010 # A = pd.Series(A) # for a in A: # print(a) for i in A: table[i] += 1 for i in range(Q): B, C = map(int,input().split()) # if B in A: # c = A.count(B) c = table[B] s += (C - B)...
N = int(input()) A = list(map(int, input().split())) Q = int(input()) S = [] c = 0 s = sum(A) table = [0] * 100010 # A = pd.Series(A) # for a in A: # print(a) for i in A: table[i] += 1 for i in range(Q): B, C = map(int,input().split()) # if B in A: # c = A.count(B) c = table[B] s += (C - B...
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]]
5
151
# -*- coding: utf-8 -*- from sys import stdin from operator import itemgetter from collections import deque, Counter import math import pprint from functools import reduce # stdin = open("sample.txt") MOD = 1000000007 INF = float('inf') alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","...
# -*- coding: utf-8 -*- from sys import stdin from operator import itemgetter from collections import deque, Counter import math import pprint from functools import reduce # stdin = open("sample.txt") MOD = 1000000007 INF = float('inf') alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","...
[["+", 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
505
#include <bits/stdc++.h> using namespace std; typedef long long ll; int a[100001]; int main() { int n, q, b, c; unsigned long long int sum = 0; cin >> n; int temp; for (int i = 0; i < n; ++i) { cin >> temp; sum = sum + temp; a[temp]++; } cin >> q; while (q--) { cin >> b >> c; int c...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int a[100001]; int main() { int n, q; ll b, c; ll sum = 0; cin >> n; int temp; for (int i = 0; i < n; ++i) { cin >> temp; sum = sum + temp; a[temp]++; } cin >> q; while (q--) { cin >> b >> c; int count = a[b]; ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 14, 8, 9, 0, 43, 39, 86, 39, 40]]
1
152
n=int(input()) ls = list(map(int,input().split())) ls = sorted(ls) ans = sum(ls) newls = [0]*(n+1) for p in ls: newls[p] += 1 ls = newls q=int(input()) for _ in range(q): b,c = map(int,input().split()) tmp = ls[b] ans = ans + tmp*c - tmp*b ls[b] = 0 ls[c] = tmp print(ans)
n=int(input()) ls = list(map(int,input().split())) ls = sorted(ls) ans = sum(ls) newls = [0]*(100000+1+1) for p in ls: newls[p] += 1 ls = newls q=int(input()) for _ in range(q): b,c = map(int,input().split()) tmp = ls[b] ans = ans + tmp*c - tmp*b ls[b] = 0 ls[c] += tmp print(ans)
[["-", 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, 72], ["+", 12, 657, 12, 23, 0, 657, 31, 657, 12, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107]]
5
127
n = int(input()) a = [int(i) for i in input().split()] q = int(input()) bc = [] d = {} suma = sum(a) for nr in a: if nr not in d: d[nr] = 1 else: d[nr] += 1 for i in range(q): bc = [int(i) for i in input().split()] b = bc[0] c = bc[1] if b not in d: print(suma) ...
n = int(input()) a = [int(i) for i in input().split()] q = int(input()) bc = [] d = {} suma = sum(a) for nr in a: if nr not in d: d[nr] = 1 else: d[nr] += 1 for i in range(q): bc = [int(i) for i in input().split()] b = bc[0] c = bc[1] if b not in d: print(suma) ...
[["+", 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
166
N = int(input()) CNT = {} S = 0 for a in map(int, input().split()): if not(a in CNT): CNT[a] = 0 CNT[a] += 1 S += a Q = int(input()) for _ in range(Q): B,C = map(int, input().split()) if B in CNT: cnt = CNT[B] S -= B*cnt S += C*cnt if not(C in CN...
N = int(input()) CNT = {} S = 0 for a in map(int, input().split()): if not(a in CNT): CNT[a] = 0 CNT[a] += 1 S += a Q = int(input()) for _ in range(Q): B,C = map(int, input().split()) if B in CNT: cnt = CNT[B] del CNT[B] S -= B*cnt S += C*cnt ...
[["+", 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
131
#include <bits/stdc++.h> #define simplify \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long #define endl "\...
#include <bits/stdc++.h> #define simplify \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define int long long #define endl "\...
[["-", 0, 11, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["-", 0, 11, 12, 23, 0, 16, 12, 16, 31, 22], ["-", 0, 11, 12, 23, 0, 16, 12, 16, 17, 48]]
1
174
#include <bits/stdc++.h> using namespace std; #define vite \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define tst ...
#include <bits/stdc++.h> using namespace std; #define vite \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define tst ...
[["-", 12, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 12, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
1
177
package main import "fmt" func main() { var n int fmt.Scan(&n) as := make([]int, n) am := make(map[int]int) sum := 0 for i := 0; i < n; i++ { fmt.Scan(&as[i]) sum += as[i] am[as[i]]++ } var q int fmt.Scan(&q) var b, c int for i := 0; i < q; i++ { fmt.Scan(&b, &c) p := am[b] am[c] += p sum -=...
package main import "fmt" func main() { var n int fmt.Scan(&n) as := make([]int, n) am := make(map[int]int) sum := 0 for i := 0; i < n; i++ { fmt.Scan(&as[i]) sum += as[i] am[as[i]]++ } var q int fmt.Scan(&q) var b, c int for i := 0; i < q; i++ { fmt.Scan(&b, &c) p := am[b] am[c] += p am[b] ...
[["+", 8, 196, 0, 436, 31, 432, 0, 437, 439, 22], ["+", 8, 196, 0, 436, 31, 432, 0, 437, 0, 70], ["+", 8, 196, 0, 436, 31, 432, 0, 437, 71, 22], ["+", 8, 196, 0, 436, 31, 432, 0, 437, 0, 73], ["+", 8, 196, 0, 7, 8, 196, 0, 436, 17, 32], ["+", 0, 7, 8, 196, 0, 436, 12, 432, 0, 433], ["+", 0, 435, 8, 196, 0, 7, 8, 196, 0...
7
170
from collections import defaultdict n=int(input()) num_dict=defaultdict(int) a_sum=0 for a in map(int,input().split()): num_dict[a]+=1 a_sum+=a for i in range(int(input())): b,c=map(int,input().split()) a_sum+=c*num_dict[c]-b*num_dict[b] num_dict[c]+=num_dict[b] num_dict[b]=0 print(a_sum)
from collections import defaultdict n=int(input()) num_dict=defaultdict(int) a_sum=0 for a in map(int,input().split()): num_dict[a]+=1 a_sum+=a for i in range(int(input())): b,c=map(int,input().split()) a_sum+=c*num_dict[b]-b*num_dict[b] num_dict[c]+=num_dict[b] num_dict[b]=0 print(a_sum)
[["-", 0, 677, 12, 657, 31, 657, 12, 206, 206, 22], ["+", 0, 677, 12, 657, 31, 657, 12, 206, 206, 22]]
5
109
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n; cin >> n; ll arr[n]; map<ll, ll> m; ll sum = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; m[arr[i]]++; sum += arr[i]; } ll queries; cin >> queries; while (queries--) { ll b, c; cin >> b >>...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n; cin >> n; ll arr[n]; map<ll, ll> m; ll sum = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; m[arr[i]]++; sum += arr[i]; } ll queries; cin >> queries; while (queries--) { ll b, c; cin >> b >>...
[["+", 0, 1, 0, 11, 12, 16, 31, 69, 28, 22], ["+", 0, 11, 12, 16, 31, 69, 341, 342, 0, 70], ["+", 0, 11, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 16, 31, 69, 341, 342, 0, 73], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72]]
1
185
#define _USE_MATH_DEFINES #include <algorithm> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; #define ll long long #define ull u...
#define _USE_MATH_DEFINES #include <algorithm> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; #define ll long long #define ull u...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
1,009
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b + 1; i++) #define all(v) v.begin(), v.end() #define SENTINEL 2000000000 #define NIL -1 using namespace std; typedef long long ll; const ll M...
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b + 1; i++) #define all(v) v.begin(), v.end() #define SENTINEL 2000000000 #define NIL -1 using namespace std; typedef long long ll; const ll M...
[["+", 0, 11, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 16, 31, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 16, 12, 69, 28, 22], ["+", 0, 11, 12, 16, 12, 69, 341, 342, 0, 70]]
1
285
array = [0 for i in range(11)] N = int(input()) A = list(map(int, input().split())) Q = int(input()) for a in A: array[a] += 1 souwa = sum(A) B = [] C = [] for i in range(Q): b, c = map(int, input().split()) B.append(b) C.append(c) for i in range(Q): souwa = souwa + (C[i]-B[i])*array[B[i]] ar...
array = [0 for i in range(100001)] N = int(input()) A = list(map(int, input().split())) Q = int(input()) for a in A: array[a] += 1 souwa = sum(A) B = [] C = [] for i in range(Q): b, c = map(int, input().split()) B.append(b) C.append(c) for i in range(Q): souwa = souwa + (C[i]-B[i])*array[B[i]] ...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612]]
5
165
import sys readline = sys.stdin.readline def solve(): N = int(readline()) A = list(map(int, readline().split())) Q = int(readline()) BC = [list(map(int, readline().split())) for i in range(Q)] count = {} for a in A: count[a] = count.get(a, 0) + 1 s = sum(A) for b, c in BC...
import sys readline = sys.stdin.readline def solve(): N = int(readline()) A = list(map(int, readline().split())) Q = int(readline()) BC = [list(map(int, readline().split())) for i in range(Q)] count = {} for a in A: count[a] = count.get(a, 0) + 1 s = sum(A) for b, c in BC...
[["+", 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
160
#include <bits/stdc++.h> using namespace std; int main() { int n, q, a[100050], l, r, x; long long sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x; sum += x; a[x]++; } cin >> q; for (int i = 0; i < q; i++) { cin >> l >> r; int v = a[l]; sum = sum - (1ll * v * l) + (1ll *...
#include <bits/stdc++.h> using namespace std; #define int long long main() { int n, q, a[100500], l, r, x; long long sum = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> x; sum += x; a[x]++; } cin >> q; for (int i = 0; i < q; i++) { cin >> l >> r; int v = a[l]; sum = sum - (1ll ...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
145
#include <bits/stdc++.h> using namespace std; #define int long long #define forn(i, n) for (int i = 0; i < (int)n; ++i) const int MOD = 1000000007; // opsi : 998244353, 1000000007, int32_t main() { ios::sync_with_stdio(false); int n; cin >> n; int arr[n]; map<int, int> mp; int jml = 0; forn(i, n) { ...
#include <bits/stdc++.h> using namespace std; #define int long long #define forn(i, n) for (int i = 0; i < (int)n; ++i) const int MOD = 1000000007; // opsi : 998244353, 1000000007, int32_t main() { ios::sync_with_stdio(false); int n; cin >> n; int arr[n]; map<int, int> mp; int jml = 0; forn(i, n) { ...
[["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 64, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 73], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
236
n=int(input()) a=[int(j)for j in input().split()] s=sum(a) import collections c=collections.Counter(a) q=int(input()) for i in range(q): x,y=map(int,input().split()) s+=c[x]*(y-x) c[y]+=c[x] c[x]=0 print(s) print(s)
n=int(input()) a=[int(j)for j in input().split()] s=sum(a) import collections c=collections.Counter(a) q=int(input()) for i in range(q): x,y=map(int,input().split()) s+=c[x]*(y-x) c[y]+=c[x] c[x]=0 print(s)
[["-", 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
109
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll n; cin >> n; ll sum = 0; map<ll, ll> m; ll a[n]; for (int i = 0; i < n; i++) cin >> a[i], m[a[i]]++, sum += a[i]; int q; cin >> q; while (q--) { ll x, b; cin >> x >> b; int fr = m[x]; sum -= (fr...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll n; cin >> n; ll sum = 0; map<ll, ll> m; ll a[n]; for (int i = 0; i < n; i++) cin >> a[i], m[a[i]]++, sum += a[i]; int q; cin >> q; while (q--) { ll x, b; cin >> x >> b; int fr = m[x]; sum -= (fr...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22]]
1
150
#include "algorithm" #include "bits/stdc++.h" #include <iostream> using namespace std; int n, q, m, x, y; long long sum = 0; int c[100050]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> m; c[m]++; sum += m; } cin >> q; for (int i = 0; i < q; i++) { cin >> x >> y; sum += c[x] ...
#include "algorithm" #include "bits/stdc++.h" #include <iostream> using namespace std; long long n, q, m, x, y; long long sum = 0; long long c[100050]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> m; c[m]++; sum += m; } cin >> q; for (int i = 0; i < q; i++) { cin >> x >> y; ...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]]
1
147
import sys sys.setrecursionlimit(10000000) MOD = 10 ** 9 + 7 INF = 10 ** 15 def main(): N = int(input()) num = [0] * 100005 A = list(map(int,input().split())) S = sum(A) for a in A: num[a] += 1 Q = int(input()) for _ in range(Q): c,d = map(int,input().split()) x...
import sys sys.setrecursionlimit(10000000) MOD = 10 ** 9 + 7 INF = 10 ** 15 def main(): N = int(input()) num = [0] * 100005 A = list(map(int,input().split())) S = sum(A) for a in A: num[a] += 1 Q = int(input()) for _ in range(Q): c,d = map(int,input().split()) x...
[["+", 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
142
#include <stdio.h> #include <string.h> using ll = long long; int main() { int N; scanf("%d", &N); static ll dat[100001]; ll ans = 0; for (int i = 0; i < N; i++) { int A; scanf("%lld", &A); dat[A]++; ans += A; } int Q; scanf("%d", &Q); for (int q = 0; q < Q; q++) { int B, C; ...
#include <stdio.h> #include <string.h> using ll = long long; int main() { int N; scanf("%d", &N); static ll dat[100001]; ll ans = 0; for (int i = 0; i < N; i++) { ll A; scanf("%lld", &A); dat[A]++; ans += A; } int Q; scanf("%d", &Q); for (int q = 0; q < Q; q++) { int B, C; s...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78]]
1
183
#include <bits/stdc++.h> #define drep(i, cc, n) for (int i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define drrep(i, cc, n) for (int i = (cc); i >= (n); --i) #define rrep(i, n) drrep(i, 0, n - 1) #define sz(s) (int)(s.size()) #define vecprint(v) ...
#include <bits/stdc++.h> #define drep(i, cc, n) for (int i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define drrep(i, cc, n) for (int i = (cc); i >= (n); --i) #define rrep(i, n) drrep(i, 0, n - 1) #define sz(s) (int)(s.size()) #define vecprint(v) ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
346
#include <bits/stdc++.h> #define ll long long #define in freopen("input.txt", "r", stdin) #define out freopen("output.txt", "w", stdout) #define skorost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
#include <bits/stdc++.h> #define ll long long #define in freopen("input.txt", "r", stdin) #define out freopen("output.txt", "w", stdout) #define skorost \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107]]
1
271
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') N = int(input()) A = list(map(int, input().split())) Q = int(input()) import collections counter = collections.defaultdict(int) for key, value in collec...
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') N = int(input()) A = list(map(int, input().split())) Q = int(input()) import collections counter = collections.defaultdict(int) for key, value in collec...
[["+", 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
169
import sys import collections input = sys.stdin.readline def main(): N = int(input()) A =list(map(int,input().split())) AD = collections.Counter(A) Q = int(input()) ans =0 for key, item in AD.items(): ans += key * item for i in range(Q): b, c = map(int,input().split()) ...
import sys import collections input = sys.stdin.readline def main(): N = int(input()) A =list(map(int,input().split())) AD = collections.Counter(A) Q = int(input()) ans =0 for key, item in AD.items(): ans += key * item for i in range(Q): b, c = map(int,input().split()) ...
[["-", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102]]
5
203
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll n; cin >> n; map<ll, ll> m; ll temp; ll a, b; ll total = 0; while (n--) { cin >> temp; m[temp]++; total += temp; } ll q; cin >> q; while (q--) { cin >> a >> b; if (m.find(a) != m.end()) { ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll n; cin >> n; map<ll, ll> m; ll temp; ll a, b; ll total = 0; while (n--) { cin >> temp; m[temp]++; total += temp; } ll q; cin >> q; while (q--) { cin >> a >> b; if (m.find(a) != m.end()) { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
1
148
n=int(input()) arr=list(map(int,input().split())) sumv=0 d={} for i in arr: sumv+=i try: d[i]+=1 except: d[i]=1 q=int(input()) while q: b,c=map(int,input().split()) sumv+=(c-b)*d[b] try: d[c]+=d[b] except: d[c]=d[b] d[b]=0 print(sumv) q-=...
n=int(input()) arr=list(map(int,input().split())) sumv=0 d={} for i in arr: sumv+=i try: d[i]+=1 except: d[i]=1 q=int(input()) while q: b,c=map(int,input().split()) if b in d: sumv+=(c-b)*d[b] try: d[c]+=d[b] except: d[c]=d[...
[["+", 0, 656, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 267], ["+", 0, 656, 0, 52, 8, 196, 0, 57, 0, 102]]
5
130
n = int(input()) alist = [int(s) for s in input().split(" ")] adict = {} ans = 0 for a in alist: ans += a if a in adict: adict[a] += 1 else: adict[a] = 1 q = int(input()) bclist = [] for _ in range(q): b, c = [int(s) for s in input().split(" ")] bclist.append([b, c]) for b, c in bclist: if c in adi...
n = int(input()) alist = [int(s) for s in input().split(" ")] adict = {} ans = 0 for a in alist: ans += a if a in adict: adict[a] += 1 else: adict[a] = 1 q = int(input()) bclist = [] for _ in range(q): b, c = [int(s) for s in input().split(" ")] bclist.append([b, c]) for b, c in bclist: if c in adi...
[["-", 0, 1, 0, 677, 12, 657, 31, 657, 31, 22], ["-", 0, 1, 0, 677, 12, 657, 31, 657, 17, 48], ["-", 0, 677, 12, 657, 31, 657, 12, 206, 51, 22], ["-", 0, 677, 12, 657, 31, 657, 12, 206, 0, 70], ["+", 0, 1, 0, 677, 12, 657, 31, 23, 0, 24], ["-", 0, 677, 12, 657, 31, 657, 12, 206, 0, 73], ["+", 0, 1, 0, 677, 12, 657, 31,...
5
196
from collections import Counter N=int(input()) A=list(map(int,input().split())) s=sum(A) Q=int(input()) cnt=Counter(A) for _ in range(Q): b,c=map(int,input().split()) if b in cnt: s-=cnt[b]*b s+=cnt[b]*c print(s) if c in cnt: cnt[c]+=cnt[b] cnt[b]=0 ...
from collections import Counter N=int(input()) A=list(map(int,input().split())) s=sum(A) Q=int(input()) cnt=Counter(A) for _ in range(Q): b,c=map(int,input().split()) if b in cnt: s-=cnt[b]*b s+=cnt[b]*c print(s) if c in cnt: cnt[c]+=cnt[b] cnt[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], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 12, 612]]
5
135
#include <bits/stdc++.h> #define int long long #define quickie \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define rep(i, a, b) for (int i = a; i < b; i++) #define rep1(i, a, b) for (int i = a; i <= b;...
#include <bits/stdc++.h> #define int long long #define quickie \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define rep(i, a, b) for (int i = a; i < b; i++) #define rep1(i, a, b) for (int i = a; i <= b;...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 107]]
1
349
import java.io.*; import java.lang.*; import java.util.*; import java.util.function.*; class Counter<T> extends TreeMap<T, Long> { public Counter() { super(); } public Counter(List<T> list) { super(); for (T e : list) this.addOne(e); } public Long count(Object elm) { return getOrDefault(elm, 0L);...
import java.io.*; import java.lang.*; import java.util.*; import java.util.function.*; class Counter<T> extends TreeMap<T, Long> { public Counter() { super(); } public Counter(List<T> list) { super(); for (T e : list) this.addOne(e); } public Long count(Object elm) { return getOrDefault(elm, 0L);...
[["+", 0, 1, 0, 492, 3, 4, 0, 91, 17, 33]]
3
492
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
[["-", 8, 9, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
453
import sys from collections import defaultdict, deque import math # import copy # from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(input()) getList = lambda: list(map(int, input()...
import sys from collections import defaultdict, deque import math # import copy # from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(input()) getList = lambda: list(map(int, input()...
[["+", 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
224
N=int(input()) a_list=list(map(int,input().split())) Q=int(input()) N_list=[0]*(N+1) sumn=0 for a in a_list: N_list[a]+=1 sumn+=a for i in range(Q): b,c=map(int,input().split()) henka=(c-b)*N_list[b] sumn+=henka N_list[c]+=N_list[b] N_list[b]=0 print(sumn)
N=int(input()) a_list=list(map(int,input().split())) Q=int(input()) N_list=[0]*(100001) sumn=0 for a in a_list: N_list[a]+=1 sumn+=a for i in range(Q): b,c=map(int,input().split()) henka=(c-b)*N_list[b] sumn+=henka N_list[c]+=N_list[b] N_list[b]=0 print(sumn)
[["-", 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
119
import sys sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python import math from copy import copy, deepcopy from copy import deepcopy as dcp from operator import itemgetter from bisect import bisect_left, bisect, bisect_right#2分探索 #bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collection...
import sys sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python import math from copy import copy, deepcopy from copy import deepcopy as dcp from operator import itemgetter from bisect import bisect_left, bisect, bisect_right#2分探索 #bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collection...
[["+", 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
550
n=int(input()) arr=list(map(int,input().split())) s=0 d={} for i in arr: if i in d: d[i]+=1 else: d[i]=1 s+=i for i in range(int(input())): a,b=map(int,input().split()) if a in d: s=s-a*d[a]+b*d[a] if b in d: d[b]+=d[a] else: if a in d: d[b...
n=int(input()) arr=list(map(int,input().split())) s=0 d={} for i in arr: if i in d: d[i]+=1 else: d[i]=1 s+=i for i in range(int(input())): a,b=map(int,input().split()) if a in d: s=s-a*d[a]+b*d[a] if b in d and a in d: d[b]+=d[a] else: if a in d: ...
[["+", 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
150
N = int(input()) A = list(map(int, input().split())) Q = int(input()) BC = [list(map(int, input().split())) for _ in range(Q)] ans = sum(A) R = {} for i in A: if i in R: R[i] += 1 else: R[i] = 1 for b, c in BC: if b in R: t = R[b] ans += t * (c - b) if c in R: R[c] += t else: ...
N = int(input()) A = list(map(int, input().split())) Q = int(input()) BC = [list(map(int, input().split())) for _ in range(Q)] ans = sum(A) R = {} for i in A: if i in R: R[i] += 1 else: R[i] = 1 for b, c in BC: if b in R: t = R[b] R[b] = 0 ans += t * (c - b) if c in R: R[c] += t ...
[["+", 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
143
#include <bits/stdc++.h> #define int long long using namespace std; typedef pair<int, int> ii; int occ[100005]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int S = 0; int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; occ[x] += 1; S += x; } int Q; cin...
#include <bits/stdc++.h> #define int long long using namespace std; typedef pair<int, int> ii; int occ[100005]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int S = 0; int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; occ[x] += 1; S += x; } int Q; cin...
[["+", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]]
1
155
N = int(input()) A = map(int, input().split()) XOR = 0 for a in A: XOR ^= a for i in range(N): A[i] = A[i]^XOR print(*A)
N = int(input()) A = list(map(int, input().split())) XOR = 0 for a in A: XOR ^= a for i in range(N): A[i] = A[i]^XOR print(*A)
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
57
n = int(input()) lis = list(map(int, input().split())) t = lis[0] for i in range(1, n): t ^= i ans = [0] * n for i , j in enumerate(lis): ans[i] = t ^ j print(*ans)
n = int(input()) lis = list(map(int, input().split())) t = lis[0] for i in range(1, n): t ^= lis[i] ans = [0] * n for i , j in enumerate(lis): ans[i] = t ^ j print(*ans)
[["+", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 0, 73]]
5
74
N = int(input()) a_list = list(map(int, input().split())) all_xor = 0 res = [] for a in a_list: all_xor ^= a for a in a_list: res.append(a ^ all_xor) print(res)
N = int(input()) a_list = list(map(int, input().split())) all_xor = 0 res = [] for a in a_list: all_xor ^= a for a in a_list: res.append(a ^ all_xor) print(*res)
[["+", 0, 1, 0, 652, 3, 4, 0, 661, 0, 48]]
5
57
N = int(input()) A = list(map(int, input().split())) count = 0 for i in A: count ^= x for i in range(len(A)): A[i] ^= count print(*A)
N = int(input()) A = list(map(int, input().split())) count = 0 for i in A: count ^= i for i in range(len(A)): A[i] ^= count print(*A)
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22]]
5
58
#include <bits/stdc++.h> #define ll long long #define vi vector<int> #define vll vector<ll> #define pb push_back #define rep(n) for (int i = 0; i < n; i++) #define all(v) v.begin(), v.end() #define print(v) \ for (auto n : v) { ...
#include <bits/stdc++.h> #define ll long long #define vi vector<int> #define vll vector<ll> #define pb push_back #define rep(n) for (int i = 0; i < n; i++) #define all(v) v.begin(), v.end() #define print(v) \ for (auto n : v) { ...
[["+", 0, 338, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22]]
1
129
N = int(input()) A = map(int, input().split()) ax = 0 ans = [] for a in A: ax ^= a for a in A: ans.append(a^ax) print(" ".join(map(str,ans)))
N = int(input()) A = list(map(int, input().split())) ax = 0 ans = [] for a in A: ax ^= a for a in A: ans.append(a^ax) print(" ".join(map(str,ans)))
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
66
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, val, temp; cin >> n; ll arr[n + 5]; for (int i = 0; i < n; i++) { cin >> arr[i]; } val = arr[0]; for (int i = 1; i < n; i++) { val = val ^ arr[i - 1]; } for (int i = 0; i < n; i++) { temp = arr[i] ^ val;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, val, temp; cin >> n; ll arr[n + 5]; for (int i = 0; i < n; i++) { cin >> arr[i]; } val = arr[0]; for (int i = 0; i < n - 1; i++) { val = val ^ arr[i + 1]; } for (int i = 0; i < n; i++) { temp = arr[i] ^ ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 12, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 17, 72]]
1
129
#include <bits/stdc++.h> #include <iostream> #define int long long int using namespace std; int32_t main() { int n, i; vector<int> a(n), b(n); for (i = 0; i < n; i++) cin >> a[i]; int res = a[0]; for (i = 1; i < n; i++) res ^= a[i]; for (i = 0; i < n; i++) { b[i] = res ^ a[i]; cout << b[i] <...
#include <bits/stdc++.h> #include <iostream> #define int long long int using namespace std; int32_t main() { int n, i; cin >> n; vector<int> a(n), b(n); for (i = 0; i < n; i++) cin >> a[i]; int res = a[0]; for (i = 1; i < n; i++) res ^= a[i]; for (i = 0; i < n; i++) { b[i] = res ^ a[i]; co...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
128
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() {...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() {...
[["-", 0, 492, 3, 4, 0, 504, 71, 16, 12, 499], ["+", 0, 492, 3, 4, 0, 504, 71, 16, 12, 499]]
3
484
n = int(input()) a = sorted(list(map(int, input().split()))) x = 0 for i in a: x ^= i for i in range(n): a[i] ^= x print(*a)
n = int(input()) a = list(map(int, input().split())) x = 0 for i in a: x ^= i for i in range(n): a[i] ^= x print(*a)
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
58
#include <cstdio> #include <cstring> #include <iostream> #define maxn 200005 int a[maxn]; using namespace std; int main(void) { int n; scanf("%d", &n); int sum = 0; for (int i = 1; i < n; ++i) { scanf("%d", &a[i]); sum ^= a[i]; } for (int i = 0; i < n - 1; ++i) { printf("%d ", sum ^ a[i]); } ...
#include <cstdio> #include <cstring> #include <iostream> #define maxn 200005 int a[maxn]; using namespace std; int main(void) { int n; scanf("%d", &n); int sum = 0; for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); sum ^= a[i]; } for (int i = 0; i < n - 1; ++i) { printf("%d ", sum ^ a[i]); } ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
132
n = int(input()) a = list(map(int,input().split())) xor_a = 0 for i in range(n): xor_a ^= a[i] print(xor_a) ans = [] for i in range(n): ans.append(a[i] ^ xor_a) print(*ans)
n = int(input()) a = list(map(int,input().split())) xor_a = 0 for i in range(n): xor_a ^= a[i] #print(xor_a) ans = [] for i in range(n): ans.append(a[i] ^ xor_a) print(*ans)
[["-", 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
74
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define sayyes cout << "Yes" << endl; #define sayno cout << "No" << endl; using namespace std; typedef long long ll; const double PI = acos(-1); typedef pair<int, int> P; const int mod = 1e9 + 7; int main() { int n; cin >> n; vector<ll> a(n)...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) #define sayyes cout << "Yes" << endl; #define sayno cout << "No" << endl; using namespace std; typedef long long ll; const double PI = acos(-1); typedef pair<int, int> P; const int mod = 1e9 + 7; int main() { int n; cin >> n; vector<ll> a(n)...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
131
N = int(input()) A = map(int, input().split()) total = 0 for a in A: total ^= a result = [] for a in A: result.append(total ^ a) print(*result)
N = int(input()) A = list(map(int, input().split())) total = 0 for a in A: total ^= a result = [] for a in A: result.append(total ^ a) print(*result)
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
55
N = int(input()) a = list(map(int,input().split())) tmp = 0 for i in a: tmp ^= i ans = a[:] for i in range(N): ans[i] ^= tmp print(ans)
N = int(input()) a = list(map(int,input().split())) tmp = 0 for i in a: tmp ^= i ans = a[:] for i in range(N): ans[i] ^= tmp print(*ans)
[["+", 0, 1, 0, 652, 3, 4, 0, 661, 0, 48]]
5
60
// SMOKE SHISHA PLAY FIFA // #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define pll ...
// SMOKE SHISHA PLAY FIFA // #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define pll ...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
241
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const int INF = 1001001001; using P = pair<int, int>; int main(void) { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; // x ^ x = 0 ➡️ 奇数なら x 偶数なら 0 ......① // x1 ^ x2 ^ x3 ^...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const int INF = 1001001001; using P = pair<int, int>; int main(void) { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; // x ^ x = 0 ➡️ 奇数なら x 偶数なら 0 ......① // x1 ^ x2 ^ x3 ^...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 130]]
1
137
#include <bits/stdc++.h> using namespace std; #define int long long #define w(x) \ int x; \ cin >> x; \ while (...
#include <bits/stdc++.h> using namespace std; #define int long long #define w(x) \ int x; \ cin >> x; \ while (...
[["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 31, 22]]
1
219
N = int(input()) A = list(map(int, input().split())) s = 0 for i in range(N): s ^= A[i] print(s) for i in range(N): ans = s^A[i] print(ans, end=" ")
N = int(input()) A = list(map(int, input().split())) s = 0 for i in range(N): s ^= A[i] for i in range(N): ans = s^A[i] print(ans, end=" ")
[["-", 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
72
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int total = 0; int res[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); total ^= a[i]; } for (int i...
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int total = 0; int res[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); total ^= a[i]; } for (int i...
[["-", 0, 7, 8, 196, 0, 1, 0, 11, 17, 130], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 504, 516, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 504, 0, 70], ["+", 0, 1, 0, 11, 12, 16, 31, 504, 71, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 504, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 140]]
3
143
#include <bits/stdc++.h> #include <math.h> using namespace std; typedef long long ll; #define M_PI 3.14159265358979323846 const int MOD = 1e9 + 7; void solve() { ll n; cin >> n; vector<ll> a(n); ll ans = 1; for (int i = 0; i < n; i++) { cin >> a[i]; ans = ans ^ a[i]; } for (int i = 0; i < n; i++...
#include <bits/stdc++.h> #include <math.h> using namespace std; typedef long long ll; #define M_PI 3.14159265358979323846 const int MOD = 1e9 + 7; void solve() { int n; cin >> n; vector<int> a(n); int ans = 0; for (int i = 0; i < n; i++) { cin >> a[i]; ans = ans ^ a[i]; } for (int i = 0; i < n; ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
209
N = int(input()) A = list(map(int, input().split())) xor = 0 for i in A: A ^= i for j in range(N): print(A^a[i], end=' ')
N = int(input()) A = list(map(int, input().split())) xor = 0 for i in A: xor ^= i for j in range(N): print(xor^A[j], end=' ')
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 652, 3, 4, 0, 657, 12, 206, 51, 22], ["+", 0, 652, 3, 4, 0, 657, 12, 206, 51, 22], ["-", 0, 652, 3, 4, 0, 657, 12, 206, 206, 22], ["+", 0,...
5
59
#include <bits/stdc++.h> #include <cstring> #include <limits> using namespace std; #define ll long long int #define lli long long int #define fw(i, s, e) for (ll i = s; i < e; ++i) #define fe(i, s, e) for (ll i = s; i <= e; ++i) #define fb(i, e, s) for (ll i = e; i >= s; --i) #define L(T) ...
#include <bits/stdc++.h> #include <cstring> #include <limits> using namespace std; #define ll long long int #define lli long long int #define fw(i, s, e) for (ll i = s; i < e; ++i) #define fe(i, s, e) for (ll i = s; i <= e; ++i) #define fb(i, e, s) for (ll i = e; i >= s; --i) #define L(T) ...
[["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 139], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 140]]
1
188
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; cin >> N; int A = 0; vector<int> B(N); for (int i = 0; i < N; i++) { int a; cin >> a; A ^= a; B.push_back(a); } for (int i = 0; i < N; i++) { int kasu = B[i] ^ A; cout << kasu; } ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; cin >> N; int A = 0; vector<int> B(0); for (int i = 0; i < N; i++) { int a; cin >> a; A ^= a; B.push_back(a); } for (int i = 0; i < N; i++) { int kasu = B[i] ^ A; cout << kasu << " ...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
105
#line 2 "codes/header.hpp" //%snippet.set('header')% //%snippet.fold()% #ifndef HEADER_H #define HEADER_H // template version 2.0 using namespace std; #include <bits/stdc++.h> // varibable settings const long long INF = 1e18; template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1; #define _overload3(_1...
#line 2 "codes/header.hpp" //%snippet.set('header')% //%snippet.fold()% #ifndef HEADER_H #define HEADER_H // template version 2.0 using namespace std; #include <bits/stdc++.h> // varibable settings const long long INF = 1e18; template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1; #define _overload3(_1...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
687
n = int(input()) a = list(map(int, input().split())) x = 0 for i in range(1, n): x = x^a[i] l = [x] for i in range(n-1): x = a[i]^a[i+1] l.append(l[i]^x) print(l)
n = int(input()) a = list(map(int, input().split())) x = 0 for i in range(1, n): x = x^a[i] l = [x] for i in range(n-1): x = a[i]^a[i+1] l.append(l[i]^x) print(*l)
[["+", 0, 1, 0, 652, 3, 4, 0, 661, 0, 48]]
5
89
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //required #include <ext/pb_ds/tree_policy.hpp> //required #define pb push_back #define pf push_front #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (long long)(x).size() #define sqr(x) (x) * (x) #define ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //required #include <ext/pb_ds/tree_policy.hpp> //required #define pb push_back #define pf push_front #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (long long)(x).size() #define sqr(x) (x) * (x) #define ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
1,428
n = int(input()) a = list(map(int, input().split())) b = 0 for i in range(n): b ^= a[i] ans = [] for i in range(n): ap = b ^ a[i] ans.append(ap) print(*list(set(ans)))
n = int(input()) a = list(map(int, input().split())) b = 0 for i in range(n): b ^= a[i] ans = [] for i in range(n): ap = b ^ a[i] ans.append(ap) print(*ans)
[["-", 0, 652, 3, 4, 0, 652, 63, 661, 0, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
79
n = int(input()) arr = list(map(int, input().split())) for i in arr: total ^= i for i in arr: print(total ^ i, end=' ')
n = int(input()) arr = list(map(int, input().split())) total = 0 for i in arr: total ^= i for i in arr: print(total ^ i, end=' ')
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
50
N = int(input()) A = list(map(int, input().split())) p = 0 for i in range(1, N): p ^= A[i] print(p) ans = [str(p)] for i in range(1, N): t = A[i-1] ^ A[i] p = p ^ t ans.append(str(p)) print(" ".join(ans))
N = int(input()) A = list(map(int, input().split())) p = 0 for i in range(1, N): p ^= A[i] ans = [str(p)] for i in range(1, N): t = A[i-1] ^ A[i] p = p ^ t ans.append(str(p)) print(" ".join(ans))
[["-", 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
104
#include <bits/stdc++.h> using namespace std; int n, a[200003], allxor = 0; int main(void) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; allxor ^= a[i]; } for (int i = 0; i < n; i++) cout << (a[i] ^ allxor); }
#include <bits/stdc++.h> using namespace std; int n, a[200003], allxor = 0; int main(void) { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; allxor ^= a[i]; } for (int i = 0; i < n; i++) cout << (a[i] ^ allxor) << ' '; }
[["+", 8, 9, 0, 7, 8, 1, 0, 16, 17, 151], ["+", 0, 7, 8, 1, 0, 16, 12, 103, 0, 104], ["+", 0, 7, 8, 1, 0, 16, 12, 103, 0, 125]]
1
84
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; #define vll vector<ll> #define FOR(i, b, e) for (int i = (b); i < (e); ++i) #define REP(i, e) FOR(i, 0, e) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define RE...
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; #define vll vector<ll> #define FOR(i, b, e) for (int i = (b); i < (e); ++i) #define REP(i, e) FOR(i, 0, e) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define RE...
[["+", 0, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
277
#include <bits/stdc++.h> using namespace std; long long a[200005]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &a[i]); } long long ans = a[1]; for (int i = 1; i < n; i++) ans = ans ^ a[i]; for (int i = 0; i < n; i++) printf("%lld ", ans ^ a[i]); }
#include <bits/stdc++.h> using namespace std; long long a[200005]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &a[i]); } long long ans = a[0]; for (int i = 1; i < n; i++) ans = ans ^ a[i]; for (int i = 0; i < n; i++) { printf("%lld ", ans ^ a[i]); } }
[["-", 0, 43, 49, 50, 51, 69, 341, 342, 0, 13], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 13], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
121
n = int(input()) list = [int(i) for i in input().split()] total = 0 ans = [] for i in range(n): total = total ^ list[i] print(total) for j in range(n): ans.append(str(total^list[j])) print(" ".join(ans))
n = int(input()) list = [int(i) for i in input().split()] total = 0 ans = [] for i in range(n): total = total ^ list[i] for j in range(n): ans.append(str(total^list[j])) print(" ".join(ans))
[["-", 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
86
n = int(input()) aa = map(int,input().split()) x = 0 for a in aa: x^=a print(" ".join(str(x^a) for a in aa ))
n = int(input()) aa = list(map(int,input().split())) x = 0 for a in aa: x^=a print(" ".join([str(x^a) for a in aa ]))
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["+", 3, 4, 0, 652, 3, 4, 0, 658, 0, 70], ["+", 3, 4, 0, 652, 3, 4, 0, 658, 0, 73]]
5
53
// author-Shivam gupta #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++) #define IN(A, B, C) assert(B <= A && A <= C) #define MP make_pair #define FOR(i, a) for (int i = 0; i < a; i++) #define FOR1(i, j...
// author-Shivam gupta #include <bits/stdc++.h> using namespace std; #define MEM(a, b) memset(a, (b), sizeof(a)) #define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++) #define IN(A, B, C) assert(B <= A && A <= C) #define MP make_pair #define FOR(i, a) for (int i = 0; i < a; i++) #define FOR1(i, j...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 130], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 140], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 8, 9, 0, 1, 0, 2, 3,...
1
223
n=int(input()) alist=list(map(int,input().split())) allh=alist[0]^alist[1] for i in range(n-1): allh = allh ^ alist[i+2] outlist=[] for a in alist: outlist.append(str(allh ^ a)) outlist.append(" ") outlist.pop() print("".join(outlist))
n=int(input()) alist=list(map(int,input().split())) allh=alist[0]^alist[1] for i in range(n-2): allh = allh ^ alist[i+2] outlist=[] for a in alist: outlist.append(str(allh ^ a)) outlist.append(" ") outlist.pop() print("".join(outlist))
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
99
#include <bits/stdc++.h> #define REP(i, n) for (long long i = 0; i < (long long)n; i++) //#define _GLIBCXX_DEBUG using namespace std; using ll = long long; using Pi = pair<int, int>; using Pl = pair<ll, ll>; using Vl = vector<ll>; using vi = vector<int>; using Graph = vector<vi>; int main() { cin.tie(0); ios::sync...
#include <bits/stdc++.h> #define REP(i, n) for (long long i = 0; i < (long long)n; i++) //#define _GLIBCXX_DEBUG using namespace std; using ll = long long; using Pi = pair<int, int>; using Pl = pair<ll, ll>; using Vl = vector<ll>; using vi = vector<int>; using Graph = vector<vi>; int main() { cin.tie(0); ios::sync...
[["-", 8, 9, 0, 43, 49, 50, 51, 11, 17, 130], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 140]]
1
165
#include "bits/stdc++.h" using namespace std; #define ll long long int main() { ll n; ll i, j; ll x; ll ans; cin >> n; vector<ll> a(n); for (i = 0; i < n; i++) { cin >> a[i]; if (i == 0) x = a[i]; else x ^= a[i]; } for (i = 0; i < n; i++) { ans = x ^ a[i]; cout << a[i...
#include "bits/stdc++.h" using namespace std; #define ll long long int main() { ll n; ll i, j; ll x; ll ans; cin >> n; vector<ll> a(n); for (i = 0; i < n; i++) { cin >> a[i]; if (i == 0) x = a[i]; else x ^= a[i]; } for (i = 0; i < n; i++) { ans = x ^ a[i]; cout << ans...
[["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
125
import math # noqa: F401 from typing import Dict, List, Optional, Tuple, Union # noqa: F401 def sum_xor(A: List[int]) -> int: sum_ = 0 for a in A: sum_ ^= a return sum_ def main(N: int, A: List[int]): sum_ = sum_xor(A) for a in A: print(a ^ sum_, end="") print() if __name...
import math # noqa: F401 from typing import Dict, List, Optional, Tuple, Union # noqa: F401 def sum_xor(A: List[int]) -> int: sum_ = 0 for a in A: sum_ ^= a return sum_ def main(N: int, A: List[int]): sum_ = sum_xor(A) for a in A: print(a ^ sum_, end=" ") print() if __nam...
[["+", 0, 652, 3, 4, 0, 653, 51, 557, 0, 6]]
5
120
n=int(input()) a=list(map(int,input().split())) ans=[] b=a.copy() del b[0] a1=0 a2=a[1] for i in b: a1=a1^i ans.append(a1) for i in b: ansii=a1^i ansi=a2^ansii ans.append(ansi) for i in range(n): print(ans[i],end=' ')
n=int(input()) a=list(map(int,input().split())) ans=[] b=a.copy() del b[0] a1=0 a2=a[0] for i in b: a1=a1^i ans.append(a1) for i in b: ansii=a1^i ansi=a2^ansii ans.append(ansi) for i in range(n): print(ans[i],end=' ')
[["-", 0, 656, 0, 1, 0, 662, 12, 206, 206, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 206, 612]]
5
108
#include <algorithm> #include <assert.h> #include <cmath> #include <deque> #include <float.h> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #incl...
#include <algorithm> #include <assert.h> #include <cmath> #include <deque> #include <float.h> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #incl...
[["+", 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, 6]]
1
3,534
n = int(input()) a=list(map(int,input().split())) forward = [] back = [] result = '' t = 0 for i in range(n): t ^= a[i] forward.append(t) t = 0 for i in range(n-1, -1, -1): t ^= a[i] back.append(t) print(forward, back) for i in range(n): if i == 0: t = back[n-2] elif i == n-1: t...
n = int(input()) a=list(map(int,input().split())) forward = [] back = [] result = '' t = 0 for i in range(n): t ^= a[i] forward.append(t) t = 0 for i in range(n-1, -1, -1): t ^= a[i] back.append(t) for i in range(n): if i == 0: t = back[n-2] elif i == n-1: t = forward[n-2] e...
[["-", 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, 21], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
166
def main(): n = int(input()) a = list(map(int,input().split())) s = 0 for i, aa in enumerate(a): if i == 0: s = aa else: s ^= aa ans = [] if s % 2 == 0: for i, aa in enumerate(a): ans.append(s^aa) else: for i, aa in enumera...
def main(): n = int(input()) a = list(map(int,input().split())) s = 0 for i, aa in enumerate(a): if i == 0: s = aa else: s ^= aa # print(bin(s)) ans = [] if n % 2 == 0: for i, aa in enumerate(a): ans.append(s^aa) else: ...
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 664, 17, 92], ["-", 0, 652, 3, 4, 0, 664, 28, 23, 0, 24], ["-", 0, 652, 3, 4, 0, 664, 28, 23, 0, 25]]
5
134
n = int(input()) a = list(map(int,input().split())) x = 0 for i in range(n): x = x^a[i] print(x) for i in range(n): print(x^a[i],end="") print(" ",end="") print("")
n = int(input()) a = list(map(int,input().split())) x = 0 for i in range(n): x = x^a[i] for i in range(n): print(x^a[i],end="") print(" ",end="") print("")
[["-", 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
86
n=int(input()) a=list(map(int,input().split())) p=0 for x in a: p^=x ans=[] for x in a: ans.append(p^x) print(ans)
n=int(input()) a=list(map(int,input().split())) p=0 for x in a: p^=x ans=[] for x in a: ans.append(p^x) print(*ans)
[["+", 0, 1, 0, 652, 3, 4, 0, 661, 0, 48]]
5
57
import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { void solve(Scanner sc, PrintWriter pw) { int N = sc.nextInt(); int[] data = new int[N]; for (int i = 0; i < N; i++) { data[i] = sc.nextInt(); } int totalXor = 0; ...
import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { void solve(Scanner sc, PrintWriter pw) { int N = sc.nextInt(); int[] data = new int[N]; for (int i = 0; i < N; i++) { data[i] = sc.nextInt(); } int totalXor = 0; ...
[["-", 0, 195, 8, 196, 0, 7, 26, 27, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 11, 17, 107], ["+", 0, 195, 8, 196, 0, 7, 26, 11, 12, 499]]
3
257
n=int(input()) a=list(map(int, input().split())) xor=[] for i in range(n-1): xor.append(a[i]^a[i+1]) f=0 for i in range(0,len(xor),2): f^=xor[i] first=f^a[0] ans=[first] k=first print(first,end=' ') for i in xor: print(k^i,end=' ') k=i
n=int(input()) a=list(map(int, input().split())) xor=[] for i in range(n-1): xor.append(a[i]^a[i+1]) f=0 for i in range(0,len(xor),2): f^=xor[i] first=f^a[0] ans=[first] k=first print(first,end=' ') for i in xor: print(k^i,end=' ') k=k^i
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 140]]
5
125