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

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;

int main()
{
    int A[200000];
    vector<int> a;
    int n;
    cin >> n;
    int i,j;
    for(i = 0;i < n;i++)
    {
        cin >> A[i];
        a.emplace_back(A[i]);
    }
    int counter = 0;
    vector<int>::iterator tmp;
    vector<int>::iterator now = a.begin();
    int ans = 0;
    while(1)
    {
        counter++;
        tmp = find(now,a.end(),counter);
        if(tmp == a.end())
        {
            if(counter == 1 && a[0] != 1)
            {
                ans = -1;
                goto end;
            }
            else if(*(a.end) == counter)
            {
                ans += tmp - now - 1;
                goto end;
            }
            else
            {
                goto end;
            }
            
        }
        else
        {
        //cout << tmp - now << endl;
            if(counter == 1)
            {
                ans += tmp - now;
            }
            else
            {
                ans += tmp - now - 1;
            }
            
            now = tmp;
        }
    }
    end:
    cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:25: error: invalid use of member function 'std::vector<int>::end' (did you forget the '()' ?)
   33 |             else if(*(a.end) == counter)
      |                      ~~~^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    int brick=0,noofbrick=1;
    for(i=1;i<=n;i++)
    {
        int x;cin>>x;
        if(x==noofbrick)
        {
        noofbrick++;}
        else
        {
            brick++;
        }
    }
    if(brick<n)
        cout<<brick<<endl;
    else
        cout<<"-1\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     for(i=1;i<=n;i++)
      |         ^
Language: C

#include<stdio.h>

int main (void){
int N;
int a,b,d;
int c=0;
int br[200000];
scanf("%d",&N);

for(a=1;a<N+1;a++){
scanf("%d",&b);
br[a] = b;
}
for(a=1;a<N+1;a++){

}
if(br[a] == a-c){
    d++;

}else{
    c++;
}
if(d==N){
    printf("-1"):
}else if (d<N){
    printf("%d",d);

}
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:24:17: error: expected ';' before ':' token
   24 |     printf("-1"):
      |                 ^
      |                 ;
Language: Java

import java.math.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> num = new ArrayList<>();
        for (int i = 0; i < n; i++)
            num.add(sc.nextInt());
        int cnt = 0
        int p=1;
        for(int i=0;i<n;i++){
            if(num.get(i)!=p){
                cnt++;
            }
            else{
                p++;
            }
        }
        System.out.println(cnt);
    }
}


Compiler output:
Main.java:11: error: ';' expected
        int cnt = 0
                   ^
