akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<bitset>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  int n, k, x, y;
  cin>>n>>k>>x>>y;
  ll total = 0;
  if(n >= k)
  {
    total += (k)*x;
    n = n -k;
  }
  else
  {
    total += n*x;
    n = 0;
  }
  total += n*y;
  cout<<total<<endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
//#define int long long
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define mod %1000000007
#define ld long double
#define pll pair<ll,ll>
bool comp(P p1,P p2)
{
    if(p1.ff.ff!=p2.ff.ff)
        return p1.ff.ff<p2.ff.ff;
    else
        return p1.ss<p2.ss;
}

int32_t main()
{
     //IOS;
     /*#ifndef ONLINE_JUDGE
     freopen("int.txt","r",stdin);
     freopen("out.txt","w",stdout);
     #endif*/
     int n;
     char s[1000];
     scanf("%d",&n);
    // trace1(n);
     printf("0\n");
     fflush(stdout);
     scanf("%s",s);
     if(s[0]=='V')
     {
        return 0;
     }
     bool ch=0;
     if(s[0]=='M')
     {
        ch=1;
     }
     int lo=1;
     int hi=n-1;
     while(lo<hi)
     {
        int mid=(lo+hi)>>1;
        int done=0;
        if(mid%2==0)
        {
            printf("%d\n",mid);
            fflush(stdout);
           scanf("%s",s);
            if(s[0]=='V')
                return 0;
            if(s[0]=='M' && ch)
                ;
            if(s[0]=='M' && ch==0)
            {
                done=1;
            }
            if(s[0]=='F' && ch==0)
                ;
            if(s[0]=='F' && ch==1)
            {
                done=1;
            }
             //          trace3(s[0],ch,done);

        }
        else
        {
           printf("%d\n",mid);
            fflush(stdout);
            scanf("%s",s);
            if(s[0]=='V')
                return 0;
            if(s[0]=='F' && ch)
                ;
            if(s[0]=='F' && ch==0)
            {
                done=1;
            }
            if(s[0]=='M' && ch==0)
                ;
            if(s[0]=='M' && ch==1)
            {
                done=1;
            }
        }
        if(done)
            hi=mid-1;
        else
            lo=mid+1;
     }
     printf("%d\n",lo);
     fflush(stdout);
     scanf("%s",s);

     return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
 #include <string> 
 #include <math.h>
 #include <bitset>
 #include <numeric>
 
 using namespace std;

 int main(){
    int A, B;

    cin >> A >> B;

    if (A!=1 && B!=1)
        cout << 1 << endl;

    else if (A!=2 && B!=2)
        cout << 2 << endl;

    else
        cout << 3 << endl;

    return 0;
 }



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n,i,j,c;
  while(1){
    scanf("%d",&n);
    if(!n) break;
    int a[n];
    for(i=0;i<n;i++)
      scanf("%d",&a[i]);
    c=0;
    for(i=0;i<n-1;i++){
      for(j=n-1;j>i;j--){
	if(a[j-1]>a[j]){
	  int t=a[j];
	  a[j]=a[j-1];
	  a[j-1]=t;
	  c++;
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

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

        #define ll long long
        #define pb push_back
        #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
        #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
        #define sortV(v) sort(v.begin(),v.end())
        #define revV(v) reverse(v.begin(),v.end())
    

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;
        const int N = 3009;
           
        void solve(){
            cin >> n;
            int cnt = 0;
            bool flag = false;
            for(int i=0;i<n;i++){
                cin >> a >> b;
                if(a == b){
                    cnt++;
                    if(cnt >= 3) flag = true;
                }else{
                    cnt = 0;
                }
            }
            if(flag) cout << "Yes\n";
            else cout << "No\n";
        }

      
 
        int main(){
            ios_base::sync_with_stdio(false);

         

            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define COUT(x) cout << (x) << endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll LINF = 1e17;
const int INF = 1001001001;
const int MOD = 1000000007;

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll div(ll a) {
    ll sum = 1, cnt = 1;
    while(a != 1) {
        a /= 2;
        sum *= 2;
        cnt += sum;
    }
    return cnt;
}

int main() {
    ll H;
    cin >> H;
    COUT(div(H));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int n, k, q;
vector<ll>a;
vector<ll>b;
int check(int mi, int ma) {
	int cnt = 0;
	int tmp = 0;
	int l = 0;
	min_priority_queue<int>pq;
	rep(i, 0, n) {
		if (mi<=a[i]) {
			pq.push(a[i]);
		}
		else {
			while (pq.size() >= k && pq.top() <= ma){
				cnt++;
				pq.pop();
			}
			while (pq.size())pq.pop();
		}
	}
	while (pq.size() >= k && pq.top() <= ma) {
		cnt++;
		pq.pop();
	}
	return cnt >= q;
}
int main() {
	cin >> n >> k >> q;
	a.resize(n);
	b.resize(n);
	rep(i, 0, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(all(b));

	ll ans = inf;
	rep(i, 0, n) {
		if (!check(a[i],b[n-1]))continue;
		if (check(a[i], a[i]))ans = 0;
		int ng = lower_bound(all(b),a[i])-b.begin(), ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (check(a[i], b[mid]))ok = mid;
			else ng = mid;
		}
		ans = min(ans,b[ok]-a[i]);
	}
	puts(ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100010
using namespace std;
int n,K,s[2010][2010],t[2010][2010];
int qrys(int x1,int y1,int x2,int y2)
{
	return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
}
int qryt(int x1,int y1,int x2,int y2)
{
	return t[x2][y2]-t[x1-1][y2]-t[x2][y1-1]+t[x1-1][y1-1];
}
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)
	{
		int x,y;char c;
		scanf("%d%d %c",&x,&y,&c);
		//cout<<x<<' '<<y<<endl;
		x%=2*K;y%=2*K;
		x++;y++;
		//cout<<x<<' '<<y<<endl;
		if(c=='B') s[x][y]++;else t[x][y]++;
	}
	for(int i=1;i<=2*K;i++)
		for(int j=1;j<=2*K;j++)
			s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1],t[i][j]+=t[i-1][j]+t[i][j-1]-t[i-1][j-1];
//	for(int i=1;i<=2*K;i++,puts(""))
//		for(int j=1;j<=2*K;j++)
//			cout<<s[i][j]<<' ';
//	for(int i=1;i<=2*K;i++,puts(""))
//		for(int j=1;j<=2*K;j++)
//			cout<<t[i][j]<<' ';
	int ans=0,cal;
	for(int dx=0;dx<K;dx++)
		for(int dy=0;dy<K;dy++)
		{
			cal=qrys(1,1,dx,dy)+qrys(dx+1,dy+1,dx+K,dy+K)+qrys(1,dy+K+1,dx,2*K)+qrys(dx+K+1,1,2*K,dy)+qrys(dx+K+1,dy+K+1,2*K,2*K);
			cal+=qryt(1,dy+1,dx,dy+K)+qryt(dx+1,1,dx+K,dy)+qryt(dx+1,dy+K+1,dx+K,2*K)+qryt(dx+K+1,dy+1,2*K,dy+K);
			//cout<<cal<<endl;
			ans=max(ans,max(cal,n-cal));
		}
	printf("%d",ans);	
	return 0;
}

Measured memory_bytes: 31744
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b,h,m = imap()
h += m/60
r1 = 2*PI * (h/12)
r2 = 2*PI * (m/60)
z1 = a * np.exp(-r1 * 1j)
z2 = b * np.exp(-r2 * 1j)
ans = abs(z1 - z2)
print(ans)


Measured memory_bytes: 37768
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define ps(s)    printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>    pii;
typedef pair<ll, ll>    pl;
typedef vector<int>        vi;
typedef vector<ll>        vl;
typedef vector<pii>        vpii;
typedef vector<pl>        vpl;
typedef vector<vi>        vvi;
typedef vector<vl>        vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];

void solve(){
    ll n,i,j;
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}
 

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

int count(int n, map<int, int> mp)
{
  int ret = 0;
  for (auto m : mp)
  {
    if (n <= m.second)
      ret++;
  }
  return ret;
}

int main()
{
  int N;
  cin >> N;
  map<int, int> prime;
  for (int i = 2; i <= N; i++)
  {
    int value = i;
    for (int j = 2; j * j <= value; j++)
    {
      while (value % j == 0)
      {
        prime[j]++;
        value /= j;
      }
    }
    if (value != 1)
      prime[value]++;
  }
  int ans = 0;
  // p^74
  ans += count(74, prime);
  // p^24 * q^2
  ans += count(24, prime) * (count(2, prime) - 1);
  // p^14 * p^4
  ans += count(14, prime) * (count(4, prime) - 1);
  // p^4 * q^4 * r^2
  ans += count(4, prime) * (count(4, prime) - 1) * (count(2, prime) - 2) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L[] = new int[N];
        for(int i=0; i<N; i++) {
            L[i] = sc.nextInt();
        }
        Arrays.sort(L);
        long sum = 0;
        for(int i=0; i<N-1; i++) {
            sum+=L[i];
        }
//        System.out.println(String.format("%d %d", sum, L[N-1]));
        System.out.println((sum > L[N-1]) ? "Yes" : "No");
    }
}


Measured memory_bytes: 23124
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int a[100];
int main()
{
	int n, m = 0; cin >> n;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if(a[i] != i) {
			m++;
		}
	}

	if(!m || m == 2) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

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

int main(){

    int N; cin >> N;
    int hotels[N]; rep(i,0,N) cin >> hotels[i];
    int ans=1;
    int highst=hotels[0];

    rep(i,1,N){

        if(hotels[i]>=highst){
            highst = hotels[i];
            ans++;
        }

    }
    

    cout << ans << endl;
    
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const int max_n = 100;
char field[max_n][max_n];
bool ok = false;
int H,W;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
void dfs(int x, int y, int now){
  field[x][y] = '.';
  for(int i=0 ; i<4 ; i++){
      int nx = x + dx[i], ny = y + dy[i];
      if(nx>=0 && ny>=0 && nx<=H && ny<=W && field[nx][ny]=='#'){
        if(now == 0) ok = true;
        now++;
        dfs(nx, ny, now);
      }
  }
}
int main(){
  cin >> H >> W;
  for(int i=0 ; i<H ; i++){
    for(int j=0 ; j<W ; j++){
      cin >> field[i][j];
    }
  }
  for(int i=0 ; i<H ; i++){
    for(int j=0 ; j<W ; j++){
      if(field[i][j] == '#'){
          dfs(i,j,0);
          if(!ok){
             cout << "No" << endl;
             return 0;
          }
          ok = false;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 384
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


void Solve() {
	
	int n;
	cin >> n;
	ll a[20010];
	ll b[20010];
	a[0] = 1;
	b[n - 1] = 1;
	for (size_t i = 1; i < n; i++)
	{
		a[i] = a[i - 1] + n;
		b[(n - 1) - i] = b[(n - 1) - i + 1] + n;
	}
	int ma = 0;
	int bef = -1;
	for (size_t i = 0; i < n; i++)
	{
		int p;
		cin >> p;
		p--;
		ll su = a[p] + b[p];
		if (ma >= su) {
			int rem = ma - su + 1;
			if (bef < p) {
				a[p] += rem;
			}
			else {
				b[p] += rem;
			}
			ma++;
		}
		else {
			ma = su;
		}

		bef = p;
	}
	
	for (size_t i = 0; i < n; i++)
	{
		if (i > 0) {
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	for (size_t i = 0; i < n; i++)
	{
		if (i > 0) {
			cout << " ";
		}
		cout << b[i];
	}
	cout << endl;
}


int main() {
	Solve();
	return 0;
}



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

int x;

void ans(ll a,ll b){
  // std::cout << "ans" << '\n';
  std::cout << a << '\n';
  std::cout << b << '\n';
}


bool cal(ll a,ll b){
  // std::cout << "a:" <<a<< " b:"<< b<< " x:"<< x<<'\n';
  if(pow(a,5.0)-pow(b,5.0)==x){
    ans(a,b);
    return true;
  }
  else return false;
}




int main(){

  std::cin >> x;

  ll MAX=pow(LLONG_MAX,((double)1/5));


  ll a=0;
  ll b=0;

  bool flag =false;
  while (a<= MAX) {

    b=-a;
    if(a-b==0 && x==0){
      ans(a,b);
      break;
    }
    if(a-b==0 && x!=0)b++;


    if(cal(a,b))break;

    while (pow(a,5.0)-pow(b,5.0)>=x) {
      flag =cal(a,b);
      if(flag)break;
      b++;
    }
    if(flag)break;

    a++;
  }


  return 0;
}


Measured memory_bytes: 4008
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<char>c(10);
    string s;
    map<string,int>mp;
    for(int i=0; i<n; i++){
        cin >> s;
        for(int j=0; j<10; j++){
            c[j]=s[j];
        }
        sort(c.begin(),c.end());
        for(int j=0; j<10; j++){
            s[j]=c[j];
        }
        mp[s]++;
    }
    long long ans=0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second==2) ans++;
        if(itr->second>2){
            long long a = itr->second;
            if(itr->second==2) ans++;
            else if(itr->second>2){
                ans += a*(a-1)/2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11268
import math

N,M = map(int,input().split())

T = M * 1900 + (N-M) * 100

p = (1/2)**M
p2 = (1/2)**M
ans = 0
for i in range(1,500000):
  ans += T * p2 * i
  p2 = p2 * (1-p)
  
print(round(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,Q;
  cin>>N >> K >> Q;
  
  if(K>Q){
    for(int i = 0; i < N; i++) {
      cout << "Yes" << endl;
    }
  }else{
    //回答入力
    int anses[Q] = {0};
    for(int i = 0; i < Q; i++) {
      cin >> anses[i];
    }

    //ポイント入力
    int points[N] = {0};
    for(int i = 0; i < Q; i++) {
      points[anses[i] -1]++;
    }

    //ポイント出力
    for(int i = 0; i < N; i++) {
      if(points[i] > Q - K){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 1280
//abc173_b.cpp
//Sun Jul  5 20:55:19 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

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

	int a[4];
	fill(a,a+4,0);
	for (int i=0;i<n;i++){
		string s;
		cin >> s;
		if (s=="AC"){
			a[0]++;
		}else if (s=="WA"){
			a[1]++;
		}else if (s=="TLE"){
			a[2]++;
		}else if (s=="RE"){
			a[3]++;
		}
	}

	cout << "AC x "<< a[0] << endl;
	cout << "WA x "<< a[1] << endl;
	cout << "TLE x "<< a[2] << endl;
	cout << "RE x "<< a[3] << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
   int N, M, A[20000] , i, s=0;

   scanf("%d%d" ,&N, &M);
   for(i=0; i<M; i++){
       scanf("%d" ,&A[i]);
       s=s+A[i];
   }

    if(s<=N){
        printf("%d" , N-s);
    }else{
        printf("-1");
    }

    return 0;
}


Measured memory_bytes: 1776
#include<stdio.h>
int main(){
    int n;
    float p;
    scanf("%d",&n);
    if(n%2==0){
        p=(1.0/2.0);
    }
    else{
        p=((n+1.0)/2.0)/n;
    }
    printf("%f\n",p);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  vector<int> v;
  REP(i,n){
    int t;cin>>t;
    v.pb(t);
  }
  VSORT(v);

  cout<<v[v.size()/2] - v[v.size()/2-1]<<endl;

 

  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge
 
#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif
 
long long mod =1000000007;
 
long long pw(long long a, long long e) {
	if(e <= 0) return 1;
	long long x =pw(a,e/2);
	x =(x*x)%mod;
	if(e%2 != 0) x =(x*a)%mod;
	return x;}
 
int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<long long> fac(10000,1),inv(10000,1);
	for(int i =1; i < 10000; i++) {
		fac[i] =(i*fac[i-1])%mod;
		inv[i] =pw(fac[i],mod-2);}
 
	vector< vector<long long> > P(2048,vector<long long>(2048,0));
	for(int i =0; i < N; i++) {
		int a,b;
		cin >> a >> b;
		P[a][b]++;}
	vector< vector<long long> > P0 =P;
 
	for(int i =2000; i > 0; i--) for(int j =2000; j > 0; j--) {
		P[i][j-1] +=P[i][j];
		if(P[i][j-1] >= mod) P[i][j-1] -=mod;
		P[i-1][j] +=P[i][j];
		if(P[i-1][j] >= mod) P[i-1][j] -=mod;
		P[i][j] =0;}
 
	long long ans =0;
	for(int i =2000; i >= -2000; i--) for(int j =2000; j >= -2000; j--) {
		int x1 =max(i,0), y1 =max(-i,0);
		int x2 =max(j,0), y2 =max(-j,0);
		long long x =(fac[x1+x2+y1+y2]*inv[x1+x2])%mod;
		x =(x*inv[y1+y2])%mod;
		long long p =(P[x1][y1]*P[x2][y2])%mod;
		ans =(ans+p*x)%mod;}
	for(int i =0; i < 2048; i++) for(int j =0; j < 2048; j++) {
		long long x =(fac[2*(i+j)]*inv[2*i])%mod;
		x =(x*inv[2*j])%mod;
		ans =(ans-P0[i][j]%mod*x)%mod;}
	ans =(ans*inv[2])%mod;
	if(ans < 0) ans +=mod;
	cout << ans << "\n";
	return 0;}
 
// look at my code
// my code is amazing

Measured memory_bytes: 66048
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    for(int i=s.length(); i>=0; --i){
        s=s.substr(0,s.length()-1);
        string s1=s.substr(0,s.length()/2);
        string s2=s.substr(s.length()/2);
        if(s1==s2){
            cout<<s1.length()*2<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int N;

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

  cin >> N;

  vector<Pii> ans;
  if (N%2 == 0) {
      for (int i = 1; i <= N; ++i) {
          for (int j = i+1; j <= N; ++j) {
              if (i+j != N+1) {
                  ans.push_back(Pii(i, j));
              }
          }
      }
  } else {
      for (int i = 1; i <= N; ++i) {
          for (int j = i+1; j <= N; ++j) {
              if (i+j != N) {
                  ans.push_back(Pii(i, j));
              }
          }
      }
  }

  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
      cout << ans[i].fi << ' ' << ans[i].sc << endl;
  }

  return 0;
}


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

int main(){
    ll N, K;
    cin >> N >> K;

    double ans = 0;
    rep(i, 1, N+1){
        ll cnt = 0, n = i;
        while(n < K){
            n *= 2;
            cnt++;
        }
        if(cnt == 0){
            ans += 1 / (double)N;
        }else{
            ans += (double)(1 / (double)N) * pow(0.5, cnt);
        }
    }
    printf("%.12lf\n", ans);
    return 0;
}

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

#define fi                      first
#define se                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

void solve();

int32_t main()
{
        fast;
        int t = 1;
        // cin >> t;
        for(int i = 1; i <= t; ++i)
                solve();
        cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}

void solve() {
        char ch;
        cin >> ch;
        ch++;
        cout << ch << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x,y,i;
    for(i = 0 ; 1 ; i++ ){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)break;
    if(y<x){
        printf("%d %d\n",y,x);
    }
    else{
        printf("%d %d\n",x,y);
    }
    }
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
//#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

int main(void){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans = min(a,k);
    k = max(0LL,k-a-b);
    ans -= k;
    cout<<ans<<endl;
}

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

int main(){
  string s;
  cin >> s;
  rep(i,s.size()) s[i] = 'x';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
//take care of precedence rule of operators 
//do not forget to change the sizes of arrays and value of contants and other things after debugging  
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)
 
#define SZ(x)  (ll)(x.size())
 
//comment the below if not required
 

 
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second

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

//cout<<"Case #"<<c<<": "<<ans<<"\n" ;

const int N = 1e3+1;

int vis[N*N+1],r,c,r1,c1,r2,c2,i,j,ans=-1,u,v,x,y,des;

int X[4]={-1,0,1,0};
int Y[4]={0,1,0,-1};

char a[N][N];

bool check(int x,int y)
{
    if(x>=1 && x<=r && y>=1 && y<=c && a[x][y]=='.')
        return true;
    return false;
}


int main()
{

    IOS;

    cin>>r>>c;
    cin>>r1>>c1;
    cin>>r2>>c2;

    des = (r2-1)*c+c2;

    rep(i,1,r+1)
        rep(j,1,c+1)
        {
            cin>>a[i][j];
            vis[(i-1)*c+j]=1e7;
        }


    deque<int> q;
    q.push_front((r1-1)*c+c1);
    vis[(r1-1)*c+c1]=0;

    while(!q.empty())
    {

        int v = q.front();

        q.pop_front();

        if(vis[v]==-1)
                continue;

        int d1 = vis[v];

        if(v==des)
            ans=d1;
    
        vis[v]=-1;
        
        u = ceil(v/(1.0*c));

        v = v%c;
        if(!v)
            v=c;


        for(i=0;i<4;++i)
        {
            x=u+X[i];
            y=v+Y[i];

            if(check(x,y))
            {
                int v1 = (x-1)*c+y;

                if(d1<vis[v1])
                {
                    vis[v1]=d1;
                    q.push_front(v1);
                }
            }

        }


        u-=2;
        v-=2;

        for(i=u;i<=(u+4);++i)
        {
            for(j=v;j<=(v+4);++j)
            {
                if(check(i,j))
                {
                    int v1 = (i-1)*c+j;

                    if((d1+1)<vis[v1])
                    {
                        vis[v1]=d1+1;
                        q.push_back(v1);
                    }

                }

            }
        }

    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 8520
def main():
    X, Y = (int(i) for i in input().split())
    ans = 0
    if X == 1 and Y == 1:
        ans += 400000
    if X == 1:
        ans += 300000
    if Y == 1:
        ans += 300000
    if X == 2:
        ans += 200000
    if Y == 2:
        ans += 200000
    if X == 3:
        ans += 100000
    if Y == 3:
        ans += 100000
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int x;
  cin >> x;

  int n = 1;
  while (1) {
    if (n * (n + 1) / 2 >= x) {
      cout << n << endl;
      return 0;
    }
    n++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int main()
{
    int N;
    cin>>N;
    bool flg = true;
    for(int i =0 ;i < N;i ++)
    {
        int x;
        cin>>x;
        if((x & 1)==0)
        {
            if(x%3 != 0 && x % 5 != 0)
                flg = false;
        }
    }
    if(flg)
    {
        cout<<"APPROVED"<<endl;
    }else
    {
        cout<<"DENIED"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int read() {
	int w = 1,res = 0;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		if(ch == '-') w = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
	return w * res;
}
int w[200010], cnt[200010], res, st, d[66000], xr[66000], m = 1 << 15;
int main() {
	int n = read();
	for(int i = 1; i < n; i ++) {
		int u = read(), v = read(), val = read();
		w[u] = w[u] ^ val;
		w[v] = w[v] ^ val;
	}
	for(int i = 0; i < n; i ++) cnt[w[i]] ++;
	for(int i = 1; i <= 15; i ++) res += cnt[i] / 2, st = st | (cnt[i] & 1) << (i - 1);
	for(int i = 1; i < m; i ++) d[i] = d[i >> 1] + (i & 1);
	for(int i = 1; i < m; i ++) d[i] -= 1;
	for(int i = 1; i < m; i ++)
		for(int j = 0; j < 15; j ++) if((i >> j) & 1) xr[i] = xr[i] ^ (j + 1);
	for(int i = 1; i < m; i ++) {
		if(xr[i] != 0) continue;
		for(int j = (i - 1) & i; j; j = (j - 1) & i)
			if(xr[j] == 0) d[i] = min(d[i], d[j] + d[i ^ j]);
	}
	printf("%d", res + d[st]);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> pos(n);
    rep(i, n) cin >> pos[i].first >> pos[i].second;

    map<pair<int, int>, int> mp;

    rep(i, n) {
        rep(j, n) {
            if (i == j)
                continue;

            mp[{pos[i].first - pos[j].first, pos[i].second - pos[j].second}]++;
        }
    }

    int ans = n;
    for (auto p : mp) {
        ans = min(ans, n - p.second);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3676
import java.util.*;

class Main {

	static Scanner in = new Scanner(System.in);

    void solve() {
		int n = in.nextInt();
		int[] s = new int[n];
		for(int i = 0; i < n; i++) s[i] = in.nextInt();
		int q = in.nextInt();
		int[] t = new int[q];
		for(int i = 0; i < q; i++) t[i] = in.nextInt();
		int ans = 0;
		for(int i : t) if(serch(s, i) > 0) ans++;
		System.out.println(ans);
	}

	int serch(int[] a, int n){
		int left = 0;
		int right = a.length;
		int mid = -1;
		while(left < right){
			mid = (left + right) / 2;
			if(a[mid] == n) return 1;
			else if(n > a[mid]) left = mid + 1;
			else if(n < a[mid]) right = mid;
		}
		return 0;
	}

    public static void main(String[] args) {
        new Main().solve();
    }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int32 n = s.size();
  int32 cnt[2] = {0,0};
  REP(i,n)cnt[s[i] - '0']++;
  ANS(min(cnt[0],cnt[1]) * 2);
  
  return 0;
}

Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))

# a_i /2 or x3
# すべてint, すべてx3はだめ

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

# 素因数の中に2がいくつ入っているか。
fact_list = []
for item in a:
    fact_list += prime_factorize(item)

print(fact_list.count(2))
    


Measured memory_bytes: 11884
n = int(input())
a = list(map(int, input().split()))
# at any partial solution, it is only possible to
# have either ceil(k/2) or ceil(k/2)-1 included values
# also, for the next solution, it matters if the current value was used or not.
# therefore, keep a partial 'max solution' for all 4 possibilities:
# ceil(k/2)-1, not included
# ceil(k/2)-1, included
# ceil(k/2), not included
# ceil(k/2), included
def solve(start_point):
  for idx, value in enumerate(a[start_point:]):
    idx = idx+start_point
    if idx%2!=0:
      partial_solution[idx][0] = max(partial_solution[idx-1][0], partial_solution[idx-1][1])
      partial_solution[idx][1] = a[idx] + max(partial_solution[idx-2][0], partial_solution[idx-2][1])
      partial_solution[idx][2] = max(partial_solution[idx-1][2], partial_solution[idx-1][3])
      partial_solution[idx][3] = a[idx] + partial_solution[idx-1][0]
    else:
      partial_solution[idx][0] = max(partial_solution[idx-1][2], partial_solution[idx-1][3])
      partial_solution[idx][1] = a[idx] + partial_solution[idx-1][0]
      partial_solution[idx][2] = float('-inf')
      partial_solution[idx][3] = a[idx] + partial_solution[idx-1][2]
  if n%2==0:
    return(max(partial_solution[n-1][2], partial_solution[n-1][3]))
  return(max(partial_solution[n-1][0], partial_solution[n-1][1]))
partial_solution = [[float('-inf') for _ in range(4)] for _ in range(len(a))]
partial_solution[0] = [0, float('-inf'), float('-inf'), a[0]]
# partial_solution[1] = [0, float('-inf'), a[0], a[1]]
# partial_solution[2] = [max(a[:2]), a[2], float('-inf'), a[0]+a[2]]
# partial_solution[3] = [max(a[:3]), a[3], a[0]+a[2], max(a[0]+a[3], a[1]+a[3])]
print(solve(start_point=1))

Measured memory_bytes: 143188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;cin>>t;int i,j,x=1,z;
    int ara[t+1];
    for(i=0;i<t;i++){
        cin>>ara[i];
    }

    for(i=0;i<t;i++)
    {
        if(ara[i]%2==0)
        {
            if(ara[i]%3==0||ara[i]%5==0)
            {
                continue;
            }
            else
            {
                x=0;
                break;
            }

        }
    }
    if(x==1)
        cout<<"APPROVED\n";
    else
        cout<<"DENIED\n";

}


Measured memory_bytes: 256
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MAX 100005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,s,ha[MAX];
long long ANS=0;
struct point{
	int p;
	long long sm;
	bool operator <(const point &other)const{
		return p<other.p;
	}
}a[MAX];
int main()
{
	n=read();s=read();
	for(int i=1;i<=n;i++)
		a[i]=(point){read(),read()};
	sort(a+1,a+n+1);
	int l=1,r=n;
	while(l<r&&a[l].p<s&&a[r].p>s)
		if(a[l].sm>=a[r].sm)
		{
			ha[++ha[0]]=a[r].p;
			a[l].sm+=a[r].sm;
			r--;
		}
		else
		{
			ha[++ha[0]]=a[l].p;
			a[r].sm+=a[l].sm;
			l++;
		}
	if(a[l].p<s)
		for(int i=l;i<=r;i++)
			ha[++ha[0]]=a[i].p;
	else
		for(int i=r;i>=l;i--)
			ha[++ha[0]]=a[i].p;
	ha[n+1]=s;
	for(int i=n;i;i--)
		ANS+=abs(ha[i+1]-ha[i]);
	printf("%lld",ANS);
	return 0;
}

Measured memory_bytes: 5668
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 2e5 + 10;
int f[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    while (m--) {
        int a, b;
        cin >> a >> b;
        if (b == 1 || b == n) swap(a, b);
        if (a == 1 || a == n) {
            if (f[b]) {
                cout << "POSSIBLE";
                exit(0);
            }
            f[b]++;
        }
    }
    cout << "IMPOSSIBLE";
    return 0;
}

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

int n, prm[N], cnt, sum[N], ans, vis[N]; 

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

void init()
{
	for(int i = 2; i <= n; i++)
	{
		if(!vis[i]) vis[i] = 1, prm[++cnt] = i;
		for(int j = 1; i * prm[j] <= n; j++)
		{
			vis[i * prm[j]] = 1;
			if(i % prm[j] == 0) break; 
		}
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), init();
	for(int tmp, i = 2; i <= n; i++)
	{
		tmp = i;
		for(int j = 1; j <= cnt && prm[j] <= i; j++)
			if(!(tmp % prm[j])) while(tmp % prm[j] == 0) sum[prm[j]]++, tmp /= prm[j]; 
	}
	ans = 1;
	for(int i = 1; i <= n; i++) ans = 1ll * ans * (sum[i] + 1) % mod;
	printf("%d\n", ans); 
	return 0; 
}


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

int main()
{
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int gcd(int a, int b);
int main()
{
	int a, b;
	cin >> a >> b;
	cout << gcd(a, b) << endl;
}

int gcd(int a, int b){
	if (b != 0) return (gcd(b, a % b));
	else return (a);
}

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

int main(void){
    ll n;
    cin >> n;
    string ans = "";
    while(n){
        int ama = n % 26;
        if(ama == 0) ama += 26;
        ans = char('a' + (ama - 1)) + ans;
        if(n % 26 == 0) n--;
        n /= 26;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }

  getChildrenNumber() {return (this.left ? 1 : 0 )+ (this.right ? 1 : 0 );}

  isLeftChild() {
    if (this.parent === null) return null;
    return this.parent.left === this;
  }

  getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

  getSuccessor() {
    let n;
    if (this.right !== null) {
      n = this.right;
      while (n.left !== null) n = n.left;
    } else {
      n = this.parent;
      while (!n.isLeftChild && n.parent != null) n = n.parent;
    }
    return n;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    if (this.root === null) {
      this.root = new BinaryTree.Node(key);
      return;
    }
    let x = this.root, y;
    let newNode = new BinaryTree.Node(key);
    while (x !== null) {
      y = x;
      x = x[key < x.key ? 'left' : 'right'];
    }
    newNode.parent = y;
    y[key < y.key ? 'left' : 'right'] = newNode;
  }

  find(key, n = this.root) {
    if (n === null || n.key === key) return n;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  delete(key) {
    const n = this.find(key);
    const leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      const skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  });
})();



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

int main() {
	ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	int n;
	cin>>n;

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

		for(int x = 1; x * x < i; x++) {
			for(int y = 1; y * y < i; y++) {
				int req = i - x*x - y*y - x * y;
				if(req > 0) {
					int low = 1;
					int high = i;
					while(low <= high) {
						int mid = low + (high - low) /2;
						int cal = mid * mid + (x + y) * mid;
						if(cal == req)
							{cnt++; break;}
						else if(cal > req) {
							high = mid - 1;
						} else {
							low = mid + 1;
						}
					}
				}
			}
		}

		cout<<cnt<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3624