stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

 int X;

 cin>>X;

 if (X>=30)



   cout<<"Yes";

 else

   cout<<"No";

   return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

    int x;

    scanf("%d", &x);

    x>=30 ? printf("Yes\n") : printf("No\n");



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int x;



int main() {

	

	ios_base::sync_with_stdio(false);

	cin >> x;

	if(x >= 30) cout << "Yes";

	else cout << "No";

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main() {

    int dd;

    scanf("%d", &dd);

    dd >= 30 ? printf("Yes") : printf("No");



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

using ll = long long;

typedef pair<ll,ll> pll;

#define pb push_back

int main()

{

    ll t;



    cin>>t;



    if(t>=30)cout<<"Yes"<<endl;

    else cout<<"No"<<endl;





}














// Optimized solution to the same problem (faster):
#include<stdio.h>

int main(){

	int temperature;

	scanf("%d", &temperature);

	if(temperature >= 30){

		printf("Yes");

	}

	if(temperature <30){

		printf("No");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;



int main() {

int X;

cin>>X;

if(X==30 || X>30)

cout<<"Yes"<<endl;

else

cout<<"No"<<endl;



    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main(){

	int temperature;

	scanf("%d", &temperature);

	if(temperature >= 30){

		printf("Yes");

	}

	if(temperature <30){

		printf("No");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

 int X;

 cin>>X;

 if (X>=30)



   cout<<"Yes";

 else

   cout<<"No";

   return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int main(){

	int temperature;

	scanf("%d", &temperature);

	if(temperature >= 30){

		printf("Yes");

	}

	if(temperature <30){

		printf("No");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

    int x;

    cin>>x;



    if (x==30||x>=30)

        cout<<"Yes";

    else

        cout<<"No";

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main(){

	int temperature;

	scanf("%d", &temperature);

	if(temperature >= 30){

		printf("Yes");

	}

	if(temperature <30){

		printf("No");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main(){

  int a;

  cin >> a;

  if(a>=30){

 cout << "Yes";

  }

else{

 cout << "No";

}

  return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main(){

	int temperature;

	scanf("%d", &temperature);

	if(temperature >= 30){

		printf("Yes");

	}

	if(temperature <30){

		printf("No");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main() {

	int X;

	-40<=X<=40;

	cin >> X;

	if (X >= 30) {

		cout << "Yes" << endl;

	} else {

		cout << "No" << endl;

	}

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	if (num >= 30){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std ;

int main()

{

    int X;

    cin>>X;

    if (X>=30)

    {

        cout<<"Yes";

    }

    else

    {

        cout<<"No";

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	if (num >= 30){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
# include<iostream>

using namespace std;

int main()

{

    int a;

    cin>>a;

    if(a>=30)

        cout<<"Yes"<<"\n";

    else

        cout<<"No"<<"\n";



}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	if (num >= 30){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

    int X;

    cin>>X;

    if(X>=30)

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	if (num >= 30){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n;

    cin>>n;

        if(n>=30)

            cout<<"Yes"<<endl;



        else

            cout<<"No"<<endl;

return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	if (num >= 30){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int x;

    cin>>x;

    if(x>=30)

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	if (num >= 30){

		printf("Yes\n");

	}

	else{

		printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

    int x;

    cin>>x;

    if(x>=30)

    {

        cout<<"Yes"<<endl;

    }

    else{ cout<<"No"<<endl;}



}


// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int degree;

	

	scanf("%i",&degree);



	degree >= 30 ? printf("Yes") : printf("No");



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int N;

    cin>>N;

    if(N>=30)

    {

        cout<<"Yes"<<endl;

    }

    else

    {

        cout<<"No"<<endl;

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int degree;

	

	scanf("%i",&degree);



	degree >= 30 ? printf("Yes") : printf("No");



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int x;

    cin>>x;

    if(x>=30)

    {

        cout<<"Yes"<<endl;

    }

    else{

        cout<<"No"<<endl;

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int degree;

	

	scanf("%i",&degree);



	degree >= 30 ? printf("Yes") : printf("No");



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int x;

    cin>>x;

    if(x>=30) cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int degree;

	

	scanf("%i",&degree);



	degree >= 30 ? printf("Yes") : printf("No");



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



using namespace std;



int main()

{

    int tem;

    cin>>tem;

    if(tem>=30)

        cout<<"Yes"<<endl;

    else

       cout << "No" << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int degree;

	

	scanf("%i",&degree);



	degree >= 30 ? printf("Yes") : printf("No");



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

    int n;

    cin>>n;

    if(n>=30)

        cout<<"Yes\n";

    else

        cout<<"No\n";

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int degree;

	

	scanf("%i",&degree);



	degree >= 30 ? printf("Yes") : printf("No");



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

 int X;

 cin>>X;



 if(X>=30)

 {

     cout<<"Yes"<<endl;

 }

 else

 {

     cout<<"No"<<endl;

 }



 return 0;





}


// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int degree;

	

	scanf("%i",&degree);



	degree >= 30 ? printf("Yes") : printf("No");



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>

#include <cstdio>

#include <cmath>

#include <queue>

#include <set>

#include <map>

#include <vector>

#include <stack>

#include <algorithm>

#define forn(a, n) for(int a = 0; a<(int) (n); ++a)

#define rforn(a, n) for(int a = (n)-1; a>=0; --a)

using namespace std;

const int N = 6e5+20;



int main()

{

    int n, m, b;

    cin>>n;

    if(n>=30) cout<<"Yes"<<endl;

    else cout<<"No"<<endl;



}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

	int degree;

	

	scanf("%i",&degree);



	degree >= 30 ? printf("Yes") : printf("No");



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;



int main() {

	int n;

	cin >> n;

	if(n >= 30)cout << "Yes\n";

	else cout << "No\n";

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	num >= 30 ? printf("Yes\n") : printf("No\n");

//	if (num >= 30){

//		printf("Yes\n");

//	}

//	else{

//		printf("No\n");

//	}

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long

using namespace std;

int main(){

	ll x;

	cin >> x;

	x >= 30 ? cout << "Yes\n" : cout << "No\n";

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	num >= 30 ? printf("Yes\n") : printf("No\n");

//	if (num >= 30){

//		printf("Yes\n");

//	}

//	else{

//		printf("No\n");

//	}

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

int X;

cin>>X;

if(X>=30)

{

    cout<<"Yes"<<endl;

}

else if(X<30)

{

    cout<<"No"<<endl;

}

return 0;







}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	num >= 30 ? printf("Yes\n") : printf("No\n");

//	if (num >= 30){

//		printf("Yes\n");

//	}

//	else{

//		printf("No\n");

//	}

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

    int X;

    cin>>X;

    if(X<30)cout<<"No"<<endl;

    else if(X>=30)cout<<"Yes"<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	num >= 30 ? printf("Yes\n") : printf("No\n");

//	if (num >= 30){

//		printf("Yes\n");

//	}

//	else{

//		printf("No\n");

//	}

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main()

{

    int x;

    cin>>x;

    if(x>=30)

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

    return 0 ;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>



int main(){

	int num;

	scanf("%d",&num);

	num >= 30 ? printf("Yes\n") : printf("No\n");

//	if (num >= 30){

//		printf("Yes\n");

//	}

//	else{

//		printf("No\n");

//	}

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>



int main(){

	int X;

	scanf("%d", &X);

	getchar();

	X >= 30 ? printf("Yes") : printf("No");

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

using namespace std;

int c[201000],val[201000],n,m,a[201000],cnt[201000];

void add(int x,int k){for(int i=x;i<=n;i+=i&-i)c[i]+=k;}

int query(int x){int ans=0;for(int i=x;i;i-=i&-i)ans+=c[i];return ans;} 

int main()

{

	scanf("%d%d",&n,&m);

	for(int i=1;i<=n;i++)

	{

		scanf("%d",&a[i]);cnt[a[i]]++;

	} 

	for(int i=1;i<=n;i++)

		for(int j=i-cnt[i]+1;j<=i;j++)if(j>=1)val[j]++;

	for(int i=1;i<=n;i++)if(val[i]==0)add(i,1);

	for(int i=1;i<=m;i++)

	{

		int x,y;scanf("%d%d",&x,&y);

		if(a[x]-cnt[a[x]]+1>=1&&--val[a[x]-cnt[a[x]]+1]==0)add(a[x]-cnt[a[x]]+1,1);cnt[a[x]]--;a[x]=y;cnt[a[x]]++;

		if(a[x]-cnt[a[x]]+1>=1&&++val[a[x]-cnt[a[x]]+1]==1)add(a[x]-cnt[a[x]]+1,-1);printf("%d\n",query(n));

	}

	return 0;

 } //设x的出现次数为cnt，则可以看成覆盖[x-cnt+1,x]区间，ans=[1,n]中没有被覆盖的区间 

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<vector>

#define SF scanf

#define PF printf

#define MAXN 200010

using namespace std;

int n,m;

int a[MAXN],cnt[MAXN];

int tims[MAXN],sum;

void add(int x){

	cnt[x]++;

	if(x-cnt[x]+1>0&&tims[x-cnt[x]+1]==0)

		sum--;	

	if(x-cnt[x]+1>0)

		tims[x-cnt[x]+1]++;

}

void del(int x){

	if(x-cnt[x]+1>0&&tims[x-cnt[x]+1]==1)

		sum++;

	if(x-cnt[x]+1>0)

		tims[x-cnt[x]+1]--;	

	cnt[x]--;

}

int main(){

	SF("%d%d",&n,&m);

	sum=n;

	for(int i=1;i<=n;i++){

		SF("%d",&a[i]);

		add(a[i]);

	}

	int x,y;

	for(int i=1;i<=m;i++){

		SF("%d%d",&x,&y);

		del(a[x]);

		a[x]=y;

		add(a[x]);

		PF("%d\n",sum);

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

 

using namespace std;

 

int n, m, x[200005], ca[200005], cb[200005], ans, ta, tb, tc;

 

int main() {

	scanf("%d%d", &n, &m);

	for (int i = 1; i <= n; i++) {

		scanf("%d", x + i);

		ta = max(0, x[i] - ca[x[i]]);

		ca[x[i]]++;

		cb[ta]++;

	}

	for (int i = 1; i <= n; i++)

		ans += (cb[i] == 0);

	while (m--) {

		scanf("%d%d", &ta, &tb);

		ca[x[ta]]--;

		tc = max(0, x[ta] - ca[x[ta]]);

		cb[tc]--;

		if (tc && !cb[tc])

			ans++;

		x[ta] = tb;

		tc = max(0, x[ta] - ca[x[ta]]);

		ca[x[ta]]++;

		if (tc && !cb[tc])

			ans--;

		cb[tc]++;

		printf("%d\n", ans);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#include<cstring>

#define MN 200005

using namespace std;

int n,m,ans,a[MN],c[MN],now[MN];

int main(){

	scanf("%d%d",&n,&m);ans=n;int x,y;

	for(int i=1;i<=n;i++){

		scanf("%d",&a[i]);c[a[i]]++;

		if(a[i]-c[a[i]]>=0&&!(now[a[i]-c[a[i]]]++))ans--;

	}

	for(int i=1;i<=m;i++){

		scanf("%d%d",&x,&y);

		if(a[x]-c[a[x]]>=0&&!(--now[a[x]-c[a[x]]]))ans++;

		c[a[x]]--;a[x]=y;c[a[x]]++;

		if(a[x]-c[a[x]]>=0&&!(now[a[x]-c[a[x]]]++))ans--;

		printf("%d\n",ans);

	}

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

 

using namespace std;

using namespace __gnu_pbds;

 

#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key

 

typedef long long ll;

typedef pair<int,int> ii;

typedef vector<int> vi;

typedef long double ld; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;



int cnt[211111]; //counts how many times the interval [i,i+1) is covered. we want cnt[0],cnt[1],...,cnt[n-1] = 1

int cov[211111];

int a[211111];



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	int n,m; cin>>n>>m;

	for(int i=1;i<=n;i++) cov[i]=i-1;

	int res=n;

	for(int i = 0; i < n; i++)

	{

		int x; cin>>x;

		a[i]=x;

		if(cov[x]>=0) 

		{

			if(cnt[cov[x]]==0) res--;

			cnt[cov[x]]++;

		}

		cov[x]--;

	}

	for(int i = 0; i < m; i++)

	{

		int x, y; cin>>x>>y;

		x--;

		cov[a[x]]++;

		if(cov[a[x]]>=0)

		{

			if(cnt[cov[a[x]]]==1) res++;

			cnt[cov[a[x]]]--;

		}

		if(cov[y]>=0)

		{

			if(cnt[cov[y]]==0) res--;

			cnt[cov[y]]++;

		}

		cov[y]--;

		a[x]=y;

		cout<<res<<'\n';

	}

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#include<cstring>

#define MN 200005

using namespace std;

int n,m,ans,a[MN],c[MN],now[MN];

int main(){

	scanf("%d%d",&n,&m);ans=n;int x,y;

	for(int i=1;i<=n;i++){

		scanf("%d",&a[i]);c[a[i]]++;

		if(a[i]-c[a[i]]>=0&&!(now[a[i]-c[a[i]]]++))ans--;

	}

	for(int i=1;i<=m;i++){

		scanf("%d%d",&x,&y);

		if(a[x]-c[a[x]]>=0&&!(--now[a[x]-c[a[x]]]))ans++;

		c[a[x]]--;a[x]=y;c[a[x]]++;

		if(a[x]-c[a[x]]>=0&&!(now[a[x]-c[a[x]]]++))ans--;

		printf("%d\n",ans);

	}

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> ii; 



const int N = 2e5 + 10; 

int n, m, a[N], cnt[N], p[N], tot;  



void add(int x) {

    int l = x - cnt[x]++; 

    if(l > 0 && ++p[l] == 1) 

        --tot; 

}

void rem(int x) {

    int l = x - --cnt[x]; 

    if(l > 0 && --p[l] == 0) 

        ++tot;

}



int main(int argc, char const *argv[]) {

    scanf("%d %d", &n, &m);

    for(int i = 1; i <= n; i++) {

        scanf("%d", &a[i]);

        add(a[i]); 

    } tot += n;  

    while(m--) {

        int x, y; 

        scanf("%d %d", &x, &y);

        rem(a[x]); a[x] = y; add(a[x]); 

        printf("%d\n", tot); 

    }

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MAXN 200010

int cnt[MAXN],a[MAXN],A[MAXN];

int n,m,x,y,ans;

int main()

{

	scanf("%d%d",&n,&m);

	for(int i=1;i<=n;i++)

	{

		scanf("%d",&A[i]);

		a[max(0,A[i]-cnt[A[i]])]++;

		cnt[A[i]]++;

	}

	for(int i=1;i<=n;i++)

		if(!a[i]) ans++;

	while(m--)

	{

		scanf("%d%d",&x,&y);

		int k=max(0,A[x]-cnt[A[x]]+1);

		if(k&&a[k]==1) ans++;

		a[k]--;

		cnt[A[x]]--;

		A[x]=y;

		k=max(0,A[x]-cnt[A[x]]);

		if(k&&a[k]==0) ans--;

		a[k]++;

		cnt[A[x]]++;

		printf("%d\n",ans);

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long i64;



const int MAXN = 200000 + 10;



int N, M;

int A[MAXN];

int answer;



int covCnt[MAXN], ptr[MAXN];



void addSeg(int x)

{

	int newL = x - covCnt[x];

	covCnt[x] ++;

	if(newL > 0)

		ptr[newL]++;

	if(newL > 0 && ptr[newL] == 1)

		answer--;

}



void removeSeg(int x)

{

	covCnt[x]--;

	int newL = x - covCnt[x];

	

	if(newL > 0)

		ptr[newL]--;

	if(newL > 0 && ptr[newL] == 0)

		answer++;

}



int main()

{

	ios::sync_with_stdio(false), cin.tie(nullptr);



	cin >> N >> M;

	for(int i = 1; i <= N; i++)

		cin >> A[i], addSeg(A[i]);

	answer += N;



	for(int i = 1; i <= M; i++)

	{

		int x, y;

		cin >> x >> y ;

		removeSeg(A[x]);

		A[x] = y;

		addSeg(A[x]);

		cout << answer << endl ;

	}



	return 0;

}




// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MAXN 200010

int cnt[MAXN],a[MAXN],A[MAXN];

int n,m,x,y,ans;

int main()

{

	scanf("%d%d",&n,&m);

	for(int i=1;i<=n;i++)

	{

		scanf("%d",&A[i]);

		a[max(0,A[i]-cnt[A[i]])]++;

		cnt[A[i]]++;

	}

	for(int i=1;i<=n;i++)

		if(!a[i]) ans++;

	while(m--)

	{

		scanf("%d%d",&x,&y);

		int k=max(0,A[x]-cnt[A[x]]+1);

		if(k&&a[k]==1) ans++;

		a[k]--;

		cnt[A[x]]--;

		A[x]=y;

		k=max(0,A[x]-cnt[A[x]]);

		if(k&&a[k]==0) ans--;

		a[k]++;

		cnt[A[x]]++;

		printf("%d\n",ans);

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



const int MAXN = 200005;

 

int n, m, ret, a[MAXN], b[MAXN], c[MAXN];

 

int main() {

  cin>>n>>m;

  ret = n;

	for (int i = 1; i <= n; i ++) {

    cin>>a[i];

    c[a[i]]++;

		if (a[i] - c[a[i]] >= 0 && ++b[a[i] - c[a[i]]] == 1)

			ret--;

	}

	while(m--) {

		int x, y; cin>>x>>y;

		if (a[x] - c[a[x]] >= 0 && !--b[a[x] - c[a[x]]])

			ret ++;

		c[a[x]]--;

		a[x] = y;

		c[a[x]] ++;

		if (a[x] - c[a[x]] >= 0 && ++b[a[x] - c[a[x]]] == 1)

			ret --;

		cout<<ret<<'\n';

	}

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define MAXN 200000

using namespace std;

int seq[MAXN+5],cnt[MAXN+5],N,M;

int A[MAXN+5];

int main()

{

	scanf("%d %d",&N,&M);

	for(int i=1;i<=N;i++)

		scanf("%d",&seq[i]),cnt[seq[i]]++;

	for(int i=1;i<=N;i++)

		for(int j=max(1,i-cnt[i]+1);j<=i;j++)

			A[j]++;

	int ans=0;

	for(int i=1;i<=N;i++)

		if(A[i]==0)

			ans++;

	int X,Y;

	for(int i=1;i<=M;i++)

	{

		scanf("%d %d",&X,&Y);

		if(seq[X]-cnt[seq[X]]+1>=1)

		{

			A[seq[X]-cnt[seq[X]]+1]--;

			if(A[seq[X]-cnt[seq[X]]+1]==0)

				ans++;

		}

		cnt[seq[X]]--;

		seq[X]=Y;

		cnt[seq[X]]++;

		if(seq[X]-cnt[seq[X]]+1>=1)

		{

			if(A[seq[X]-cnt[seq[X]]+1]==0)

				ans--;

			A[seq[X]-cnt[seq[X]]+1]++;

		}

		printf("%d\n",ans);

	}

	return 0;

}

// Fastest known solution for this problem: