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

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

int main(){
  int N;
  vector<int>num1(N);
  vector<int>num2(N);
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>num1(i);
  }
  for(int i=0;i<N;i++){
    cin>>num2(i);
  }
  vector<int> a(N);
  for(int i=0;i<N;i++){
    a(i)=i++;
  }
  map<vector<int>, int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
  return 0;
}
    
    
    
  
  
  
  
  
  
  
  
  
  
  


Compiler output:
a.cc: In function 'int main()':
a.cc:12:14: error: no match for call to '(std::vector<int>) (int&)'
   12 |     cin>>num1(i);
      |          ~~~~^~~
a.cc:15:14: error: no match for call to '(std::vector<int>) (int&)'
   15 |     cin>>num2(i);
      |          ~~~~^~~
a.cc:19:6: error: no match for call to '(std::vector<int>) (int&)'
   19 |     a(i)=i++;
      |     ~^~~
a.cc:21:3: error: 'map' was not declared in this scope
   21 |   map<vector<int>, int> mp;
      |   ^~~
a.cc:4:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    3 | #include<algorithm>
  +++ |+#include <map>
    4 | using namespace std;
a.cc:21:18: error: expected primary-expression before ',' token
   21 |   map<vector<int>, int> mp;
      |                  ^
a.cc:21:20: error: expected primary-expression before 'int'
   21 |   map<vector<int>, int> mp;
      |                    ^~~
a.cc:23:5: error: 'mp' was not declared in this scope
   23 |     mp[a]=mp.size();
      |     ^~
a.cc:26:15: error: 'mp' was not declared in this scope
   26 |   int ans=abs(mp[p]-mp[q]);
      |               ^~
a.cc:26:18: error: 'p' was not declared in this scope
   26 |   int ans=abs(mp[p]-mp[q]);
      |                  ^
a.cc:26:24: error: 'q' was not declared in this scope
   26 |   int ans=abs(mp[p]-mp[q]);
      |                        ^
Language: C++

#include<instream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int N;
  vector<int>num1(N);
  vector<int>num2(N);
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>num1(i);
  }
  for(int i=0;i<N;i++){
    cin>>num2(i);
  }
  vector<int> a(N);
  for(int i=0;i<N;i++){
    a(i)=i++;
  }
  map<vector<int>, int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
  return 0;
}
    
    
    
  
  
  
  
  
  
  
  
  
  
  

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

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

int main(){
  int N;
  cin >> N;
  vector<int>P(N),Q(N),v(N);

  for(int i=0;i<N;i++){
    cin >> P.at(i);
    v.at(i)=i+1;
  }
  for(int i=0;i<N;i++){
    cin >> Q.at(i);
  }
  int count=1;
  int p=0;
  int q=0;

  do {
    int count_p =0;
    int count_q =0;
    for (int i=0;i<N;i++){
      if(v.at(i)==P.at(i)){
        count_p++;
      }
      if(v.at(i)==Q.at(i)){
        count_q++;
      }
    }
    if(N==count_p){
      p=count;
    }
    if(N==count_q){
      q=count;
    }
    if(p!=0 && q!=0){
      break;
    }
    count++;
  } while (next_permutation(v.begin(), v.end()));
  if(p>=q){
    cout << p-q << endl;
  }
  else{
    cout << q-p << endl;
  }
}


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

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

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



Compiler output:
a.cc: In function 'int main()':
a.cc:16:14: error: 'class std::map<std::vector<int>, int>' has no member named 'sice'; did you mean 'size'?
   16 |     mp[a]=mp.sice();
      |              ^~~~
      |              size
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int> p(n), q(n);
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  vector<int> a(n);
  rep(i,n) a[i]=i+1;
  
  map<nector<int>,int> mp;
  do{
    mp[a]=mp.sice();
  }while(next_permutation(a.begin(),a.end()));
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:7: error: 'nector' was not declared in this scope
   14 |   map<nector<int>,int> mp;
      |       ^~~~~~
a.cc:14:17: error: wrong number of template arguments (1, should be at least 2)
   14 |   map<nector<int>,int> mp;
      |                 ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
  102 |     class map
      |           ^~~
a.cc:14:18: error: expected unqualified-id before ',' token
   14 |   map<nector<int>,int> mp;
      |                  ^
a.cc:14:19: error: expected unqualified-id before 'int'
   14 |   map<nector<int>,int> mp;
      |                   ^~~
a.cc:16:5: error: 'mp' was not declared in this scope; did you mean 'p'?
   16 |     mp[a]=mp.sice();
      |     ^~
      |     p
a.cc:18:15: error: 'mp' was not declared in this scope; did you mean 'p'?
   18 |   int ans=abs(mp[p]-mp[q]);
      |               ^~
      |               p
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int> p(n), q(n);
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  vector<int> a(n);
  rep(i,n) a[i]=i+1;
  
  map<nector<int>,int> mp;
  do{
    mp[a]=mp.sice();
  }while(next_permutation(a.begin(),a.end()));
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
}



Compiler output:
a.cc:4:9: error: 'Long' does not name a type; did you mean 'long'?
    4 | typedef Long Long ll;
      |         ^~~~
      |         long
