akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define forj(j,n) for(int j=n; j>=0; j--)
#define forx(x,v) for(auto &x:v)
#define sz(v) (int)(v).size()
#define rz(n) resize(n)
#define vec(x) vector < x >
using int64 = long long;
using vi = vector < int >;
using vi64 = vector < int64 >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
const string yo = "Yes\n", no = "No\n";


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d) cout<<yo;
	else cout<<no;






	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

mat G(1000010,vec(0));
vec memo(1000010,-1);
vector<bool> visited(1000010, false);
ll dfs(ll to){
    if(visited[to]) return -1;
    if(memo[to] != -1) return memo[to];
    visited[to] = true;
    ll ans = 0;
    for(ll next : G[to]){
        ll temp = dfs(next);
        if(temp == -1) return -1;
        ans = max(ans, temp + 1);
    }
    visited[to] = false;
    memo[to] = ans;
    return ans;
}

int main(){
    cin>>N;
    ll last;
    rep(i,N){
        rep(j,N-1){
            ll I = i;
            cin>>A;
            --A;
            if(I > A) swap(I, A);
            if(j > 0) G[last].push_back(I*N + A);
            last = I*N + A;
        }
    }
    ll ans = 0;
    rep(i, N*N){
        ll temp = dfs(i);
        if(temp == -1){
            cout<<-1<<endl;
            return 0;
        }else{
            ans = max(ans, temp);
        }
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 47360
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,k,n) for(i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
ll arr[405],prefs[405];
ll dp[405][405];
ll suminrange(ll l,ll r){
    if(l==0) return prefs[r];
    return prefs[r]-prefs[l-1];
}
ll findAns(ll l,ll r){
    if(l==r) return 0;
    if(dp[l][r]>=0) return dp[l][r];
    ll i,ans=LLONG_MAX;
    for(i=l;i<r;i++){
        ll myans = suminrange(l,i) + suminrange(i+1,r) + findAns(l,i) + findAns(i+1,r);
        ans = min(ans,myans);
    }
    return dp[l][r]=ans;
}
void solve(ll caseno){
	ll i,j,n,ans;
    cin>>n;
    mset(dp,-1);
    for(i=0;i<n;i++) cin>>arr[i];
    prefs[0]=arr[0];
    for(i=1;i<n;i++) prefs[i]=arr[i]+prefs[i-1];
    ans = findAns(0,n-1);
    cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 4924
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String strO = br.readLine();
        String strE = br.readLine();
        String strALL = "";
        int i = 0;
        for(i=0;i<strE.length();i++){
            strALL += strO.substring(i,i+1)+strE.substring(i,i+1);
        }

        if(strO.length()-strE.length() > 0)strALL += strO.substring(i,i+1);
        System.out.println(strALL);
    }
}

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

#define BUFF_SIZE 1024
char buffer[1024 * 1024];
int pos = 0;
int end = 0;

int mygetchar(){
  if(pos == end){
    int i;
    end = read(0, buffer, sizeof(buffer));
    pos = 0;
  }
  return buffer[pos++];
}

int getInt(){
  int ret = 0, c;
  c = mygetchar();
  while(!isdigit(c)) c = mygetchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = mygetchar();
  }
  return ret;
}

#define mask (0x7F)
int cnt[mask];

int main(){
  int n, i;
  while(n = getInt()){
    const int n2 = n / 2;
    memset(cnt, 0, sizeof(cnt));

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

      if(++cnt[a & mask] > n2){
	printf("%d\n", a);
	for(++i; i < n; i++)
	  getInt();
	goto end;
      }

    }

    puts("NO COLOR");

  end:;
  }
  return 0;
}

Measured memory_bytes: 1384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,h;
	scanf("%d%d",&n,&h);
	int maxv=0;
	int a[n+5],b[n+5];
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		maxv=max(a[i],maxv);
	}
	sort(b+1,b+n+1);
	int sum=0,s=0;
	for(int i=n;i>=1;i--){
		if(sum>=h){
			printf("%d\n",s);
			return 0;
		}
		if(b[i]<maxv)
			break;
		sum+=b[i];
		s++;
	}
	if(sum>=h){
		printf("%d\n",s);
		return 0;
	}
	if((h-sum)%maxv==0)
		s+=(h-sum)/maxv;
	else
		s+=(h-sum)/maxv+1;
	printf("%d\n",s);
	return 0;
}

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

using namespace std;

