akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
typedef pair<in,in> PII;
vector<pair<PII,in> > evt;
vector<PII> rvt;
set<PII> cnu;
VI obv;
multiset<in> bd;
in bssc=0;
VI rbd;
VI bnus;
VI prtof;
VI typof;
VI usd;
void imp(){
  in q;
  cin>>q;
  forn(z,q)
    cout<<"-1\n";
  exit(0);
}
in vlof(in cc){
  cc=lower_bound(all(rbd),cc)-rbd.begin();
  if(cc==sz(bnus))
    return -1;
  in cv=bnus[cc];
  if(cv<0)
    return -1;
  return cv+bssc;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  in a,b;
  rvt.resize(n);
  usd.resize(n);
  forn(z,n){
    cin>>a>>b;
    rvt[z]=MP(b,a);
    if(a<=b){
      obv.PB(a);
      continue;
    }
    evt.PB(MP(MP(a,z),1));
    evt.PB(MP(MP(b,z),0));
  }
  forn(z,n+1){
    cin>>a;
    bd.insert(a);
  }
  bssc=sz(obv);
  forv(i,obv){
    auto it=bd.lower_bound(obv[i]);
    if(it==bd.end()){
      imp();
    }
    bd.erase(it);
  }
  fors(i,bd)
    rbd.PB(*i);
  n=sz(rbd);
  prtof.resize(n,-1);
  typof.resize(n,-1);
  bnus.resize(n);
  const in inf=1e7;
  sort(all(evt));
  in nxev=0;
  in nd;
  obv.clear();
  in bdbl=-1;
  forv(z,rbd){
    nd=rbd[z];
    while(nxev<sz(evt) && evt[nxev].ff.ff<=nd){
      if(evt[nxev].ss==0){
	cnu.insert(MP(rvt[evt[nxev].ff.ss].ss,evt[nxev].ff.ss));
      }
      else{
	if(!usd[evt[nxev].ff.ss]){
	  cnu.erase(evt[nxev].ff);
	  ++bssc;
	  obv.PB(evt[nxev].ff.ss);
	}
      }
      ++nxev;
    }
    if(sz(obv)>0){
      prtof[z]=obv.back();
      typof[z]=1;
      obv.pop_back();
      continue;
    }
    if(sz(cnu)==0){
      if(bdbl!=-1)
	imp();
      bdbl=z;
      continue;
    }
    auto it=cnu.end();
    --it;
    prtof[z]=it->second;
    typof[z]=0;
    usd[it->second]=1;
    cnu.erase(it);
  }
  assert(bdbl!=-1);
  bnus[bdbl]=0;
  for(in i=bdbl+1;i<sz(bnus);++i)
    bnus[i]=-inf;
  in cc;
  for(in i=bdbl-1;i>=0;--i){
    bnus[i]=bnus[i+1];
    if(typof[i]==0){
      cc=rvt[prtof[i]].ss;
      cc=lower_bound(all(rbd),cc)-rbd.begin();
      if(cc<sz(bnus))
	bnus[i]=max(bnus[i],bnus[cc]+1);
    }
  }
  in q;
  cin>>q;
  in ca,cb;
  forn(z,q){
    cin>>ca>>cb;
    in c1=vlof(ca);
    if(c1!=-1)
      ++c1;
    cout<<max(c1,vlof(cb))<<"\n";
  }
  return 0;
}


Measured memory_bytes: 17260
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

int A[200000];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N = getint();
	int saidai = 1;
	rep(i, N) {
		A[i] = getint();
		if (A[i] > saidai) saidai = A[i];
	}
	nth_element(A, A + N / 2, A + N);

	if (N % 2) {
		ll kotae = -A[N / 2] - saidai;
		for (int i = N / 2; i < N; i++) {
			kotae += 2 * A[i];
		}
		printf("%lld\n", kotae);
	}
	else {
		ll kotae = - saidai;
		for (int i = N / 2; i < N; i++) {
			kotae += 2 * A[i];
		}
		printf("%lld\n", kotae);
	}


	Would you please return 0;
}

Measured memory_bytes: 4656
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
  long long a,b,c,n;
  cin>>a>>b>>c>>n;
  long long ans=0;
  rep(i,n+1){
      rep(j,n+1){
          long long tes=n-i*a-j*c;
          if(tes>=0&&tes%b==0){
              ans++;
              //cout<<i<<" "<<j<<endl;
          }
      }
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
string s[50];
int h,w;
int d[]={0,1,0,-1,0};
main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	bool f=0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)
	{
		if(s[i][j]=='.')continue;
		bool flag=1;
		for(int r=0;r<4;r++)
		{
			int tx=i+d[r],ty=j+d[r+1];
			if(tx<0||ty<0||tx>=h||ty>=w)continue;
			flag&=s[tx][ty]=='.';
		}
		f|=flag;
	}
	cout<<(f?"No":"Yes")<<endl;
}


Measured memory_bytes: 256
n, a, b = [int(i) for i in input().split()]
mod = 10**9 + 7
 
