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

n,x,m=map(int,input().split())
id=[-1 for i in range(m+1)]
s=[]
c=0
while id[x]==-1:
    id[x]=c
    c+=1
    s.append(x)
    x=x*x%m
d=c-id[x]
ans=0
if n<=d:
    for i in range(n):
        ans+=s[i]
else:
    for i in range(id[x]):
        ans+=s[i]
    n-=id[x]
    sum=0
    for i in range(d):
        sum+=s[id[x]+i]
    ans+=(n//d)*sum
    n=n%d
    for i in range(n):
        ans+=s[id[x]+i]
print(ans)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,x,m=map(int,input().split())
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll n, x, m;
    cin >> n >> x >> m;

    VL r(m);
    deque<ll> dq;
    rep(i,n) {
        r[x]++;
        dq.push_back(x);
        x *= x;
        x %= m;

        // 巡回検出
        if (r[x] != 0) break;
    }

    // 残りの数
    n -= dq.size();

    if (n != 0){
        // ループサイズ
        // while(dq.front() != x) dq.pop_front();
        // ll loop_sz = dq.size();

        // 何回ループするかを計算し、ループする数に対して加算する
        ll nq = n / loop_sz;
        while(!dq.empty()){
            ll y = dq.front(); dq.pop_front();
            r[y] += nq;
        }

        // 残りは普通に計算する
        ll nr = n % loop_sz;
        while(nr--){
            r[x]++;
            x *= x;
            x %= m;
        }
    }

    ll ans = 0;
    rep(i,m) ans += (ll)i * r[i];
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:21: error: 'loop_sz' was not declared in this scope
   43 |         ll nq = n / loop_sz;
      |                     ^~~~~~~
Language: C++

#include<iostream>
#include<vector>
#define ll long long
using namespace std;

int main() {
	long long n;
	ll X, MOD;
	cin >> n >> X >> MOD;
	vector<ll> v(MOD + 1);
	vector<int> seen(MOD + 1);
	v[1] = X;
	seen[X] = 1;
	long long ans = v[1];
	for (ll i = 2; i <= n; i++) {
		ll x = ((1LL * v[i - 1] % MOD) * (v[i - 1] % MOD)) % MOD;
		if (x == 0)
			break;
		if (x == 1) {
			ans += (n - i + 1);
			break;
		}
		if (seen[x]) {
			ll sz = i - seen[x];
			ll t = 0;
			for (int j = seen[x]; j < i; j++) {
				t += v[j];
			}
			ans += ((n - i + 1) / sz) * t;
			ll rem = (n - i + 1) % sz;
			assert(rem < MOD);
			for (int j = seen[x]; j < seen[x] + rem; j++) {
				ans += v[j];
			}
			break;
		}
		else {
			v[i] = x;
			seen[x] = i;
			ans += v[i];
		}
	}
	cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:25: error: 'assert' was not declared in this scope
   31 |                         assert(rem < MOD);
      |                         ^~~~~~
a.cc:3:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    2 | #include<vector>
  +++ |+#include <cassert>
    3 | #define ll long long
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;

int main() {
	ll N; cin >> N;
	ll X; cin >> X;
	ll M; cin >> M;
	ll FSum=X;
	int cnt=1;
	while(X*X<M){
		X=X*X;
		FSum+=X;
		cnt++;
	}
	ll LSum=0;
	vector<int> m;
	REP(i,N-cnt){
		X=X*X%M;
		m.push_back(X);
		if ((i!=0) &&(m.back()==m.at(0))){
			(N-cnt/i)*LSum
		}else{
			LSum+=X;
		}
	}
	cout << FSum+LSum << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:39: error: expected ';' before '}' token
   23 |                         (N-cnt/i)*LSum
      |                                       ^
      |                                       ;
   24 |                 }else{
      |                 ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 998244353
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

const int dx8[] = {-1, 0, 1, 0,1,1,-1,-1};
const int dy8[] = {0, -1, 0, 1,1,-1,1,-1};


unordered_map<ll,ll> m1 ;
void solve()
{
    m1.clear();
 ll n,x,m ;
 cin >> n >> x >> m;
 vector<ll>arr1;
 vector<ll>arr2 ;
 arr1.pb(x);
 arr2.pb(x);
 m1[x]=0;
  for(ll i =1 ;i<n;i++)
 {
     arr1.pb(0);
     arr2.pb(0);
  arr1[i]=(arr1[i-1]*arr1[i-1])%m;
  arr2[i]=arr2[i-1]+arr1[i];
     if(m1.count(arr1[i])!=0)
     {
        // cout <<"hello" << endl;
         ll len= i-m1[arr1[i]];
         ll sum = arr2[i]-arr2[m1[arr1[i]]];
         ll rem= n-i;
         ll ans=0 ;
         ans= arr2[i-1]+ (rem/len)*sum;
         ll a = m1[arr1[i]] ;
         ll b = a+ (rem%len) -1 ;
         ll temp= a-1>=0?arr2[a-1]:0;
         ans+=  arr2[y]-temp;
         cout << ans<< endl;

         return ;
     }
     m1[arr1[i]]=i;
 }


 cout << arr2[n-1]<< endl;

}



int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:55:22: error: 'y' was not declared in this scope
   55 |          ans+=  arr2[y]-temp;
      |                      ^
Language: C++

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N, X, M; cin >> N >> X >> M;
	vector<ll> his;

	std::cout << "pas"<< std::endl;
	ll res{0};
	ll m{-1};
	REP(i, N)
	{
		if (is[X])
		{
			m = X;
			break;
		}
		else
			is[X] = true;
		res += X;
		his.push_back(X);
		(X *= X) %= M;
	}

	if (m == -1)
	{
		std::cout << res << std::endl;
		return 0;
	}

	vector<ll> hiss;
	ll it = find(ALL(his), m) - his.begin();
	for (ll i = it; i < his.size(); ++i)
	{
		hiss.push_back(his[i]);
		DEBUG(his[i]);
	}

	ll rem = N - it;
	DEBUG(rem);
	ll sum = accumulate(ALL(hiss), 0ll);
	DEBUG(sum);
	ll cs = hiss.size();
	DEBUG(cs);
	res += sum * (rem/cs -1);
	res += accumulate(hiss.begin(), hiss.begin()+(rem%cs), 0ll);
	
	std::cout << res << std::endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:31:21: error: 'is' was not declared in this scope; did you mean 'i'?
   31 |                 if (is[X])
      |                     ^~
      |                     i
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using pii = pair<int,int>;
using pll = pair<long,long>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back

vll rem(1e5+5,0),vec(1e5+5,0);

int main() {
  ll n,x,m,first=0,period=0;
  cin>>n>>x>>m;
  ll sum=0,ans=0;

  for(ll i=1;i<=m-1;i++) {
    rem[i]=x;
    if(vec[x]!=0) {
      first=vec[x];
      period=i-first;
    }
    vec[x]=i;
    x*=x;
    x%=m;
  }
  if(first!=0) {
    for(ll i=first;i<=first+period-1;i++) sum+=rem[i];
  } else {
    for(ll i=1;i<=m-1;i++) sum+=rem[i];
    ans+=sum*(n/period);
    n%=period;
    for(ll i=1;i<=n;i++) ans+=rem[i];
    cout<<ans<<endl;
    break;
  }

  if(n<=first) {
    for(ll i=1;i<=n;i++) ans+=rem[i];
  } else {
    for(ll i=1;i<=first-1;i++) ans+=rem[i];
    n-=first-1;
    ans+=sum*(n/period);
    n%=period;
    for(ll i=first;i<=first+n-1;i++) ans+=rem[i];
  }

  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: break statement not within loop or switch
   37 |     break;
      |     ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    long long N, X, M;
    cin >> N >> X >> M;

    vector<long long> b, l;
    vector<bool> is_appeared(M, false);
    REP(i, N){
        if(is_appeared[X]) break;
        is_appeared[X] = true;
        b.push_back(X);
        X *= X;
        X %= M;
    }
    while(!b.empty()){
        int tmp = b.back();
        b.pop_back();
        l.push_back(tmp);
        if(tmp == X) break;
    }
    reverse(l.begin(), l.end());

    long long ans = 0;
    for(auto v: b) ans += b;
    if((long long) b.size() < N){
        N -= (long long) b.size();
        long long s = 0;
        for(auto v: l) s += v;
        long long len = l.size();
        ans += s * (N/len);
        for(int i = 0; i < N%len; ++i) ans += l[i];
    }
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:24: error: no match for 'operator+=' (operand types are 'long long int' and 'std::vector<long long int>')
   34 |     for(auto v: b) ans += b;
      |                    ~~~~^~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    long long N, X, M;
    cin >> N >> X >> M;

    vector<long long> b, l;
    vector<bool> is_appeared(M, false);
    REP(i, N){
        if(is_appeared[X]) break;
        is_appeared[X] = true;
        b.push_back(X);
        X *= X;
        X %= M;
    }
    while(!b.empty()){
        int tmp = b.back();
        b.pop_back();
        l.push_back(tmp);
        if(tmp == X) break;
    }
    reverse(l.begin(), l.end());

    long long ans = 0
    for(auto v: b) ans += b;
    if((long long) b.size() < N){
        N -= (long long) b.size();
        long long s = 0;
        for(auto v: l) s += v;
        long long len = l.size();
        ans += s * (N/len);
        for(int i = 0; i < N%len; ++i) ans += l[i];
    }
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:5: error: expected ',' or ';' before 'for'
   34 |     for(auto v: b) ans += b;
      |     ^~~
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for ( int i=0; i< (n); ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int func( int x, int m ){
    return (x*x)%m;
}

int main(){
    ll n;
    ll x,m;
    cin >> n >> x >> m;
    vector<int> a(0), id(m,-1);
    ll ai = func(x%m,m);
    int len = 0;
    ll tot = 0;
    while( id[x] == -1 ){
        a.push_back(x);
        id[x] = len;
        ++len;
        tot += x;
        x = func(x,m);
    }
    int c = len - id[x];
    ll s = 0;
    for( int i = id[x]; i<len; ++i ) s = a[i]; // one loop sum
    ll ans = 0;
    if( n <= len ){ // consider sum end in non-periodic part
        rep(i,n) ans += a[i];
    }else{
        ans += tot; // non-periodic + first loop
        n -= len;
        ans += s*(n/c);
        n %= c;
        rep(i,n) ans += a[ id[x] + i ] // end  on the way of loop
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:39: error: expected ';' before '}' token
   37 |         rep(i,n) ans += a[ id[x] + i ] // end  on the way of loop
      |                                       ^
      |                                       ;
   38 |     }
      |     ~
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  ll n, x, m; cin >> n >> x >> m;
  map<int,int> mp;
  Vi a;
  int count = 0;
  ll sum = 0;
  while(mp.count(x) == 0) {
    a.push_back(x);
    sum += x;
    mp[x] = count;
    ++count;
    x = (ll) x * x % m;
  }
  dump(mp);
  dump(a,count,sum,x);
  if (n <= count) plexit(sum)
  ll c = 0;
  int s = count - mp[x];
  for (int i = mp[x]; i < count; ++i) c += a[i];
  ll ans = sum;
  n -= count;
  ans += n/s*c;
  dump(sum,ans,n,s,c);
  n %= s;
  int si = mp[x];
  rep(i,n) ans += a[si+i];
  pl(ans)
  return 0;
}


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

#include<iostream>
using namespace std;
int main()
{
    long long int N, X, M, Amod, sum1 = 0, ans, a = 0, A, r;
    cin >> N >> X >> M;
    long long int A[N], sum[N], kakunin[M];
    A[0] = X;
    sum[0] = X;
    for(int i = 0; i < M; i++)  kakunin[i] = 0; //初期化
    long long int n = (N < 2 * M) ? N : 2 * M;
    for(int i = 1; i < n; i++){
        Amod = A[i-1] % M;
        A[i] = (Amod * Amod) % M;
        sum[i] = sum[i-1] + A[i];//A[i]までの和
        ans = sum[i];
        if(kakunin[A[i]] == 0){
            kakunin[A[i]] += 1;
        }
        else if(kakunin[A[i]] == 1){
            sum1 += A[i];//sum1は循環部分の和
            kakunin[A[i]] += 1;
            a += 1;//循環部分の項数
        }
        else{
            A =  (N - i) / a;//循環部分の個数
            r = (N - i) % a;//循環終了後のあまりの項数
            ans = sum[i] + A * sum1 + sum[i-a+r] - sum[i-a];
            break;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:19: error: conflicting declaration 'long long int A [N]'
    7 |     long long int A[N], sum[N], kakunin[M];
      |                   ^
a.cc:5:56: note: previous declaration as 'long long int A'
    5 |     long long int N, X, M, Amod, sum1 = 0, ans, a = 0, A, r;
      |                                                        ^
a.cc:8:6: error: invalid types 'long long int[int]' for array subscript
    8 |     A[0] = X;
      |      ^
a.cc:13:17: error: invalid types 'long long int[int]' for array subscript
   13 |         Amod = A[i-1] % M;
      |                 ^
a.cc:14:10: error: invalid types 'long long int[int]' for array subscript
   14 |         A[i] = (Amod * Amod) % M;
      |          ^
a.cc:15:30: error: invalid types 'long long int[int]' for array subscript
   15 |         sum[i] = sum[i-1] + A[i];//A[i]までの和
      |                              ^
a.cc:17:21: error: invalid types 'long long int[int]' for array subscript
   17 |         if(kakunin[A[i]] == 0){
      |                     ^
a.cc:18:22: error: invalid types 'long long int[int]' for array subscript
   18 |             kakunin[A[i]] += 1;
      |                      ^
a.cc:20:26: error: invalid types 'long long int[int]' for array subscript
   20 |         else if(kakunin[A[i]] == 1){
      |                          ^
a.cc:21:22: error: invalid types 'long long int[int]' for array subscript
   21 |             sum1 += A[i];//sum1は循環部分の和
      |                      ^
a.cc:22:22: error: invalid types 'long long int[int]' for array subscript
   22 |             kakunin[A[i]] += 1;
      |                      ^
Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll N, X, M;
ll S[100005];

int main() {
  INCANT;
  cin >> N >> X >> M;
  ll idx=0ll;
  ll cur = X;
  ll sz = 1;
  vector<ll> A;
  fill(S, S+M+2, -1ll);
  S[X] = 0ll;
  A.push_back(X);
  while(idx<min(M+3, N)) {
    ll n = pow(cur,2ll);
    n%=M;
    if (n==0ll) {
      cur=0ll;
      break;
    }
    if (S[n]>=0ll) {
      start = S[n];
      sz = idx - start +1;
      break;
    }
    idx++;
    S[n]=idx;
    A.push_back(n);
    cur=n;
  }
  ll ret = 0ll;
  if (cur==0 || idx==N-1) {
    rep(i, idx+1) ret+=A[i];
    cout << ret << endl;
    return 0;
  }
  rep(i, sz) {
    if (i+start>=A.size()) break;
    ret+=A[i+start];
  }
  
  ll cir = (N-start)/sz;
  ret*=cir;
  rep(i, start) ret+=A[i];
  rep(i, (N-start)%sz) {
    ret+=A[i+start];
  }
  cout << ret << "\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:7: error: 'start' was not declared in this scope
   40 |       start = S[n];
      |       ^~~~~
a.cc:56:11: error: 'start' was not declared in this scope
   56 |     if (i+start>=A.size()) break;
      |           ^~~~~
a.cc:57:14: error: 'start' was not declared in this scope
   57 |     ret+=A[i+start];
      |              ^~~~~
a.cc:60:15: error: 'start' was not declared in this scope
   60 |   ll cir = (N-start)/sz;
      |               ^~~~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define mod 998244353
typedef long long ll;
#define NMAX 10000000001
int main()
{
    ll n, x, m;
    vector<bool> memo(NMAX, false);
    cin >> n >> x >> m;
    ll ans = 0;
    ll a1 = 0;
    ll a2 = 0;

    a1 = x; 
    memo[a1] = true;
    int p = -1;
    int l = -1;
    ans = a1;
    int length = 1;

    while(1){
        a2 = a1 * a1 % m;
        if(memo[a2]) {
            p = a2;
            l = a1;
            break;
        }
        length++;
        memo[a2] =true;
        ans += a2;
        a1 = a2;
        if(n == length) { cout << ans << endl; return 0;}
    }

    ll cnt = 0;
    vector<int> value(0);
    a1 = p;
    value.push_back(a1);
    ll nowans = a1;
    while(1){
        a2 = a1 * a1 % m;
        if(a2 == l) break;
        value.push_back(a2);
        nowans+= a2;
    }

    ans += nowans * ((n-length) / value.size());a
    for(int i=0; i<(n-length) % value.size(); i++)
        ans += value[i];

    cout << ans << endl;
    return 0;
    
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:49: error: 'a' was not declared in this scope
   50 |     ans += nowans * ((n-length) / value.size());a
      |                                                 ^
a.cc:51:18: error: 'i' was not declared in this scope
   51 |     for(int i=0; i<(n-length) % value.size(); i++)
      |                  ^
Language: C++

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

int main() {
    long long int N, X, M, ans=0, a=0, b=0, z=0;
    cin >> N >> X >> M;
    vector<long long int> history(M,0), when(M,-1), log(M,-1);
    for (long long int i = 0; i < min(M, N); i++) {
        if (history[X] == 1) {
            a = when[X];
            b = i;
            break;
        }
        history[X] = 1;
        log[i] = X;
        when[X] = i;
        X = (X*X) % M;
    }
    if ((b!= 0)) {
        for (int i = 0; i < a; i++) {
            ans += log[i];
        }
        for (int i = a; i < b; i++) {
            z = (N-a) / (b-a);
            ans += z*log[i];
            // if (i-a < (N-a) % (b-a)) {
            //     ans += log[i];
            // }
        }
        // for (int i = a; i < N-(z*(b-a)); i++) {
        //     ans += log[i];
        // }
    }
    for (int i = a; i < N-(z*(b-a)); i++) {
        ans += log[i];
    }
    }


    cout << ans << endl;
}

Compiler output:
a.cc:40:5: error: 'cout' does not name a type
   40 |     cout << ans << endl;
      |     ^~~~
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
  long long N;
  long X,M,A;
  std::cin>>N>>X>>M;
  A = X;
  long long count = X;
  std::vector<int> vec{X};
  std::vector<int>::iterator itr;
  int a = 2;
  long long index = 0;
  for(; a <= N; a++)
  {
    X = (X * X) % M;
    vec.push_back(X);
    itr = std::find(vec.begin(), vec.end(), X);
    if(itr != vec.end())
    {
      index = std::distance(vec.begin(), itr);
      break;
    }
    count += X;
  }
  long XXX = A;
  long long counttt = AA;
  for(int c = 2; c <= index; c++)
  {
    XXX = (XXX * XXX) % M;
    counttt += XXX;
  }
  int b = (N-a+1)%(a-index-1);
  count = counttt + (count - counttt) * ((N-index)/(a-index-1));
  if(b == 0);
  else if(b >= 1)
  {
    count += X;
    for(int c = 2;c <= b; c++)
    {
      X = (X*X)%M;
      count += X;
    }
  }
  std::cout<<count;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: warning: narrowing conversion of 'X' from 'long int' to 'int' [-Wnarrowing]
   11 |   std::vector<int> vec{X};
      |                        ^
a.cc:11:24: warning: narrowing conversion of 'X' from 'long int' to 'int' [-Wnarrowing]
a.cc:28:23: error: 'AA' was not declared in this scope; did you mean 'A'?
   28 |   long long counttt = AA;
      |                       ^~
      |                       A
Language: C++

ll N, X, M;
	cin >> N >> X >> M;
	vecl(A);
	pb(A, 0);
	ll ans = 0;
	map<int, int> K;

	while (true) {
		if (A.size()>N) {
			break;
		}
		if (K[X]!=0) {
			int n = A.size() - K[X];
			ans += (N - A.size()+1) / n * (A[A.size() - 1] - A[K[X]-1]);
			if((N - A.size() + 1) % n>0)
			ans += (A[K[X]-1+(N - A.size()+1) % n] - A[K[X]-1]);
			break;
		}
		pb(A, X );
		A[A.size() - 1] += A[A.size() - 2];
		K[X] = A.size() - 1;
		ans += X;
		X *= X;
		X %= M;
	}
	ce(ans)

Compiler output:
a.cc:1:1: error: 'll' does not name a type
    1 | ll N, X, M;
      | ^~
a.cc:2:9: error: 'cin' does not name a type
    2 |         cin >> N >> X >> M;
      |         ^~~
a.cc:3:13: error: expected constructor, destructor, or type conversion before '(' token
    3 |         vecl(A);
      |             ^
a.cc:4:11: error: expected constructor, destructor, or type conversion before '(' token
    4 |         pb(A, 0);
      |           ^
a.cc:5:9: error: 'll' does not name a type
    5 |         ll ans = 0;
      |         ^~
a.cc:6:9: error: 'map' does not name a type
    6 |         map<int, int> K;
      |         ^~~
a.cc:8:9: error: expected unqualified-id before 'while'
    8 |         while (true) {
      |         ^~~~~
a.cc:26:11: error: expected constructor, destructor, or type conversion before '(' token
   26 |         ce(ans)
      |           ^
Language: Java

import java.util.*;
import java.lang.*;
import java.io.*;

public class D {
    public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
          long n=sc.nextLong();
          int x=sc.nextInt();
          int m=sc.nextInt();
          deployE obj=new deployE();
          obj.solve(n,x,m);
      }
        
  }
    
}
class deployE
{
    public void solve(long n,int x,int m)
    {
        long sum=x;
        long prev=x;
        for(long i =0 ;i<n-1;i++)
        {
            prev=((prev%m)*(prev%m))%m;
            sum=sum+prev;
//            System.out.println(prev);
        }
        System.out.println(sum);
    }
    
}


Compiler output:
Main.java:5: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error
Language: C++

#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<ll(n);++i)
#define repr(i,n) for(ll i=ll(n);i-->0;)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

void test(ll n,ll x,ll m){
  ll ans = 0;
  for(int i=0;i<n;++i){
    cout<<i<<" "<<x<<endl;
    ans += x;
    x = x*x%m;
  }
  cout<<"ans : "<<ans<<endl;
}

signed main(){

  ll n,x,m;
  cin>>n>>x>>m;
  
  ll ans = 0;
  set<ll> st;
  for(ll i=0;i<n;++i){
    ans += x;
    st.emplace(x);
    x = x*x%m;

    if(st.find(x)!=st.end()){
      ll val = x;
      ll looplen = 0;
      ll loopgain = 0;
      dump(val);
      do{
        loopgain += val;
        val = val*val%m;
        looplen++;
      }while(val!=x);
      dump(ans,ans+(n-i-1)/(looplen)*loopgain);
      ans += (n-i-1)/(looplen)*loopgain;
      dump(x,looplen,(n-i-1)/looplen,(n-i-1)%looplen,loopgain);
      ll len = (n-i-1)%looplen;
      dump(m);
      rep(j,len){
        ans += x;
        x = x*x%m;
      }
      break;
    }
  }
  cout<<(ans)<<endl;

}

Compiler output:
a.cc:2:2: error: #endif without #if
    2 | #endif
      |  ^~~~~
Language: C++


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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define mod 1000000007



int main(){
	
		fast
		ll n,x,m;
		cin>>n>>x>>m;
		ll sum=x;
		for(ll i=2;i<=n;i++)
		{
			if(x*x==m)
			{
				break;
			}
			else{
				x=(x%mod)*(x%mod)
				sum=(sum%mod)+(x%mod);
			}
		}
		cout<<x;


	return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:25:50: error: expected ';' before 'sum'
   25 |                                 x=(x%mod)*(x%mod)
      |                                                  ^
      |                                                  ;
   26 |                                 sum=(sum%mod)+(x%mod);
      |                                 ~~~
Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll N, X, M;
ll S[100005];

int main() {
  INCANT;
  cin >> N >> X >> M;
  ll idx=0ll;
  ll cur = X;
  ll sz,start;
  vector<ll> A;
  S[X] = 0ll;
  A.push_back(X);
  ll ret=X;
  while(idx<min(M+1, N)) {
    ll n = pow(cur,2ll);
    n%=M;
    if (n==0ll) {
      cur=0ll;
      break;
    }
    if (S[n]>0) {
      start = S[n];
      sz = idx - start +1;
      break;
    }
    idx++;
    S[n]=idx;
    A.push_back(n);
    ret+=n;
    cur=n;
  }
  if (cur==0 || idx==N-1) {
    cout << ret << endl;
    return 0;
  }
  ret = 0ll;
  ll tmp=0ll;
  assert(sz>0);
  rep(i, start) tmp+=A[i];
  rep(i, sz) ret+=A[start+i];
  
  ll cir = (N-start)/sz;
  ret*=cir;
  ret+=tmp;
  rep(i, (N-start)%sz) ret+=A[start+i];
  cout << ret << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:3: error: 'assert' was not declared in this scope
   56 |   assert(sz>0);
      |   ^~~~~~
a.cc:14:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   13 | #include <map>
  +++ |+#include <cassert>
   14 | #define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll N, X, M;
ll S[100005];

int main() {
  INCANT;
  cin >> N >> X >> M;
  ll idx=0ll;
  ll cur = X;
  ll sz;
  ll start=sz=0ll;
  vector<ll> A;
  S[X] = 0ll;
  A.push_back(X);
  ll ret=X;
  while(idx<min(M+1, N)) {
    ll n = pow(cur,2ll);
    n%=M;
    if (n==0ll) {
      cur=0ll;
      break;
    }
    if (S[n]>0) {
      start = S[n];
      sz = idx - start +1;
      break;
    }
    idx++;
    S[n]=idx;
    A.push_back(n);
    ret+=n;
    cur=n;
  }
  if (cur==0 || idx==N-1) {
    cout << ret << endl;
    return 0;
  }
  ret = 0ll;
  ll tmp=0ll;
  assert(sz>0);
  rep(i, start) tmp+=A[i];
  rep(i, sz) ret+=A[start+i];
  
  ll cir = (N-start)/sz;
  ret*=cir;
  ret+=tmp;
  rep(i, (N-start)%sz) ret+=A[start+i];
  cout << ret << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:3: error: 'assert' was not declared in this scope
   57 |   assert(sz>0);
      |   ^~~~~~
a.cc:14:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   13 | #include <map>
  +++ |+#include <cassert>
   14 | #define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll N, X, M;
ll S[100005];

int main() {
  INCANT;
  cin >> N >> X >> M;
  ll idx=0ll;
  ll cur = X;
  ll sz;
  ll start=sz=0ll;
  vector<ll> A;
  S[X] = 0ll;
  A.push_back(X);
  ll ret=X;
  while(idx<min(M+1, N)) {
    ll n = pow(cur,2ll);
    n%=M;
    if (n==0ll) {
      cur=0ll;
      break;
    }
    if (S[n]>0) {
      start = S[n];
      sz = idx - start +1;
      break;
    }
    idx++;
    S[n]=idx;
    A.push_back(n);
    ret+=n;
    cur=n;
  }
  if (cur==0 || idx==N-1) {
    cout << ret << endl;
    return 0;
  }
  ret = 0ll;
  ll tmp=0ll;
  assert(sz>0);
  rep(i, start) tmp+=A[i];
  rep(i, sz) ret+=A[start+i];
  
  ll cir = (N-start)/sz;
  ret*=cir;
  ret+=tmp;
  rep(i, (N-start)%sz) ret+=A[start+i];
  cout << ret << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:3: error: 'assert' was not declared in this scope
   57 |   assert(sz>0);
      |   ^~~~~~
a.cc:14:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   13 | #include <map>
  +++ |+#include <cassert>
   14 | #define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
Language: C++

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

int main(){
  int N,X,M;
  cin >> N >> X >> M;
  vector<int> A(N);
  A.at(0) = X;
  for(int i = 1;i<N;i++){
    A.at(i) = (A.at(i-1)*A.at(i-1)) % M;
  }
  
  int sum = 0;
  for(int i=0;i<N;i++){
    s += A.at(i);
  }
  cout << s << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 's' was not declared in this scope
   16 |     s += A.at(i);
      |     ^
a.cc:18:11: error: 's' was not declared in this scope
   18 |   cout << s << endl;
      |           ^
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    INT n,x,m;
    cin >> n >> x >> m;
    
    bool check = true;
    int cnt = 0;
    int start=0;
    INT total=0;
    INT ans=0;
    vector<INT> past;
    
    past.push_back(x);
    while(check){
        x = x*x % m;
        past.push_back(x);
        cnt++;
        if(cnt==n-1){
            rep(i,n){
                ans += past[i];
            }
            cout << ans;
            return 0;
        }
        rep(i,cnt){
            if(past[i]==x){
                check=false;
                start = i;
                for(int j=start;j<=cnt;j++){
                    total += past[j];
                }
                break;
            }
        }
        
    }
    INT initial_part_total = 0;
    for(int i=0;i<start;i++){
        initial_part_total += past[i];
    }
    INT roop = (n - start),(cnt - start);
    INT last_part = (n-start)-((cnt-start)*roop);
    
    INT last_part_total=0 ;
    rep(i, last_part){
        last_part_total += past[i];
    }
    
    ans = initial_part_total + (total*roop) + last_part_total;
    cout << ans;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:49:32: error: expected ')' before '-' token
   49 |     INT roop = (n - start),(cnt - start);
      |                            ~   ^~
      |                                )
Language: C++

#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0 ; i < int(N);i++)
#define all(x) (x.begin(),x.end())
using namespace std ;
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll a;
	int b,c;

	cin >>a >> b >> c;
	ll int sum = 0;
	vector<int> v(a);
	for (int i = 0 ;i < a ;i++){
		if(b < c){
			v[i]=b;
			// cout << b << endl;
			b *= b;
			b %= c;
		}
	}
	for (int i = 0 ;i < a ;i++){
		sum += v[i];
	}
	cout << sum ;


	return 0 ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: two or more data types in declaration of 'sum'
   20 |         ll int sum = 0;
      |         ^~
a.cc:31:17: error: 'sum' was not declared in this scope
   31 |                 sum += v[i];
      |                 ^~~
a.cc:33:17: error: 'sum' was not declared in this scope
   33 |         cout << sum ;
      |                 ^~~
Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll N, X, M;
ll S[100005];

int main() {
  INCANT;
  cin >> N >> X >> M;
  ll idx=0ll;
  ll cur = X;
  ll start=sz=0ll;
  vector<ll> A;
  S[X] = 0ll;
  A.push_back(X);
  ll ret=X;
  while(idx<min(M+1, N)) {
    ll n = pow(cur,2ll);
    n%=M;
    if (n==0ll) {
      cur=0ll;
      break;
    }
    if (S[n]>0) {
      start = S[n];
      sz = idx - start +1;
      break;
    }
    idx++;
    S[n]=idx;
    A.push_back(n);
    ret+=n;
    cur=n;
  }
  if (cur==0 || idx==N-1) {
    cout << ret << endl;
    return 0;
  }
  ret = 0ll;
  ll tmp=0ll;
  rep(i, start) tmp+=A[i];
  rep(i, sz) ret+=A[start+i];
  
  ll cir = (N-start)/sz;
  ret*=cir;
  ret+=tmp;
  rep(i, (N-start)%sz) ret+=A[start+i];
  cout << ret << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:12: error: 'sz' was not declared in this scope
   27 |   ll start=sz=0ll;
      |            ^~
Language: Java

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int x = scn.nextInt();
        int m = scn.nextInt();
        int sum=x;
        int a=x;
        for(int i=1;i<n;i++)
        {
          if(a>m)
          {a = ((int)Math.pow(a,2))%m;}
          else 
          {a=(int)Math.pow(a,2)}

            sum +=a;

        }
        System.out.println(sum);
    }
}


Compiler output:
Main.java:16: error: ';' expected
          {a=(int)Math.pow(a,2)}
                               ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int n, x, m;
bool v[100010];
int ind[100010];
int p[100010];


int32_t main(){
INIT
//cout<<totient(9)<<flush;
cin>>n>>x>>m;
int res=0;
int a=x;

for(int i=1; i<=m; i++){
    if(v[a]==true){
        res+=a;
        int sum=res-p[ind[a]]; sum*=( (n-ind[a])/(i-ind[a]) ); sum+=p[ind[a] ];
        //cout<<a<<"\n"; int b=a; a*=a; a%=m;
         for(int j=1; j<=((n-ind[b])%(i-ind[b]));j++ ){sum+=a; a*=a; a%=m;   }
          //cout<<((n-ind[a])%(i-ind[a]))<<"\n";
            cout<<sum; return 0;
    }
    v[a]=true; ind[a]=i;
    res+=a; a*=a; a%=m;
    p[i]=res;
    if(i>=n){ cout<<res; return 0; }
}


return 0;
}





Compiler output:
a.cc: In function 'int32_t main()':
a.cc:31:34: error: 'b' was not declared in this scope
   31 |          for(int j=1; j<=((n-ind[b])%(i-ind[b]));j++ ){sum+=a; a*=a; a%=m;   }
      |                                  ^
Language: C++

#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

// scanf("%d", &x); => std::cin >> x;
// printf("%d\n", x); => std::cout << x << "\n";

int main() {
    Bint N, X, M;
    std::cin >> N;
    std::cin >> X;
    std::cin >> M;
    Bint ans = X;
    
    for (int i = 1; i < N; i++) {
        ans += ((A[i - 1] % M) * (A[i - 1] % M)) % M;
    }

    std::cout << ans << "\n";
    return 0;
}

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

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <assert>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll N, X, M;
ll S[100005];

int main() {
  INCANT;
  cin >> N >> X >> M;
  ll idx=0ll;
  ll cur = X;
  ll start=sz=0ll;
  vector<ll> A;
  S[X] = 0ll;
  A.push_back(X);
  ll ret=X;
  while(idx<min(M+1, N)) {
    ll n = pow(cur,2ll);
    n%=M;
    if (n==0ll) {
      cur=0ll;
      break;
    }
    if (S[n]>0) {
      start = S[n];
      sz = idx - start +1;
      break;
    }
    idx++;
    S[n]=idx;
    A.push_back(n);
    ret+=n;
    cur=n;
  }
  if (cur==0 || idx==N-1) {
    cout << ret << endl;
    return 0;
  }
  ret = 0ll;
  ll tmp=0ll;
  assert(sz>0);
  rep(i, start) tmp+=A[i];
  rep(i, sz) ret+=A[start+i];
  
  ll cir = (N-start)/sz;
  ret*=cir;
  ret+=tmp;
  rep(i, (N-start)%sz) ret+=A[start+i];
  cout << ret << "\n";
  return 0;
}

Compiler output:
a.cc:9:10: fatal error: assert: No such file or directory
    9 | #include <assert>
      |          ^~~~~~~~
compilation terminated.
Language: C++

/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  ll N; cin >> N;
  int X, M; cin >> X >> M;
  vec<ll> Sum;
  map<int, ll> mp; // An, sum
  Sum.push_back(X);
  while(true){
    decltype(mp)::iterator it = mp.find(X);
    if(it == np.end()){
      // not found
      mp.insert(make_pair(X, Sum[Sum.size()-1]));
      X = (X*X) % M;
      ll s = Sum[Sum.size()-1] + X;
      Sum.push_back(s);
    }else{
      break;
    }
  }
  int looptime = S.size();
  ll Ans = (N / looptime) * S[looptime-1] + S[N % looptime];
  cout << Ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:14: error: 'np' was not declared in this scope; did you mean 'mp'?
   37 |     if(it == np.end()){
      |              ^~
      |              mp
a.cc:47:18: error: 'S' was not declared in this scope
   47 |   int looptime = S.size();
      |                  ^
Language: C++

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

int main(){
  int N,X,M,A=0;
  cin >> N >> X >> M;
  A=X;
  for (int i=2; i<N; i++){
    A+= (A*A)%M
  }
  cout << A<< endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:16: error: expected ';' before '}' token
    9 |     A+= (A*A)%M
      |                ^
      |                ;
   10 |   }
      |   ~
Language: C++

#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

// scanf("%d", &x); => std::cin >> x;
// printf("%d\n", x); => std::cout << x << "\n";

int main() {
    Bint N, M;
    long long X
    std::cin >> N;
    long long A[N];
    std::cin >> X;
    std::cin >> M;
    A[0] = X;
    Bint ans = A[0];
    
    for (int i = 1; i < N; i++) {
        A[i] = ((A[i - 1] % M) * (A[i - 1] % M)) % M;
        ans += A[i];
    }

    std::cout << ans << "\n";
    return 0;
}

Compiler output:
a.cc:10:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory
   10 | #include <boost/multiprecision/cpp_dec_float.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int start=s.nextInt();
    int end=s.nextInt();
    while(n-- >0){
      if(sum<=end){
        int val=Math.pow(start,2);
        start=val;
        sum+=val;
      }
    }
    System.out.println(sum);
   }
}


Compiler output:
Main.java:10: error: cannot find symbol
      if(sum<=end){
         ^
  symbol:   variable sum
  location: class Main
Main.java:11: error: incompatible types: possible lossy conversion from double to int
        int val=Math.pow(start,2);
                        ^
Main.java:13: error: cannot find symbol
        sum+=val;
        ^
  symbol:   variable sum
  location: class Main
Main.java:16: error: cannot find symbol
    System.out.println(sum);
                       ^
  symbol:   variable sum
  location: class Main
4 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 998244353;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

struct UnionFind {
    vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(
        int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {  // xとyの木を併合
        int rx = root(x);       // xの根をrx
        int ry = root(y);       // yの根をry
        if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] =
            ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll ans = 0;

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    x %= m;

    vector<bool> check(100010, false);

    ll zero = x;
    vector<ll> amari;

    amari.push_back(x);
    check[x] = true;

    ll key = 0;
    while (1) {
        x = x * x;
        x %= m;

        zero += x;
        if (check[x] == true) {
            key = x;
            break;
        }
        if (x == 0) {
            cout << zero << "\n";
            return 0;
        }

        check[x] = true;
        amari.push_back(x);
    }

    ll sum = 0, keynum = 0;
    bool yes = false;
    vector<ll> BI;
    rep(i, amari.size()) {
        if (key == amari[i]) {
            yes = true;
            keynum = i;
        }

        if (yes == false) {
            ans += amari[i];
        } else {
            sum += amari[i];
            BI.push_back(amari[i]);
        }
    }

    ans += (n / (amari.size() - keynum)) * sum;
    rep(i, max((n % BI.size()) - 2,0ll) {
        ans += BI[i]; }

    cout << ans << "\n";
    return 0;
}

Compiler output:
a.cc:114:2: error: unterminated argument list invoking macro "rep"
  114 | }
      |  ^
a.cc: In function 'int main()':
a.cc:109:5: error: 'rep' was not declared in this scope
  109 |     rep(i, max((n % BI.size()) - 2,0ll) {
      |     ^~~
a.cc:109:8: error: expected '}' at end of input
  109 |     rep(i, max((n % BI.size()) - 2,0ll) {
      |        ^
a.cc:59:12: note: to match this '{'
   59 | int main() {
      |            ^