Language: Java

/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;

int N;
int solve(vector<int> A,vector<int> B,int mask){
    int res = inf;
    vector<int> C(N);
    debug(mask)
    REP(i,N){
        // debug((mask>>i&1))
        if (mask>>i &1) C[i] = B[i];
        else C[i] = A[i];
    }

    set<int> swaped;
    int cnt = 0;
    debug(C)
    REP(i,N){
        for(int j=N-1;j>i;j--){
            if(C[j] < C[j-1]){
                if((mask>>j&1) && (mask>>(j-1)&1)){
                    debug(j)
                    swap(C[j],C[j-1]);
                    cnt++;
                    swaped.insert(j-1);
                    swaped.insert(j);
                }else{
                    return inf;
                }
            }
        }
    }
    REP(i,N){
        if (mask>>i &1){
            if( swaped.find(i) == swaped.end()){
                //救済

                cerr<<"swapしてないのでNG\n";
                return inf;
            }
        }
    }

    cout << "OK" << mp(mask,cnt ) << endl;
    return cnt;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<int> A(N),B(N);
    REP(i,N){
        cin >> A[i];
    }REP(i,N){
        cin >> B[i];
    }

    int max_bit = 1<<N;
    int ans = inf;
    REP(mask, max_bit){
        chmin(ans,solve(A,B,mask));
    }

    cout << ans << endl;
}

Compiler output:
Main.java:11: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:11: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:13: error: class, interface, enum, or record expected
using namespace std;
^
Main.java:14: error: unnamed classes are a preview feature and are disabled by default.
using P = pair<int64, int64>;
^
  (use --enable-preview to enable unnamed classes)
Main.java:14: error: ';' expected
using P = pair<int64, int64>;
                           ^
Main.java:15: error: class, interface, enum, or record expected
typedef vector<int> vi;
^
Main.java:16: error: class, interface, enum, or record expected
const int MOD = (int)1e9 + 7;
^
Main.java:17: error: class, interface, enum, or record expected
const int64 INF = 1LL << 62;
^
Main.java:18: error: class, interface, enum, or record expected
const int inf = 1<<30;
^
Main.java:19: error: class, interface, enum, or record expected
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
^
Main.java:19: error: '{' expected
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
                ^
Main.java:19: error: illegal start of type
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
                                                ^
Main.java:19: error: > or ',' expected
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
                                                       ^
Main.java:19: error: illegal start of type
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
                                                                            ^
Main.java:20: error: class, interface, enum, or record expected
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
^
Main.java:20: error: '{' expected
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
                ^
Main.java:20: error: illegal start of type
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
                                                ^
Main.java:20: error: > or ',' expected
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
                                                       ^
Main.java:20: error: illegal start of type
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
                                                                            ^
Main.java:21: error: illegal character: '#'
#define REP(i, n) for (int i = 0; i < (n); i++)
^
Main.java:21: error: class, interface, enum, or record expected
#define REP(i, n) for (int i = 0; i < (n); i++)
        ^
Main.java:21: error: class, interface, enum, or record expected
#define REP(i, n) for (int i = 0; i < (n); i++)
                                  ^
Main.java:21: error: class, interface, enum, or record expected
#define REP(i, n) for (int i = 0; i < (n); i++)
                                           ^
Main.java:22: error: illegal character: '#'
#define FOR(i,s,n) for (int i = s; i < (n); i++)
^
Main.java:22: error: class, interface, enum, or record expected
#define FOR(i,s,n) for (int i = s; i < (n); i++)
                                   ^
Main.java:22: error: class, interface, enum, or record expected
#define FOR(i,s,n) for (int i = s; i < (n); i++)
                                            ^
Main.java:23: error: illegal character: '#'
#define ALL(obj) (obj).begin(), (obj).end() //?????????????!!
^
Main.java:24: error: illegal character: '#'
#define debug(x) cerr << #x << ": " << x << "\n";
^
Main.java:24: error: illegal character: '#'
#define debug(x) cerr << #x << ": " << x << "\n";
                         ^
