Language: C++

#include <algorithm>
#include <iostream>
#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:9:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    9 |         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:10:9: error: 'vector' was not declared in this scope
   10 |         vector<int> input(N);
      |         ^~~~~~
a.cc:10:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:4:
/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:10:16: error: expected primary-expression before 'int'
   10 |         vector<int> input(N);
      |                ^~~
a.cc:11:9: error: 'unordered_map' was not declared in this scope
   11 |         unordered_map<int, int> hash;
      |         ^~~~~~~~~~~~~
a.cc:11:9: note: suggested alternatives:
In file included from /usr/include/c++/14/unordered_map:41,
                 from a.cc:3:
/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:11:23: error: expected primary-expression before 'int'
   11 |         unordered_map<int, int> hash;
      |                       ^~~
a.cc:14:14: error: 'input' was not declared in this scope; did you mean 'int'?
   14 |       cin >> input[i];
      |              ^~~~~
      |              int
a.cc:15:7: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
   15 |       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:22:17: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
   22 |       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:27:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |       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:27:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   27 |       cout << sum << endl;
      |                      ^~~~
      |                      std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~