akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll N, L ;
  cin >> N >> L;
  vector<string> str;
  rep(i,N){
    string inp; cin >> inp;
    str.pb(inp);
  }
  sort(all(str));

  rep(i,str.size())
    cout << str[i] ; 
  cout << endl;
    

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    vector<char> spare(s.size());
    for(int i = 0; i < s.size(); i++){
        spare.at(i) = s.at(i);
    }
    sort(spare.begin(), spare.end());
    if(spare.at(0) == spare.at(1)){
        if(spare.at(2) == spare.at(3) && spare.at(1) != spare.at(2)){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef vi poly;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int mod=998244353;
namespace Poly{
	const int N=(1<<20)+5,g=3;
	inline int power(int x,int p){
		int res=1;
		for(;p;p>>=1,x=(ll)x*x%mod)
			if(p&1)res=(ll)res*x%mod;
		return res;
	}
	void dft(poly &A,int n){
		static ull W[N<<1],*H[30],*las=W,mx=0;
		for(;mx<n;mx++){
			H[mx]=las;ull w=1,wn=power(g,(mod-1)>>(mx+1));
			REP(i,1<<mx)*las++=w,w=w*wn%mod;
		}
		static ull a[N];A.resize(1<<n);
		for(int i=0,j=0;i<(1<<n);++i){
			a[i]=A[j];
			for(int k=1<<(n-1);(j^=k)<k;k>>=1);
		}
		for(int k=0,d=1;k<n;k++,d<<=1)
			for(int i=0;i<(1<<n);i+=d<<1){
				ull *l=a+i,*r=a+i+d,*w=H[k],t;
				for(int j=0;j<d;++j,++l,++r){
					t=(*w++)*(*r)%mod;
					*r=*l+mod-t,*l+=t;
				}
			}
		REP(i,1<<n)A[i]=a[i]%mod;
	}
	void idft(poly &a,int n){
		a.resize(1<<n);
		reverse(a.begin()+1,a.end());
		dft(a,n);
		int inv=power(1<<n,mod-2);
		REP(i,1<<n)a[i]=(ll)a[i]*inv%mod;
	}
	poly mul(poly a,poly b){
		int aim=(a.size()+b.size()),n=1;
		while((1<<n)<=aim)n++;
		dft(a,n),dft(b,n);
		REP(i,1<<n)a[i]=(ll)a[i]*b[i]%mod;
		return idft(a,n),a.resize(aim),a;
	}
}

const int N=205,M=8005;
int fac[M],rev[M],f[M],g[M],n,m;

void init(int n){
	fac[0]=1;
	rep(i,1,n)fac[i]=(ll)fac[i-1]*i%mod;
	rev[n]=Poly::power(fac[n],mod-2);
	per(i,n,1)rev[i-1]=(ll)rev[i]*i%mod;
}

poly A,B,C;

int main(){
	read(m),read(n),init(m+2);
	rep(i,0,m)f[i]=(ll)fac[m]*rev[i]%mod*rev[m-i]%mod;
	A.resize(m+1),B.resize(m+1);
	per(i,n,1){
		rep(j,1,m){
			A[j]=(ll)fac[j+2]*f[j]%mod;
			B[m-j]=rev[j+2];
		}
		C=Poly::mul(A,B);
		rep(j,0,m)
			g[j]=((ll)C[m+j]*rev[j]
				   +((ll)j*(j+1)/2+1)%mod*f[j])%mod;
		swap(f,g);
	}
	printf("%d\n",f[0]);
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int add(int x,int y){
	return (x+=y)<mod?x:x-mod;
}
int mul(int x,int y){
	return (int)((long long int)x*y%mod);
}
void addto(int&x,int y){
	x = add(x,y);
}
int d[3003][3003][2];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0; i<=n; i++)
		d[0][i][0] = 1;
	for(int i=0; i<m; i++)
	for(int j=0; j<=n; j++)
	for(int k=0; k<2; k++){
		if(j){
			addto(d[i+1][j][k||(j==1)],d[i][j][k]);
			addto(d[i+1][j-1][k||(j==1)], d[i][j][k]);
		}
		if(j<n){
			addto(d[i+1][j][k||(j==0)],d[i][j][k]);
			addto(d[i+1][j+1][k||(j==0)],d[i][j][k]);
		}
	}
	int res = 0;
	for(int j=0; j<=n; j++)
		addto(res, d[m][j][1]);
	printf("%d\n",res);
	return 0;
}


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

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define mp            make_pair
typedef long long     ll;

int a,b,c;
int arr[101][101][101];
int main()
{
 /*cin>>a>>b>c;
for(int i=0;i<a;i++){
    int x,y,z;cin>>x>>y>>z;
    arr[x][y][z]++;
}
  for(int i = 1 ; i<=100 ; ++i)
        for(int j = 1 ; j<=100 ; ++j)
            for(int a = 0 ; a<=m ; ++a)
            {
               arr[i][j][a] += arr[i-1][j][a] + arr[i][j-1][a];
                arr[i][j][a] -= arr[i-1][j-1][a];
            }*/
ll n,a,b;cin>>n>>a>>b;
if(b<a){cout<<0;}else if (a<b&&n==1){
cout<<0;

}else if(n==1){cout<<1;}else {
cout<<(n-2)*(b-a)+1;
}

}
/*
2
2
2 3
2
2 4
*/


Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#define ll long long
#define MAXN 200005
#define MOD(x, m) (((x) % m + m) % m)
using namespace std;
ll N, K;
ll A[MAXN], psum[MAXN];
map<ll, ll> mp;

int main() {
	int i, j;
	scanf("%lld%lld", &N, &K);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &A[i]);
		A[i] %= K;
		psum[i] = (psum[i - 1] + A[i]) % K;
	}

	ll ans = 0ll;
	mp[psum[0]]++;
	for (i = 1; i <= N; ++i) {
		if (i - K >= 0) {
			mp[MOD(psum[i - K] - (i - K), K)]--;
		}
		ans += mp[MOD(psum[i] - i, K)];
		mp[MOD(psum[i] - i, K)]++;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll a, b, x, c, ans = 0;
	std::cin >> a >> b >> x;

	c = (a / x) * x;
	if (a % x != 0) {
		c += x;
	}

	if (c <= b) {
		ans += ((b - c) / x) + 1;
	}

	outn(ans);

	return 0;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


int n;

signed main(){
    cin>>n;
    int x=111;
    while(n>x){
        x+=111;
    }
    cout<<x<<endl;
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;

int n,a;
int b[N],c[N],mxa[2],da[2],mxb[2],db[2];

int main(){
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;++i) {
		scanf("%d",&a);
		if(i&1) {
		  b[a]++;
		  if(b[a]>=mxa[0]){
		  	if(da[0]==a) {mxa[0]=b[a];}
		  	else{
		  		mxa[1]=mxa[0];da[1]=da[0];
		  		da[0]=a;mxa[0]=b[a];
		  	}
		  }else if(b[a]>=mxa[1]){
		  	 mxa[1]=b[a];da[1]=a;
		  }
		}else{
		  c[a]++;
		  if(c[a]>=mxb[0]){
		  	if(db[0]==a) {mxb[0]=c[a];}
		  	else{
		  		mxb[1]=mxb[0];db[1]=db[0];
		  		db[0]=a;mxb[0]=c[a];
		  	}
		  }else if(c[a]>=mxb[1]){
		  	 mxb[1]=c[a];db[1]=a;
		  }
		}
	}
	if(da[0]!=db[0])
	  printf("%d\n",n-mxa[0]-mxb[0]);
	else{
		int mx=max(mxa[0]+mxb[1],mxa[1]+mxb[0]);
		printf("%d\n",n-mx);
	}
	return 0;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {
    
    long long n, a, b, ans = 0;
    
    cin >> n;
    
    for (long long i= 1; i*i <= n; i++)
    {
        if (n % i == 0){
            a = n / i;
            //cout << a << endl;
            b = i;
            if (i > a)
            {
                b = i;
                break;
            }
        }
    }
    ans = (a - 1) + (b - 1);
    cout << ans << endl;
    
    return 0;
}


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

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	
	if (n == 1){
		printf("%d\n", m);
		return 0;
	}
	if (n == 2){
		printf("%d %d\n", m, m);
		return 0;
	}
	
	vector<int> res;
	
	if (n & 1){
		for (int i = 0; i < n / 2; i++){
			res.push_back(0);
		}
		for (int i = 0; i < n - (n / 2); i++){
			res.push_back(m);
		}
	}
	else {
		for (int i = 0; i < n / 2 - 1; i++){
			res.push_back(0);
		}
		for (int i = 0; i < n / 2 + 1; i++){
			res.push_back(m);
		}
	}
	
	for (int i = 0; i < n; i++){
		if (i) printf(" ");
		printf("%d", res[i]);
	}
	puts("");
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <string>
int main(){
  int N;
  std::cin >> N;

  std::vector<std::string> prev(1,"a");
  std::vector<std::string> next(0);
  if(N == 1){
    std::cout << "a" << std::endl;
    return 0;
  }
  for(int i = 0; i < N-1; ++i){
    for(int j = 0; j < prev.size(); ++j){
      int num_kind = 1;
      char search = 'b';
      for(int k = 0; k < prev[j].length(); ++k){
        if(search == prev[j][k]){
          ++num_kind;
          ++search;
        }
      }
      char back = 'a';
      for(int k = 0; k < num_kind + 1; ++k){
        std::string n_str = prev[j];
        n_str.push_back(back);
        next.push_back(n_str);
        ++back;
      }
    }
    prev.clear();
    for(int j = 0; j < next.size(); ++j){
      prev.push_back(next[j]);
    }
    next.clear();
  }
  for(int i = 0; i < prev.size(); ++i){
    std::cout << prev[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 11888
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<algorithm>
#include<iostream>
using namespace std;

int N;
long long x,dp[5];
int main(){
  cin>>N;
  while(N--){
    cin>>x;
    dp[4]=min({dp[1],dp[2],dp[3],dp[4]})+x;
    dp[3]=min(dp[2],dp[3])+(!x)*2+(x&1);
    dp[2]=min({dp[0],dp[1],dp[2]})+(~x&1);
    dp[1]=min(dp[0],dp[1])+(!x)*2+(x&1);
    dp[0]=dp[0]+x;
  }
  cout<<(*min_element(dp,dp+5))<<endl;
}


Measured memory_bytes: 256
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using ulong = unsigned long;
using ll = long long;
using ull = unsigned long long;

using namespace std;

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

	ll x, y;
	cin >> x >> y;
	ll result = 0;

	for(ll i = x; i <= y; i *= 2)
	{
		result++;
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define gc getchar
inline int read()
{
	int res=0,f=0;
	char c;c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){res=res*10+c-48;c=gc();}
	if(f)return -res;
	return res;
}
signed main()
{
	int r=read(),d=read(),x=read();
	for(int i=1;i<=10;i++)
	{
		x=r*x-d;
		cout<<x<<endl;
	}
}

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

using namespace std;
   
int main() {
 
    int n,c,k;
    cin >>n>>c>>k;
 
    vector<int>vec(n);
    for (int i=0;i<n;i++) 
    cin>>vec[i];
 
    sort(vec.begin(), vec.end());
 
    int start = vec[0];
    int sum = 1, cnt = 1;
 
    for (int i=1;i<n; i++)
    {
        cnt ++;
        if (vec[i] >start+k||cnt>c)
        {
            start=vec[i];
            cnt=1;
            sum++;
        }
    }
    cout << sum << endl;
    
}


Measured memory_bytes: 640
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
    	new Main(); 
    }
 
    public Main() {
    	while(sc.hasNext()){
    		new aoj0090().doIt();
    	}
    }
    class aoj0090{
    	int cnt = 0;
    	boolean num[] = new boolean [10];
    	void dfs(int n,int s,int c){
//    		System.out.println(s+" "+c+" "+cnt);
    		if(c == n && s == 0)cnt++;
    		if(c < n && s >= 0){
    			for(int i = 0;i <= 9;i++){
    				if(!num[i]){
    					if(s - (i*c) < 0)break;
    					num[i] = true;
    					dfs(n,s-(i*c),c+1);
    					num[i] = false;
    				}
    			}
    		}
    	}
    	void doIt(){
    		int n = sc.nextInt();
    		int s = sc.nextInt();
    		int max = 0;
    		for(int i = 0;i < 10;i++)max += i*(i+1);
    		cnt = 0;
    		if(n > 10 || s > max)System.out.println(0);
    		else{
    			if(s <= max){
    				dfs(n+1,s,1);
    				System.out.println(cnt);
    			}
    		}
    	}
    }
}

Measured memory_bytes: 26780
#include <bits/stdc++.h>
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define deb(x) cerr << ">> " << #x << " : " << x << "\n"
#define endl '\n'
#define ff first
#define ss second
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define print(a) for(auto x : a) cout << x << " "; cout << endl;

using namespace std;

const ll inf = 1e18 + 42;

const ll M = 998244353;

ll power(ll x, ll y) {
	if (y == 0) return 1;
	if (y & 1) return (x * power(x, y - 1));
	ll t = power(x, y / 2);
	return (t * t);
}

const ll MAX = 1e3 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void ahShitHereWeGoAgain()
{
	ll a, b;
	cin >> a >> b;
	cout << a * b;
}

int main()
{
	DESYNC	
	ll t = 1;
	// cin >> t;
	while (t--)
		ahShitHereWeGoAgain();
	return 0;
}



Measured memory_bytes: 3652
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int a, b, c;
  cin >> a >> b >> c;
  if(a+b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	int num = 0;
	long int big, small, all = 0;
	cin >> num;
	big = num;
	small = num;
	all = num;
	for (int i=2; i <= n; ++i){
		cin >> num;
		if (num > big){
			big = num;
		}
		else if(num<small){
			small = num;
		}
		all += num;
		
	}
	cout << small << " " << big << " " << all << endl;
	return 0;
	}


Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && a!=c){
    cout<<"Yes"<<endl;
  }
  else if(b==c &&c!=a){
    cout<<"Yes"<<endl;
  }
  else if(c==a &&a!=b){
    cout<<"Yes"<<endl;
  }  
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
const int maxn=500005,inf=0x3f3f3f3f;
struct seg_tree{
	int Max[maxn<<2];
	void push_up(int p,int u,int v){
		Max[p]=max(Max[u],Max[v]);
	}
	int query(int p,int l,int r,int L,int R){
		if((L<=l)&&(R>=r))return Max[p];
		int mid=(l+r)>>1,u=p<<1,v=u+1,res=0;
		if(L<=mid)res=query(u,l,mid,L,R);
		if(R>mid)res=max(res,query(v,mid+1,r,L,R));
		return res;
	}
	void update(int p,int l,int r,int pos,int val){
		if(l==r){
			Max[p]=val;
			return;
		}
		int mid=(l+r)>>1,u=p<<1,v=u+1;
		if(pos<=mid)update(u,l,mid,pos,val);
		else update(v,mid+1,r,pos,val);
		push_up(p,u,v);
	}
}T;
int n,m,a[maxn],p[maxn],s[maxn],tot;
vector<int>E[maxn];
priority_queue<int,vector<int>,greater<int> >Q;
void dfs(int u){
	REP(i,0,E[u].size()-1)Q.push(E[u][i]);
	while(!Q.empty()){
		int v=Q.top();
		s[++tot]=v;
		Q.pop(),dfs(v);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	REP(i,1,n)
		scanf("%d",&a[i]),p[a[i]]=i;
	if(m==1){
		REP(i,1,n)
			printf("%d\n",i);
		return 0;
	}
	REP(i,1,n){
		E[p[T.query(1,1,n,p[i]+1,p[i]+m-1)]].push_back(p[i]);
		T.update(1,1,n,p[i],i);
	}
	dfs(0);
	REP(i,1,n)
		a[s[i]]=i;
	REP(i,1,n)
		printf("%d\n",a[i]);
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll ans;
  for(int i = 1; i <= N; i++) {
    if(i * i > N) break;
    ans = i * i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define fst first
#define snd second

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);
  
  string s; ll k;
  cin >> s >> k;
  int i, n = s.size();
  for(i = 0; i < n && s[i] == '1'; i++);
  if(k <= i) cout << "1\n";
  else if(i < n) cout << s[i] << "\n";
  else cout << s[n-1] << "\n";
  return 0;
}



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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
// const int mod = (int)1e9 + 7;

int main(int argc, char* argv[]){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;

    int res = 0;
    int startWithB = 0, endWithA = 0, both = 0;

    string s[n];
    for(int i = 0; i < n; ++i){
        cin >> s[i];
        for(int j = 0; j + 1 < (int)s[i].size(); ++j)
            res += s[i][j] == 'A' && s[i][j + 1] == 'B';

        startWithB += s[i][0] == 'B' && s[i].back() != 'A';
        endWithA += s[i][0] != 'B' && s[i].back() == 'A';
        both += s[i][0] == 'B' && s[i].back() == 'A';
    }

    if(both){
        if(endWithA != 0) res++, endWithA--;
        res += both - 1;
        if(startWithB != 0) res++, startWithB--;
    }

    int paired = min(endWithA, startWithB);
    endWithA -= paired;
    startWithB -= paired;
    res += paired;

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 768
using System;
using System.Linq;

class F
{
	static void Main()
	{
		Func<int[]> read = () => $"0 {Console.ReadLine()}".Split().Select(int.Parse).ToArray();
		var a = read();
		var h = read();
		int n = a[1], k = a[2];

		var dp = new long[n - k + 1, n + 1];
		for (int i = 1; i <= n - k; i++)
			for (int j = i; j <= i + k; j++)
				dp[i, j] = Enumerable.Range(i - 1, j - i + 1).Min(x => dp[i - 1, x] + Math.Max(0, h[j] - h[i == 1 ? 0 : x]));
		Console.WriteLine(Enumerable.Range(n - k, k + 1).Min(j => dp[n - k, j]));
	}
}


Measured memory_bytes: 17632
# 03:35 sec    56176 KB     1570 bytes 
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None

def delete(target):
    def remove_node(p, c, a):
        if p.left == c: p.left = a
        else: p.right = a
    p, c = None, root
    while c.key != target: p, c = c, c.left if target < c.key else c.right
    if c.left is None:
        remove_node(p, c, c.right)
    elif c.right is None:
        remove_node(p, c, c.left)
    elif c.right.left is None:
        c.right.left = c.left
        remove_node(p, c, c.right)
    else:
        g = c.right
        while g.left.left: g = g.left
        c.key = g.left.key
        g.left = g.left.right

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'd': delete(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 56176
#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(){
	string s;
	cin >> s;
	int len = s.size();
	rep(i,len){
		if(i % 2 == 1) continue;
		cout << s[i];
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

int main(){
  int i,j;
  int a,b,m;
  cin>>a>>b>>m;
  int s[a];
  int t[b];
  int am=inf;
  int bm=inf;
  for(i=0;i<a;i++) {
    cin>>s[i];
    am=min(am,s[i]);
  }
  for(i=0;i<b;i++) {
    cin>>t[i];
    bm=min(bm,t[i]);
  }
  int ans=am+bm;
  for(i=0;i<m;i++){
    int x,y,c;
    cin>>x>>y>>c;
    x--; y--;
    chmin(ans,s[x]+t[y]-c);
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int N;
int T;
int A[100000];
int B[100000];


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

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

    int a=A[0];

    for(int i=1; i<N; i++) {
        a=min(A[i-1],a);
        B[i]= A[i]-a;
    }

    int b=B[0];

    for(int i=1; i<N; i++) {
        b=max(b, B[i]);
    }

    int c=0;

    for(int i=0; i<N; i++) {
        if(b==B[i]) {
            c++;
        }
    }

    cout << c << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i<=last;++i)
using namespace std;
const int maxN=2333;
int N,M,T;
int arr[maxN][maxN];
int sum[maxN][maxN];
int suml[maxN][maxN];
int sumr[maxN][maxN];
int main()
{
	scanf("%d%d%d",&N,&M,&T);
	char ch;
	REP(i,1,N)
	{
		REP(j,1,M)
		{
			cin>>ch;
			arr[i][j]=ch-'0';
			sum[i][j]=arr[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			if(arr[i][j])
			{
				if(arr[i-1][j])
				{
					suml[i][j]++;
				}
				if(arr[i][j-1])
				{
					sumr[i][j]++;
				}
			}
			suml[i][j]+=suml[i-1][j]+suml[i][j-1]-suml[i-1][j-1];
			sumr[i][j]+=sumr[i-1][j]+sumr[i][j-1]-sumr[i-1][j-1];
		}
	}
	int fx,fy,lx,ly,answer;
	REP(i,1,T)
	{
		scanf("%d%d%d%d",&fx,&fy,&lx,&ly);
		answer=sum[lx][ly]-sum[lx][fy-1]-sum[fx-1][ly]+sum[fx-1][fy-1];
		answer-=suml[lx][ly]+suml[fx][fy-1]-suml[lx][fy-1]-suml[fx][ly];
		answer-=sumr[lx][ly]+sumr[fx-1][fy]-sumr[lx][fy]-sumr[fx-1][ly];
		printf("%d\n",answer);
	}
	return 0;
}

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

#define inf  	 1e18
#define int  	 long long
#define float	  double
#define endl 	 "\n"
#define w(t) 	 int t;cin>>t;while(t--)
#define str  	 to_string
#define vci  	 vector<int>
#define vcs  	 vector<string> 
#define mp   	 make_pair
#define pb   	 push_back
#define pii  	 pair<int,int>
#define pis  	 pair<int,string>
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define mod   	 1000000007
random_device rd;
mt19937 rand_gen(rd());
#define setbits(x)     __builtin_popcountll(x)
#define trailzero(x)   __builtin_ctzll(x)
#define shuffle(vc) shuffle(vc.begin(), vc.end(), rand_gen);
#define decimal(x,value)  cout<<fixed<<setprecision(x)<<value
void io()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("/home/kashif/cp/input.txt","r",stdin);
		
		freopen("/home/kashif/cp/output.txt","w",stdout);
	#endif

}
int n,W;
int v[101]={0};
int weight[101]={0};
int dp[100001][101]={0};
int solve(int w,int k)
{
	
	if(k>n) 
		return 0;
	int &ans=dp[w][k];
	if(ans!=-1)
		return ans;
	if(weight[k]>w)
		return ans=solve(w,k+1);
	else
	{
		int t=solve(w-weight[k],k+1);
		int g=solve(w,k+1);
		ans=max(v[k]+t,g);	
	}
	return ans;



}
int32_t main()
{
	
	fastio();
	//io();
	memset(dp,-1,sizeof(dp));
	cin>>n>>W;
	for(int i=1;i<=n;i++)
		cin>>weight[i]>>v[i];
	
	cout<<solve(W,1)<<endl;

	
	
}


Measured memory_bytes: 82504
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<ll>
#define vpi vector< pi >
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL)
const int N=25;
vi v[N];
bool dp[N][N];
int n,m;
string s[N];
int main()
{
	cin>>n>>m;
	
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	int res=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='#') continue;
			memset(dp,0,sizeof dp);
			queue<int> q;
			q.push(i*m+j);
			q.push(-1);
			dp[i][j] =1;
			int l=0;
			while(!q.empty())
			{
				int x=q.front();
				int i=x/m,j=x%m;
				q.pop();
				if(x==-1)
				{
					if(q.empty()) break;
					l++;
					q.push(-1);
					continue;
				}
				if(i-1>=0&&s[i-1][j]=='.'&&dp[i-1][j]==0)
					q.push((i-1)*m+j),dp[i-1][j]=1;
				if(i+1<n&&s[i+1][j]=='.'&&dp[i+1][j]==0)
					q.push((i+1)*m+j),dp[i+1][j]=1;
				if(j-1>=0&&s[i][j-1]=='.'&&dp[i][j-1]==0)
					q.push((i)*m+j-1),dp[i][j-1]=1;
				if(j+1<m&&s[i][j+1]=='.'&&dp[i][j+1]==0)
					q.push((i)*m+j+1),dp[i][j+1]=1;
			}
			//cout<<i<<' '<<j<<" "<<l<<"\n";
			res=max(res,l);
		}
	}
cout<<res;

	return 0;
}

Measured memory_bytes: 256
ary = []
gets.chomp.to_i.times do
    ary << gets.chomp.split(" ").map { |i| i.to_i }
end
ary = ary.sort_by do |a|
    a[1]
end
now = -1
count = 0
ary.each do |a|
    if a[0] > now
        count += 1
        now = a[1]
    end
end
puts count


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


int main() {
    int k;
    cin >> k;
    int ans = 0;
    for(int i=0; i < k; i++) {
      for(int j=0; j < k; j++) {
        for(int l=0; l < k; l++) {
          ans += gcd(i+1, gcd(j+1, l+1));
        }
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=2e5+10;
const int mod=1e9+7;
const int bas=2001;
int n;
int a[maxn],b[maxn],dp[4003][4003];
long long inv[8004],jie[8004];

inline void init()
{
	jie[1]=1;
	for(int i=2;i<=8001;i++) jie[i]=jie[i-1]*i%mod;
	inv[1]=inv[0]=1;
	for(int i=2;i<=8001;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=8001;i++) inv[i]=inv[i]*inv[i-1]%mod;
}	

inline long long C(int a,int b)
{
	if(a==b) return 1;
	if(a<b) return 0;
	return jie[a]*inv[b]%mod*inv[a-b]%mod;
}

int main()
{
	init();
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),dp[bas-a[i]][bas-b[i]]++;
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++) dp[i][j]=((dp[i][j]+dp[i-1][j])%mod+dp[i][j-1])%mod;
	long long ans=0;
	for(int i=1;i<=n;i++) ans=(ans+dp[a[i]+bas][b[i]+bas])%mod;
	for(int i=1;i<=n;i++) ans=(ans-C((a[i]+b[i])*2,a[i]*2)+mod)%mod;
	printf("%lld\n",ans*inv[2]%mod);
	return 0;
}


Measured memory_bytes: 64512
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;


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

	double res = 0;
	for (int32_t i = 1; i <= N; i++) {
		double prob = 1.0;
		int32_t value = i;
		while (value < K) {
			value *= 2;
			prob /= 2.0;
		}
		res += prob;
	}
	res /= N;

	cout << fixed << std::setprecision(std::numeric_limits<double>::max_digits10) << res << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double v = sc.nextDouble();
			double t = v / 9.8;
			double y = 4.9 * t * t;
			double f = (y / 5) + 1;	
			int F = (int)f;
			if(f%5!=0){
				F++;
			}
			System.out.println(F);
		}
	}
}

Measured memory_bytes: 28184
#include <stdio.h>
#define max(x, y)  ((x)<(y) ? (y) : (x))

int main(){
  int n;  scanf("%d", &n);
  int field[2][102];
  field[0][0] = field[1][0] = 0;
  for(int i=0; i<2; i++)
    for(int j=1; j<=n; j++){
      int cand;  scanf("%d", &cand);
      field[i][j] = field[i][j-1] + cand;
    }
  int ans = 0;
  for(int i=1; i<=n; i++){
    int score = field[0][i] + (field[1][n] - field[1][i-1]);
    ans = max(ans, score);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>
#include <iomanip>
#include <stack>

using namespace std;
using namespace boost::multiprecision;

int A, P;

void solve() {
	cin >> A >> P;
	cout << (3 * A + P) / 2 << endl;
	return;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
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;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[200001], ne[200001], he[100001];
int co[100001];
int saidai;
void dfs(int u, int prev, int c) {
	int k = 1;
	for (int i = he[u]; i; i = ne[i]) {
		if (to[i] != prev) {
			if (k == c) k++;
			co[i >> 1] = k;
			chmax(saidai, k);
			dfs(to[i], u, k++);
		}
	}
}

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


	int N = getint();
	int tmp = 2;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		to[tmp] = b;
		ne[tmp] = he[a];
		he[a] = tmp++;
		to[tmp] = a;
		ne[tmp] = he[b];
		he[b] = tmp++;
	}

	dfs(1, 0, 0);

	putint(saidai);
	rep1(i, N) putint(co[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
priority_queue<ll> pq;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m; ll sum = 0, tmp;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> tmp;
		sum += tmp;
		pq.push(tmp);
	}
	while (m && !pq.empty()) {
		ll cur = pq.top();
		pq.pop();
		sum -= (cur - cur / 2);
		if (cur / 2)
			pq.push(cur / 2);
		--m;
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

int main() {
    string o, e;
    cin >> o;
    cin >> e;
    string result(o.size() + e.size(), '*');
    for(int i=0; i < o.size(); i++) {
        result[i*2] = o[i];
    }
    for(int i=0; i<e.size(); i++) {
        result[i*2+1] = e[i];
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 256
import collections
n = int(input())
l = list(input().split())
flg = True
c = collections.Counter(l)
if n%2 == 0:
  flg = all(i == 2 for i in c.values())
else:
  g = c.pop("0") == 1
  flg = all(i == 2 for i in c.values()) and g
#print(c)
print(2**(n//2)%1000000007 if flg else 0)


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

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

int main() {
    int a1,a2,a3; cin >> a1 >> a2 >> a3;
    int ans = 1000000;
    if(abs(a1 - a2) + abs(a2 - a3) < ans){ans = abs(a1 - a2) + abs(a2 - a3);}
    if(abs(a1 - a3) + abs(a3 - a2) < ans){ans = abs(a1 - a3) + abs(a3 - a2);}
    if(abs(a2 - a1) + abs(a1 - a3) < ans){ans = abs(a2 - a1) + abs(a1 - a3);}
    if(abs(a2 - a3) + abs(a3 - a1) < ans){ans = abs(a2 - a3) + abs(a3 - a1);}
    if(abs(a3 - a2) + abs(a2 - a1) < ans){ans = abs(a3 - a2) + abs(a2 - a1);}
    if(abs(a3 - a1) + abs(a1 - a2) < ans){ans = abs(a3 - a1) + abs(a1 - a2);}
    cout << ans;
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> p(N);
    REP(i,N) cin>>p[i];
    sort(p.begin(),p.end());
    ll ans=0;
    REP(i,K){
        ans+=p[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3628
def comb(n, r):
    nc = n
    for rc in range(1, r):
        nc -= 1
        n = n*nc
        r = r*rc

    return n/r


def solve():
    N, M = map(int, input().split())
    ans = comb(N, 2) + comb(M, 2)
    print(int(ans))


# Solve
if __name__ == "__main__":
    solve()


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

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

  int N,A,B,C; cin >> N >> A >> B >> C;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }

  int ans = 1e9;
  function<void(int,int,int,int,int)> dfs =
  [&](int i,int a,int b,int c,int sum){
    if(i == N){
      if(a && b && c){
        int cost = abs(a-A) + abs(b-B) + abs(c-C) + (sum-30);
        ans = min(ans,cost);
      }
      return;
    }
    dfs(i+1,a,b,c,sum);
    dfs(i+1,a + L[i],b,c,sum+10);
    dfs(i+1,a,b + L[i],c,sum+10);
    dfs(i+1,a,b,c + L[i],sum+10);
  };
  dfs(0,0,0,0,0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
l = {}
sum_n = 0
n = 1
while sum_n <= 10 ** 5:
    sum_n += n
    l[sum_n] = n
    n += 1
n = int(input())
if n not in l:
    print('No')
else:
    print('Yes')
    m = l[n]
    print(m+1)
    ans = [[m] for _ in range(m+1)]
    min_n = 1
    max_n = 1
    for i in range(1, m+1):
        max_n += i
        for j in range(min_n, max_n):
            ans[j-min_n].append(j)
            ans[i].append(j)
        min_n = max_n
    for i in ans:
        print(*i)


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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ch(n);
  vector<int> cw(m);
  int k;
  cin >> k;
  set<pair<int, int>> st;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    st.emplace(x, y);
    ++ch[x];
    ++cw[y];
  }
  int mxh = *max_element(ch.begin(), ch.end());
  int mxw = *max_element(cw.begin(), cw.end());
  vector<int> up;
  vector<int> dw;
  for (int i = 0; i < n; i++) {
    if (ch[i] == mxh) {
      up.push_back(i);
    }
  }
  for (int i = 0; i < m; i++) {
    if (cw[i] == mxw) {
      dw.push_back(i);
    }
  }
  for (int x : up) {
    for (int y : dw) {
      if (!st.count({x, y})) {
        cerr << x << " " << y << endl;
        cout << (mxh + mxw) << '\n';
        return 0;
      }
    }
  }
  cout << max(0, mxh + mxw - 1) << '\n';
  return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    int ans = 0;
    for (int d = 0; d < N; d++) {
        bool ok = true;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                int x1, x2, y1, y2;
                x1 = (i + d) % N;
                x2 = (j + d) % N;
                y1 = j;
                y2 = i;
                if (S[x1][y1] != S[x2][y2]) {
                    ok = false;
                    break;
                }
            }
            if (!ok) break;
        }
        if (ok) {
            ans += N;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
    #define int long long
    #define PI 3.141592653589793
    #define rep(i, n) for (int i = 0; i < (n); i++)
    #define rrep(i, n, k) for (int i = (n); i >= (k); i--);
    #define all(x) (x).begin(), (x).end()
    template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
    template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
    template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
    template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
    const int inf = 2e17;
    const int mod = 1e9 + 7;

    signed main() {
        double N;
        cin >> N;
        for (double h = 1; h <= 3500; ++h) {
            for (double n = 1; n <= 3500; ++n) {
                double w = (N * h * n) / (4 * h * n - N * n - N * h);
                if (w == ceil(w) && w > 0 && w <= 3500) {
                    cout << h << " " << n << " " << w;
                    return 0;
                }
            }
        }

    }



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
using namespace std;

int main() {
	int a, b, c, d, e, f;
	int R;
	int T;
	string str;
	int M1, M2, M3, M4, M5, M6;
	cin >> a >> b >> c >> d >> e >> f;
	M1 = a, M2 = b, M3 = c, M4 = d, M5 = e, M6 = f;
	cin >> str;
	for (int j = 0; j<str.size(); j++) {
		if (str[j] == 'S')T = M6, M6 = M2, M2 = M1, M1 = M5, M5 = T;
		if (str[j] == 'N')T = M1, M1 = M2, M2 = M6, M6 = M5, M5 = T;
		if (str[j] == 'E')T = M3, M3 = M1, M1 = M4, M4 = M6, M6 = T;
		if (str[j] == 'W')T = M1, M1 = M3, M3 = M6, M6 = M4, M4 = T;

	}
	R = M1;
	cout << R << endl;

	return 0;
}

Measured memory_bytes: 3140
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for(int i = 0; i < n; i++){
            char[] c = sc.next().toCharArray();
            Arrays.sort(c);
            String s = String.valueOf(c);
            if(map.containsKey(s)){
                map.put(s,map.get(s)+1);
            }else{
                map.put(s,1);
            }
        }
        for(Map.Entry<String, Integer> entry : map.entrySet()){
		    ans += calcComb(entry.getValue());
		}
        System.out.println(ans);
    }

    static long calcComb(int n){
        long ret = (long)n;
        return ((ret*ret)-ret)/2;
    }
}



Measured memory_bytes: 53980
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
//#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,d,a,i,j,ans = 0, val = 0,c;
    cin>>n>>d>>a;
    pii h[n];
    for(i=0;i<n;i++)
        cin>>h[i].ff>>h[i].ss;
    sort(h,h+n);    
    multiset <pii> st;
    for(i=0;i<n;i++)
    {
        while(st.size() and st.begin()->ff <= h[i].ff)
        {
            val += st.begin()->ss;
            st.erase(st.begin());
        }
        h[i].ss += val;
        if(h[i].ss > 0)
        {
            c = (h[i].ss+a-1)/a;
            ans += c;
            st.insert({h[i].ff+2*d+1, a*c});
            val -= a*c;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int m,n,t=1,yy[100005],vis[100005],d,sum,hh[100005];
struct SY
{
	int t,back;
}sy[200005];
int main()
{
    scanf("%d%d",&m,&n);
    int a,b;
    for(int i=1;i<=m;++i) scanf("%d",&vis[i]);
    for(int i=0;i<n;++i)
    {
    	scanf("%d%d",&a,&b);
    	sy[t].t=b;sy[t].back=yy[a];yy[a]=t++;
    	sy[t].t=a;sy[t].back=yy[b];yy[b]=t++;
	}
	for(int i=1;i<=m;++i)
	{
		int ok=1;
		d+=10;
		for(int j=yy[i];j;j=sy[j].back)
		{
			if(vis[sy[j].t]>=vis[i]) {ok=0;break;}
		}
		if(ok||yy[i]==0) sum++;
	}
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 6160
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int i;
    cin>>s;
    int x=0,y=0;
    for(i=0;s[i]!='\0';i++){
        if(s[i]=='A')
        x++;
        if(s[i]=='B')
        y++;
    }
    if(x==3 || y==3)
    cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
    }
    
}

Measured memory_bytes: 3640
import sys

S=list(str(input()))
N=len(S)

N1=int((N-1)/2)
N2=int((N+3)/2-1)

S1=list(S[:N1])
S2=list(S[N2:])


S3=list(reversed(S1))
S4=list(reversed(S2))
Sr=list(reversed(S))

if S==Sr:
    if S1==S3:
        if S2==S4:
            print("Yes")
            sys.exit()
print("No")


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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    bool ok = false;
    for(int i = 1; i < 1001; i++){
        int t = k * i;
        if(t > b){
            break;
        }else if(a <= t && t <= b){
            ok = true;
            break;
        }else{
            continue;
        }
    }
    
    if(ok){
        cout << "OK\n";
    }else{
        cout << "NG\n";
    }
}


Measured memory_bytes: 3628
#include <vector>
#include <iostream>
#include <set>
int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<int> a(N);
    for (int i = 0; i < N; i++) { std::cin >> a[i]; }
    std::vector<int> grundy(K + 1, 0);
    for (int i = 0; i <= K; i++) {
        std::set<int> next;
        for (int j = 0; j < N; j++) {
            if (i >= a[j]) { next.insert(grundy[i - a[j]]); }
        }
        int obj = 0;
        for (const int e : next) {
            if (e != obj) {
                break;
            } else {
                obj++;
            }
        }
        grundy[i] = obj;
    }
    std::cout << (grundy[K] == 0 ? "Second" : "First") << std::endl;

    return 0;
}


Measured memory_bytes: 640
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var s = "AKIHABARA";
		var t = Console.ReadLine();
		var flag = true;
		int i = 0, j = 0;
		while (flag)
		{
			if (i >= s.Length)
			{
				flag &= j >= t.Length;
				break;
			}
			if (j >= t.Length) t = t + "A";
			if (s[i] != t[j])
			{
				flag &= s[i] == 'A';
				j--;
			}
			i++;
			j++;
		}
		Console.WriteLine(flag ? "YES" : "NO");
	}
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

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

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N;
	cin >> N;
	cout << N * N * N << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256