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

#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
using namespace std;

const ll Maxn = 123456;
const ll Mod = 1000000007;



ll A[Maxn];
ll fact[Maxn];
ll inv[Maxn], ifact[Maxn];
ll freq[Maxn];



template<typename T, typename T1>
T mod(T x, T1 p)
{
    x %= p;
    while (x < 0)
        x += p;
    return x;
}


template<typename T>
T inverse(T x, T p) {
    x = mod(x, p);
    if (x == 1)
        return x;
    return mod((1LL * (-p / x) * (inv[p % x] % p)) , p);
    // Since inverse of p % x is already calculated.
}


ll NcR(ll n, ll r) {
    ll ret = (1LL * ifact[n - r] * ifact[r]) % Mod ;
	ret = (1LL * ret * fact[n]) % Mod;
    return ret;
}

int main()
{
ios_base::sync_with_stdio(false);


fact[0] = 1;
ifact[0] = 1;
for(ll i = 1; i < Maxn; i++) {
	fact[i] = 1LL * fact[i - 1] * i % Mod;
}

ifact[0] = 1;
for(ll i = 1; i < Maxn; i++) {
	ifact[i] = 1LL * ifact[i - 1] * inverse(i, Mod) % Mod;
}
for(ll i = 1; i < Maxn; i++) {
	inv[i] = inverse(i, Mod);
	ifact[i] = ifact[i - 1] * inv[i] % Mod;
}



ll n;
cin>>n;

n++;

//cout<<NcR(4,2)<<endl;


ll num=1;
for(ll i=0;i<n;i++)
    {cin>>A[i];
     freq[A[i]]++;
     if(freq[A[i]]==2)
        num=A[i];
    }

    ll i=0,p=0,q=0;

    //cout<<num<<endl;
    ll idx1,idx2;
    while(i<n)
    {
        if(A[i]==num){idx1=i;break;}
        p++;
        i++;
    }
    i=n-1;
    while(i>=0)
    {
        if(A[i]==num){idx2=i;break;}
        q++;
        i--;
    }
    ll d  = idx2-idx1;
    //d++;
   // cout<<p<<" "<<q<<endl;
    ll ans;
    cout<<n-1<<'\n';
    for(ll k=2;k<=n;k++)
    {

      ans= NcR(n,k);
      if(k-1<=n-d-1)
      {
          ans-=NcR(n-d-1,k-1);
          if(ans<0)ans+=mod;
      }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:114:25: error: overloaded function with no contextual type information
  114 |           if(ans<0)ans+=mod;
      |                         ^~~
Language: C++

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;

template<ull max_n, ull m>
class nCr_mod_m
{
public:
	nCr_mod_m() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[0] = 0;
		inv[1] = 1;
		for (ull i = 2; i <= max_n; i++) {
			inv[i] = m - inv[m % i] * (m / i) % m;
			fac[i] = fac[i - 1] * i % m;
			finv[i] = finv[i - 1] * inv[i] % m;
		}
	}

	ull C(ull n, ull r) {
		if (n < r)
			return 0;
		return fac[n] * (finv[r] * finv[n - r] % m) % m;
	}
private:
	ull fac[max_n + 1], inv[max_n + 1], finv[max_n + 1];
};
int main() {
	int n, a[100010], have[100010], pos1, pos2;
	memset(have, -1, sizeof(have));
	nCr_mod_m<100010, 1000000007> nCr;
	scanf("%d", &n);
	for (int i = 0; i <= n; i++) {
		scanf("%d", a + i);
		if (have[a[i]] == -1) {
			have[a[i]] = i;
		} else {
			pos1 = have[a[i]];
			pos2 = i;
		}
	}
	for (int i = 1; i <= n + 1; i++) {
		ull combis = nCr.C(n + 1, i);
		combis -= nCr.C(pos1 + (n - pos2), i - 1);
		if (combis < 0)
			combis += 1000000007;
		printf("%lld\n", combis);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'memset' was not declared in this scope
   36 |         memset(have, -1, sizeof(have));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <deque>
  +++ |+#include <cstring>
    5 |
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007LL
#define MAX 100000
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

ll fact[MAX*10], rfact[MAX+10];

ll comb(ll n, ll r){
    return (((fact[n] * rfact[r]) % MOD) * rfact[n-r]) % MOD;
}

signed main(){
    int n, d1, d2, tmp;
    cin >> n;
    vector<int> use(n+1, -1);
    rep(n+1){
        cin >> tmp;
        if(use[tmp] != -1){
            d2 = i;
            d1 = use[tmp];
            break;
        }else{
            use[tmp] = i;
        }
    }

    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    reppp(i, 2, n+1){
        fact[i] = (fact[i-1] * i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }

    printf("%d\n", n); //k=1
    if(n > 1) printf("%d\n", (n * (n+1) / 2 - d1 - (n-d2)) % (int)MOD); //k=2;
    if(n > 2)
        reppp(i, 3, n){
            ll ans = comb((ll)n+1, (ll)i);
            if(d1 + (n - d2) >= i-1){
                //ll dup = comb((ll)(d1+n-d2), i-1);
                reppp(j, max(0, i-1-(n-d2)), d1){
                    dup += (comb((ll)d1, (ll)j) * comb((ll)(n-d2), (ll)(i-1-j))) % MOD;
                }
                ans -= dup % MOD;
                if(ans < 0) ans += MOD;
            }
            printf("%lld\n", ans);
        }
    printf("%d\n", 1); //k=n+1;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:21: error: 'dup' was not declared in this scope
   78 |                     dup += (comb((ll)d1, (ll)j) * comb((ll)(n-d2), (ll)(i-1-j))) % MOD;
      |                     ^~~
a.cc:80:24: error: 'dup' was not declared in this scope
   80 |                 ans -= dup % MOD;
      |                        ^~~
Language: C++

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <deque>
#include "nCr_mod_m.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

template<ull max_n, ull m>
class nCr_mod_m
{
public:
	nCr_mod_m() {
		fac[0] = fac[1] = 1;
		for (int i = 2; i <= max_n; i++)
			fac[i] = fac[i - 1] * i % m;
		inv[1] = 1;
		for (int i = 2; i <= max_n; i++)
			inv[i] = m - inv[m % i] * (m / i) % m;
		finv[0] = finv[1] = 1;
		for (int i = 2; i <= max_n; i++)
			finv[i] = finv[i - 1] * inv[i] % m;
	}

	ull C(ull n, ull r) {
		if (n < r)
			return 0;
		return fac[n] * (finv[r] * finv[n - r] % m) % m;
	}
private:
	ull fac[max_n + 1], inv[max_n + 1], finv[max_n + 1];
};
int main() {
	int n, a[100010], doubled, pos1, pos2;
	bool have[100010] = { false };
	nCr_mod_m<100010, 1000000007> nCr;
	scanf("%d", &n);
	for (int i = 0; i <= n; i++) {
		scanf("%d", a + i);
		if (have[a[i]]) {
			doubled = a[i];
			pos2 = i;
			for (int j = 0; j < i; j++)
				if (a[j] == doubled)
					pos1 = j;
		}
		have[a[i]] = true;
	}
	printf("%d\n", n);
	for (int i = 2; i <= n; i++) {
		ull combis = nCr.C(n + 1, i);
		combis -= nCr.C(pos1 + (n - pos2), i - 1);
		if (combis < 0)
			combis += 1000000007;
		printf("%d\n", combis);
	}
	printf("%d\n", 1);
}

Compiler output:
a.cc:5:10: fatal error: nCr_mod_m.h: No such file or directory
    5 | #include "nCr_mod_m.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define mod 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%mod) % mod)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };

long D[114514];
i64 Powmod(i64 a, i64 b, i64 p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		i64 d = Powmod(a, b / 2, p);
		return d * d % p;
	}
	else
	{
		return a * Powmod(a, b - 1, p) % p;
	}
}
int main()
{
	memset(D, -1, sizeof(D));
	int N;
	scanf("%d", &N);
	int A[114514];
	for(int i = 0; i <= N; i++)
	{
		scanf("%d", &A[i]);
	}
	int C[114514];
	//memset(C, -1, sizeof(C));
	i64 K[114514];
	K[0] = 1;
	C[0] = -1;
	for (int i = 1; i <= N + 1; i++)
	{
		K[i] = (K[i - 1] * (long)i) % mod;
		C[i] = -1;
	}
	int l = -1, r = -1;
	for (int i = 0; i <= N; i++)
	{
		int x = A[i];
		if (C[x] == -1)
		{
			C[x] = i;
		}
		else
		{
			l = C[x];
			r = i;
			break;
		}
	
	}
	//printf("%d %d\n",l,r);
	int W = l + N - r;
	
	printf("%d\n", N);
	for (int i = 2; i <= N; i++)
	{
		i64 p;
		if(D[i]!=-1)p =D[i];
		else
		{
			D[i] = Powmod(K[i], mod - 2, mod);
			p = D[i];
		}
		i64 d = K[N + 1] * p % mod;
		f(D[N + i - 1]!=-1)p =D[i];
		else
		{
			D[N + 1 - i] = Powmod(K[N + i - 1], mod - 2, mod);
			p = D[i];
		}
		d = d * p % mod;
		if (i == 2)
		{
			d -= l;
			d -= N - r;
		}
		else
		{
			if (i - 1 <= W)
			{
					if(D[i - 1]!=-1)p =D[i - 1];
		else
		{
			D[i- 1] = Powmod(K[i - 1], mod - 2, mod);
			p = D[i - 1];
		}
				long e = K[W] *p % mod;
							if(D[i - 1]!=-1)p =D[i - 1];
		else
		{
			D[W - i+ 1] = Powmod(K[W - i + 1], mod - 2, mod);
			p = D[W - i + 1];
		}
				e = e * Powmod(p, mod - 2, mod);
				d -= e;
			}
		}
		while (d< 0)
		{
			d += mod;
		}
		d %= mod;
		printf("%lld\n", d);

	}
	printf("1\n");
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:85:17: error: 'f' was not declared in this scope
   85 |                 f(D[N + i - 1]!=-1)p =D[i];
      |                 ^
a.cc:86:17: error: 'else' without a previous 'if'
   86 |                 else
      |                 ^~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//関係無いけどMODからどうやって階乗を復元すんだっけ？

ll Combination(int n, int r)
{
    if (n <= 0 || r < 0 || r > n) return 0;
    if (n - r < r) r = n - r;
    if (r == 0) return 1;
    if (r == 1) return n;

    int numerator[r];
    int denominator[r];

    for (int k = 0; k < r; k++)
    {
        numerator[k] = n - r + k + 1;//分子
        denominator[k] = k + 1;//分母
    }

    for (int p = 2; p <= r; p++)
    {
        int pivot = denominator[p - 1];
        if (pivot > 1)
        {
            int offset = (n - r) % p;
            for (int k = p - 1; k < r; k += p)
            {
                numerator[k - offset] /= pivot;
                denominator[k] /= pivot;
            }
        }
    }

    ll result = 1;
    for (int k = 0; k < r; k++)
    {
        if (numerator[k] > 1){
        	result *= numerator[k];
        	result %= MOD;
        }
    }

    return cb[r]=result;
}


int main(void){
	int n,a[100010],before,after;
	ll ans,cb[100010]={};
	map<int,int> b;
	cin>>n;
	rep(i,n+1){//0-origin
		cin>>a[i];
		if(b.count(a[i])==0){
			b[a[i]]=i;
		}else{
			before = b[a[i]];
			after = i;
		}
	}
	// cout<<before<<","<<after<<endl;
	reg(i,1,n+1){
		if(i==1){
			ans=n;
		}else{
			if(cb[i]!=0){
				ans=cb[i];
			}else{
				ans=Combination(n+1,i);
			}		
			ans-=Combination(n+1-(after-before+1),i-1);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'll Combination(int, int)':
a.cc:65:12: error: 'cb' was not declared in this scope
   65 |     return cb[r]=result;
      |            ^~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define mod 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%mod) % mod)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };

long D[114514];
i64 Powmod(i64 a, i64 b, i64 p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		i64 d = Powmod(a, b / 2, p);
		return d * d % p;
	}
	else
	{
		return a * Powmod(a, b - 1, p) % p;
	}
}
int main()
{
	memset(D, -1, sizeof(D));
	int N;
	scanf("%d", &N);
	int A[114514];
	for(int i = 0; i <= N; i++)
	{
		scanf("%d", &A[i]);
	}
	int C[114514];
	//memset(C, -1, sizeof(C));
	i64 K[114514];
	K[0] = 1;
	C[0] = -1;
	for (int i = 1; i <= N + 1; i++)
	{
		K[i] = (K[i - 1] * (long)i) % mod;
		C[i] = -1;
	}
	int l = -1, r = -1;
	for (int i = 0; i <= N; i++)
	{
		int x = A[i];
		if (C[x] == -1)
		{
			C[x] = i;
		}
		else
		{
			l = C[x];
			r = i;
			break;
		}
	
	}
	//printf("%d %d\n",l,r);
	int W = l + N - r;
	
	printf("%d\n", N);
	for (int i = 2; i <= N; i++)
	{
		i64 p;
		if(D[i]!=-1)p =D[i];
		else
		{
			D[i] = Powmod(K[i], mod - 2, mod);
			p = D[i];
		}
		i64 d = K[N + 1] * p % mod;
		f(D[N + i - 1]!=-1)p =D[i];
		else
		{
			D[N + 1 - i] = Powmod(K[N + i - 1], mod - 2, mod);
			p = D[i];
		}
		d = d * p % mod;
		if (i == 2)
		{
			d -= l;
			d -= N - r;
		}
		else
		{
			if (i - 1 <= W)
			{
					if(D[i - 1]!=-1)p =D[i - 1];
		else
		{
			D[i- 1] = Powmod(K[i - 1], mod - 2, mod);
			p = D[i - 1];
		}
				long e = K[W] *p % mod;
				e = e * Powmod(K[W - i + 1], mod - 2, mod);
				d -= e;
			}
		}
		while (d< 0)
		{
			d += mod;
		}
		d %= mod;
		printf("%lld\n", d);

	}
	printf("1\n");
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:85:17: error: 'f' was not declared in this scope
   85 |                 f(D[N + i - 1]!=-1)p =D[i];
      |                 ^
a.cc:86:17: error: 'else' without a previous 'if'
   86 |                 else
      |                 ^~~~
Language: C++

#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

constexpr long MOD = 1000000000 + 7;

long gcd(long a, long b)
{
    if (b > a)
        swap(a, b);
    if (b == 0)
        return a;
    if (b == 1)
        return 1;
    return gcd(b, a % b);
}

long COMB[50001][

long comb(long a, long b)
{
    if (b > a)
        return 0;
    if (a - b < b)
        return comb(a, a - b);

    long x = 1;

    vector<long> cs;
    cs.push_back(1);
    for (long i = 2; i <= b; ++i) {
        if (cs.back() >= 1000000000) {
            cs.push_back(1);
        }
        cs.back() *= i;
    }

    for (long i = 0; i < b; ++i) {
        long d = a - i;
        for (long& c : cs) {
            long g = gcd(d, c);
            // cerr << "    " << i << " " << d << " " << g << endl;
            d /= g;
            c /= g;
        }
        x *= d;
        x %= MOD;
    }
    // assert(c == 1);

    // cerr << "GCD " << a << ' ' << b << ' ' << x << endl;
    return x;
}

int main()
{
    int N;
    cin >> N;
    ++N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    set<int> s;
    int dupe = -1;
    for (int x : a) {
        if (s.find(x) != s.end()) {
            dupe = x;
            break;
        }
        s.insert(x);
    }

    int l = -1;
    int r = -1;
    for (int i = 0; i < N; ++i) {
        if (a[i] == dupe) {
            if (l == -1)
                l = i;
            else
                r = i;
        }
    }

    assert(r != -1);

    int osz = l + (N - 1) - r;

    for (int k = 1; k <= N; ++k) {
        long p = comb(N, k);
        long q = comb(osz, k - 1);
        long v = (p + MOD - q) % MOD;
        cout << v << '\n';
    }

    return 0;
}


Compiler output:
a.cc:32:1: error: expected primary-expression before 'long'
   32 | long comb(long a, long b)
      | ^~~~
a.cc:30:18: error: expected ']' before 'long'
   30 | long COMB[50001][
      |                  ^
      |                  ]
   31 | 
   32 | long comb(long a, long b)
      | ~~~~              
a.cc: In function 'int main()':
a.cc:102:18: error: 'comb' was not declared in this scope; did you mean 'wctomb'?
  102 |         long p = comb(N, k);
      |                  ^~~~
      |                  wctomb
Language: C++

#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
using namespace std;

typedef long long ll;

#define FOR(i,N) for(int i=0;i<N;i++)

int mod=1e9+7;

ll mo=1000000007;
map<pair<ll,ll>, ll>mem;
const int NUM_=1000001;
ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];

ll combi(ll N_, ll C_) {
    if(mem[make_pair(N_, C_)]){
        return mem[make_pair(N_, C_)];
    }
    if(C_<0 || C_>N_) return 0;
    return mem[make_pair(N_, C_)]=factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

int main() {
    
    memset(fact,0,sizeof(fact));
    memset(factr,0,sizeof(factr));
    memset(inv,0,sizeof(inv));
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
    }
    
    
    int n;
    cin>>n;
    vector<int>a(n+1);
    map<int,int>ma;
    int d=-1;
    int l,r;
    for(int i=0;i<n+1;i++){
        cin>>a[i];
        ma[a[i]]++;
        if(ma[a[i]]>1){
            d=a[i];
            r=n+1-i-1;
        }
    }
    for(int i=0;i<n+1;i++){
        if(a[i]==d){
            l=i;
            break;
        }
    }
    int l_a_r=max(l,r);
    cout<<n<<endl;
    ll cur=n+1;
    for(int i=2;i<n+1;i++){
        cur=cur*(n+1-(i-1))/i;
        if(i<=l+r+1){
            ll ans=combi(l,i-1)+combi(r,i-1);
            for(int j=1;j<=min(i-1,l);j++){
                if(i-j>1){
                    ans+=combi(l, j)*combi(r,i-1-j);
                }
            }
            cout<<(cur-ans)%mod<<endl;
        } else {
            cout<<cur%mod<<endl;
        }
    }
    cout<<1<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:5: error: 'memset' was not declared in this scope
   33 |     memset(fact,0,sizeof(fact));
      |     ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    9 | #include<unordered_set>
  +++ |+#include <cstring>
   10 | using namespace std;
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

#define REP(i,m,M) for(int i=m; i<M; i++)
#define REPR(i,M,m) for(int i=M; i>m; i—-)
#define REPLL(i,m,M) for(ll i=m; i<M; i++)
#define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
#define ALL(v) v.begin(),v.end()

ll C[100002][100002];

void fillC(int n){
    C[0][0] = 1LL;
    for(int i=0; i<=n+1; i++){
        C[i][0] = 1LL;
        C[i][i] = 1LL;
        for(int j=1; j<=i-1; j++){
            C[i][j] = (C[i-1][j-1]+C[i-1][j]) % MOD;
        }
    }
}


int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    vi v;
    int x, y;
    while(1){
        int tmp;
        cin >> tmp;
        auto itr = find(v.begin(), v.end(), tmp);
        if(itr == v.end()){
            v.push_back(tmp);
            continue;
        }
        x = itr - v.begin();
        //cerr << x << endl;
        y = n - v.size();
        //cerr << y << endl;
        break;
    }
    
    fillC(n);
   /*
    for(int i=0; i<=n+1; i++){
        for(int j=0; j<=i; j++){
            cerr << C[i][j] << " ";
        }
        cerr << endl;
    }
    */
    
    for(int k=1; k<=n+1; k++){
        cout << C[n+1][k] - C[x+y][k-1] << endl;
    }


    return 0;
}


Compiler output:
a.cc:23:39: error: extended character — is not valid in an identifier
   23 | #define REPR(i,M,m) for(int i=M; i>m; i—-)
      |                                       ^
a.cc:25:40: error: extended character — is not valid in an identifier
   25 | #define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
      |                                        ^
Language: C++

C:\Filyan\Competitive Programming\CP\CP\Source.cpp

Compiler output:
a.cc:1:3: error: stray '\' in program
    1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
      |   ^
a.cc:1:10: error: stray '\' in program
    1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
      |          ^
a.cc:1:34: error: stray '\' in program
    1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
      |                                  ^
a.cc:1:37: error: stray '\' in program
    1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
      |                                     ^
a.cc:1:40: error: stray '\' in program
    1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
      |                                        ^
a.cc:1:2: error: found ':' in nested-name-specifier, expected '::'
    1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
      |  ^
      |  ::
a.cc:1:1: error: 'C' does not name a type
    1 | C:\Filyan\Competitive Programming\CP\CP\Source.cpp
      | ^
Language: C++

#include <stdio.h>
#define MOD 1000000007

long long fac[100005];
long long invfac[100005];

long long powmod(long long a,int b)
{
    if (b==1) return a;
    if (b&1) return (powmod((a*a)%MOD,b/2)*a)%MOD;
    return powmod((a*a)%MOD,b/2);
}

long long inv(long long a)
{
    return powmod(a,MOD-2);
}

long long choose(long long a,long long b)
{
    if (b<0 || b>a) return 0;
    return (((fac[a]*invfac[b])%MOD)*invfac[a-b])%MOD;
}

int t1,t2;
int n;
int use[100005];

int i1,i2;
int mid;
long long ans;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d%d",&n,&t1);
    use[t1]=1;
    fac[0]=invfac[0]=1;
    for (int i=1; i<=n; i++) {
        fac[i]=(i*fac[i-1])%MOD;
        invfac[i]=(inv(i)*invfac[i-1])%MOD;
        scanf("%d",&t1);
        if (use[t1]) {
            i1=use[t1];
            i2=i+1;
        }
        use[t1]=i+1;
    }
    // do the counting
    mid=i2-i1-1;
    printf("%d\n",n);
    n++;
    for (int i=2; i<=n; i++) {
        //printf("i %d\n",i);
        // order is BACAD
        // some part of BCD
        ans=choose(n-2,i);
        //printf("BCD %lld\n",ans);
        // some part of BACD or BCAD, A mandatory
        ans+=choose(n-2,i-1);
        ans+=choose(n-2,i-1);
        //printf("BACD BCAD %lld\n",ans);
        // some part of BAD, A mandatory
        ans+=MOD-choose(n-mid-2,i-1);
        //printf("BAD %lld\n",ans);
        // some part of BACAD, both A mandatory
        ans+=choose(n-2,i-2);
        //printf("BACAD %lld\n",ans);
        printf("%lld\n",ans%MOD;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:32: error: expected ')' before ';' token
   71 |         printf("%lld\n",ans%MOD;
      |               ~                ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MAX_N = 100005;

int n,m,A[MAX_N];
map<int, pair<ll, ll>> sum;

// x[a..b]++ und add[a..b] += c
void magic(int a, int b, int c)
{
	if (a > b)
		return;
	sum[a].first++;
	sum[b+1].second--;
	sum[a].second += c;
	sum[b+1].second -= c;
}

int main()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<=n; i++)
		scanf("%d",A+i);
	ll cost = 0;
	for (int i=1; i<n; i++)
	{
		int a = A[i], b = A[i+1];
		cost += (b-a+m)%m;
		if (a <= b)
			magic(a+1, b, -a-1); // a < x <= b: x - a - 1
		else
		{
			magic(a+1, m, -a-1); // a < x <= m:  x - a - 1
			magic(1, b, m-a-1);  // 1 <= x <= b: m - a + x - 1
		}
	}
	ll sub = 0, px = 0, padd = 0;
	for (auto it : sum)
	{
		sub = max(sub, (it->first-1)*px + padd);
		px += it->second.first;
		padd += it->second.second;

	}
	printf("%lld\n", cost - sub);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:35: error: base operand of '->' has non-pointer type 'std::pair<const int, std::pair<long long int, long long int> >'
   43 |                 sub = max(sub, (it->first-1)*px + padd);
      |                                   ^~
a.cc:44:25: error: base operand of '->' has non-pointer type 'std::pair<const int, std::pair<long long int, long long int> >'
   44 |                 px += it->second.first;
      |                         ^~
a.cc:45:27: error: base operand of '->' has non-pointer type 'std::pair<const int, std::pair<long long int, long long int> >'
   45 |                 padd += it->second.second;
      |                           ^~
Language: C++

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}


int main()
{
#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);

	int n, m;
	cin >> n >> m;

	vector<int> x(n);
	for (int k = 0; k < n; k++)
		cin >> x[k];

	vector<pair<int, int>> to_right, center;
	long long resp = 0;
	map<int, long long> residue;
	map<int, long long> end_left;
	vector<long long> res_best(m + 1);
	vector<long long> res_cnt(m + 1);

	for (int j = 0; j < n - 1; j++)
	{
		if (x[j] > x[j + 1])
		{
			resp += m - x[j] + 1;
			residue[x[j + 1]] += m - x[j] + 1;
			res_best[x[j + 1]] += m - x[j] + 1;;
			res_cnt[x[j + 1]]++;
			x[j] = 1;
			if (x[j + 1] == 1)
				continue;
		}

		end_left[x[j + 1]] += x[j + 1] - x[j];
		to_right.push_back({ x[j], x[j + 1] });
		center.push_back({ x[j] + 1, x[j + 1] });
	}

	sort(center.begin(), center.end(), [&](pair<int, int>& a, pair<int, int>& b) {
		return a.first < b.first;
		});

	vector<long long> sum_right(m + 1);
	for (auto x : to_right)
	{
		sum_right[x.first] += (x.second - x.first);
	}

	for (int i = sum_right.size() - 1; i > 0; i--)
	{
		sum_right[i - 1] += sum_right[i];
	}
	vector<long long> center_balance(m + 2);
	map<int, long long> center_sum_left;
	for (auto x : center)
	{
		center_sum_left[x.first] += x.second - x.first + 1;
		center_balance[x.first] += 1;
		center_balance[x.second + 1] -= 1;
	}

	for (int j = 1; j <= m; j++)
	{
		center_balance[j] += center_balance[j - 1];
	}

	for (int j = m; j > 0; j--)
	{
		res_best[j - 1] += res_best[j];
		res_cnt[j - 1] += res_cnt[j];
	}


	long long sum_left = 0, sum_center = 0;
	long long max_res = 0;
	long long best_sum = LLONG_MAX;
	for (int f = 1; f <= m; f++)
	{
		long long curr_sum = resp - res_best[f] + res_cnt[f];
		curr_sum += sum_left + sum_right[f];
		sum_center += center_sum_left[f];

		curr_sum += sum_center;
		best_sum = min(best_sum, curr_sum);

		sum_center -= center_balance[f];
		sum_left += end_left[f];
	}

	cout << best_sum;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:113:30: error: 'LLONG_MAX' was not declared in this scope
  113 |         long long best_sum = LLONG_MAX;
      |                              ^~~~~~~~~
a.cc:23:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   22 | #include <set>
  +++ |+#include <climits>
   23 |
Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int arr[MAXN];
int pref[MAXN];
int pref2[MAXN];
int ans;
int res= 1e9;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    for(int i=1;i<n;i++){
        int x = arr[i];
        int y = arr[i+1];
        if(y<x){
            y+=m;
            pref[x+2]++;
            pref[y+1]--;
            pref2[y+1]+=y-x-1;
        }else{
            pref[x+2]++;
            pref[y+1]--;
            pref2[y+1]+=y-x-1;
            pref[m+x+2]++;
            pref[m+y+1]--;
            pref2[m+y+1]+=y-x-1;
        }
        ans+=(y-x);


    }
    for(int i=1;i<=2*m;i++){
        pref[i] += pref[i-1];
        pref2[i] += tot[i-1];
        pref2[i]-=pref[i];
        res = min(res,ans+pref2[i]);
    }
    cout<<res<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:21: error: 'tot' was not declared in this scope
   38 |         pref2[i] += tot[i-1];
      |                     ^~~
Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int arr[MAXN];
int pref[MAXN];
int pref2[MAXN];
int ans;
int res= 1e9;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    for(int i=1;i<n;i++){
        int x = arr[i];
        int y = arr[i+1];
        if(y<x){
            y+=m;
            pref[x+2]++;
            pref[y+1]--;
            pref2[y+1]+=y-x-1;
        }else{
            pref[x+2]++;
            pref[y+1]--;
            pref2[y+1]+=y-x-1;
            pref[m+x+2]++;
            pref[m+y+1]--;
            pref2[m+y+1]+=y-x-1;
        }
        ans+=(y-x);


    }
    for(int i=1;i<=2*m;i++){
        pref[i] += pref[i-1];
        tot[i] += tot[i-1];
        pref2[i]-=pref[i];
        res = min(res,ans+pref2[i]);
    }
    cout<<res<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: 'tot' was not declared in this scope
   38 |         tot[i] += tot[i-1];
      |         ^~~
Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int arr[MAXN];
int pref[MAXN];
int tot[MAXN];
int ans;
int res= 1e9;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    for(int i=1;i<n;i++){
        int x = arr[i];
        int y = arr[i+1];
        if(y<x){
            y+=m;
            pref[x+2]++;
            pref[y+1]--;
            tot[y+1]+=y-x-1;
        }else{
            pref[x+2]++;
            pref[y+1]--;
            tot[y+1]+=y-x-1;
            pref[m+x+2]++;
            pref[m+y+1]--;
            tot[m+y+1]+=y-x-1;
        }
        ans+=(y-x);


    }
    for(int i=1;i<=2*m;i++){
        pref[i] += pref[i-1];
        tot[i] += tot[i-1];
        pref2[i]-=pref[i];
        res = min(res,ans+pref2[i]);
    }
    cout<<res<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'pref2' was not declared in this scope; did you mean 'pref'?
   39 |         pref2[i]-=pref[i];
      |         ^~~~~
      |         pref
Language: C

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	ll n,m;
	cin>>n>>m;
	ll a;
	vector<ll> A;
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}

	vector<pair<ll,ll>> kukan;//pair<ll,ll> 左端, 右端
	rep(i,n-1){
		if(A[i] < A[i+1]){
			kukan.push_back(pair<ll,ll>{A[i]+m,A[i+1]+m});
			kukan.push_back(pair<ll,ll>{A[i],A[i+1]});
		}else{
			kukan.push_back(pair<ll,ll>{A[i],A[i+1]+m});
			kukan.push_back(pair<ll,ll>{A[i]+m,A[i+1]+m*2});
		}
	}
	sort(all(kukan));

	//pair<ll,ll> : 右端,左端
	priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> que;
	
	ll val = 0;//現在の明るさtを挟む区間の個数
	int ki = 0;
	ll toku = 0;//お気に入りによって得した量
	ll max_toku = 0;
	rep(t,2*m+3){
		toku += val;
		chmax(max_toku, toku);//明るさtをお気に入りにした時に得した量(手数圧縮量) = toku になってる.
		while(que.size() > 0 && que.top().first == t){
			pair<ll,ll> top = que.top();
			val--;
			toku -= top.first - top.second - 1;//お気に入りがその区間から外れることで, 今まで得とカウントしてた量は無効
			que.pop();
		}
		while(ki < kukan.size() && kukan[ki].first == t){
			que.push(pair<ll,ll>{kukan[ki].second, kukan[ki].first});
			val++;
			ki++;
			toku -= 1;//t+1をお気に入りにしても, まだ得はしないので.
		}
		
		//cout<<toku<<" ";
		//cout<<que.size()<<" ";
	}
	//cout<<endl;
	ll ans = 0;
	rep(i,A.size()-1){//手数圧縮しなかった場合にかかる手数
		if(A[i] < A[i+1]) ans += A[i+1] - A[i];
		else ans += A[i+1] - A[i] + m;
	}
	ans -= max_toku;
	cout<<ans<<endl;
	//cout<<toku<<endl;
	//cout<<max_toku<<endl;
	return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

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

    int n,m;cin>>n>>m;
    vector<ll> a(n),imos(m+10,0);
    map<ll,ll> mp;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    ll cnt=0; // x=0 の時のコスト
    for(int i=1;i<n;i++){
        cnt += min((a[i]+m-a[i-1])%m, 1+a[i]);
        if(a[i-1]<a[i]){
            if(a[i]-a[i-1]>=3){
                imos[a[i-1]+2]++;
                imos[a[i]+1]--;
            }
        }
        else{
            imos[a[i-1]+2]++;
            imos[0]++;
            imos[a[i]+1]--;
        }
        mp[a[i]+1] += (a[i]+m-a[i-1])%m -1;
    }
    for(int i=1;i<=m;i++){
        imos[i] += imos[i-1];
    }
    for(int i=1;i<m;i++){
        cnt -= imos[i];
        cnt += mp[i];
        res=min(res,cnt);
    }
    cout<<res<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:9: error: 'res' was not declared in this scope
   40 |         res=min(res,cnt);
      |         ^~~
a.cc:42:11: error: 'res' was not declared in this scope
   42 |     cout<<res<<endl;
      |           ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <array>
#include <numeric>

using namespace std;
const int maxn = 3e5 + 1e2;
using ll = long long;
array<int, maxn> a;
array<ll, maxn> p;
int n, m;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll tot = 0;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i < n; ++i) {
        int l = a[i - 1], r = a[i];
        r += (l > r) * m;
        tot += r - l;
        if (r - l > 1) {
            ++p[l + 2];
            p[r + 1] -= (r - (l + 2) + 1) + 1;
            p[r + 2] += (r - (l + 2) + 1);
        }
    }
    partial_sum(p.begin() + 1, p.begin() + 2 * m + 1, p);
    partial_sum(p.begin() + 1, p.begin() + 2 * m + 1, p);

    ll ans = 0;
    for (int i = 1; i <= m; ++i) ans = max(ans, p[i] + p[i + m]);
    cout << tot - ans << endl;

}

Compiler output:
In file included from /usr/include/c++/14/numeric:62,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_numeric.h: In instantiation of '_OutputIterator std::partial_sum(_InputIterator, _InputIterator, _OutputIterator) [with _InputIterator = long long int*; _OutputIterator = array<long long int, 300100>]':
a.cc:31:16:   required from here
   31 |     partial_sum(p.begin() + 1, p.begin() + 2 * m + 1, p);
      |     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:270:7: error: no match for 'operator*' (operand type is 'std::array<long long int, 300100>')
  270 |       *__result = __value;
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:274:12: error: no match for 'operator++' (operand type is 'std::array<long long int, 300100>')
  274 |           *++__result = __value;
      |            ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:276:14: error: no match for 'operator++' (operand type is 'std::array<long long int, 300100>')
  276 |       return ++__result;
      |              ^~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
const int N=100100;
long long n,m,t3,t4,a[N*2],sum;
long long ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>t3;
    for(int i=2;i<=n;++i)
    {
        int d,t1,t2;
        cin>>t4;
        t1=t3;t2=t4;
        if(t2<t1) t2+=m;
        d=t2-t1;
        ans+=d;
        if(d>1)
        {
            a[t1+2]++;
            a[t2+1]-=d;
            a[t2+2]+=d-1;
        }    
        t3=t4;
    }
    sum=0;
    for(int i=1;i<=2*m;++i)
    {
        sum+=a[i];
        a[i]=sum;
    }
    sum=0;
    int maxx=0;
    for(int i=1;i<=2*m;++i)
    {
        sum+=a[i];
        a[i]=sum;
    }
    for(int i=m+1;i<=2*m;++i)
    {
        a[i-m]+=a[i];
        maxx=max(a[i-m],maxx);
    }
    cout<<ans-maxx<<endl;      
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: no matching function for call to 'max(long long int&, int&)'
   42 |         maxx=max(a[i-m],maxx);
      |              ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:42:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   42 |         maxx=max(a[i-m],maxx);
      |              ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

int \, M;
int v[100005];

class BinaryIndexedTree
{
public:
    int aib[100005];

    void U(int pos, int val)
    {
        for(; pos <= M; pos += (pos & (-pos)))
            aib[pos] += val;
    }

    void update(int st, int dr, int val)
    {
        if(st > dr) return;
        U(st, val);
        U(dr + 1, -val);
    }

    int Q(int pos)
    {
        int ans = 0;
        for(; pos > 0; pos -= (pos &(-pos)))
            ans += aib[pos];
        return ans;
    }
}A, B;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &M);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]);

    for(int u = 1; u < N; u++)
    {
        int p1 = v[u];
        int p2 = v[u + 1];

        if(p1 < p2)
        {
            B.update(1, p1, p2 - p1);

            A.update(p1 + 1, p2, -1);
            B.update(p1 + 1, p2, p2 + 1);

            B.update(p2 + 1, M, p2 - p1);
        }
        else
        {
            A.update(1, p2, -1);
            B.update(1, p2, p2 + 1);

            B.update(p2 + 1, p1, M - p1 + p2);

            A.update(p1 + 1, M, -1);
            B.update(p1 + 1, M, M + p2);
        }
    }

    int mn = 1 << 30;
    for(int i = 1; i <= M; i++)
    {
        int x = A.Q(i) * i + B.Q(i);
        mn = min(mn, x);
    }

    printf("%d\n", mn);

    return 0;
}


