stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



set<int>gr[2][2010];

int depth[2][2010];

int spTab[2][15][2010];



void dfs(int gn, int u, int p, int d)

{

    depth[gn][u] = d;

    spTab[gn][0][u] = p;

    for(int v:gr[gn][u]){

        if(v != p)

            dfs(gn, v, u, d+1);

    }

}

int n;



void fill(){

    for(int gn = 0; gn < 2; gn++){

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

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

                if(spTab[gn][i-1][j] != -1){

                    spTab[gn][i][j] = spTab[gn][i-1][spTab[gn][i-1][j]];

                }

            }

        }

    }

}



int lca(int gn, int u, int v){

    if(depth[gn][u] > depth[gn][v]){

        swap(u, v);

    }

    for(int i = 14; i >= 0; i--){

        if(depth[gn][v]-(1<<i) >= depth[gn][u])

            v = spTab[gn][i][v];

    }

    if(u == v)return u;

    for(int i = 14; i >= 0; i--){

        if(spTab[gn][i][u] != spTab[gn][i][v]){

            u = spTab[gn][i][u];

            v = spTab[gn][i][v];

        }

    }

    return spTab[gn][0][u];

}



int dist(int u, int v){

    int d = max(u, v) - min(u, v);

    int l0 = lca(0, u, v);

    int l1 = lca(1, u, v);

    int d0 = depth[0][u] + depth[0][v] - 2*depth[0][l0];

    int d1 = depth[1][u] + depth[1][v] - 2*depth[1][l1];

    return min(d, min(d0, d1));

}



int main()

{

    cin >> n;

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

        gr[0][i].insert(i+1);

        gr[1][i].insert(i+1);

        

        gr[0][i+1].insert(i);

        gr[1][i+1].insert(i);

    }

    int x, y;

    cin >> x >> y;

    gr[0][x].insert(y);

    gr[0][y].insert(x);

    gr[1][x].insert(y);

    gr[1][y].insert(x);

    memset(spTab, -1, sizeof(spTab));

    gr[0][x].erase(x+1);

    gr[0][x+1].erase(x);

    dfs(0, x, -1, 0);

    gr[1][y].erase(y-1);

    gr[1][y-1].erase(y);

    dfs(1, y, -1, 0);

    

    fill();

    vector<int>len;

    len.resize(n);

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

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

            //int d = dist(i, j);

            //cerr << i << " " << j << ": " << d << endl;

          int d = min({j-i, abs(y-j)+1+abs(x-i), abs(y-i)+1+abs(x-j)});

            len[d]++;

        }

    }

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

        cout << len[i] << endl;

    }

    return 0;

}


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



using namespace std;



int main()

{

  int n;

    cin >> n;

    int x, y;

    cin >> x >> y;

    vector<int>len;

    len.resize(n);

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

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

          int d = min({j-i, abs(y-j)+1+abs(x-i), abs(y-i)+1+abs(x-j)});

            len[d]++;

        }

    }

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

        cout << len[i] << endl;

    }

    return 0;

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

using namespace std;

int n,x,y;

int cnt[2020];

int dist[2020][2020];

vector<int> ga[2020];

queue<int> q;

void BFS(int src){

	q.push(src);

	memset(dist[src],63,sizeof(dist[src]));

	dist[src][src]=0;

	int pp;

	while(q.size()){

		pp=q.front();

		q.pop();

		for(int snk:ga[pp]){

			if(dist[src][snk]>dist[src][pp]+1){

				dist[src][snk]=dist[src][pp]+1;

				q.push(snk);

			} 

		}

	}

}

int main(){

	#ifdef FILIN

		#ifndef LOCAL

			freopen(FILIN,"r",stdin);

			freopen(FILOUT,"w",stdout);

		#endif

	#endif

	cin>>n>>x>>y;

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

		ga[i].push_back(i+1);

		ga[i+1].push_back(i);

	}

	ga[x].push_back(y);

	ga[y].push_back(x);

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

		BFS(i);

	}

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

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

			cnt[dist[i][j]]++;

		}

	}

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

		cout<<cnt[i]<<endl;

	return 0;

}


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

