akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    int tmp = N, S = 0;
    while(tmp > 0){
        S += tmp % 10;
        tmp /= 10;
    }
    if(N % S == 0) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_N = 312345;
ll x[MAX_N], y[MAX_N];

const ll INF = 1e18;

int main2() {
  int N = nextLong();
  REP(i, N) {
    x[i] = nextLong();
    y[i] = nextLong();
  }
  ll ans = 0;

  for (int s = 0; s < (1 << 2); s++) {

    ll ma = -INF, mi = INF;
    REP(i, N) {
      ll x1 = (s >> 0 & 1) ? x[i] : -x[i];
      ll y1 = (s >> 1 & 1) ? y[i] : -y[i];
      chmax(ma, x1 + y1);
      chmin(mi, x1 + y1);
    }
    chmax(ans, ma - mi);
  }

  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 6888
#include <bits/stdc++.h>
#define pb push_back
#define int long long

using namespace std;

double PI = acos(-1);
const int MAXN = 2e9;

long long ans = 0;

main() {
	int	n;
	cin >> n;
	vector<int> arr(n + 11), l(n + 11), r(n + 11);
	for(int i = 0; i <n; i++) {
		cin >> arr[i];
	}
	stack <int> st;
	for(int i = 0; i < n; i++) {
		while(!st.empty() && arr[st.top()] >= arr[i]) 
			st.pop();
		if(st.empty())
			l[i] = 0;
		else
			l[i] = st.top() + 1;
		st.push(i);
	}
	while(!st.empty()) st.pop();
	for(int i = n - 1; i >= 0; i--) {
		while(!st.empty() && arr[st.top()] >= arr[i]) 
			st.pop();
		if(st.empty())
			r[i] = n - 1;
		else
			r[i] = st.top() - 1;
		st.push(i);
	}
	for(int i = 0; i < n; i++) {
		//if(l[i] != -1 && r[i] != -1)
			ans += (i + 1 - l[i]) * (r[i] - i + 1) * arr[i];
	}
	cout << ans;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
char S[300005];
int suf[300005];
int main() {
	int N;
	scanf("%d%s", &N, S);
	for (int i = N - 1; i >= 0; --i) {
		suf[i] = suf[i + 1] + (S[i] == 'E');
	}
	int ans = INT_MAX, pre = 0;
	for (int i = 0; i < N; ++i) {
		ans = min(ans, pre + suf[i + 1]);
		pre += S[i] == 'W';
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
# 整数の入力
inputs = []
inputs.append(int(input()))
inputs.append(int(input()))
inputs.append(int(input()))
inputs.append(int(input()))
inputs.append(int(input()))
amari_list = []
time = 0
for input in inputs:
  amari = input % 10
  if amari == 0:
    time += input
  else:
    time += (input // 10) * 10
    amari_list.append(amari)
if len(amari_list) > 0:
  time += (len(amari_list) - 1)*10
  time += min(amari_list)
# 出力
print(time)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <list>
#include <algorithm>
using namespace std;
class person{
public:
	int crt;
	int next;
	bool ex;
	person(){ex=true;}
};
person p[200000];
int main()
{
	int n,m,q;cin>>n>>m>>q;
	for(int i=0;i<n;i++){
		p[i].crt=(i-1+n)%n;
		p[i].next=(i+1)%n;
		p[i].ex=true;
	}
	int owner=0;
	while(m--){
		int dim;cin>>dim;
		if(dim%2==0){
			for(int j=0;j<dim;j++)owner=p[owner].next;
		}else{
			for(int j=0;j<dim;j++)owner=p[owner].crt;
		}
		p[owner].ex=false;
		//printf("owner:%d\n",owner);
		p[p[owner].crt].next=p[owner].next;
		p[p[owner].next].crt=p[owner].crt;
		owner=p[owner].next;
	}
	while(q--){
		int num;cin>>num;
		cout<<p[num].ex<<endl;
	}
    return 0;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>

using namespace std;

set <long long int> sx,sy;
map <long long int,int> mx,my;
long long int compx[8005],compy[8005];
int n,m;
long long int a,b,c;
vector <pair<pair<long long int,long long int>,pair<long long int,long long int>>> l;
bool visited[8005][8005];
bool board[8005][8005];
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n >> m;

	for(int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		l.push_back(make_pair(make_pair(a,c),make_pair(b,c)));
		sy.insert(a);
		sy.insert(b);
		sx.insert(c);
	}
	for(int i=0;i<m;i++)
	{
		cin >> a >> b >> c;
		l.push_back(make_pair(make_pair(a,b),make_pair(a,c)));
		sy.insert(a);
		sx.insert(b);
		sx.insert(c);
	}
	sx.insert(0);
	sy.insert(0);
	sx.insert(-1e18);
	sx.insert(1e18);
	sy.insert(-1e18);
	sy.insert(1e18);

	int idxx = 0;
	int idxy = 0;

	for(auto it : sy)
	{
		my[it] = idxy;
		compy[idxy] = it;
		idxy+=2;
	}
	for(auto it : sx)
	{
		mx[it] = idxx;
		compx[idxx] = it;
		idxx+=2;
	}

	memset(board,true,sizeof(board));

	for(int i=0;i<l.size();i++)
	{
		int y1 = my[l[i].first.first];
		int x1 = mx[l[i].first.second];
		int y2 = my[l[i].second.first];
		int x2 = mx[l[i].second.second];

		if(y1==y2)
		{
			for(int j=x1;j<=x2;j++)
			{
				board[y1][j] = false;
			}
		}
		else
		{
			for(int j=y1;j<=y2;j++)
			{
				board[j][x1] = false;
			}
		}
	}

	memset(visited,false,sizeof(visited));
	queue <pair<int,int>> que;
	for(int ny=-1;ny<=1;ny+=2)
	{
		for(int nx=-1;nx<=1;nx+=2)
		{
			que.push(make_pair(my[0]+ny,mx[0]+nx));
			//cout << my[0]+ny << ' ' << mx[0] + nx << '\n';
			visited[my[0] + ny][mx[0] + nx] = true;
		}
	}

	while(!que.empty())
	{
		int y = que.front().first;
		int x = que.front().second;
		que.pop();
		//cout << y << ' ' << x << '\n';
		if(y<=0 || y>=idxy-2 || x<=0 || x>=idxx-2)
		{
			cout << "INF" << '\n';
			return 0;
		}

		for(int i=0;i<4;i++)
		{
			int ny = y + 2*dy[i];
			int nx = x + 2*dx[i];
			if(ny<0 || ny>=idxy || nx<0 || nx>=idxx)
			{
				continue;
			}
			int checky = (ny + y)/2;
			int checkx = (nx + x)/2;
			if(board[checky][checkx]==false)
			{
				continue;
			}
			if(visited[ny][nx]==false)
			{
				visited[ny][nx] = true;
				que.push(make_pair(ny,nx));
			}
		}
	}

	long long int res = 0;

	/*
	for(int y=0;y<idxy;y++)
	{
		for(int x=0;x<idxx;x++)
		{
			cout << board[y][x];
		}
		cout << '\n';
	}
	*/

	for(int y=1;y<idxy;y+=2)
	{
		for(int x=1;x<idxx;x+=2)
		{
			if(visited[y][x])
			{
				long long int dy = compy[y+1] - compy[y-1];
				long long int dx = compx[x+1] - compx[x-1];
				res += dy*dx;
			}
		}
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 129636
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int F[maxn];
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;
  string s;
  cin>>n>>s;
  int cnt=0;
  for(char c:s)cnt+=c=='1';
  vector<int64_t> A(n),B(n);
  A.back()=1%(cnt+1);
  if(cnt>1)B.back()=1%(cnt-1);
  for(int i=n-2;i>=0;--i){
    A[i]=A[i+1]*2%(cnt+1);
    if(cnt>1)B[i]=B[i+1]*2%(cnt-1);
  }
  int64_t sumA=0,sumB=0;
  for(int i=0;i<n;++i)if(s[i]=='1')sumA+=A[i],sumB+=B[i];
  F[0]=0;
  for(int i=1;i<maxn;++i){
    F[i]=F[i%__builtin_popcount(i)]+1;
  }
  for(int i=0;i<n;++i){
    if(s[i]=='1'){
      if(cnt==1){
        cout<<0<<'\n';continue;
      }
      cout<<F[(sumB-B[i])%(cnt-1)]+1<<'\n';
    }else{
      cout<<F[(sumA+A[i])%(cnt+1)]+1<<'\n';
    }
  }
  
  return 0;
}
//2020.07.11 20:17:40


Measured memory_bytes: 7532
#include <bits/stdc++.h>
using namespace std;
int main(){

  //input
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  
  //setup
  sort(A,A+N);
  reverse(A,A+N);
  
  long long Total=0;
  for(int i=0;i<N;i++){
    Total+=A[i/2];
  }
  Total-=A[0];
  
  //output
  cout << Total << endl;
  
}

Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int N, M, S = 0;
vector<long long> w;
using Graph = vector<vector<int> >;
Graph G;

void dfs(vector<int> vs, vector<long long> &dist) {
    for (auto v : vs) {
        for (auto nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + w[nv];
            dfs({nv}, dist);
        }
    }
}

long long solve() {
    vector<int> deg(N, 0);
    for (int v = 0; v < N; ++v) {
        for (auto nv : G[v]) {
            ++deg[v];
            ++deg[nv];
        }
    }
    for (int v = 0; v < N; ++v) deg[v] /= 2;

    queue<int> que;
    for (int v = 0; v < N; ++v) if (v != S && deg[v] == 1) que.push(v);

    vector<bool> fucked(N, false);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        fucked[v] = true;
        for (auto nv : G[v]) {
            --deg[nv];
            if (nv != S && deg[nv] == 1) que.push(nv);
        }
    }

    long long res = 0;
    vector<int> vs;
    vector<long long> dist(N, -1);
    for (int v = 0; v < N; ++v) if (!fucked[v]) {
            res += w[v];
            vs.push_back(v);
            dist[v] = 0;
        }

    dfs(vs, dist);
    long long ma = 0;
    for (int v = 0; v < N; ++v) ma = max(ma, dist[v]);
    return res + ma;
}


int main() {
    cin >> N >> M;
    w.resize(N);
    for (int i = 0; i < N; ++i) cin >> w[i];
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int u, v; cin >> u >> v; --u, --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    cout << solve() << endl;
}


Measured memory_bytes: 24264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

void solve(){
    int n;
    cin>>n;
    vector<int>x(n);
    vector<int>y(n);
    rep(i,n)cin>>x[i]>>y[i];
    double sum=0;
    rep(i,n){
      for(int j=i+1;j<n;j++){
        sum+=sqrt(pow((x[i]-x[j]),2.0)+pow((y[i]-y[j]),2.0));
      }
    }
cout<<(sum*2/n)<<endl;
}

int main(){
    cout<<std::fixed<<std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int N;
	cin >> N;

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

		//偶数
		if (A % 2 == 0) {
			if (A % 3 == 0 || A % 5 == 0) {
				//3または5で割り切れる
			}
			else {
				//上記以外
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

	cout << "APPROVED" << endl;

}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

const ll N = 56, MOD = 1e9 + 7;

vector < vector < ll > >   MUL (vector < vector < ll > > A, vector < vector < ll > > B){
    vector < vector < ll > > C;
    int n = (int)A.size();
    int m = (int)B.size();
    int k = (int)B[0].size();
    for (int i = 0; i < n; i++){
        vector < ll > v (k, 0);
        C.push_back (v);
    }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            for (int l = 0; l < k; l++)
                C[i][l] = (C[i][l] + A[i][j] * B[j][l]) % MOD;
    return C;
}

vector < vector < ll > > POWER (vector < vector < ll > > V, ll y){
    vector < vector < ll > > ans = V, c = V;
    y--;
    while (y){
        if ((y & 1) == 1)
            ans = MUL (ans, c);
        c = MUL (c, c);
        y /= 2;
    }
    return ans;
}

ll n, k;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    vector < vector < ll > > A, B, C;
    vector < ll > v (n, 1);
    A.pb (v);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++)
            cin>>v[j];
        B.pb (v);
    }
    C = MUL (A, POWER (B, k));
    ll ans = 0;
    for (int i = 0; i < n; i++)
        ans = (ans + C[0][i]) % MOD;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int k,x,i;
    vector <int> a;
    scanf("%d %d",&k,&x);
    a.push_back(x);
    for(i=1;i<k;i++)
    {
        if(x-i>=-1000000)
            a.push_back(x-i);
        if(x+i<=1000000)
            a.push_back(x+i);
    }
    sort(a.begin(),a.end());
    k=a.size();
    for(i=0;i<k;i++)
        printf("%d ",a[i]);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 45;
const int mod = 1e9 + 7; 
using namespace std;

int n, x, y, z, now, lim, f[N][(1 << 17) + 5], ans; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

void output(int x)
{
	int a[100], cnt = 0;
	while(x) a[cnt++] = x & 1, x >>= 1;
	if(!cnt) return (void) (puts("0")); 
	for(int i = cnt - 1; i >= 0; i--) printf("%d", a[i]);
	puts(""); 
}

int main()
{
	n = read <int> (), x = read <int> (), y = read <int> (), z = read <int> ();
	now = (1 << (x - 1 + y + z)) | (1 << (y - 1 + z)) | (1 << (z - 1)), lim = (1 << (x + y + z)) - 1; 
	f[0][0] = 1; 
	for(int tmp, i = 0; i < n; i++)
		for(int j = 0; j <= lim; j++)
			if(f[i][j])
			{
				for(int k = 1; k <= 10; k++)
				{
					tmp = ((j << k) | (1 << (k - 1))) & lim; 
					if((tmp & now) != now) f[i + 1][tmp] = (f[i + 1][tmp] + f[i][j]) % mod; 
				}
			}
	for(int j = 0; j <= lim; j++) if((j & now) != now) ans = (ans + f[n][j]) % mod; 
	printf("%d\n", (fpow(10, n) - ans + mod) % mod); 
	return 0; 
}


Measured memory_bytes: 21860
#include <bits/stdc++.h>
using namespace std;

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  VLL _a(n), _b(n);
  rep(i,n) cin >> _a[i];
  rep(i,n) cin >> _b[i];

  VLL a(n), b(n);
  ll ans = 0;
  // aを固定して考えたときに a[i] + b[j] の kbit 目が立っているbの条件を探し、
  // 条件を満たすbの数をカウント
  rep(k,30){
    ll T = 1LL<<k;

    rep(i,n) {
      a[i] = _a[i] % (2LL*T);
      b[i] = _b[i] % (2LL*T);
    }
    sort(all(b));
    ll cnt = 0;
    rep(i,n){
      // 条件1: 2^k <= ai + bj < 2^(k+1)
      //    ->  2^k - a[i] <= b[j] < 2^(k+1) - a[i]
      //    ->  T - a[i] <= b[j] < 2*T - a[i]
      cnt += lower_bound(all(b), 2LL*T - a[i]) - lower_bound(all(b), T - a[i]) ;
      // 条件2: 2^k + 2^(k+1) <= ai + bj < 2 * 2^(k+1)
      //    ->  2^k + 2^(k+1) - a[i] <= b[j] < 2 * 2^(k+1) - a[i]
      //    ->  3 * T - a[i] <= b[j] < 4 * T - a[i]
      cnt += lower_bound(all(b), 4LL*T - a[i]) - lower_bound(all(b), 3LL*T - a[i]) ;

    }
    if(cnt % 2 == 1) ans |= (1LL<<k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define w(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;

ll n,m;

ll mat[1005][1005];
ll vis[1005][1005];

ll dx[4] = {0,0,1,-1};
ll dy[4] = {1,-1,0,0};

string s;

bool valid(ll r, ll c){
	return (r>=0 && r<n && c>=0 && c<m);
}

int main(){
	fast();
	
	cin>>n>>m;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	--a;--b;--c;--d;
	for(ll i=0;i<n;i++){
		cin>>s;
		for(ll j=0;j<m;j++){
			mat[i][j] = (s[j]=='.');
		}
	}
	
	
	deque<pair<pair<ll, ll>, ll>> dq;
	dq.push_front(make_pair(make_pair(a,b),0));
	
	bool f = true;
	
	while(!dq.empty()){
		
		pair<pair<ll, ll> , ll> x = dq.front();
		dq.pop_front();
		
		pair<ll, ll> pos = x.first;
		
		if(vis[pos.first][pos.second]) continue;
		vis[pos.first][pos.second] = 1;
		
		if(pos.first==c && pos.second==d){
			cout<<x.second<<endl;
			f = false;
			break;
			
		}
		
		for(ll i=0;i<4;i++){
			
			ll xx = pos.first + dx[i];
			ll yy = pos.second + dy[i];
			
			if(valid(xx,yy) && mat[xx][yy] && !vis[xx][yy]){
				dq.push_front(make_pair(make_pair(xx,yy),x.second));
			}
			
		}
		for(ll i=-2;i<=2;i++){
			for(ll j=-2;j<=2;j++){
				ll xx = pos.first+i;
				ll yy = pos.second+j;
				
				if(valid(xx,yy) && mat[xx][yy] && !vis[xx][yy]){
					dq.push_back(make_pair(make_pair(xx,yy),x.second+1));
				}
			}
		}
	}
	if(f) cout<<-1<<endl;
	
	return 0;
}


Measured memory_bytes: 20704
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	im := IntMap{}

	for i := 0; i < n; i++ {
		s := getNextString(scanner)
		im.increment(int(s[0] - 'A'))
	}
	var ans int64

	head := [5]byte{'M', 'A', 'R', 'C', 'H'}

	for i := 0; i < 5; i++ {
		for ii := 0; ii < i; ii++ {
			for iii := 0; iii < ii; iii++ {
				ans += int64(im.get(int(head[i]-'A'))) * int64(im.get(int(head[ii]-'A'))) * int64(im.get(int(head[iii]-'A')))
			}
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}
func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]) {
    
    char a[2000000],b[2000000];
    int n=0;
    
    scanf("%s %s",a,b);
    
    
    for(int i=0;i<strlen(a);i++){
        if(a[i]!=b[i]){
            n=n+1;
        }
    }
    printf("%d",n);
    return 0;
}


Measured memory_bytes: 2556
#include <iostream>
#include <map>
using namespace std;

map<int, int> m;

void prime_factorize(int n) {
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            m[i]++;
            n /= i;
        }
    }
    if (n != 1) m[n]++;
}

int num_e(int n) {
    int res = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        pair<int, int> p = *it;
        if (p.second >= n - 1) res++;
    }
    return res;
}

int main() {
    int N;
    cin >> N;

    for (int i = 2; i <= N; i++)
        prime_factorize(i);

    int res = num_e(75) + (num_e(25) * (num_e(3) - 1)) + (num_e(15) * (num_e(5) - 1))
            + (num_e(5) * (num_e(5) - 1) * (num_e(3) - 2)) / 2;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int mxN = 103;
const int mxK = 1e5 + 5;
const ll mo = 1e9 + 7;

int n, k;
int dp[mxK], val[mxK];
int a[mxN];

int add(int x, int y) {
    while (x+y<0)
        y+=mo;
    return (1ll * (x + y)) % mo;
}

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

    cin >> n >> k;

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

    val[0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            dp[j] = 0;
        }
        for (int j = 0; j <= k; j++) {
            dp[j] = add(dp[j], val[j]);
            if (j + a[i] + 1 <= k) {
                dp[j + a[i] + 1] = add(dp[j + a[i] + 1], -val[j]);
            }
        }
        for (int j = 1; j <= k; j++) {
            val[j] = add(val[j - 1], dp[j]);
        }
        //for (int j = 0; j <= k; j++) { cout << val[j] << ' '; } cout << endl;
    }


    cout << val[k] << endl;
}


Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

// Solution
public class Main {
  private static Scanner in;
  private static PrintWriter out;
  private static final String INPUT = ""; // input file name

  /**
   * Interactive get next command
   */
  static int get(int pos) {
    out.println(pos + 1);
    out.flush();
    return ni();
  }

  static void solve() {
    int a = ni();

    out.println(a + a * a + a * a * a);
  }

  static String convert(int x) {
    char[] z = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();

    StringBuilder sb = new StringBuilder();

    while (x > 0) {
      if (x % 26 == 0) {
        x = x / 26 - 1;
        sb.append('Z');
      } else {
        sb.append(z[x % 26 - 1]);
        x = x / 26;
      }
    }

    return sb.reverse().toString();
  }

  static int sconvert(String s) {
    int ans = 0;

    for (char c: s.toCharArray()) {
      int t = c - 'A' + 1;
      ans = ans * 26 + t;
    }

    return ans;
  }

  public static void main(String[] args) throws Exception {
    long S = System.currentTimeMillis();
    in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
    out = new PrintWriter(System.out);

    solve();
    out.flush();
    long G = System.currentTimeMillis();
    tr(G - S + "ms");
  }

  private static int gcd(int a, int b) {
    while (b != 0) {
      int t = b;
      b = a % b;
      a = t;
    }

    return a;
  }

  private static int ni() {
    return in.nextInt();
  }

  private static String nt() {
    return in.next();
  }

  private static String ns() {
    return in.nextLine();
  }

  private static long nl() {
    return in.nextLong();
  }

  // Math Utils
  private static int pi(int num, int pow) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static int pim(int num, int pow, int mod) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  private static long pl(long num, long pow) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static long plm(long num, long pow, long mod) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  static void tr(Object... o) {
    if (!INPUT.isEmpty())
      out.println(Arrays.deepToString(o));
  }

  private static void fo(int begin, int end, Callback call) {
    for (int i = begin; i < end; i++) {
      call.call(i);
    }
  }

  @FunctionalInterface
  private interface Callback {
    void call(int index);
  }
}


Measured memory_bytes: 38728
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int a,n,low,ans;
  cin>>n;
  cin>>low>>a;
  ans=a-low;
  if(a<low) low=a;
  for (int i = 2; i < n; ++i)
  {
    cin>>a;
    if(a>=low) ans=(a-low>ans)? a-low:ans;
    else low=a;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3120
def gi; gets.to_i end
def gs; gets.chomp end
def gli; gets.split(' ').map(&:to_i) end
def d(n); Math.log10(n).to_i + 1 end
class Integer
  # 約数の組み合わせを列挙する
  def divisor_combinations
    (1..Math.sqrt(self).to_i).
      select { |i| self % i == 0 }.
      map { |i| [i, self / i] }
  end
end

N = gi
L_N  = gli.sort

res = 0
N.times do |i|
  j = i - 1
  k = 0
  while k < j
    if L_N[k] + L_N[j] > L_N[i]
      res += j - k
      j -= 1
    else
      k += 1
    end
  end
end
puts res


Measured memory_bytes: 1912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int a,b;
	cin>>a>>b;
	int out=b;
	rep(i,a-1)out*=(b-1);
	cout<<out<<endl;
}







Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(A>100||B>100||C>100||A<-100||B<-100||C<-100)
        return 0;
    else
    {
        if(A<=C&&B>=C)
            printf("Yes");
        else
            printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];

    sort(s.begin(), s.end());

    cout << unique(s.begin(), s.end()) - s.begin() << endl;
}


Measured memory_bytes: 9560
#include<bits/stdc++.h>
using namespace std;

void solve() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << min(a, k) - max(0, k - a - b) << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int N,K;
vector<int>posi,nega,nega2;
int zero;
signed main() {
	cin>>N>>K;
	rep(i,N){
		int a;cin>>a;
		if(a>0)posi.push_back(a);
		else if(a<0){
			nega.push_back(a);
			nega2.push_back(-a);
		}
		else zero++;
	}
	sort(all(posi));
	sort(all(nega));
	sort(all(nega2));
	int ok=-inf,ng=inf;
	while(ng-ok>1){
		int mid=(ok+ng)/2;
		if(mid>0){
			int cnt=posi.size()*nega.size()+zero*(N-zero)+zero*(zero-1)/2;
			rep(i,posi.size()){
				cnt+=lower_bound(posi.begin(),posi.begin()+i,(mid+posi[i]-1)/posi[i])-posi.begin();
			}
			rep(i,nega2.size()){
				cnt+=lower_bound(nega2.begin(),nega2.begin()+i,(mid+nega2[i]-1)/nega2[i])-nega2.begin();
			}
			if(cnt<K)ok=mid;
			else ng=mid;
		}else {
			int cnt=0;
			rep(i,nega.size()){
				cnt+=posi.size()-(upper_bound(all(posi),mid/nega[i])-posi.begin());
			}
			if(cnt<K)ok=mid;
			else ng=mid;
		}
	}
	cout<<ok<<endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define N 505

int n, X;
int L[N];
int dp[2][N][N];

const int mod = 1e9 + 7;

void add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}
int mul(int x, int y) {return 1ll * x * y % mod;}

int main() {
	cin >> n >> X;
    for (int i = 1; i <= n; i ++) cin >> L[i];
    sort(L+1, L+n+1, greater <int> ());
    int u = 0, v = 1;
    dp[u][L[1]][1] = 1;
    for (int i = 2; i <= n; i ++) {
        int l = L[i];
        int mx = X / L[i-1];
        memset(dp[v], 0, sizeof dp[v]);
        for (int len = 1; len <= X; len ++) {
            for (int k = 1; k <= mx; k ++) if (dp[u][len][k]) {
                if (len + l <= X) add(dp[v][len+l][k+1], mul(dp[u][len][k], k+1));
                add(dp[v][len][k], mul(len-k*(l-1), dp[u][len][k]));
                for (int t = 1; t < l; t ++) if (len + t <= X) add(dp[v][len+t][k], mul(2*k, dp[u][len][k]));
                for (int t = 0; t < l-1; t ++) if (len + t <= X) add(dp[v][len+t][k-1], mul((k-1)*(l-t-1), dp[u][len][k]));
            }
        }
        swap(u, v);
    }
    int ans = 0;
    for (int i = 1; i <= n; i ++) add(ans, dp[u][X][i]);
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


long int gcd(long int a, long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);
  if(b-a+1<k*2){
    for(int i=a;i<b+1;i++){
      printf("%d\n",i);
    }
  }else{
    for(int i=a;i<a+k;i++){
      printf("%d\n",i);
    }
    for(int i=b-k+1;i<b+1;i++){
      printf("%d\n",i);
    }
  }
  return 0;
}

Measured memory_bytes: 1664
from itertools import permutations


def calc_distance(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


n = int(input())
xy_array = [[int(x) for x in input().split()] for y in range(n)]
p = permutations([x for x in range(n)])

sum_distance = 0
for order in p:
    for index in range(n - 1):
        x1 = xy_array[order[index]][0]
        x2 = xy_array[order[index + 1]][0]
        y1 = xy_array[order[index]][1]
        y2 = xy_array[order[index + 1]][1]
        sum_distance += calc_distance(x1, y1, x2, y2)
tmp = 1
for i in range(2, n + 1):
    tmp *= i
print(sum_distance / tmp)


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    S = input()
    print(Yes if S[2]==S[3] and S[4]==S[5] else No)


main()







Measured memory_bytes: 5676
#include <stdio.h>
int main(void)
{
  char s[1001];
  int i;
  scanf("%s", s);
  while(s[i]!=0){
    i++;
  }
  if(s[i-1]=='s'){
    s[i]='e';
    s[i+1]='s';
    s[i+2]='\0';
  }else{
    s[i]='s';
    s[i+1]='\0';
  }
  printf("%s", s);
  return 0;
}


Measured memory_bytes: 1736
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;

struct City {
    int p;
    int x;
    int ord;
};

bool jisyo(const City &lhs, const City &rhs) {
        if (lhs.p != rhs.p) {
            return lhs.p < rhs.p;
        }  else {   
            return lhs.x < rhs.x;
        }
}

bool order(const City &lhs, const City &rhs) {
    return lhs.ord < rhs.ord;
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<City> c(m);

    for(int i=0; i<m; i++) {
        int k,l;
        scanf("%d %d", &k, &l);
        c[i].p = k;
        c[i].x = l;
        c[i].ord = i;

    }
    sort(c.begin(),c.end(), jisyo);

    int pi = -1, ind=1;
    for (int i=0; i<m; i++) {
        if(pi != c[i].p) {
            pi = c[i].p;
            ind = 1;
        }
        c[i].x = ind;
        ind++;
        //printf("p: %d, x: %d\n", c[i].p, c[i].x);
    }

    sort(c.begin(), c.end(), order);

    for(int i=0; i<m; i++) {
        printf("%06d%06d\n", c[i].p, c[i].x);
    }
    return 0;
}

Measured memory_bytes: 2688
package main

import (
	"fmt"
	"sort"
)

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func main() {
	n := nextInt()
	dic := map[int]struct{}{}
	var fst, snd int

	for range make([]struct{}, n) {
		a := nextInt()
		if _, in := dic[a]; !in {
			dic[a] = struct{}{}
		} else {
			delete(dic, a)
			arr := []int{a, snd, fst}
			sort.Ints(arr)
			fst = arr[2]
			snd = arr[1]
		}
	}
	fmt.Println(fst * snd)
}


Measured memory_bytes: 6784
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <utility>
#include <string>

using namespace std;

typedef long long int ll; 
typedef pair<int,int> Pii;

Pii solve(vector<int> F,vector<int> S,int tmp){
    int minA=1000000;
    Pii minP=make_pair(-1,-1);
    for(int atF = 0 ; atF<F.size(); atF++){
      for(int atS = 0; atS<S.size(); atS++){
        if(F[atF]-S[atS]==tmp){
          if(minA>(F[atF]+S[atS]))
            return make_pair(F[atF],S[atS]);
        }
        if(F[atF]<S[atS])break;
      }
    }

  return minP;
}
 

int main(){
    int n,m,tmp;
    vector<Pii> ans;
    vector<int> taro;
    int tSum;
    vector<int> hanako;
    int hSum;
    while(1){
      cin>>n>>m;
      if(n==0&&m==0)break;
      // 初期化
      taro.clear();hanako.clear();
      tSum=0;hSum=0;
      // 入力
      for(int i=0;i<n;i++){
        cin>>tmp;
        taro.push_back(tmp);
        tSum+=tmp;
      }
      for(int i=0;i<m;i++){
        cin>>tmp;
        hanako.push_back(tmp);
        hSum+=tmp;
      }
      tmp=tSum-hSum;
      if(abs(tmp)%2==1){
        cout<<(-1)<<endl;
        continue;
      }
      sort(taro.begin(),taro.end());
      sort(hanako.begin(),hanako.end());
      tmp/=2;
      // tarouが多く渡す．
      if(tmp>0){
        Pii ans = solve(taro,hanako,tmp);
        if(ans.first==-1)cout<<-1<<endl;
        else{
          cout << ans.first << " " << ans.second<<endl;
        }
      }
      // hanakoが多く渡す．
      else if(tmp<=0){
        Pii ans = solve(hanako,taro,-tmp);
        if(ans.first==-1)cout<<-1<<endl;
        else{
          cout << ans.second << " " << ans.first<<endl; 
        }
      }
    }

    return 0;
}


Measured memory_bytes: 3120
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jenish
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGoToSchool solver = new CGoToSchool();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGoToSchool {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int arr[][] = new int[n][2];
            for (int i = 0; i < n; i++) {
                arr[i][0] = in.scanInt();
                arr[i][1] = i + 1;
            }


            Arrays.sort(arr, new Comparator<int[]>() {

                public int compare(int[] o1, int[] o2) {
                    return o1[0] - o2[0];
                }
            });


            for (int i = 0; i < n; i++) out.print(arr[i][1] + " ");

        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 47312
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(sa: String, sb: String, sc: String);
    let mut a: Vec<char> = sa.chars().collect();
    let mut b: Vec<char> = sb.chars().collect();
    let mut c: Vec<char> = sc.chars().collect();

    let mut buff = a[0];
    a.remove(0);
    loop {
        if buff == 'a' {
            if a.len() == 0 {
                println!("{}", "A");
                break;
            }
            buff = a[0];

            a.remove(0);
        } else if buff == 'b' {
            if b.len() == 0 {
                println!("{}", "B");
                break;
            }
            buff = b[0];

            b.remove(0);
        } else if buff == 'c' {
            if c.len() == 0 {
                println!("{}", "C");
                break;
            }
            buff = c[0];

            c.remove(0);
        }
    }
}


Measured memory_bytes: 2140
#include<iostream>
#include<cstdio>
#include<set>

std::multiset<int> s;
int N, curr;

int main()
{
    std::cin>>N;
    for (int i = 0; i < N; ++i)
    {
        scanf("%d", &curr);
        s.insert(curr);
        auto it = s.lower_bound(curr);
        if (++it != s.end())
            s.erase(it);
    }
    std::cout<<s.size()<<"\n";
}

Measured memory_bytes: 5916
#include <iostream>
using namespace std;

int main(){
  string s[3];
  cin >> s[0];
  cin >> s[1];
  cin >> s[2];

  unsigned int sc[3];
  sc[0] = 0;
  sc[1] = 0;
  sc[2] = 0;

  int idx = 0;

  unsigned int len[3];
  len[0] = s[0].length();
  len[1] = s[1].length();
  len[2] = s[2].length();

  while(sc[idx] < len[idx]){
    int next_idx = s[idx][sc[idx]] - 'a';
    sc[idx]++;
    idx = next_idx;
  }

  string c;
  switch(idx){
  case 0:
    c = "A";
    break;
  case 1:
    c = "B";
    break;
  case 2:
    c = "C";
    break;
  default:
    c = "unkown";
    break;
  }

  std::cout << c << std::endl;
}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
con = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    con[A-1].append(B-1)
    con[B-1].append(A-1)
    
d = deque()
houmon = [False] * N
ans = [0] * (N-1)

houmon[0] = True
d.append(0)
while d:
#     print(d, houmon, ans)
    room = d.popleft()
#     houmon[room] = True
#     print(room)
    
    for next_room in con[room]:
        if not houmon[next_room]:
            ans[next_room-1] = room+1
            d.append(next_room)
            houmon[next_room] = True
    
print('Yes\n' + '\n'.join(map(str, ans)))


Measured memory_bytes: 100728
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	VI a(N);
	REP(i,N) cin >> a[i];

	int idx = 1;
	int ans = 1;
	REP(i,N-1){
		idx = a[idx-1];
		if(idx == 2){
			cout <<  ans << endl;
			return 0;
		}
		ans++;
	}

			cout << -1 << endl;
	return 0;

}


Measured memory_bytes: 640
using static System.Math;
using System.Collections.Generic;
using System;

public class P
{
    public int id { get; set; }
    public long a { get; set; }
}

public class hello
{
    public static int s, e, n;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
         s = int.Parse(line[0]);
         e = int.Parse(line[1]);
         n = int.Parse(line[2]);
        var ps = new List<P>();
        line = Console.ReadLine().Trim().Split(' ');
        var a = 0L;
        for (int i = 0; i < n; i++)
        {
            a+= long.Parse(line[i]);
            if (a < 0) ps.Add(new P { id = i, a = a });
            if (s + a <= e) { Console.WriteLine( i + 1); goto exit; }
        }
        if (a >= 0) { Console.WriteLine(-1); goto exit; }
        getAns(ps, -a);
    exit:;
    }
    static void getAns (List<P> ps , long a)
    {
        var res = long.MaxValue;
        foreach (var x in ps)
        {
            var w = s + x.a;
            var w2 = (w - e + a -1) / a;
            var t = w2 * n + x.id + 1;
            res = Min(res,  t);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 28220
#include "math.h"
#include<stdio.h>
#include<map>
#include<string>
#include<iostream>
#include<vector>

using namespace std;

int main(void){
    int a,b,c,d,e,k;
    int ant[4];

    cin>>ant[0];
    cin>>ant[1];
    cin>>ant[2];
    cin>>ant[3];
    cin>>ant[4];
    cin>>k;

   if(abs(ant[4]-ant[0]) > k){
                cout<<":("<<endl;
                return 0;
    }
    
    cout<<"Yay!"<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
	vector<long long> v( 5 );
	long long ans = 0;
	long long n;
	cin >> n;
	for( int i = 0; i < 5; i++ )
	{
		cin >> v[i];
	}
	
	sort( v.begin(), v.end() );


	ans = 4 + n / v[0] + (n%v[0] != 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256