1 error
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll N;
    cin >> N;

    ll cur = 1;

    for(ll i=0; i<N; i++)
    {
        ll a;
        cin >> a;

        if(a == cur)
        {
            cur++;
        }
    }

    cur--;

    if(cur == 0)
    {
        cout << -1 << endl;
    }

    else
    {
        cout << n-cur << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:105:17: error: 'n' was not declared in this scope
  105 |         cout << n-cur << endl;
      |                 ^
Language: C++

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define PN 6700417 

long check(long* a,long n){
    long m=0;
    for(long i=0;i<n;i++){
      if(i+1>=a[i]&&!(a[i]==a[i+1])){
        a[m]=a[i];
        m++;
      }
    }
    return m;
}

int main(){
    int i;
    //入力
    /*long n,l;
    cin>>n;
    l=n;
    long a[n]={};
    for(i=0;i<n;i++){
        long y;
        cin>>y;
        if(i+1>=y){
            a[j]=y;
            j++;
        }
    }
    //処理
    if(a[0]==0){
        cout<<-1<<endl;
        exit;
    }
    long m=j;
    do{
        n=m;
        m=check(a,n);
    }while(!(m==n));

    //出力
    cout<<(l-m)<<endl;*/
    long n,j=1,k;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>k;
        if(k==j){
            j++;
        }
    }
    if(j==1){
        cout<<-1<<endl;
    }else{
        cout<<j<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:5: error: 'cin' was not declared in this scope
   46 |     cin>>n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:54:9: error: 'cout' was not declared in this scope
   54 |         cout<<-1<<endl;
      |         ^~~~
a.cc:54:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:54:19: error: 'endl' was not declared in this scope
   54 |         cout<<-1<<endl;
      |                   ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:56:9: error: 'cout' was not declared in this scope
   56 |         cout<<j<<endl;
      |         ^~~~
a.cc:56:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:56:18: error: 'endl' was not declared in this scope
   56 |         cout<<j<<endl;
      |                  ^~~~
a.cc:56:18: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include"bits/stdc++.h"

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define PN 6700417 
int main(){
    int i,j=0;
    //入力
    /*long n,l;
    cin>>n;
    l=n;
    long a[n]={};
    for(i=0;i<n;i++){
        long y;
        cin>>y;
        if(i+1>=y){
            a[j]=y;
            j++;
        }
    }
    //処理
    if(a[0]==0){
        cout<<-1<<endl;
        exit;
    }
    long m=j;
    do{
        n=m;
        m=check(a,n);
    }while(!(m==n));

    //出力
    cout<<(l-m)<<endl;*/
    long n,j=1,k;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>k;
        if(k==j){
            j++;
        }
    }
    if(j==1){
        cout<<-1<<endl;
    }else{
        cout<<j<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:12: error: conflicting declaration 'long int j'
   35 |     long n,j=1,k;
      |            ^
a.cc:8:11: note: previous declaration as 'int j'
    8 |     int i,j=0;
      |           ^
Language: C++

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  int index=0;
  int N=1,s=0;  
  rep(i,n){
    if(a.at(i)==N){
      N++;
      s++;
    }
  }
  if(s==0){
    cout<<-1<<endl;
    return 0;
  }
  cout<<n-s<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin>>n;
      |   ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int> a(n);
      |   ^~~~~~
a.cc:4:10: error: expected primary-expression before 'int'
    4 |   vector<int> a(n);
      |          ^~~
a.cc:5:7: error: 'i' was not declared in this scope
    5 |   rep(i,n){
      |       ^
a.cc:5:3: error: 'rep' was not declared in this scope
    5 |   rep(i,n){
      |   ^~~
a.cc:17:5: error: 'cout' was not declared in this scope
   17 |     cout<<-1<<endl;
      |     ^~~~
a.cc:17:15: error: 'endl' was not declared in this scope
   17 |     cout<<-1<<endl;
      |               ^~~~
a.cc:20:3: error: 'cout' was not declared in this scope
   20 |   cout<<n-s<<endl;
      |   ^~~~
a.cc:20:14: error: 'endl' was not declared in this scope
   20 |   cout<<n-s<<endl;
      |              ^~~~
Language: C++

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



int main(){
  int n,s;
  cin >>n;
  bool t=true;
  vector<int>a(n);
  vector<int>b;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=i;i<=n;i++){
    if(a.at(i-1)!=1) t=false;
    if(a.at(i)!=i){
      a.erase(i.1);
      s++;
    }
    
    
  }
  
  if(t=true){
    cout << s;
  }
  else(t=false){
    cout << -1 <<endl;
  }
}
    
    
    


Compiler output:
a.cc: In function 'int main()':
a.cc:18:16: error: expected ')' before numeric constant
   18 |       a.erase(i.1);
      |              ~ ^~
      |                )
a.cc:18:14: error: no matching function for call to 'std::vector<int>::erase(int&)'
   18 |       a.erase(i.1);
      |       ~~~~~~~^~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided
a.cc:28:16: error: expected ';' before '{' token
   28 |   else(t=false){
      |                ^
      |                ;
Language: C++

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

ll a, b; 


int main() {
  int n; cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  
  int count = 0;
  int len = a.size();
  int tmp=1;
  rep(i,len) {
    if(a[i]==tmp) {
      tmp++;
    }
  }
 
  tmp--;
  if (tmp==0) cout << -1 << endl;
  else ((len-tmp)>0) cout << len-tmp << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:21: error: expected ';' before 'cout'
   25 |   else ((len-tmp)>0) cout << len-tmp << endl;
      |                     ^~~~~
      |                     ;
Language: C++

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



int main(){
  int n.s;
  cin >>n;
  bool t=true;
  vector<int>a(n);
  vector<int>b;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(int i=i;i<=n;i++){
    if(a.at(i-1)!=1) t=false;
    if(a.at(i)!=i){
      a.erase(i.1);
      s++;
    }
    
    
  }
  
  if(t=true){
    cout << s;
  }
  else(t=false){
    cout << -1 <<endl;
  }
}
    
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: expected initializer before '.' token
    7 |   int n.s;
      |        ^
a.cc:8:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |   cin >>n;
      |         ^
      |         yn
a.cc:18:16: error: expected ')' before numeric constant
   18 |       a.erase(i.1);
      |              ~ ^~
      |                )
a.cc:18:14: error: no matching function for call to 'std::vector<int>::erase(int&)'
   18 |       a.erase(i.1);
      |       ~~~~~~~^~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided
a.cc:19:7: error: 's' was not declared in this scope
   19 |       s++;
      |       ^
a.cc:26:13: error: 's' was not declared in this scope
   26 |     cout << s;
      |             ^
a.cc:28:16: error: expected ';' before '{' token
   28 |   else(t=false){
      |                ^
      |                ;
Language: C++

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

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  sort(a.begin(),a.end());
  int p = a[n-1];
  int temp = 1;
  
  for(int i=0;i<n;i++){
    if(a[i] == temp+i)
      continue;
    else{
      temp++;
    }
  }
  
  if(temp <= p-1){
    cout<<p-temp;
  }else{
    cout<<-1;
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:10: error: request for member 'begin' in 'a', which is of non-class type 'int [n]'
   12 |   sort(a.begin(),a.end());
      |          ^~~~~
a.cc:12:20: error: request for member 'end' in 'a', which is of non-class type 'int [n]'
   12 |   sort(a.begin(),a.end());
      |                    ^~~
Language: C

include<stdio.h>

int main (void){
int N;
int a,b;
int c=0;
int d =0;
int br[20000];
scanf("%d",&N);

for(a=1;a<N+1;a++){
scanf("%d",&b);
br[a] = b;
}
for(int e=1;e<N+1;e++){

if(br[e] == e-c){
    d++;

}else{
    c++;
}
}

if(c == N){
    printf("-1");
}else if (c<N+1){
    printf("%d",c);

}
return 0;
}


Compiler output:
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
Language: Java

import java.math.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> num = new ArrayList<>();
        for (int i = 0; i < n; i++)
            num.add(sc.nextInt());
        int cnt = 0;
        r: for (int i = 0; i < n; i++) {
            for (int k = 0; k < num.size(); k++) {
                if (num.get(k) != k + 1) {
                    num.remove(k);
                    cnt++;
                    k--;
                }
                if(k==num.size-1){
                    break r;
                }
                if (cnt == n) {
                    System.out.println(-1);
                    System.exit(0);
                }
            }
        }
        System.out.println(cnt);
    }
}


Compiler output:
Main.java:19: error: cannot find symbol
                if(k==num.size-1){
                         ^
  symbol:   variable size
  location: variable num of type List<Integer>
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  long n;
  long a[n];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]
  }
  long min=2001000;
  for(int i=0;i<n;i++){
    if(min>a[i]-i){
      min=a[i]-i
    }
  }
  if(min>=n)min=-1;
  cout<<min;
  return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n;
  long a[n];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long min=2001000;
  for(int i=0;i<n;i++){
    if(min>a[i]-i){
      min=a[i]-i;
    }
  }
  if(min>=n)min=-1;
  cout<<min;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: expected ';' before '}' token
    8 |     cin>>a[i]
      |              ^
      |              ;
    9 |   }
      |   ~           
a.cc:13:17: error: expected ';' before '}' token
   13 |       min=a[i]-i
      |                 ^
      |                 ;
   14 |     }
      |     ~            
a.cc: At global scope:
a.cc:22:5: error: redefinition of 'int main()'
   22 | int main(){
      |     ^~~~
a.cc:3:5: note: 'int main()' previously defined here
    3 | int main(){
      |     ^~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
	int n , i = 0;
  cin>>n;
  int j;
  int k = 1,sum = 0;
  while( i < n){
  	cin j;
    if( j == k){
    	k++;
      sum++;
    }
    i++;
  }
  if( k == 1){
  	cout<<-1<<endl;
  }
  else{
  	cout<<n-sum<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: expected ';' before 'j'
    9 |         cin j;
      |            ^~
      |            ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  long n;
  long a[n];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]
  }
  long min=2001000;
  for(int i=0;i<n;i++){
    if(min>a[i]-i){
      min=a[i]-i
    }
  }
  if(min>=n)min=-1;
  cout<<min;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: expected ';' before '}' token
    8 |     cin>>a[i]
      |              ^
      |              ;
    9 |   }
      |   ~           
a.cc:13:17: error: expected ';' before '}' token
   13 |       min=a[i]-i
      |                 ^
      |                 ;
   14 |     }
      |     ~
