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

#include <climits>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)

#define si(x) int x = scanInt();

#define sll(x) LL x = scanLong();

#define sci(x) int x; scanf("%d", &x);

#define scll(x) LL x; scanf("%lld", &x);

#define pi(x) printf("%d ", x)

#define pll(x) printf("%lld ", x)

#define ps(x) printf("%s", x)

#define nl printf("\n")

#define clr(a) memset(a, 0, sizeof(a))

#define PB push_back

#define MP make_pair

using namespace std;

typedef unsigned int UI; // 32 bit integer

typedef long int LI; // 32 bit integer

typedef unsigned long int ULI; // 32 bit unsigned integer

typedef long long int LL; // 64 bit integer

typedef unsigned long long int  ULL; // 64 bit unsigned integer

typedef long double LD;

typedef vector<int> VI;

typedef vector<LL> VLL;

typedef pair<int, int> PII;

typedef pair<LL, LL> PLL;

LL mod = 1e9+7;



/* Fast I/O */

inline int scanInt() {

	int n = 0;

	char ch = getchar();

	int sign = 1;

	while(ch < '0' || ch > '9') {

		if(ch == '-')	sign = -1;

		ch = getchar();

	}

	while(ch >= '0' && ch <= '9') {

		n = (n<<1)+(n<<3)+(int)(ch-'0');

		ch = getchar();

	}

	return n*sign;

}



inline LL scanLong() {

	LL n = 0;

	char ch = getchar();

	LL sign = 1;

	while(ch < '0' || ch > '9') {

		if(ch == '-')	sign = -1;

		ch = getchar();

	}

	while(ch >= '0' && ch <= '9') {

		n = (n<<1)+(n<<3)+(LL)(ch-'0');

		ch = getchar();

	}

	return n*sign;

}



const LL MAXN = 2e5+10;	

LL arr[MAXN], cnt[MAXN], present[MAXN];



int main() {

	sll(n); sll(m);

	rep(i, 0, n) {

		arr[i] = scanLong();

		cnt[arr[i]]++;

	}

	rep(i, 1, n+1) {

		LL low = max(0ll, i - cnt[i]);

		rep(j, low, i)	present[j]++;

	}

	LL ans = 0;

	rep(i, 0, n)	if(!present[i])	ans++;

	rep(i, 0, m) {

		sll(x); sll(y); x--;

		if(y != arr[x]) {

			if(y > cnt[y]) {

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

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

			}

			if(arr[x] >= cnt[arr[x]]) {

				if(present[arr[x]-cnt[arr[x]]] == 1)	ans++;

				present[arr[x]-cnt[arr[x]]]--;

			}

			cnt[arr[x]]--;

			cnt[y]++;

			arr[x] = y;

		}

		pll(ans); nl;

	}

}


// 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:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define R register

namespace IO{

	char buf[1<<15],*S,*T;

	inline char gc(){

		if (S==T){

			T=(S=buf)+fread(buf,1,1<<15,stdin);

			if (S==T) return EOF;

		}return *S++;

	}

	inline int read(){

		R int x; R bool f; R char c;

		for (f=0; (c=gc())<'0'||c>'9'; f=c=='-');

		for (x=c^'0'; (c=gc())>='0'&&c<='9'; x=(x<<1)+(x<<3)+(c^'0'));

		return f?-x:x;

	}

	const int outlim=1<<20;int cnt=0;

	char outbuf[outlim+5],*SS=outbuf;

	inline void pc(char c){

		*SS++=c;++cnt;if (cnt==outlim)

			fwrite(outbuf,1,outlim,stdout),SS=outbuf,cnt=0;

	}

	inline void write(int x){

		if (x>9) write(x/10);

		pc(x%10^'0');

	}

	void endfile(){

		if (cnt)

			fwrite(outbuf,1,cnt,stdout);

		fclose(stdin);fclose(stdout);

	}

}

#define MN 200005

#define M (1<<18)

int vl[MN],cnt[MN],n,m,T[M<<1];

inline void rw(int k,int x){

	if (k<1) return;

	if (!T[k+=M]) for (; k; k>>=1) ++T[k];

	else{

		if (~x) ++T[k];

		else if (!(--T[k])) for (; k>>=1; ) --T[k];

	}

}

