Language: C++

int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1){int &t=p[B|1<<i][k];t=min(t,p[B][j]+d[i]);}}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}

Compiler output:
a.cc:1:35: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    1 | int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1){int &t=p[B|1<<i][k];t=min(t,p[B][j]+d[i]);}}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}
      |                                   ^~~~
a.cc: In function 'int main()':
a.cc:1:42: error: 'cin' was not declared in this scope
    1 | int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1){int &t=p[B|1<<i][k];t=min(t,p[B][j]+d[i]);}}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}
      |                                          ^~~
a.cc:1:51: error: 'i' was not declared in this scope
    1 | int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1){int &t=p[B|1<<i][k];t=min(t,p[B][j]+d[i]);}}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}
      |                                                   ^
a.cc:1:49: error: 'R' was not declared in this scope
    1 | int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1){int &t=p[B|1<<i][k];t=min(t,p[B][j]+d[i]);}}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}
      |                                                 ^
a.cc:1:74: error: 'fill' was not declared in this scope
    1 | int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1){int &t=p[B|1<<i][k];t=min(t,p[B][j]+d[i]);}}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}
      |                                                                          ^~~~
a.cc:1:99: error: 'B' was not declared in this scope
    1 | int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1){int &t=p[B|1<<i][k];t=min(t,p[B][j]+d[i]);}}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}
      |                                                                                                   ^
a.cc:1:263: error: 'cout' was not declared in this scope
    1 | int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)if(~B&1<<i)d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1){int &t=p[B|1<<i][k];t=min(t,p[B][j]+d[i]);}}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}
      |                                                                                                                                                                                                                                                                       ^~~~