total = pow(2, n, mod) - 1
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
 
at = combination(n,a)
bt = combination(n,b)
 
result = total - at - bt
result %= mod
if result < 0:
  result += mod
print(result)

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);
    const char* dayname[] = {
        "Christmas Eve Eve Eve",
        "Christmas Eve Eve",
        "Christmas Eve",
        "Christmas",
    };
    int D; cin >> D;
    cout << dayname[D-22] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

vector<vector<int>> multiply(vector<vector<int>> A, vector<vector<int>> B) {
    int N = A.size();
    vector<vector<int>> res(N, vector<int>(N, 0));

    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++)
            for(int x=0; x<N; x++)
                res[i][j] = (res[i][j] + A[i][x] * B[x][j])%mod;

    return res;
}

vector<vector<int>> power(vector<vector<int>> gr, int K) {
    if(K == 1) return gr;

    vector<vector<int>> res = power(gr, K/2);

    if(K&1) return multiply(gr, multiply(res, res));
    else return multiply(res, res);
}

int solve(vector<vector<int>> gr, int N, int K) {
    vector<vector<int>> res = power(gr, K);
    int ans = 0;
    for(int i=0; i<N; i++)
    for(int j=0; j<N; j++) ans = (ans + res[i][j])%mod;
    return ans;
}

int32_t main() {
    int N, K; cin>>N>>K;
    vector<vector<int>> gr(N, vector<int>(N));
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++) cin>>gr[i][j];

    cout<<solve(gr, N, K)<<endl;
    return 0;
}


Measured memory_bytes: 4956
n,k,s=map(int,input().split())

if k==n:
    answer=' '.join(map(str,[s for i in range(n)]))
else:
    first_part=' '.join(map(str,[s for i in range(k)]))
    if s!=10**9:
        second_part=' '.join(map(str,[s+1 for i in range(n-k)]))
    else:
        second_part=' '.join(map(str,[s-1 for i in range(n-k)]))
    answer=first_part+' '+second_part
print(answer)

Measured memory_bytes: 14232
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;

    int n;
    cin>>n;
    int k=1000;
    while(n>k)
    {
        k+=1000;
    }
    cout<<k-n<<endl;




}



































































Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define for_(i,n) for(int i=0;i<n;++i)
#define for_1(i,n) for(int i=1;i<=n;++i)
const int mod= 1e9 +7;
const int inf=1e7;
int n;
string s;

/*
dp[i][j]:- i th character of permutation is j
we need find sigma over j (dp[n][j])
i range from 0 to n-1

dp[i][j] = dp[i-1][1] + ... +dp[i-1][j-1] if(s[i-1] = '<')
         = dp[i-1][j+1] + ... +dp[i-1][n] if(s[i-1] = '>')
*/
void add_self(int &a, int b)
{
    a+=b;
    if(a>=mod)
    a-= mod;
}


/********************** Recursive Approach ***************************
int dp[3001][3001]; int pre[3001][3001];
int solve(int i, int j){

if(i==1 && j==1){ dp[i][j]=1; return 1;}
//else if(i==1) return 0;
else if(j>i) return 0;
else if(dp[i][j]!=-1) return dp[i][j];
else{
    dp[i][j]=0;
    if(s[i-2]=='<')
    {
        for_1(k,j-1)
        add_self(dp[i][j],solve(i-1,k));
    }
    else if(s[i-2]=='>')
    {
        for(int k=j;k<=n;++k)
        add_self(dp[i][j],solve(i-1,k));
    }
    
   return dp[i][j]; 
}
}

// --------------O(n^3)
*************************************** Recursive Approach ***************/
main()
{
   cin>>n>>s;
   
 /* memset(dp,-1,sizeof(dp));
    int ans=0;
    for_1(i,n)
        add_self(ans,solve(n,i));
    cout<<ans;
 */ 
 
 
 /*********** iterative ***********/
 vector<vector<int>> dpi(n+1,vector<int>(n+1));
 //vector<vector<int>> pref(n+1,vector<int>(n+1));
dpi[1][1]=1;//pref[1][1]=1;

 for(int len =2; len<=n;++len)
 {   
     for(int b =1;b<=len;++b)
     { 
         int l,r;
         if(s[len-2]=='<') l=1,r=b-1;
         else l=b,r=len-1;
         if(l<=r) 
         {
             int tmp = (dpi[len-1][r]+mod-dpi[len-1][l-1])%mod;
             add_self(dpi[len][b],tmp);
         
     
         }
         dpi[len][b] = (dpi[len][b-1] + dpi[len][b]) % mod;
        
         }
 }
/*
int answer = 0;
for(int b = 1; b <= n; ++b) {
    add_self(answer, dpi[n][b]);
    }
    //if extra pref[n+1][n+1] is used
*/
 cout<<dpi[n][n]<<endl;
}





