Language: C++

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <array>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint iy = Mint(1);
    Mint one = Mint(1);
    // 割り算の演算は時間がかかるので最後に1度だけ行うようにすること
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      iy *= (i + one);
    }
    return y / iy;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

class UnionFind {
private:
  int n;
  std::vector<int > parent;
public:
  UnionFind(int num) :
    n(num) {
      parent = std::vector<int> (n);
      for (int i=0; i<n; i++) {
        parent[i] = i;
      }
    }
  int GetRoot(int i) {
    int n = i;
    while(parent[n]!=n) {
      n = parent[n];
    }
    parent[i] = n;
    return n;
  }

  bool SameGroup(int n, int m) {
    n = this->GetRoot(n);
    m = this->GetRoot(m);
    return n==m;
  }

  bool Unite(int n, int m) {
    n = this->GetRoot(n);
    m = this->GetRoot(m);
    if (n==m) return false;
    parent[n] = m;
    return true;
  }
};

int getgcd(int a, int b) {
  int max = std::max(a, b);
  int min = std::min(a, b);
  if (min==0) return max;
  return getgcd(min, max%min);
}

Mint mynCk(int n, int k) {
  if (2*k>n) return mynCk(n, n-k);
  Mint retval(1);
  Mint iretval(1);
  for (int i=0; i<k; i++) {
    retval *= Mint(n-i);
  }
  for (int i=1; i<=k; i++) {
    iretval *= Mint(i);
  }
  return retval / iretval;
}
long long doubling[58][200004];

int main() {
  int N;
  std::cin >> N;
  long long K;
  std::cin >> K;
  std::vector<int > A(N);
  std::vector<int > parent(N+4, -1);
  std::vector<int > pos(200004, -1);
  std::vector<int> AA(2*N);
  for (int i=0; i<N; i++) {
    std::cin >> A[i];
    AA[i] = A[i];
    AA[i+N] = A[i];
  }
  // printf("read end\n");
  for (int i=0; i<2*N; i++) {
    // printf("i=%d\n", i);
    if (pos[AA[i]] != -1) {
      if (pos[AA[i]]<N) parent[pos[AA[i]]] = i;
    }
    pos[AA[i]] = i;
  }
  for (int i=0; i<N; i++) {
    doubling[0][i] = parent[i] + 1 - i;
    // printf("doubling[0][%d]=%lld\n", i, doubling[0][i]);
  }
  for (int i=1; i<58; i++) {
    for (int j=0; j<N; j++) {
      long long dst = doubling[i-1][j] + j;
      long long step = doubling[i-1][dst%N];
      doubling[i][j] = doubling[i-1][j] + step; 
    }
  }
  long long sum = 0;
  int now = 0;
  for (int i=58-1; i>=0; i--) {
    // printf("doubling[%d][%d]=%lld\n", i, now, doubling[i][now]);
    if (sum + doubling[i][now] <= K * N) {
      sum += doubling[i][now];
      now = (now + doubling[i][now]) % N;
      // printf("i=%d, now=%d, sum=%lld\n", i, now, sum);
    }
  }
  // printf("sum=%lld\n", sum);
  long long remain = K*(long long )N - sum;
  now = sum % N;
  std::vector<int > ans;
  std::map<int, int> mp;
  // printf("now=%d, remain=%lld\n", now, remain);
  for (long long i=0; i<remain; i++) {
    //int pos = (now + i) % N;
    mp[1]=1;
    //if (mp[A[pos]]==1) {
    /*if (mp[1]==1) {
      /*while(ans[ans.size()-1]!=A[pos]) {
        mp[ans[ans.size()-1]] = 0;
        ans.pop_back();
      }
      mp[ans[ans.size()-1]] = 0;
      ans.pop_back();*/
    } else {
      //ans.push_back(A[pos]);
      //mp[A[pos]]=1;
    }*/
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:229:7: error: 'else' without a previous 'if'
  229 |     } else {
      |       ^~~~
a.cc:232:7: error: expected primary-expression before '/' token
  232 |     }*/
      |       ^
a.cc:233:3: error: expected primary-expression before '}' token
  233 |   }
      |   ^
a.cc: At global scope:
a.cc:234:3: error: expected unqualified-id before 'return'
  234 |   return 0;
      |   ^~~~~~
a.cc:235:1: error: expected declaration before '}' token
  235 | }
      | ^