criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli n, m=0;

int main() {
	cin >> n;
	rep1(i,sqrt(n)){
		if(n%i==0)m=i;
	}
	cout << "0 0 0 " << m << " " << n/m << " 0"; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:16: error: 'sqrt' was not declared in this scope
   27 |         rep1(i,sqrt(n)){
      |                ^~~~
a.cc:10:34: note: in definition of macro 'rep1'
   10 | #define rep1(i,j) for(int i=1;i<=j;i++)
      |                                  ^
Language: Java

import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long S = sc.nextLong()

        System.out.println("0 0 1 0 0 "+S);


    }



}


Compiler output:
Main.java:8: error: ';' expected
        long S = sc.nextLong()
                              ^
1 error
Language: C++

// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL s;
	cin >> s;
	LL a = (LL)ceil(sqrt(s));
	LL r = a * a - s;
	cout << "0 0 1 " << a << " " << a << " " << r << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:18:25: error: 'sqrt' was not declared in this scope
   18 |         LL a = (LL)ceil(sqrt(s));
      |                         ^~~~
a.cc:18:20: error: 'ceil' was not declared in this scope
   18 |         LL a = (LL)ceil(sqrt(s));
      |                    ^~~~
Language: C

#include"stdio.h"
int main(void){
 double z;
  scanf("%lf",&z);
 double x=y=0; 
  while(x*y!=z/2){
  	x++;
    if(x*y!=z/2){break;}
    y++;
    if(x*y!=z/2){break;}
  }
  printf("%lf %lf %lf %lf %lf %lf ","0","0",x,"0","0",y);
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:11: error: 'y' undeclared (first use in this function)
    5 |  double x=y=0;
      |           ^
main.c:5:11: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  static constexpr u64 max = 1000000000;
  const u64 s = scan<u64>();
  u64 r = max - s % max;
  if (s % max == static_cast<u64>(0)) {
    r = static_cast<u64>(0);
  }
  std::cout << 0 << " " << 0 << " " << max << " " << r << " " << 1 << " "
            << (s + r) / max << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Compiler output:
a.cc: In function 'T n91::scan()':
a.cc:70:8: error: 'cin' is not a member of 'std'
   70 |   std::cin >> ret;
      |        ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <vector>
  +++ |+#include <iostream>
    5 |
Language: C++

#include <bits/stdc++.h>
using namespace std;

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



signed main()
{
	int s; in >> s;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:16: error: 'in' was not declared in this scope; did you mean 'yn'?
   61 |         int s; in >> s;
      |                ^~
      |                yn
Language: C++

#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define pob pop_back
#define st first
#define nd second
#define test cout<<"test"<<endl;
#define mp make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

ll INF = 1e9;
ll mod = 1e9+7;

ll n,m,k,l,r,ans;

ll min(ll a, ll b) {
	return (a<b)? a:b;
}
ll max(ll a, ll b) {
	return a+b-min(a,b);
}

int main() {
	cin>>n;
	cout<<0<<' '<<n<<' '<<0<<' '<<0<<' '<<1<<' '<<0<<endl;g
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:63: error: 'g' was not declared in this scope
   29 |         cout<<0<<' '<<n<<' '<<0<<' '<<0<<' '<<1<<' '<<0<<endl;g
      |                                                               ^
Language: C++

#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


int s;cin>>s;
signed main(){
  cout << 0 << 0 << s+1 << 1 << 1 << 1 << endl;
}


Compiler output:
a.cc:47:7: error: 'cin' does not name a type
   47 | int s;cin>>s;
      |       ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long s;
int main(){
	cin>>s;
	cout<<0<<' '<<0<<' '<<0<<' '<<s<<' '<<1<<' '0<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:53: error: expected ';' before numeric constant
    6 |         cout<<0<<' '<<0<<' '<<0<<' '<<s<<' '<<1<<' '0<<endl;
      |                                                     ^
      |                                                     ;
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mod=1e9+7;
ll m,n,yy[200005],loc[200005],next[200005],cnt,fir[200005];
vector<int> ans[200005];
int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
	cin>>m>>n;
	for(int i=1;i<=m;++i)
	{
		cin>>yy[i];
		if(loc[yy[i]]) next[loc[yy[i]]]=i;
		else fir[yy[i]]=i;
		loc[yy[i]]=i;
	}
	int now=1;
	while(1)
	{
        if(!next[now]) ans[cnt].push_back(yy[now]),++now;
        else now=next[now]+1;
        if(now==m+1)
        {
        	if(ans[cnt].size()==0) break;
			now=fir[ans[cnt][0]]+1;
        	//cout<<ans[cnt].size()<<" "<<now<<endl;
        	cnt++;
		}
	}
	now=n%cnt;
	int s=ans[now].size();
	for(int i=0;i<s;++i) cout<<ans[now][i]<<" ";
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:32: error: reference to 'next' is ambiguous
   15 |                 if(loc[yy[i]]) next[loc[yy[i]]]=i;
      |                                ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:6:31: note:                 'long long int next [200005]'
    6 | ll m,n,yy[200005],loc[200005],next[200005],cnt,fir[200005];
      |                               ^~~~
a.cc:22:13: error: reference to 'next' is ambiguous
   22 |         if(!next[now]) ans[cnt].push_back(yy[now]),++now;
      |             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:6:31: note:                 'long long int next [200005]'
    6 | ll m,n,yy[200005],loc[200005],next[200005],cnt,fir[200005];
      |                               ^~~~
a.cc:23:18: error: reference to 'next' is ambiguous
   23 |         else now=next[now]+1;
      |                  ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:6:31: note:                 'long long int next [200005]'
    6 | ll m,n,yy[200005],loc[200005],next[200005],cnt,fir[200005];
      |                               ^~~~
Language: C++

#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn=2e5+10;
set<int>s[maxn];
int n,k,a[maxn],b[maxn],cnt,tot;
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),s[a[i]].insert(i);
	int now=1;
	while(b[now]==0)
	{
		b[now]=++cnt;
		set<int>::iterator it=s[a[now]].upper_bound(now);
		if(it!=s[a[now]].end())
		{
			now=*it+1;
			if(now==n+1)now=1,tot++;
		}
		else
		{
			it=s[a[now]].upper_bound(0);
			now=*it+1;
			tot++;
		}
	}
//	printf("%lld\n",tot);
	k%=tot;
	now=1;
	if(k==0)return 0;
	while(k!=1)
	{
		set<int>::iterator it=s[a[now]].upper_bound(now);
		if(it!=s[a[now]].end())
		{
			now=*it+1;
			if(now==n+1)now=1,k--;
		}
		else
		{
			it=s[a[now]].upper_bound(0);
			now=*it+1;
			k--;
		}
//		printf("%lld\n",now);
	}
//	puts("!");
	for(;now<=n;now++)
	{
		set<int>::iterator it=s[a[now]].upper_bound(now);
		while(it!=s[a[now]].end())
		{
			now=*it+1;
			if(now==n+1)
			{
				now=1,k--;
				return 0;
			}
			it=s[a[now]].upper_bound(now);
		}
		printf("%lld ",a[now]);
	}
}
/*
5 10
1 2 3 2 3
*/

Compiler output:
cc1plus: error: '::main' must return 'int'
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;
  long long n;
  long long k;
  cin>>n>>k;
  int a[n];
  REP(i, n) cin>>a[i];
  
  vector<int> prev(20'0010, -1);
  vector<bool> used(n, false);
  cpp_int 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];
      cpp_int mid = i + g[i][j - 1];
      cpp_int temp = g[(int)(mid % n)][j - 1];
      g[i][j] += temp;
    }
  }
  
  cpp_int now = 0;
  cpp_int bd = n * k;
  while(now < bd){
    int i = now % n;
    long long nj = -1;
    for(int j = 0; j <= 60; j++){
      if(now + g[i][j] < bd){
        nj = j;
      }
    }
    if(nj < 0) break;
    now = now + g[i][nj];
  }
  
  vector<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{
        exist[st.top()] = false;
        st.pop();
      }
    }
  }
  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:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
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;
  long long n;
  long long k;
  cin>>n>>k;
  int a[n];
  REP(i, n) cin>>a[i];
  
  vector<int> prev(20'0010, -1);
  vector<bool> used(n, false);
  cpp_int 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];
      cpp_int mid = i + g[i][j - 1];
      cpp_int temp = g[mid % n][j - 1];
      g[i][j] += temp;
    }
  }
  
  cpp_int now = 0;
  cpp_int bd = n * k;
  while(now < bd){
    int i = now % n;
    long long nj = -1;
    for(int j = 0; j <= 60; j++){
      if(now + g[i][j] < bd){
        nj = j;
      }
    }
    if(nj < 0) break;
    now = now + g[i][nj];
  }
  
  vector<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{
        exist[st.top()] = false;
        st.pop();
      }
    }
  }
  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:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
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;
  cpp_int n;
  cpp_int k;
  cin>>n>>k;
  int a[n];
  REP(i, n) cin>>a[i];
  
  vector<int> prev(20'0010, -1);
  vector<bool> used(n, false);
  cpp_int 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];
      cpp_int mid = i + g[i][j - 1];
      cpp_int temp = g[mid % n][j - 1];
      g[i][j] += temp;
    }
  }
  
  cpp_int now = 0;
  while(now < n * k){
    int 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];
  }
  
  vector<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{
        exist[st.top()] = false;
        st.pop();
      }
    }
  }
  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:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (ll i = (n); i >= 0; --i)
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define FORR(i, m, n) for (ll i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  if (n % 2 == 0) {
    bool f = true;
    rep(i, n / 2) {
      if (a[2 * i] != a[2 * i + 1]) {
        f = false;
      }
    }
  }
  if (f) return 0;
  map<ll, ll> mp;
  rep(i, n) mp[a[i]] = -1;
  vector<vector<ll>> dp;
  vector<ll> res(n);
  rep(i, 2 * n) {
    if (mp[a[i % n]] != -1 && mp[a[i % n]] < n) res[mp[a[i % n]]] = i - mp[a[i % n]] + 1;
    mp[a[i % n]] = i;
  }
  dp.push_back(res);
  while (res[0] < n * k) {
    vector<ll> nxt(n, 0);
    rep(i, n) nxt[i] = res[i] + res[(res[i] + i) % n];
    res = nxt;
    dp.push_back(res);
  }
  ll m = dp.size();
  ll pos = 0;
  repr(i, m - 1) {
    if (pos + dp[i][pos % n] < n * k) pos += dp[i][pos % n];
  }
  pos %= n;
  stack<ll> st;
  rep(i, n) mp[a[i]] = 0;
  FOR(i, pos, n) {
    //cout << i << ' ' << mp[a[i]] << '\n';
    if (mp[a[i]] == 1) {
      while (!st.empty() && st.top() != a[i]) {
        mp[st.top()] = 0;
        st.pop();
      }
      mp[a[i]] = 0;
      st.pop();
    }
    else {
      st.push(a[i]);
      mp[a[i]] = 1;
    }
  }
  if (st.empty()) {
    return 0;
  }
  vector<ll> ans;
  while (!st.empty()) {
    ans.push_back(st.top());
    st.pop();
  }
  reverse(ans.begin(), ans.end());
  rep(i, ans.size()) cout << ans[i] << ' ';
  cout << '\n';






  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:7: error: 'f' was not declared in this scope
   41 |   if (f) return 0;
      |       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  ll N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }

  map<int,vector<int>> m;
  for(int i=0;i<N;i++){
    m[A.at(i)].push_back(i);
  }

  int i=0;
  ll loop=0;
  while(true){
    int k=upper_bound(m[A.at(i)].begin(),m[A.at(i)].end(),i)-m[A.at(i)].begin();
    if(k==m[A.at(i)].size()){
      k=m[A.at(i)].at(0);
    }else{
      k=m[A.at(i)].at(k);
    }
    k++;
    k%=N;
    if(k<=i+1){
      loop++;
    }
    i=k;
    if(i==0){
      break;
    }
  }

  if(K==0){
    cout<<endl;
  }else if(&&N==1){
    if(K%2==0){
      cout<<endl;
    }else{
      cout<<A.at(0)<<endl;
    }
  }else{
    K%=loop;
    while(K>1){
      int k=upper_bound(m[A.at(i)].begin(),m[A.at(i)].end(),i)-m[A.at(i)].begin();
      if(k==m[A.at(i)].size()){
        k=m[A.at(i)].at(0);
      }else{
        k=m[A.at(i)].at(k);
      }
      k++;
      k%=N;
      if(k<=i+1){
        K--;
      }
      i=k;
    }

    vector<int> ans;
    while(i<N){
      int k=upper_bound(m[A.at(i)].begin(),m[A.at(i)].end(),i)-m[A.at(i)].begin();
      if(k==m[A.at(i)].size()){
        ans.push_back(A.at(i));
      }else{
        i=m[A.at(i)].at(k);
      }
      i++;
    }
    for(int j=0;j<ans.size();j++){
      cout<<ans.at(j)<<" ";
    }
    cout<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   41 |   }else if(&&N==1){
      |            ~~~^~~
a.cc:41:14: error: label 'N' used but not defined
   41 |   }else if(&&N==1){
      |              ^
Language: C++

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	VI A(N);
	REP(i, N)cin >> A[i];

	vector<VI> a(60, VI(N));
	VI used(200010, -1);
	
	//doubling
	REP(k, 2) {
		REP(i, N) {
			if (used[A[i]] != -1) {
				a[0][used[A[i]] % N] = k * N + i - used[A[i]] + 1;
			}
			used[A[i]] = k * N + i;
		}
	}
	FOR(k, 1, 60) {
		REP(i, N) {
			a[k][i] = a[k - 1][i] + a[k - 1][(a[k - 1][i] + i) % N];
		}
	}

	int sum = 0, now = 0;
	const int C = N * K;
	while (1) {
		int ind = 0;
		REP(k, 60) {
			if (a[k][now] + sum >= C) {
				ind = k - 1;
				break;
			}
		}
		if (ind == -1)break;
		sum += a[ind][now];
		now = sum % N;
	}









	//cout << now << endl;
	//シュミレーションと出力
	stack<int> st;
	map<int, bool>F;
	FOR(i, now, N) {
		if (F[A[i]]) {
			if(!st.empty())hile (st.top() != A[i])st.pop();
			if (!st.empty())st.pop();
			F[A[i]] = false;
		}
		else {
			st.push(A[i]);
			F[A[i]] = true;
		}
		
	}

	VI ans;
	while (!st.empty()) {
		ans.push_back(st.top());
		st.pop();
	}
	reverse(ans.begin(), ans.end());
	REP(i, ans.size())cout << ans[i] << " ";
	cout << endl;


	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:95:40: error: 'hile' was not declared in this scope
   95 |                         if(!st.empty())hile (st.top() != A[i])st.pop();
      |                                        ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
// constexpr ll MOD = 1e9+7;
constexpr ll MOD = 998244353;

ll n,k;
ll a[1<<19];
bool inque[1<<19];
ll table[1<<19][100];
ll pre[1<<19];

void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

void make_table() {

    for (int i = n * 2 - 1; i >= 0; i--) {
        table[i%n][0] = pre[a[i%n]] - i + 1;
        pre[a[i%n]] = i;
    }

    for (int i = 1; i < 66; i++) {
        for (int j = 0; j < n; j++) {
            table[j][i] = table[j][i-1] + table[(table[j][i-1] + j) % n][i-1];
            table[j][i] = min(table[j][i], (1LL << 61));
        }
    }

}

void solve() {
    make_table();
    ll pos = 0;
    ll left = n * k;
    // for (int i = 0; i < 64; i++) {
    //     for (int j = 0; j < n; j++) {
    //         cout << table[j][i] << " ";
    //     }
    //     cout << endl;
    // }
    for (int i = 65; i >= 0; i--) {
        if (left >= table[pos][i]) {
            left -= table[pos][i];
            pos += table[pos][i];
            pos %= n;
        }
    }

    vector<int> v(1 << 19);
    while (left--) {
        if (!inque[a[pos]]) {
            v.push_back = a[pos];
            inque[a[pos]] = 1;
        } else {
            while (inque[a[pos]]) {
                v.pop_back();
                inque[v[v.size() - 1]] = 0;
            }
        }
        pos++;
        pos %= n;
    }

    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << " \n"[i == v.size() - 1];
    }
}

