stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

const int N=2005;

inline int read()

{

	int x=0,f=1,ch=getchar();

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

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

	return x*f;

}

inline int cread()

{

	int ch=getchar();

	while(ch<'0'||ch>'9') ch=getchar();

	return ch-'0';

}

int n,m,q;

int map[N][N];

int sum[N][N],sum1[N][N],sum2[N][N];

inline int query(int x1,int y1,int x2,int y2)

{

	return sum[x2][y2]-sum[x2][y1]-sum[x1][y2]+sum[x1][y1];

}

inline int query1(int x1,int y1,int x2,int y2)

{

	x2--;

	return sum1[x2][y2]-sum1[x2][y1]-sum1[x1][y2]+sum1[x1][y1];

}

inline int query2(int x1,int y1,int x2,int y2)

{

	y2--;

	return sum2[x2][y2]-sum2[x2][y1]-sum2[x1][y2]+sum2[x1][y1];

}

int main()

{

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

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

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

			map[i][j]=cread();

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

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

			sum[i][j]=sum[i-1][j]+sum[i][j-1]+map[i][j]-sum[i-1][j-1];

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

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

		{

			if(map[i][j]&&map[i+1][j]) sum1[i][j]=1;

			if(map[i][j]&&map[i][j+1]) sum2[i][j]=1;

			sum1[i][j]+=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1];

			sum2[i][j]+=sum2[i-1][j]+sum2[i][j-1]-sum2[i-1][j-1];

		}

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

	{

		int x1=read(),y1=read(),x2=read(),y2=read();x1--,y1--;

//		cout<<query(x1,y1,x2,y2)<<"\t"<<query1(x1,y1,x2,y2)<<"\t"<<query2(x1,y1,x2,y2)<<endl;

		printf("%d\n",query(x1,y1,x2,y2)-query1(x1,y1,x2,y2)-query2(x1,y1,x2,y2));

	}

	return 0;

}

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

using namespace std;

int x,y,xx,yy,n,m,q,c[2005][2005],cnt[2005][2005],e[2005][2005],e2[2005][2005],e3[2005][2005];

int main(){

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

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

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

			scanf("%1d",&c[i][j]);

			e2[i][j]=e2[i][j-1];e3[i][j]=e3[i-1][j];

			if(c[i][j]&&c[i][j-1]) ++e2[i][j];

			if(c[i][j]&&c[i-1][j]) ++e3[i][j];

		}

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

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

			cnt[i][j]=cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1]+c[i][j];

			e[i][j]=e[i-1][j]+e[i][j-1]-e[i-1][j-1];

			if(c[i][j]){

				if(c[i-1][j]) ++e[i][j];

				if(c[i][j-1]) ++e[i][j];

			}

		}

	while(q--){

		scanf("%d%d%d%d",&x,&y,&xx,&yy);--x;--y;

//		printf("**%d %d**\n",cnt[xx][yy]+cnt[x][y]-cnt[x][yy]-cnt[xx][y],e[xx][yy]+e[x+1][y+1]-e[x+1][yy]-e[xx][y+1]+e2[x+1][yy]-e2[x+1][y+1]+e3[xx][y+1]-e3[x+1][y+1]);

		printf("%d\n",cnt[xx][yy]+cnt[x][y]-cnt[x][yy]-cnt[xx][y]-(e[xx][yy]+e[x+1][y+1]-e[x+1][yy]-e[xx][y+1]+e2[x+1][yy]-e2[x+1][y+1]+e3[xx][y+1]-e3[x+1][y+1]));

	}

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

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

const int N=2005;

inline int read()

{

	int x=0,f=1,ch=getchar();

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

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

	return x*f;

}

inline int cread()

{

	int ch=getchar();

	while(ch<'0'||ch>'9') ch=getchar();

	return ch-'0';

}

int n,m,q;

int map[N][N];

int sum[N][N],sum1[N][N],sum2[N][N];

inline int query(int x1,int y1,int x2,int y2)