int main(){

	n=IO::read(),m=IO::read();

	for (R int i=1; i<=n; ++i) ++cnt[vl[i]=IO::read()],rw(vl[i]-cnt[vl[i]]+1,1);

	for (R int i=1,x,y; i<=m; ++i){

		x=IO::read(),y=IO::read();

		--cnt[vl[x]];rw(vl[x]-cnt[vl[x]],-1);

		vl[x]=y;rw(y-cnt[y],1);++cnt[y];

		IO::write(n-T[1]);IO::pc('\n');

	}IO::endfile();return 0;

}

// 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:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <cstdio>

#include <algorithm>

#include <utility>

#include <string>

#include <cmath>

#include <set>

#include <functional>

#include <map>

#include <queue>

#include <cstring>

#include <stack>

#include <iomanip>

#include <climits>

#include <numeric>

#include <cassert>

#include <cstring>

using namespace std;

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

#define show(x) cout << #x << " = " << x << endl;

typedef long long ll;

typedef pair<int,int> pii;

int main(){

    int n,m;

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> n >> m;

    vector<int>a(n);

    vector<int>x(m),y(m);

    vector<int>c(n+1,0);

    rep(i,n){

        cin >> a[i];

        c[a[i]]++;

    }

    int ans = 0;

    map<int,int>k;

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

        for(int j = i-1; j >= i-c[i] ; j--){

            k[j]++;

        }

    }

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

        if(k[i] == 0){

            ans++;

        }

    }

    rep(i,m){

        cin >> x[i] >> y[i];

        x[i]--;

        int old = a[x[i]];

        int now = y[i];

        if(old == now){

            cout << ans << endl;

            continue;

        }

        k[now-c[now]-1]++;

        if(k[now-c[now]-1]==1 && now-c[now]-1>=0)ans--;

        k[old-c[old]]--;

        if(k[old-c[old]]==0 && old-c[old] >= 0)ans++;

        cout <<ans << endl;

        c[a[x[i]]]--;

        c[y[i]]++;

        a[x[i]] = y[i];

    }

    return 0;

}

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

#include <cstdio>

#include <algorithm>

#include <utility>

#include <string>

#include <cmath>

#include <set>

#include <functional>

#include <map>

#include <queue>

#include <cstring>

#include <stack>

#include <iomanip>

#include <climits>

#include <numeric>

#include <cassert>

#include <cstring>

using namespace std;

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

#define show(x) cout << #x << " = " << x << endl;

typedef long long ll;

typedef pair<int,int> pii;

int main(){

    int n,m;

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

    vector<int>a(n);

    vector<int>x(m),y(m);

    vector<int>c(n+1,0);

    rep(i,n){

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

        c[a[i]]++;

    }

    int ans = 0;

    vector<int>k(n*2,0);

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

        for(int j = i-1+n; j >= i-c[i]+n ; j--){

            k[j]++;

        }

    }

    for(int i = n; i < n*2; i++){

        if(k[i] == 0){

            ans++;

        }

    }

    rep(i,m){

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

        x[i]--;

        int old = a[x[i]];

        int now = y[i];

        if(old == now){

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

            continue;

        }

        k[n+now-c[now]-1]++;

        if(k[n+now-c[now]-1]==1 && now-c[now]-1>=0)ans--;

        k[n+old-c[old]]--;

        if(k[n+old-c[old]]==0 && old-c[old] >= 0)ans++;

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

        c[a[x[i]]]--;

        c[y[i]]++;

        a[x[i]] = y[i];

    }

    return 0;

}

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

#include<cstdio>

using namespace std;

int n,m,a[200005],b[200005],cnt[200005],x,y,ans;

inline int read(){

	char c=getchar();

	for(;c>'9'||c<'0';) c=getchar();

	int xx=c-'0';

	c=getchar();

	for(;c>='0'&&c<='9';){

		xx=(xx<<3)+(xx<<1)+c-'0';

		c=getchar();

	}

	return xx;

}

int main(){

	n=read(),m=read(),ans=n;

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

		cnt[a[i]=read()]++;

		if(a[i]-cnt[a[i]]>=0){

			if(!b[a[i]-cnt[a[i]]]) ans--;

			b[a[i]-cnt[a[i]]]++;

		}

	}

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

		x=read(),y=read();

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

			b[a[x]-cnt[a[x]]]--;

			if(!b[a[x]-cnt[a[x]]]) ans++;

		}

		cnt[a[x]]--,a[x]=y,cnt[y]++;

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

			b[a[x]-cnt[a[x]]]++;

			if(b[a[x]-cnt[a[x]]]==1) ans--;

		}

		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 mp[MN],a[MN],sm[MN];

int tot,n,m;



inline int read()