/*
typedef struct structure{
    int x,y;
} pt;
pt p0;
bool cmp(pt a, pt b)
{
    return cw(p0,a,b);
}
bool cw(pt a, pt b, pt c){
    return ((c.y-a.y)*(b.x-a.x)-(b.y-a.y)*(c.x-a.x))>=0
}



convex_hull(vector<pt>& points)
{
   // sort(points.begin(),points.end, cmp);// sorted according to y cordinate
    p0=points[0];
    sort(points.begin(),points.end, cmp);
    vector<pt> convexHull;
    stack<pt> temp;
    convexHull.push_back(points[0]);
    
    temp.push(points[0]);temp.push(points[1]);//temp.push(points[2]);
    pt top,top0;
    for(int it=2;it<points.size();++it)
    {   
        top=temp.top(); temp.pop(); top0=temp.top();
        pt next=points[it];
        if(cw(top0,top,next))
        {
            convexHull.push_back(top);
            temp.push(top);
            top0=top;
            top=next;
        }
        else
        {
          temp.push(next);  
        }
        
    }
    
}*/












Measured memory_bytes: 35584
#include <stdio.h>
#include <math.h>
#define sq(x) (x)*(x)
double heron(double a,double b,double c)
{
	double s,S;
	s = (a+b+c)/2;
	S = sqrt(s*(s-a)*(s-b)*(s-c));
	return S;
}
int main(void)
{
	double x1,y1,x2,y2,x3,y3,xp,yp,AB,AC,BC,AD,BD,CD;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp) != EOF)
	{
		AB = sqrt(sq(x1-x2) + sq(y1-y2));
		BC = sqrt(sq(x2-x3) + sq(y2-y3));
		AC = sqrt(sq(x1-x3) + sq(y1-y3));
		AD = sqrt(sq(x1-xp) + sq(y1-yp));
		BD = sqrt(sq(x2-xp) + sq(y2-yp));
		CD = sqrt(sq(x3-xp) + sq(y3-yp));
		if(heron(AB,BC,AC) <= heron(AB,AD,BD) + heron(BC,BD,CD) + heron(AC,AD,CD) + 0.1 && heron(AB,BC,AC) >= heron(AB,AD,BD) + heron(BC,BD,CD) + heron(AC,AD,CD) - 0.1)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int K;
string S;
string ans = "";

int main(void) {
	cin >> K;
	cin >> S;

	int M = S.size();

	if (M <= K) { ans = S; }
	else { ans = S.substr(0, K) + "..."; }

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	static int map[][]=new int[8][8];
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i,j,n,x,y,k=1;
		n=sc.nextInt();
		while(n--!=0){
			for(i=0;i<8;i++){
				String str=sc.next();
				char ch[]=str.toCharArray();
				for(j=0;j<8;j++){
					map[i][j]=ch[j]-'0';
				}
			}//i
			x=sc.nextInt();
			y=sc.nextInt();
			
			bomb(y-1,x-1);
			
			System.out.printf("Data %d:\n",k++);
			for(i=0;i<8;i++){	
				for(j=0;j<8;j++){
					System.out.print(map[i][j]);
				}
				System.out.println();
			}
		}//while
	}
	public static void bomb(int y,int x){
		map[y][x]=0;
		if(x+1<8 && map[y][x+1]==1){
			bomb(y,x+1);
		}
		if(x+2<8 && map[y][x+2]==1){
			bomb(y,x+2);
		}
		if(x+3<8 && map[y][x+3]==1){
			bomb(y,x+3);
		}
		if(0<=x-1 && map[y][x-1]==1){
			bomb(y,x-1);
		}
		if(0<=x-2 && map[y][x-2]==1){
			bomb(y,x-2);
		}
		if(0<=x-3 && map[y][x-3]==1){
			bomb(y,x-3);
		}
		if(y+1<8 && map[y+1][x]==1){
			bomb(y+1,x);
		}
		if(y+2<8 && map[y+2][x]==1){
			bomb(y+2,x);
		}
		if(y+3<8 && map[y+3][x]==1){
			bomb(y+3,x);
		}
		if(0<=y-1 && map[y-1][x]==1){
			bomb(y-1,x);
		}
		if(0<=y-2 && map[y-2][x]==1){
			bomb(y-2,x);
		}
		if(0<=y-3 && map[y-3][x]==1){
			bomb(y-3,x);
		}
	}//bomb
}

Measured memory_bytes: 12000
//--- pD ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	int mod = (int)1e9+7;

	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}

	private void run_case() {
		// scanner.nextLine();
		String line = scanner.nextLine();

		int K = Integer.parseInt(line.split("\\s+")[1]);

		line = scanner.nextLine();

		int[] dices = strToIntArray(line);

		int[] max_k_arr = findmaxK(dices, K);

		double res = 0.0;
		for (int u: max_k_arr) {
			res += getEV(u);
		}

		System.out.println(res);
		return;
	}

	private double getEV(int n) {
		double res = (1.0 / n) * ( ( (1+n)*n ) / 2.0);
		return res;
	}

	private int[] findmaxK(int[] arr, int k) {
		int sz = arr.length;
		int l = 0, r = k-1;
		int cur_sum = 0;
		for (int i=l; i<=r; i++) cur_sum += arr[i];

		int res_r = 0;
		int res_l = 0;
		int cur_max = 0;
		for (;r < sz ;) {
			if (cur_sum > cur_max) {
				res_l = l;
				res_r = r;
				cur_max = cur_sum;
			}
			cur_sum -= arr[l++];
			r ++;
			if (r < sz) cur_sum += arr[r];
		}

		int[] res = new int[k];
		int idx = 0;
		for (int i=res_l; i<=res_r; i++) {
			res[idx++] = arr[i];
		}
		return res;
	}


	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}

