Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
int n;
long long k;
int a[200100];
vector<int> pos[200100];
int hash[200100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pos[a[i]].push_back(i);
	}
	for(int i=1;i<=n;i++){
		pos[a[i]].push_back(i+n);
	}
	int item=a[1];
	long long rounds=0;
	int cur=1;
	while(1){
		int lascur=cur;
		int nex=upper_bound(pos[item].begin(),pos[item].end(),cur)-pos[item].begin();
		cur=pos[item][nex]+1;
		if(cur>n){
			cur-=n;
			rounds+=1LL;
		}
		if(rounds==k){
			cur=lascur;
			break;
		}
		if(cur==1){
			k-=k/rounds*rounds;
			rounds=0;
		}
		item=a[cur];
	}
	deque<int> q;
	for(int i=cur;i<=n;i++){
		if(hash[a[i]]){
			while(q.back()!=a[i])
				q.pop_back();
			q.pop_back();
			hash[a[i]]=0;
		}
		else{
			q.push_back(a[i]);
			hash[a[i]]++;
		}
	}
	while(q.size()){
		cout<<q.front()<<' ';
		q.pop_front();
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:61:20: error: reference to 'hash' is ambiguous
   61 |                 if(hash[a[i]]){
      |                    ^~~~
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/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:23:5: note:                 'int hash [200100]'
   23 | int hash[200100];
      |     ^~~~
a.cc:65:25: error: reference to 'hash' is ambiguous
   65 |                         hash[a[i]]=0;
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:23:5: note:                 'int hash [200100]'
   23 | int hash[200100];
      |     ^~~~
a.cc:69:25: error: reference to 'hash' is ambiguous
   69 |                         hash[a[i]]++;
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:23:5: note:                 'int hash [200100]'
   23 | int hash[200100];
      |     ^~~~