Language: C++

#include<bits/stdc++.h>
#define MAXN 100001
int n,q,time[MAXN];
long long ans;
int main()
{
	cin>>n;
	for(int i=1,x;i<=n;++i)
	{
		cin>>x;
		ans+=x;
		++time[x];
	}
	cin>>q;
	for(int i=1,b,c;i<=q;++i)
	{
		cin>>b>>c;0
		ans-=1ll*time[b]*b;
		ans+=1ll*time[b]*c;
		cout<<ans;
		time[c]+=time[b];
		time[b]=0;
	}
	return 0;
}

Compiler output:
a.cc:3:18: error: 'int time [100001]' redeclared as different kind of entity
    3 | int n,q,time[MAXN];
      |                  ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |         cin>>n;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   12 |                 ++time[x];
      |                         ^
a.cc:12:25: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
   12 |                 ++time[x];
      |                   ~~~~~~^
a.cc:12:25: error: lvalue required as increment operand
   12 |                 ++time[x];
      |                         ^
a.cc:17:28: error: expected ';' before 'ans'
   17 |                 cin>>b>>c;0
      |                            ^
      |                            ;
   18 |                 ans-=1ll*time[b]*b;
      |                 ~~~         
a.cc:19:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |                 ans+=1ll*time[b]*c;
      |                                ^
a.cc:19:25: error: invalid operands of types 'long long int' and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator*'
   19 |                 ans+=1ll*time[b]*c;
      |                      ~~~^~~~~~~~
      |                      |         |
      |                      |         time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                      long long int
a.cc:20:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |                 cout<<ans;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:21:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   21 |                 time[c]+=time[b];
      |                       ^
a.cc:21:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   21 |                 time[c]+=time[b];
      |                                ^
a.cc:21:24: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to binary 'operator+'
   21 |                 time[c]+=time[b];
      |                 ~~~~~~~^~~~~~~~~
a.cc:21:24: note:   in evaluation of 'operator+=(time_t(time_t*) noexcept {aka long int(long int*) noexcept}, time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept})'
a.cc:22:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |                 time[b]=0;
      |                       ^
a.cc:22:24: error: assignment of read-only location '*(time + ((sizetype)b))'
   22 |                 time[b]=0;
      |                 ~~~~~~~^~