// 1/n * (1+..+n)
// 1/n * ((1+n)*n/2)


Measured memory_bytes: 49988
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let H: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    const INF: i64 = 1e15 as i64;
    let X = {
        let mut X = H.clone();
        X.push(INF);
        X
    };

    let (ans, _, _) = X.iter().fold((0, 0, 0), |(res, c, p), &h| {
        if h <= p {
            (std::cmp::max(res, c), c + 1, h)
        } else {
            (std::cmp::max(res, c), 0, h)
        }
    });

    println!("{}", ans);
}


Measured memory_bytes: 8572
#include <stdio.h>
#include <math.h>

int main (int argc, const char * argv[]) {
    int x,h;
	double s,a;
	
	while (1) {
		scanf("%d%d", &x, &h);
		if (x == h && x == 0) {
			return 0;
		}
		s = 0;
		
		a = sqrt((double)h*(double)h + ((double)x/2)*((double)x/2));
		s += (double)x*(double)x;
		s += (double)x*a*2;
		printf("%f\n", s);
	}
	
    return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class Program
{
    private static long Solve(int N, int K, long[] a)
    {
        long sum = a.Where(n => n > 0).Sum();
        long nsum = 0;
        long psum = 0;
        for (int i = 0; i < K; ++i)
        {
            if (a[i] < 0) { nsum += a[i]; }
            if (a[i] > 0) { psum += a[i]; }
        }
        long nmax = nsum;
        long pmin = psum;
        for (int i = K; i < N; ++i)
        {
            if (a[i - K] < 0) { nsum -= a[i - K]; }
            if (a[i] < 0) { nsum += a[i]; }
            if (a[i - K] > 0) { psum -= a[i - K]; }
            if (a[i] > 0) { psum += a[i]; }
            nmax = Math.Max(nsum, nmax);
            pmin = Math.Min(psum, pmin);
        }
        return Math.Max(sum + nmax, sum - pmin);
    }
    static void Main(string[] args)
    {
        int[] values = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        long[] a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        Console.WriteLine(Solve(values[0], values[1], a));
    }
}


Measured memory_bytes: 17752
#include<stdio.h>
#include<cstring>
using namespace std;
int main()
{
   char s[15];
   scanf("%s",s);
   int num=0;
   if(s[0]!='A')
   {
       printf("WA");
       return 0;
   }
   if(s[1]=='C')
   {
        printf("WA");
       return 0;
   }
   if(s[strlen(s)-1]=='C')
   {
        printf("WA");
       return 0;
   }
    for(int i=0;i<strlen(s);i++)
    {
        if(s[i]=='B'||(s[i]>'C'&&s[i]<='Z'))
        {
             printf("WA");
       return 0;
        }
    }
   for(int i=2;i<strlen(s)-1;i++)
   {
       if(s[i]=='C')
        num++;
   }
   if(num==1)
   {
        printf("AC");
   }

   else printf("WA");

}




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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n, m;
  cin >> n >> m;
  int p[100000], y[100000];
  vector<ll> yd[100001];
  rep(i,m) {
    int pi, yi;
    cin >> pi >> yi;
    p[i] = pi;
    y[i] = yi;
    yd[pi].push_back(yi);
  }
  // 上記コードは1行で済む。
  // rep (i,m) scanf ("%d%d",&p[i],&y[i]), yd[p[i]].push_back(y[i]);
  rep (i,n) sor(yd[i+1]);
  rep (i,m) {
    // vector<ll> ydp = yd[p[i]]; => コピーされるのでNG。TLEを起こす。
    vector<ll>* ydp = &yd[p[i]];
    int index = int(lower_bound(ydp->begin(), ydp->end(), y[i]) - ydp->begin()) + 1;
    printf ("%012lld\n" , ll (p[i])*1000000+index);
  }
  return 0;
}


Measured memory_bytes: 7808
//https://atcoder.jp/contests/abc150/tasks/abc150_d
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

ll lcm(ll num1,ll num2){
    return num1 / __gcd(num1,num2) * num2;
}

