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

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

template<class T,class F>
struct segtree{
  int n;
  T e;
  F f;
  std::vector<T> dat;

  segtree(){}
  segtree(int sz,T _e,F _f):e(_e),f(_f){
    n = 1;
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
  }
  segtree(std::vector<T> const& v,T _e,F _f):e(_e),f(_f){
    build(v);
  }
  void build(std::vector<T> const& v){
    n = 1;
    int sz = v.size();
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
    for(int i=0;i<sz;++i){
      dat[i+n] = v[i];
    }
    for(int i=n-1;i>0;--i){
      dat[i] = f(dat[i<<1],dat[i<<1|1]);
    }
  }
  void set(int p,T v){
    for(dat[p+=n]=v;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  void increment(int p){
    for(dat[p+=n]=1;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  T query(int l,int r){
    T res = e;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
      if(l&1){
        res = f(res,dat[l]);
        l++;
      }
      if(r&1){
        r--;
        res = f(res,dat[r]);
      }
    }
    return res;
  }
  T operator[](int k){
    return query(k,k+1);
  }
};

vector<int64_t> frac;

signed main(){

  int n;
  cin>>n;
  frac.resize(n+1);
  frac[0] = frac[1] = 1;
  for(int64_t i=2;i<=n;++i)frac[i]=frac[i-1]*i;
  vector<int64_t> a(n),b(n);
  for(auto& ai:a)cin>>ai;
  for(auto& bi:b)cin>>bi;

  auto get = [](vector<int> const& a){
    int n = a.size();
    auto sum = [](auto a,auto b){return a+b;};
    segtree<int,decltype(sum)> seg(n+1,0,sum);

    int k = 0;
    for(int i=0;i<n;++i){
      int t = seg.query(0,a[i]);
      k += (a[i]-t-1)*frac[n-i-1];
      seg.increment(a[i]);
    }
    return k;
  };

  cout<<abs(get(a)-get(b))<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:88:16: error: no match for call to '(main()::<lambda(const std::vector<int>&)>) (std::vector<long int>&)'
   88 |   cout<<abs(get(a)-get(b))<<endl;
      |             ~~~^~~
a.cc:88:16: note: candidate: 'int (*)(const std::vector<int>&)' (conversion)
a.cc:88:16: note:   candidate expects 2 arguments, 2 provided
a.cc:74:14: note: candidate: 'main()::<lambda(const std::vector<int>&)>'
   74 |   auto get = [](vector<int> const& a){
      |              ^
a.cc:74:14: note:   no known conversion for argument 1 from 'std::vector<long int>' to 'const std::vector<int>&'
a.cc:88:23: error: no match for call to '(main()::<lambda(const std::vector<int>&)>) (std::vector<long int>&)'
   88 |   cout<<abs(get(a)-get(b))<<endl;
      |                    ~~~^~~
a.cc:88:23: note: candidate: 'int (*)(const std::vector<int>&)' (conversion)
a.cc:88:23: note:   candidate expects 2 arguments, 2 provided
a.cc:74:14: note: candidate: 'main()::<lambda(const std::vector<int>&)>'
   74 |   auto get = [](vector<int> const& a){
      |              ^
a.cc:74:14: note:   no known conversion for argument 1 from 'std::vector<long int>' to 'const std::vector<int>&'
Language: C++

#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> P(N),Q(N),R(N);
  int i;
  for(i=0;i<N;i++){
    cin >> P[i];
    R[i]=i+1;
  }
  for(i=0;i<N;i++){
    cin >> Q[i];
  }
  int a,b,c=1;
  bool Pflag,Qflag;
  do{
    Pflag=true;Qflag=true;
    for(i=0;i<N;i++){
      if(P[i]!=R[i])Pflag=false;
      if(Q[i]!=R[i])Qflag=false;
    }
    if(Pflag)a=c;
    if(Qflag)b=c;
    c++;
  }while(next_permutation(R.begin(),R.end()); 
  cout << abs(a-b) <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:45: error: expected ')' before ';' token
   29 |   }while(next_permutation(R.begin(),R.end());
      |         ~                                   ^
      |                                             )
Language: C++

#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> P(N),Q(N),R(N);
  for(i=0;i<N;i++){
    cin >> P[i];
    R[i]=i+1;
  }
  for(i=0;i<N;i++){
    cin >> Q[i];
  }
  int a,b,c=1:
  bool Pflag,Qflag;
  do{
    Pflag=true;Qflag=true;
    for(i=0;i<N;i++){
      if(P[i]!=R[i])Pflag=false;
      if(Q[i]!=R[i])Qflag=false;
    }
    if(Pflag)a=c;
    if(Qflag)b=c;
    c++;
  }while(next_permutation(R.begin(),R.end()); 
  cout << abs(a-b) <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   for(i=0;i<N;i++){
      |       ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i=0;i<N;i++){
      |       ^
a.cc:17:14: error: expected ',' or ';' before ':' token
   17 |   int a,b,c=1:
      |              ^
a.cc:20:5: error: 'Pflag' was not declared in this scope
   20 |     Pflag=true;Qflag=true;
      |     ^~~~~
a.cc:20:16: error: 'Qflag' was not declared in this scope
   20 |     Pflag=true;Qflag=true;
      |                ^~~~~
a.cc:21:9: error: 'i' was not declared in this scope
   21 |     for(i=0;i<N;i++){
      |         ^
a.cc:28:45: error: expected ')' before ';' token
   28 |   }while(next_permutation(R.begin(),R.end());
      |         ~                                   ^
      |                                             )
Language: C++

#include<iostream>
#include<math.h>
#include<vector>
#include<algolithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> P(N),Q(N),R(N);
  for(i=0;i<N;i++){
    cin >> P[i];
    R[i]=i+1;
  }
  for(i=0;i<N;i++){
    cin >> Q[i];
  }
  int a,b,c=1:
  bool Pflag,Qflag;
  do{
    Pflag=true;Qflag=true;
    for(i=0;i<N;i++){
      if(P[i]!=R[i])Pflag=false;
      if(Q[i]!=R[i])Qflag=false;
    }
    if(Pflag)a=c;
    if(Qflag)b=c;
    c++;
  }while(next_permutation(R.begin(),R.end()); 
  cout << abs(a-b) <<endl;
}

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

#include<iostream>
#include<math>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> P(N),Q(N),R(N);
  for(i=0;i<N;i++){
    cin >> P[i];
    R[i]=i+1;
  }
  for(i=0;i<N;i++){
    cin >> Q[i];
  }
  int a,b,c=1:
  bool Pflag,Qflag;
  do{
    Pflag=true;Qflag=true;
    for(i=0;i<N;i++){
      if(P[i]!=R[i])Pflag=false;
      if(Q[i]!=R[i])Qflag=false;
    }
    if(Pflag)a=c;
    if(Qflag)b=c;
    c++;
  }while(next_permutation(R.begin(),R.end()); 
  cout << abs(a-b) <<endl;
}

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

#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> p(n), q(n), s(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];
    iota(s.begin(),  s.end(), 1);

    int a, b, cnt = 1;
    do{
        vector<int> w(n);
        w = s;
        if(w == p) a = cnt;
        if(w == q) b = cnt;
        cnt++;
    }while(next_permutation(s.begin(), s.end()));

    cout << abs(a-b) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: 'iota' was not declared in this scope
   28 |     iota(s.begin(),  s.end(), 1);
      |     ^~~~
Language: C++

NR == 1 {
    n = $1
}
NR == 2 {
    split($0, p)
}
NR == 3 {
    split($0, q)
}
END {

    x = 0
    y = 0

    for (_idx = 0; ;++_idx) {
        idx = _idx
        r[n] = 1
        for (k = 2; k <= n; ++k) {
            r[n + 1 - k] = 1 + (idx % k)
            idx = int(idx / k)
        }
        if (idx > 0) break;

        for (i = 1; i <= n; ++i) b[i] = 1;
        b[r[1]] = 0;
        for (k = 2; k <= n; ++k) {
            count = 1
            for (j = 1; j <= n; ++j) {
                if (b[j]) {
                    if (count == r[k]) {
                        r[k] = j
                        b[j] = 0
                        break
                    }
                    count++
                }
            }
        }

        # check
        eq = 1
        for (i = 1; i <= n; ++i) if (r[i] != p[i]) eq = 0;
        if (eq) x = _idx;
        eq = 1
        for (i = 1; i <= n; ++i) if (r[i] != q[i]) eq = 0;
        if (eq) y = _idx;

    }

    print(x > y ? x - y : y - x)
}


Compiler output:
a.cc:40:11: error: invalid preprocessing directive #check
   40 |         # check
      |           ^~~~~
a.cc:1:1: error: 'NR' does not name a type
    1 | NR == 1 {
      | ^~
a.cc:4:1: error: 'NR' does not name a type
    4 | NR == 2 {
      | ^~
a.cc:7:1: error: 'NR' does not name a type
    7 | NR == 3 {
      | ^~
a.cc:10:1: error: 'END' does not name a type
   10 | END {
      | ^~~
Language: C++

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

int perm(int n){
  if(n==0){
    return 1;
  }else{
    return n*perm(n-1);
  }
}


int main(){
  int N;
  cin>>N;
  vector<int> P(N),Q(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>Q.at(i);
  }
  int a,b;
  
  set<int> A,B;
  for(int i=0;i<N;i++){
    A.insert(i+1);
    B.insert(i+1);
  }
  
  int sum1=0;
  int sum2=0;
  for(i=0;i<N;i++){
    int count1=0;
    int count2=0;
    for(int n:A){
      if(n<P.at(i)){
        count1++;
      }
    }
    for(int n:B){
      if(n<Q.at(i)){
        count2++;
      }
    }
    sum1+=count1*perm(N-1-i);
    sum2+=count2*perm(N-1-i);
    A.erase(P.at(i));
    B.erase(Q.at(i));
  }
  if(sum1-sum2>0){
    cout<<sum1-sum2<<endl;
  }else{
    cout<<sum2-sum1<<endl;
  }
}
  

  
      

Compiler output:
a.cc: In function 'int main()':
a.cc:33:7: error: 'i' was not declared in this scope
   33 |   for(i=0;i<N;i++){
      |       ^
Language: C++

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

int perm(int n){
  if(n==0){
    return 1;
  }else{
    return n*perm(n-1);
  }
}


int main(){
  int N;
  cin>>N;
  vector<int> P(N),Q(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>Q.at(i);
  }
  int a,b;
  
  set<int> A,B;
  fo(int i=0;i<N;i++){
    A.insert(i+1);
    B.insert(i+1);
  }
  
  int sum1=0;
  int sum2=0;
  for(i=0;i<N;i++){
    int count1=0;
    int count2=0;
    for(int n:A){
      if(n<P.at(i)){
        count1++;
      }
    }
    for(int n:B){
      if(n<Q.at(i)){
        count2++;
      }
    }
    sum1+=count1*perm(N-1-i);
    sum2+=count2*perm(N-1-i);
    A.erase(P.at(i));
    B.erase(Q.at(i));
  }
  if(sum1-sum2>0){
    cout<<sum1-sum2<<endl;
  }else{
    cout<<sum2-sum1<<endl;
  }
}
  

  
      

Compiler output:
a.cc: In function 'int main()':
a.cc:26:6: error: expected primary-expression before 'int'
   26 |   fo(int i=0;i<N;i++){
      |      ^~~
a.cc:26:14: error: 'i' was not declared in this scope
   26 |   fo(int i=0;i<N;i++){
      |              ^
Language: C++

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

int perm(int n){
  if(n==0){
    return 1;
  }else{
    return n*perm(n-1);
  }
}


int main(){
  int N;
  cin>>N;
  vector<int> P(N),Q(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>Q.at(i);
  }
  int a,b;
  
  set<int> A,B;
  fo(int i=0;i<N;i++){
    A.insert(i+1);
    B.insert(i+1);
  }
  
  int sum1=0;
  int sum2=0;
  for(i=0;i<N;i++){
    count1=0;
    count2=0;
    for(int n:A){
      if(n<P.at(i)){
        count1++;
      }
    }
    for(int n:B){
      if(n<Q.at(i)){
        count2++;
      }
    }
    sum1+=count1*perm(N-1-i);
    sum2+=count2*perm(N-1-i);
    A.erase(P.at(i));
    B.erase(Q.at(i));
  }
  if(sum1-sum2>0){
    cout<<sum1-sum2<<endl;
  }else{
    cout<<sum2-sum1<<endl;
  }
}
  

  
      

Compiler output:
a.cc: In function 'int main()':
a.cc:26:6: error: expected primary-expression before 'int'
   26 |   fo(int i=0;i<N;i++){
      |      ^~~
a.cc:26:14: error: 'i' was not declared in this scope
   26 |   fo(int i=0;i<N;i++){
      |              ^
a.cc:34:5: error: 'count1' was not declared in this scope
   34 |     count1=0;
      |     ^~~~~~
a.cc:35:5: error: 'count2' was not declared in this scope
   35 |     count2=0;
      |     ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;

    int p[n];
    rep(i,n)cin >> p[i];
    int q[n];
    rep(i,n)cin >> q[i];
    int r[n];
    rep(i,n) r[i] = i + 1;

    int a = 1;
    while(true){
        int flag = 1;
        rep(i,n){
            if(r[i] != p[i])flag = 0;
        }
        if(flag)break;
        next_permutation(r, r+n);
        a++;
    }

    int r[n];
    rep(i,n) r[i] = i + 1;
    int b = 1;
    while(true){
        int flag = 1;
        rep(i,n){
            if(r[i] != q[i])flag = 0;
        }
        if(flag)break;
        next_permutation(r, r+n);
        b++;
    }

    cout << abs(a - b) << endl;
    return 0;
}
 
 


Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: redeclaration of 'int r [n]'
   33 |     int r[n];
      |         ^
a.cc:19:9: note: 'int r [n]' previously declared here
   19 |     int r[n];
      |         ^
Language: C++

#include <iostream>

bool areEqual(int a[], int b[], int N){
  for(int i=0;i<N;++i){
    if(a[i]!=b[i]) return false;
  }
  return true;
}

int main(){
 int N, a, b, permutation = 1;
 std::cin>>N;
 int P[N], Q[N], T[N];
 for(int i=0;i<N;++i){
   std::cin>>P[i];
   T[i] = i+1;
 }

  for(int i=0;i<N;++i){
   std::cin>>Q[i];
 }

 if(areEqual(T, P, N)) a = permutation;
 if(areEqual(T, Q, N)) b = permutation;

while(std::next_permutation(T, T + N)){
  ++permutation;
   if(areEqual(T, P, N)) a = permutation;
   if(areEqual(T, Q, N)) b = permutation;
}

std::cout<<abs(a-b);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:12: error: 'next_permutation' is not a member of 'std'; did you mean 'is_permutation'?
   26 | while(std::next_permutation(T, T + N)){
      |            ^~~~~~~~~~~~~~~~
      |            is_permutation
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

    int n;
    cin >> n;

    vector<int> x(n), p(n), q(n);

    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }

    for (int i = 0; i < n; i++) {
        x[i] = i + 1;
    }

    int a = 0, b = 0, counter = 0;

    do {
        counter++;
        if (p == x) {
            a = counter;
        }

        if (q == x) {
            b = counter;
        }
    } while (next_permutation(x.begin(), x.end()));

    cout << abs(a - b) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:14: error: 'next_permutation' was not declared in this scope
   38 |     } while (next_permutation(x.begin(), x.end()));
      |              ^~~~~~~~~~~~~~~~
Language: C++

// ABC150C.cpp :
//#include "pch.h"
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int N;
	cin >> N;
	int num = 0;
	vector<int>v(N);
	for (int i = 0; i < N; i++)
	{
		v.at(i) = i+1;
	}
	vector<int>P(N);
	int p = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> P.at(i);
		p += P.at(i)*(int)pow(10, N - i - 1);
	}

	vector<int>Q(N);
	int q = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> Q.at(i);
		q += Q.at(i)*(int)pow(10, N - i - 1);
	}

	int count = 0;
	int a = 0;
	int b = 0;
	do
	{
		int num = 0;
		for (int i = 0; i < N; i++)
		{
			num+= v.at(i) * (int)pow(10, N - i - 1);
		}
		count++;
		if (num==p)
		{
			a = count;
		}
		if (num==q)
		{
			b = count;
		}
	} while (next_permutation(v.begin(),v.end()));
	cout << abs(a - b) << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:35: error: 'pow' was not declared in this scope
   22 |                 p += P.at(i)*(int)pow(10, N - i - 1);
      |                                   ^~~
a.cc:30:35: error: 'pow' was not declared in this scope
   30 |                 q += Q.at(i)*(int)pow(10, N - i - 1);
      |                                   ^~~
a.cc:41:46: error: 'pow' was not declared in this scope
   41 |                         num+= v.at(i) * (int)pow(10, N - i - 1);
      |                                              ^~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int32_t;
using Uint = uint32_t;
constexpr long long int mod = 1e9 + 7;


int main() {

	Int N; cin >> N;
	vector<Int> P(N), Q(N);
	rep(i, N)cin >> P[i];
	rep(i, N)cin >> Q[i];
	
	Int a = 0, b = 0;
	Int cnt = 0;
	vector<Int> v(N);
	rep(i, N)v[i] = i + 1;

	do {

		cnt++;

		bool flag_p = true;
		rep(i, N) {
			if (v[i] != P[i]) {
				flag_p = false;
				break;
			}
		}

		bool flag_q = true;

		rep(i, N) {
			if (v[i] != Q[i]) {
				flag_q = false;
				break;
			}
		}

		if (flag_p) {
			a = cnt;
		}

		if (flag_q) {
			b = cnt;
		}

	} while (next_permutation(v.begin(), v.end()));

	cout << abs(a - b) << endl;

}

Compiler output:
a.cc:17:14: error: 'uint32_t' does not name a type
   17 | using Uint = uint32_t;
      |              ^~~~~~~~
a.cc:13:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   12 | #include <cmath>
  +++ |+#include <cstdint>
   13 | #define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
a.cc: In function 'int main()':
a.cc:62:18: error: 'next_permutation' was not declared in this scope
   62 |         } while (next_permutation(v.begin(), v.end()));
      |                  ^~~~~~~~~~~~~~~~
Language: C++

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

int main() {
  int n;
  vector<int>p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int>ele(n); cin >> ele[i] = i+1;
  map<vector<int>, int> mp;
  
  do{
    mp[ele] = mp.size();
  } while(next_permutaion(ele.begin(), ele.end()));
  
  int ans = abs(mp[p]-mp[q]);
  cout << ans << endl;
  
  return 0;
}


Compiler output:
a.cc:2:2: error: invalid preprocessing directive #typedef
    2 | #typedef rep(i,n) for(int i=0; i<(n); ++i)
      |  ^~~~~~~
a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   rep(i,n) cin >> p[i];
      |       ^
a.cc:8:3: error: 'rep' was not declared in this scope
    8 |   rep(i,n) cin >> p[i];
      |   ^~~
a.cc:15:11: error: 'next_permutaion' was not declared in this scope
   15 |   } while(next_permutaion(ele.begin(), ele.end()));
      |           ^~~~~~~~~~~~~~~
Language: C++

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

int main() {
  int n;
  vector<int>p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int>ele(n); cin >> ele[i] = i+1;
  map<vector<int>, int> mp;
  
  do{
    mp[ele] = mp.size();
  } while(next_permutaion(ele.begin(), ele.end()));
  
  int ans = abs(mp[p]-mp[q]);
  cour << ans << endl;
  
  return 0;
}

Compiler output:
a.cc:2:2: error: invalid preprocessing directive #typedef
    2 | #typedef rep(i,n) for(int i=0; i<(n); ++i)
      |  ^~~~~~~
a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   rep(i,n) cin >> p[i];
      |       ^
a.cc:8:3: error: 'rep' was not declared in this scope
    8 |   rep(i,n) cin >> p[i];
      |   ^~~
a.cc:15:11: error: 'next_permutaion' was not declared in this scope
   15 |   } while(next_permutaion(ele.begin(), ele.end()));
      |           ^~~~~~~~~~~~~~~
a.cc:18:3: error: 'cour' was not declared in this scope
   18 |   cour << ans << endl;
      |   ^~~~
Language: C++

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


int main(void){
    int n = 0;
    int P[9];
    int Q[9];
    int a = 0, b = 0, cnt = 0;
    int C[9];
    int Add[9];

    scanf("%d", &n);

    for(int i = 0; i < n; i++){ 
        scanf("%d", &P[i]);
    }
    for(int i = 0; i < n; i++){ 
        scanf("%d", &Q[i]);
    }

    for(int i = 0; i < n; i++){ 
        Add[i] = 0;
    }

    int func(int cnt){
        //n文字目になった時、同じ順番かチェック
        if(cnt == n-1){
            for(int i = 0; i < n; i++){
                if(P[i] == C[i]){
                    if(i == n - 1){
                        a = cnt;
                    }
                }else{
                    break;
                }
            }
            for(int i = 0; i < n; i++){
                if(Q[i] == C[i]){
                    if(i == n - 1){
                        b = cnt;
                    }
                }else{
                    break;
                }
            }
            return 0;
        }
        for(int i = 0; i < n; i++){
            
        }
        func(cnt + 1);
    }

    printf("%d\n", abs(a-b));
    return 0;

} 


Compiler output:
a.cc: In function 'int main()':
a.cc:27:22: error: a function-definition is not allowed here before '{' token
   27 |     int func(int cnt){
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int P[2][10];
  for (int i = 0; i < N; i ++) cin >> P[0][i];
  for (int i = 0; i < N; i ++) cin >> P[1][i];
  int k[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
  int an[2];
  int Q[9];
  Q[0] = 1;
  for (int i = 1; i < 9; i ++) Q[i] = Q[i - 1] * i;
  for (int i = 0; i < 2; i ++) {
    for (int j = 0; j < N; j ++) {
      an[i] += Q[N - j - 1] * P[i][j] * (k[P[i][j]] - 1);
      for (int l = P[i][j] + 1; l <= N; l ++) k[l] --;
    }
  }
  cout << max(a[0] - a[1], a[1] - a[0]) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: 'a' was not declared in this scope
   20 |   cout << max(a[0] - a[1], a[1] - a[0]) << endl;
      |               ^
Language: C++

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int N, x, y;
  cin >> N;

  vector<int> P(N);
  vector<int> Q(N);

  REP(i, N) cin >> P[i];
  REP(i, N) cin >> Q[i];

  vector<int> v(N);
  iota(ALL(v), 1);
  int cnt = 1;
  do{
    if(v == P) x = cnt;
    if(v == Q) y = cnt;
    cnt++;
  }while(next_permutation(ALL(v)));

  cout << abs(x-y) << endl;


  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:3: error: 'iota' was not declared in this scope
   51 |   iota(ALL(v), 1);
      |   ^~~~
Language: C++

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

int main() {
	int n;
	cin >> n;
	vector<int>P(n), Q(n),R(n);
	rep(i, n) {
		cin >> P[i] >> Q[i];
		R[i] = i+1;
	}
	map<vector<int>, int>mp;
	do {
		mp[R] = mp.size();
	} while (next_permutaton(R.begin(), R.end()));
	int ans = abs(mp[P] - mp[Q]);
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: 'next_permutaton' was not declared in this scope
   19 |         } while (next_permutaton(R.begin(), R.end()));
      |                  ^~~~~~~~~~~~~~~
Language: C++

#include <cstdint>
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>
#include <string>


int main()
{
    int n;
    std::cin >> n;
    std::vector<int> na(n);
    std::vector<int> nb(n);
    for ( int _n = 0; _n < n; _n++ ) {
        na[_n] = _n+1;
        nb[_n] = _n+1;
    }

    int a = 0;
    int b = 0;
    for ( int _n = 0; _n < n; _n++ ) {
        int p;
        std::cin >> p;
        auto it_a = std::find(na.begin(), na.end(), p);
        auto sz_a = std::distance(na.begin(), it_a);
        a += kaijo((n-_n)-1) * sz_a;
        na.erase(it_a);
    }
    for ( int _n = 0; _n < n; _n++ ) {
        int p;
        std::cin >> p;
        auto it_b = std::find(nb.begin(), nb.end(), p);
        auto sz_b = std::distance(nb.begin(), it_b);
        b += kaijo((n-_n)-1) * sz_b;
        nb.erase(it_b);
    }

    std::cout << std::abs(a-b) << std::endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:14: error: 'kaijo' was not declared in this scope
   27 |         a += kaijo((n-_n)-1) * sz_a;
      |              ^~~~~
a.cc:35:14: error: 'kaijo' was not declared in this scope
   35 |         b += kaijo((n-_n)-1) * sz_b;
      |              ^~~~~
Language: C

#include <stdio.h>

int main(void){
    int N;
    char s;
    int ans;
    
    scanf("%d", &N);
    scanf("%c", &s);
    
    for (int i=0; i<=N-3; i++){
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
}

Compiler output:
main.c: In function 'main':
main.c:12:14: error: subscripted value is neither array nor pointer nor vector
   12 |         if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
      |              ^
main.c:12:29: error: subscripted value is neither array nor pointer nor vector
   12 |         if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
      |                             ^
main.c:12:46: error: subscripted value is neither array nor pointer nor vector
   12 |         if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
      |                                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int n; cin >> n;
  int p[n],q[n];
  FOR(i,0,n-1) cin >> p[i];
  FOR(i,0,n-1) cin >> q[i];

  int snuke[n];
  FOR(i,0,n-1) snuke[i] = i+1;

  int ansa,ansb;
  int ref = 0;

  do{
    ++ref;
    bool allp,allq;
    allp = allq = true;

    if(equal(p.begin(), p.end(), snuke.begin())) ansa = ref;
    if(equal(p.begin(), p.end(), snuke.begin())) ansa = ref;
  } while (next_permutation(snuke,snuke+n));

  cout << abs(ansa-ansb) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:16: error: request for member 'begin' in 'p', which is of non-class type 'int [n]'
   35 |     if(equal(p.begin(), p.end(), snuke.begin())) ansa = ref;
      |                ^~~~~
a.cc:35:27: error: request for member 'end' in 'p', which is of non-class type 'int [n]'
   35 |     if(equal(p.begin(), p.end(), snuke.begin())) ansa = ref;
      |                           ^~~
a.cc:35:40: error: request for member 'begin' in 'snuke', which is of non-class type 'int [n]'
   35 |     if(equal(p.begin(), p.end(), snuke.begin())) ansa = ref;
      |                                        ^~~~~
a.cc:36:16: error: request for member 'begin' in 'p', which is of non-class type 'int [n]'
   36 |     if(equal(p.begin(), p.end(), snuke.begin())) ansa = ref;
      |                ^~~~~
a.cc:36:27: error: request for member 'end' in 'p', which is of non-class type 'int [n]'
   36 |     if(equal(p.begin(), p.end(), snuke.begin())) ansa = ref;
      |                           ^~~
a.cc:36:40: error: request for member 'begin' in 'snuke', which is of non-class type 'int [n]'
   36 |     if(equal(p.begin(), p.end(), snuke.begin())) ansa = ref;
      |                                        ^~~~~
Language: C++

import java.io.*;
import java.util.*;
import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] P = new int[n], Q = new int[n];
        for(int i=0;i<n;i++) P[i]=sc.nextInt();
        for(int i=0;i<n;i++) Q[i]=sc.nextInt();
        int a = help(n,P), b = help(n,Q);
        System.out.println(Math.abs(a-b));
    }
    int help(int n, int[] a){
        // a is a permutation of n
        boolean[] used = new boolean[n+2];
        int ans = 0;
        int[] fac = new int[10];
        fac[0]=1;
        for(int i=1;i<10;i++) fac[i] = i*fac[i-1];
        for(int i=0;i<n;i++){
            int cnt = 0;
            for(int j=1;j<a[i];j++){
                if(!used[j]) cnt++;
            }
            used[a[i]] = true;
            ans += fac[n-1-i]*cnt;
        }
        return ans;
    }
}



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import static java.lang.System.in;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> p(n), q(n), permutation(n);
    for(auto&& p_i : p) {
        cin >> p_i;
    }
    for(auto&& q_i : q) {
        cin >> q_i;
    }
    iota(permutation.begin(), permutation.end(), 1);

    int a = 0, b = 0, count = 1;
    while(a == 0 || b == 0) {
        if (p == permutation) {
            a = count;
        }
        if (q == permutation) {
            b = count;
        }
        next_permutation(permutation.begin(), permutation.end());

        count++;
    }

    cout << abs(a - b) << endl;

    return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: expected '}' at end of input
   33 |     return 0;
      |              ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

/*
AtCoder ABC150 C "Count Order".
next_permutation().
*/
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vi;

int n;

bool jud_same(vi a,vi b){
	REP(i,n){
		if(a[i]==b[i]){}
		else return false;
	}
	return true;
}

int main(){
	cin>>n;
	
	vi p(n),q(n);
	REP(i,n) cin>>p[i];
	REP(i,n) cin>>q[i];
	
	vi v=p;
	sort(ALL(v));
	
	int cnt=1;
	int pn,qn;
	do{
		if(jud_array(v,p)) pn=cnt;
		if(jud_array(v,q)) qn=cnt;
		cnt++;
	}while(next_permutation(ALL(v)));

	cout<<abs(pn-qn)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:20: error: 'jud_array' was not declared in this scope
   36 |                 if(jud_array(v,p)) pn=cnt;
      |                    ^~~~~~~~~
a.cc:37:20: error: 'jud_array' was not declared in this scope
   37 |                 if(jud_array(v,q)) qn=cnt;
      |                    ^~~~~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;

void permutation(string s, int N, string target, int &count, bool &found) {
	if (found) return;
	if (s.length() == N) {		
		if (s == target) {
			found = true;
			return;
		}
		count++;
	}
	else {
		for (int i = 1; i <= N; i++) {
			if (s.find(to_string(i)) != string::npos) continue;
			permutation(s + to_string(i), N, target, count, found);
		}
	}
}

int main()
{
	int N;
	cin >> N;
	string s, P, Q;
	rep(i, N) {
		cin >> s;
		P += s;
	}
	rep(i, N) {
		cin >> s;
		Q += s;
	}

	int a = 1, b = 1;
	bool flag = false;
	permutation("", N, P, a, flag);
	flag = false;
	permutation("", N, Q, b, flag);
	cout << abs(a - b) << endl;

	return 0;	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:13: error: 'i' was not declared in this scope
   27 |         rep(i, N) {
      |             ^
a.cc:27:9: error: 'rep' was not declared in this scope
   27 |         rep(i, N) {
      |         ^~~
Language: C

#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void swap(int *x,int *y){int tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
//next_permutation
//from https://qiita.com/Nikkely/items/0ddca51b3c0e60afbaab
int next_permutation(int *a,int n){
    int x=-1,y=-1;
    for(int i=n-2;i>=0;i--)if(a[i]<a[i+1]){x=i;break;}
    for(int i=n-1;x!=-1&&i>=0;i--)if(a[x]<a[i]){y=i;break;}
    if(x==-1||y==-1)return 1;
    swap(&a[x],&a[y]);
    qsort(&a[x+1],n-(x+1),sizeof(int),asc_cmp);
    return 0;
}

int main(){
    int n;scanf("%d",&n);
    int p[20];for(int i=0;i<n;i++)scanf("%d",&p[i]);
    int q[20];for(int i=0;i<n;i++)scanf("%d",&q[i]);

    char p_str[20],q_str[20];
    for(int i=0;i<n;i++){
      p_str[i]=p[i]+'0';
      q_str[i]=q[i]+'0';
    }
    p_str[n]=q_str[n]='\0';

    int a[n];for(int i=1;i<=n;i++)a[i-1]=i;

    int index[2];
  	index[0]=index[1]=-1;
    char list[20];
    for(;1;){
        for(int j=0;j<n;j++)list[j]='0'+a[j];
        list[n]='\0';
        if(!strcmp(list,p_str))index[0]=i;
        if(!strcmp(list,q_str))index[1]=i;
        if(index[0]!=-1&&index[1]!=-1)break;
      	if(next_permutation(a,n))break;
    }
    
    printf("%d\n",abs(index[0]-index[1]));
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:38:41: error: 'i' undeclared (first use in this function)
   38 |         if(!strcmp(list,p_str))index[0]=i;
      |                                         ^
main.c:38:41: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <vector>
#include <numeric>

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

bool check(vector<int> arr_a, vector<int> arr_b)
{
    rep (i, 0, arr_a.size()) {
        if (arr_a[i] != arr_b[i]) return false;
    }
    return true;
}

int main()
{
    int N; cin >> N;
    vector<int> P(N), Q(N);
    rep (i, 0, N) cin >> P[i];
    rep (i, 0, N) cin >> Q[i];

    vector<int> nums(N);
    iota(nums.begin(), nums.end(), 1);
    int cnt = 0, a = 0 , b = 0;
    do {
        ++cnt;
        if (check(P, nums)) a = cnt;
        if (check(Q, nums)) b = cnt;
        if (a != 0 and b != 0) break;
    } while (next_permutation(nums.begin(), nums.end()));

    cout << abs(a - b) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:14: error: 'next_permutation' was not declared in this scope
   44 |     } while (next_permutation(nums.begin(), nums.end()));
      |              ^~~~~~~~~~~~~~~~
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> ps(n), qs(n);
  for (auto &&p : ps) {
    cin >> p;
  }
  for (auto &&q : qs) {
    cin >> q;
  }
  
  int a = 1, b = 1;
  {
    vector<int> xs(n);
    for (int i = 0; i < n; i++) {
      xs[i] = i + 1;
    }
    
    do {
      bool f = true;
      for (int i = 0; i < n; i++) {
        f &= (ps[i] == xs[i]);
      }
      if (f) {
        break;
      }
      a++;
    } while (next_permutation(as.begin(), as.end()));
  }
  {
    vector<int> xs(n);
    for (int i = 0; i < n; i++) {
      xs[i] = i + 1;
    }
    
    do {
      bool f = true;
      for (int i = 0; i < n; i++) {
        f &= (qs[i] == xs[i]);
      }
      if (f) {
        break;
      }
      b++;
    } while (next_permutation(as.begin(), as.end()));
  }
  
  cout << abs(a - b) << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:31: error: 'as' was not declared in this scope; did you mean 'xs'?
   31 |     } while (next_permutation(as.begin(), as.end()));
      |                               ^~
      |                               xs
a.cc:48:31: error: 'as' was not declared in this scope; did you mean 'xs'?
   48 |     } while (next_permutation(as.begin(), as.end()));
      |                               ^~
      |                               xs
Language: C++

#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

double dist(vector<int> x, vector<int> y, int i, int j)
{
	return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

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

	vector<int> q(n);
	for (int i = 0; i < n; i++) cin >> q[i];

	vector<int> vec(n);
	for (int i = 0; i < n; i++) vec[i] = i + 1;

	map<vector<int>, int> mp;
	do
	{
		mp[vec] = mp.size();
	} while (next_permutation(vec.begin(), vec.end()));

	cout << abs(mp[p] - mp[q]) << endl;
}

Compiler output:
a.cc: In function 'double dist(std::__debug::vector<int>, std::__debug::vector<int>, int, int)':
a.cc:108:21: error: 'pow' was not declared in this scope
  108 |         return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
      |                     ^~~
a.cc:108:16: error: 'sqrt' was not declared in this scope
  108 |         return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
      |                ^~~~
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for(int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  
  for(int i = 0; i < n; ++i) {
    cin >> q[i];
  }
  
  vector<int> v;
  for(int i = 0; i < n; ++i) {
  	v.push_back(i+1);
  }
  
  int t = 0;
  
  int a = 0, b = 0;
  
  do {
    ++t;
    if(v == p) {
      a = t;
    }
    if(v == q) {
      b = t;
    }
  }while(next_permutation(v.begin(), v.end());
  cout << abs(a-b);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:46: error: expected ')' before ';' token
   33 |   }while(next_permutation(v.begin(), v.end());
      |         ~                                    ^
      |                                              )
Language: Java

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    String n = scan.nextLine();
    String p = scan.nextLine();
    String q = scan.nextLine();

    List<Integer> pArray = Arrays.stream(p.split(" ")).map(Integer::valueOf)
        .collect(Collectors.toList());
    List<Integer> qArray = Arrays.stream(q.split(" ")).map(Integer::valueOf)
        .collect(Collectors.toList());

    int pans = 0;
    List<Integer> tmpLIst = new ArrayList<>();
    while (!pArray.isEmpty()) {
      tmpLIst.clear();
      tmpLIst.addAll(pArray);
      pans = pans + calc(tmpLIst);
      pArray.remove(0);
    }

    int qans = 0;
    while (!qArray.isEmpty()) {
      tmpLIst.clear();
      tmpLIst.addAll(qArray);
      qans = qans + calc(tmpLIst);
      qArray.remove(0);
    }
    System.out.println(pans >= qans ? pans - qans : qans - pans);
    scan.close();
  }

  static int calc(List<Integer> list) {

    if (list.size() == 1) {
      return 1;
    }

    int base = list.get(0);
    Collections.sort(list);
    int index = list.indexOf(base);

    int f = 1;
    for (int i = 1; i < list.size(); i++) {
      f = f * i;
    }
    return index * f;
  }
}

Compiler output:
Main.java:36: error: cannot find symbol
  static int calc(List<Integer> list) {
                  ^
  symbol:   class List
  location: class Main
Main.java:5: error: cannot find symbol
    Scanner scan = new Scanner(System.in);
    ^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
    Scanner scan = new Scanner(System.in);
                       ^
  symbol:   class Scanner
  location: class Main
Main.java:11: error: cannot find symbol
    List<Integer> pArray = Arrays.stream(p.split(" ")).map(Integer::valueOf)
    ^
  symbol:   class List
  location: class Main
Main.java:11: error: cannot find symbol
    List<Integer> pArray = Arrays.stream(p.split(" ")).map(Integer::valueOf)
                           ^
  symbol:   variable Arrays
  location: class Main
Main.java:12: error: cannot find symbol
        .collect(Collectors.toList());
                 ^
  symbol:   variable Collectors
  location: class Main
Main.java:13: error: cannot find symbol
    List<Integer> qArray = Arrays.stream(q.split(" ")).map(Integer::valueOf)
    ^
  symbol:   class List
  location: class Main
Main.java:13: error: cannot find symbol
    List<Integer> qArray = Arrays.stream(q.split(" ")).map(Integer::valueOf)
                           ^
  symbol:   variable Arrays
  location: class Main
Main.java:14: error: cannot find symbol
        .collect(Collectors.toList());
                 ^
  symbol:   variable Collectors
  location: class Main
Main.java:17: error: cannot find symbol
    List<Integer> tmpLIst = new ArrayList<>();
    ^
  symbol:   class List
  location: class Main
Main.java:17: error: cannot find symbol
    List<Integer> tmpLIst = new ArrayList<>();
                                ^
  symbol:   class ArrayList
  location: class Main
Main.java:43: error: cannot find symbol
    Collections.sort(list);
    ^
  symbol:   variable Collections
  location: class Main
12 errors
Language: C++

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

int f(vector<int> a)
{
    int n = a.size();
    vector<int> b(n);
    int x = 1;
    for (int &bb : b)
    {
        bb = x;
        x++;
    }
    int ret = 1;
    while (next_permutation(b.begin, b.end))
    {
        bool flag = true;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != b[i])
            {
                flag = false;
            }
        }
        if (flag)
        {
            break;
        }
        else
        {
            ret++;
        }
    }
    return ret;
}

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for (int &p : P)
    {
        cin >> p;
    }
    vector<int> Q(N);
    for (int &q : Q)
    {
        cin >> q;
    }

    int a = f(P);
    int b = f(Q);
    cout << abs(a - b) << endl;
}


Compiler output:
a.cc: In function 'int f(std::vector<int>)':
a.cc:15:28: error: no matching function for call to 'next_permutation(<unresolved overloaded function type>, <unresolved overloaded function type>)'
   15 |     while (next_permutation(b.begin, b.end))
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:2939:5: note: candidate: 'template<class _BIter> bool std::next_permutation(_BIter, _BIter)'
 2939 |     next_permutation(_BidirectionalIterator __first,
      |     ^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2939:5: note:   template argument deduction/substitution failed:
a.cc:15:28: note:   couldn't deduce template parameter '_BIter'
   15 |     while (next_permutation(b.begin, b.end))
      |            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2972:5: note: candidate: 'template<class _BIter, class _Compare> bool std::next_permutation(_BIter, _BIter, _Compare)'
 2972 |     next_permutation(_BidirectionalIterator __first,
      |     ^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2972:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

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

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

//--------------------------------------------------------------------

int fac(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    int P[n];
    for(int i=0; i<n; i++) cin >> P[i];    
    int Q[n];
    for(int i=0; i<n; i++) cin >> Q[i];
    int a = 0, b = 0, 
	for (int i = 0; i < n-1; i++) {
		if (P[i] != 1) {
			a += (P[i] - 1) * fac(n - i - 1);
		}
		if (Q[i] != 1) {
			b += (Q[i] - 1) * fac(n - i - 1);
		}
		for (int j = i + 1; j < n; j++) {
			if (P[i] < P[j]) {
				P[j] -= 1;
			}
			if (Q[i] < Q[j]) {
				Q[j] -= 1;
            }
        }
    }
    int ans = std::abs(a-b);
    cout << ans << endl;




    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: expected unqualified-id before 'for'
   26 |         for (int i = 0; i < n-1; i++) {
      |         ^~~
a.cc:26:25: error: 'i' was not declared in this scope
   26 |         for (int i = 0; i < n-1; i++) {
      |                         ^