Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <bits/stdc++.h>

int main() {
  	int N;
  	int K;
	cin >> N;
  	vector<int> input(N);
  	unordered_map<int, int> hash;
  	int sum = 0;
  	for(int i = 0; i < N; i++) {
      cin >> input[i];
      hash[input[i]]++;
      sum += input[i];
    }
  	cin >> K;
    int orig, upd;
    for(int i = 0; i < K; i++){
      cin >> orig >> upd;
      int num = hash[orig];
      int diff = upd - orig;
      hash.erase(orig);
      hash[upd] += num;
      sum += diff * num;
      cout << sum << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |         cin >> N;
      |         ^~~
      |         std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:9: error: 'vector' was not declared in this scope
   11 |         vector<int> input(N);
      |         ^~~~~~
a.cc:11:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:11:16: error: expected primary-expression before 'int'
   11 |         vector<int> input(N);
      |                ^~~
a.cc:12:9: error: 'unordered_map' was not declared in this scope
   12 |         unordered_map<int, int> hash;
      |         ^~~~~~~~~~~~~
a.cc:12:9: note: suggested alternatives:
In file included from /usr/include/c++/14/unordered_map:41,
                 from a.cc:4:
/usr/include/c++/14/bits/unordered_map.h:109:11: note:   'std::unordered_map'
  109 |     class unordered_map
      |           ^~~~~~~~~~~~~
/usr/include/c++/14/unordered_map:67:13: note:   'std::pmr::unordered_map'
   67 |       using unordered_map
      |             ^~~~~~~~~~~~~
a.cc:12:23: error: expected primary-expression before 'int'
   12 |         unordered_map<int, int> hash;
      |                       ^~~
a.cc:15:14: error: 'input' was not declared in this scope; did you mean 'int'?
   15 |       cin >> input[i];
      |              ^~~~~
      |              int
a.cc:16:7: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
   16 |       hash[input[i]]++;
      |       ^~~~
      |       std::hash
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
   59 |     struct hash;
      |            ^~~~
a.cc:23:17: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
   23 |       int num = hash[orig];
      |                 ^~~~
      |                 std::hash
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
   59 |     struct hash;
      |            ^~~~
a.cc:28:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   28 |       cout << sum << endl;
      |       ^~~~
      |       std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:28:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   28 |       cout << sum << endl;
      |                      ^~~~
      |                      std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~