a.cc: In function 'int main()':
a.cc:15:7: error: 'nector' was not declared in this scope
   15 |   map<nector<int>,int> mp;
      |       ^~~~~~
a.cc:15:17: error: wrong number of template arguments (1, should be at least 2)
   15 |   map<nector<int>,int> mp;
      |                 ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
  102 |     class map
      |           ^~~
a.cc:15:18: error: expected unqualified-id before ',' token
   15 |   map<nector<int>,int> mp;
      |                  ^
a.cc:15:19: error: expected unqualified-id before 'int'
   15 |   map<nector<int>,int> mp;
      |                   ^~~
a.cc:17:5: error: 'mp' was not declared in this scope; did you mean 'p'?
   17 |     mp[a]=mp.sice();
      |     ^~
      |     p
a.cc:19:15: error: 'mp' was not declared in this scope; did you mean 'p'?
   19 |   int ans=abs(mp[p]-mp[q]);
      |               ^~
      |               p
Language: C++

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007

typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    vector<li> p(n);
    vector<li> q(n);
    rin{
        cin>>p[i];
    }
    rin{
        cin>>q[i];
    }
    vector<li> perm(n);
    rin{
        perm[i]=i+1;
    }
    li pp = -1;
    li qq=-1;
    li cnt=0;
    do{
        if(perm==p){
            pp=cnt;
        }
        if(perm==q){
            qq=cnt;
        }
        cnt++;
    }while(next_permutations(allof(perm)));
    cout<<abs(pp-qq)<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:12: error: 'next_permutations' was not declared in this scope
   79 |     }while(next_permutations(allof(perm)));
      |            ^~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
	int n;
	cin>>n;
	vector<int> p(n),q(n),r(n);
	rep(i,n)r[i]=i+1;
	
	rep(i,n)cin>>p[i];
	rep(i,n)cin>>q[i];
	
	int nanbanp=0,nanbanq;
	do{
		count++;
		if(r==p)nanbanp=count;
		if(r==q)nanbanq=count;
	}while(next_permutation(p.begin(),p.end()));
	
	cout<<abs(nanbanp-nanbanq)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:22: error: no post-increment operator for type
   17 |                 count++;
      |                      ^~
a.cc:18:33: error: cannot resolve overloaded function 'count' based on conversion to type 'int'
   18 |                 if(r==p)nanbanp=count;
      |                                 ^~~~~
a.cc:19:33: error: cannot resolve overloaded function 'count' based on conversion to type 'int'
   19 |                 if(r==q)nanbanq=count;
      |                                 ^~~~~
Language: C++

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

int main() {
	int n;
	cin>>n;
	vector<int> p(n),q(n),r(n);
	rep(i,n)r[i]=i+1;
	
	rep(i,n)cin>>p[i];
	rep(i,n)cin>>q[i];
	
	int nanbanp=0,nanbanq;
	do{
		count++
		if(r==p)nanbanp=count;
		if(r==q)nanbanq=count;
	}while(next_permutation(p.begin(),p.end()));
	
	cout<<abs(nanbanp-nanbanq)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:22: error: no post-increment operator for type
   17 |                 count++
      |                      ^~
a.cc:19:33: error: cannot resolve overloaded function 'count' based on conversion to type 'int'
   19 |                 if(r==q)nanbanq=count;
      |                                 ^~~~~
Language: Java

import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		boolean flg = true;
		int[] numbers = new int[N];
		int[] bestNumbers = new int[N];
		int a = 0;
		int b = 0;
		int buf = 0;
		int ans = -1;
		for(int i = 0;i < N;i++){
			P[i] = sc.nextInt();
			numbers[i] = i + 1;
			bestNumbers[i] = N - i;
		}
		for(int i = 0;i < N;i++){
			Q[i] = sc.nextInt();
		}
		while(flg){
			flg = false;
			for(int i = N - 1;i > 0;i--){
				buf++;
				if(Arrays.equals(numbers,P)){
					a = buf;
				}else if(Arrays.equals(numbers,Q)){
					b = buf;
				}
				if(numbers[i] > numbers[i - 1]){
					ultimateSort(numbers,i,i - 2);
					flg = true;
				}
			}
		}
		
		ans = Math.abs(a - b);
		System.out.println(ans);
	}
	public static void swap(int[] a,int i,int j){
		int buf = a[i];
		a[i] = a[j];
		a[j] = buf;
	}
	public static void ultimateSort(int[] a,int head){
		int N = a.length;
		for(int i = head + 1;i < N;i++){
			if(a[i] == a[head] + 1){
				swap(a,head,i);
				break;
			}
		}
		Arrays.sort(a,head + 1,N);
	}
}

Compiler output:
Main.java:33: error: method ultimateSort in class Main cannot be applied to given types;
					ultimateSort(numbers,i,i - 2);
					^
  required: int[],int
  found:    int[],int,int
  reason: actual and formal argument lists differ in length
1 error
Language: Java