Language: C++

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


int main(){
   cin >> N;
   vector<int> a;
   int count = 0;
   for(int i=0;i<N;i++){
       cin >> a[i];
   }
   sort(a.begin(),a.end());
   if(a[0] == 1){
   for(int i=0;i<N;i++){
       if(a[i] = a[i-1] + 1 && i != 0){
           count += 1;
       }else{
           break;
       }
   }
   }else{
       cout << -1;
   }
   cout << count;
return 0;
}

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

#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<numeric>
typedef long long ll;
typedef vector <long long> vll;
using namespace std;

int main() {
	ll N;
	cin >> N;
	ll a[N];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int B;
	int now = 0;
	int i = 1;
	int j = 0;
	while (1) {
		if (a[j] = i) {
			B += (j - now);
			now = j;
			i++;
		}
		j++;
		if (j == N - 1) {
			B += (j - now);
			break;
		}
	}
	if (i == 1) {
		cout << -1 << endl;
		return 0;
	}
	cout << B << endl;
	return 0;
}

Compiler output:
a.cc:7:9: error: 'vector' does not name a type
    7 | typedef vector <long long> vll;
      |         ^~~~~~
Language: C++

#include <iostream> 
using namespace std; 
  
int main() 
{
    long n;
    cin>>n;
    long a[n];
    for(long i=1;i<=n;i++){
      cin>>a[i];
    }
  long c=1,s=0,f=0;
  for(long i=1;i<=n && f==0;i++){
     if(a[i]!=c){
       s++;
     }
    else{
      c++;
      if(c>=n-1){
        f=1;
    }
      
   }
    if(c==1 || f==1){
      s=-1;
    }
    if(n==a[n] ){
       s=0;
    }
 
    cout<<s;
    return 0; 
} 


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

#include <iostream> 
using namespace std; 
  
int main() 
{
    long n;
    cin>>n;
    long a[n];
    for(long i=1;i<=n;i++){
      cin>>a[i];
    }
  long c=1,s=0,f=0;
  for(long i=1;i<=n && f==0;i++){
     if(a[i]!=c){
       s++;
     }
    else{
      c++;
      if(c>=n-1){
        f=1;
    }
      
   }
    if(c==1 || f=1){
      s=-1;
    }
    if(n==a[n] ){
       s=0;
    }
 
    cout<<s;
    return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:24:13: error: lvalue required as left operand of assignment
   24 |     if(c==1 || f=1){
      |        ~~~~~^~~~
a.cc:33:2: error: expected '}' at end of input
   33 | }
      |  ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include<bits/stdc++.h>
2
using namespace std;
3
​
4
​
5
int main(){
6
   int n,i,j,k=1,cnt=0;
7
   cin >> n;
8
  
9
  vector<int> a(n);
10
  vector<int> b(n);
11
  
12
  for(i=0;i<n;i++){
13
    cin >> a.at(i);
14
  }
15
  
16
  for(i=0;i<n;i=j)
17
    for(j=i;j<n;j++){
18
      if(a.at(j)==k){
19
        b.at(k-1)=a.at(j);
20
        k++;
21
      }
22
      else cnt++;
23
    }
24
  
25
  if(b.at(0)==1)
26
    cout << cnt;
27
  
28
  else cout << -1;
29
}


※ 512 KiB まで

Compiler output:
a.cc:60:1: error: extended character ※ is not valid in an identifier
   60 | ※ 512 KiB まで
      | ^
a.cc:2:1: error: expected unqualified-id before numeric constant
    2 | 2
      | ^
a.cc:4:1: error: expected unqualified-id before numeric constant
    4 | 3
      | ^
a.cc:60:1: error: '\U0000203b' does not name a type
   60 | ※ 512 KiB まで
      | ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<numeric>
typedef long long ll;
typedef vector <long long> vll;
using namespace std;

int main() {
	ll N;
	cin >> N;
	vll a;
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	int B;
	int now = 0;
	int i = 1;
	int j = 0;
	while (1) {
		if (a.at(j) = i) {
			B += (j - now);
			now = j;
			i++;
		}
		j++;
		if (j == N - 1) {
			B += (j - now);
			break;
		}
	}
	if (i == 1) {
		cout << -1 << endl;
		return 0;
	}
	cout << B << endl;
	return 0;
}

Compiler output:
a.cc:7:9: error: 'vector' does not name a type
    7 | typedef vector <long long> vll;
      |         ^~~~~~
a.cc: In function 'int main()':
a.cc:13:9: error: 'vll' was not declared in this scope; did you mean 'll'?
   13 |         vll a;
      |         ^~~
      |         ll
a.cc:15:24: error: 'a' was not declared in this scope
   15 |                 cin >> a.at(i);
      |                        ^
a.cc:22:21: error: 'a' was not declared in this scope
   22 |                 if (a.at(j) = i) {
      |                     ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<numeric>
typedef long long ll;
typedef vector<long> vl;
using namespace std;

int main() {
	ll N;
	cin >> N;
	vl a;
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	int B;
	int now = 0;
	int i = 1;
	int j = 0;
	while (1) {
		if (a.at(j) = i) {
			B += (j - now);
			now = j;
			i++;
		}
		j++;
		if (j == N - 1) {
			B += (j - now);
			break;
		}
	}
	if (i == 1) {
		cout << -1 << endl;
		return 0;
	}
	cout << B << endl;
	return 0;
}

Compiler output:
a.cc:7:9: error: 'vector' does not name a type
    7 | typedef vector<long> vl;
      |         ^~~~~~
a.cc: In function 'int main()':
a.cc:13:9: error: 'vl' was not declared in this scope; did you mean 'll'?
   13 |         vl a;
      |         ^~
      |         ll
a.cc:15:24: error: 'a' was not declared in this scope
   15 |                 cin >> a.at(i);
      |                        ^
a.cc:22:21: error: 'a' was not declared in this scope
   22 |                 if (a.at(j) = i) {
      |                     ^
Language: C++

#include<iostream>

using namespace std;

int main(void)
{
  int n;
  int[] a(n);
  
  cin>>n;
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  
  int buf1,buf2;
  bool can=false;
  
  for(int i=0;i<n;i++)
  {
    if(i<=a[i])
      buf1=i;
      buf2=a[i];
      can=true;
      break;
  }
  
  int dec;
  
  if(can==true)
  {
   for(int i=0;i<n;i++)
   {
     if(buf2==buf1-i+1)
     {
       cout<<i<<endl;
       break;
     }
    
   }
  }
  else
    cout<<-1<<endl;
}
      
  
  


Compiler output:
a.cc: In function 'int main()':
a.cc:8:6: error: structured binding declaration cannot have type 'int'
    8 |   int[] a(n);
      |      ^~
a.cc:8:6: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:8:6: error: empty structured binding declaration
a.cc:8:9: error: expected initializer before 'a'
    8 |   int[] a(n);
      |         ^
a.cc:14:10: error: 'a' was not declared in this scope
   14 |     cin>>a[i];
      |          ^
a.cc:22:11: error: 'a' was not declared in this scope
   22 |     if(i<=a[i])
      |           ^
a.cc:24:12: error: 'a' was not declared in this scope
   24 |       buf2=a[i];
      |            ^
Language: C++

#include<iostream>

using namespace std;

int main(void)
{
  int n;
  int a(n);
  
  cin>>n;
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  
  int buf1,buf2;
  bool can=false;
  
  for(int i=0;i<n;i++)
  {
    if(i<=a[i])
      buf1=i;
      buf2=a[i];
      can=true;
      break;
  }
  
  int dec;
  
  if(can==true)
  {
   for(int i=0;i<n;i++)
   {
     if(buf2==buf1-i+1)
     {
       cout<<i<<endl;
       break;
     }
    
   }
  }
  else
    cout<<-1<<endl;
}
      
  
  


Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: invalid types 'int[int]' for array subscript
   14 |     cin>>a[i];
      |           ^
a.cc:22:12: error: invalid types 'int[int]' for array subscript
   22 |     if(i<=a[i])
      |            ^
a.cc:24:13: error: invalid types 'int[int]' for array subscript
   24 |       buf2=a[i];
      |             ^
Language: C++

#include<iostream>

using namespace std;

int main(void)
{
  int n;
  int a(n);
  
  cin>>n;
  
  for(int i=0;i<n;i++)
  {
    cin>>a[n];
  }
  
  int buf1,buf2;
  bool can=false;
  
  for(int i=0;i<n;i++)
  {
    if(i<=a[i])
      buf1=i;
      buf2=a[i];
      can=true;
      break;
  }
  
  int dec;
  
  if(can==true)
  {
   for(int i=0;i<n;i++)
   {
     if(buf2==buf1-i+1)
     {
       cout<<i<<endl;
       break;
     }
    
   }
  }
  else
    cout<<-1<<endl;
}
      
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: invalid types 'int[int]' for array subscript
   14 |     cin>>a[n];
      |           ^
a.cc:22:12: error: invalid types 'int[int]' for array subscript
   22 |     if(i<=a[i])
      |            ^
a.cc:24:13: error: invalid types 'int[int]' for array subscript
   24 |       buf2=a[i];
      |             ^
Language: C++

#include<bits/stdc++.h>
#include<string>
#include<numeric>
using namespace std;
//max=({});

int main() {
	int n;
	vecor<int>a(n);
	for (int i = 1;i <= n;++i) {
		cin >> a[i];
	}
	int res = 1;
	int ans = 0;
	int under = 1;
	for (int i = under;i <= n;++i) {
		if (a[i] != res) {
			++ans;
		}
		else {
			++res;
			under = res;
		}
	}
	if (res == 1)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'vecor' was not declared in this scope
    9 |         vecor<int>a(n);
      |         ^~~~~
a.cc:9:15: error: expected primary-expression before 'int'
    9 |         vecor<int>a(n);
      |               ^~~
a.cc:11:24: error: 'a' was not declared in this scope
   11 |                 cin >> a[i];
      |                        ^
a.cc:17:21: error: 'a' was not declared in this scope
   17 |                 if (a[i] != res) {
      |                     ^
Language: C++

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

int main() {
  int n;
  cin >>  n;
  int a[n+5];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }

  int ans=0;
  int idx=1;
  bool one=false
  for(int i=0; i<n; i++){
    if(a[i]==1) one=true;
    if(a[i]!=idx){
      ans++;
      continue;
    }
    else{
      idx++;
    }
  }

  if((ans==0 && idx!=(n+1)) || one==false) cout<<-1;
  //else(ans!=0 && idx==(n+1))
  else cout << ans;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:3: error: expected ',' or ';' before 'for'
   15 |   for(int i=0; i<n; i++){
      |   ^~~
a.cc:15:16: error: 'i' was not declared in this scope
   15 |   for(int i=0; i<n; i++){
      |                ^
Language: C++


#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int* a = new int[n];
    int k = n+10;
    int f = 0;
    for (int i = 0; i < n; i++) {
        cin>>a[i];
        a[i]=  a[i] - ( i -1 1 );
    }
    for (int i = 0; i < n; i++) {
        if (a[i] <= 0) {
            if (k < a[i]) {
                k = a[i];
                f = 1;
            }
        }
    }
    if (f == 0)
        k = -1;
    std::cout << k<<"\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:29: error: expected ')' before numeric constant
   13 |         a[i]=  a[i] - ( i -1 1 );
      |                       ~     ^~
      |                             )
Language: Java

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class BrickBreak {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		List<Integer> list = new ArrayList<Integer>();
		int count = 1;
		int Hakai = 0;

		for(int i = 0;i < a.length;i++) {
			a[i] = sc.nextInt();
		}



		for(int i = 0;i < a.length;i++) {
			if(a[i] == count) {
				count++;
			}else {
				Hakai++;
			}
		}
		if(count-1 + Hakai == n && count != 1) {
			System.out.println(Hakai);
		}else {
			System.out.println(-1);
		}

	}

}


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

#include <iostream>

using namespace std;

int main()
{

  int N;
  cin >> N;
  
  vector<int> suji;
  
  for(int i=0;i<N;i++) 
  {
    int buf;
    cin >> buf;
    suji.push_back(buf);
  }
  int count = 1;
  int break_count = 0;
  for(auto ite:suji) 
  {
    if(ite==count){
    }else{
    	break_count++;
    }
    count++;
  }
  if(break_count==0){
  break_count = -1;
  }
  cout << break_count;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'vector' was not declared in this scope
   11 |   vector<int> suji;
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:11:10: error: expected primary-expression before 'int'
   11 |   vector<int> suji;
      |          ^~~
a.cc:17:5: error: 'suji' was not declared in this scope
   17 |     suji.push_back(buf);
      |     ^~~~
a.cc:21:16: error: 'suji' was not declared in this scope
   21 |   for(auto ite:suji)
      |                ^~~~
Language: C++

#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
	int n,x,a=1,f=0,c=0;
	cin>>n;
	vector <int> v;
	while(n--)
	{
		cin>>x;
		v.push_back(x);
	}
	vector<int>:: iterator it,pit;
    
	pit=v.begin();
	it =find(pit,v.end(),a);
	if (it!=v.end())
	{
	 c+=(it-pit);
	 a++;
	 f=1;
    }
    pit=it;
    it =find(pit,v.end(),a);
	while(it !=v.end())
	{
		
		c+=(it-pit-1);
		pit=it;
		a++;
		it=find(pit,v.end(),a);
		
	}
  
  
    if (f==1)
	cout<<c;
    else
    cout<<-1
	
	
}
	


	
	
	
   



Compiler output:
a.cc: In function 'int main()':
a.cc:43:13: error: expected ';' before '}' token
   43 |     cout<<-1
      |             ^
      |             ;
......
   46 | }
      | ~
Language: C++

#include <vector>
using namespace std;
#define min(x,y) (x<y)?x:y 
#define max(x,y) (x>y)?x:y

int main(void)
{
	int N;
	vector<int> a;
	cin >> N;
	a.resize(N);
	for (int i = 0; i < N; i++)cin >> a[i];

	int judge = 1;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (judge == a[i])judge++;
		else ans++;
	}
	if (judge == 1)ans = -1;

	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope
   10 |         cin >> N;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <vector>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:22:9: error: 'cout' was not declared in this scope
   22 |         cout << ans << endl;
      |         ^~~~
a.cc:22:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:22:24: error: 'endl' was not declared in this scope
   22 |         cout << ans << endl;
      |                        ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <vector>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#include<stdio.h>

int main() {
  int N = 0;
  cin >> N;
  vector<int> a(N, 0);
  for(int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  reverse(a.begin(), a.end());
  int c = 0;
  int d = 0;
  int i = 1;
  while(true) {
    if(a.at(N - 1 - d) != i) {
      a.pop_back();
      c++;
      d++;
    }
    else if(a.at(N - 1 - d) == i) {
      a.pop_back();
      d++;
      i++;
    }
    if(d == N - 1) break;
  }
  if(a.at(0) != i) c++;
  if(c != N) cout << c << endl;
  else cout << -1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   cin >> N;
      |   ^~~
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> a(N, 0);
      |   ^~~~~~
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> a(N, 0);
      |          ^~~
a.cc:8:12: error: 'a' was not declared in this scope
    8 |     cin >> a.at(i);
      |            ^
a.cc:10:11: error: 'a' was not declared in this scope
   10 |   reverse(a.begin(), a.end());
      |           ^
a.cc:10:3: error: 'reverse' was not declared in this scope
   10 |   reverse(a.begin(), a.end());
      |   ^~~~~~~
a.cc:28:14: error: 'cout' was not declared in this scope
   28 |   if(c != N) cout << c << endl;
      |              ^~~~
a.cc:28:27: error: 'endl' was not declared in this scope
   28 |   if(c != N) cout << c << endl;
      |                           ^~~~
a.cc:29:8: error: 'cout' was not declared in this scope
   29 |   else cout << -1 << endl;
      |        ^~~~
a.cc:29:22: error: 'endl' was not declared in this scope
   29 |   else cout << -1 << endl;
      |                      ^~~~
Language: C++

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

int main()
{
  int n;
  cin>>n;
  int a;
  int disc=0;
  int k=1;
  for(i=0;i<n;i++)
  {
    cin>>a;
      if(a!=k)
        disc++;
      else k++;
  }
  if(disc>n-1)
    cout<<-1<<endl;
  else cout<<disc<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   for(i=0;i<n;i++)
      |       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int count = 0;
  
  for (int i = 0; i < n; i++) {
    if (a.at(i) == count + 1) {
      count++;
    }
  }
  
  cout << n - count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'N' was not declared in this scope
    8 |   vector<int> a(N);
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
int32_t main()
{
    int n,i,br=0,x=1;
  	cin>>n;
  	for(i=0;i<n;i++)
    {
      	cin>>a[i];
      	if(a[i]==x)
        {
          	x++;
        }
     	 else
         {
           	br++;
         }
    }
  if(br==n)
    cout<<-1<<endl;
  else
    cout<<br<<endl;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:15:14: error: 'a' was not declared in this scope
   15 |         cin>>a[i];
      |              ^
Language: C++

int main(){
  int N;
  cin >>N;
  vector<int> brick(N);
  int i=1;
  
  for (int j=0;j<N;j++){
    cin >>brick.at(j);
    if (brick.at(j)==i){
      i++;
    }
  }
  if (i==1){
    cout << -1 <<endl;
  }
  else{
    cout << N-i+1 <<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >>N;
      |   ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int> brick(N);
      |   ^~~~~~
a.cc:4:10: error: expected primary-expression before 'int'
    4 |   vector<int> brick(N);
      |          ^~~
a.cc:8:11: error: 'brick' was not declared in this scope
    8 |     cin >>brick.at(j);
      |           ^~~~~
a.cc:14:5: error: 'cout' was not declared in this scope
   14 |     cout << -1 <<endl;
      |     ^~~~
a.cc:14:18: error: 'endl' was not declared in this scope
   14 |     cout << -1 <<endl;
      |                  ^~~~
a.cc:17:5: error: 'cout' was not declared in this scope
   17 |     cout << N-i+1 <<endl;
      |     ^~~~
a.cc:17:21: error: 'endl' was not declared in this scope
   17 |     cout << N-i+1 <<endl;
      |                     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec;
  for(int i=0,i<n,i++){
    cin >> vec.at(i);
  }
  int a=1;
  for(int i=0,i<n,i++){
    if(vec.at(i)==a){
      a++;
    }
  }
  cout << n+1-a << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:16: error: expected ';' before '<' token
    7 |   for(int i=0,i<n,i++){
      |                ^
      |                ;
a.cc:7:16: error: expected primary-expression before '<' token
a.cc:7:22: error: expected ';' before ')' token
    7 |   for(int i=0,i<n,i++){
      |                      ^
      |                      ;
a.cc:11:16: error: expected ';' before '<' token
   11 |   for(int i=0,i<n,i++){
      |                ^
      |                ;
a.cc:11:16: error: expected primary-expression before '<' token
a.cc:11:22: error: expected ';' before ')' token
   11 |   for(int i=0,i<n,i++){
      |                      ^
      |                      ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vetor<int> vec;
  for(int i=0,i<n,i++){
    cin << vec.at(i);
  }
  int a=1;
  for(int i=0,i<n,i++){
    if(vec.at(i)==a){
      a++;
    }
  }
  cout << n+1-a << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'vetor' was not declared in this scope
    6 |   vetor<int> vec;
      |   ^~~~~
a.cc:6:9: error: expected primary-expression before 'int'
    6 |   vetor<int> vec;
      |         ^~~
a.cc:7:16: error: expected ';' before '<' token
    7 |   for(int i=0,i<n,i++){
      |                ^
      |                ;
a.cc:7:16: error: expected primary-expression before '<' token
a.cc:7:22: error: expected ';' before ')' token
    7 |   for(int i=0,i<n,i++){
      |                      ^
      |                      ;
a.cc:8:12: error: 'vec' was not declared in this scope
    8 |     cin << vec.at(i);
      |            ^~~
a.cc:11:16: error: expected ';' before '<' token
   11 |   for(int i=0,i<n,i++){
      |                ^
      |                ;
a.cc:11:16: error: expected primary-expression before '<' token
a.cc:11:22: error: expected ';' before ')' token
   11 |   for(int i=0,i<n,i++){
      |                      ^
      |                      ;
a.cc:12:8: error: 'vec' was not declared in this scope
   12 |     if(vec.at(i)==a){
      |        ^~~
Language: C++

#include "Header.h"
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v.at(i);
	int ans = 0;
	int now = 1;
	rep(i, n) {
		if (v.at(i) == now) {
			now++;
			continue;
		}else ans++;
	}
	if (ans == n) cout << -1 << endl;
	else cout << ans << endl;
	return 0;

}

Compiler output:
a.cc:1:10: fatal error: Header.h: No such file or directory
    1 | #include "Header.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: expected primary-expression before ')' token
   10 |     if(a[i]==k;){
      |                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long int a,b,c,ar[100009],sum;
int main()
{
  cin>>a;
 long long int j=1;

  for(int i=1;i<=a;i++)
     cin>>ar[i];
    for(int i=1;i<=a;i++)
    {
      if(ar[i]!=j)
        cnt++;
      else
      {
       j++;
      }
    }

      if(cnt==a)
         cout<<"-1"<<endl;
       else
         cout<<cnt<<endl;

       return 0;
   }





Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   14 |         cnt++;
      |         ^~~
      |         int
a.cc:21:10: error: 'cnt' was not declared in this scope; did you mean 'int'?
   21 |       if(cnt==a)
      |          ^~~
      |          int
Language: C++

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

int main()
{
  int n;
  cin>>n;
  int a[n];
  int flag=0;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=0;i<n;i++)
  {
    if(a[i]==1)
    {
      flag=1;
      break;
    }
  }
  int count=0;
  int k=1;
  if(flag==1)
  {
   for(i=0;i<n;i++)
   {
     if(a[i]!=k)
       count++;
     else k++;
   }
    cout<<count;
  }
  else cout<<-1;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   for(i=0;i<n;i++)
      |       ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i=0;i<n;i++)
      |       ^
a.cc:26:8: error: 'i' was not declared in this scope
   26 |    for(i=0;i<n;i++)
      |        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define me(a,b) memset(a,b,sizeof(a))
int a[200010];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	int and=1;
	for(int i=0;i<n;i++){
		if(a[i]==ans)
		ans++
	}
	cout<<n-ans+1==n?-1:n-ans+1<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:16: error: expected unqualified-id before '=' token
   14 |         int and=1;
      |                ^
a.cc:16:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |                 if(a[i]==ans)
      |                          ^~~
      |                          abs
a.cc:19:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         cout<<n-ans+1==n?-1:n-ans+1<<endl;
      |                 ^~~
      |                 abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define me(a,b) memset(a,b,sizeof(a))
int a[200010]
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	int and=1;
	for(int i=0;i<n;i++){
		if(a[i]==ans)
		ans++
	}
	cout<<n-ans+1==n?-1:n-ans+1<<endl;
	return 0;
}

Compiler output:
a.cc:7:1: error: expected initializer before 'int'
    7 | int main(){
      | ^~~
Language: C++

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

int main()
{
  int n;
  cin>>n;
  int a[n];
  int flag=0;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]==1)
      flag=1;
  }
  int count=0;
  int k=1;
  if(flag==1)
  {
  for(i=0;i<n;i++)
  {
    if(a[i]!=k)
      count++;
    else k++;
  }
    cout<<count;
  }
  else cout<<-1;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   for(i=0;i<n;i++)
      |       ^
a.cc:20:7: error: 'i' was not declared in this scope
   20 |   for(i=0;i<n;i++)
      |       ^
Language: C++

#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();

ULL main(){
    ULL N;
    ULL i;
    ULL a;
    ULL num;
    cin >> N;
    num = 0;
    for(i=0;i<N;i++){
        cin >> a;
        if( a == num + 1){
            num++;
        }
    }
    if( num == 0){
        cout << -1 << endl;
    }else{
        cout << N - a<< endl;
    }
    return 0;
}

void process(){
    
}

Compiler output:
a.cc:14:1: error: '::main' must return 'int'
   14 | ULL main(){
      | ^~~
Language: C++

#include <algorithm>
#include <cstdio>

using namespace std ;

const int N=2e5+10 ;

vector<int> V[N] ;
int n ;

int main ()
{
	int i , x , res=0 ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ )
		scanf("%d",&x),
		V[x].push_back(i);
	x=0;
	vector<int>::iterator it ;
	for ( i=1 ; i<=n ; i++ )
	{
		it=upper_bound(V[i].begin(),V[i].end(),x);
		if ( it==V[i].end() ) break;
		x=*it,++res;
	}
	if ( !res ) puts("-1");
	else printf("%d\n",n-res);
	return 0 ;
}


Compiler output:
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<int> V[N] ;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:17:17: error: 'V' was not declared in this scope
   17 |                 V[x].push_back(i);
      |                 ^
a.cc:19:9: error: 'vector' was not declared in this scope
   19 |         vector<int>::iterator it ;
      |         ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <cstdio>
  +++ |+#include <vector>
    3 | 
a.cc:19:16: error: expected primary-expression before 'int'
   19 |         vector<int>::iterator it ;
      |                ^~~
a.cc:22:17: error: 'it' was not declared in this scope; did you mean 'i'?
   22 |                 it=upper_bound(V[i].begin(),V[i].end(),x);
      |                 ^~
      |                 i
a.cc:22:32: error: 'V' was not declared in this scope
   22 |                 it=upper_bound(V[i].begin(),V[i].end(),x);
      |                                ^