{

	int n=0,f=1; char c=getchar();

	while (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}

	while (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}

	return n*f;

}



int main()

{

	register int i,j,x,y;

	n=read(); m=read();

	for (i=1;i<=n;++i) ++mp[a[i]=read()];

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

		for (j=0;j<i&&j<mp[i];++j)

			if (sm[i-j]++==0) ++tot;

	while (m--)

	{

		x=read(); y=read();

		--mp[a[x]];

		if (mp[a[x]]<a[x])

			if (--sm[a[x]-mp[a[x]]]==0) --tot;

		if (mp[y]<y)

			if (sm[y-mp[y]]++==0) ++tot;

		++mp[y]; a[x]=y;

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

	}

}

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



using namespace std;



int main()

{

    int x;

    cin >> x;



    if (x < 1200){

        cout << "ABC" << endl;

    }else{

        cout << "ARC" << endl;

    }

}


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

int main()

{

	int input;

	scanf("%d",&input);

	if(input<1200){

		printf("ABC\n");

	}

	else{

		printf("ARC\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 < 1200) {

		cout << "ABC";

	}

	else {

		cout << "ARC";

	}

}

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

int main()

{

	int input;

	scanf("%d",&input);

	if(input<1200){

		printf("ABC\n");

	}

	else{

		printf("ARC\n");

	}

	return 0;

}

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

#include <math.h>

#include <string.h>

#include <algorithm>

#include <iostream>

#include <string>

#include <time.h>

#include <queue>

#include <list>

#include <string.h>

#define sf scanf

#define pf printf

#define lf double

#define ll long long

#define p123 printf("123\n");

#define pn printf("\n");

#define pk printf(" ");

#define p(n) printf("%d",n);

#define pln(n) printf("%d\n",n);

#define s(n) scanf("%d",&n);

#define ss(n) scanf("%s",n);

#define ps(n) printf("%s",n);

#define sld(n) scanf("%lld",&n);

#define pld(n) printf("%lld",n);

#define slf(n) scanf("%lf",&n);

#define plf(n) printf("%lf",n);

#define sc(n) scanf("%c",&n);

#define pc(n) printf("%c",n);

#define gc getchar();

#define re(n,a) memset(n,a,sizeof(n));

#define len(a) strlen(a)

#define LL long long

#define eps 1e-6

using namespace std;

const double pi = 3.1415926535;

/*

https://codeforces.com/contest/1106/problems

https://codeforces.com/contest/1106/submit

*/



int main() {

    int n ;

    s(n)

    if(n < 1200){

        puts("ABC");

        

    }else {

        puts("ARC");

        }

    return 0;

}


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

int main()

{

	int input;

	scanf("%d",&input);

	if(input<1200){

		printf("ABC\n");

	}

	else{

		printf("ARC\n");

	}

	return 0;

}

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

using namespace std;

typedef long long ll;

int  main(){

    int x;

    cin>>x;

    x>=1200?cout<<"ARC"<<endl:cout<<"ABC"<<endl;

return 0;

}


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

int main()

{

	int input;

	scanf("%d",&input);

	if(input<1200){

		printf("ABC\n");

	}

	else{

		printf("ARC\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<1200){

        cout<<"ABC"<<endl;

    }

    else cout<<"ARC"<<endl;

    return 0;

}


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

int main()

{

   int m;

   scanf("%d",&m);





   if(m < 1200)

   {

       printf("ABC\n");



   }



   else printf("ARC\n");



    return 0;

}


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

using namespace std;

int main(void){

    // Here your code !

    int a;

    cin >> a;

    cout << ((a>=1200)?"ARC":"ABC") << endl;

}


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

int main(void){

    int a;

    scanf("%d",&a);

    puts((a>=1200)?"ARC":"ABC");

}


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

using namespace std;

int main()

{

    int n;

    cin>>n;

        if(n<1200)

        cout<<"ABC";

		

        else cout<<"ARC";

    

}

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



int main(){

	int n;

	scanf("%d", &n);

	if(n<1200) printf("ABC\n");

	else printf("ARC\n");

	return 0;

}

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

using namespace std;

int main(){

	long long n,i,sum=0,a,left=0;

	cin>>n;

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

	{

		cin>>a;

		sum+=(left+a)/2;

		left=(left+a)%2;

		if(!a)

			left=0;

	}

	cout<<sum<<endl;

	return 0;

}

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

#include <algorithm>

#include <cstring>

#include <cctype>

typedef long long int64;

using namespace std;

inline int read(int f = 1, int x = 0, char ch = ' ')

{

    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;

    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();

    return f*x;

}

const int N = 1e5+5;

int n, a[N];

int64 ans;

int main()

{

    n = read(); 

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

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

    {

        ans += a[i]>>1, a[i] &= 1;

        if(a[i]&&a[i+1]) --a[i], --a[i+1], ++ans;

    }

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

    return 0;

}   

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

#include<iostream>

#include<cstring>

#include<cstdio>

#include<cmath>

#define MXN 100010

#define LLI long long



int n,

	a[MXN];

LLI ans;





int main(){

	

	scanf("%d",&n);

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

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

		if((a[i-1]+a[i])&1){

			ans+=(a[i-1]+a[i])>>1;

			if(a[i])

				a[i]=1;

		}

		else{

			ans+=(a[i-1]+a[i])>>1;

			a[i]=0;

		}

	}

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

	//system("pause");

	return 0;

}

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

#include<string>

#define min(a,b) ((a)<(b)?(a):(b))

#define MAXN 100005

using namespace std;

inline int read(){

	register int x=0;

	register bool f=1;

	register char ch=getchar();

	while(!isdigit(ch)){

		if(ch=='-') f=0;

		ch=getchar();

	}

	while(isdigit(ch)){

		x=(x<<1)+(x<<3)+(ch-'0');

		ch=getchar();

	}

	return f?x:-x;

}

long long A[MAXN],N,ans,sum;

int main(){

	N=read();

	for(int i=1;i<=N;i++) A[i]=read();

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

		sum+=A[i];

		if(!A[i]||sum%2==0){

			ans+=(sum/2);

			sum=0;

		}

	}

	ans+=(sum/2);

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

	return 0;

}

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

