stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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";

}

// Faster C++ solution for the same problem (measured speedup: 5.302703286234091x):
#include <stdio.h>

int main()

{

	int X;

	scanf("%d",&X);

	if(X>=30)

	{

		printf("Yes");

	}

	else 

	{

		printf("No");

	}

	return 0;

}
// Slower C++ solution:
#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;







}

// Faster C++ solution for the same problem (measured speedup: 5.316241276234093x):
#include <stdio.h>

int main()

{

	int X;

	scanf("%d",&X);

	if(X>=30)

	{

		printf("Yes");

	}

	else 

	{

		printf("No");

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

    int x;

    cin>>x;

    if(x>=30)

    {

        cout<<"Yes"<<endl;

    }

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



}


// Faster C++ solution for the same problem (measured speedup: 5.316337352005546x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.316337352005546x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.316054781541807x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.316337352005546x):
#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;

}
// Slower C++ solution:
#include <iostream>



using namespace std;



int main()

{

    int tem;

    cin>>tem;

    if(tem>=30)

        cout<<"Yes"<<endl;

    else

       cout << "No" << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.316337352005546x):
#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;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

    int n;

    cin>>n;

    if(n>=30)

        cout<<"Yes\n";

    else

        cout<<"No\n";

}


// Faster C++ solution for the same problem (measured speedup: 5.303752874050101x):
#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;

}
// Slower C++ solution:
#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;





}


// Faster C++ solution for the same problem (measured speedup: 5.316337352005546x):
#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;

}
// Slower C++ solution:
#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;



}

// Faster C++ solution for the same problem (measured speedup: 5.316337352005546x):
#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;

}
// Slower C++ solution:
#include <iostream>

using namespace std;



int main() {

	int n;

	cin >> n;

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

	else cout << "No\n";

}

// Faster C++ solution for the same problem (measured speedup: 5.303752874050101x):
#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;

}
// Slower C++ solution:
#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";

}

// Faster C++ solution for the same problem (measured speedup: 5.302799117345311x):
#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;

}
// Slower C++ solution:
#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;







}

// Faster C++ solution for the same problem (measured speedup: 5.316337352005546x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.31602380282488x):
#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;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

    int x;

    cin>>x;

    if(x>=30)

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

    return 0 ;

}


// Faster C++ solution for the same problem (measured speedup: 5.316337352005546x):
#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;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.3159587108769095x):
#include <stdio.h>



int main(){

	

	int temp;

	

	scanf("%d", &temp);

	

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

	

	return 0;



}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.3159587108769095x):
#include <stdio.h>



int main() {

    int n;

    scanf("%d", &n);

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

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.320143731910265x):
#include <stdio.h>

#include <string.h>



int main(){

	int X;

	scanf("%d", &X);

	getchar();

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

	

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.3159587108769095x):
#include <stdio.h>

int main()

{

	int suhu;

	

	scanf("%d",&suhu);

 

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

 

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.3159587108769095x):
#include <stdio.h>



int main(){

	int n;

	scanf("%d", &n);

	if (n >= 30){

		printf("Yes");

	}

	else{

		printf("No");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.3159587108769095x):
#include <stdio.h>



int main() {

  int A;

  scanf("%d", &A);



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

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.3159587108769095x):
#include <stdio.h>

int main ()

{

	int X;

	scanf("%d",&X);

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

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.3159587108769095x):
#include <stdio.h>

int main (){

	int temperature ;

	scanf("%d",&temperature);

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

	

	

	

	

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.316003784431406x):
#include<stdio.h>



int main()

{

	int temp;

	scanf("%d", &temp);

	temp <= 29 ? printf("No") : printf("Yes");



	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int c;

    cin >> c;

    if (c >= 30)

    {

        cout << "Yes" << endl;

    }

    else

    {

        cout << "No" << endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.3159587108769095x):
#include <stdio.h>



int main()

{

	int a=30;

	int x;

	scanf("%d",&x);

	(x>=a)&&(x>=a)?printf("Yes"):printf("No");

	return 0;

	

}
// Slower C++ solution:
#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]中没有被覆盖的区间 

// Faster C++ solution for the same problem (measured speedup: 5.066037643028179x):
#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);

	}

}
// Slower C++ solution:
#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]中没有被覆盖的区间 

// Faster C++ solution for the same problem (measured speedup: 5.05255344331157x):
#include<cstdio>

#include<algorithm>

#define MAXN 200006

using namespace std;

int n,q,a[MAXN],sum[MAXN],vis[MAXN],ans,p,x;

int main()

{

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

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

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

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

		sum[a[i]]++;

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

	{

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

			vis[j]++;

	}

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

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

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

	{

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

		int y=a[p];

		sum[y]--;

		if(y-sum[y]>0)

		{

			vis[y-sum[y]]--;

			if(!vis[y-sum[y]]) ans++;

		}

		a[p]=x;

		if(x-sum[x]>0)

		{

			if(!vis[x-sum[x]]) ans--;

			vis[x-sum[x]]++;

		}

		sum[x]++;

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

	}

}
// Slower C++ solution:
#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]中没有被覆盖的区间 

// Faster C++ solution for the same problem (measured speedup: 5.064765462462015x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

typedef long long ll;

const int N=2e6+5;

int a[N];

int cnt[N];

int f[N];

int main()

{

    int n,m;

    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++)

        if(cnt[i])

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

                f[j]++;

    int ans=0;

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

        if(f[i]==0)

            ans++;

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

        int x,y,z;

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

        x=a[z];

        a[z]=y;

        if(x-cnt[x]>=0){

            f[x-cnt[x]]--;

            if(f[x-cnt[x]]==0)

                ans++;

        }

        cnt[x]--;

        cnt[y]++;

        if(y-cnt[y]>=0){

            if(f[y-cnt[y]]==0)

                ans--;

            f[y-cnt[y]]++;

        }

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

    }

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.0996858266515135x):
#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);

	}

}
// Slower C++ solution:
#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';

	}

}


// Faster C++ solution for the same problem (measured speedup: 5.17656711268493x):
#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);

	}

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.091531489072174x):
#include<cstdio>

#include<algorithm>

using namespace std;



const int MAXN=2e5 + 100;

typedef pair<int,int> pii;

#define fi first

#define se second



int n,m;

pii q[MAXN];

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



int main(){

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

    for(int i=1;i<=n;i++) scanf("%d",&a[i]);

    for(int i=1;i<=m;i++) scanf("%d%d",&q[i].fi,&q[i].se);

    for(int i=1;i<=n;i++) cnt[a[i]]++;

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

        if(cnt[i])

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

                f[j]++;

    }

    int ans=0;

    for(int i=0;i<n;i++) if(!f[i]) ans++;

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

        int x=a[q[i].fi],y=q[i].se;

        a[q[i].fi]=y;

        if(x-cnt[x]>=0){

            f[x-cnt[x]]--;

            if(f[x-cnt[x]]==0) ans++;

        }

        cnt[x]--;

        if(y-cnt[y]-1>=0){

            f[y-cnt[y]-1]++;

            if(f[y-cnt[y]-1]==1) ans--;

        }

        cnt[y]++;

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

    }

}