int main(int argc, char *argv[]) {
    input();
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:60:15: error: invalid use of member function 'std::vector<int>::push_back' (did you forget the '()' ?)
   60 |             v.push_back = a[pos];
      |             ~~^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
// constexpr ll MOD = 1e9+7;
constexpr ll MOD = 998244353;

ll n,k;
ll a[1<<19];
bool inque[1<<19];
ll table[1<<19][100];
ll pre[1<<19];

void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
}

void make_table() {

    for (int i = n * 2 - 1; i >= 0; i--) {
        table[i%n][0] = pre[a[i%n]] - i + 1;
        pre[a[i%n]] = i;
    }

    for (int i = 1; i < 66; i++) {
        for (int j = 0; j < n; j++) {
            table[j][i] = table[j][i-1] + table[(table[j][i-1] + j) % n][i-1];
            table[j][i] = min(table[j][i], (1LL << 61));
        }
    }

}

void solve() {
    make_table();
    ll pos = 0;
    ll left = n * k;
    // for (int i = 0; i < 64; i++) {
    //     for (int j = 0; j < n; j++) {
    //         cout << table[j][i] << " ";
    //     }
    //     cout << endl;
    // }
    for (int i = 65; i >= 0; i--) {
        if (left >= table[pos][i]) {
            left -= table[pos][i];
            pos += table[pos][i];
            pos %= n;
        }
    }

    vector<int> v(1 << 19);
    while (left--) {
        if (!inque[a[pos]]) {
            v.push_back = a[pos];
            inque[a[pos]] = 1;
        } else {
            while (inque[a[pos]]) {
                v.pop_back();
                inque[v[v.size() - 1]] = 0;
            }
        }
        pos++;
        pos %= n;
    }

    for (int i = 0; i < pp; i++) {
        cout << dq[i] << " \n"[i == pp - 1];
    }
}