#include <cstdio>



using namespace std;



typedef long long ll;

const int Maxn = 100010;

int n;

int a[Maxn];



int main() {

	

	scanf("%d",&n);

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

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

	

	register ll ans = 0;

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

		register int tmp = a[i] >> 1ll;

		a[i] -= tmp << 1ll;

		ans += tmp;

		tmp = min(a[i],a[i+1]);

		a[i] -= tmp;

		a[i+1] -= tmp;

		ans += tmp;

	}

	

	ans += a[n] >> 1ll;

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

	

	return 0;

	

}

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

#include<cstring>

#include<algorithm>

#include<cmath>

#define inf 20021225

#define ll long long

#define mxn 100010

using namespace std;



ll a[mxn],n;



int main()

{

	scanf("%lld",&n);ll ans=0;

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

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

	{

		ll cnt=a[i];

		while(i<n && a[i+1]!=0)	cnt+=a[i+1],i++;

		ans+=cnt/2;

	}

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

Character Drawing Adapted from FAKEUPDATE.NET

		   _    _____         _

		   \`,""   ,'7"r-..__/ \

		  ,'\ `, ,',','    _/   \

		 /   \, 7 / /     (   \ |

		J     \/ j  L______\  / |

		L   __JF"""/""\"\_,    /

		L,-"| O|  f O |  L_  _/

		F   \_ /  \__/   `-  j|

			.-'    `"""    ,' |          _..====.._

			\__/         r"_  A        ,' _..---.._`,

			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,

					  j   / / / 7"    `-<""=:'  '':. \ \

					 /   <,' /  F  . i , \   `,    :T W I

					 |    \,'  /    >X<  |     \   :| | L

					 |     `._/    ' ! ` |      I  :| |  G

					  \           \     /       |  :H T  |

					 __>-.__   __,-\   |        |  S P   |

					/     /|   | \  \  \_       | 'A R   |

				   /   __/ |   |  L  L   \      K./ /    L

				  /   |    |   4  I  I    |    E./ /   ,'

				 J    \    I    L F  I    |    // / _,'

		_________|     |   F    |J   F    |   //_/-'

		\   __   |    /   J     |/  J     |  /="

		\\  \_\  \__,' \  F     |   F     |

		\\\_____________\/      F__/      F

		 \\| 计算机编程 |_____/  (______/

		  \/从入门到入土/

*/

#include <iostream>

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

#include <functional>

using namespace std;

#define MATH_PI 3.14159265358979323846

int main(){

	ios::sync_with_stdio(false);

	long long N, ans = 0, tmp = 0, i, a;

	cin >> N;

	for (i = 0; i<N; ++i){

		cin >> a;

		tmp += a;

		if (a == 0 || i == N - 1){

			ans += tmp / 2;

			tmp = 0;

		}

	}

	cout << ans << endl;

endapp:

	//system("pause > nul");

	return 0;

}

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

#include<cstring>

#include<algorithm>

#include<cmath>

#define inf 20021225

#define ll long long

#define mxn 100010

using namespace std;



ll a[mxn],n;



int main()

{

	scanf("%lld",&n);ll ans=0;

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

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

	{

		ll cnt=a[i];

		while(i<n && a[i+1]!=0)	cnt+=a[i+1],i++;

		ans+=cnt/2;

	}

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

	return 0;

}

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

using namespace std;

#define gi(x) ((x) = F())

int F(){

	char ch;

	int x, a;

	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');

	if (ch == '-') ch = getchar(), a = -1;

	else a = 1;

	x = ch - '0';

	while (ch = getchar(), ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + ch - '0';

	return a * x;

}

int n, a[100010];

long long ans;

int main(){

	gi(n);

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

	for (int i = 1; i <= n; ++i) if (a[i] & 1) if (a[i + 1]) ++ans, --a[i], --a[i + 1];

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

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

	return 0;

}

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

int a[100005],i,n;long long s;

int main(){

	scanf("%d",&n);

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

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

		if(!a[i])continue;

		s+=a[i]>>1;

		a[i]&=1;

		if(a[i])if(a[i+1])a[i]--,a[i+1]--,s++;

	}

	printf("%lld\n",s);

}

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

#include<cstdio>

#include<cstdlib>

#include<algorithm>

#include<vector>

#include<queue>

using namespace std;

const int N=2005;

vector<int> ad[N],ap[N];

priority_queue<int> pq;

int a[N],ans[N],vis[N],tail[N];

int n,v,cnt;

void dfs(int x){

	vis[x]=1;

	for(int i=0;i<ad[x].size();i++){

		v=ad[x][i];

		if(vis[v])continue;

		tail[v]=1;ap[x].push_back(v);

		dfs(v);

	}

}

int main(){

	cin>>n;

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

	sort(a+1,a+n+1);

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

	if(__gcd(a[i],a[j])>1&&i!=j)ad[i].push_back(j);

	for(int i=1;i<=n;i++)if(vis[i]==0)dfs(i);

	for(int i=1;i<=n;i++)if(tail[i]==0)pq.push(i);

	while(pq.size()>0){

		v=pq.top();

		cnt++;ans[cnt]=a[v];

		pq.pop();

		for(int i=0;i<ap[v].size();i++)

		pq.push(ap[v][i]);

	}

	for(int i=1;i<=cnt;i++)cout<<ans[i]<<" ";

	cout<<endl;

	return 0;

} 

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

#include<algorithm>

#include<queue>

#include<vector>

using namespace std;

const int N=2333;

int a[N];

int g[N][N];

int n;

int gcd(int a,int b){return b?gcd(b,a%b):a;}

struct sumireko{int to,ne;}e[N*1000];

int he[N],ecnt;

void addline(int f,int t)

{

	e[++ecnt].to=t;

	e[ecnt].ne=he[f];

	he[f]=ecnt;

}



bool vv[N];

int bi;

int sp[N];

vector<int> to[N];

void dfs(int x)

{

	vv[x]=1;

	for(int i=he[x],t;i;i=e[i].ne)

	{

		t=e[i].to;

		if(!vv[t])

		{

			to[x].push_back(t);

			dfs(t);

		}

	}

}



priority_queue<int> q;



int main()

{

	scanf("%d",&n);

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

	sort(a+1,a+1+n);

	for(int i=n;i;i--)

		for(int j=i-1;j;j--)

			if(gcd(a[i],a[j])!=1)

				addline(i,j),addline(j,i)/*,printf("line %d %d\n",i,j)*/;

	for(int i=1;i<=n;i++) if(!vv[i])

	{

		bi++;

		sp[bi]=i;

		dfs(i);

	}

	/*printf("%d\n",bi);

	for(int i=1;i<=bi;i++) printf("%d ",sp[i]);

	puts("\n----------------------------------");

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

	{

		printf("%d:",i);

		for(int j=0;j<to[i].size();j++) printf("%d ",to[i][j]);

		putchar('\n');

	}

	puts("\n----------------------------------");*/

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

		q.push(sp[i]);

	while(!q.empty())

	{

		int g=q.top();

		q.pop();

		printf("%d ",a[g]);

		for(int i=0;i<to[g].size();i++) q.push(to[g][i]);

	}

	return 0;

}

// Fastest known solution for this problem: