Language: C++

#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()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  long long k;
  cin>>n>>k;
  int a[n];
  REP(i, n) cin>>a[i];
  
  int prev(20'0010, -1);
  bool used(n, false);
  long long g[n][61];
  REP(i, 2 * n){
    int ni = i % n;
    if(prev[a[ni]] < 0){
      prev[a[ni]] = i;
      continue;
    }
    
    int start = prev[a[ni]];
    if(used[start]) continue;
    g[start][0] = i - start + 1;
    used[start] = true;
  }
  REPP(j, 60){
    REP(i, n){
      g[i][j] = g[i][j - 1];
      long long mid = i + g[i][j - 1];
      long long temp = g[mid % n][j - 1];
      g[i][j] += temp;
    }
  }
  
  long long now = 0;
  while(now < n * k){
    long long i = now % n;
    long long nj = -1;
    for(int j = 0; j <= 60; j++){
      if(now + g[i][j] < n * k){
        nj = j;
      }
    }
    if(nj < 0) break;
    now = now + g[i][nj];
  }
  
  bool exist(200'010, false);
  stack<int> st;
  for(int i = now % n; i < n; i++){
    if(!exist[a[i]]){
      st.push(a[i]);
      exist[a[i]] = true;
      continue;
    }
    while(!st.empty()){
      if(st.top() == a[i]){
        st.pop();
        exist[a[i]] = false;
        break;
      }else{
        st.pop();
        exist[a[i]] = false;
      }
    }
  }
  vector<int> ans;
  while(!st.empty()){
    ans.push_back(st.top());
    st.pop();
  }
  reverse(ALL(ans));
  for(int& x: ans) cout << x << ' ';
  cout << endl;  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:77:23: error: expression list treated as compound expression in initializer [-fpermissive]
   77 |   int prev(20'0010, -1);
      |                       ^
a.cc:78:21: error: expression list treated as compound expression in initializer [-fpermissive]
   78 |   bool used(n, false);
      |                     ^
a.cc:82:12: error: invalid types 'int[int]' for array subscript
   82 |     if(prev[a[ni]] < 0){
      |            ^
a.cc:83:11: error: invalid types 'int[int]' for array subscript
   83 |       prev[a[ni]] = i;
      |           ^
a.cc:87:21: error: invalid types 'int[int]' for array subscript
   87 |     int start = prev[a[ni]];
      |                     ^
a.cc:88:12: error: invalid types 'bool[int]' for array subscript
   88 |     if(used[start]) continue;
      |            ^
a.cc:90:9: error: invalid types 'bool[int]' for array subscript
   90 |     used[start] = true;
      |         ^
a.cc:114:28: error: expression list treated as compound expression in initializer [-fpermissive]
  114 |   bool exist(200'010, false);
      |                            ^
a.cc:117:14: error: invalid types 'bool[int]' for array subscript
  117 |     if(!exist[a[i]]){
      |              ^
a.cc:119:12: error: invalid types 'bool[int]' for array subscript
  119 |       exist[a[i]] = true;
      |            ^
a.cc:125:14: error: invalid types 'bool[int]' for array subscript
  125 |         exist[a[i]] = false;
      |              ^
a.cc:129:14: error: invalid types 'bool[int]' for array subscript
  129 |         exist[a[i]] = false;
      |              ^