Main.java:25: error: illegal character: '#'
#define mp make_pair
^
Main.java:25: error: class, interface, enum, or record expected
#define mp make_pair
        ^
Main.java:29: error: class, interface, enum, or record expected
    REP(i,N){
    ^
Main.java:31: error: class, interface, enum, or record expected
        if (i!=N-1) os << " ";
        ^
Main.java:32: error: class, interface, enum, or record expected
    }
    ^
Main.java:34: error: class, interface, enum, or record expected
    return os;
    ^
Main.java:35: error: class, interface, enum, or record expected
}
^
Main.java:39: error: class, interface, enum, or record expected
    os << " ";
    ^
Main.java:40: error: class, interface, enum, or record expected
    os << P.second;
    ^
Main.java:41: error: class, interface, enum, or record expected
    return os;
    ^
Main.java:42: error: class, interface, enum, or record expected
}
^
Main.java:46: error: class, interface, enum, or record expected
    while(it!=S.end()){
    ^
Main.java:48: error: class, interface, enum, or record expected
        os << " ";
        ^
Main.java:49: error: class, interface, enum, or record expected
        it++;
        ^
Main.java:50: error: class, interface, enum, or record expected
    }
    ^
Main.java:52: error: class, interface, enum, or record expected
    return os;
    ^
Main.java:53: error: class, interface, enum, or record expected
}
^
Main.java:56: error: class, interface, enum, or record expected
    for(auto it=q.begin();it<q.end();it++){
                          ^
Main.java:56: error: class, interface, enum, or record expected
    for(auto it=q.begin();it<q.end();it++){
                                     ^
Main.java:58: error: class, interface, enum, or record expected
        os<<" ";
        ^
Main.java:59: error: class, interface, enum, or record expected
    }
    ^
Main.java:61: error: class, interface, enum, or record expected
    return os;
    ^
Main.java:62: error: class, interface, enum, or record expected
}
^
Main.java:69: error: not a statement
    vector<int> C(N);
                  ^
Main.java:100: error: not a statement
                cerr<<"swap??????NG\n";
                    ^
Main.java:106: error: not a statement
    cout << "OK" << mp(mask,cnt ) << endl;
                                  ^
Main.java:69: error: ';' expected
    vector<int> C(N);
                 ^
Main.java:69: error: ';' expected
    vector<int> C(N);
                   ^
Main.java:70: error: ';' expected
    debug(mask)
               ^
Main.java:71: error: ';' expected
    REP(i,N){
            ^
Main.java:79: error: ';' expected
    debug(C)
            ^
Main.java:80: error: ';' expected
    REP(i,N){
            ^
Main.java:84: error: ';' expected
                    debug(j)
                            ^
Main.java:95: error: ';' expected
    REP(i,N){
            ^
Main.java:112: error: not a statement
    ios::sync_with_stdio(false);
    ^
Main.java:113: error: not a statement
    cin >> N;
        ^
Main.java:114: error: not a statement
    vector<int> A(N),B(N);
                  ^
Main.java:116: error: not a statement
        cin >> A[i];
            ^
Main.java:118: error: not a statement
        cin >> B[i];
            ^
Main.java:127: error: not a statement
    cout << ans << endl;
                ^
Main.java:112: error: ';' expected
    ios::sync_with_stdio(false);
                        ^
Main.java:114: error: ';' expected
    vector<int> A(N),B(N);
                 ^
Main.java:114: error: ';' expected
    vector<int> A(N),B(N);
                   ^
Main.java:115: error: ';' expected
    REP(i,N){
            ^
Main.java:117: error: ';' expected
    }REP(i,N){
             ^
Main.java:123: error: ';' expected
    REP(mask, max_bit){
                      ^
75 errors