import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		boolean flg = true;
		int[] numbers = new int[N];
		int[] bestNumbers = new int[N];
		int a = 0;
		int b = 0;
		int buf = 0;
		int ans = -1;
		for(int i = 0;i < N;i++){
			P[i] = sc.nextInt();
			numbers[i] = i + 1;
			bestNumbers[i] = N - i
		}
		for(int i = 0;i < N;i++){
			Q[i] = sc.nextInt();
		}
		while(flg){
			flg = false;
			for(int i = N - 1;i > 0;i++){
				buf++;
				if(Arrays.equals(numbers,P)){
					a = buf;
				}else if(Arrays.equals(numbers,Q)){
					b = buf;
				}else if(Arrays.equals(bestNumbers,numbers)){
					break;
				}
				if(numbers[i] > numbers[i - 1]){
					swap(numbers,i,i - 1);
					flg = true;
				}else{
					swap(numbers,i,i - 2);
					swap(numbers,i,i - 1);
				}
			}
		}
		
		ans = Math.abs(a - b);
		System.out.println(ans);
	}
	public static void swap(int[] a,int i,int j){
		int buf = a[i];
		a[i] = a[j];
		a[j] = buf;
	}
}

Compiler output:
Main.java:18: error: ';' expected
			bestNumbers[i] = N - i
			                      ^
1 error
Language: Java

import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		boolean flg = true;
		int[] numbers = new int[N];
		int a = 0;
		int b = 0;
		int buf = 0;
		int ans = -1;
		for(int i = 0;i < N;i++){
			P[i] = sc.nextInt();
			numbers[i] = 1 + i;
		}
		for(int i = 0;i < N;i++){
			Q[i] = sc.nextInt();
		}
		while(flg){
			flg = false;
			for(int i = N - 1;i > 0;i--){
				buf++;
				if(Arrays.equals(P,number)){
					a = buf;
				}else if(Arrays.equals(Q,number)){
					b = buf;
				}
				if(numbers[i] > numbers[i - 1]){
					swap(numbers,i,i - 1);
					flg = true;
				}
			}
		}
		ans = Math.abs(a - b);
		System.out.println(ans);
	}
	public static void swap(int[] a,int i,int j){
		int buf = a[i];
		a[i] = a[j];
		a[j] = a[i];
	}
}

Compiler output:
Main.java:25: error: cannot find symbol
				if(Arrays.equals(P,number)){
				                   ^
  symbol:   variable number
  location: class Main
Main.java:27: error: cannot find symbol
				}else if(Arrays.equals(Q,number)){
				                         ^
  symbol:   variable number
  location: class Main
2 errors
Language: Java

import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] P = new int[N];
		int[] Q = new int[N];
		boolean flg = true;
		int numbers = new int[N];
		int a = 0;
		int b = 0;
		int buf = 0;
		int ans = -1;
		for(int i = 0;i < N;i++){
			P[i] = sc.nextInt();
			numbers[i] = 1 + i;
		}
		for(int i = 0;i < N;i++){
			Q[i] = sc.nextInt();
		}
		while(flg){
			flg = false;
			for(int i = N - 1;i > 0;i--){
				buf++;
				if(Arrays.equals(P,number)){
					a = buf;
				}else if(Arrays.equals(Q,number)){
					b = buf;
				}
				if(numbers[i] > numbers[i - 1]){
					swap(numbers,i,i - 1);
					flg = true;
				}
			}
		}
		ans = Math.abs(a - b);
		System.out.println(ans);
	}
	public static void swap(int[] a,int i,int j){
		int buf = a[i];
		a[i] = a[j];
		a[j] = a[i];
	}
}

Compiler output:
Main.java:9: error: incompatible types: int[] cannot be converted to int
		int numbers = new int[N];
		              ^
Main.java:16: error: array required, but int found
			numbers[i] = 1 + i;
			       ^
