akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>  
using namespace std;  
#define int long long

int ans=0;
string s;

int convert(string str)
{
    stringstream geek(str); 
    int x = 0; 
    geek >> x; 
  	return x;
}

string substr(int i,int j)
{
	string str = "";
	for(int k=i;k<=j;k++)
	{
		str += s[k];
	}
	return str;
}

void cal(int data[],int r)
{
	string strr = substr(0,data[0]-1);
	int vall = convert(strr);
	ans += vall;
	for(int i=0;i<r;i++)
	{
		 if(i==(r-1))
		{
			string str = substr(data[i],s.size()-1);
			int val = convert(str);
			ans += val;
		}
		else
		{
			string str = substr(data[i],data[i+1]-1);
			int val = convert(str);
			ans += val;
		}
	}
}
void combinationUtil(int arr[], int data[],  
                    int start, int end,  
                    int index, int r);  
  
 
void printCombination(int arr[], int n, int r)  
{  
    
    int data[r];  
    combinationUtil(arr, data, 0, n-1, 0, r);  
}  
  

void combinationUtil(int arr[], int data[],  
                    int start, int end,  
                    int index, int r)  
{  
    if (index == r)  
    {  
		cal(data,r);
        return;  
    }  
  
    for (int i = start; i <= end &&  
        end - i + 1 >= r - index; i++)  
    {  
        data[index] = arr[i];  
        combinationUtil(arr, data, i+1,  
                        end, index+1, r);  
    }  
}  
  
int32_t main()  
{  
    cin >> s;
    int val = convert(s);
    ans += val;
    int arr[15]; 
    for(int i=1;i<=s.size()-1;i++)
    {
    	arr[i-1]=i;
	}
    int n = s.size()-1; 
    for(int i=1;i<=n;i++)
    {
    	printCombination(arr, n, i);  
	}
    cout << ans << endl;
}  

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

int main(){
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];
    vector<int> a(n, INT_MAX);
    rep(i,n-1){
        a[i] = min(a[i], b[i]);
        a[i+1] = b[i];
    }
    cout << accumulate(a.begin(), a.end(),0) << endl;
}



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

using namespace std;