using namespace std;

int n,x,y;

int dist;

int cnt[2020];

int main(){

	#ifdef FILIN

		#ifndef LOCAL

			freopen(FILIN,"r",stdin);

			freopen(FILOUT,"w",stdout);

		#endif

	#endif

	cin>>n>>x>>y;

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

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

			dist=j-i;

			dist=min(dist,abs(i-x)+abs(j-y)+1);

			dist=min(dist,abs(i-y)+abs(j-x)+1);

			cnt[dist]++;

		}

	} 

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

		cout<<cnt[i]<<endl;

	return 0;

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

#include <string>

#define ft first

#define sc second

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) (a)=(a>b)?(a):(b);

#define chmin(a, b) (a)=(a<b)?(a):(b);

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> pll;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;





/*

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

   cin >> a[i];

*/



class Edge {

public:

  ll t, w;

  Edge() {}

  Edge(ll t, ll w): t(t), w(w) {}

};



ll N, M;

vector<Edge> g[2222];

ll d[2222][2222];



void dijkstra(ll s) {

  ll i, u;

  ll clr[2222]={};

  priority_queue<pll> q;

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

    d[s][i]=INF;

    clr[i]=0;

  }

  d[s][s]=0;

  q.push({0, s});

    

  while(q.size()) {

    pll f=q.top(); q.pop();

    u=f.second;

    clr[u]=1;

    if(d[s][u]<-f.first) continue;

    

    for(i=0; i<g[u].size(); i++) {

      Edge e=g[u][i];

      if(clr[e.t] || d[s][e.t]<=d[s][u]+e.w) continue;

      

      d[s][e.t]=d[s][u]+e.w;

      q.push({-d[s][e.t], e.t});

    }

  }

}

int main(void) {

  ll i, j, k;

  

  ll X, Y;

  cin >> N >> X >> Y;

  X--; Y--;

  

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

    g[i].push_back(Edge(i+1, 1));

    g[i+1].push_back(Edge(i, 1));

  }

  

  g[X].push_back(Edge(Y, 1));

  g[Y].push_back(Edge(X, 1));

  

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

  

  ll cnt[2222]={};

  for(i=0; i<N; i++) for(j=i+1; j<N; j++) cnt[d[i][j]]++;

  

  for(i=1; i<N; i++) pt(cnt[i]);

  

  

  

}






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

#include <string>

#define ft first

#define sc second

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) (a)=(a>b)?(a):(b);

#define chmin(a, b) (a)=(a<b)?(a):(b);

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> pll;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;





/*

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

   cin >> a[i];

*/







int main(void) {

  ll i, j, k;

  

  ll N, X, Y;

  cin >> N >> X >> Y;

  X--; Y--;

  

  

  ll cnt[2222]={};

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

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

      cnt[min(j-i, abs(X-i)+1+abs(Y-j))]++;

  

  for(i=1; i<N; i++) pt(cnt[i]);

  

  

  

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

#define N 100005

#define ll long long

#define inf 0x3f3f3f3f

#define m0(x) memset(x,0,sizeof(x))

#define m1(x) memset(x,-1,sizeof(x))

using namespace std;

int n,l,r,ans[2005];

int main()

{

	cin>>n>>l>>r;

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

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

	{

		int dis=j-i;

		dis=min(dis,abs(l-i)+abs(r-j)+1);

		dis=min(dis,abs(r-i)+abs(l-j)+1);

		ans[dis]++;

	}

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

	cout<<ans[i]<<endl;

	return 0;

}

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

#include<cmath>

#include<algorithm>

using namespace std;

int dis[2002];

int main(){

  int n,x,y;

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

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

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

      int cache;

      cache=min(j-i,abs(i-x)+abs(j-y)+1);

      if(cache<n)dis[cache]++;

	}

  }

  for(int i=1;i<n;i++) printf("%d\n",dis[i]);

  return 0;

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

using namespace std;

const int maxn=20000+5;

int n,x,y,ans[maxn];