Main.java:25: error: cannot find symbol
				if(Arrays.equals(P,number)){
				                   ^
  symbol:   variable number
  location: class Main
Main.java:27: error: cannot find symbol
				}else if(Arrays.equals(Q,number)){
				                         ^
  symbol:   variable number
  location: class Main
Main.java:30: error: array required, but int found
				if(numbers[i] > numbers[i - 1]){
				          ^
Main.java:30: error: array required, but int found
				if(numbers[i] > numbers[i - 1]){
				                       ^
Main.java:31: error: incompatible types: int cannot be converted to int[]
					swap(numbers,i,i - 1);
					     ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
7 errors
Language: C

#include <stdio.h>
#include <stdlib.h>

int num (int n, int a[]) {
  int count=0;
  
  for (int i=0; i<n-1; i++) {
	for(int j=i; j<n; j++)
      if (a[i]>a[j])
		count++;
    count *= n-i-1;
  }
  return count;
}

int main(void)
{
	int n;
	int p[8],q[8], P,Q;
	
	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]);
	}
	
	P = num(n,p): Q = num(n, q);
	
	printf("%d", abs(P-Q));
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:29:21: error: expected ';' before ':' token
   29 |         P = num(n,p): Q = num(n, q);
      |                     ^
      |                     ;
Language: C++

#include <vector>
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

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

  string p,q;p="";q="";
  int temp;

  for (int i = 0; i < n; i++) {
    std::cin >> temp;
    p+=temp+'0';
  }
  for (int i = 0; i < n; i++) {
    std::cin >> temp;
    q+=temp+'0';
  }

  string s="";
  for (int i = 1; i <= n; i++) {
    s+=(i+'0');
  }

  int pnum=0;
  int qnum=0;
  int cnt=0;
  if(p!=q)
  while (next_permutation(s.begin(), s.end()))
  {
    cnt++;
    if(s==p)
    {
      pnum=cnt;
    }
    if(s==q)
    {
      qnum=cnt;
    }
    if(pnum!=0 && qnum!=0)break;
  }

  std::cout << abs(pnum-qnum) << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:10: error: 'next_permutation' was not declared in this scope
   32 |   while (next_permutation(s.begin(), s.end()))
      |          ^~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int N,P[8],Q[8];
  cin>>N;
 for ( int i; i<N; i++) cin>>P[i];
  for ( int i; i<N; i++)cin>>Q[i];
  vector<int> v;
  
   for ( int i; i<N; i++)v.push_back(i+1);
  int idx =0, a=-1,b=-1;
  do {
    bool ok=true;
     for ( int i; i<N; i++)if (v[i]!=P[i]) ok=false;
    if (ok) a=idx;
    
    ok=true;
     for ( int i; i<N; i++)if (v[i]!=Q[i]) ok=false;
    if (ok) b=idx;
    
    idx++;
  }while(next_permutation(v.begin(),v.end())));
  int ans=abs(a-b);
  cout<<ans<<endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:25:46: error: expected ';' before ')' token
   25 |   }while(next_permutation(v.begin(),v.end())));
      |                                              ^
      |                                              ;
a.cc:25:46: error: expected primary-expression before ')' token
Language: C++

#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int N,P[8],Q[8];
  cin>>N;
 for ( int i; i<N; i++) cin>>P[i];
  for ( int i; i<N; i++)cin>>Q[i];
  vector<int> v;
  
   for ( int i; i<N; i++)v.push_back(i+1);
  int idx =0, a=-1,b=-1;
  do {
    bool ok=true;
     for ( int i; i<N; i++)if (v[i]!=P[i]) ok=false;
    if (ok) a=idx;
    
    ok=true;
     for ( int i; i<N; i++)if (v[i]!=Q[i]) ok=false;
    if (ok) b=idx;
    
    idx++;
  }while(next_permutation(all(v)));
  int ans=abs(a-b);
  cout<<ans<<endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:25:27: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   25 |   }while(next_permutation(all(v)));
      |                           ^~~
      |                           std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:2:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: C++

#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int N,P[8],Q[8];
  cin>>N;
 for ( int i; i<N; i++) cin>>P[i];
  for ( int i; i<N; i++)cin>>Q[i];
  vector<int> v;
  
   for ( int i; i<N; i++)v.push_back(i+1);
  int idx =0, a=-1,b=-1;
  do {
    bool ok=true;
     for ( int i; i<N; i++)if (v[i]!=P[i]) ok=false;
    if (ok) a=idx;
    
    ok=true;
     for ( int i; i<N; i++)if (v[i]!=Q[i]) ok=false;
    if (ok) b=idx;
    
    idX++;
  }while(next_permutation(all(v)));
  int ans=abs(a-b);
  cout<<ans<<endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'idX' was not declared in this scope; did you mean 'idx'?
   24 |     idX++;
      |     ^~~
      |     idx
a.cc:25:27: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   25 |   }while(next_permutation(all(v)));
      |                           ^~~
      |                           std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:2:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: C++

#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int N,P[8],Q[8];
  cin>>N;
 for ( int i; i<N; i++) cin>>P[i];
  for ( int i; i<N; i++)cin>>Q[i];
  vector<int> v;
  
   for ( int i; i<N; i++)v.push_back(i+1);
  int idx =0, a=-1,b=-1;
  do {
    bool ok=true;
     for ( int i; i<N; i++)if (v[i]!=P[i]) ok=false;
    if (ok) a=idx;
    
    ok=true;
     for ( int i; i<N; i++)if (v[i]!=Q[i]) ok=false;
    if (ok) b=idx;
    
    id++;
  }while(next_permutation(all(v)));
  int ans=abs(a-b);
  cout<<ans<<endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'id' was not declared in this scope; did you mean 'idx'?
   24 |     id++;
      |     ^~
      |     idx
a.cc:25:27: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   25 |   }while(next_permutation(all(v)));
      |                           ^~~
      |                           std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:2:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: C++

#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int N,P[8],Q[8];
  cin>>N;
 for ( int i; i<N; i++) cin>>P[i];
  for ( int i; i<N; i++)cin>>Q[i];
  vector<int> v;
  
   for ( int i; i<N; i++)v.push_back(i+1);
  int idx =0; a=-1,b=-1;
  do {
    bool ok=true;
     for ( int i; i<N; i++)if (v[i]!=P[i]) ok=false;
    if (ok) a=idx;
    
    ok=true;
     for ( int i; i<N; i++)if (v[i]!=Q[i]) ok=false;
    if (ok) b=idx;
    
    id++;
  }while(next_permutation(all(v)));
  int ans=abs(a-b);
  cout<<ans<<endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: 'a' was not declared in this scope
   14 |   int idx =0; a=-1,b=-1;
      |               ^