{

	return sum[x2][y2]-sum[x2][y1]-sum[x1][y2]+sum[x1][y1];

}

inline int query1(int x1,int y1,int x2,int y2)

{

	x2--;

	return sum1[x2][y2]-sum1[x2][y1]-sum1[x1][y2]+sum1[x1][y1];

}

inline int query2(int x1,int y1,int x2,int y2)

{

	y2--;

	return sum2[x2][y2]-sum2[x2][y1]-sum2[x1][y2]+sum2[x1][y1];

}

int main()

{

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

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

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

			map[i][j]=cread();

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

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

			sum[i][j]=sum[i-1][j]+sum[i][j-1]+map[i][j]-sum[i-1][j-1];

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

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

		{

			if(map[i][j]&&map[i+1][j]) sum1[i][j]=1;

			if(map[i][j]&&map[i][j+1]) sum2[i][j]=1;

			sum1[i][j]+=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1];

			sum2[i][j]+=sum2[i-1][j]+sum2[i][j-1]-sum2[i-1][j-1];

		}

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

	{

		int x1=read(),y1=read(),x2=read(),y2=read();x1--,y1--;

//		cout<<query(x1,y1,x2,y2)<<"\t"<<query1(x1,y1,x2,y2)<<"\t"<<query2(x1,y1,x2,y2)<<endl;

		printf("%d\n",query(x1,y1,x2,y2)-query1(x1,y1,x2,y2)-query2(x1,y1,x2,y2));

	}

	return 0;

}

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

using namespace std;

int n,sum[2005][2005],u[2005][2005],m,l[2005][2005],t[2005][2005];

char map[2005][2005];

int main()

{

	int q,x1,y1,x2,y2;

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

	for(int i=1;i<=n;i++) scanf("%s",map[i]+1);

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

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

		sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];

		u[i][j]=u[i-1][j]+u[i][j-1]-u[i-1][j-1];

		l[i][j]=l[i-1][j];t[i][j]=t[i][j-1];

		if(map[i][j]=='1'){

			sum[i][j]++;

			if(map[i-1][j]=='1') u[i][j]++,t[i][j]++;

			if(map[i][j-1]=='1') u[i][j]++,l[i][j]++;

		}

	}

	while(q--)

	{

		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

		printf("%d\n",sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1]-(u[x2][y2]-u[x1-1][y2]-u[x2][y1-1]+u[x1-1][y1-1]-t[x1][y2]-l[x2][y1]+t[x1][y1-1]+l[x1-1][y1]));

	}

	return 0;

}
// 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;



char a[2111][2111];

int up[2111][2111];

int ri[2111][2111];



int UP(int x1,int y1,int x2,int y2)

{

	return (up[x2][y2]-up[x2][y1-1]-up[x1-1][y2]+up[x1-1][y1-1]);

}



int RI(int x1,int y1,int x2,int y2)

{

	return (ri[x2][y2]-ri[x2][y1-1]-ri[x1-1][y2]+ri[x1-1][y1-1]);

}



int dp[2011][2011];



int DP(int x1,int y1,int x2,int y2)

{

	return (dp[x2][y2]-dp[x2][y1-1]-dp[x1-1][y2]+dp[x1-1][y1-1]);

}



int main()

{

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

	int n,m,q;

	cin>>n>>m>>q;

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

	{

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

		{

			cin>>a[i][j];

			if(a[i][j]=='1') dp[i][j]=1;

		}

	}

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

	{

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

		{

			if(a[i][j]=='1'&&a[i+1][j]=='1')

			{

				up[i][j]=1;

			}

		}

	}

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

	{

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

		{

			if(a[i][j]=='1'&&a[i][j+1]=='1')

			{

				ri[i][j]=1;

			}

		}

	}

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

	{

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

		{

			up[i][j]+=up[i-1][j]+up[i][j-1]-up[i-1][j-1];

			dp[i][j]+=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];

			ri[i][j]+=ri[i-1][j]+ri[i][j-1]-ri[i-1][j-1];

		}

	}

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

	{

		int x1,y1,x2,y2;

		cin>>x1>>y1>>x2>>y2;

		int V = DP(x1,y1,x2,y2);

		int E = RI(x1,y1,x2,y2-1)+UP(x1,y1,x2-1,y2);

		cout<<V-E<<'\n';

	}

}


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