int main(){

	cin>>n>>x>>y;

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

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

		{

			int dist1=i-j;

			int dist2=abs(x-j)+abs(y-i)+1;

			int dist=min(dist1,dist2);

			ans[dist]++;

		}

	for(int i=1;i<=n-1;i++)cout<<ans[i]<<endl;

	return 0;

}

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

#include<cmath>

#include<algorithm>

using namespace std;

int dis[2002];

int main(){

  int n,x,y;

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

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

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

      int cache;

      cache=min(j-i,abs(i-x)+abs(j-y)+1);

      if(cache<n)dis[cache]++;

	}

  }

  for(int i=1;i<n;i++) printf("%d\n",dis[i]);

  return 0;

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

using namespace std;

int n,x,y,f[2004];



int main()

{

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

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

    {

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

        {

            if(j<=x||i>=y)

            {

                f[j-i]++;

            }

            else if(i>x&&i<y&&j<y&&j>x)

            {

                int p=min(j-i,y-j+1+i-x);

                f[p]++;

            }

            else if(i<=x&&j>=y)f[j-i-(y-x-1)]++;

            else if(i<=x&&j>x)

            {

                int p=min(j-i,y-j+1+x-i);

                f[p]++;

            }

            else 

            {

                int p=min(j-i,i-x+1+j-y);

                f[p]++;

            }

        }

    }

    for(int i=1;i<n;i++)printf("%d\n",f[i]);

}

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

#include<cmath>

#include<algorithm>

using namespace std;

int dis[2002];

int main(){

  int n,x,y;

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

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

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

      int cache;

      cache=min(j-i,abs(i-x)+abs(j-y)+1);

      if(cache<n)dis[cache]++;

	}

  }

  for(int i=1;i<n;i++) printf("%d\n",dis[i]);

  return 0;

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

#include<math.h>

#include<string>

#include<string.h>

#include<iostream>

#include<stdlib.h>

#include<stdio.h>

#include<vector>

#include<queue>

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

#define fo1(n)for(int i = 1; i<=n ; i++)

using namespace std;

vector<int>G[2005];

int vis[2005];

int len[2005];

queue<pair<int, int> >q;

void bfs(int now, int deep)

{

	memset(vis, 0, 2005*sizeof(int));

	

	q.push(make_pair(now, deep));

	int no, dep;

	vis[now] = 1;

	while (!q.empty())

	{

		no = q.front().first;

		dep = q.front().second;

		vis[no] = 1;

		len[dep]++;

		q.pop();

		fo(G[no].size())

		{

			if (!vis[G[no][i]])

			{

				q.push(make_pair(G[no][i], dep + 1));

				vis[G[no][i]] = 1;

			}

		}

	}

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	int n, x, y;

	cin >> n >> x >> y;

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

	{

		G[i].push_back(i + 1);

		G[i + 1].push_back(i);

	}

	G[x].push_back(y);

	G[y].push_back(x);

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

	{

		bfs(i, 0);

	}

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

	{

		cout << len[i] / 2 << endl;

	}

	return 0;

}

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

#include<cmath>

#include<iostream>

#include<algorithm>

#include<cstring>

#include<cstdlib>

#include<queue>

#include<map>

#include<stack>

#include<set>

#include<vector>

#include<functional>

using namespace std;

typedef long long LL;

inline LL read()

{

	LL kk=0,f=1;

	char cc=getchar();

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

	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}

	return kk*f;

}

LL dis[2022][2022];

LL cun[2022];

int main()