a.cc:14:20: error: 'b' was not declared in this scope
   14 |   int idx =0; a=-1,b=-1;
      |                    ^
a.cc:24:5: error: 'id' was not declared in this scope; did you mean 'idx'?
   24 |     id++;
      |     ^~
      |     idx
a.cc:25:27: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   25 |   }while(next_permutation(all(v)));
      |                           ^~~
      |                           std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:2:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int N,P[8],Q[8];
  cin>>N;
 for ( int i; i<N; i++) cin>>P[i];
  for ( int i; i<N; i++)cin>>Q[i];
  vector<int> v;
  
   for ( int i; i<N; i++)v.push_back(i+1);
  int idx =0; a=-1,b=-1;
  do {
    bool ok=true;
     for ( int i; i<N; i++)if (v[i]!=P[i]) ok=false;
    if (ok) a=idx;
    
    ok=true;
     for ( int i; i<N; i++)if (v[i]!=Q[i]) ok=false;
    if (ok) b=idx;
    
    id++;
  }while(next_permutation(all(v)));
  int ans=abs(a-b);
  cout<<ans<<endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<int> v;
      |   ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include<algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> v;
      |          ^~~
a.cc:12:26: error: 'v' was not declared in this scope
   12 |    for ( int i; i<N; i++)v.push_back(i+1);
      |                          ^
a.cc:13:15: error: 'a' was not declared in this scope
   13 |   int idx =0; a=-1,b=-1;
      |               ^
a.cc:13:20: error: 'b' was not declared in this scope
   13 |   int idx =0; a=-1,b=-1;
      |                    ^
a.cc:16:32: error: 'v' was not declared in this scope
   16 |      for ( int i; i<N; i++)if (v[i]!=P[i]) ok=false;
      |                                ^
a.cc:20:32: error: 'v' was not declared in this scope
   20 |      for ( int i; i<N; i++)if (v[i]!=Q[i]) ok=false;
      |                                ^
a.cc:23:5: error: 'id' was not declared in this scope; did you mean 'idx'?
   23 |     id++;
      |     ^~
      |     idx
a.cc:24:31: error: 'v' was not declared in this scope
   24 |   }while(next_permutation(all(v)));
      |                               ^
a.cc:24:27: error: 'all' was not declared in this scope; did you mean 'atoll'?
   24 |   }while(next_permutation(all(v)));
      |                           ^~~
      |                           atoll
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
int N,P[8],Q[8];
  cin>>N;
  rep(i,0,N) cin>>P[i];
  rep(i,0,N) cin>>Q[i];
  vector<int> v;
  rep(i,0,N) v.push_back(i+1);
  int idx =0; a=-1,b=-1;
  do {
    bool ok=true;
    rep(i,0,N) if (v[i]!=P[i]) ok=false;
    if (ok) a=idx;
    
    ok=true;
    rep(i,0,N) if (v[i]!=Q[i]) ok=false;
    if (ok) b=idx;
    
    id++;
  }while(next_permutation(all(v)));
  int ans=abs(a-b);
  cout<<ans<<endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   rep(i,0,N) cin>>P[i];
      |       ^
a.cc:8:3: error: 'rep' was not declared in this scope
    8 |   rep(i,0,N) cin>>P[i];
      |   ^~~
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<int> v;
      |   ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include<algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> v;
      |          ^~~
a.cc:12:15: error: 'a' was not declared in this scope
   12 |   int idx =0; a=-1,b=-1;
      |               ^
a.cc:12:20: error: 'b' was not declared in this scope
   12 |   int idx =0; a=-1,b=-1;
      |                    ^
a.cc:22:5: error: 'id' was not declared in this scope; did you mean 'idx'?
   22 |     id++;
      |     ^~
      |     idx
a.cc:23:31: error: 'v' was not declared in this scope
   23 |   }while(next_permutation(all(v)));
      |                               ^
a.cc:23:27: error: 'all' was not declared in this scope; did you mean 'atoll'?
   23 |   }while(next_permutation(all(v)));
      |                           ^~~
      |                           atoll
Language: C++

#include <bits/stdc++.h>

using namespace std;

void Nanban(vector<int> x,int *y,vector<vector<int>> z)
{
  while(1)
  {
    if(x==z.at(*y-1))
      break;
    *y++;
  }
}
  