const int MAXN=2005;



int N,M,Q;

bool grid[MAXN][MAXN];



int V[MAXN][MAXN],E1[MAXN][MAXN],E2[MAXN][MAXN];



int main()

{

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

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

		for(int j=1,x;j<=M;j++)

		{

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

			grid[i][j]=x;

		}

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

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

			V[i][j]=V[i-1][j]+V[i][j-1]-V[i-1][j-1]+grid[i][j];

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

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

			E1[i][j]=E1[i-1][j]+E1[i][j-1]-E1[i-1][j-1]+(grid[i][j]&&grid[i][j-1]);

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

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

			E2[i][j]=E2[i-1][j]+E2[i][j-1]-E2[i-1][j-1]+(grid[i][j]&&grid[i-1][j]);

	

	while(Q--)

	{

		int x1,y1,x2,y2;

		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

		printf("%d\n",

		(V[x2][y2]-V[x2][y1-1]-V[x1-1][y2]+V[x1-1][y1-1])

		-(E1[x2][y2]-E1[x2][y1]-E1[x1-1][y2]+E1[x1-1][y1])

		-(E2[x2][y2]-E2[x2][y1-1]-E2[x1][y2]+E2[x1][y1-1]));

	}

	

	return 0;

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

using namespace std;



#define FOR(i,a,b) for(int i = (a); i < (b); i++)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)

#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



#define SZ(a) (int) a.size()

#define ALL(a) a.begin(),a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const LL INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 2020;



int V[MAX][MAX];

int EX[MAX][MAX];

int EY[MAX][MAX];

char S[MAX][MAX];



int getS(int x1, int y1, int x2, int y2, int a[][MAX])

{

	int res = a[x2][y2];

	if (x1) res -= a[x1-1][y2];

	if (y1) res -= a[x2][y1 - 1];

	if (x1 && y1) res += a[x1-1][y1-1];

	return res;

}



int main()

{

	//freopen("in.txt", "r", stdin);

	//ios::sync_with_stdio(false); cin.tie(0);



	int n, m, q;

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

	FOR (i, 0, n)

	{

		scanf("%s", S[i]);

		FOR (j, 0, m)

		{

			S[i][j] -= '0';

		}

	}



	FOR (i, 0, n)

	{

		FOR (j, 0, m)

		{

			V[i][j] += S[i][j];

			if (i) V[i][j] += V[i-1][j];

			if (j) V[i][j] += V[i][j-1];

			if (i && j) V[i][j] -= V[i-1][j-1];



			if (i) EX[i][j] += S[i][j] & S[i-1][j];

			if (j) EY[i][j] += S[i][j] & S[i][j-1];



			if (i) EX[i][j] += EX[i-1][j];

			if (j) EX[i][j] += EX[i][j-1];

			if (i && j) EX[i][j] -= EX[i-1][j-1];



			if (i) EY[i][j] += EY[i-1][j];

			if (j) EY[i][j] += EY[i][j-1];

			if (i && j) EY[i][j] -= EY[i-1][j-1];

		}

	}



	FOR (i, 0, q)

	{

		int x1, y1, x2, y2;

		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

		x1--;

		y1--;

		x2--;

		y2--;



		int v = getS(x1, y1, x2, y2, V);

		int ex = getS(x1 + 1, y1, x2, y2, EX);

		int ey = getS(x1, y1 + 1, x2, y2, EY);



		int e = ex + ey;



		int cnt = v - e;

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



	}



}


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

const int MAXN=2005;



int N,M,Q;

bool grid[MAXN][MAXN];



int V[MAXN][MAXN],E1[MAXN][MAXN],E2[MAXN][MAXN];



int main()

{

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

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

		for(int j=1,x;j<=M;j++)

		{

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

			grid[i][j]=x;

		}

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

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

			V[i][j]=V[i-1][j]+V[i][j-1]-V[i-1][j-1]+grid[i][j];

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

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

			E1[i][j]=E1[i-1][j]+E1[i][j-1]-E1[i-1][j-1]+(grid[i][j]&&grid[i][j-1]);

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

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

			E2[i][j]=E2[i-1][j]+E2[i][j-1]-E2[i-1][j-1]+(grid[i][j]&&grid[i-1][j]);

	

	while(Q--)

	{

		int x1,y1,x2,y2;

		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

		printf("%d\n",

		(V[x2][y2]-V[x2][y1-1]-V[x1-1][y2]+V[x1-1][y1-1])

		-(E1[x2][y2]-E1[x2][y1]-E1[x1-1][y2]+E1[x1-1][y1])

		-(E2[x2][y2]-E2[x2][y1-1]-E2[x1][y2]+E2[x1][y1-1]));

	}

	

	return 0;

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

using namespace std;

#define R register

#define L 2002



inline void read(int &x){

    static int ch; static bool flag;

    for(flag=0,ch=getchar(); ch>'9'||ch<'0'; ch=getchar()) flag |= ch=='-';

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

    x = flag ? -x : x; 

}



int N,M,Q,Ans;

char Map[L][L];

int node[L][L],x[L][L],y[L][L];



inline int calc(int a1,int b1,int a2,int b2,int s[L][L]){

	return s[a2][b2]-s[a1-1][b2]+s[a1-1][b1-1]-s[a2][b1-1];

}



int main()

{

	read(N),read(M),read(Q);

	for(R int i=1;i<=N;++i) scanf("%s",Map[i]+1);

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

		for(R int j=1;j<=M;++j){

			node[i][j] = Map[i][j]=='1';

			node[i][j] += node[i-1][j]+node[i][j-1]-node[i-1][j-1];

			x[i][j] = Map[i][j]=='1' && Map[i-1][j]=='1';

			x[i][j] += x[i-1][j]+x[i][j-1]-x[i-1][j-1];

			y[i][j] = Map[i][j]=='1' && Map[i][j-1]=='1';

			y[i][j] += y[i-1][j]+y[i][j-1]-y[i-1][j-1];

		}

	while(Q--){

		R int a1,b1,a2,b2; read(a1),read(b1),read(a2),read(b2); Ans=0;

		Ans += calc(a1,b1,a2,b2,node);

		Ans -= calc(a1+1,b1,a2,b2,x);

		Ans -= calc(a1,b1+1,a2,b2,y);

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

	}

	return 0;

}

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

const int MAXN=2005;



int N,M,Q;

bool grid[MAXN][MAXN];



int V[MAXN][MAXN],E1[MAXN][MAXN],E2[MAXN][MAXN];



int main()

{

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

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

		for(int j=1,x;j<=M;j++)

		{

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

			grid[i][j]=x;

		}

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

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

			V[i][j]=V[i-1][j]+V[i][j-1]-V[i-1][j-1]+grid[i][j];

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

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

			E1[i][j]=E1[i-1][j]+E1[i][j-1]-E1[i-1][j-1]+(grid[i][j]&&grid[i][j-1]);

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

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

			E2[i][j]=E2[i-1][j]+E2[i][j-1]-E2[i-1][j-1]+(grid[i][j]&&grid[i-1][j]);

	

	while(Q--)

	{

		int x1,y1,x2,y2;

		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

		printf("%d\n",

		(V[x2][y2]-V[x2][y1-1]-V[x1-1][y2]+V[x1-1][y1-1])

		-(E1[x2][y2]-E1[x2][y1]-E1[x1-1][y2]+E1[x1-1][y1])

		-(E2[x2][y2]-E2[x2][y1-1]-E2[x1][y2]+E2[x1][y1-1]));

	}

	

	return 0;

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

#include <algorithm>

#include <stdio.h>

#include <vector>

#include <queue>

#include <string>

#include <cmath>

#include <map>

#include <string.h>

#define ll long long



using namespace std;



const int MAXN = 2000;



int row, col, q;

char area[MAXN + 5][MAXN + 5];

int pref[5][MAXN + 5][MAXN + 5];



int main(){

	

	cin >> row >> col >> q;

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

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

			cin >> area[i][j];

		}

	}

	for(int k = 1; k <= 3; k ++){

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

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

				pref[k][i][j] = pref[k][i - 1][j] 

					+ pref[k][i][j - 1] - pref[k][i - 1][j - 1];

				if(k == 1)pref[k][i][j] += (area[i][j] - '0');

				else if(k == 2){

					if(area[i][j - 1] == '1' && area[i][j] == '1')

						pref[k][i][j] += 1;

				}else{

					if(area[i - 1][j] == '1' && area[i][j] == '1')

						pref[k][i][j] += 1;

				}

			}

		}

	}

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

		int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;

		int ans = 0;

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

			int cur = 0;

			if(j == 1) cur = pref[j][r2][c2] - pref[j][r1 - 1][c2] - 

						pref[j][r2][c1 - 1] + pref[j][r1 - 1][c1 - 1];

			if(j == 2) cur = pref[j][r2][c2] - pref[j][r1 - 1][c2] - 

						pref[j][r2][c1] + pref[j][r1 - 1][c1];

			if(j == 3) cur = pref[j][r2][c2] - pref[j][r1][c2] -

						pref[j][r2][c1 - 1] + pref[j][r1][c1 - 1];

			// cout << j <<" "<< cur << endl;

			if(j == 1)ans += cur;

			else ans -= cur;

		}

		cout << ans << endl;

	}



	return 0;

}

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