{

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

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

	for(LL j=1;j<=n;++j)

	dis[i][j]=abs(i-j);

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

	for(LL j=1;j<=n;++j)

	{

		dis[i][j]=min(dis[i][j],dis[i][x]+dis[y][j]+1);

	}

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

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

	cun[dis[i][j]]++;

	for(int i=1;i<n;++i)printf("%d\n",cun[i]);

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

#include<math.h>

#include<string>

#include<string.h>

#include<iostream>

#include<stdlib.h>

#include<stdio.h>

#include<vector>

#include<queue>

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

#define fo1(n)for(int i = 1; i<=n ; i++)

using namespace std;

vector<int>G[2005];

int vis[2005];

int len[2005];

queue<pair<int, int> >q;

void bfs(int now, int deep)

{

	memset(vis, 0, 2005*sizeof(int));

	

	q.push(make_pair(now, deep));

	int no, dep;

	vis[now] = 1;

	while (!q.empty())

	{

		no = q.front().first;

		dep = q.front().second;

		vis[no] = 1;

		len[dep]++;

		q.pop();

		fo(G[no].size())

		{

			if (!vis[G[no][i]])

			{

				q.push(make_pair(G[no][i], dep + 1));

				vis[G[no][i]] = 1;

			}

		}

	}

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	int n, x, y;

	cin >> n >> x >> y;

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

	{

		G[i].push_back(i + 1);

		G[i + 1].push_back(i);

	}

	G[x].push_back(y);

	G[y].push_back(x);

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

	{

		bfs(i, 0);

	}

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

	{

		cout << len[i] / 2 << endl;

	}

	return 0;

}

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

#include<cstdio>

#include<cstdlib>

#include<cstring>

using namespace std;

typedef long long ll;



int n, x, y, res[2010];

int main(){

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

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

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

              int dst = j-i;

              dst = min(dst, abs(i-x)+abs(j-y)+1);

              dst = min(dst, abs(j-x)+abs(i-y)+1);

              res[dst]++;

        }

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

            printf("%d\n", res[i]);



        return 0;



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

#include<math.h>

#include<string>

#include<string.h>

#include<iostream>

#include<stdlib.h>

#include<stdio.h>

#include<vector>

#include<queue>

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

#define fo1(n)for(int i = 1; i<=n ; i++)

using namespace std;

vector<int>G[2005];

int vis[2005];

int len[2005];

queue<pair<int, int> >q;

void bfs(int now, int deep)

{

	memset(vis, 0, 2005*sizeof(int));

	

	q.push(make_pair(now, deep));

	int no, dep;

	vis[now] = 1;

	while (!q.empty())

	{

		no = q.front().first;

		dep = q.front().second;

		vis[no] = 1;

		len[dep]++;

		q.pop();

		fo(G[no].size())

		{

			if (!vis[G[no][i]])

			{

				q.push(make_pair(G[no][i], dep + 1));

				vis[G[no][i]] = 1;

			}

		}

	}

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	int n, x, y;

	cin >> n >> x >> y;

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

	{

		G[i].push_back(i + 1);

		G[i + 1].push_back(i);

	}

	G[x].push_back(y);

	G[y].push_back(x);

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

	{

		bfs(i, 0);

	}

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

	{

		cout << len[i] / 2 << endl;

	}

	return 0;

}

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

using namespace std;

int st[2003];

int main()

{

    int g,h,t,q,w,a,b,c,nn;

    scanf("%d %d %d",&t,&q,&w);

    for(g=1;g<t;g++){

        for(h=g+1;h<=t;h++){

            a=h-g;

            b=abs(q-g)+abs(w-h)+1;

            c=abs(q-h)+abs(w-g)+1;

            nn=min(a,min(b,c));

            st[nn]++;

        }

    }

    for(g=1;g<t;g++)

        printf("%d\n",st[g]);

    return 0;

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

#include<math.h>

#include<string>

#include<string.h>

#include<iostream>

#include<stdlib.h>

#include<stdio.h>

#include<vector>

#include<queue>

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

#define fo1(n)for(int i = 1; i<=n ; i++)

using namespace std;

vector<int>G[2005];

int vis[2005];

int len[2005];

queue<pair<int, int> >q;

void bfs(int now, int deep)

{

	memset(vis, 0, 2005*sizeof(int));

	

	q.push(make_pair(now, deep));

	int no, dep;

	vis[now] = 1;

	while (!q.empty())

	{

		no = q.front().first;

		dep = q.front().second;

		vis[no] = 1;

		len[dep]++;

		q.pop();

		fo(G[no].size())

		{

			if (!vis[G[no][i]])

			{

				q.push(make_pair(G[no][i], dep + 1));

				vis[G[no][i]] = 1;

			}

		}

	}

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	int n, x, y;

	cin >> n >> x >> y;

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

	{

		G[i].push_back(i + 1);

		G[i + 1].push_back(i);

	}

	G[x].push_back(y);

	G[y].push_back(x);

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

	{

		bfs(i, 0);

	}

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

	{

		cout << len[i] / 2 << endl;

	}

	return 0;

}

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

using namespace std;



int n,x,y;

int dis[2010][2010];

int cnt[2010];



int main()

{

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

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

	{

		dis[i][j]=min(j-i,min(abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1));

		cnt[dis[i][j]]++;

	}

	for(int i=1;i<n;i++) printf("%d\n",cnt[i]);

	return 0;

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

#include<math.h>

#include<string>

#include<string.h>

#include<iostream>

#include<stdlib.h>

#include<stdio.h>

#include<vector>

#include<queue>

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

#define fo1(n)for(int i = 1; i<=n ; i++)

using namespace std;

vector<int>G[2005];

int vis[2005];

int len[2005];

queue<pair<int, int> >q;

void bfs(int now, int deep)

{

	memset(vis, 0, 2005*sizeof(int));

	

	q.push(make_pair(now, deep));

	int no, dep;

	vis[now] = 1;

	while (!q.empty())

	{

		no = q.front().first;

		dep = q.front().second;

		vis[no] = 1;

		len[dep]++;

		q.pop();

		fo(G[no].size())

		{

			if (!vis[G[no][i]])

			{

				q.push(make_pair(G[no][i], dep + 1));

				vis[G[no][i]] = 1;

			}

		}

	}

}

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	int n, x, y;

	cin >> n >> x >> y;

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

	{

		G[i].push_back(i + 1);

		G[i + 1].push_back(i);

	}

	G[x].push_back(y);

	G[y].push_back(x);

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

	{

		bfs(i, 0);

	}

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

	{

		cout << len[i] / 2 << endl;

	}

	return 0;

}

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



using namespace std;



const int N = 2005;



int n, X, Y;



int cnt[2005];



int main(){

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



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

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

            if(i<=X&&j<=Y){

                ++cnt[min(j-i,X-i+Y-j+1)];

            }else if(i<=X&&j>Y){

                ++cnt[X-i+j-Y+1];

            }else if(i<=Y&&j<=Y){

                ++cnt[min(j-i,i-X+Y-j+1)];

            }else if(i<=Y&&j>Y){

                ++cnt[min(j-i,i-X+j-Y+1)];

            }else{

                ++cnt[j-i];

            }

        }

    }



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

        printf("%d\n",cnt[i]);

    }





    return 0;

}
// Slower C++ solution:
#pragma GCC optimize(3,"Ofast","inline")

