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

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const int inf = 1e+7;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int N; cin >> N;
    int Q[200100];
    rep(i, N) {
        int x; cin >> x;
        Q[x - 1] = i;
    }
    
    int ans = 1, t = 1
    rep(i, N) {
        if (Q[i] > Q[i - 1]) {
            t ++;
        } else {
            t = 1;
        }
        ans = max(ans, t);
    }
    
    cout << N - ans << "\n";


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:18: error: expected ',' or ';' before 'for'
   28 | #define rep(i,n) for(int i=0;i<n;i++)
      |                  ^~~
a.cc:54:5: note: in expansion of macro 'rep'
   54 |     rep(i, N) {
      |     ^~~
a.cc:54:9: error: 'i' was not declared in this scope
   54 |     rep(i, N) {
      |         ^
a.cc:28:30: note: in definition of macro 'rep'
   28 | #define rep(i,n) for(int i=0;i<n;i++)
      |                              ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int a[200010];
int dp[200010];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int b=a[i];
		dp[b]=dp[b-1]+1;
		if(ans<dp[b]){
			ans=dp[b]
		}
	}
		
	cout<<n-ans<<endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:34: error: expected ';' before '}' token
   19 |                         ans=dp[b]
      |                                  ^
      |                                  ;
   20 |                 }
      |                 ~
Language: C++

import numpy as np



def ii():
    return int(input())




def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l



N = ii()

P = lvi(N)

'''
P = []
for _ in range(N):
    p = ii()
    P.append(p -1)

print(P)
'''

#fill( Q, Q + N, 0)
Q = [0 for i in range(N)]


#print( 'Q', Q)

for i in range(1, N):
    Q[P[i - 1]] = i


maxcnt = 1
cnt = 1

print( 'Q', Q)

for i in range(1, N):
    if Q[i] > Q[i - 1]:
        cnt += 1
    else:
        cnt = 1

    maxcnt = max( maxcnt, cnt)


print(N - maxcnt)


Compiler output:
a.cc:23:1: error: empty character constant
   23 | '''
      | ^~
a.cc:23:3: warning: missing terminating ' character
   23 | '''
      |   ^
a.cc:23:3: error: missing terminating ' character
a.cc:30:1: error: empty character constant
   30 | '''
      | ^~
a.cc:30:3: warning: missing terminating ' character
   30 | '''
      |   ^
a.cc:30:3: error: missing terminating ' character
a.cc:32:2: error: invalid preprocessing directive #fill
   32 | #fill( Q, Q + N, 0)
      |  ^~~~
a.cc:36:2: error: invalid preprocessing directive #print
   36 | #print( 'Q', Q)
      |  ^~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import numpy as np
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C

#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
int N;
int num[200010]={};
int f[200010]={};
int main(){
	scanf("%d",&N);
	for(int i=1; i<=N; i++)
		scanf("%d",&num[i]);
	memset(f,0,sizeof(f));
	f[1]=1;
	for(int i=2; i<=N; i++){
		for(int j=1; j<i; j++){
			if(num[i]>num[j])
				f[i]=max(f[i],f[j]);
		}
		f[i]++;
	}
	for(int i=1; i<=N; i++)f[0]=max(f[0],f[i]);
	printf("%d\n",N-f[0]+1);
	return 0;
}


Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>
using namespace std;

int N[210000];
int dp[210000];

int Max(int a, int b)
{
	if(a > b)
		return a;
	else
		return b;
}

int main ()
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		dp[i] = 1, N[i] = 0;
	for(int i = 0; i < n; i++)
		scanf("%d", &N[i]);
	
	int max = 0;
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < i; j++)
		{
			if(N[i] == N[j] + 1)
				dp[i] = Max(dp[i], dp[i] + dp[j]);
		}
		if(dp[i] > max)
			max = dp[i];
	}
	
	printf("%d\n", n - max);
	
	return 0;
}

Compiler output:
main.c:2:1: error: unknown type name 'using'
    2 | using namespace std;
      | ^~~~~
main.c:2:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    2 | using namespace std;
      |                 ^~~
Language: C

#include <cstdio>
using namespace std;

int N[210000];
int dp[210000];

int Max(int a, int b)
{
	if(a > b)
		return a;
	else
		return b;
}

int main ()
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		dp[i] = 1, N[i] = 0;
	for(int i = 0; i < n; i++)
		scanf("%d", &N[i]);
	
	int max = 0;
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < i; j++)
		{
			if(N[i] == N[j] + 1)
				dp[i] = Max(dp[i], dp[i] + dp[j]);
		}
		if(dp[i] > max)
			max = dp[i];
	}
	
	printf("%d\n", n - max);
	
	return 0;
}

Compiler output:
main.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.
Language: Java

#include<cstdio>
#include<iostream>
#define maxn 200010
using namespace std;
int n,a[maxn],mx,mxx;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	mxx=n;
	for(int i=1;i<=n;i++)
		if(a[i]==mx+1)mx++;
	for(int i=n;i>=1;i--)
		if(a[i]==mxx)mxx--;
	printf("%d",min(n-mx,mxx));
	return 0;
} 

