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

#include <iostream>
using namespace std;

int main() {
	int N;cin>>N;
	vector<int>a(N);
	for(int i=0;i<N;i++)cin>>a[i];
	
	int cnt = 0;
	for(int i=0;i<N;i++)
	{
		if(a[i] == cnt+1)
		{
			cnt++;
		}
	}
	
	if(cnt==0)cout<<-1<<endl;
	else cout<<N-cnt<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'vector' was not declared in this scope
    6 |         vector<int>a(N);
      |         ^~~~~~
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 | using namespace std;
a.cc:6:16: error: expected primary-expression before 'int'
    6 |         vector<int>a(N);
      |                ^~~
a.cc:7:34: error: 'a' was not declared in this scope
    7 |         for(int i=0;i<N;i++)cin>>a[i];
      |                                  ^
a.cc:12:20: error: 'a' was not declared in this scope
   12 |                 if(a[i] == cnt+1)
      |                    ^
Language: C++

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

int main() {
	int N, a;
	cin >> N;
	int k = 1;

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

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

#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    scanf("%d",&n);
    vector <int> a(n);
    rep(i,n)    scanf("%d",&a[i]);

    int ans=0;
    rep(i,n) {
        if(a[i]!=i+1) {
            a.erase(a.begin()+i);
            ans++;
            i--;
            n--;
        }
    }
    if(a.empty())   printf("%d",-1);
    else    printf("%d",ans)

 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:29: error: expected ';' before 'return'
   23 |     else    printf("%d",ans)
      |                             ^
      |                             ;
   24 | 
   25 |  return 0;
      |  ~~~~~~
Language: C++

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

int main()
{
    long long n;
    cin>>n;
    
    if(n==1) cout<<"0"<<"\n";
    
    else{
    vector<long long>v;
    set<long long>s;
     int l;
    for(int i=0;i<n;i++){
        long long x;
        cin>>x;
        l=x;
        v.push_back(x);
        //if(i!=n-1){
        s.insert(x);
        }
    }
    
    if(s.size()==1) cout<<"-1"<<"\n";
    else
     cout<<v.size()-l<<"\n";
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:8: error: 's' was not declared in this scope
   25 |     if(s.size()==1) cout<<"-1"<<"\n";
      |        ^
a.cc:27:12: error: 'v' was not declared in this scope
   27 |      cout<<v.size()-l<<"\n";
      |            ^
a.cc:27:21: error: 'l' was not declared in this scope
   27 |      cout<<v.size()-l<<"\n";
      |                     ^
a.cc: At global scope:
a.cc:29:5: error: expected unqualified-id before 'return'
   29 |     return 0;
      |     ^~~~~~
a.cc:30:1: error: expected declaration before '}' token
   30 | }
      | ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
  	int n, x, actual=0, brick=0;
  	cin >> n;
  	
  	for(int i=0; i<n; i++){
    	cin >> x;
      	if(x==actual+1) actual++;
      	else brick++:
    }
  	
  	if(actual) cout << brick;
  	else cout << -1;
  
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:21: error: expected ';' before ':' token
   12 |         else brick++:
      |                     ^
      |                     ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[i];
  rep(i,n) cin>>a[i];
  int ans=0,now=1;
  rep(i,n){
    if(a[i]!=now){
      ans++;
    }else{
      now++;
    }
  }
  if(ans==n) cout<<-1<<endl;
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'i' was not declared in this scope
   23 |   int a[i];
      |         ^
a.cc:24:17: error: 'a' was not declared in this scope
   24 |   rep(i,n) cin>>a[i];
      |                 ^
a.cc:27:8: error: 'a' was not declared in this scope
   27 |     if(a[i]!=now){
      |        ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:31: error: 'h' was not declared in this scope
   14 |                 printf("%d",n-h+1);
      |                               ^
Language: C++

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

int num_order_bricks(vector<int> numbers, int size)
{
    int aux = 1, count = 0, bricks=0;
    bool find_one = false;
    while(size--)
    {
        if(numbers[count]== aux )
        {
            bricks++;
            aux++;
        }
        count++;
    }
    return bricks;
}
int main()
{
    int size, n, num_break_bricks;
    cin >> size;
    vector<int> size_ladrillos;
    while(size--)
    {
        cin>>n;
        size_ladrillos.push_back(n);
    }
    
    std::vector<int>::iterator it = std::find(size_ladrillos.begin(), size_ladrillos.end(), 1);
    if(it !=size_ladrillos.end() && size_ladrillos.size() <= 20000){
        num_break_bricks= num_order_bricks(size_ladrillos, size_ladrillos.size());
        cout<< size_ladrillos.size() - num_break_bricks << endl;
    }
    else
        cout<< -1 << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:46: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
   31 |     std::vector<int>::iterator it = std::find(size_ladrillos.begin(), size_ladrillos.end(), 1);
      |                                     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:31:46: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   31 |     std::vector<int>::iterator it = std::find(size_ladrillos.begin(), size_ladrillos.end(), 1);
      |                                     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'z' was not declared in this scope
   25 |     z=n-count+1;
      |     ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'z' was not declared in this scope
   24 |     z=n-count+1;
      |     ^
a.cc:25:15: error: 'z' was not declared in this scope
   25 |         cout<<z<<endl;
      |               ^
Language: C++

#include<iostream>

usng namespace std;

int main(){
  
  int N;
  
  int a[200000];
  
  cin >> N;
  
  int Count = 0;
  
  int Count_ = 0;
  
  for(int i = 0; i < N; i++){
    
    cin >> a[i];
    
  }
  
  for(int i = 0; i < N; i++){
    
    for(int j = Count_; j < N; j++){
      
      if(a[j] == i+1) {
        
        Count++;
        
        break;
        
      }
        
      else continue;
      
    }
    
    Count_ = j;
    
  }
  
  if(Count==0;) cout << -1;
  
  else cout << N - Count;
  
}
    
    

Compiler output:
a.cc:3:1: error: 'usng' does not name a type
    3 | usng namespace std;
      | ^~~~
a.cc: In function 'int main()':
a.cc:11:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   11 |   cin >> N;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:39:14: error: 'j' was not declared in this scope
   39 |     Count_ = j;
      |              ^
a.cc:43:15: error: expected primary-expression before ')' token
   43 |   if(Count==0;) cout << -1;
      |               ^
a.cc:43:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   43 |   if(Count==0;) cout << -1;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:45:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   45 |   else cout << N - Count;
      |        ^~~~
      |        std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{long long n;
int b=1;
int c=0;
int x=0;
cin>>n;
for(int i=0;i<n;i++){
    int m;
    cin>>m;
    if(m==1){
        x=x+1;
    }
    if(m==b){
        c=c+1;
        b=b+1;
    }
}
if(!x) cout<<-1; else
cout<<n-c;

    return 0;

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

		/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	ll n;
	cin>>n;
	vector<ll>arr(n+10);
	ll fl=0;
	for(ll i=1;i<=n;i++)
	{
		cin>>arr[i];
		if(arr[i]==1)
		{
			fl=1;
		}
	}
	if(fl==0)
	{
		cout<<-1;
	}
	else
	{
		ll reqd=1;
		ll pos=0;
		ll ccount=0;
		for(ll i=1;i<=n;i++)
		{
			if(arr[i]==reqd)
			{
				pos=i;
				ccount++;
				reqd++;
			}
		}
		cout<<(pos-ccount+(n-pos));
	}
    return 0;
}


//252908XL

Compiler output:
a.cc: In function 'int main()':
a.cc:34:12: error: redeclaration of 'll n'
   34 |         ll n;
      |            ^
a.cc:32:12: note: 'll n' previously declared here
   32 |         ll n;
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
const int MN = 2e5+5, MOD=1e9+7;
ll lcm (ll a, ll b) {return a*b/__gcd(a,b);}
ll multiplyMod(ll a, ll b) { return (a % MOD * b % MOD) % MOD; }
ll addMod(ll a, ll b) { return (a % MOD + b % MOD) % MOD; }
ll subMod(ll a, ll b) { return (a % MOD - b % MOD) % MOD; }
ll fpow(ll b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
int n;
vi occur[MN];
vi a;
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0,z ;i<n;i++) {
        cin >> z;
        occur[z].pb(i);
        a.pb(z);
    }
    int prev = -1;
    int ans = 0;
  
    for (int i = 1; i<=n;i++) {
        if (upper_bound(occur[i].begin(), occur[i].end(), prev-1) == occur[i].end()) {
            if (i == 1 && a[0] != 1) {
                cout << -1 << "\n";
                return 0;
            }
            break;
        }
        ans += occur[i][ptr] - (prev+1);
        prev = occur[i][ptr];
    }
    cout << ans << "\n";
 
    return 0;
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:25: error: 'ptr' was not declared in this scope
   44 |         ans += occur[i][ptr] - (prev+1);
      |                         ^~~
Language: C++

#include <bits/stdc++.h

using namespace std;

int main(){
    int n, nr, ncur=1, rez=0;
    cin>>n;
    for(int i=0; i<n; ++i){
        cin>>nr;
        if(nr!=ncur) rez++;
        else ncur++;
    }
    if(rez==n) cout<<-1;
    else cout<<rez;
    return 0;
}


Compiler output:
a.cc:1:24: error: missing terminating > character
    1 | #include <bits/stdc++.h
      |                        ^
Language: C++

#include<bits/stdc++.h>
using namespace  std;
int main(){


  int N;
  long long A[200000];
  cin>>N;

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

  for(int i=1;i<=N;i++){
    if(i==A[i]) po++;
    else {po++; sta++}

  }
  if(N==sta) cout<<-1;
  else  cout<<sta<<endl;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:18:22: error: expected ';' before '}' token
   18 |     else {po++; sta++}
      |                      ^
      |                      ;
Language: C++

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n, a[maxn];
int lo=0;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

  cin>>n;
  for (int i=0; i<n; i++) {
    int x; cin>>x;
    if (lo+1==x) x++;
  }
  if (x==0) out(-1);
  cout<<n-x<<endl;
  

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:7: error: 'x' was not declared in this scope
   21 |   if (x==0) out(-1);
      |       ^
a.cc:22:11: error: 'x' was not declared in this scope
   22 |   cout<<n-x<<endl;
      |           ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
const int MAX = 200000;

int main(){
  int n;
  cin >> n;
  
  vector<int> a(MAX);
  for(int i=0; i<n; i++){
  	cin >> a.at(i);
  }
 
  int last = -1;
  int ct = 0;    //見つかった数
  
  for(int i=1; i<=n; i++){ //探している数字
    for(int j=last+1; j<n; j++){ //最初から順に
      if(a.at(j)==i){
        last = j;
        ct++;
        break; //見つかったら次の数へ
      }
    }
    if(last<=j){ //lastが更新されてなければ
      break; //見つからなかったら抜ける
    }
  }

  if(ct){
    cout << n - ct << endl;
  }
  else{
    cout << "-1" << endl;
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:14: error: 'j' was not declared in this scope
   26 |     if(last<=j){ //lastが更新されてなければ
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
int a,c=1;
  cin>>a;
  int d=a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  rep(i,a){
  if(a[i]==c){
  c++;
    a[i]=0;
  }
  }
  rep(i,a){
  if(a[i]==0)
    d--;
  }
    cout<<d;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:7: error: invalid types 'long long int[long long int]' for array subscript
   24 |   if(a[i]==c){
      |       ^
a.cc:26:6: error: invalid types 'long long int[long long int]' for array subscript
   26 |     a[i]=0;
      |      ^
a.cc:30:7: error: invalid types 'long long int[long long int]' for array subscript
   30 |   if(a[i]==0)
      |       ^
Language: C++

N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
	if(a[i] == ans + 1):
		ans += 1
if(ans == 0):
	print(-1)
else: 
	print(N - ans)

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,a[200010];
{
  cin>>n;
  for(i=1;i<=n;i++)
    cin>>a[i];
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=n;j++)
      if(a[j]=i)
      {
        l++;
        break;
      }
    if(l!=i)
      break;
  }
  if(l==0)
    cout<<"-1"<endl;
  else
    cout<<n-i<<endl;
}


Compiler output:
a.cc:4:1: error: expected unqualified-id before '{' token
    4 | {
      | ^
Language: C++

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int k=1, ans=0;
    rep(i,n) {
        if (nxt == a[i]) {
            ++k;
        } else {
            ++ans;
        }
    }
    if (ans==n) ans=-1;
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'i' was not declared in this scope
    8 |     rep(i,n) cin >> a[i];
      |         ^
a.cc:8:5: error: 'rep' was not declared in this scope
    8 |     rep(i,n) cin >> a[i];
      |     ^~~
Language: C++

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

Compiler output:
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:13:24: error: expected ';' before 'else'
   13 |   if(k==n-1) cout<<"-1"
      |                        ^
      |                        ;
   14 |     else
      |     ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
long long a,b,l,n;
string s;
 
int main(){
	
  cin >> n;
  
  int a;
  
  for (int i=0; i<n; i++){
    	cin >> a;
		s+=(char)(a+48)
  	}
  
  sort(s.begin(), s.end());
  
  for (int i=0; i<n; i++){
    if (i>=0)
  	if (s[i]!=i+48){
    	s.erase(i, 1);
      	l++;
      	i--;
    }
  }
  
  cout << l << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:32: error: expected ';' before '}' token
   15 |                 s+=(char)(a+48)
      |                                ^
      |                                ;
   16 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
long long a,b,l;
 
int main(){
	
  cin >> n;
  
  int a;
  
  for (int i=0; i<n; i++){
    	cin >> a;
		s+=(char)(a+48)
  	}
  
  sort(s.begin(), s.end());
  
  for (int i=0; i<n; i++){
    if (i>=0)
  	if (s[i]!=i+48){
    	s.erase(i, 1);
      	l++;
      	i--;
    }
  }
  
  cout << l << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |   cin >> n;
      |          ^
      |          yn
a.cc:14:17: error: 's' was not declared in this scope
   14 |                 s+=(char)(a+48)
      |                 ^
a.cc:17:8: error: 's' was not declared in this scope
   17 |   sort(s.begin(), s.end());
      |        ^
Language: C++

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

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  vector<int> a(n); for (int& x : a) cin >> x;
  for (int i = 0, j, d = 1; i < n; ++i) {
    for (j = i; j < n && a[j] != d; ++j);
    ++d;
  }
  cout << n - d << '\n';
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: 'd' was not declared in this scope
   12 |   cout << n - d << '\n';
      |               ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:6:16: error: 'a' was not declared in this scope
    6 |         cin >> a; if(a == s) s++;
      |                ^
Language: C++

#include<iostream>
#include<string>
#include <cmath>
#include <limits>
#include <numeric>

using namespace std;

int main(){
    int N, a;
    queue<int> q;
    cin >> N;
    for (auto i = 0; i < N; i++){
        cin >> a;
        q.push(a)
    }
    int count = 0;
    int now_block = 1;
    for (auto i = 0; i < N; i++){
        if (q.front() == now_block){
            count++;
            now_block++;
            q.pop()
        }else{
            q.pop()
        }
    }
    int answer = N - count;
    cout << answer << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'queue' was not declared in this scope
   11 |     queue<int> q;
      |     ^~~~~
a.cc:6:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    5 | #include <numeric>
  +++ |+#include <queue>
    6 | 
a.cc:11:11: error: expected primary-expression before 'int'
   11 |     queue<int> q;
      |           ^~~
a.cc:15:9: error: 'q' was not declared in this scope
   15 |         q.push(a)
      |         ^
a.cc:20:13: error: 'q' was not declared in this scope
   20 |         if (q.front() == now_block){
      |             ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:22: error: 'res' was not declared in this scope
   13 |                 else res++;
      |                      ^~~
Language: C++

N = int(input())
a = list(map(int,input().split()))
cur=1
res=0

for i in range(N):
    if(a[i]!=cur):
        res+=1
    else:
        cur+=1
if(cur==1): print(-1)
else: print(res)

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

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



int main(){

    int n;
    cin>>n;
    int cnt = 1;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x==cnt) cnt++;
    }
    if(cnt==1) cout<<-1<<endl;
    else cout<<n+1-cnt<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'cin' was not declared in this scope
   10 |     cin>>n;
      |     ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<string>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:17:16: error: 'cout' was not declared in this scope
   17 |     if(cnt==1) cout<<-1<<endl;
      |                ^~~~
a.cc:17:16: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:17:26: error: 'endl' was not declared in this scope
   17 |     if(cnt==1) cout<<-1<<endl;
      |                          ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<string>
  +++ |+#include <ostream>
    3 | using namespace std;
a.cc:18:10: error: 'cout' was not declared in this scope
   18 |     else cout<<n+1-cnt<<endl;
      |          ^~~~
a.cc:18:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:18:25: error: 'endl' was not declared in this scope
   18 |     else cout<<n+1-cnt<<endl;
      |                         ^~~~
a.cc:18:25: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  long int n,x;
  vector<int> v;
  cin>>n;
  for(long int i=0;i<n;i++)
  {
    cin>>x;
    v.push_back(x);
  }
  long int c=0;
  sort(v.begin(),v.end());
  for(long int i=0;i<n;i++)
  {
    if(v[i]==i+1)
      c++;
    else
      break;
  }
  long int y=n-c;
  cout<<y;
}
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  long int n,x;
  vector<int> v;
  cin>>n;
  for(long int i=0;i<n;i++)
  {
    cin>>x;
    v.push_back(x);
  }
  long int c=0;
  sort(v.begin(),v.end());
  for(long int i=0;i<n;i++)
  {
    if(v[i]==i+1)
      c++;
    else
      break;
  }
  long int y=n-c;
  if(c==0)
    cout<<"-1";
  else
  cout<<y;
}


Compiler output:
a.cc:31:5: error: redefinition of 'int main()'
   31 | int main()
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main()
      |     ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  long int n,x;
  vector<int> v;
  cin>>n;
  for(long int i=0;i<n;i++)
  {
    cin>>x;
    v.push_back(x);
  }
  long int c=0;
  sort(v.begin(),v.end());
  for(long int i=0;i<n;i++)
  {
    if(v[i]==i+1)
      c++;
    else
      break;
  }
  long int y=n-c;
  cout<<y;
}
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  long int n,x;
  vector<int> v;
  cin>>n;
  for(long int i=0;i<n;i++)
  {
    cin>>x;
    v.push_back(x);
  }
  long int c=0;
  sort(v.begin(),v.end());
  for(long int i=0;i<n;i++)
  {
    if(v[i]==i+1)
      c++;
    else
      break;
  }
  long int y=n-c;
  if(y==n)
    cout<<"-1";
  else
  cout<<y;
}
Submission Info

Compiler output:
a.cc:31:5: error: redefinition of 'int main()'
   31 | int main()
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main()
      |     ^~~~
a.cc:56:1: error: 'Submission' does not name a type
   56 | Submission Info
      | ^~~~~~~~~~
Language: C++

int main(void){
	unsigned int N;
	int cls=0;	
	int blicknum=0;
	int scBlicknum=1;
	scanf("%d",&N);
	for(int m=0;m<N;m++){
		scanf("%d",&blicknum);
		if(blicknum==scBlicknum){
			scBlicknum++;
		}else{
			cls++;
		}
	} 
	if(cls==N){
		cls=-1;
	}
	printf("%d",cls);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'scanf' was not declared in this scope
    6 |         scanf("%d",&N);
      |         ^~~~~
a.cc:18:9: error: 'printf' was not declared in this scope
   18 |         printf("%d",cls);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int main(void){
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    int target = 1;
    int rmv = 0;
    
    for(int i = 0;i < n;i++){
        if(target == a[i]){
            target++;
        }else{
            rmv++;
        }
    }
    
    cout << (rmv == n) ? -1 : rmv << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:35: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   22 |     cout << (rmv == n) ? -1 : rmv << endl;
      |                               ~~~~^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> pos(200005);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        pos[a].push_back(i);
    }
    
    // 1 が存在しないとき
    if(pos[1].size() == 0){
        cout << -1 << endl;
        return 0;
    }
    
    // 現在地 : 1 の中で一番左側の位置
    int now_pos = pos[1][0];
    for(int i = 2; i < 200005; ++i){
      　if(pos[i].size() == 0){
			cout << n - i + 1 << endl;
         	return 0;
        }
        auto it = upper_bound(pos[i].begin(), pos[i].end(), now_pos);
        
        if(it == pos[i].end()){     // 条件を満たすものがない場合
            cout << n - i + 1 << endl;
            return 0;
        }
        
        now_pos = *it;      // 現在地の更新
    }
}

Compiler output:
a.cc:26:7: error: extended character 　 is not valid in an identifier
   26 |       　if(pos[i].size() == 0){
      |       ^
a.cc: In function 'int main()':
a.cc:26:7: error: '\U00003000if' was not declared in this scope
   26 |       　if(pos[i].size() == 0){
      |       ^~~~
Language: C++

#include <bits/stdc++.h>
#define ll long long 
#define endl '\n'
#define debug(x)  cout<<x<<" ";
#define for(i,n) for(i=0;i<n;i++)
#define fastInOut   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;

int main() {
    fastInOut
    ll x;
    cin>>x;
    int A[x];
    int i;
    for(i,x){
        cin>>A[i];
    }
    int c=0;
    int h=1;
    for(i,x){
        if(A[i]!=h)
           c++;
        else 
          h++;
    }
    if(c==x)
      debug(-1);
      else
    debug(c);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:7: error: 'else' without a previous 'if'
   28 |       else
      |       ^~~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector[int] raw_number(N);
  for(int i=0; i<N ; i++){
    cin >> raw_number.at(i);
  }
  
  int k = 1;//現在の数字
  int c = 0;//潰すレンガの数
  int i = 0;//繰り返す数
  while(i<N){
    if(raw_number.at(i) == k)
      k++;
    else
      c++;
    i++;
  }
  if(c == n)
    cout << -1 << endl;
  else 
    cout << c << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: expected identifier before 'int'
    7 |   vector[int] raw_number(N);
      |          ^~~
a.cc:7:10: error: expected ']' before 'int'
    7 |   vector[int] raw_number(N);
      |          ^~~
      |          ]
a.cc:7:9: error: empty structured binding declaration
    7 |   vector[int] raw_number(N);
      |         ^
a.cc:7:15: error: expected initializer before 'raw_number'
    7 |   vector[int] raw_number(N);
      |               ^~~~~~~~~~
a.cc:9:12: error: 'raw_number' was not declared in this scope
    9 |     cin >> raw_number.at(i);
      |            ^~~~~~~~~~
a.cc:16:8: error: 'raw_number' was not declared in this scope
   16 |     if(raw_number.at(i) == k)
      |        ^~~~~~~~~~
a.cc:22:11: error: 'n' was not declared in this scope
   22 |   if(c == n)
      |           ^
Language: C++

n = int(input())
a = list(map(int, input().split()))
s = set(a)
ans = 0
l = []
for i in s:
  if i in a:
    ans += 1
    f = a.index(i)
    a = a[f:]
    l.append(i)
  else:
    break
ll = list(range(1, ans + 1))
if l == ll:
  ans = n - ans
else:
  ans = -1
print(ans)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> dp(n + 1, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    dp[i + 1] = dp[i] + (a[i] == dp[i] + 1);
  }
  cout << (dp[i] == 0 ? -1 : n - dp[n]) << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: 'i' was not declared in this scope
   14 |   cout << (dp[i] == 0 ? -1 : n - dp[n]) << '\n';
      |               ^
Language: C++

#include <bits/stdc++.h>

#define sc second
#define fr first
#define mk make_pair
#define pb push_back
#define int long long

using namespace std;

const int N = (1e6 + 5);
const int inf = (1e9 + 7);

int n;
int a[N];
int cn = 1;
int last
int ans;

main () {
    cin >> n;

    for (int i = 1; i <= n; i ++) {
        cin >> a[i];
        if (a[i] == cn) {
            cn ++;
            ans += (i - last - 1);
        }
    }
    if (cn == 1) puts("-1");
    else  cout << ans + (n - last) << endl;
}


Compiler output:
a.cc:7:13: error: expected initializer before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:18:1: note: in expansion of macro 'int'
   18 | int ans;
      | ^~~
a.cc:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | main () {
      | ^~~~
a.cc: In function 'int main()':
a.cc:27:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |             ans += (i - last - 1);
      |             ^~~
      |             abs
a.cc:27:25: error: 'last' was not declared in this scope
   27 |             ans += (i - last - 1);
      |                         ^~~~
a.cc:31:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |     else  cout << ans + (n - last) << endl;
      |                   ^~~
      |                   abs
a.cc:31:30: error: 'last' was not declared in this scope
   31 |     else  cout << ans + (n - last) << endl;
      |                              ^~~~
Language: C++

#include <iostream>
using namespace std;

int main()
{
 	int n;
  	cin >> n;
  	vector<int> v(n);
  	for ( int i =0 ; i < n; i++ ){
     	cin >> v[i];
    }
  
  	int cnt =1 , ans =0;
  	for ( int i =0 ; i < n ; i ++ ){
      if ( v[i] == cnt ){
        ans++;
        cnt++;
      }
    }
  	cout << (ans ? n- ans : -1);
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'vector' was not declared in this scope
    8 |         vector<int> v(n);
      |         ^~~~~~
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 | using namespace std;
a.cc:8:16: error: expected primary-expression before 'int'
    8 |         vector<int> v(n);
      |                ^~~
a.cc:10:16: error: 'v' was not declared in this scope
   10 |         cin >> v[i];
      |                ^
a.cc:15:12: error: 'v' was not declared in this scope
   15 |       if ( v[i] == cnt ){
      |            ^
Language: Java

import java.io.*;
import java.util.*;
public class Main {
	public static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
	}

	public static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); }
	public static long lcm(long a, long b) { return a * b / gcd(a, b); }
	public static int abs(int x) { if (x < 0) return -x; return x; }

	public static void main(String[] args) {
		FS in = new FS();

		HashMap<Integer, TreeSet<Integer>> map;
		map = new HashMap<>();

		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			int a = in.nextInt();
			map.putIfAbsent(a, new TreeSet<>());
			map.get(a).put(i);
			map.get(a).put(n + 1);
		}

		int k = 0, l = -1;
		while (true) {
			if (!map.containsKey(k + 1))
				break;
			if (map.get(k + 1).higher(l) != (n + 1)) {
				l = map.get(k + 1).higher(l);
				k++;
			}
			else
				break;
		}

		System.out.println((n - k));
	}
}


Compiler output:
Main.java:31: error: cannot find symbol
			map.get(a).put(i);
			          ^
  symbol:   method put(int)
  location: class TreeSet<Integer>
Main.java:32: error: cannot find symbol
			map.get(a).put(n + 1);
			          ^
  symbol:   method put(int)
  location: class TreeSet<Integer>
2 errors
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[i];

  int count =0;
  for(int i=0; i<n; ++i)
    if(a[i] == count +1) ++count;
  
  if(count ==0)cout << -1<<endl
  else
  cout << n-count<<endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:32: error: expected ';' before 'else'
   14 |   if(count ==0)cout << -1<<endl
      |                                ^
      |                                ;
   15 |   else
      |   ~~~~
Language: C++

#include <bits/stdc++.h>

int main(void){
	int n,ans=0;
	bool breaking=0;
	cin >> n;
	
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin << a[i];
	}
	
	for(int i=0; i<n; i++){
		int cnt=1;
		if(cnt == a[n];){
			continue;
		}else{
			ans++;
			breaking= 1;
		}
	}
	
	if(breaking == 1 && ans == 0){
		ans= -1;
	}
	
	cout << ans << endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |         cin >> n;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:9: error: 'vector' was not declared in this scope
    8 |         vector<int> a(n);
      |         ^~~~~~
a.cc:8:9: note: suggested alternatives:
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:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:8:16: error: expected primary-expression before 'int'
    8 |         vector<int> a(n);
      |                ^~~
a.cc:10:24: error: 'a' was not declared in this scope
   10 |                 cin << a[i];
      |                        ^
a.cc:15:27: error: 'a' was not declared in this scope
   15 |                 if(cnt == a[n];){
      |                           ^
a.cc:15:32: error: expected primary-expression before ')' token
   15 |                 if(cnt == a[n];){
      |                                ^
a.cc:27:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |         cout << ans << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:27:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   27 |         cout << ans << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C

N = int(input())
A = [int(i) for i in input().split()]
now = 1 
for i in range(N):
	if now == A[i]:
		now += 1 
print("{}".format(N - now + 1))

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | N = int(input())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'N' [-Wimplicit-int]
main.c:1:5: error: expected expression before 'int'
    1 | N = int(input())
      |     ^~~
Language: C++

#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin >> a[i];
  int num=1;
  while(1){
    auto itr= find(a.begin(),a.end(),num);
    if(itr!=a.end()){
      a.assign(itr,a.end());
      a.erase(remove(a.begin(), a.end(), num), a.end());
      num++;
    }else break;
  }
  if(num==1) cout << -1 << endl;
  else cout << N-num+1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> N;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:18:14: error: 'cout' was not declared in this scope
   18 |   if(num==1) cout << -1 << endl;
      |              ^~~~
a.cc:18:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:18:28: error: 'endl' was not declared in this scope
   18 |   if(num==1) cout << -1 << endl;
      |                            ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<algorithm>
  +++ |+#include <ostream>
    3 | using namespace std;
a.cc:19:8: error: 'cout' was not declared in this scope
   19 |   else cout << N-num+1 << endl;
      |        ^~~~
a.cc:19:8: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:27: error: 'endl' was not declared in this scope
   19 |   else cout << N-num+1 << endl;
      |                           ^~~~
a.cc:19:27: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

char buf[1600000];
template<typename T>
void readi(T &n) {
    int c;
    n = 0;
    c = buf[bufi++];
    for (; '0' <= c; c = buf[bufi++])
        n = 10 * n + c - '0';
}

// End of template.

int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int n;
    readi(n);

    int t = 1;
    for (int i = n; i; --i) {
        int a;
        readi(a);
        t += t == a;
    }

    if (t == 1)
        print(-1);
    else
        print(n - t + 1);

    return 0;
}



Compiler output:
a.cc: In function 'void readi(T&)':
a.cc:86:13: error: 'bufi' was not declared in this scope; did you mean 'buf'?
   86 |     c = buf[bufi++];
      |             ^~~~
      |             buf
Language: C++

#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <numeric>
#include <string>
using namespace std;
int main()
{
    long n,a,cnt=0;
    scanf("%d"&n);
    for(int i=1;i<=n;i++){scanf("%d",&a);if(a==i){cnt++;} }
    if(cnt==0){printf("%d",-1);}
    else printf("%d",n-cnt);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: invalid operands of types 'const char [3]' and 'long int' to binary 'operator&'
   10 |     scanf("%d"&n);
      |           ~~~~^~
      |           |    |
      |           |    long int
      |           const char [3]
Language: C++

#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <numeric>
#include <string>
using namespace std;
int main()
{
    long n,a,cnt=0;
    for(int i=1;i<=n;i++){ if(a==i){cnt++;} }
    if(cnt==0){printf("%d",-1);}
    else printf("%d",&(n-cnt));
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:25: error: lvalue required as unary '&' operand
   12 |     else printf("%d",&(n-cnt));
      |                       ~~^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n,cnt,flag;

int main(void){
    cin >> n;
    vector<int> a(n);

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

    for(int i = 0; i < n; i++){
        if(cnt+1 == a[i]){
            cnt++;
            flag = 1;
        }
    }
	if(flag){
    	cout << n - cnt << endl;
    }else{
      	cout << -1 << endl;
}

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

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

int main() {
	int n;
	vector<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 = 1;i <= n;++i) {
		if (a[i] != res) {
			++ans;
		}
		else {
			++res;
			under = res;
		}
	}
	if (res == 1)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}
#include<bits/stdc++.h>
#include<string>
#include<numeric>
using namespace std;
//max=({});

int main() {
	int n;
	vector<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 = 1;i <= n;++i) {
		if (a[i] != res) {
			++ans;
		}
		else {
			++res;
			under = res;
		}
	}
	if (ans == n)ans = -1;
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc:35:5: error: redefinition of 'int main()'
   35 | int main() {
      |     ^~~~
a.cc:7:5: note: 'int main()' previously defined here
    7 | int main() {
      |     ^~~~