int main(){
	int N;
	cin>>N;
    vector <long long>a(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
    }
	long long sum=0;
	long long s=0;
	while(1){
		for(int i=0 ; i<N ; i++){
			s=(long long)(a[i]/N);
			a[i]=a[i]%N;
			sum+=s;
			if(s==0)continue;
			for(int j=0 ; j<N ; j++){
				if(i==j)continue;
				a[j]+=s;
			}
		}
		sort(a.begin(),a.end());
		if(a[N-1]<N)break;
	}
	cout<<sum<<"\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second  
#define endl '\n'
#define pb push_back
#define t_case ll tt; cin>>tt; while (tt--)
#define all(v) v.begin(),v.end()
#define ub(a,x) upper_bound(all(a),x)-a.begin()
#define lb(a,x) lower_bound(all(a),x)-a.begin()
#define fr(a,b,c) for (ll a=b;a<c;a++)
#define take(xx,n) for (int i=0;i<n;i++) cin>>xx[i];
#define take1(xx,n) for (int i=1;i<=n;i++) cin>>xx[i];
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
int main() 
{
	fastio
	//t_case
	{
		ll sum=0,ans=0,f=1,n,m,k,x,y,z;
		ld a,b,c  ;
		cin>>a>>b>>c>>k;
		if (ceil(b/a)<=1){
			fr(i,0,7) {
				b*=2; sum++;
				if (ceil(b/a)==2){
				 	break;
				 }
			}
		}
		if (ceil(c/b)<=1){
			fr(i,0,7) {
				c*=2; sum++;
				if (ceil(c/b)==2){
				 	break;
				 }
			}
		}
		if (sum<=k) cout<<"Yes";
		else cout<<"No";
		cout<<endl;
	}
	return 0;
}
 

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll n, m;
  cin >> n >> m;
  map<int, ll> mp;
  rep(i, n){
    int a;
    cin >> a;
    mp[a]++;
  }
  rep(i, m){
    int b, c;
    cin >> b >> c;
    mp[c] += b;
  }
  ll ans = 0;
  rrepit(ritr, mp){
    n -= ritr->second;
    ans += (ll)ritr->first * ritr->second;
    // cerr << ritr->first << " " << ritr->second << " " << n << endl;
    if(n <= 0){
      ans += (ll)ritr->first * n;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');

  (function(x) {
    // ????????????????????????
    console.log(Math.pow(x, 3));

  })(parseInt(inputs[0], 10)); // ??°?????????

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15796
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a*b%2==0){
            System.out.println("Even");
        }
        else{
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
string n;
int main() {
    cin >> n;
    for (int i = 1; i < n.length() - 1; ++i) {
        if (n[i - 1] == n[i] && n[i + 1] == n[i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

class edge {
public:
	int s, e;
	ll f;
	edge() {
		*this = edge(0, 0, 0);
	}
	edge(int s, int e, ll f) : s(s), e(e), f(f) {}
};
vector <edge> Ve;
vector <int> fconn[100050];
void epush(int s, int e, ll f) {
	fconn[s].push_back(Ve.size());
	fconn[e].push_back(Ve.size() + 1);
	Ve.emplace_back(s, e, f);
	Ve.emplace_back(e, s, 0);
}
ll dchk[100050];
ll DFS(int n, int snk, ll C, ll F) {
	if (n == snk) return F;
	dchk[n] = C;
	for (auto it : fconn[n]) {
		edge& ed = Ve[it];
		if (ed.f == 0 || dchk[ed.e] == C) continue;
		ll t;
		if (t = DFS(ed.e, snk, C, min(F, ed.f))) {
			ed.f -= t;
			Ve[it ^ 1].f += t;
			return t;
		}
	}
	return 0;
}
void init(int snk) {
	int i;
	for (i = 0; i <= snk; i++) {
		fconn[i].clear();
		dchk[i] = false;
	}
	Ve.clear();
}

char in[105][105];
int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	
	int sx, sy, ex, ey;
	for (i = 0; i < N; i++) {
		scanf("%s", in[i]);
		for (j = 0; j < M; j++) {
			if (in[i][j] == 'S') sx = i, sy = j;
			if (in[i][j] == 'T') ex = i, ey = j;
			if (in[i][j] == 'o') {
				epush(i, j + N, 1);
				epush(j + N, i, 1);
			}
		}
	}

	int src = N + M, snk = N + M + 1;
	epush(src, sx, INF);
	epush(src, sy + N, INF);
	epush(ex, snk, INF);
	epush(ey + N, snk, INF);

	ll f = 0, t;
	while (t = DFS(src, snk, f + 1, INF)) f += t;
	if (f >= INF) f = -1;
	return !printf("%lld\n", f);
}
//*/

Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

#define mod 1000000007
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    cin >> a;
    ll ans = 0;
    ll x = 100;
    while(1){
        x*=1.01;
        ans++;
        if(x>=a) break;
    }
    cout << ans;
    return 0;
}

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

int main(void){
 
    int N;
    string s;
    cin >> N;
    map<string,int> mp{};
    
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    
    for(int i=0;i<N;i++){
        cin >> s;
        mp[s] += 1;
    }
    
    cout << "AC" << " x " << mp["AC"] << endl;
    cout << "WA" << " x " << mp["WA"] << endl;
    cout << "TLE" << " x " << mp["TLE"] << endl;
    cout << "RE" << " x " << mp["RE"] << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<long> t,p;
long getans(int n, long x){
  if(x == 1){
    if(n == 0) return 1;
    else return 0;
  }else if(x <= 1 + t[n - 1]){
    return getans(n - 1, x - 1);
  }else if(x == 2 + t[n - 1]){
    return p[n - 1] + 1;
  }else if(x < 3 + 2 * t[n - 1]){
    return p[n - 1] + 1 + getans(n - 1, x - (2 + t[n - 1]));
  }else{
    return p[n - 1] * 2 + 1;
  }
}
  
int main(){
  long N, X;  
  cin >> N >> X;

  t.push_back(1);
  p.push_back(1);
  for(int i = 1; i < N; ++i){
    t.push_back(t[i - 1] * 2 + 3);
    p.push_back(p[i - 1] * 2 + 1);
  }
  
  cout << getans(N, X) << endl;
  
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vpii = vector<pii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { if (a > b) { a = b; return true; } else return false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { if (a < b) { a = b; return true; } else return false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  vb t(10001);
  t[0] = true;
  rep(i, n) {
    int s;
    cin >> s;
    for (int j = 10000; j >= s; j--) t[j] = t[j] || t[j - s];
  }
  for (int i = 10000; i >= 0; i--) {
    if (t[i] && i % 10 != 0) {
      cout << i << endl;
      return;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

set<int>ng={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};

signed main()
{
	IOS();
	vector<int>ans;
	int loop = 1;
	while(loop--){
		int N;cin >> N;
		if(!N)break;
		int cnt = 0,mi = 0;
		rep(i,0,N){
			string s;
			cin>>s;
			if(s=="A")cnt++;
			else cnt--;
			chmin(mi,cnt);
		}
		ans.push_back(cnt == 0&&mi == 0);
	}
	for(auto e:ans){
		if(e)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}



Measured memory_bytes: 3204
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
using namespace std;

const int maxn=12;

int MX[maxn][maxn][maxn][maxn];
//from (i,j) to (j,k)
int mnl[maxn][maxn][maxn];
//from (i,j) up k
int mnh[maxn][maxn][maxn];
//front(i,j) right k
int sum[maxn][maxn],mx[maxn][maxn];

inline int getmin(int i,int j,int a,int b)
{
	int t=min(mnh[i][j][b-j],mnh[a][j][b-j]);
	int t2=min(mnl[a][j][a-i],mnl[a][b][a-i]);
	return min(t,t2);
}

inline int getsum(int i,int j,int a,int b)
{
	return sum[a][b]-sum[i-1][b]-sum[a][j-1]+sum[i-1][j-1];
}

int main()
{
	
	int n,m;;
	while(1)
	{
		cin>>n>>m;
		if(!n) break;
		
		rep(i,1,n) rep(j,1,m) {
			cin>>mx[i][j];	
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+mx[i][j];
		}
		
		rep(i,1,n) rep(j,1,m){
			mnl[i][j][0]=mx[i][j];
			rep(k,1,i-1) mnl[i][j][k]=min(mnl[i][j][k-1],mx[i-k][j]);
		}
		
		rep(i,1,n) rep(j,1,m){
			mnh[i][j][0]=mx[i][j];
			for(int k=1;j+k<=m;++k) mnh[i][j][k]=min(mnh[i][j][k-1],mx[i][j+k]);
		}
		
		rep(i,1,n) rep(j,1,m){
			MX[i][j][i][j]=mx[i][j];
			rep(a,i+1,n) MX[i][j][a][j]=max(MX[i][j][a-1][j],mx[a][j]);
			rep(a,j+1,m) MX[i][j][i][a]=max(MX[i][j][i][a-1],mx[i][a]);
			rep(a,i+1,n) rep(b,j+1,m) MX[i][j][a][b]=max(max(MX[i][j][a-1][b],MX[i][j][a][b-1]),mx[a][b]);
		}
		
		int ans=0;
		rep(i,1,n) rep(j,1,m)//zuoshang
		{
			rep(a,i+2,n) rep(b,j+2,m)//youxia
			{
				int Min=getmin(i,j,a,b);
				if(Min <= MX[i+1][j+1][a-1][b-1]) continue;
				ans=max(ans,Min*((a-i-1)*(b-j-1))-getsum(i+1,j+1,a-1,b-1));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}



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

int main(){
  int x,y,w,h;
  int t,n;
  cin >> t;
  while( t-- ){
    cin >> x>>y>>w>>h;
    cin >> n;

    w+=x; h+=y;
    int ans=0, a,b;
    for( int i=0;i<n;i++ ){
      cin >> a >> b;
      if( a>=x && a<=w && b>=y && b<=h )
	ans++;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P=pair<int,int>;

const int nm = 1e5;
int n, a, b;
ll ans = 0;
vector<P> v;
int main() {

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		v.emplace_back(a, b);
	}

	sort(v.begin(), v.end(), [](auto &x, auto &y) {
		return x.first + x.second > y.first + y.second;
	}
	);

	for (int i = 0; i < n; ++i)
		if (!(i & 1))
			ans += v[i].first;
		else
			ans -= v[i].second;

	cout << ans << endl;
}


Measured memory_bytes: 4296
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) ); 
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n; cin >> n;

  int d=1;
  vector<vector<int>> lr(10, vector<int>(10,0));
  bool isend = false;
  rep(i,6){
    repz(l,1,10){
      repz(k,l*d,(l+1)*d){
        if(k>n){
          isend = true;
          break;
        }
        int r = k%10;
        lr[l][r]++;
      }
      if(isend) break;
    }
    if(isend) break;
    d*=10;
  }

  ll res=0;
  rep(r,10){
    rep(l,10){
      res+=lr[r][l]*lr[l][r];
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    AB = [[int(x) for x in input().split()] for _ in range(M)]

    A = [[] for j in range(N + 1)]
    ans = [0] * (N + 1)

    for a, b in AB:
        A[a].append(b)
        A[b].append(a)

    q = collections.deque()
    v = set()

    q.append(1)
    v.add(1)
    while q:
        c = q.popleft()

        for n in A[c]:
            if n not in v:
                v.add(n)
                q.append(n)
                ans[n] = c

    print("Yes")
    for i in range(2, N + 1):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 60628
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {

	ll n, t;
	ll s = 0;

	cin >> n;
	t = n;

	while (t > 10) {
		s += t % 10;
		t /= 10;
	}
	s += t;

	if (n % s == 0) {
		cout << "Yes" NL;
	} else {
		cout << "No" NL;
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long x,cnt=0,ans,ccnt;
  cin>>x;
  ans=(x/11)*2;
  ccnt=x%11;
  while(ccnt>0){
    ccnt=ccnt-6;
    cnt++;
    if(ccnt<=0) break;
    ccnt=ccnt-5;
    cnt++;
    if(ccnt<=0) break;
  }
  cout<<cnt+ans<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <numeric>
#include <stack>
#include <cmath>
#include <queue>
#include <functional>
#include <complex>
#include <cstring>
#include <stdlib.h>
using namespace std;
#define endl '\n'
// #define exp 2.7182818284590452353602874713527
// #define pi acos(-1)
// typedef complex<double> comp;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
void solve()
{
	int k;
	cin >> k;
	int mi = 2, ma = 2;
	vector<int> a(k);
	for(auto &i : a)
		cin >> i;
	for(int i = k-1;i >= 0;i--)
	{
		if(mi > (ma/a[i])*a[i])
		{
			cout << -1;
			return;
		}
		mi = a[i]*((int)(ceill(((long double)mi)/a[i])));
		ma = a[i]*(ma/a[i]) + a[i]-1;
	}
	cout << mi << ' ' << ma;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double t1 = clock();
    int t;
    t = 1;
    // scanf("%d", &t);
    // cin >> t;
    // while(t--)
    for(int i = 1;i <= t;i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
    cerr << setprecision(10) << (clock()-t1)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){
	int N, M;
	cin >> N >> M;
	cout << M + (M==100 ? 1 : 0);
	rep(N, i)
	{
		cout << "00";
	}
	cout << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from itertools import permutations

def main():
    t,x = map(int,input().split())
    print(t/x)
if __name__=='__main__':
    main() 

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

int k,x,y,nowx,nowy;

struct r2{int x,y;};
vector<r2> ans;

void move(int x,int y){
  nowx+=x;nowy+=y;
  ans.push_back({nowx,nowy});
}

int main(){
  cin>>k>>x>>y;

  if(!(k&1)&&((x+y)&1)){
    cout<<-1<<endl;
    return 0;
  }
  if(abs(x)+abs(y)==k){
    cout<<1<<endl<<x<<" "<<y<<endl;
    return 0;
  }

  int X=abs(x),Y=abs(y);
  if(X>Y)swap(X,Y);

  int sousai=-1;
  for(int j=k*2;sousai<0;j+=k)
    if((j-(X+Y))%2==0)sousai=(j-(X+Y))/2;

  while(sousai>=k)move(0,-k),sousai-=k;
  move(-sousai,k-sousai);
  
  while(nowx+k<=X)move(k,0);
  while(nowy+k<=Y)move(0,k);
  if(nowx!=X||nowy!=Y)ans.push_back({X,Y});

  cout<<ans.size()<<endl;

  for(auto p:ans){
    int ansx=p.x,ansy=p.y;
    if(abs(x)>abs(y))swap(ansx,ansy);
    if(x<0)ansx*=-1;
    if(y<0)ansy*=-1;
    cout<<ansx<<" "<<ansy<<endl;
  }
}


Measured memory_bytes: 3952
def input_from_console():
    s = input().rstrip()
    return s


def main():
    def check_mm(mm):
        if mm >= '01' and mm <= '12':
            return True
        return False
    s = input_from_console()
    e1 = check_mm(s[:2])
    e2 = check_mm(s[2:])
    if e1 == True and e2 == False:
        print('MMYY')
    elif e1 == False and e2 == True:
        print('YYMM')
    elif e1 == True and e2 == True:
        print('AMBIGUOUS')
    else:
        print('NA')


if __name__ == "__main__":
    main()


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

int main(){
    int n;
    cin>>n;
    vector<long long> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
     for(int i=0;i<n;i++){
         cin>>b[i];
    }    
    for(int i=0;i<n;i++){
        cin>>c[i];
    }

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    long long ans=0;
    long long up[n]={};

    for(int i=0;i<n;i++){
        up[i]=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        cerr<<up[i]<<endl;
    }

    long long sum[n+1]={};

    for(int i=1;i<n+1;i++){
        sum[i]=sum[i-1]+up[i-1];
    }

    for(int i=0;i<n;i++){
        long long low=lower_bound(b.begin(),b.end(),c[i])-b.begin();

        ans+=sum[low];
        cerr<<low<<endl;
    }

    cout<<ans;

}



Measured memory_bytes: 4096
n = int(input())
a = input().split()
b = [0] * n
for i in range(n):
    if i % 2 == 0:
        b[i//2] = a[n-1-i]
    else:
        b[n-(i+1)//2] = a[n-1-i]
print(' '.join(b))


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int a,b;cin>>a>>b;
  cout<<a*b<<endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <utility>

using namespace std;

typedef vector<bool> vb;
typedef pair<int, int> pii;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};
pii ff(string s[], int h, int w, int x, int y, vb f[]) {
    pii ret;

    f[x][y] = true;
    if (s[x][y] == '#') {
        ret.first = 1;
        ret.second = 0;
    } else {
        ret.first = 0;
        ret.second = 1;
    }

    for (int i = 0; i < 4; i++) {
        int tx = x + dx[i], ty = y + dy[i];
        if (tx >= 0 && tx < h && ty >= 0 && ty < w && !f[tx][ty] && s[tx][ty] != s[x][y]) {
            pii t = ff(s, h, w, tx, ty, f);
            ret.first += t.first;
            ret.second += t.second;
        }
    }
    
    return ret;
}

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    vb f[h];
    for (int i = 0; i < h; i++) {
        f[i].resize(w, false);
    }
    long long ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (!f[i][j]) {
                pii t = ff(s, h, w, i, j, f);
                ans += 1ll * t.first * t.second;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 23040
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int h,w;
  cin>>h>>w;
  vector<vector<int>> v(h,vector<int>(w));
  rep(i,0,h) rep(j,0,w) cin>>v[i][j];
  int c=0;
  vector<pii> ans;
  while(c!=h){
    if(c%2==0){
      rep(i,1,w){
        if(v[c][i-1]%2==1){
          v[c][i]++;
          ans.pb({c+1,i});
          ans.pb({c+1,i+1});
        }
      }
      c++;
      if(c<h){
        if(v[c-1][w-1]%2==1){
          v[c][w-1]++;
          ans.pb({c,w});
          ans.pb({c+1,w});
        }
      }
    }
    else{
      rrep(i,w-2,0){
        if(v[c][i+1]%2==1){
          v[c][i]++;
          ans.pb({c+1,i+2});
          ans.pb({c+1,i+1});
        }
      }
      c++;
      if(c<h){
        if(v[c-1][0]%2==1){
          v[c][0]++;
          ans.pb({c,1});
          ans.pb({c+1,1});
        }
      }
    }
  }
  cout<<ans.size()/2<<endl;
  for(int i=0;i<ans.size();i+=2){
    cout<<ans[i].f<<" "<<ans[i].s<<" "<<ans[i+1].f<<" "<<ans[i+1].s<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

using namespace std;

/*

    bottom up.
    taking method.

*/

const int N = 1000 + 5 , mod = 1e9 + 7;

int dp[N][N];
char a[N][N];
int n , m;

int add(int a , int b){
    return (a%mod + b%mod) % mod;
}

main(){

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

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

    dp[0][1] = 1;
    for(int i = 1 ; i <= n ; i ++){
            for(int j = 1 ; j <= m ; j ++){

                    if(a[i][j] == '#')continue;

                    dp[i][j] = add(dp[i-1][j] , dp[i][j-1]);

            }
    }

    /*
    printf("\n");
    for(int i = 1 ; i <= n ; i ++){
            for(int j = 1 ; j <= m ; j ++){
                    printf("%d%c" , dp[i][j] , j == m ? '\n' : ' ');
            }
    }
    */

    printf("%d\n" , dp[n][m]);
}


Measured memory_bytes: 5120
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int h[100010];

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

	int curHeight = h[1] - 1;
	
	for (int i = 2 ; i <= n ; i++)
	{
		if (h[i] > curHeight) {
			h[i]--;
			curHeight = h[i];
		} else if (h[i] == curHeight) {
			curHeight = h[i];
		} else if (h[i] < curHeight) {
			printf("No\n");
			return 0;
		}
	}
	
	printf("Yes\n");
	
	return 0;
}


Measured memory_bytes: 512
def submit():
    k = input()
    lenk = len(k)
    d = int(input())
    f = lambda x: x % d
    modp = 10 ** 9 + 7

    dp = [[[0 for _ in range(d)],
           [0 for _ in range(d)]] for _ in range(lenk)]

    curr = int(k[0])
    for j in range(10):
        if j < curr:
            dp[0][0][f(j)] += 1
        if j == curr:
            dp[0][1][f(j)] += 1
            break

    for i in range(1, lenk):
        curr = int(k[i])
        for s in range(d):
            # smaller at prev
            for j in range(10):
                dp[i][0][f(s + j)] += dp[i - 1][0][s]
                dp[i][0][f(s + j)] %= modp
            
            # unsmall at prev
            for j in range(curr + 1):
                dp[i][j == curr][f(s + j)] += dp[i - 1][1][s]
                dp[i][j == curr][f(s + j)] %= modp
                
    ans = dp[lenk - 1][0][0] + dp[lenk - 1][1][0] - 1
    print(ans % modp)

submit()
            

Measured memory_bytes: 64484
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ll n;
    vector<ll> num;
    cin>>n;
    for(ll i=0;i<n;i++) {
        ll tmp;
        cin >>tmp;
        num.push_back(tmp);
    }
    sort(num.begin(),num.end());
    vector<bool> is_prime(num[n-1], true);
    ll sum=0;
    ll point = 0;
    for(ll p = 2; p <= num[n-1]; p++) {
        if (!is_prime[p]) continue;
        for (ll k = p * 2; k <= num[n-1]; k += p) is_prime[k] = false;
        bool y = true;
        while(y && point < n) {
            if(p==num[point] && is_prime[p]) {
                sum++;
                point++;
                continue;
            }else if(!is_prime[num[point]]) {
                point++;
                continue;
            }
            y = false;
        }
        if(point == n) {
            cout << sum<< endl;
            y = false;
            break;
        }
    }
}



Measured memory_bytes: 15168
n,s=map(int,input().split())
dp=[0]*(s+1)
mod=998244353
inv=pow(2,mod-2,mod)
dp[0]=pow(2,n,mod)
for i in list(map(int,input().split())):
  for j in range(s,i-1,-1):
    dp[j]=(dp[j]+dp[j-i]*inv)%mod
print(dp[s])

Measured memory_bytes: 68312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];  
    map<int,int> mp;
    ll ans=0;
    for(int i = 0; i < n; i++) {
        int l=i+a[i];
        int r=i-a[i];
        ans += mp[r];
        mp[l]++;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 21040
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n;
  cin>>n;
  vector<double> x(n),y(n);
  for(auto& xi:x)cin>>xi;
  for(auto& yi:y)cin>>yi;
  double p1,p2,p3,p8;
  p1=p2=p3=p8=0;
  for(int i=0;i<n;i++){
    double dif=abs(x[i]-y[i]);
    p1+=dif;
    p2+=dif*dif;
    p3+=dif*dif*dif;
    chmax(p8,dif);
  }
  p2=pow(p2,1./2.);
  p3=pow(p3,1./3.);
  printf("%.10lf\n%.10lf\n%.10lf\n%.10lf\n",p1,p2,p3,p8);
  return 0;
}



Measured memory_bytes: 3404
using System;

class TempMatch
{
	static public void Main(string[] args)
	{
		string[] vals = Console.ReadLine().Split(' ');
		int N = int.Parse(vals[0]);
		int M = int.Parse(vals[1]);
		string[] A = new string[N];
		string[] B = new string[M];

		for(int i=0; i<N; i++)
			A[i] = Console.ReadLine();
		for(int i=0; i<M; i++)
			B[i] = Console.ReadLine();
		for(int y=0; y<=N-M; y++)
		{
			for(int x=0; x<=N-M; x++)
			{
				bool match = true;
				for(int j=0; j<M; j++)
				{
					for(int i=0; i<M; i++)
					{
						if(A[y+j][x+i] != B[j][i])
						{
							match = false;
							break;
						}
					}
				}
				if(match)
				{
					Console.WriteLine("Yes");
					return;
				}
			}
		}
		Console.WriteLine("No");

	}
}


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

#define int long long int

int compute(int a, int b){
	int temp;
	temp = pow(a,4)+pow(b,4)+a*b*(pow(a,2)+pow(b,2))+pow(a*b,2);
	return temp;
}

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int x;
	cin>>x;
	vector<int> V;
	for(int i=1;i<=(int)sqrtl(x);i++){
		if(x%i == 0){
			V.push_back(i);
			if(i != x/i)
				V.push_back(x/i);
		}
	}
	int ans1=INT_MIN,ans2=INT_MIN;
	for(auto y: V){
		int temp = x/y;
		int l=y/2,r=10000;
		l = l*(-1);
		while(l <= r){
			int mid = (l+r)/2;
			int temp2 = compute(mid,mid+y);
			if(temp2 == temp){
				ans1 = mid;
				ans2 = mid+y;
				break;
			}
			else if(temp2 > temp)
				r = mid-1;
			else
				l = mid+1;
		}
		l = 10000,r = (-1)*y/2;
		l = l*(-1);
		while(l <= r){
			int mid = (l+r)/2;
			int temp2 = compute(mid,mid+y);
			if(temp2 == temp){
				ans1 = mid;
				ans2 = mid+y;
				break;
			}
			else if(temp2 > temp)
				r = mid-1;
			else
				l = mid+1;
		}
		if(ans1 != INT_MIN)
			break;
	}
	if(ans1 < ans2)
		swap(ans1,ans2);
	cout<<ans1<<" "<<ans2<<"\n";

	return 0;
}

Measured memory_bytes: 4216
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=1e6+5;
int n,cnt[3],a[N],l[N],r[N],col[3],id[3];
char s[N];

signed main(){
//	freopen("123.txt","r",stdin);
//	freopen("321.txt","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);a[0]=a[n+1]=3;
	for(int i=1;i<=n;i++) cnt[a[i]=s[i]-'A']++;
	if(!(cnt[0]&&cnt[1]&&cnt[2])) return 0;
	r[0]=1;l[n+1]=n;for(int i=1;i<=n;i++) r[i]=i+1,l[i]=i-1;
	for(int i=n-1;i;i--) if(a[i]==a[i+1]) r[i]=r[i+1],l[r[i]]=i;
	for(int i:{0,1,2}) col[i]=i,cnt[i]=0;
	for(int i=r[0];i<=n;i=r[i]) cnt[a[i]]++;
	sort(col,col+3,[](int x,int y){return cnt[x]<cnt[y];});
	for(int i:{0,1,2}) id[col[i]]=i;
	for(int i=r[0];i<=n;i=r[i]) a[i]=id[a[i]];
	for(int i:{0,1,2}) cnt[i]=0;
	for(int i=r[0];i<=n;i=r[i]) cnt[a[i]]++;
//	printf("#%d %d %d\n",cnt[0],cnt[1],cnt[2]);
//	for(int i=r[0];i<=n;i=r[i]) write(a[i]);puts("");
//	for(int i=r[0];i<=n;i=r[i]) putchar('A'+col[a[i]]);puts("");
	for(int i=r[0];i<=n&&cnt[2]>cnt[1];i=r[i]) if(a[i]==2&&a[l[i]]!=a[r[i]]){
		cnt[2]--;
		r[l[i]]=r[i];
		l[r[i]]=l[i];
	}
//	printf("#%d %d %d\n",cnt[0],cnt[1],cnt[2]);
//	for(int i=r[0];i<=n;i=r[i]) write(a[i]);puts("");
//	for(int i=r[0];i<=n;i=r[i]) putchar('A'+col[a[i]]);puts("");
	for(int i=r[0];i<=n&&cnt[2]>cnt[1];i=r[i]) if(a[i]==2&&!a[l[i]]&&!a[r[i]]){
		cnt[2]--;
		cnt[0]--;
		r[l[i]]=r[r[i]];
		l[r[r[i]]]=l[i];
	}
//	printf("#%d %d %d\n",cnt[0],cnt[1],cnt[2]);
//	for(int i=r[0];i<=n;i=r[i]) write(a[i]);puts("");
//	for(int i=r[0];i<=n;i=r[i]) putchar('A'+col[a[i]]);puts("");
	for(int i=0;i<=n&&cnt[2]>cnt[0];i=r[i]) if(!i||!a[i]){
		while(cnt[2]>cnt[0]&&a[r[i]]+a[r[r[i]]]==3&&a[r[i]]&&a[r[r[i]]]&&a[r[r[r[i]]]]){
			cnt[1]--;
			cnt[2]--;
			l[r[r[r[i]]]]=i;
			r[i]=r[r[r[i]]];
		}
	}
//	printf("#%d %d %d\n",cnt[0],cnt[1],cnt[2]);
//	for(int i=r[0];i<=n;i=r[i]) write(a[i]);puts("");
	for(int i=r[0];i<=n;i=r[i]) putchar('A'+col[a[i]]);
}

Measured memory_bytes: 16400
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 1e5;
ll fenw[2*N+100], pre[N+9];
void upd(int x, int delta=1) {
    x += N+1;
    for(; x < 2*N+10; x += x&-x)
        fenw[x] += delta;
}
ll qry(int x) {
    x += N+1;
    ll sum = 0;
    for(; x > 0; x -= x&-x)
        sum += fenw[x];
    return sum;
}
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    

    int n; cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }   
    ll lo = 1, hi = 1e9, ans = 1;
    while(lo <= hi) {
        int mid = (lo+hi)/2;
        upd(0, 1);
        long long subs = 0;
        for(int i = 1; i <= n; i++) {
            if(a[i] >= mid) {
                pre[i] = pre[i-1]+1;
            } else {
                pre[i] = pre[i-1]-1;
            }
            subs += qry(pre[i]);
            upd(pre[i], 1);
        }
        // cout << mid << " " << subs << endl;
        for(int i = 0; i < 2*N+20; i++) {
            fenw[i] = 0;
        }
        if(subs >= (1ll*n*(n+1)/2+1)/2) {
            ans = mid;
            lo = mid+1;
        } else {
            hi = mid-1;
        }
    }
    cout << ans << "\n";







    return 0;
    
}

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

int main(void)
{
    int n;
    cin >> n;
    bool f = true;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(a % 2 == 0)
        {
            if(a % 3 != 0 && a % 5 != 0)
            {
                f = false;
            }
        }
    }
    cout << (f ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int k, n; cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> dist(n);
    rep(i, n-1) {
        dist[i] = a[i+1]-a[i];
    }
    dist[n-1] = k-a[n-1]+a[0];
    int max = *max_element(dist.begin(), dist.end());
    
    cout << k-max << endl;
}

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

typedef long long ll;
typedef std::pair <ll, int> pr;
typedef std::map <ll, int> map;
const int mod = 1000000007;

int cnt;
ll n, m, ans = 0;
pr pd[54];

ll PowerMod(ll a, ll n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

namespace NT {
	const int N = 1000054;

	int pn = 0, c[N], p[78540];
	map result;

	inline ll MulMod(ll a, ll b, ll m) {return (__int128)a * b % m;}

	ll PowerMod(ll a, ll n, ll m) {
		if (!n || a == 1) return 1ll;
		ll s = PowerMod(a, n >> 1, m);
		s = MulMod(s, s, m);
		return n & 1 ? MulMod(s, a, m) : s;
	}

	void sieve(int n) {
		int i, j, v;
		memset(c, -1, sizeof c);
		for (i = 2; i <= n; ++i) {
			if (!~c[i]) p[pn] = i, c[i] = pn++;
			for (j = 0; (v = i * p[j]) <= n && j <= c[i]; ++j) c[v] = j;
		}
	}

	bool Miller_Rabin(ll n) {
		static const int test[8] = {2, 3, 5, 7, 11, 13, 82, 373};
		if (n < N) return n > 1 && p[c[n]] == n;
		int c, i, j; ll s = n - 1, u, v;
		for (c = 0; !(s & 1); ++c, s >>= 1);
		for (i = 0; i < 8; ++i) {
			if (!(n % test[i])) return false;
			u = PowerMod(test[i], s, n);
			for (j = 0; j < c; ++j, u = v)
				if (v = MulMod(u, u, n), u != 1 && u != n - 1 && v == 1) return false;
			if (u != 1) return false;
		}
		return true;
	}

	ll Pollard_Rho(ll n, int c) {
		ll i = 1, k = 2, x = rand() % (n - 1) + 1, y = x, p;
		for (; k <= 131072; ) {
			x = (MulMod(x, x, n) + c) % n;
			p = std::__gcd((y - x + n) % n, n);
			if (p != 1 && p != n) return p;
			if (++i == k) y = x, k <<= 1;
		}
		return 0;
	}
	
	inline void push(ll prime, int alpha) {result[prime] += alpha;}
	
	void __builtin_factor(ll n) {
		int i, j, k; ll d;
		for (i = 0; n != 1; )
			if (n >= N) {
				if (Miller_Rabin(n)) return push(n, 1);
				for (k = 97; !(d = Pollard_Rho(n, k)); --k);
				__builtin_factor(d), n /= d;
			} else {
				for (i = p[c[n]], j = 0; !(n % i); n /= i, ++j);
				push(i, j);
			}
	}

	inline void factor(ll n) {result.clear(), __builtin_factor(n);}

	inline void init() {sieve(N - 1);}
}

void dfs(int dep, ll P, ll Q) {
	if (dep == cnt) {
		ans += PowerMod(m, (P + 1) / 2, P & 1 ? (n & 1 ? P * Q % mod : 0) : P / 2 * Q % mod);
		return;
	}
	for (int i = 0; i <= pd[dep].second; ++i, P *= pd[dep].first)
		dfs(dep + 1, P, Q * (i == pd[dep].second ? 1 : 1 - pd[dep].first));
}

void work() {
	ans = cnt = 0;
//	scanf("%lld%lld%d", &n, &m, &mod), NT::factor(n), m %= mod;
	scanf("%lld%lld", &n, &m), NT::factor(n);
	for (const pr &e : NT::result) pd[cnt++] = e;
	dfs(0, 1, 1), ans %= mod;
	printf("%d\n", int(ans + (ans >> 63 & mod)));
}

int main() {
	int T; NT::init();
//	for (scanf("%d", &T); T; --T) work();
	work();
	return 0;
}

Measured memory_bytes: 4480
import java.awt.*;
import java.util.*;
import java.awt.geom.*;

public class Main {
    public static void main(String args[])throws Exception{
        Scanner cin= new Scanner(System.in);
		int n,m;
		Point2D.Double[] w = new Point2D.Double[200];
		Point2D.Double[] b = new Point2D.Double[200];
		for(;;){
			n=cin.nextInt();
			m=cin.nextInt();
			//			System.out.printf("%d %d\n",n,m);
			
			if(n==0 && m==0) break;
			
			
			for(int i=0;i<n;i++){
				w[i] = new Point2D.Double();
				w[i].x= cin.nextInt();
				w[i].y= cin.nextInt();
			}
			for(int i=0;i<m;i++){
				b[i] = new Point2D.Double();
				b[i].x= cin.nextInt();
				b[i].y= cin.nextInt();
			}
			
			int f=0;
		out:
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					int t1=0,t2=0;
					//					System.out.printf("%d  %d\n",i,j);
					for(int k=0;k<n;k++){
						if(k==i) continue;
						int ccw=Line2D.relativeCCW( w[k].x, w[k].y, w[i].x, w[i].y, b[j].x, b[j].y);
						//						if(ccw==0) if(w[i].distance(b[j]) + w[i].distance(w[k]) <= w[k].distance(b[j])) ccw=1;
						//						System.out.println(ccw);
						t1+=ccw;
					}
					for(int k=0;k<m;k++){
						if(k==j) continue;
						int ccw=Line2D.relativeCCW(b[k].x, b[k].y, b[j].x, b[j].y, w[i].x, w[i].y);
						//						System.out.println(ccw);
						//						if(ccw==0) if(b[j].distance(w[i]) + b[j].distance(b[k]) <= w[i].distance(b[k])) ccw=-1;
						//						System.out.println(ccw);
						t2+=ccw;
					}
					//					System.out.printf("t1,t2= %d,%d\n",t1,t2);
					if(t1>=0 && t2>=0 && Math.abs(t1)==n-1 && Math.abs(t2)==m-1){
						f=1;
						System.out.println("YES");
						break out;
					}
				}
			}
			if(f==0) System.out.println("NO");
		}
	}
}

Measured memory_bytes: 13000