Compiler output:
Main.java:1: error: illegal character: '#'
#include<cstdio>
^
Main.java:2: error: illegal character: '#'
#include<iostream>
^
Main.java:3: error: illegal character: '#'
#define maxn 200010
^
Main.java:5: error: class, interface, enum, or record expected
int n,a[maxn],mx,mxx;
^
Main.java:6: error: unnamed classes are a preview feature and are disabled by default.
int main(){
^
  (use --enable-preview to enable unnamed classes)
Main.java:7: error: illegal start of expression
	scanf("%d",&n);
	           ^
Main.java:9: error: illegal start of expression
		scanf("%d",&a[i]);
		           ^
7 errors
Language: C++

>

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main(void)
{
  int n;
  cin >> n;
  vector<p> v(n, {0, 0});
  // vector<int> vTmp(n, 0);
  for (int i = 0; i < n; i++){
    cin >> v[i].first;
    v[i].second = i;
  }

  sort(v.begin(), v.end());
  int maxv = 0, count = 0;
  for (int i = 0; i < n - 1; i++){
    count++;
    if (v[i].second >= v[i+1].second || i == n-2) {
      maxv = max(maxv, count);
      count = 0;
    }
  }
  cout << n - maxv << endl;

  return 0;
}


Compiler output:
a.cc:1:1: error: expected unqualified-id before '>' token
    1 | >
      | ^
a.cc:6:9: error: 'pair' does not name a type
    6 | typedef pair<int,int> p;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:12:3: error: 'cin' was not declared in this scope
   12 |   cin >> n;
      |   ^~~
a.cc:13:3: error: 'vector' was not declared in this scope
   13 |   vector<p> v(n, {0, 0});
      |   ^~~~~~
a.cc:13:10: error: 'p' was not declared in this scope
   13 |   vector<p> v(n, {0, 0});
      |          ^
a.cc:13:13: error: 'v' was not declared in this scope
   13 |   vector<p> v(n, {0, 0});
      |             ^
a.cc:20:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   20 |   sort(v.begin(), v.end());
      |   ^~~~
      |   short
a.cc:25:14: error: 'max' was not declared in this scope; did you mean 'maxv'?
   25 |       maxv = max(maxv, count);
      |              ^~~
      |              maxv
a.cc:29:3: error: 'cout' was not declared in this scope; did you mean 'count'?
   29 |   cout << n - maxv << endl;
      |   ^~~~
      |   count
a.cc:29:23: error: 'endl' was not declared in this scope
   29 |   cout << n - maxv << endl;
      |                       ^~~~
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);

    for(auto& x : v) cin >> x, --x;

    vector<int> d(n, 0);

    for(int i = 0; i < n; ++i){
        if(v[i] == 0) d[v[i]] = 1;
        else d[v[i]] = d[v[i]-1]+1; }


    cout << (n - *max_element(begin(d), end(d))) << endl;
    return 0; }


Compiler output:
a.cc: In function 'int main()':
a.cc:19:19: error: 'max_element' was not declared in this scope
   19 |     cout << (n - *max_element(begin(d), end(d))) << endl;
      |                   ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#define MAXN 100    // pre-calc max n for phi(m, n)
#define MAXM 10010 // pre-calc max m for phi(m, n)
#define MAXP 40000 // max primes counter
#define MAX 400010    // max prime
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))

using namespace std;

int a[100005];