int main() {
#if LOCAL&01
    //std::ifstream in("./test/sample-2.in"); //input.txt
    std::ifstream in("input.txt"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif    
    ll N, M; cin>>N>>M;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    ll lcmv=an[0]/2;
    ll lcmv2=an[0];
    FOR(i,1,N){
        lcmv=lcm(lcmv,an[i]/2);
        lcmv2=lcm(lcmv2,an[i]);
    }
    for(auto& a:an){
        ll tmp = lcmv2 / a;
        if (tmp %2 ==0) {
            cout<<0<<endl;
            return 0;
        }
    }
#if 0
    auto test = [&](){
        vector<int> is_lcm(M+1, 0);
        for(auto ak:an){
            ll p=0;
            while (true) {
                auto x = ak * p + ak / 2;
                if (x>M) break;
                is_lcm.at(x)++;
                ++p;    
            }
        }
        vector<ll> o;
        FOR(i,0,M+1){
            if(is_lcm.at(i)==an.size()) o.emplace_back(i);
        }
        dump(o,o.size());
    };
    test();
#endif
    dump(lcmv);
    ll ans=max((M-lcmv)/(lcmv*2),0LL);
    if(M-lcmv>=0) ++ans;
    dump(M-lcmv);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(){
	string s;
	cin >> s;

	int n = s.length();
    int ans[n];
	for(int i = 0; i < n; i++){
        ans[i]=0;
    }

	int cnt = 1;
    int a = 0;
	for(int i = 1; i < n; i++){
		if(s[i] == s[i-1]){
            cnt++;
        }else{
			if(s[i]=='L'){
				ans[i] += cnt/2;
				ans[i-1] += (cnt+1)/2;
				a = i;
			}else{
				ans[a] += (cnt+1)/2;
				ans[a-1] += cnt/2;
			}
			cnt=1;
		}
	}
	ans[a] += (cnt+1)/2;
	ans[a-1] += cnt/2;


	for(int i = 0; i < n; i++){
        cout << ans[i] << " ";
    }
	cout << endl;


	return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

i64 sums[510][510];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, m, Q;
  cin >> n >> m >> Q;
  rep(i, m) {
    int l, r;
    cin >> l >> r;
    sums[l][r]++;
  }
  rep(i, 501) rep(j, 501) sums[i + 1][j] += sums[i][j];
  rep(i, 501) rep(j, 501) sums[i][j + 1] += sums[i][j];
  rep(i, Q) {
    int p, q;
    cin >> p >> q;
    p--;
    cout << sums[q][q] - sums[q][p] - sums[p][q] + sums[p][p] << endl;
  }
  return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> as(n);
    for(int i=0; i<n; i++) cin >> as.at(i);

    map<int, ll> imp, jmp;
    for(int i=0; i<n; i++)
    {
        imp[as.at(i)+i+1]++;
        jmp[-as.at(i)+i+1]++;
    }
    ll ans = 0;
    for(auto itr = imp.begin(); itr != imp.end(); itr++)
    {
        ans += jmp[itr->first] * itr->second;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 38248
//ABC138 C - Alchemist
//20190902

using System;
using System.Linq;
using static System.Math;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            var v = Console.ReadLine().Split().Select(double.Parse).OrderByDescending(x => x).ToList();

            while (v.Count() > 1)
            {
                var a = v.Last();
                v.RemoveAt(v.Count() - 1);

                var b = v.Last();
                v.RemoveAt(v.Count() - 1);

                var avg = Average(a,b);

                v.Add(avg);
            }

            Console.WriteLine(v.Last());

        }


        static double Average(double x, double y)
        {
            return (x + y) / 2.0;
        }
    }
}


Measured memory_bytes: 11476
#include<stdio.h>
int main(){ int i,n,b,c=0,a=0;
scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&b);if(b%2==0){c++;if(b%3==0||b%5==0){a++;}}}
puts(c==a?"APPROVED":"DENIED");              
}