#include <bits/stdc++.h>

#define N 100005

#define ll long long

#define inf 0x3f3f3f3f

#define m0(x) memset(x,0,sizeof(x))

#define m1(x) memset(x,-1,sizeof(x))

using namespace std;

ll ans[2000+5],a[2005][2005];

int main()

{

	ll n,x,y;

	cin>>n>>x>>y;

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

	{

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

			a[i][j]=max(i-j,j-i);

	}

	a[x][y]=1;

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

	{

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

		{

			if(a[i][j]>a[i][x]+1+a[y][j])

				a[i][j]=a[i][x]+1+a[y][j];

		}

	}

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

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

		{

		//cout<<i<<' '<<j<<' '<<a[i][j]<<' '<<endl;

			ans[a[i][j]]++;

		}

	//cout<<endl;	

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

		cout<<ans[i]<<endl;

	return 0;

}


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

#include<algorithm>

using namespace std;

int n,x,y,A[20000];

int main()

{

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

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

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

            {

                int s=j-i;

                if(j<=x||i>=y)

                    A[s]++;

                else

                {

                    s=min(abs(i-x)+abs(j-y)+1,s);

                     s=min(abs(i-y)+abs(j-x)+1,s);

                     A[s]++;



                }

            }



    }

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

        printf("%d\n",A[i]);

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