int main()
{
  int n;
  cin>>n;
  
  vector<int> vec;
  for(int i=1;i<n+1;i++)
    vec.push_back(i);
  
  vector<vector<int>> x;
  
  do
  {
    x.push_back(vec);
  }while(next_permutation(vec.begin(),vec.end()));
  
  vector<int> p(n);
  vector<int> 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=1,b=1;
  
  Nanban(vector<int> p,int &a,vector<vector<int>> x)
  while(1)
  {
    if(q==x.at(b-1))
      break;
    b++;
  }
  
  int result=a-b;
  if(result<0)
    result=result*(-1);
  
  cout<<result<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:22: error: expected primary-expression before 'p'
   42 |   Nanban(vector<int> p,int &a,vector<vector<int>> x)
      |                      ^
a.cc:42:24: error: expected primary-expression before 'int'
   42 |   Nanban(vector<int> p,int &a,vector<vector<int>> x)
      |                        ^~~
a.cc:42:51: error: expected primary-expression before 'x'
   42 |   Nanban(vector<int> p,int &a,vector<vector<int>> x)
      |                                                   ^
Language: C++

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

int main(){
	int n;
	cin>>n;
	int p[n],q[n],s[n],t[n];
	rep(i,n)cin>>p[i];
	rep(i,n)cin>>q[i];
	rep(i,n)s[i]=i+1;
	rep(i,n)t[i]=i+1;
	int i=0;
	do{
		bool a=true;
		rep(i,n)a=a&&s[i]==p[i];
		if(a)break;
		i++;
	}while(next_permutation(s,s+n))
	int ac=i;
	i=0;
	do{
		bool a=true;
		rep(i,n)a=a&&t[i]==q[i];
		if(a)break;
		i++;
	}while(next_permutation(t,t+n))
	int bc=i;
	cout << abs(ac-bc) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:40: error: expected ';' before 'int'
   20 |         }while(next_permutation(s,s+n))
      |                                        ^
      |                                        ;
   21 |         int ac=i;
      |         ~~~                             
a.cc:28:40: error: expected ';' before 'int'
   28 |         }while(next_permutation(t,t+n))
      |                                        ^
      |                                        ;
   29 |         int bc=i;
      |         ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 10;