Measured memory_bytes: 1664
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, m, q) = in.readLine.split(" ").map(_.toInt)

  val table = Array.ofDim[Int](n+1, n+1)
  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach { a =>
      table(a(0))(a(1)) += 1
    }

  for {
    i <- 1 to n
    j <- 1 to n
  } {
    table(i)(j) += table(i-1)(j)
    table(i)(j) += table(i)(j-1)
    table(i)(j) -= table(i-1)(j-1)
  }

  val solver = (l:Int, r:Int) =>
    table(r)(r) - table(r)(l-1) - table(l-1)(r) + table(l-1)(l-1)

  val out = new java.io.PrintWriter(System.out)
  Iterator.continually(in.readLine)
    .take(q)
    .map(_.split(" ").map(_.toInt))
    .foreach { a =>
      out.println(solver(a(0),a(1)))
    }
  out.flush
}

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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main()
{
    int n,m;
    map<int,int> mp;
    cin >> n >> m;
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int v;
            cin >> v;
            ++mp[v];
        } 
    }
    int ans = 0;
    for(auto ele: mp){
        if(ele.second == n)++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int p = 100000;
    int ans = 0;
    if(n == 1 && m == 1) {
        cout << 400000+p*2*3 << endl;
        return 0;
    }
    else {
        if(3-n >= 0) {
            ans+=p*(4-n);
        }
        if(3-m >= 0) {
            ans+=p*(4-m);
        }

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

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b)
		if (b < c)
			printf("Yes\n");
		else
			printf("No\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 580
(defun solver ()
  (let* ((r (read)) (g (read)) (b (read)) (num 0))
    (setf num (+ (* 100 r) (* 10 g) (* 1 b)))
    (if (zerop (mod num 4))
        (format t "YES~%")
        (format t "NO~%"))))

(solver)

Measured memory_bytes: 13416
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<string> word(n);
  vector<string> trace(n);
  for(int i=0;i<n;i++)cin >> word.at(i);
  for(int i=0;i<n-1;i++){
    int s=word.at(i).size();
    if(word.at(i)[s-1]!=word.at(i+1)[0]){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      if(word.at(i)==trace.at(j)){
        cout << "No" << endl;
        return 0;
      }
    }
    trace.at(i)=word.at(i);
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define MAX 256

int miku(int x){
	if(x > 36)return 0;
	if(x < 10)return (x + 3)*(x + 2)*(x + 1) / 6;
	if(x > 18)return miku(36 - x);
	if(x > 9 && x < 19)return (x + 3)*(x + 2)*(x + 1) / 6 - (miku(x - 10) * 4);
}

int main(void){
	int n,i = 0;
	int ans[MAX];
	
	while(cin >> n){
		ans[i] = miku(n);
		i++;
	}
	
	for(int j = 0;j < i;j++){
		cout << ans [j] <<endl;
	}

	return 0;
}

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

int main()
{
 long long int test;
 //cin>>test;
 test=1;
 while(test--)
 {
  long long int n,ans=0,minm;
  vector<long long int> arr;
  cin>>n;
  for(int i=0;i<n;i++)
   { long long int x;
   	 cin>>x;
   	 arr.push_back(x);
   	}
   minm=arr[0];
   for(int i=0;i<n-1;i++)
   {
   	if(arr[i+1] < minm)
   		ans+=minm-arr[i+1];
   	else
   		minm=max(minm,arr[i+1]);
   }
   cout<<ans;	
 }
}

Measured memory_bytes: 5348
#include <iostream>

using namespace std;

int main()
{
	const int kNumBuilding = 4;
	const int kNumFloor = 3;
	const int kNumRoom = 10;

	int numResidents[kNumBuilding][kNumFloor][kNumRoom] = {0};

	int numInfo;
	cin >> numInfo;

	int b, f, r, v;
	for(int i = 0; i < numInfo; i++)
	{
		cin >> b >> f >> r >> v;
		numResidents[b - 1][f - 1][r - 1] += v;
	}

	for(int i = 0; i < kNumBuilding; i++)
	{
		if(i != 0)
		{
			cout << "####################" << endl;
		}
		for(int j = 0; j < kNumFloor; j++)
		{
			for(int k = 0; k < kNumRoom; k++)
			{
				cout << ' ' << numResidents[i][j][k];
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3028
#include<iostream>
#include<cmath>
using namespace std;
#define EPS 1e-10
 
double a,b,c,d,e,f,g,h;
double det(){
    double dx1,dy1,dx2,dy2;
    dx1 = a-c;
    dy1 = b-d;
    dx2 = e-g;
    dy2 = f-h;
    return dx1*dy2 - dy1*dx2;
}
int main(){
    int n;
    cin>>n;
    while(n--){
        cin>>a>>b>>c>>d>>e>>f>>g>>h;
        cout<<(fabs(det())<EPS?"YES":"NO")<<endl;
    }
    return 0;
}

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

int main()
{

  char a[10];
  int i,n=0,s=0;
  cin >> a;
  
  a[10] = 0;
  
  for(i=0;i<10;i++)
  {
  if((a[i]=='A')||(a[i]=='G')||(a[i]=='C')||(a[i]=='T'))
  {
  s++;
  }
    if(n<s)
    {
      n=s;
    }
    if((a[i+1]!='A')&&(a[i+1]!='G')&&(a[i+1]!='C')&&(a[i+1]!='T'))
    {
    s=0;
    }
  }
  cout << n << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int p[1010];
int sum[1002010];

int main(void){
	int n,m;

	while(scanf("%d%d",&n,&m) && (n||m)){
		for(int i=0;i<n;i++){
			scanf("%d",&p[i]);
		}
		p[n++] = 0; //0点のスコアを作る

		int size=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				sum[size++] = p[i] + p[j];
			}
		}
		sort(sum,sum+size);

		int ans = 0;

		for(int i=0;i<size;i++){
			int rem = m - sum[i];
			if(rem < 0) continue;
			int left = 0, right = size;

			while(left < right){
				int center = (left + right) / 2;
				if(rem > sum[center]){
					left = center + 1;
				}
				else if(rem < sum[center]){
					right = center;
				}
				else {
					break;
				}
			}

			ans = max(ans, sum[i] + sum[right-1]);
		}

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

	return 0;
}

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

int main(){
  int N,A,B; cin>>N>>A>>B;
  string s; cin>>s;
  
  int b=0,pass=0;
  for(int i=0;i<N;i++){
    if(s[i]=='a'){
      if(pass<A+B){
        pass++;
        cout<<"Yes"<<endl;
      }
      else cout<<"No"<<endl;
    }
    else if(s[i]=='b'){
      if(pass<A+B&&b<B){
        pass++,b++;
        cout<<"Yes"<<endl;
      }
      else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000000 + 7;
const ll INF = LLONG_MAX;
const ll MAX_V = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a%3 == 0|| b %3 == 0 || (a+b)%3 == 0)cout  << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int m;
  cin>>m;
  int n=3*m;

  LL a[n];
  REP(i, n) cin>>a[i];
  sort(a, a+n, greater<LL>());
  LL ans=0;
  REP(i, m){
    ans+= a[2*i+1];
  }
  ECHO(ans);

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;


ll massiv[100010];
ll n;

int main(){
FLASH;
cin>>n;
for(ll i=1;i<=n;i++)
{
  ll x;
  cin>>x;
  massiv[x]=i;
}

for(ll i=1;i<=n;i++)cout<<massiv[i]<<" ";
cout<<endl;





return 0;
} 


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

int main() {
 int n; cin >> n;
 long long sum=0;
 vector<int> d(n);
 for(int i=0;i<n;i++){
   cin >> d[i];
 }
 for(int i=0;i<n;i++){
   for(int j=i+1;j<n;j++){
     sum+=d[i]*d[j];

   }
 }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
using namespace std;
#define MAX 10001
int main(){
    int A[MAX];
    int B[MAX];
    int a;
    int now =0;
    for (int i=0;i<MAX;i++){
        scanf("%d %d",&A[i],&B[i]);
        if(A[i] == 0 && B[i]==0){
            break;
        }else
        {
            now++;
        }
        
    }
    for (int j=0;j<now;j++){
        if(B[j] > A[j]){
            a = A[j];
            A[j] = B[j];
            B[j] = a;
        }
        printf("%d %d\n",B[j],A[j]);
    }
    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    long long int length = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        length += A.at(i);
    }
    long long int hanbun = 0;
    long long int anohan;
    int hanbuni;
    for(int i = 0; i < N; i++) {
        hanbun += A.at(i);
        if(hanbun >= (length + 1) / 2) {
            hanbuni = i;
            anohan = length - hanbun;
            hanbun -= A.at(i);
            break;
        }
    }
    if(hanbun < anohan) {
        hanbun += A.at(hanbuni);
        cout << hanbun - anohan << endl;
    } else {
        anohan += A.at(hanbuni);
        cout << anohan - hanbun << endl;
    }

}

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

int main () {
  ll n, k, ans = 0;
  cin >> n >> k;
  ll a[n];
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  sort(a, a+n);
  if (n < k) {
    k = n;
  }
  for (ll i = 0; i < n-k; i++) {
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while ((line = br.readLine()) != null) {
			long a, b, gcm;
			a = Long.parseLong(line.substring(0, line.indexOf(" ")));
			b = Long.parseLong(line.substring(line.indexOf(" ") + 1));
			gcm = getGCD(a, b);
			System.out.println(gcm + " " + getLCM(a, b, gcm));
		}
	}

	public static long getGCD(long a, long b) {

		long mod;
		long gt = a >= b ? a : b;
		long lt = a <= b ? a : b;

		do {
			mod = gt % lt;
			gt = lt;
			lt = mod;
		} while (mod != 0);

		return gt;
	}

	public static long getLCM(long a, long b, long gcm) {
		return a * b / gcm;
	}
}

Measured memory_bytes: 16876
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long long a[4];
	for (int i = 0; i < 4; i++) {
		cin >> a[i];
	}
	cout << max(max(a[0] * a[2], a[0] * a[3]), max(a[1] * a[2], a[1] * a[3])) << endl;
	return 0;
}

Measured memory_bytes: 3140
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, res = 1;
  cin >> x;
  for(int i = 2; i * i <= x; i++) {
        int a = i * i;
        while(a * i <= x) a *= i;
        res = max(res, a);
    }
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

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

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

    int a[n];
    int c[n-1];
    int ans = 0;
  
    rep(i,n){
      int temp;
      cin >> temp;
      --temp;
      a[i]= temp;
    }
    rep(i,n){
      int b;
      cin >> b;
      ans += b; 
    }
    rep(i,n-1){cin >> c[i];}
    
    rep(i,n){
        if(i != 0 && a[i] == (a[i-1] + 1)){
            ans += c[a[i-1]];
            //cout << i << endl;
            //cout << a[i-1] << endl; 
            //cout << c[a[i-1]] << endl;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans;
        if(N%2==0) ans = N*N/4;
        else ans = (N/2)*(N/2+1);
        System.out.println(ans); 
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
using namespace std;

int main() {
	int A , B;
	cin >> A >> B;
	if (A >= 13) {
		cout << B << endl;
		return 0;
	}
	else if (A >= 6 && A <= 12) {
		cout << B / 2 << endl;
		return 0;
	}
	else {
		cout << '0' << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin>>n;
   int a[n],b[n];
   for(int i = 0; i<n; i++){
       cin>>a[i]>>b[i];
   }
   int sum = 0;
   for(int i = 0; i<n; i++){
       sum = sum+(b[i]-a[i]+1);
   }
   cout<<sum<<endl;
   return 0;
}

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

    int l,r;
    l=x;
    r=x;
    while(1)
    {
        if(m.count(l)==0)
        {
            cout<<l;
            break;
        }
        else if(m.count(r)==0)
        {
            cout<<r;
            break;
        }

        l--;
        r++;
    }

return 0;
}


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

int main() {
  	string s;
  	cin >> s;
  	if (s.size() % 2)
      	return cout << "No" << '\n', 0;
  	for (int i = 0; i < s.size(); i+=2) {
     	if (s[i] != 'h' || s[i + 1] != 'i') 
      		return cout << "No" << '\n', 0;
    }
  
  	cout << "Yes" << '\n';
 	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
typedef pair < int , int > pii;
typedef long long LL;
int n,k;
LL psum[100005];
pii arr[100005];
inline int lbound(int lb,int rb,int tar){
	int mid;
	if(arr[rb].first<tar) return rb+1;
	while(lb<rb){
		mid=((lb+rb)>>1);
		if(arr[mid].first<tar) lb=mid+1; else rb=mid;
	}
	return lb;
}
inline LL gsum(int lb,int rb){
	if(lb>rb) return 0LL;
	return (LL)psum[rb]-(LL)(lb?(LL)psum[lb-1]:0LL);
}
int main(){
	LL res=0;
	scanf("%d%d",&n,&k);
	int xb,x2,cur,kf=0;
	for(xb=0;xb<n;xb++)scanf("%d%d",&arr[xb].first,&arr[xb].second);
	sort(arr,arr+n);
	for(xb=0;xb<n;xb++) psum[xb]=(xb?(LL)((LL)psum[xb-1]+(LL)arr[xb].second):(LL)arr[xb].second);
	int lb=0,rb=n-1;
	for(xb=30;xb>=0;--xb){
		if(rb<0) break;
		cur=1<<xb;
		int first1=lbound(0,rb,cur);
		if(k&cur || xb==0) res=MAX((LL)res,(LL)gsum(0,first1-1));
		if(k&cur && xb==0) res=MAX((LL)res,(LL)gsum(0,rb));
		if(!(k&cur)) rb=first1-1;
		n=rb+1;
		for(x2=0;x2<n;x2++) if(arr[x2].first&cur) arr[x2].first-=cur;
		if(k&cur) k-=cur;
		sort(arr,arr+n);
		for(x2=0;x2<n;x2++) psum[x2]=(x2?(LL)((LL)psum[x2-1]+(LL)arr[x2].second):(LL)arr[x2].second);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll infll = (1LL << 61) - 1;

ll n, ans = infll;

ll func(ll a)
{
    ll r = 0;
    while (a) r++, a /= 10;
    return r;
}

int main()
{
    cin >> n;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i != 0) continue;
        ans = min(ans, max(func(i), func(n / i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define FILE_IN freopen("input.txt", "r", stdin);
#define FILE_OUT freopen("output.txt", "w", stdout);
#define PI acos(-1)
using namespace std;
void fastio()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);
  cout. tie(0);

}
int main() {
 fastio();
    lli f,t,x;
    set<lli>s;
     set<lli>::iterator it;
    cin>>t;
    while(t--) {
        cin>>f>>x;
        if(f==0) {
            s.insert(x);
            cout<<s.size()<<endl;
        }
        else if(f==1)
            cout<<s.count(x)<<endl;

       else
          s.erase(x);
       

}
    return 0;
}


Measured memory_bytes: 12404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

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

    set<string> st;
    rep(_, N){
        string c, s;
        cin >> c >> s;
        if(c=="insert"){
            st.emplace(s);
        }
        else{
            cout << (st.find(s) != st.end() ? "yes" : "no") << '\n';
        }
    }


}


Measured memory_bytes: 29008
n,x,y=map(int,input().split())
ans = [0] * n
x -=1
y -=1
for i in range(n):
    for j in range(i+1,n):
        m = min(j-i,abs(i-x)+1+abs(y-j),abs(i-y)+1+abs(j-x))
        ans[m]+=1
for i in range(1,n):print(ans[i])

Measured memory_bytes: 3444
(n, k), a, f = $<.map{|l| l.to_s.split.map(&:to_i) }
a.sort!
f.sort!
f.reverse!

m = []
n.times do |i|
   m << [a[i] * f[i], f[i]]
end

m.sort_by!{|(af, _)| -af }

ma = m[0][0]
ans = (0 .. ma).bsearch do |x|
  
  k_x = 0
  m.each do |(m_i, f_i)|
    break if m_i <= x
    k_x += ( m_i - x + f_i - 1 ) / f_i
  end
  
  k_x <= k
end

puts ans

Measured memory_bytes: 41140
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int a,b;

signed main(void) {
    cin >> a >> b;
    cout << a-b+1 << endl;

    return 0;
}


Measured memory_bytes: 256