Language: C++

#include <iostream>
#include <vector>

using namespace std;

int order(int n){
        int x;
        vector<int> v;
        for (int i = 1; i <= n; ++i){
                v.push_back(i);
        }

        int o = 1;
        int sum;
        for (int i = 1; i <= n; ++i){
                cin >> x;

                vector<int>::iterator iter = find(v.begin(), v.end(), x);
                vector<int>::difference_type index = distance(v.begin(), iter);

                sum = 1;
                for (int j = 1; j <= n-i; ++j){
                        sum *= j;
                }
                sum *= index;
                v.erase(std::remove(v.begin(), v.end(), x), v.end());
                o += sum;
        }
        return o;
}


int main(){
        int n, p, q;
        cin >> n;

        p = order(n);
        q = order(n);

        cout << max(p,q) - min(p,q) << endl;

}

Compiler output:
a.cc: In function 'int order(int)':
a.cc:18:50: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   18 |                 vector<int>::iterator iter = find(v.begin(), v.end(), x);
      |                                              ~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:18:50: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   18 |                 vector<int>::iterator iter = find(v.begin(), v.end(), x);
      |                                              ~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:26:44: error: cannot convert 'std::vector<int>::iterator' to 'const char*'
   26 |                 v.erase(std::remove(v.begin(), v.end(), x), v.end());
      |                                     ~~~~~~~^~
      |                                            |
      |                                            std::vector<int>::iterator
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/stdio.h:158:32: note:   initializing argument 1 of 'int remove(const char*)'
  158 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~