int p[maxn],q[maxn];
int cantor(int *a,int n) {  ///a[]:原数组,下标从1开始
    int ans=0;
    for(int i=1;i<n;i++) {
        int m=1,rk=0;
        for(int j=i+1;j<=n;j++) {
            if(a[j]<a[i])
                rk++;
            m*=(j-i);   ///阶乘
        }
        ans+=rk*m;      ///据公式X = A[0] * (n-1)! + A[1] * (n-2)! + … + A[n-1] * 0!
                        ///A[i] = rk
    }
    return ans+1;       ///ans+1,即为原序列在全排列中的次序
}
int main()
{
  int n;
  cin >> n;
  for(int i = 1;i<=n;++i)
  {
      cin >> p[i];
  }
  for(int i = 1;i<=n;++i)
  {
      cin >>q[i];
  }
  int a = cantor(p,n);
  int b = cantor(q,n);
  cout << abs(b-a) << "\n";
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 10;
int p[maxn],q[maxn];
int cantor(int *a,int n) {  ///a[]:原数组,下标从1开始
    int ans=0;
    for(int i=1;i<n;i++) {
        int m=1,rk=0;
        for(int j=i+1;j<=n;j++) {
            if(a[j]<a[i])
                rk++;
            m*=(j-i);   ///阶乘
        }
        ans+=rk*m;      ///据公式X = A[0] * (n-1)! + A[1] * (n-2)! + … + A[n-1] * 0!
                        ///A[i] = rk
    }
    return ans+1;       ///ans+1,即为原序列在全排列中的次序
}
int main()
{
  int n;
  cin >> n;
  for(int i = 1;i<=n;++i)
  {
      cin >> p[i];
  }
  for(int i = 1;i<=n;++i)
  {
      cin >>q[i];
  }
  int a = cantor(p,n);
  int b = cantor(q,n);
  cout << abs(b-a) << "\n";
    return 0;
}


Compiler output:
a.cc:40:11: error: redefinition of 'const int maxn'
   40 | const int maxn = 10;
      |           ^~~~
a.cc:4:11: note: 'const int maxn' previously defined here
    4 | const int maxn = 10;
      |           ^~~~
a.cc:41:5: error: redefinition of 'int p [10]'
   41 | int p[maxn],q[maxn];
      |     ^
a.cc:5:5: note: 'int p [10]' previously declared here
    5 | int p[maxn],q[maxn];
      |     ^
a.cc:41:13: error: redefinition of 'int q [10]'
   41 | int p[maxn],q[maxn];
      |             ^
a.cc:5:13: note: 'int q [10]' previously declared here
    5 | int p[maxn],q[maxn];
      |             ^
a.cc:42:5: error: redefinition of 'int cantor(int*, int)'
   42 | int cantor(int *a,int n) {  ///a[]:原数组,下标从1开始
      |     ^~~~~~
a.cc:6:5: note: 'int cantor(int*, int)' previously defined here
    6 | int cantor(int *a,int n) {  ///a[]:原数组,下标从1开始
      |     ^~~~~~
a.cc:56:5: error: redefinition of 'int main()'
   56 | int main()
      |     ^~~~
a.cc:20:5: note: 'int main()' previously defined here
   20 | int main()
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n,a=0,b=0;
  cin>>n;
  vector<int>p(n),q(n),r(n);
  rep(i,n){
    cin>>p[i]>>q[i];
    r[i]=i+1;
  }
  do{
    if(r==p) a++;
    if(r==q) b++;
  }while(next_permutation(all(r));
  cout<<abs(a-b)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:34: error: expected ')' before ';' token
   19 |   }while(next_permutation(all(r));
      |         ~                        ^
      |                                  )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n,a=0,b=0;
  cin>>n;
  vector<int>p(n),q(n),r(n);
  rep(i,n){
    cin>>p[i]>>q[i];
    r[i]=i+1;
  }
  do{
    if(r==p) a++;
    if(r==q) b++;
  }while(next_permutation(all(a));
  cout<<abs(a-b)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:18: error: request for member 'begin' in 'a', which is of non-class type 'int'
    4 | #define all(v) v.begin(),v.end()
      |                  ^~~~~
a.cc:19:27: note: in expansion of macro 'all'
   19 |   }while(next_permutation(all(a));
      |                           ^~~
a.cc:4:28: error: request for member 'end' in 'a', which is of non-class type 'int'
    4 | #define all(v) v.begin(),v.end()
      |                            ^~~
a.cc:19:27: note: in expansion of macro 'all'
   19 |   }while(next_permutation(all(a));
      |                           ^~~
a.cc:19:34: error: expected ')' before ';' token
   19 |   }while(next_permutation(all(a));
      |         ~                        ^
      |                                  )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n,a=0,b=0;
  cin>>n;
  vector<int>p(n),q(n),r(n);
  rep(i,n){
    cin>>p[i]>>q[i];
    r[i]=i+1;
  }
  do{
    if(r[i]==p[i]) a++;
    if(r[i]==q[i]) b++;
  }while(next_permutation(all(a));
  cout<<abs(a-b)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:10: error: 'i' was not declared in this scope
   17 |     if(r[i]==p[i]) a++;
      |          ^
a.cc:18:10: error: 'i' was not declared in this scope
   18 |     if(r[i]==q[i]) b++;
      |          ^
a.cc:4:18: error: request for member 'begin' in 'a', which is of non-class type 'int'
    4 | #define all(v) v.begin(),v.end()
      |                  ^~~~~
a.cc:19:27: note: in expansion of macro 'all'
   19 |   }while(next_permutation(all(a));
      |                           ^~~
a.cc:4:28: error: request for member 'end' in 'a', which is of non-class type 'int'
    4 | #define all(v) v.begin(),v.end()
      |                            ^~~
a.cc:19:27: note: in expansion of macro 'all'
   19 |   }while(next_permutation(all(a));
      |                           ^~~
a.cc:19:34: error: expected ')' before ';' token
   19 |   }while(next_permutation(all(a));
      |         ~                        ^
      |                                  )
Language: C++

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

void func150c(){
    //skipped
    int N;
    cin >> N;
    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(N);
    for (int i = 0; i < N; ++i) {
        v[i] = i + 1;
    }
    bool flag = true;
    int a = 1;
    while (flag) {
        flag = false;
        for (int i = 0; i < N; ++i) {
            if (v[i] != P[i]) {
                flag = true;
                next_permutation(v.begin(), v.end());
                a++;
            }
        }
    }
    cout << abs(a - b) << "\n";
}

int main()
{
  func150c();
  return 0;
}

Compiler output:
a.cc: In function 'void func150c()':
a.cc:28:17: error: 'next_permutation' was not declared in this scope
   28 |                 next_permutation(v.begin(), v.end());
      |                 ^~~~~~~~~~~~~~~~
a.cc:33:21: error: 'b' was not declared in this scope
   33 |     cout << abs(a - b) << "\n";
      |                     ^
Language: C++

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

void func150c(){
    //skipped
    int N;
    cin >> N;
    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(N);
    for (int i = 0; i < N; ++i) {
        v[i] = i + 1;
    }
    bool flag = true;
    int a = 1;
    while (flag) {
        flag = false;
        for (int i = 0; i < N; ++i) {
            if (v[i] != P[i]) {
                flag = true;
                next_permutation(v.begin(), v.end());
                a++;
            }
        }
    }
    cout << abs(a - b) << endl;
}

int main()
{
  func150c();
  return 0;
}

Compiler output:
a.cc: In function 'void func150c()':
a.cc:28:17: error: 'next_permutation' was not declared in this scope
   28 |                 next_permutation(v.begin(), v.end());
      |                 ^~~~~~~~~~~~~~~~
a.cc:33:21: error: 'b' was not declared in this scope
   33 |     cout << abs(a - b) << endl;
      |                     ^
Language: C++

from itertools import permutations
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from math import factorial
from math import sqrt
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


#ここから書き始める
n = int(input())
x = [i for i in range(1, n + 1)]
p = list(map(int, input().split()))
q = list(map(int, input().split()))
a = 0
b = 0
cnt = 0
a_finished = False
b_finished = False
for i in permutations(x):
    # print("i =", i)
    if a_finished and b_finished:
        break
    if list(i) == p:
        a = cnt
        a_finished = True 
    if list(i) == q:
        b = cnt
        b_finished = True
    cnt += 1
ans = abs(a - b)
print(ans)

Compiler output:
a.cc:57:26: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
   57 |         return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      |                          ^~~~~~~~
a.cc:60:2: error: invalid preprocessing directive #\U00003053\U00003053\U0000304b\U00003089\U000066f8\U0000304d\U000059cb\U00003081\U0000308b
   60 | #ここから書き始める
      |  ^~~~~~~~~~~~~~~~~~
a.cc:71:7: error: invalid preprocessing directive #print
   71 |     # print("i =", i)
      |       ^~~~~
a.cc:1:1: error: 'from' does not name a type
    1 | from itertools import permutations
      | ^~~~
a.cc:56:5: error: 'def' does not name a type
   56 |     def __str__(self):
      |     ^~~
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> s(n);
  for (int i = 0; i < n; i++) s[i] = i+1;
  int i = 0;
  int pidx = 0;
  int qidx = 0;
  do {
    bool pflag = true;
    for (int i = 0; i < n; i++) {
      if (s[i] != p[i]) pflag = false;
    }
    if (pflag) { 
      pidx = i;
      break;
    } else i++;
  } while (next_permutation(s.begin(), s.end()));

  i = 0;
  do {
    bool qflag = true;
    for (int i = 0; i < n; i++) {
      if (s[i] != q[i]) qflag = false;
    }
    if (qflag) {
      qidx = i;
      break
    } else i++;
  } while (next_permutation(s.begin(), s.end()));

  cout << abs(pidx - qidx) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:12: error: expected ';' before '}' token
   34 |       break
      |            ^
      |            ;
   35 |     } else i++;
      |     ~
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i] =i+1;

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'vestor' was not declared in this scope
   14 |     map <vestor<int>,int> mp;
      |          ^~~~~~
a.cc:14:20: error: wrong number of template arguments (1, should be at least 2)
   14 |     map <vestor<int>,int> mp;
      |                    ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
  102 |     class map
      |           ^~~
a.cc:14:21: error: expected unqualified-id before ',' token
   14 |     map <vestor<int>,int> mp;
      |                     ^
a.cc:14:22: error: expected unqualified-id before 'int'
   14 |     map <vestor<int>,int> mp;
      |                      ^~~
a.cc:16:9: error: 'mp' was not declared in this scope; did you mean 'p'?
   16 |         mp[a] = mp.size();
      |         ^~
      |         p
a.cc:19:19: error: 'mp' was not declared in this scope; did you mean 'p'?
   19 |     int ans = abs(mp[p] - mp[q]);
      |                   ^~
      |                   p
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
long long order_p=0;
long long order_q=0;
vector<long long>p(n);
vector<long long>q(n);
vector<long long>sample(n);
for (int i=0;i<n;i++){
    cin >> p[i];
    }
for (int i=0;i<n;i++){
    cin >> q[i];
    }
int sample[n];
for(int i=0;i<n;i++){
    sample[i]=i+1;
}
do{
    order_p++;
    if(sample==p)break;
}while(next_permutation(sample.begin(),sample.end()));
for(int i=0;i<n;i++){
    sample[i]=i+1;
}
do{
    order_q++;
    if(sample==q)break;
}while(next_permutation(sample.begin(),sample.end()));
cout << abs(order_p - order_q) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: conflicting declaration 'int sample [n]'
   17 | int sample[n];
      |     ^~~~~~
a.cc:10:18: note: previous declaration as 'std::vector<long long int> sample'
   10 | vector<long long>sample(n);
      |                  ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
long long order_p=0;
long long order_q=0;
int p[n];
int q[n];
for(int i=0;i<n;i++){
    cin >> p[i];
}
for(int i=0;i<n;i++){
    cin >> q[i];
}
int sample[n];
for(int i=0;i<n;i++){
    sample[i]=i+1;
}
do{
    order_p++;
    if(p==sample)break;
}while(next_permutation(tmp,tmp+n));
for(int i=0;i<n;i++){
    sample[i]=i+1;
}
do{
    order_q++;
    if(q==sample)break;
}while(next_permutation(tmp,tmp+n));
cout << abs(order_p - order_q) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:25: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   23 | }while(next_permutation(tmp,tmp+n));
      |                         ^~~
      |                         tm
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  int n;
  cin>>n;
  vector<int>p(n),q(n);
  rep(i,n) cin>>p(n);
  rep(i,n) cin>>q(n);
  vector<int>a(n);
  rep(i,n)a[i]=i+1;
  map<vector<int>,int>mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: no match for call to '(std::vector<int>) (int&)'
    9 |   rep(i,n) cin>>p(n);
      |                 ~^~~
a.cc:10:18: error: no match for call to '(std::vector<int>) (int&)'
   10 |   rep(i,n) cin>>q(n);
      |                 ~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  int n;
  cin>>n;
  vector<int>p(n),q(n);
  rep(i,n) cin>>p(n);
  rep(i,n) cin>>q(n);
  vector<int>a(n);
  rep(i,n)a.at(i)=i+1;
  map<vector<int>,int>mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  cout<<abs(mp[p]-mp[q])<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: no match for call to '(std::vector<int>) (int&)'
    9 |   rep(i,n) cin>>p(n);
      |                 ~^~~
a.cc:10:18: error: no match for call to '(std::vector<int>) (int&)'
   10 |   rep(i,n) cin>>q(n);
      |                 ~^~~