const int MAXN=2005;



int N,M,Q;

bool grid[MAXN][MAXN];



int V[MAXN][MAXN],E1[MAXN][MAXN],E2[MAXN][MAXN];



int main()

{

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

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

		for(int j=1,x;j<=M;j++)

		{

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

			grid[i][j]=x;

		}

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

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

			V[i][j]=V[i-1][j]+V[i][j-1]-V[i-1][j-1]+grid[i][j];

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

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

			E1[i][j]=E1[i-1][j]+E1[i][j-1]-E1[i-1][j-1]+(grid[i][j]&&grid[i][j-1]);

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

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

			E2[i][j]=E2[i-1][j]+E2[i][j-1]-E2[i-1][j-1]+(grid[i][j]&&grid[i-1][j]);

	

	while(Q--)

	{

		int x1,y1,x2,y2;

		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

		printf("%d\n",

		(V[x2][y2]-V[x2][y1-1]-V[x1-1][y2]+V[x1-1][y1-1])

		-(E1[x2][y2]-E1[x2][y1]-E1[x1-1][y2]+E1[x1-1][y1])

		-(E2[x2][y2]-E2[x2][y1-1]-E2[x1][y2]+E2[x1][y1-1]));

	}

	

	return 0;

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

#include <cstdio>

#include <cstring>

#include <queue>

using namespace std;



typedef long long LL;



int main() {

    LL A, B, C;

    cin >> A >> B >> C;

    LL ans1 = 0;

    if (A%2 != 0) {

        ans1 = B*C;

    }

    LL ans2 = 0;

    if (C%2 != 0) {

        ans2 = B*A;

    }

    LL ans3 = 0;

    if (B%2 != 0) {

        ans3 = A*C;

    }

    LL ans = min(ans1,ans2);

    ans = min(ans, ans3);

    cout << ans << endl;

    return 0;

}

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

#include <algorithm>

using namespace std;

#define ll long long



int main(){

	ll a, b, c;

	scanf("%lld%lld%lld", &a, &b ,&c);

	if(a >= b && a >= c){

		if(a % 2) printf("%lld\n", b * c);

		else printf("0\n");

	}else if(b >= a && b >= c){

		if(b % 2) printf("%lld\n", a * c);

		else printf("0\n");

	}else if(c >= a && c >= b){

		if(c % 2) printf("%lld\n", a * b);

		else printf("0\n");

	}

	return 0;

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

#include<algorithm>

using namespace std;

int main()

{

	long long a, b, c;

	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)

		cout << 0 << endl;

	else

		cout << min(min(a*b, b*c), a*c) << endl;

	//system("Pause");

}

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

#include <algorithm>

using namespace std;

#define ll long long



int main(){

	ll a, b, c;

	scanf("%lld%lld%lld", &a, &b ,&c);

	if(a >= b && a >= c){

		if(a % 2) printf("%lld\n", b * c);

		else printf("0\n");

	}else if(b >= a && b >= c){

		if(b % 2) printf("%lld\n", a * c);

		else printf("0\n");

	}else if(c >= a && c >= b){

		if(c % 2) printf("%lld\n", a * b);

		else printf("0\n");

	}

	return 0;

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

#include <cstdio>

#include <cstring>

#include <queue>

using namespace std;



typedef long long LL;



int main() {

    LL A, B, C;

    cin >> A >> B >> C;

    LL ans1 = 0;

    if (A%2 != 0) {

        ans1 = B*C;

    }

    LL ans2 = 0;

    if (C%2 != 0) {

        ans2 = B*A;

    }

    LL ans3 = 0;

    if (B%2 != 0) {

        ans3 = A*C;

    }

    LL ans = min(ans1,ans2);

    ans = min(ans, ans3);

    cout << ans << endl;

    return 0;

}

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

#include<algorithm>



using namespace std;



int main(){

	long long  a[3],b=0;

	scanf("%lld %lld %lld",&a[0],&a[1],&a[2]);

	sort(a,a+3);

	b=(a[2]%2)*(a[1]*a[0]);

	printf("%lld",b);

	return 0;

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

#include<algorithm>

using namespace std;

int main()

{

	long long a, b, c;

	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)

		cout << 0 << endl;

	else

		cout << min(min(a*b, b*c), a*c) << endl;

	//system("Pause");

}

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

#include<algorithm>



using namespace std;



int main(){

	long long  a[3],b=0;

	scanf("%lld %lld %lld",&a[0],&a[1],&a[2]);

	sort(a,a+3);

	b=(a[2]%2)*(a[1]*a[0]);

	printf("%lld",b);

	return 0;

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

using namespace std;

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



int main(){

  int N;

  cin >> N;

  vector<int> a(N);

  rep(i,N){

    cin >> a[i];

  }



  int count = 0;

  bool flag = true;

    

  while(flag == true){

    rep(i,N){

    	if(a[i]%2 == 0){

      		a[i] = a[i]/2;

        }

      	else {

          flag = false;

          break ;

        }

    }

    if(flag == false) break;

    count++;

  }

  

  cout << count << endl;

  

  return 0;

}


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

#include <algorithm>

using namespace std;



int N, A[200];



int main()

{

	int dmin = 100;

	scanf("%d", &N);

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

		int A;

		scanf("%d", &A);

		int d = 0;

		while (A % 2 == 0) {

			A /= 2;

			++d;

		}

		dmin = min(dmin, d);

	}

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

	return 0;

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

using namespace std;



int main(){

  int n;  cin >> n;

  int ans = 1<<30;

  while(n--){

    int a;  cin >> a;

    int cnt = 0;

    while(a % 2 == 0){

      a >>= 1;

      cnt++;

    }

    ans = min(ans, cnt);

  }



  cout << ans << endl;



  return 0;

}


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

#define min(x, y) ((x)<(y) ? (x) : (y))

int main(){

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

	int ans = 1<<30;

  while(n--){

    int a;  scanf("%d", &a);

    int count = 0;

    while(a % 2 == 0){

      count++;

      a >>= 1;

    }

    ans = min(ans, count);

  }

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

  return 0;

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

#include <string>

#include <vector>

#include <cstdlib>

using namespace std;







int main() {

    int N;

    cin >> N;

    vector<int> vec(N);

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

      int val;

      cin >> val;

      vec[i] = val;

    }



    int ans = 0;



    while (true) {

        bool odd = false;

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

            if (vec[i] % 2 != 0) odd = true;

        }



        if (odd) break;



        for (int i = 0; i < N; ++i) {vec[i] /= 2;}

        ++ans;

    }

    cout << ans << "\n";

}


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

using namespace std;



int main() {

    int N;

    scanf("%d\n", &N);

    int A[N];

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

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

    }

 

    int ans = 0;

    while (true) {

        bool odd = false;

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

            if (A[i] % 2) odd = true;

        }

        if (odd) break;

        for (int i = 0; i < N; ++i) {A[i] /= 2;}

        ++ans;

    }

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

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

using namespace std;

#define ll long long

#define ull unsigned long long

#define mp make_pair

typedef pair<int,int> pii;

ll a[200009];

ll n;ll k;

int main()

{

    scanf("%d%lld",&n,&k);

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

    sort(a,a+n);

    ll l=-1e18,r=1e18;

    while(r-l>1)

    {

        ll mid=(l+r)/2;ll cnt=0;

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

        {

            if(a[i]>0){

                cnt+=upper_bound(a,a+n,(long double)mid/a[i])-a;

            }

            else if(a[i]<0){

                cnt+=n-(lower_bound(a,a+n,(long double)mid/a[i])-a);

            }

            else if(mid>=0)cnt+=n;

            if(a[i]*a[i]<=mid)cnt--;

        }

        if(cnt>=k*2)r=mid;

        else l=mid;

    }

    cout<<r<<endl;

    return 0;

}

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

using namespace std;

#define int long long

#define ld long double

#define pb push_back

#define mp make_pair

#define eb emplace_back

#define fi first

#define se second

#define lb lower_bound

#define ub upper_bound

const int mod = 1e9+7;

const int mx = 1e18;

const long double pi = 4*atan((long double)1);

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef vector<pii> vii;

#define file "orz"

int n,k;

signed main()

{

    //freopen(file".inp","r",stdin);

    //freopen(file".out","w",stdout);

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

    cin>>n>>k;

    int arr[n+5];	

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

    	cin>>arr[i];

    sort(arr,arr+n);

    int l=-mx, r=mx;

    while(l+1<r)

    {

//    	cout<<l<<endl;

    	int mid=(l+r)>>1;

    	int tmp=0;

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

    	{

//    		cout<<i<<endl;

    		if(arr[i]>0)

			{

			    if(arr[0]*arr[i]>mid)

			    	continue;

			    int ll=0, rr=n;

			    while(ll+1<rr)

			    {

			    	int m=(ll+rr)>>1;

			    	if(arr[i]*arr[m]>mid)

			    		rr=m;

			    	else

			    		ll=m;

				}

				tmp+=rr;

				if(arr[i]*arr[i]<=mid)

					tmp--;

			}

			if(arr[i]==0)

				if(mid>=0)

					tmp+=n-1;

			if(arr[i]<0)

			{

				if(arr[n-1]*arr[i]>mid)

					continue;

				int ll=-1, rr=n-1;

				while(ll+1<rr)

				{

					int m=(ll+rr)>>1;

					if(arr[i]*arr[m]>mid)

						ll=m;

					else

						rr=m;	

				}

				tmp+=n-rr;	

				if(arr[i]*arr[i]<=mid)

					tmp--;

			}	

		}

//		cout<<"here";

//		cout<<tmp<<endl;

		if(tmp>=k*2)

			r=mid;

		else

			l=mid;

	}

	cout<<l+1;

}