#include <vector>

#include <algorithm>



using namespace std;



int main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int n, x, y;

    cin >> n >> x >> y;

    vector<vector<int>> d = vector<vector<int>>(n + 1, vector<int>(n + 1));

    vector<int> a = vector<int>(n);

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

    {

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

        {

            d[i][j] = abs(i - j);

        }

    }

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

    {

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

        {

            d[i][j] = min(d[i][j], d[i][x] + d[y][j] + 1);

            a[d[i][j]]++;

        }

    }

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

    {

        cout << a[i] << "\n";

    }

}

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

#include<algorithm>

using namespace std;

int n,x,y,A[20000];

int main()

{

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

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

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

            {

                int s=j-i;

                if(j<=x||i>=y)

                    A[s]++;

                else

                {

                    s=min(abs(i-x)+abs(j-y)+1,s);

                     s=min(abs(i-y)+abs(j-x)+1,s);

                     A[s]++;



                }

            }



    }

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

        printf("%d\n",A[i]);

}
// Slower C++ solution:
#pragma GCC optimize("O3")

//#pragma GCC optimize("unroll-loops,no-stack-protector")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>



#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define endl '\n'

#define elif else if

#define ll long long int

#define ld long double

#define vec vector

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

#define fore(a, v, n) for(ll a=v; a<n; a++)

#define all(x) x.begin(), x.end()

#define presicion(x) cout<<fixed<<setprecision(x)

#define dbg(x) cerr<<#x<<" = "<<x<<endl

#define PI 3.14159265358979323

#define sen(ang) sin((ang)*PI/180)

//cout<<flush;



using namespace std;



#define MUCHO 9999999



ll n;

map<ll, ll> cants;

ll ns[400000];



int main() {

	IOS;

	cin >> n;

	forn (i) {

		cin >> ns[i];

		cants[ns[i]]++;

	}



	ll count = 0;

	for (auto v = cants.rbegin(); v != cants.rend(); v++) {

		if (!v->second)

			continue;

		assert(v->second > 0);



		{

			ll count = 0;



			fore (e, 1, 31) {

				int sum = 1 << e;

				auto pair = cants.find(sum - v->first);



				if (pair != cants.end() && pair->second)

					count++;

			}



			assert(0 <= count && count <= 1);

		}



		fore (e, 1, 31) {

			ll sum = 1 << e;

			auto pair = cants.find(sum - v->first);

			assert(0 <= pair->second);



			if (pair != cants.end() && pair->second) {

				ll matches = min(pair->second, v->second);



				if (pair->first == v->first)

					matches /= 2;

				pair->second -= matches;

				v->second -= matches;

				count += matches;

				break;

			}

		}

	}



	cout << count << endl;

	return 0;

}


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

#include <cstring>

#include <algorithm>

#include <vector>

#include <map>

#ifdef sahdsg

#define DBG(...) printf(__VA_ARGS__)

#else

#define DBG(...) (void)0

#endif // sahdsg

#define REP(r,x,y) for(register int r=(x); r<y; r++)

using namespace std;

typedef long long LL;

inline void read(int&x) {

	x=0;char ch=getchar(); while(ch<'0') ch=getchar();

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

}

map<int,int> a;

int main()

{

	int n; read(n);

	REP(i,0,n) {

		int t; read(t);

		if(a.count(t)==0) a[t]=0;

		a[t]++;

	}

	int ans=0;

	for(map<int,int>::reverse_iterator it=a.rbegin(); it!=a.rend(); it++) {

		int now=it->first;

		int k=now;

		k|=k>>1;

		k|=k>>2;

		k|=k>>4;

		k|=k>>8;

		k|=k>>16;

		k++;

		k-=now;

		DBG("%d %d %d\n", k, now, a[k]);

		if(k==now) ans+=a[k]/2,it->second%=2;

		else ans+=min(it->second,a[k]),a[k]-=min(it->second,a[k]);

	}

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

}