int main(int argc, char *argv[]) {
    input();
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:60:15: error: invalid use of member function 'std::vector<int>::push_back' (did you forget the '()' ?)
   60 |             v.push_back = a[pos];
      |             ~~^~~~~~~~~
a.cc:72:25: error: 'pp' was not declared in this scope
   72 |     for (int i = 0; i < pp; i++) {
      |                         ^~
a.cc:73:17: error: 'dq' was not declared in this scope
   73 |         cout << dq[i] << " \n"[i == pp - 1];
      |                 ^~
Language: C++

#define MOD 1000000007
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;
    int A[N];
    unordered_map<int, vector<int>> d;
    for (int i = 0; i < N; i++) {
        cin >> A[i]
        d[A[i]].push_back(i);
    }
    ll a = K - 1, b = 0;
    unordered_set<int> s;
    while (a) {
        if (b == N) {
            a--;
            b = 0;
            continue;
        }
        if (s.count(b)) {
            a %= (K - 1 - a);
            break;
        }
        else s.insert(b);
        vector<int> l = d[A[b]];
        int i = *upper_bound(l.begin(), l.end(), b);
        if (i) b = i + 1;
        else {
            a--;
            b = 1 + *l.begin();
        }
    }
    while (a) {
        if (b == N) {
            a--;
            b = 0;
            continue;
        }
        vector<int> l = d[A[b]];
        int i = *upper_bound(l.begin(), l.end(), b);
        if (i) b = i + 1;
        else {
            a--;
            b = 1 + *l.begin();
        }
    }
    vector<int> ans;
    while (b < N) {
        vector<int> l = d[A[b]];
        int i = *upper_bound(l.begin(), l.end(), b);
        if (i) b = i + 1;
        else {
            ans.push_back(A[b]);
            b++;
        }
    }
    if (ans.size()) {
        cout << ans[0];
        for (int i = 1; i < ans.size(); i++) cout << " " << ans[i];
        cout << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:20: error: expected ';' before 'd'
   12 |         cin >> A[i]
      |                    ^
      |                    ;
   13 |         d[A[i]].push_back(i);
      |         ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pi;

#define fi first
#define se second

ll read() {
  ll res = 0, w = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

const int N = 2e5 + 10;

int st[N], p[N], a[N], nxt[N], las[N], x[N], n, pos, top;
ll k;

int main() {
  n = read(), k = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    nxt[las[a[i]]] = i;
    las[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    nxt[las[a[i]]] = i;
    las[a[i]] = i;
  }
  for (int i = 1; i < n; i++) x[i] = i + 1;
  x[n] = 1;
  st[++top] = 1, p[top] = 1, pos = 1;
  do {
    ++top, p[top] = p[top - 1] + (nxt[pos] <= pos) + (nxt[pos] == n);
    st[top] = pos = x[nxt[pos]];
  } while (st[top] != st[1]);
  k -= (k - 1) / (p[top] - 1) * (p[top] - 1);
  R int j = 1;
  while (j <= top - 1 && p[j + 1] <= k) ++j;
  for (int i = st[j]; i <= n; ++i) {
    if (nxt[i] > i)
      i = nxt[i];
    else
      printf("%d ", a[i]);
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:3: error: 'R' was not declared in this scope
   45 |   R int j = 1;
      |   ^
a.cc:46:10: error: 'j' was not declared in this scope
   46 |   while (j <= top - 1 && p[j + 1] <= k) ++j;
      |          ^
a.cc:47:19: error: 'j' was not declared in this scope
   47 |   for (int i = st[j]; i <= n; ++i) {
      |                   ^
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
set<int> pl[214514];
set<ll> fp[214514];
ll dp[214514][62];
int n;
ll gbis_special(ll cur, ll lim){
	if( cur + dp[ (cur%n) ][0] > lim) return cur;
	ll cnt = 0;
	while( cur + dp[ (cur%n) ][cnt+1] <= lim){
		cnt++;
	}
	cur += dp[ (cur%n) ][cnt];
	return gbis_special(cur,lim);
}
int main(){
	ll k;
	cin>>n>>k;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
		pl[x].insert(i);
	}
	for(int i=0;i<n;i++){
		int cur = a[i];
		set<int>::iterator it = pl[cur].upper_bound(i);
		if( it == pl[cur].end() ){
			it = pl[cur].upper_bound(-1);
			dp[i][0] = *it + n - i + 1;
		}
		else{
			dp[i][0] = *it - i + 1;
		}
	}
	for(int j=1;j<=61;j++){
		for(int i=0;i<n;i++){
			dp[i][j] = dp[i][j-1] + dp[ (i+dp[i][j-1])%n ][j-1];
		}
	}
	ll stt = gbis_special(0,n*k-1);
	vector<ll> final;
	for(ll i=stt;i<=n*k-1;i++){
		final.pb(a[i%n]);
		fp[a[i%n]].insert(i);
	}
	ll idx = stt;
	vector<ll> ans;
	while(idx <= n*k-1){
		ll sa = idx-stt;
		if(sa>=0)ll cur = final[sa];
		set<ll>::iterator it = fp[cur].upper_bound(idx);
		if( it == fp[cur].end() ){
			ans.pb(cur);
			idx++;
		}
		else{
			idx = *it;
			idx++;
		}
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:43: error: 'cur' was not declared in this scope
   57 |                 set<ll>::iterator it = fp[cur].upper_bound(idx);
      |                                           ^~~
Language: C++

#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
using namespace std;
using i64 = int64_t;
i64 n, k;
vector<i64> a;
int main() {
    cin >> n >> k;
    a.assign(n, 0);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector<vector<i64>> nexts(n + 1, vector<i64>(50));
    map<i64, i64> fwds;
    for (i64 i = 0; i < n; ++i) {
        if (fwds.count(a[i]) == 0) {
            fwds[a[i]] = i + 1;
        }
    }
    for (i64 i = n - 1; i >= 0; --i) {
        nexts[i][0] = fwds[a[i]];
        fwds[a[i]] = i<n-1&&a[i]==a[i+1]?next[i+2][0]:nexts[i + 1][0];
    }
    for (i64 e = 1; e < 50; ++e) {
        for (i64 i = 0; i < n; ++i) {
            i64 j = nexts[i][e - 1];
            nexts[i][e] = nexts[j][e - 1];
        }
    }
    i64 p = 0;
    for (i64 e = 0; e < 50; ++e) {
        if ((k - 1) & (1ll << e)) {
            p = nexts[p][e];
        }
    }
    vector<i64> stk;
    map<i64, i64> ins;
    for (i64 i = p; i < n; ++i) {
        cerr << a[i] << '\t' << ins[a[i]] << endl;
        if (ins[a[i]] > 0) {
            while (true) {
                assert(!stk.empty());
                i64 x = stk.back();
                ins[x]--;
                stk.pop_back();
                if (x == a[i]) break;
            }
        } else {
            stk.push_back(a[i]);
            ins[a[i]]++;
        }
    }
    for (i64 x : stk) cout << x << ' ';
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:46: error: invalid types '<unresolved overloaded function type>[i64 {aka long int}]' for array subscript
   30 |         fwds[a[i]] = i<n-1&&a[i]==a[i+1]?next[i+2][0]:nexts[i + 1][0];
      |                                              ^
Language: C++

#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;
typedef long long ll;
int n,a[N],L[N],R[N],nxt[N];
ll K;
bool vis[N];
int dis(int x,int y){
	return y>x+1?y-x:y+n-x;
}
int ans[N];
void sim(int pos,int res){
	memset(L,0,sizeof(L));
	int len=0;
	for(int i=1;i<=res;i++,pos=pos==n?1:pos+1){
		if(L[a[pos]]){
			len=L[a[pos]]-1;
			L[a[pos]]=0;
			continue;
		}
		ans[++len]=a[pos];
		L[a[pos]]=len;
	}
	for(int i=1;i<=len;i++) printf("%d ",ans[i]);
}
int main(){
	scanf("%d%lld",&n,&K);
	K*=n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) if(!L[a[i]]) L[a[i]]=i;
	for(int i=n;i;i--){
		if(R[a[i]]) nxt[i]=R[a[i]]+1<=n?R[a[i]]+1:1;
		else nxt[i]=L[a[i]]+1<=n?L[a[i]]+1:1;
		R[a[i]]=i;
	}
	int x=1;
	while(!vis[x]){
		vis[x]=1;
		if(K<=n){
			sim(x,K);
			return 0;
		}
		K-=dis(x,nxt[x]);
		x=nxt[x];
	}
	ll sum=0;
	memset(vis,0,sizeof(vis));
	while(!vis[x]){
		vis[x]=1;
		sum+=dis(x,nxt[x]);
		x=nxt[x];
	}
	K%=sum;
	while(K>=dis(x,nxt[x])){
		K-=dis(x,nxt[x]);
		x=nxt[x];
	}
	sim(x,K);
	return 0;
}


Compiler output:
a.cc: In function 'void sim(int, int)':
a.cc:14:9: error: 'memset' was not declared in this scope
   14 |         memset(L,0,sizeof(L));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdio>
  +++ |+#include <cstring>
    3 | #define N 200005
a.cc: In function 'int main()':
a.cc:48:9: error: 'memset' was not declared in this scope
   48 |         memset(vis,0,sizeof(vis));
      |         ^~~~~~
a.cc:48:9: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os](T value) {
    os << value;
    if (value != vc.back())
      os << ' ';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  ui  N{}; std::cin >> N;
  ull K{}; std::cin >> K;

  typedef std::vector<ui> Vector;
  Vector A(N);
  std::map<ui, Vector> idx;
  rep(0, N)
  {
    std::cin >> A[i];
    idx[A[i]].push_back(i); // 出現位置
  }

  ui LOG_K = (ui)log2(K);
  ui LOG_N = (ui)log2(N);
  assert(LOG_K + LOG_N < 58); // 制約チェック

  typedef std::vector<ull> Vector_ull;
  std::vector<Vector_ull> dp(LOG_K + LOG_N + 1, Vector_ull(N));
  for (auto p : idx)
  {
    ui sz = p.second.size();
    p.second.push_back(p.second[0] + N);
    rep(0, sz)
    {
      dp[0][p.second[i]] = p.second[i + 1] - p.second[i] + 1; // 移動距離
    }
  }

  rep(1, dp.size())
  {
    rep_uj(0, N)
    {
      dp[i][j] = std::min(
        std::numeric_limits<ull>::max() / 3,
        dp[i - 1][j] + dp[i - 1][(dp[i - 1][j] + j) % N]);
    }
  }

  ull it{ 0 };
  ull it_max = K * N - 1;
  for(ui i = dp.size() - 1;;)
  {
    if (it + dp[i][it % N] <= it_max)
    {
      it += dp[i][it % N];
    }
    if(!i--)
      break;
  }
  assert(it <= it_max);

  Vector ans;
  ans.reserve(N);

  it %= N;
  std::set<ui> dic;
  while(it < N)
  {
    if (dic.count(A[it]))
    {
      while (true)
      {
        ui last = ans.back();
        ans.pop_back();
        dic.erase(last);
        if (last == A[it])
          break;
      }
    }
    else
    {
      ans.push_back(A[it]);
      dic.insert(A[it]);
    }
    ++it;
  }

  std::cout << ans << "\n";

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Compiler output:
a.cc:2:10: fatal error: boost/range/algorithm.hpp: No such file or directory
    2 | #include <boost/range/algorithm.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os](T value) {
    os << value << " ";
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << " " << p.second << " ";
}

void solve(void)
{
  ui  N{}; std::cin >> N;
  ull K{}; std::cin >> K;

  typedef std::vector<ui> Vector;
  Vector A(N);
  std::map<ui, Vector> idx;
  rep(0, N)
  {
    std::cin >> A[i];
    idx[A[i]].push_back(i); // 出現位置
  }

  ui LOG_K = (ui)log2(K);
  ui LOG_N = (ui)log2(N);
  assert(LOG_K + LOG_N < 58); // 制約チェック

  typedef std::vector<ull> Vector_ull;
  std::vector<Vector_ull> dp(LOG_K + LOG_N + 1, Vector_ull(N));
  for (auto p : idx)
  {
    ui sz = p.second.size();
    p.second.push_back(p.second[0] + N);
    rep(0, sz)
    {
      dp[0][p.second[i]] = p.second[i + 1] - p.second[i] + 1; // 移動距離
    }
  }

  rep(1, dp.size())
  {
    rep_uj(0, N)
    {
      dp[i][j] = std::min(
        std::numeric_limits<unsigned long long>::max() / 3,
        dp[i - 1][j] + dp[i - 1][(dp[i - 1][j] + j) % N]);
    }
  }

  ull it{ 0 };
  ull it_max = K * N - 1;
  for(ui i = dp.size() - 1;;)
  {
    if (it + dp[i][it % N] <= it_max)
    {
      it += dp[i][it % N];
    }
    if(!i--)
      break;
  }
  assert(it <= it_max);

  Vector ans;
  ans.reserve(N);

  it %= N;
  std::set<ui> dic;
  while(it < N)
  {
    if (dic.count(A[it]))
    {
      while (true)
      {
        ui last = ans.back();
        ans.pop_back();
        dic.erase(last);
        if (last == A[it])
          break;
      }
    }
    else
    {
      ans.push_back(A[it]);
      dic.insert(A[it]);
    }
    ++it;
  }

  std::cout << ans << "\n";

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Compiler output:
a.cc:2:10: fatal error: boost/range/algorithm.hpp: No such file or directory
    2 | #include <boost/range/algorithm.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.