int main()
{
	int n;
	scanf("%d",&n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d",&x);
		a[x] = a[x - 1] + 1;
		if (a[x] > ans) {
			ans = a[x];
		}
	}
	printf("%d", n - ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:28: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |                 if (a[x] > ans) {
      |                            ^~~
      |                            abs
a.cc:31:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |         printf("%d", n - ans);
      |                          ^~~
      |                          abs
Language: C++

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

const int mn = 2e5 + 5;
int n;

int a[mn];
int d[mn];
int p[mn];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),p[a[i]]=i,d[i]=1;
	int ans=1;
	for(int i=1;i<n;i++){
		if (p[i+1]>p[i]) d[i+1]=max(d[i]+1,d[i+1]),ans=max(ans,d[i+1]);
	}
	printf("%d\n",n-ans);
	return 0;
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | /#include<bits/stdc++.h>
      |  ^
a.cc:1:1: error: expected unqualified-id before '/' token
    1 | /#include<bits/stdc++.h>
      | ^
a.cc: In function 'int main()':
a.cc:11:9: error: 'scanf' was not declared in this scope
   11 |         scanf("%d",&n);
      |         ^~~~~
a.cc:15:41: error: 'max' was not declared in this scope
   15 |                 if (p[i+1]>p[i]) d[i+1]=max(d[i]+1,d[i+1]),ans=max(ans,d[i+1]);
      |                                         ^~~
a.cc:17:9: error: 'printf' was not declared in this scope
   17 |         printf("%d\n",n-ans);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | /#include<bits/stdc++.h>
Language: C++

#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main() {
	int n, p[200005],q[200005], pq[200005];
	cin >> n;
	for (int i = 1, int x;i <= n;i++) {
		cin >> x;
		p[x] = i;
	}
	q[1] = 0;
	int ans = n - 1;
	for (int i = 2;i <= n;i++) {
		if (p[i] > p[i - 1]) q[i] = q[i - 1] + 1;
		else q[i] = 1;
		ans = min(ans, n - p[i]);
	}

	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: error: expected unqualified-id before 'int'
   16 |         for (int i = 1, int x;i <= n;i++) {
      |                         ^~~
a.cc:16:24: error: expected ';' before 'int'
   16 |         for (int i = 1, int x;i <= n;i++) {
      |                        ^~~~
      |                        ;
a.cc:16:30: error: expected initializer before ';' token
   16 |         for (int i = 1, int x;i <= n;i++) {
      |                              ^
a.cc:16:37: error: expected ')' before ';' token
   16 |         for (int i = 1, int x;i <= n;i++) {
      |             ~                       ^
      |                                     )
a.cc:16:38: error: 'i' was not declared in this scope
   16 |         for (int i = 1, int x;i <= n;i++) {
      |                                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a[200005];
cin>>n;
for(int i=1;i<=n;++i)cin>>a[i];
for(int Max=0,pos=0,i=1;i<=n;++i){
Max=max(Max,a[i]);
if(Max>a[i])pos=max(pos,a[i]);
}
cout<<pos<<endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:7: error: 'pos' was not declared in this scope; did you mean 'pow'?
   11 | cout<<pos<<endl;
      |       ^~~
      |       pow
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a[200005];
cin>>n;
for(int i=1;i<=n;++i)cin>>a[i];
for(int Max=0,pos=0;i=1;i<=n;++i){
Max=max(Max,a[i]);
if(Max>a[i])pos=max(pos,Max);
}
cout<<pos<<endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:21: error: 'i' was not declared in this scope
    7 | for(int Max=0,pos=0;i=1;i<=n;++i){
      |                     ^
a.cc:7:29: error: expected ')' before ';' token
    7 | for(int Max=0,pos=0;i=1;i<=n;++i){
      |    ~                        ^
      |                             )
a.cc:7:32: error: 'i' was not declared in this scope
    7 | for(int Max=0,pos=0;i=1;i<=n;++i){
      |                                ^
a.cc:11:7: error: 'pos' was not declared in this scope; did you mean 'pow'?
   11 | cout<<pos<<endl;
      |       ^~~
      |       pow
Language: C

#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
int mod=(int)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n=in()q[200001],i,a=1,m=0;
    rep(i,n)q[in()]=i+1;
    rep(i,n){
        if(q[i+1]<q[i+2])a++;
        else a=1;
        m=max(m,a);
    }
    print(n-m);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:84:15: error: expected ',' or ';' before 'q'
   84 |     int n=in()q[200001],i,a=1,m=0;
      |               ^
main.c:85:9: error: 'i' undeclared (first use in this function)
   85 |     rep(i,n)q[in()]=i+1;
      |         ^
main.c:12:22: note: in definition of macro 'rep'
   12 | #define rep(i,n) for(i=0;i<n;i++)
      |                      ^
main.c:85:9: note: each undeclared identifier is reported only once for each function it appears in
   85 |     rep(i,n)q[in()]=i+1;
      |         ^
main.c:12:22: note: in definition of macro 'rep'
   12 | #define rep(i,n) for(i=0;i<n;i++)
      |                      ^
main.c:85:13: error: 'q' undeclared (first use in this function)
   85 |     rep(i,n)q[in()]=i+1;
      |             ^
main.c:87:26: error: 'a' undeclared (first use in this function)
   87 |         if(q[i+1]<q[i+2])a++;
      |                          ^
main.c:89:9: error: 'm' undeclared (first use in this function)
   89 |         m=max(m,a);
      |         ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
vector<int> lis_fast(const vector<int>& a) {
  const int n = a.size();
  vector<int> A(n, 1e9);
  vector<int> id(n);
  for (int i = 0; i < n; ++i) {
    id[i] = index_of(A, a[i]);
    A[ id[i] ] = a[i];
  }
  int m = *max_element(id.begin(), id.end());
  vector<int> b(m+1);
  for (int i = n-1; i >= 0; --i)
    if (id[i] == m) b[m--] = a[i];
  return b;
}
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  int ans = lis_fast(v);
  cout << n - ans << endl;
}

Compiler output:
a.cc: In function 'std::vector<int> lis_fast(const std::vector<int>&)':
a.cc:9:13: error: 'index_of' was not declared in this scope
    9 |     id[i] = index_of(A, a[i]);
      |             ^~~~~~~~
a.cc:12:12: error: 'max_element' was not declared in this scope
   12 |   int m = *max_element(id.begin(), id.end());
      |            ^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:22:21: error: cannot convert 'std::vector<int>' to 'int' in initialization
   22 |   int ans = lis_fast(v);
      |             ~~~~~~~~^~~
      |                     |
      |                     std::vector<int>
Language: C++

#include <bits/stdc++.h>

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int q[200005];

map<int, int> pt;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  int n;cin>>n;
  for(int i=0;i<n;i++){
    int t;
    cin>>t;
    t--;
    q[t]=i;
  }
  ll mx=1;
  ll ans=0;
  for(int i=1;i<n;i++){
    if(q[i]>q[i-1]){
      mx++;
      ans=max(mx,ans);
    }else{
      mx=1;
    }
  }
x  cout<<n-ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:34:1: error: 'x' was not declared in this scope; did you mean 'mx'?
   34 | x  cout<<n-ans<<endl;
      | ^
      | mx
Language: C++

#include<iostream>
#include<algorithm>
#define MAX 200000
using namespace std;
 
int n, A[MAX + 1], L[MAX];
 
int lis(){
    L[0] = A[0];
    int length = 1;
 
    for(int i = 1; i < n; i++){
        if(L[length - 1] < A[i] && A[i] == L[length - 1] + 1){
            L[length++] = A[i];
        }else if(*lower_bound(L, L + length, A[i]) == A[i] - 1){
            *lower_bound(L, L + length, A[i]) = A[i];
        }
    }
 
    return length;
}
 
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
 
    cout << n - lis() << endl;
 
    return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:31:14: error: expected '}' at end of input
   31 |     return 0;
      |              ^
a.cc:23:11: note: to match this '{'
   23 | int main(){
      |           ^
Language: C++

#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int i,j,A[N+1];

  for(int i = 0;i < N;i++){
    cin >> n;
    A[n] = i;
  }

  int sequence = 1;
  int prev = A[1];
  int ans = 1;

  for(i = 2;i <= N;i++){
    if(prev < A[i])
     sequence++;
     else{
       ans = max(sequence,ans);
       sequence = 1;
     }

     prev = A[i];
  }
  ans = max(ans,sequence);
  cout << N-ans << endl;

  return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'n' was not declared in this scope
   11 |     cin >> n;
      |            ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#pragma GCC optimize("O3")
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;

int n,a[200005],rs,x[200005];


int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    for(int i=1;i<=n;i++){
        x[a[i]]=x[a[i]-1]+1;
        rs=max(rs,x[a[i]]);
    }
    rs(n-rs);


}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:7: error: 'rs' cannot be used as a function
   30 |     rs(n-rs);
      |     ~~^~~~~~
Language: Java

//Meet Arora 2016055

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
import java.awt.Point;

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /**
     * call this method to initialize reader for InputStream
     */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    /**
     * get next word
     */
    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}

public class b {
	public static void main(String[] args) throws IOException {
		Reader.init(System.in);
		int n=Reader.nextInt();
		int[] a=new int[n];
		PriorityQueue<Integer> pq = new PriorityQueue<>(n);
		HashMap<Integer, Integer> hm = new HashMap<>();

		for (int i = 0; i < n; i++) {
			a[i] = Reader.nextInt();
			pq.add(a[i]);
			hm.put(a[i], i);
		}

		int count = 0;
		int inc = 0, max_inc = -1;
		int min = pq.remove();
		int min_index = hm.get(min);
		for (int i = 1; i < n; i++) {
			int next = pq.remove();
			int index = hm.get(next);
			if (min_index<index) {
				inc++;
				if (inc > max_inc)
					max_inc = inc;
			}
			else {
				inc = 0;
			}
			min = next;
			min_index = index;
		}

		if (max_inc==-1) {
			max_inc=0;
		}
		count = n-1-max_inc;
		System.out.println(count);
	}
}


Compiler output:
Main.java:43: error: class b is public, should be declared in a file named b.java
public class b {
       ^
1 error
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define maxx 200005
int n;
int a[maxx];
int b[maxx];
int c[maxx];
int main()
{
    int biggest=0;
    scanf("%d",&n);
    flag=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=1;
   
        if(c[flag]>a[i])
        continue;
        
        for(int j=i;j>1;j--)
        {
            if(a[i]-1==a[j-1])
            {
                b[i]+=b[j-1];
                //a[j-1]=-200005;
                break;
            }
        }
        c[flag]=min(c[flag],a[i]);
        biggest=max(biggest,b[i]);
    }

    printf("%d",n-biggest);

    //cout << "Hello world!" << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'flag' was not declared in this scope
   15 |     flag=1;
      |     ^~~~
Language: C++

#include<iostream>
#include <complex>
#include <vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<list>
#include <iterator>
using namespace std;
int main() {

	int N, min = 1000000, max = -1;
	int count = 0;
	list<int>p;
	cin >> N;
	p.resize(N);
	for (int i = 0; i < N; i++) {
		int tempp;
		cin >> tempp;
		p.push_back(tempp);
	}
	while(p.back() != N){
		auto result = std::find(p.begin(), p.end(), p.back() +1);
		int temp = (*result);
		p.erase(result);
		p.push_back(temp);
		count++;

	}



	while (p.front() != 1) {
		auto result = std::find(p.begin(), p.end(), p.front() - 1);
		int temp = (*result);
		p.erase(result);
		p.push_front(temp);
		count++;

	}

	auto pite = p.begin();
	int pre=0, post=0;
	for (int i = 0; i < N; i++) {
		if (*pite != *(std::next(pite, 1))) {
			break;
		}
		pre++;
	}
	auto pite = p.end();
	for (int i = N-1; i != -1; i--) {
		if (*pite != *(std::prev(pite, 1))) {
			break;
		}
		post++;
	}

	if (pre < post) {
		auto result = std::find(p.begin(), p.end(), N-post);
		int temp = (*result);
		p.erase(result);
		p.push_front(temp);
		count++;
	}
	else {
		auto result = std::find(p.begin(), p.end(), pre + 1);
		int temp = (*result);
		p.erase(result);
		p.push_back(temp);
		count++;
	}

	while (p.back() != N) {
			auto result = std::find(p.begin(), p.end(), p.back() + 1);
			int temp = (*result);
			p.erase(result);
			p.push_back(temp);
			count++;

		}



	while (p.front() != 1) {
		auto result = std::find(p.begin(), p.end(), p.front() - 1);
		int temp = (*result);
		p.erase(result);
		p.push_front(temp);
		count++;

	}

	cout << count << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:14: error: conflicting declaration 'auto pite'
   50 |         auto pite = p.end();
      |              ^~~~
a.cc:42:14: note: previous declaration as 'std::_List_iterator<int> pite'
   42 |         auto pite = p.begin();
      |              ^~~~
Language: C++

//C:\Program Files(x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\x86_64-w64-mingw32\bits\stdc++.h
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

using namespace std;

int n,ans=200010;
int a[200010],val[100010];
bool used[100010];
deque<int> dq;

bool check(){
//	for(int i=0;i<n;i++) printf("%d ",dq[i]);
//	puts("");
	for(int i=1;i<n;i++) if(dq[i]<dq[i-1]) return false;
	return true;
}

int hash(){
	int res=0;
	for(int i=0;i<n;i++){
		res=res*31+dq[i];
		res%=100007;
	}
	return res;
}

int dfs(int res){
	int hs=hash();
	if(used[hs]) return val[hs];
//	printf("%d\n",res);
	if(check()){
		used[hs]=1;
		val[hs]=0;
		return 0;
	}
	used[hs]=1;
	val[hs]=200010;
	for(int i=0;i<n;i++){
		int x=dq[i];
		dq.erase(dq.begin()+i);
		if(i){
			dq.push_front(x);
			int v=dfs(res+1);
			val[hs]=min(val[hs],v+1);
			dq.pop_front();
		}
		if(i<n-1){
			dq.push_back(x);
			int v=dfs(res+1);
			val[hs]=min(val[hs],v+1);
			dq.pop_back();
		}
		dq.insert(dq.begin()+i,x);
	}
	if(res==0) ans=val[hs];
	return val[hs];
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		dq.push_back(a[i]);
	}
	dfs(0);
	printf("%d\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:50:16: error: reference to 'hash' is ambiguous
   50 |         int hs=hash();
      |                ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from a.cc:3:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:40:5: note:                 'int hash()'
   40 | int hash(){
      |     ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <string>
#include <list>

using namespace std;
using ll = long long;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> p(N1);
    for (int i=0; i<N; ++i) {
        int pi;
        cin >> pi;
        p[pi-1] = i;
    }
    int count = 0;
    int max = 0;
    for (int i=0; i<N-1; ++i) {
        if (p[i] < p[i+1]) {
            ++count;
        }
        else {
            if (count > max) max = count;
            count = 0;
        }
    }
    if (count > max) max = count;
    max = N - max - 1;
    cout << max << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:17:19: error: 'N1' was not declared in this scope; did you mean 'N'?
   17 |     vector<int> p(N1);
      |                   ^~
      |                   N
Language: C++

#include <algorithm>
#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>
using namespace std;
const LL MOD=1e9+7;
int main()
{
	int n,k=0;
	cin>>n;
	vector <int> a(n),ans;
	rep(i,n) cin>>a[i];
	rep(i,n)
	{
		int p=a[i],t=0;
		for(int j=i;j<n;j++)
		{
			if(a[j]==p) t++,p++;
		}
		if(t) ans.push_back(t),k++;
	}
	sort(ans.begin(),ans.end());
	cout<<n-ans[k-1];
    rt0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'vector' was not declared in this scope
   32 |         vector <int> a(n),ans;
      |         ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include <iostream>
  +++ |+#include <vector>
    5 | //#include <cfloat>
a.cc:32:17: error: expected primary-expression before 'int'
   32 |         vector <int> a(n),ans;
      |                 ^~~
a.cc:33:23: error: 'a' was not declared in this scope
   33 |         rep(i,n) cin>>a[i];
      |                       ^
a.cc:36:23: error: 'a' was not declared in this scope
   36 |                 int p=a[i],t=0;
      |                       ^
a.cc:39:37: error: 't' was not declared in this scope
   39 |                         if(a[j]==p) t++,p++;
      |                                     ^
a.cc:41:20: error: 't' was not declared in this scope
   41 |                 if(t) ans.push_back(t),k++;
      |                    ^
a.cc:41:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |                 if(t) ans.push_back(t),k++;
      |                       ^~~
      |                       abs
a.cc:43:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |         sort(ans.begin(),ans.end());
      |              ^~~
      |              abs
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans=0;

int dp[200001][200001];
int XXX[200000],YYY[200000];
    int n=1;
    int main() {
     cin>>n;
     for(int i=0;i<n;++i){
         XXX[i]=(i+1);
         int a;
         cin>>a; YYY[i]=(a);}
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
        if(XXX[i] == YYY[j])  dp[i + 1][j + 1] = dp[i][j] + 1;
        else   dp[i + 1][j + 1]=max(dp[i][j + 1], dp[i + 1][j]);
    }
    cout << n-dp[n][n] << std::endl;   
      return 0;
    }
  

Compiler output:
/tmp/ccQrNpHx.o: in function `main':
a.cc:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `XXX' defined in .bss section in /tmp/ccQrNpHx.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `YYY' defined in .bss section in /tmp/ccQrNpHx.o
a.cc:(.text+0xaf): relocation truncated to fit: R_X86_64_PC32 against symbol `XXX' defined in .bss section in /tmp/ccQrNpHx.o
a.cc:(.text+0xc6): relocation truncated to fit: R_X86_64_PC32 against symbol `YYY' defined in .bss section in /tmp/ccQrNpHx.o
collect2: error: ld returned 1 exit status
Language: Java



import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N =scanner.nextInt();

		int[] P =new int[N];

		for (int i =0;i<N;i++) {
			P[i]=scanner.nextInt();
		}

		int max =0;
		for(int i=0;i<N;i++) {
			if(P[i]==(max+1)) {
				max+=1;
			}
		}

		int min =N+1;
		int mincnt =0;
		for(int j=N-1;j>=0;j--) {
			if(P[j]==(min-1)) {
				min-=1;
				mincnt++
			}
		}

		int ans;
		ans=(max>mincnt)?N-max:N-mincnt;
		System.out.println(ans);

	}

}


Compiler output:
Main.java:29: error: ';' expected
				mincnt++
				        ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
cout << 5 << endl;
return 0
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: expected ';' before '}' token
    5 | return 0
      |         ^
      |         ;
    6 | }
      | ~
Language: Java

import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
long[] ar = new long[N];
long[] index = new long[N+1];
long answer=N;
for(int i=0;i<N;i++){
  ar[i] = sc.nextInt();
}
outer:for(long i=1;i<=N;i++){
inner:  for(long j=N-1;j>=0;j--){
      if(i>1&&j==index[i-1]) {
        if(answer>N-(i-1)){
            answer=N-(i-1);
        }
              break outer;
      }
    if(ar[j] == i){
      index[i]=j;
            break inner;
    }
    }
}

outer:for(long i=N;i>=1;i--){
inner:  for(long j=0;j<N;j++){
      if(i<N&&j==index[i+1]) {
        if(answer>i){
            answer=i;
        }
              break outer;
      }
    if(ar[j] == i){
      index[i]=j;
            break inner;
    }
    }
}

      System.out.println(answer);
      }
}


Compiler output:
Main.java:8: error: incompatible types: possible lossy conversion from long to int
long[] ar = new long[N];
                     ^
Main.java:9: error: incompatible types: possible lossy conversion from long to int
long[] index = new long[N+1];
                         ^
Main.java:16: error: incompatible types: possible lossy conversion from long to int
      if(i>1&&j==index[i-1]) {
                        ^
Main.java:22: error: incompatible types: possible lossy conversion from long to int
    if(ar[j] == i){
          ^
Main.java:23: error: incompatible types: possible lossy conversion from long to int
      index[i]=j;
            ^
Main.java:31: error: incompatible types: possible lossy conversion from long to int
      if(i<N&&j==index[i+1]) {
                        ^
Main.java:37: error: incompatible types: possible lossy conversion from long to int
    if(ar[j] == i){
          ^
Main.java:38: error: incompatible types: possible lossy conversion from long to int
      index[i]=j;
            ^
8 errors
Language: Java

import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
long[] ar = new long[N];
long[] index = new long[N+1];
long answer=N;
for(int i=0;i<N;i++){
  ar[i] = sc.nextInt();
}
outer:for(int i=1;i<=N;i++){
inner:  for(int j=N-1;j>=0;j--){
      if(i>1&&j==index[i-1]) {
        if(answer>N-(i-1)){
            answer=N-(i-1);
        }
              break outer;
      }
    if(ar[j] == i){
      index[i]=j;
            break inner;
    }
    }
}

outer:for(int i=N;i>=1;i--){
inner:  for(int j=0;j<N;j++){
      if(i<N&&j==index[i+1]) {
        if(answer>i){
            answer=i;
        }
              break outer;
      }
    if(ar[j] == i){
      index[i]=j;
            break inner;
    }
    }
}

      System.out.println(answer);
      }
}


Compiler output:
Main.java:8: error: incompatible types: possible lossy conversion from long to int
long[] ar = new long[N];
                     ^
Main.java:9: error: incompatible types: possible lossy conversion from long to int
long[] index = new long[N+1];
                         ^
Main.java:15: error: incompatible types: possible lossy conversion from long to int
inner:  for(int j=N-1;j>=0;j--){
                   ^
Main.java:29: error: incompatible types: possible lossy conversion from long to int
outer:for(int i=N;i>=1;i--){
                ^
4 errors
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int P[N];
	map<int, int> mp;
	rep(i, N) cin >> P[i];
	rep(i, N) {
		mp[p[i]] = i;
	}
	int ans = 0;
	int tmp = 0;
	rep(i, N) {
		while (mp[i + 1] < mp[i + 2] && i < N) {
			tmp++;
		}
		ans = max(ans, tmp);
		tmp = 0;
	}

	cout << N - ans + 1 << endl;



    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:20: error: 'p' was not declared in this scope
   23 |                 mp[p[i]] = i;
      |                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int a,s=0,ss=0;
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(a!=i+1)
			s++;
		if(a!=n-i)
			ss++;
	}
	printf("%d",min(s,ss);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:30: error: expected ')' before ';' token
   16 |         printf("%d",min(s,ss);
      |               ~              ^
      |                              )
Language: C++

#include <cstdio>
#include <vector>
#include <utility>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    vector<pair<int, int>> pairs;
    int elem;
    for (int i = 0; i < n; i++) {
        scanf("%d", &elem);
        pairs.push_back(make_pair(elem, i));
    }

    sort(pairs.begin(), pairs.end());

    int cont = 1, maxCont = 0;
    for (vector<pair<int, int>>::iterator it = pairs.begin(); it < pairs.end() - 1; it++) {
        if (it->second < (it+1)->second) {
            cont++;
        } else {
            if (cont > maxCont) {
                maxCont = cont;
            }
            cont = 1;
        }
    }
    printf("%d\n", n - maxCont);

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |     sort(pairs.begin(), pairs.end());
      |     ^~~~
      |     short
Language: C++

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

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

#define N 200000

int p[N],pind[N];

int main(){
  int n,idx=0,cont=1;
  cin >> n;
  REP(i,n){
    cin>>p[i];
    pind[p[i]-1] = i;
  }
  vector<int> v;
  while(idx<n){
    v.push_back(idx);
    if(idx == n-1) break;
    while(idx<n-1){
      if(pind[idx] > pind[idx+1])
	break;
      idx++;
    }
    idx++;
  }
  REP(i,v.size()-1)
    cont = max(cont,v[i+1]-v[i]);
  cont = max(cont,n-v[v.size()-1])
  cout<<n-cont<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:35: error: expected ';' before 'cout'
   36 |   cont = max(cont,n-v[v.size()-1])
      |                                   ^
      |                                   ;
   37 |   cout<<n-cont<<endl;
      |   ~~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 200005
using namespace std;
int n,ans,tl,a[maxn],que[maxn];
int inline read(){
	int x=0,f=1,ch=getchar();
	while (ch<48||ch>57) f=ch=='-'?-f:f,ch=getchar();
	while (ch>47&&ch<58) x=x*10+ch-48,ch=getchar();
	return x*f;
}
void find(int x){
	int L=1,R=tl,mid;
	while(L<=R){
		mid=(R+L)>>1;
		if (que[mid-1]<x&&x<que[mid]){que[mid]=x;return;}
		if (x>que[mid-1]) R=mid-1;else L=mid+1;
	}
}
void find1(int x){
	int L=1,R=tl,mid;
	while(L<=R){
		mid=(R+L)>>1;
		if (que[mid-1]>x&&x>que[mid]){que[mid]=x;return;}
		if (x>que[mid-1]) R=mid-1;else L=mid+1;
	}
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++){
		a[i]=read();
		if (a[i]>que[tl]) que[++tl]=a[i];else find(a[i]);
	}
	ans=tl;
	que[tl=0]=1<<30;
	for (int i=n;i;i--) if (a[i]<que[tl]) que[++tl]=a[i];else find1(a[i]);
	printf("%d",n-(tl<ans?ans:tl)+1);
	return 0;
9}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:2: error: expected ';' before '}' token
   41 | 9}
      |  ^
      |  ;
Language: C++

#include <bits/stdc++.h>
#define MAXN 200005
typedef long long ll;

using namespace std;

ll n, a[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    
    ll ans1 = 0, ans2 = 0, ans = n;
    static ll l[MAXN];
    static ll r[MAXN];
    int c = n;
    for(int i = n - 1; i >= 0; i--){
        if(a[i] == c){
            c--;
        } else{
            ans1++;
        }
       // r[i] = ans1;
    }
    c = 1;
    for(int i = 0; i < n; i++){
        if(a[i] == c){
            c++;
        } else{
            ans2++;
        }
       // l[i] = ans2;
    }
    ans = min(ans1, ans2);
    for(int i = 0; i < n - 1; i++) ans = min(ans, l[i] + r[i + 1]);
    cout << min(ans1, ans2);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:9:11: note: to match this '{'
    9 | int main(){
      |           ^
Language: C

#include<stdio.h>
int a[200005];
int main()
{
int n,i;
scanf("%d",&n);
for(i=1;i<=n; i++)scanf("%d",&a[i]);
int ans = n;
int cur = n;
for(i=n;i>=1;i--)
if(a[i]==ans)ans--;
printf("%d\n",ans);
return 0;
}a

Compiler output:
main.c:14:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
   14 | }a
      | ^
Language: C++

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

const int N=201000;

int n,a[N],f[N],index[N];
int ans;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{	
		scanf("%d",a+i);
		index[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		f[i]=f[index[a[i]-1]]+1;
		ans=max(ans,f[i]);
	}
	cout<<n-ans<<endl;
	return 0;
}

Compiler output:
a.cc:6:24: error: 'int index [201000]' redeclared as different kind of entity
    6 | int n,a[N],f[N],index[N];
      |                        ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:15:22: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   15 |                 index[a[i]]=i;
      |                      ^
a.cc:19:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   19 |                 f[i]=f[index[a[i]-1]]+1;
      |                             ^
Language: C++

#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
	ll N;
	ll res = 0;
	ll ans = INF;
	cin >> N;
	vector<ll> P(N);
	rep(i, N)
	{
		cin >> P[i];
	}
	
	ll now = N;
	for (ll i = N - 1; i > -1; i--)
	{
		if (now == P[i])
		{
			res++;
			now = now - 1;
		}
	}
	ans = N - res;
	now = 1;
	res = 0;
	for (ll i = 0; i < N; i++)
	{
		if (now == P[i])
		{
			res++;
			now = now + 1;
		}
	}
	ans = min(ans, N - res);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:13: error: 'INT_MAX' was not declared in this scope
   29 | #define INF INT_MAX
      |             ^~~~~~~
a.cc:49:18: note: in expansion of macro 'INF'
   49 |         ll ans = INF;
      |                  ^~~
a.cc:17:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   16 | #include <cstdlib>
  +++ |+#include <climits>
   17 |
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    int s,e,m,v,la;
    node  *l, *r;
    node (int _s, int _e): s(_s), e(_e){
        m = (s+e)/2;
        la = 0;
        if (s == e){
            if (s == 0) v =0;
            else v = -1;
        }
        else{
            l = new node(s,m);
            r = new node(m+1,e);
            v = l->v + r->v;
        }
    }
    void prop(){
        if (la){
            v = 0;
            if (s != e ){
                l -> la = 1;
                r -> la = 1;
            }
            la = 0;
        }
    }
    void up(int qs, int qe){
        prop();
        if (qs == s && qe == e){
            la = 1;
            return;
        }
        if (qs  > m) r->up(qs,qe);
        else if (qe <= m)  l->up(qs,qe);
        else l->up(qs,m), r->up(m+1,qe);
        l->prop(); r->prop();
        v = l->v+r->v;
    }
    int qu(int qs, int qe){
        prop();
        if (qs == s && qe == e)  return v;
        if (qs > m) return r->qu(qs,qe);
        else if (qe <= m) return l->qu(qs,qe);
        else return l->qu(qs,m) + r->qu(m+1,qe);
    }
} *root;
int n;
int a[200005];

int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        //a[i] = min(i,n/2);
        scanf("%d",&a[i]);
    }
    root = new node(0,n-1);
    ll ans = 0;
    for (int i = n-1; i >=0; i--){
        int expect = i+root->qu(0,i);
        //printf("%d: %d %d\n",i,expect,a[i]);
        if (expect != a[i]){
            ans += a[i];
            root->up(max(0,i-a[i]+1),i);
        }
    }
    for (int i = 0; i < n; i++){
        if (query(0,i) != a[i]){
            printf("-1\n");
        }
        return 0;
    }
    printf("%lld",ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:13: error: 'query' was not declared in this scope
   70 |         if (query(0,i) != a[i]){
      |             ^~~~~