Compiler output:
a.cc:7:5: error: stray '\' in program
    7 | int \, M;
      |     ^
a.cc:7:6: error: expected unqualified-id before ',' token
    7 | int \, M;
      |      ^
a.cc: In function 'int main()':
a.cc:44:20: error: 'N' was not declared in this scope
   44 |     scanf("%d%d", &N, &M);
      |                    ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long LL;


int main(){
//    freopen("test.txt", "r", stdin);
    LL n, m, pre, now;
    scanf("%lld%lld%lld", &n, &m, &pre);
    vector<LL> a(m+2, 0);
    vector<LL> b(m+2, 0);
    for (int i = 1; i < n; i++) {
        scanf("%lld", &now);
        if (now > pre) {
            b[1] += now - pre;
            b[pre + 1] -= now - pre;
            b[now + 1] += now - pre;
            a[pre+1] -= 1;
            a[now+1] += 1;
            b[pre + 1] += now + 1;
            b[now + 1] -= now - 1;
        }
        else { // now < pre
            b[now + 1] += now - pre + m;
            b[pre + 1] -= now - pre + m;
            a[1] -= 1;
            a[now + 1] += 1;
            b[1] += now + 1;
            b[now + 1] -= now + 1;
            a[pre + 1] -= 1;
            b[pre + 1] += now + m + 1;
        }
        pre = now;
    }
    LL ret = INT_MAX;
    for (int i = 1; i <= m; i++) {
        a[i] += a[i-1];
        b[i] += b[i-1];
        ret = min(a[i]*(LL)i + b[i], ret);
    }
    cout << ret << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:14: error: 'INT_MAX' was not declared in this scope
   38 |     LL ret = INT_MAX;
      |              ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 |
Language: C++

#include <iostream>
using namespace std;

const int MAXM=100010;
int m,n;
int segment[MAXM*2];
int segexit[MAXM*2];
int gensum[MAXM*2];
int main() {
	memset(segment,0,sizeof(segment));
	memset(segexit,0,sizeof(segexit));
	int result = 0;
	cin>>n>>m;
	int last; cin>>last;
	for (int i=1,now;i<n;i++,last=(now-1)%6+1) {
		cin>>now;
		if (now<last) now+=6;
		result += now-last;
		segment[last+2]++;
		segment[now+1]--;
		segexit[now] += now-last-1;
	}
	memset(gensum,0,sizeof(gensum));
	for (int i=0,step=0,last=0;i<=m*2;i++) {
		step += segment[i];
		last += step;
		gensum[i] += last;
		last -= segexit[i];
	}
	int mmax=0;
	for (int i=1;i<=m;i++) {
		int tt = gensum[i]+gensum[i+m];
		if (tt>mmax)
			mmax = tt;
	}
	cout<<result-mmax<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'memset' was not declared in this scope
   10 |         memset(segment,0,sizeof(segment));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <bits/stdc++.h>

using namespace std;

int n,m,i,j,a[100005];
long long s[200005];

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
		a[i]--;
	}
	
	long long tot = 0;
	
	for(i = 1; i < n; i++){
		int l = a[i - 1];
		int r = a[i];
		
		if(l <= r){
			s[l + 2]++;
			s[r + 1]--;
			s[r + 1] -= r - l - 1;
			s[r + 2] += r - l - 1;
		}
		else{
			r += m;
			s[l + 2]++;
			s[r + 1]--;
			s[r + 1] -= r - l - 1;
			s[r + 2] += r - l - 1;
		}
		
		tot += r - l;
	}
	
	for(i = 1; i < 2 * m; i++)
	s[i] = s[i - 1] + s[i];
	for(i = 1; i < 2 * m; i++)
	s[i] = s[i - 1] + s[i];
	
	long long res = 1e18;
	
	for(i = 0; i < m; i++)
	res = min(res, tmp - (s[i] + s[i + m]));
	
	printf("%lld\n", res);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:24: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   47 |         res = min(res, tmp - (s[i] + s[i + m]));
      |                        ^~~
      |                        tm
Language: C++

#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-8

typedef pair<int,int> pii ;
typedef long long ll ;

int n,m;
int l[100005];
pair<ll,ll> p[100005],p2[100005];  //<?x,?>

inline void update(ll a,l b)
{
	if(b>a)
	{
		p[b+1].second+=b-a;
		p[a+1].first--;
		p[a+1].second+=b+1;
		p[b+1].first++;
		p[b+1].second-=b+1;
		p[1].second+=b-a;
		p[a+1].second-=b-a;
	}
	else
	{
		p[a+1].first--;
		p[a+1].second+=b+1+m;
		p[b+1].second+=m-a+b;
		p[a+1].second-=m-a+b;
		p[1].first--;
		p[1].second+=b+1;
		p[b+1].first++;
		p[b+1].second-=b+1;
	}
}

int main()
{
	ll ans=1e18+7;
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>l[i];
	for(int i=2;i<=n;i++) 
	{
		update((ll)l[i-1],(ll)l[i]);
//		memset(p2,0,sizeof(p2));
//		p2[1]=p[1];
//		for(int j=2;j<=m;j++)
//		{
//			p2[j].first=p2[j-1].first+p[j].first;
//			p2[j].second=p2[j-1].second+p[j].second;
//		}
//		for(int j=1;j<=m;j++) cout<<p2[j].first<<" "<<p2[j].second<<endl;
//		system("pause");
	}
	for(int i=2;i<=m;i++)
	{
		p[i].first+=p[i-1].first;
		p[i].second+=p[i-1].second;
	}

	for(int i=1;i<=m;i++) ans=min(ans,p[i].first*(ll)i+p[i].second);
	cout<<ans;
	return 0;
}

Compiler output:
a.cc:31:25: error: 'l' is not a type
   31 | inline void update(ll a,l b)
      |                         ^
Language: C++

#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-8

typedef pair<int,int> pii ;
typedef long long ll ;

int n,m;
int l[100005];
pii p[100005];  //<?x,?>

inline void update(int a,int b)
{
	if(b>a)
	{
		p[b+1].second+=b-a;
		p[a+1].first--;
		p[a+1].second+=b+1;
		p[b+1].first++;
		p[b+1].second-=b+1;
		p[1].second+=b-a;
		p[a+1].second-=b-a;
	}
	else
	{
		p[a+1].first--;
		p[a+1].second+=b+1+m;
		p[b+1].second+=m-a+b;
		p[a+1].second-=m-a+b;
		p[1].first--;
		p[1].second+=b;
		p[b+1].first++;
		p[b+1].second-=b;
	}
}

int main()
{
	int ans=INF;
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>l[i];
	for(int i=2;i<=n;i++) update(l[i-1],l[i]);
	
	for(int i=2;i<=m;i++)
	{
		p[i].first+=p[i-1].first;
		p[i].second+=p[i-1].second;
//	}for(int i=1;i<=m;i++) cout<<p[i].first<<" "<<p[i].second<<endl;
	for(int i=1;i<=m;i++) ans=min(ans,p[i].first*i+p[i].second);
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:2: error: expected '}' at end of input
   71 | }
      |  ^
a.cc:57:1: note: to match this '{'
   57 | {
      | ^