int main(){

	int n, d, ans;

	cin>> n >> d;

	ans=n/(2*d+1);
	if(n!=ans*(2*d+1)) ans++;

	cout<< ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int main() {
    const int HEIGHT = 3;
    const int WEIGHT = 3;

    vector<vector<int> > mat(WEIGHT, vector<int>(HEIGHT));

    for(int i = 0; i < HEIGHT; i++) {
        int num1, num2, num3;
        scanf("%d %d %d", &num1, &num2, &num3);
        mat.at(i).at(0) = num1;
        mat.at(i).at(1) = num2;
        mat.at(i).at(2) = num3;
    }

    bool flag = true;
    int rowDiff[WEIGHT - 1];
    rowDiff[0] = mat.at(0).at(0) - mat.at(0).at(1);
    rowDiff[1] = mat.at(0).at(1) - mat.at(0).at(2);
    
    for(int i = 1; i < HEIGHT; i++) {
        if(mat.at(i).at(0) - mat.at(i).at(1) != rowDiff[0] ||
           mat.at(i).at(1) - mat.at(i).at(2) != rowDiff[1] ) {
               flag = false;
               break;
           }
    }

    int columnDiff[HEIGHT - 1];
    columnDiff[0] = mat.at(0).at(0) - mat.at(1).at(0);
    columnDiff[1] = mat.at(1).at(0) - mat.at(2).at(0);
    
    for(int i = 1; i < WEIGHT; i++) {
        if(mat.at(0).at(i) - mat.at(1).at(i) != columnDiff[0] ||
           mat.at(1).at(i) - mat.at(2).at(i) != columnDiff[1] ) {
               flag = false;
               break;
           }
    }
    
    if(flag) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i;
  int n;
  char s[50];
  int count=0;
  scanf("%d",&n);
  scanf("%s",s);
  for(i=0;i<n-2;i++){
    if(s[i]=='A' && s[i+1] =='B'&& s[i+2] =='C'){
      count=count+1;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL n;
int res;

void go(LL k, bool a, bool b, bool c) {
  if (k > n) return;
  if (a&&b&&c) {
    res++;
  }
  go(k*10 + 3, true, b, c);
  go(k*10 + 5, a, true, c);
  go(k*10 + 7, a, b, true);
}

void init() {

}

void input() {

}

void solve() {
  cin >> n;
  res = 0;
  go(0, false, false, false);
  cout << res << endl;

}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
n = int(input())
l = input().split()

for i in range(n):
	l[i] = int(l[i])
	
counting = 0
i = 0
#print(n)
while i < n-1:
	if l[i] == i+1:
		k = l[i]
		m = l[i+1]
		l[i] = m
		l[i+1] = k
		counting += 1
		#print(l)
	i += 1
#print(n)		
if l[n-1] == n:
	l[n-1] = l[n-2]
	l[n-2] = n
	counting += 1
#print(l)	
print(counting)

Measured memory_bytes: 10612
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007


int main()
{
  int N;
  lli ans=0,hold,mi=922337203685477587;
  int in=0;
  cin >> N;
  rep(i, N){
  cin >> hold;
    if(hold<0){
      hold*=-1;
      in++;
    }
    mi = min(mi,hold);
    ans+=hold;
  }
  if(in%2==0){
  cout << ans << endl;
  }  
  else {
  cout << ans-2*mi<< endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    X=int(input())
    ans=0
    for i in range(1,int(1000*0.5)):
        for j in range(2,15):
            if i**j<=X:
                ans=max(ans,i**j)
    print(ans)    
resolve()

Measured memory_bytes: 39408
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 105
#define M 5000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

const int inf=(int)1e9;

int i,j,m,n,p,k,st,ed,k1=1,fox[N*N*2],Que[N*N*2],dis[N*N*2],Q[N*N*2];

int sx,ex,sy,ey;

struct Node{
	int ed,before,flow;
}s[M];

char c[N][N];

int ID(int x,int y,int z)
{
		return x*m+y+z*n*m; 
}

void add(int x,int y,int flow)
{
	s[++k1].ed=y; s[k1].before=fox[x]; fox[x]=k1; s[k1].flow=flow;
	s[++k1].ed=x; s[k1].before=fox[y]; fox[y]=k1; s[k1].flow=0;
}
int bfs()
{
   Q[Q[0]=1]=st; memset(dis,-1,sizeof(dis));
   dis[st]=0;
   int l=1,i;
   for (;l<=Q[0]&&dis[ed]==-1;++l)
  {
        int p=Q[l];
        for (i=fox[p];i;i=s[i].before)
          if (s[i].flow&&dis[s[i].ed]==-1)
            {
            	dis[s[i].ed]=dis[p]+1;
            	Q[++Q[0]]=s[i].ed;
			}
  }
  return dis[ed]!=-1;
}
int dfs(int x,int flow)
{
	if (x==ed) return flow;
	int i; int nowans=0,a;
	for (i=fox[x];i&&flow;i=s[i].before)
	  if (dis[s[i].ed]==dis[x]+1&&s[i].flow)
	  {
	  		   a=dfs(s[i].ed,min(flow,s[i].flow));
	  		   if (a) 
	  		   	{
	  		   		nowans+=a;
	  		   		flow-=a;
	  		   		s[i].flow-=a;
	  		   		s[i^1].flow+=a;
				}
	  }
	 if (!nowans) dis[x]=(int)1e9;
	 return nowans;
}
int maxflow()
{
   int ans=0,j;
   while (bfs()) ans+=dfs(st,inf); 
   return ans;
}

int main()
{
		scanf("%d%d",&n,&m);
		for (i=0;i<n;++i) scanf("%s",c[i]); st=n*m*2; ed=st+1;
		for (i=0;i<n;++i)
			for (j=0;j<m;++j)
				if (c[i][j]!='.')
			{
					if (c[i][j]=='o')
					add(ID(i,j,0),ID(i,j,1),1);
					else add(ID(i,j,0),ID(i,j,1),inf);
					for (k=j-1;k>=0;--k) if (c[i][k]!='.') //break;  
					if (k>=0) add(ID(i,j,1),ID(i,k,0),inf);
					for (k=j+1;k<m;++k)  if (c[i][k]!='.') //break;
					if (k<m)  add(ID(i,j,1),ID(i,k,0),inf);
					for (k=i-1;k>=0;--k) if (c[k][j]!='.') //break;
					if (k>=0) add(ID(i,j,1),ID(k,j,0),inf);
					for (k=i+1;k<n;++k)  if (c[k][j]!='.') //break;
					if (k<n)  add(ID(i,j,1),ID(k,j,0),inf);
					if (c[i][j]=='S') add(st,ID(i,j,0),inf),sx=i,sy=j;
					if (c[i][j]=='T') add(ID(i,j,1),ed,inf),ex=i,ey=j;
			}
			if (sx==ex||sy==ey) printf("-1\n");
			else 
			cout<<maxflow()<<endl;
}


Measured memory_bytes: 47616
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::VecDeque;

fn main() {
    input!{
        k: usize
    }
    let mut q = VecDeque::new();
    q.push_back(1);
    let mut d = vec![k + 1; k];
    d[1] = 1;
    while let Some(v) = q.pop_front() {
        if v == 0 {
            println!("{}", d[v]);
            return;
        }
        if d[(v + 1) % k] > d[v] + 1 {
            d[(v + 1) % k] = d[v] + 1;
            q.push_back((v + 1) % k);
        }
        if d[v * 10 % k] > d[v] {
            d[v * 10 % k] = d[v];
            q.push_front(v * 10 % k);
        }
    }
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007


int n,q;

int main(){
  int ans = 0;
  cin >> n;
  vector<int> s(n);
  for(int i = 0; i < n; ++i) cin >> s[i];
  cin >> q;
  vector<int> t(q);
  for(int i = 0; i < q; ++i){
    cin >> t[i];
    int l1 = 0,r1 = n-1,p;
    for(int j = 0; j < 25; j++){
      p = (l1+r1)/2;
      if(s[l1]==t[i]||s[r1]==t[i]){
        ans++;
        break;
      }
      if(r1 == l1) break;
      if(s[p] > t[i]){
        r1 = p;
      }else{
        l1 = p;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <stdlib.h>

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

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cnt=0;
    string ans;
    queue<string> q;
    q.push("1");
    q.push("2");
    q.push("3");
    q.push("4");
    q.push("5");
    q.push("6");
    q.push("7");
    q.push("8");
    q.push("9");
    cnt = 9;
    if(n <= 9)
    {
        cout << n << endl;
        return 0;
    }
    while(!q.empty())
    {
        string s = q.front(); q.pop();
        int tmp = s.size()-1;
        char c = s[tmp];
        char c1, c2;
        c1 = c-1;
        c2 = c+1;
        string tmst1, tmst2;
        tmst1 = s;
        tmst1 += c1;
        tmst2 = s;
        tmst2 += c2;
        if(c!='0')
        {
            q.push(tmst1);
            cnt++;
            if(cnt == n)
            {
                ans=tmst1;break;
            }
        }
        s += c;
        q.push(s);
        cnt++;
        if(cnt == n)
        {
            ans = s;
            break;
        }
        if(c!='9')
        {
            q.push(tmst2);
            cnt++;
            if(cnt == n)
            {
                ans = tmst2;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 4736
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

void solve() {
    int n,a[3];
    cin >> n >> a[0] >> a[1] >> a[2];
    VS s(n);
    REP(i,0,n) cin >> s[i];
    vector<char> cs;
    REP(i,0,n) {
        if (a[s[i][0]-'A'] == 0 && a[s[i][1]-'A'] == 0) {
            cout << "No" << endl;
            return;
        }
        if (a[s[i][0]-'A'] == 0) {
            a[s[i][0]-'A']++;
            a[s[i][1]-'A']--;
            cs.push_back(s[i][0]);
        } else if (a[s[i][1]-'A'] == 0) {
            a[s[i][1]-'A']++;
            a[s[i][0]-'A']--;
            cs.push_back(s[i][1]);
        } else if (i == n - 1 || (a[s[i][0]-'A'] > 1 && a[s[i][1]-'A'] > 1)) {
            a[s[i][0]-'A']++;
            a[s[i][1]-'A']--;
            cs.push_back(s[i][0]);
        } else {
            if (s[i+1][0] == s[i][0] || s[i+1][1] == s[i][0]) {
                a[s[i][0]-'A']++;
                a[s[i][1]-'A']--;
                cs.push_back(s[i][0]);
            } else {
                a[s[i][1]-'A']++;
                a[s[i][0]-'A']--;
                cs.push_back(s[i][1]);
            }
        }
    }
    cout << "Yes" << endl;
    for (char c: cs) cout << c << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 6736
#include<bits/stdc++.h>
using namespace std;
int n,nn,ans[1010101],nm[1010101],cc[1010101][3],tg[1010101],tt=1;
string s;
void ii(int x)
{
	int nw=1,y=x;
	for(int i=n;i>=1;i--,x/=3)
	{
		int nww=x%3;
		if(!cc[nw][nww])
		{
			tt++;
			cc[nw][nww]=tt;
		}
		nw=cc[nw][nww];
	}
	nm[nw]=y+1;
}
void gx(int x)
{
	swap(cc[x][1],cc[x][2]);
	tg[x]=0;
	for(int i=0;i<3;i++)
	{
		tg[cc[x][i]]^=1;
	}
}
void jj()
{
	int nw=1;
	for(int i=1;i<=n;i++)
	{
		if(tg[nw])
		{
			gx(nw);
		}
		swap(cc[nw][0],cc[nw][2]);
		swap(cc[nw][1],cc[nw][2]);
		nw=cc[nw][0];
	}
}
void dfs(int x,int pp,int pw)
{
	if(tg[x])
	{
		gx(x);
	}
	if(nm[x]>0)
	{
		ans[nm[x]-1]=pp;
		return;
	}
	for(int i=0;i<3;i++)
	{
		dfs(cc[x][i],pp+i*pw,pw*3);
	}
}
int main()
{
	cin>>n>>s;
	nn=1;
	for(int i=1;i<=n;i++)
	{
		nn*=3;
	}
	for(int i=0;i<nn;i++)
	{
		ii(i);
	}
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='S')
		{
			tg[1]^=1;
		}
		else
		{
			jj();
		}
	}
	dfs(1,0,1);
	for(int i=0;i<nn;i++)
	{
		cout<<ans[i]<<' ';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 22008
#include <bits/stdc++.h>
#define N 200010
using namespace std;
int n, a[N], b[N];
bool S(int i, int j, int k) {
	return a[i] <= k && a[j] <= k;
}
bool B(int i, int j, int k) {
	return a[i] > k && a[j] > k; 
}
int chk(int k) {
	for (int i = 0; i < n - 1; ++i) {
		if (B(n + i, n + i + 1, k) || B(n - i, n - i - 1, k)) return 0;
		if (S(n + i, n + i + 1, k) || S(n - i, n - i - 1, k)) return 1;
	}
	return S(1, 1, n);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n - 1; ++i) scanf("%d", &a[i]);
	int l = 1, r = 2 * n - 1, ans = 0;
	for (; l < r; ) {
		int mid = (l + r) / 2;
		if (chk(mid)) {
			r = mid;
		} else l = mid + 1;
	}
	printf("%d", r);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

template <class T> inline bool chmax(T& a, T b){
    if(a < b){a = b; return true;}
    return false;
}
template <class T> inline bool chmin(T& a, T b){
    if(a > b){a = b; return true;}
    return false;
}



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~






std::vector<int> C;
std::vector<std::pair<long double, long double>> A;

int main(void){
    int n; scanf("%d", &n);
    A.resize(n);
    REP(i, n){
        scanf("%Lf%Lf", &A[i].first, &A[i].second);
    }
    C.resize(n); REP(i, n) C[i] = i;
    long double res = 0;
    do{
        long double x = A[C[0]].first, y = A[C[0]].second;
        for(int i = 1; i < n; ++i){
            long double nx = A[C[i]].first, ny = A[C[i]].second;
            res += sqrt((nx - x) * (nx - x) + (ny - y) * (ny - y));
            x = nx; y = ny;
        }
    }while(std::next_permutation(C.begin(), C.end()));
    for(int x = 2; x <= n; ++x) res /= x;
    printf("%.16Lf\n", res);

    


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int W,a,b;
  cin >> W >> a >> b;
  if (b >= a && b <= a+W || b+W >= a && b <= a) {
    cout << 0;
  } else {
    cout << min(abs(b-a),min(abs(b+W-a),abs(b-W-a)));
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main(){
  int n, R[MAX];
  cin >> n;

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

  int maxv = R[1] - R[0];
  int minv = R[0];

  for(int i = 1; i < n; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vs v(n); cin >> v;
	vi cnt(26, 10000);
	for (auto s : v)
	{
		vi t(26);
		for (auto c : s) t[c - 'a']++;
		REP(i, 26) chmin(cnt[i], t[i]);
	}
	string ans;
	REP(i, 26)
	{
		REP(j, cnt[i]) ans += char('a' + i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        int color[] = new int[9];
        for (int c=0;c<9;c++){
            color[c]=0;
        }
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
            if (a[i] <= 399){
                color[0] = 1;
            }else if (a[i] <= 799){
                color[1] = 1;
            }else if (a[i] <= 1199){
                color[2] = 1;
            }else if (a[i] <= 1599){
                color[3] = 1;
            }else if (a[i] <= 1999){
                color[4] = 1;
            }else if (a[i] <= 2399){
                color[5] = 1;
            }else if (a[i] <= 2799){
                color[6] = 1;
            }else if (a[i] <= 3199){
                color[7] = 1;
            }else if (a[i] >= 3200){
                color[8]++; 
            }
        }
        int min = 0,max = 0;
        for(int i=0;i<8;i++){
            if(color[i]==1){
                min++;
            }
        }
        max = min + color[8];
        if (min == 0){
            min = 1;
        }
        System.out.println(min + " " + max);
        
    }
    
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
int p[100100];
int x[100100], y[100100];

class UnionFind {
private:
    static const int MAX = 100100;
    int par[MAX];
    int r[MAX];
public:
    UnionFind(int n = MAX) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            r[i] = 0;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (r[x] < r[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (r[x] == r[y]) r[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int solve() {
    UnionFind uf(n);
    for (int i = 0; i < m; i++) uf.unite(x[i], y[i]);
    unordered_set<int> s0[n];
    unordered_set<int> s1[n];
    for (int i = 0; i < n; i++) {
        int j = uf.find(i);
        s0[j].insert(i);
        s1[j].insert(p[i]);
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int u : s0[i]) {
            if (s1[i].count(u) > 0) res++;
        }
    }
    return res;
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> vec;
    for(int i=0;i<h+2;i++){
        string s;
        if ((i==0) || (i==h+1)){
            string str(w+2,'#');
            s = str;
        }else{
            string tmp;
            cin >> tmp;
            s = '#' + tmp + "#";
        }
        vec.push_back(s);
    }
    for(int i=0;i<h+2;i++) cout << vec[i] << endl;
    
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint N,M,V,P;
    cin >> N >> M >> V >> P;
    lint A[N];
    rep(i,N) cin >> A[i];
    sort(A,A+N,greater<lint>());
    lint border=A[P-1];
    lint ans=P;
    lint lim=N-1;
    lint nokori=V-(P-1); // rank out
    lint acum=border;
    lint dec=N-V;
    for(int i=P;i<N;i++){
        if(border-A[i]>M) break;
        lint need=acum-A[i]*(i-P+1);
        if((need+dec-1)/dec<=M) ans++;
        acum+=A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 300010
#define ll long long
using namespace std;
int n,a,b,f[maxn];
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if(a+b-1>n||(ll)a*b<n) {puts("-1");return 0;}
	int cnt=0,lst=b;
	f[0]=1-b;
	for(int i=1;i<=n-a;i++)
		if(cnt==0)
			cnt=min(n-i-a+1,b-1),f[i]=f[i-1]+b+cnt,a--;
		else cnt--,f[i]=f[i-1]-1;
	for(int i=n-a+1;i<=n;i++)
		f[i]=i;
	for(int i=1;i<=n;i++)
		cout<<f[i]<<' ';
    return 0;
}


Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n ,m ; cin >>n>>m;
  vector<ll> x(m);
  rep(i,m)  cin >>x[i];
  sort(all(x));
  vector<ll> y(m-1);
  rep(i,m-1) y[i]=x[i+1]-x[i];
  sort(all(y));
  if(n>=m) {
    cout <<0<<endl;
    return 0;
  }
  int key=0;
  rep(i,n-1) key+=y[m-2-i];
  cout <<x[m-1]-x[0]-key<<endl;
}

Measured memory_bytes: 1792
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD  = 1000000007;
	constexpr ll MOD9 = 1000000009;

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	void init(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}
using namespace atcoder;
#endif

int Q;
ll calc(intv& A, intv& a, intv& b, intv& c, intv& d){
	ll sum=0;

	for(int i=0;i<Q;i++){
		if(A[b[i]-1]-A[a[i]-1]==c[i]) sum+=d[i];
	}
	return sum;
}

int main(){
	//init();

	int N,M;cin>>N>>M>>Q;
	intv a(Q),b(Q),c(Q),d(Q);

	for(int i=0;i<Q;i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	
	intv A;
	for(int i=0;i<N;i++) A.push_back(1);
	

	ll ans=0;
	ans=max(ans,calc(A,a,b,c,d));
	
	if(M!=1)
	while(true){
		//cout<<"A: ";out(A);
		
		int index=N-1;
		while(index!=-1){
			if(A[index]==M) index--;
			else break;
		}
		if(index==-1) break;

		//cout<<"index = "<<index<<endl;

		A[index]++;
		for(int i=index+1;i<N;i++){
			A[i] = A[index];
		}

		ans=max(ans,calc(A,a,b,c,d));
	}
	cout<<ans;

}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <iomanip>

int main(int argc, char const* argv[])
{
	int n{};
	std::cin >> n;
	while (n) {
		std::vector<int> table{};
		for (int i = 0; i < n * n; i++) {
			int d;
			std::cin >> d;
			table.push_back(d);
		}
		for (int i = 0; i < n; i++) {
			auto hsum = 0;
			for (int j = 0; j < n; j++) {
				auto current = table[i * n + j];
				hsum += current;
				std::cout << std::setw(5) << std::right << current ;
			}
			std::cout << std::setw(5) << std::right << hsum;
			std::cout << std::endl;
		}
		int sum{};
		for (int i = 0; i < n; i++) {
			auto vsum = 0;
			for (int j = 0; j < n; j++) {
				auto current = table[j * n + i];
				vsum += current;
			}
			std::cout << std::setw(5) << std::right << vsum;
			sum += vsum;
		}
		std::cout << std::setw(5) << std::right << sum;
		std::cout << std::endl;
		std::cin >> n;
	}

	return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<list>
#include<queue>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  list<int> E[N];
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; a--; b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  int S[N]; for (int i = 0; i < N; i++) S[i] = -1;
  bool visited[N]; for (int i = 0; i < N; i++) visited[i] = false;
  queue<int> Q; Q.push(0); visited[0] = true;
  while (!Q.empty()) {
    int v = Q.front(); Q.pop();
    for (auto it = E[v].begin(); it != E[v].end(); it++) {
      if (!visited[*it]) {
        visited[*it] = true;
        S[*it] = v; Q.push(*it);
      }
    }
  }
  bool exists = true;
  for (int i = 1; i < N; i++) {
    if (S[i] == -1) exists = false;
  }
  if (exists) {
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
      cout << S[i]+1 << endl;
    }
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 19084
#include<iostream>

using namespace std;

int main(void){
  
  int n = 0;
  cin >> n;
  
  switch(n){
    case 22: cout << "Christmas Eve Eve Eve" << endl; break;
    case 23: cout << "Christmas Eve Eve" << endl; break;
    case 24: cout << "Christmas Eve" << endl; break;
    case 25: cout << "Christmas" << endl;
  }   
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string s = Console.ReadLine();
            string t = Console.ReadLine();
            string ans = "No";
            if (s == t) { ans = "Yes"; }
            else
            {
                for (int i = 1; i < s.Length; i++)
                {
                    if (s.Substring(s.Length - i) + s.Substring(0, s.Length - i) == t)
                    {
                        ans = "Yes";
                        break;
                    }
                }
            }

            Console.WriteLine(ans);
            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {
        
    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 11092
package main

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

func solve() {
	s := func() []int {
		rs := getRunes()
		ret := make([]int, len(rs))
		for i, r := range rs {
			ret[i] = int(r - '0')
		}
		return ret
	}()
	n := len(s)

	ans := 0
	for bit := 0; bit < (1 << uint(n-1)); bit++ {
		cursor := 0
		for i := 1; i <= n; i++ {
			if (bit&(1<<uint(i-1))) > 0 || i == n {
				ans += f(s[cursor:i])
				cursor = i
			}
		}
	}

	fmt.Fprintln(wr, ans)
}

func f(ns []int) int {
	ret := 0
	keta := 1
	for i := len(ns) - 1; i >= 0; i-- {
		ret += ns[i] * keta
		keta *= 10
	}
	return ret
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
# problem C

sx, sy, tx, ty = map(int, input().split())

w = tx - sx
h = ty - sy

str1 = "R" * w + "U" * h + "L" * w + "D" * h
str2 = "D" + "R" * (w + 1) + "U" * (h + 1) + "L" + "U" + "L" * (w + 1) +"D" * (h + 1) + "R"
print(str1 + str2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int check[]={5,7,5,7,7};

int main(){
  int n;
  while(cin >> n, n){
    vector<string> s(n);
    for(int i=0;i<n;i++)
      cin >> s[i];
    int ans=0;
    for(int f=0;f<n;f++){
      int p=f;
      bool ok=true;
      for(int k=0;k<5;k++){
	int nowl=0;
	while(nowl<check[k]){
	  nowl+=s[p].size();
	  p++;
	} 
	if(nowl!=check[k])
	  ok=false;
      }
      if(ok){
	ans=f+1;
	break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3160
#abc159 b

import itertools
from math import factorial
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7

#ここから書き始める
s = input()
c1 = False
c2 = False
c3 = False
n = len(s)

s2 = s[:(n - 1) // 2]
s3 = s[(n + 3) // 2 - 1:]

if s == s[::-1]:
    c1 = True

if s2 == s2[::-1]:
    c2 = True

if s3 == s3[::-1]:
    c3 = True

if c1 and c2 and c3:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v;
  ll s = 0;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
    s ^= a;
  }

  ll ret = s;
  rep(i,N){
    v[i] &= ~s;
  }
  
  int r = 0;
  for(int i=61; i>=0; i--){
    bool ok = false;
    REP(j,r,N){
      if(v[j]>>i&1){
        ok = true;
        swap(v[r],v[j]);
        break;
      }
    }
    if(!ok) continue;

    rep(j,N){
      if(j==r) continue;
      if(v[j]>>i&1){
        v[j] ^= v[r];
      }
    }
    r++;
  }
  ll t = 0;
  rep(i,N){
    t ^= v[i];
  }
  ret += t + t;

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 1528
a,b,x = gets.split(' ').map(&:to_i)

if b-2*x.to_f/(a*a) <= 0
  puts Math.atan2((b-x.to_f/(a*a))*2, a) * 180 / Math::PI
else
  puts Math.atan2(b, 2.0*(a*(x.to_f / (a * a).to_f)).to_f/b.to_f) * 180 / Math::PI
end
  

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int n;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=9;++i){
        for(int j=i;j<=9;++j){
            if(i*j==n){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
}

Measured memory_bytes: 256
N,K = map(int,input().split())
h = [int(input()) for i in range(N)]
h.sort()
Max = []
Min = []
ans = 999999999999999
for i in range(N-K+1): #N個のうちK個の連続する数の区間はN-K+1個だけ作れる
    Max.append(i+K-1) #ソートされたある区間での最大値はi+K-1
    Min.append(i)     #ソートされたある区間での最小値はi
for i in range(N-K+1):
    ans = min(ans,h[Max[i]] - h[Min[i]])
print(ans)

Measured memory_bytes: 15436
n,d,a = map(int,input().split())
XH = []
for _ in range(n):
    x,h = map(int,input().split())
    h = (h+a-1)//a
    XH.append([x,h])
ans = 0
XH.sort()
p = 0
j = 0
data = []
for i in range(n):
    while XH[i][0] > XH[j][0] + 2*d:
        p -= data[j]
        j += 1
    p_i = max(XH[i][1]-p,0)
    data.append(p_i)
    ans += p_i
    p += p_i

print(ans)

Measured memory_bytes: 85608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(v) cout << #v << ":\t" << v << "\n"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 1e2 + 3;

ll w, h, x, y;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(6);
	
	cin >> w >> h >> x >> y;
	cout << w * h / ld(2) << " ";
	cout << (x == ld(w)/2 && y == ld(h)/2 ? 1 : 0);
	
	return 0;
}


Measured memory_bytes: 256
import math

def sqdist(a,b):
	temp = 0
	for i in xrange(len(a)):
		temp += (a[i] - b[i])**2
	return temp

n,d = map(int,raw_input().split())
x = []
for i in xrange(n):
	x.append(map(int,raw_input().split()))

res = 0
for i in xrange(n-1):
	for j in xrange(i+1,n):
		dist = sqdist(x[i],x[j])
		if math.sqrt(dist) == math.floor(math.sqrt(dist)):
			res += 1
print res

Measured memory_bytes: 2692
N,a,b = (int(i) for i in input().split())
sum = 0
for i in range(N):
    order = 0
    temp = i+1
    while temp > 0:
        order += temp%10
        temp = (temp - (temp%10)) /10
    if order >= a and order <= b:
        sum += i+1
print(sum)
        
        

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int counter = 1;
  if(a != b)
    counter ++;
  if(a !=c && b != c)
    counter ++;
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define INF 1000000000000001LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w;
ll dp[55][55];
ll dp2[55][55][55][55];
string str[51];
vector<P> G[55][55];


int tencnt(ll x){
	int cnt=0;
	while(x>0LL){
		x/=10LL;
		cnt++;
	}
	return cnt;
}

ll mul(ll x,ll y){
	int cnt=tencnt(x)+tencnt(y);
	if(cnt>=17)return INF;
	return min(x*y,INF);
}

ll calc(int y,int x){
	dp2[y][x][y][x]=(ll)(str[y][x]-'0');
	for(int i=0;i<G[y][x].size();i++){
		ll ny=G[y][x][i].first;
		ll nx=G[y][x][i].second;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(dp2[ny][nx][i][j]>0LL){
					dp2[y][x][i][j]=max(dp2[y][x][i][j],mul(dp2[y][x][y][x],dp2[ny][nx][i][j]));
				}
			}
		}
	}
}

ll func(int y,int x){
	if(dp[y][x]!=-1)return dp[y][x];
	if(y==h-1 && x==w-1)return (ll)(str[y][x]-'0');
	ll res=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(dp2[y][x][i][j]>0){
				ll val=dp2[y][x][i][j];
				res=max(res,val);
				if(i<h-1 && str[i+1][j]=='+'){
					if(i<h-2)res=max(res,val+func(i+2,j));
					if(i<h-1 && j<w-1)res=max(res,val+func(i+1,j+1));
				}
				if(j<w-1 && str[i][j+1]=='+'){
					if(j<w-2)res=max(res,val+func(i,j+2));
					if(i<h-1 && j<w-1)res=max(res,val+func(i+1,j+1));
				}
			}
		}
	}
	res=min(res,INF);
	dp[y][x]=res;
	return dp[y][x];
}

int main(void){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		cin >> str[i];
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(str[i][j]=='*'){
				if(i>0){
					if(i<h-1)G[i-1][j].push_back(P(i+1,j));
					if(j<w-1)G[i-1][j].push_back(P(i,j+1));
				}
				if(j>0){
					if(j<w-1)G[i][j-1].push_back(P(i,j+1));
					if(i<h-1)G[i][j-1].push_back(P(i+1,j));
				}
			}
		}
	}
	memset(dp2,0,sizeof(dp2));
	for(int i=h-1;i>=0;i--){
		for(int j=w-1;j>=0;j--){
			if((str[i][j]-'0')>=0 && (str[i][j]-'0')<=9)calc(i,j);
		}
	}
	memset(dp,-1,sizeof(dp));
	ll val=func(0,0);
	printf("%lld\n",val==INF?-1:val);
	return 0;
}

Measured memory_bytes: 74972
X, K, D = map(int, input().split())
if abs(X) > D * K:
    abso = abs(X) - D * K
    print(abso)
    exit()
div = abs(X)//D
mod = abs(X)%D #+側の最小値
if (K - div)%2 == 0: #K-div:+側での絶対値の最小値までたどり着く回数
    print(mod)
else:
    print(D-mod)


Measured memory_bytes: 9104
#include <cstdio>
#include <map>
 
using namespace std;
 
#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
 
//------------------------------------------------------------------------------
const int UF_SIZE = 200000;
 
struct UF {
  int par[UF_SIZE];
  int rnk[UF_SIZE];
  void init(int n) {
    REP(i, n) {
      par[i] = i;
      rnk[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
 
    if (rnk[x] < rnk[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};
 
//------------------------------------------------------------------------------
const int K_MAX = 100000;
const int L_MAX = 100000;
 
typedef pair<int, int> P;
 
int N, K, L;
int p[K_MAX];
int q[K_MAX];
int r[L_MAX];
int s[L_MAX];
 
UF road;
UF rail;
map<P, int> cnts;
 
void solve() {
  road.init(N);
  REP(i, K) road.unite(p[i] - 1, q[i] - 1);
 
  rail.init(N);
  REP(i, L) rail.unite(r[i] - 1, s[i] - 1);
 
  REP(i, N) {
    cnts[P(road.find(i), rail.find(i))]++;
  }
  REP(i, N) printf("%d%c",
    cnts[P(road.find(i), rail.find(i))],
    i + 1 == N ? '\n' : ' '
  );
}
 
void input() {
  scanf("%d%d%d", &N, &K, &L);
  REP(i, K) scanf("%d%d", p + i, q + i);
  REP(i, L) scanf("%d%d", r + i, s + i);
}
 
int main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 16640
import string

def accepted(s):
    if s[0] != 'A':
        return "WA"
    if s[1] == 'C':
        return "WA"
    if s[-1] == 'C':
        return "WA"
    c = 0
    for ss in s[1:]:
        if ss == 'C':
            c += 1
        elif ss not in string.ascii_lowercase:
            return "WA"
    if c != 1:
        return "WA"
    return "AC"

s = input()
print(accepted(s))


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  vector<int> odd, even;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) odd.push_back(a[i]);
    else even.push_back(a[i]);
  }
  if (n % 2 == 0) {
    reverse(even.begin(), even.end());
    for (int i = 0; i < even.size(); i++) {
      cout << even[i] << " ";
    }
    for (int i = 0; i < odd.size(); i++) {
      cout << odd[i] << " ";
    }
    cout << endl;
  } else {
    reverse(odd.begin(), odd.end());
    for (int i = 0; i < odd.size(); i++) {
      cout << odd[i] << " ";
    }
    for (int i = 0; i < even.size(); i++) {
      cout << even[i] << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 5080
<?php
$num=trim(fgets(STDIN));
$is8Count=0;

for($i=1;$i<=$num;$i+=2){
    $count=0;
    for($j=1;$j<=$i;$j+=2){
        
        //var_dump($i." % ".$j."余り:".$i%$j);
        if($i%$j==0){
        $count++;
        //var_dump($count);    
        }
    }
       //var_dump($i."の時の約数個:".$count);
    if($count==8){
        $is8Count++;
    }
}

echo $is8Count;
?>

Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int N, L;
  cin >> N >> L;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin >> a[i];

  int last = -1;
  for(int i=0;i+1<N;i++)if(a[i] + a[i+1] >= L){
    last = i;
  }
  if(last < 0){
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  for(int i=0;i<last;i++)
    cout << i + 1 << endl;
  for(int i=N-2;i>=last+1;i--)
    cout << i + 1 << endl;
  cout << last + 1 << endl;
  return 0;
}


Measured memory_bytes: 1152