Language: C++

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

long long N=0,K=0,M=0,A=0,ans=0,p=0;
string S;
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.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:4:36: error: expected ';' before '<' token
    4 | #define rep(i,n) for (int i = 0, i < (n); ++i)
      |                                    ^
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n) cin >> p[i];
      |     ^~~
a.cc:4:36: error: expected primary-expression before '<' token
    4 | #define rep(i,n) for (int i = 0, i < (n); ++i)
      |                                    ^
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n) cin >> p[i];
      |     ^~~
a.cc:4:36: error: expected ';' before '<' token
    4 | #define rep(i,n) for (int i = 0, i < (n); ++i)
      |                                    ^
a.cc:14:5: note: in expansion of macro 'rep'
   14 |     rep(i,n) cin >> q[i];
      |     ^~~
a.cc:4:36: error: expected primary-expression before '<' token
    4 | #define rep(i,n) for (int i = 0, i < (n); ++i)
      |                                    ^
a.cc:14:5: note: in expansion of macro 'rep'
   14 |     rep(i,n) cin >> q[i];
      |     ^~~
a.cc:4:36: error: expected ';' before '<' token
    4 | #define rep(i,n) for (int i = 0, i < (n); ++i)
      |                                    ^
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,n) a[i] = i+1;
      |     ^~~
a.cc:4:36: error: expected primary-expression before '<' token
    4 | #define rep(i,n) for (int i = 0, i < (n); ++i)
      |                                    ^
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,n) a[i] = i+1;
      |     ^~~
a.cc:18:9: error: two or more data types in declaration of 'type name'
   18 |     map<vector<int> int> mp;
      |         ^~~~~~~~~~~
a.cc:18:24: error: wrong number of template arguments (1, should be at least 2)
   18 |     map<vector<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:20:11: error: no match for 'operator[]' (operand types are 'int' and 'std::vector<int>')
   20 |         mp[a] = mp.size();
      |           ^
a.cc:20:20: error: request for member 'size' in 'mp', which is of non-class type 'int'
   20 |         mp[a] = mp.size();
      |                    ^~~~
a.cc:23:21: error: no match for 'operator[]' (operand types are 'int' and 'std::vector<int>')
   23 |     int ans = abs(mp[p] - mp[q]);
      |                     ^
a.cc:23:29: error: no match for 'operator[]' (operand types are 'int' and 'std::vector<int>')
   23 |     int ans = abs(mp[p] - mp[q]);
      |                             ^