akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  set<char> st;
  rep(i, 26) st.insert(char('a'+i));
  for(auto c: s) st.erase(c);
  if(st.empty()) {
    cout << "None" << endk;
  } else {
    cout << *st.begin() << endk;
  }
  return 0;
}


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

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#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 mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const int INF = 1e9;
const LL mod = 1e9 + 7;
const int maxn = 1e7 + 7;

LL ans,n;
map<LL,int>mp;

void check(LL x) {
    if(x == 1) return ;
    LL m = n;
    while(m % x == 0) m /= x;
    m %= x;
    if(m == 1) {
        if(!mp[x]) {
//            cout << "x = " << x << endl;
            ans++;
            mp[x] = 1;
        }
    }
}

int main() {
    while(~slld(n)) {
        mp.clear();
        ans = 0;
        for(LL i = 1; i * i <= n; i++) {
            if(n % i == 0) {
                check(i), check(n/i);
            }
        }
        for(LL i = 1; i * i <= n - 1; i++) {
            if((n-1) % i == 0) {
                check(i),check((n-1)/i);
            }
        }
        plld(ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int n, p;
  cin >> n;
  int m = 0;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> p;
    s += p;
    m = max(m, p);
  }
  s -= m / 2;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3160
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    ll r,l;
    rp(i,s.length())
        if(s[i] == 'A') {
            l = i ;
            break;
        }
    rpd(i,s.length())
        if(s[i] == 'Z'){
            r = i;
            break;
        }

    cout << r - l+1 <<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main()
{
    char s[10000];
    int n;
    cin >> n;
    cin >> s;
    int i=0;
    while(s[i]!='\0')
    {
        int x=int(s[i]);
        int l=x+n;
        if(l>90)
        {
            l=l-26;
        }
        cout << char(l);
        i++;
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep1(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define PI acos(-1.0)
#define LONG_LONG_MAX 9223372036854775807
#define LONG_LONG_MIN -9223372036854775808
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

int k, x, l, r;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> k >> x;
    l = max(x - k + 1, -1000000);
    r = min(x + k - 1, 1000000);
    for (int i = l; i <= r; ++i) {
        if (i != r) {
            cout << i << " ";
        } else {
            cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a[i] = tmp;
  }
  vector<long long> ac(n + 1, 0);
  vector<long long> bc(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    ac[i] = ac[i - 1] + a[i - 1];
  }
  bc[1] = a[0];
  for (int i = 2; i <= n; i++) {
    bc[i] = bc[i - 2] + a[i - 1];
  }
  while (q--) {
    int x;
    cin >> x;
    int lb = 0;
    int ub = n / 2 + 1;
    int l;
    if (abs(a[0] - x) <= abs(a[n / 2] - x)) {
      l = n - n / 2;
    }
    else {
      while (true) {
        l = (lb + ub) / 2;
        if (l >= 2 && abs(a[n - 2 * l + 1] - x) > abs(a[n - l] - x)) {
          ub = l;
        }
        else if (n - 2 * l >= 2 && abs(a[n - l - 1] - x) >= abs(a[n - 2 * l - 1] - x)) {
          lb = l;
        }
        else {
          break;
        }
      }
    }
    long long ans;
    if (n - 2 * l >= 0) {
      ans = ac[n] - ac[n - l] + bc[n - 2 * l];
    } else {
      ans = ac[n] - ac[n / 2];
    }
    cout << ans << '\n';
  }
  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll INF = TEN(18);
const ll M = TEN(11);

int main() {
    ll n, s;
    cin >> n >> s;
    for (ll b = 2; b * b <= M; ++b) {
        ll x = n;
        ll sum = 0;
        while (x) {
            sum += x % b;
            x /= b;
        }
        if (sum == s) {
            cout << b << endl;
            return 0;
        }
    }
    ll ans = INF;
    if (n == s) ans = n + 1;

    for (ll t = 1; t * t <= M; ++t) {
        ll rem = s - t;
        if (rem < 0) break;
        ll p = n - rem;
        if (p >= 0 && p % t == 0 && rem < p / t && t < p / t) {
            chmin(ans, p / t);
        }
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
author:Manson
date:7.7.2018
theme:
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1005;

ll fsum(ll x){
	ll a = 0;
	while(x){
		a += (x % 10);
		x /= 10;
	}
	return a;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll>v;
	for(int i = 1;i < 10;i++){
		v.push_back(i);
	}
	v.push_back(19);
	ll K;
	cin>>K;
	ll last = 19;
	while(v.size() < K){
		ll p = fsum(last);
		ll add = 1;
		while((last+add)*fsum(last+add*2) > (last+2*add)*fsum(last+add)){
			add *= 10;
		}
		last += add;
		v.push_back(last);
	}
	for(int i = 0;i < K;i++){
		cout<<v[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b;
  int wa,sa,seki;
  int ret;
  scanf("%d %d",&a,&b);
  wa = a+b;
  sa = a-b;
  seki = a*b;
  
  if(wa > sa){
    if(wa>seki){
      ret = wa;
    }else{
      ret = seki;
    }}else{
      if (sa>seki){
        ret = sa;
      }else{
        ret = seki;
      }
    }
    printf("%d",ret);
  
  
  
  return 0;
}

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

using namespace std;

int n;
int chk[11];
char s[11];

void f(int lev, int num) {
	
	int i, j, k;
	
	if (lev == n)
	{
		printf("%s\n", s);
		
		return;
	}
	
	for (i = 0; i <= num; i++)
	{
		s[lev] = 'a' + i;
		chk[lev] = i;
		k = 0;
		
		for (j = 0; j <= lev; j++)
		{
			if (k < chk[j])
				k = chk[j];
		}
		
		f(lev + 1, k + 1);
	}
	
}

int main() {
	
	scanf("%d", &n);
	
	f(0, 0);
	
	return 0;
}

Measured memory_bytes: 1536
import math
n,k = map(int,input().strip().split())
f = 1
x = n
while True:
    if x>k:
        poss = x//k
        x = x-poss*k
    if abs(x-k)<x:
        x = abs(x-k)
        f = 1
    else:
        break
print(x)


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


int main() {
    int n;
    cin>>n;
    int num[n];
    for (int i = 0; i < n; ++i) {
        cin>>num[i];
    }
    sort(num,num+n);
    int count=0;
    for (int j = 0; j < n;) {
        int cnum=0;
        int numn=num[j];
        while(num[j]==numn){
            cnum++;
            j++;
            if(j>=n)break;
        }
        //cout<<cnum<<" "<<numn<<endl;
        if(cnum>=numn)count+=cnum-numn;
        else count+=cnum;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 640
tiles = str(input())
size = len(tiles)
one = 0
zero = 0

for i in range(size):
	one_i = (i+1) % 2
	zero_i = i % 2
	one += abs(one_i - int(tiles[i]))
	zero += abs(zero_i - int(tiles[i]))

print(min(one, zero))

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

int main() {

  int in0, in1, in2, in3, in4;
  char in;

  while( cin >> in0 >> in >> in1 >> in >> in2 >> in >> in3 >> in >> in4 ) {

    vector< int > hand;

    hand.push_back( in0 );
    hand.push_back( in1 );
    hand.push_back( in2 );
    hand.push_back( in3 );
    hand.push_back( in4 );
    sort( hand.begin(), hand.end() );

    bool flag = false;
    if ( ( hand[1] == hand[2] && hand[2] == hand[3] ) && ( hand[2] == hand[0] || hand[2] == hand[4] ) ) {
      cout << "four card" << endl;
      continue;
    }
    if ( ( hand[0] == hand[1] && hand[3] == hand[4] ) && ( hand[2] == hand[0] || hand[2] == hand[4] ) ) {
      cout << "full house" << endl;
      continue;
    }
    for ( int i = 0; i < 4; i++ ) {
      if ( hand[3-i] != hand[4] - i - 1 ) break;
      if ( i == 3 ) {
	cout << "straight" << endl;
	flag = true;
	break;
      }
    }
    if ( flag ) continue;
    if ( hand[0] == 1 && hand[1] == 10 && hand[2] == 11 && hand[3] == 12 && hand[4] == 13 ) {
      cout << "straight" << endl;
      continue;
    }
    for ( int i = 0; i < 3; i++ ) {
      if ( hand[i] == hand[i+1] && hand[i] == hand[i+2] ) {
	cout << "three card" << endl;
	flag = true;
	break;
      }
    }
    if ( flag ) continue;
    int c = 0;
    for ( int i = 0; i < 4; i++ ) {
      if ( hand[i] == hand[i+1] ) c++;
    }
    if ( c == 1 ) {
      cout << "one pair" << endl;
      continue;
    }else if ( c == 2 ) {
      cout << "two pair" << endl;
      continue;
    }else if ( c == 0 ) {
      cout << "null" << endl;
      continue;
    }
  }

  return 0;

}

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

using namespace std;
using ll = long long;

template <typename T> T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B;
  cin >> A >> B;
  cout << lcm(A, B) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	int count = 0;
	for (int i = 0; i < n; ++i) {
		int b;
		cin >> b;
		if (b != i + 1) count = count + 1;
	}
	if (count <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int from, to;
	double weight;
} Edge;

typedef struct {
	double x, y, z, r;
} Coord;

Coord coord[ 100 ];
int node[ 100 ];
Edge edge[ 4950 ];

int compare( const void *a, const void *b ) {
	double at = (*(Edge *)a).weight, bt = (*(Edge *)b).weight;

	if ( at < bt )
		return -1;
	if ( at > bt )
		return 1;
	return 0;
}

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

void unite( int x, int y ) {
	node[ find( y ) ] = find( x );
}

double kruskal( int v, int e ) {
	int i;
	double sum;

	qsort( edge, e, sizeof(Edge), &compare );

	for ( i = 0; i < v; i++ )
		node[ i ] = i;

	sum = 0.0;
	for ( i = 0; i < e; i++ )
		if ( find( edge[ i ].from ) != find( edge[ i ].to ) ) {
			unite( edge[ i ].from, edge[ i ].to );
			sum += edge[ i ].weight;
		}

	return sum;
}

int main( void ) {
	int i, j;
	int n, cnt;

	while ( scanf( "%d", &n ), n ) {
		for ( i = 0; i < n; i++ )
			scanf( "%lf %lf %lf %lf", &coord[ i ].x, &coord[ i ].y, &coord[ i ].z, &coord[ i ].r );

		cnt = 0;
		for ( i = 0; i < n; i++ )
			for ( j = i + 1; j < n; j++ ) {
				edge[ cnt ].from = i;
				edge[ cnt ].to = j;
				edge[ cnt ].weight = fmax( sqrt( ( coord[ i ].x - coord[ j ].x ) * ( coord[ i ].x - coord[ j ].x ) + ( coord[ i ].y - coord[ j ].y ) * ( coord[ i ].y - coord[ j ].y ) + ( coord[ i ].z - coord[ j ].z ) * ( coord[ i ].z - coord[ j ].z ) ) - coord[ i ].r - coord[ j ].r, 0.0 );
				cnt++;
			}

		printf( "%.3f\n", kruskal( n, n * ( n - 1 ) / 2 ) );
	}

	return 0;
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std ;
int x[5];
int main () {
  int p;
  string a[5] ;
  for(int i = 0 ; i < 3 ; i++ ) cin >> a[i]  ;
  while(a[p][x[p]]) p=a[p][x[p]++]-'a' ;
  cout << char ('A' + p ) << endl ;
}

Measured memory_bytes: 256
n,m = list(map(int, input().split()))
h = list(map(int, input().split()))
nice = list(1 for i in range(n))
def chk_nice(x,y): 
    global nice
    if nice[x] != 0:
        nice[x] = (h[x] > h[y])
for i in range(m):
    a,b = list(map(int, input().split()))
    chk_nice(a-1, b-1)
    chk_nice(b-1, a-1)
print(sum(nice))



Measured memory_bytes: 20028
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int H,W;
int A[101][101];
int C[101][101];
vector<int> V[101][101];

template<class V> class MaxFlow_dinic {
public:
	struct edge { int to,reve;V cap;};
	static const int MV = 1100;
	vector<edge> E[MV];
	int itr[MV],lev[MV];
	void add_edge(int x,int y,V cap,bool undir=false) {
		E[x].push_back((edge){y,(int)E[y].size(),cap});
		E[y].push_back((edge){x,(int)E[x].size()-1,undir?cap:0});
	}
	void bfs(int cur) {
		MINUS(lev);
		queue<int> q;
		lev[cur]=0;
		q.push(cur);
		while(q.size()) {
			int v=q.front(); q.pop();
			ITR(e,E[v]) if(e->cap>0 && lev[e->to]<0) lev[e->to]=lev[v]+1, q.push(e->to);
		}
	}
	V dfs(int from,int to,V cf) {
		if(from==to) return cf;
		for(;itr[from]<E[from].size();itr[from]++) {
			edge* e=&E[from][itr[from]];
			if(e->cap>0 && lev[from]<lev[e->to]) {
				V f=dfs(e->to,to,min(cf,e->cap));
				if(f>0) {
					e->cap-=f;
					E[e->to][e->reve].cap += f;
					return f;
				}
			}
		}
		return 0;
	}
	V maxflow(int from, int to) {
		V fl=0,tf;
		while(1) {
			bfs(from);
			if(lev[to]<0) return fl;
			ZERO(itr);
			while((tf=dfs(from,to,numeric_limits<V>::max()))>0) fl+=tf;
		}
	}
};


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	
	FOR(y,H) FOR(x,W) {
		cin>>A[y][x];
		V[y][(A[y][x]-1)/W].push_back(A[y][x]);
	}
	
	FOR(x,W) {
		MaxFlow_dinic<int> mf;
		FOR(y,H) {
			mf.add_edge(0,2+y,1);
			mf.add_edge(102+y,1,1);
			FOR(i,H) if(V[y][i].size()) mf.add_edge(2+y,102+i,1);
		}
		mf.maxflow(0,1);
		FOR(y,H) {
			FORR(e,mf.E[2+y]) if(e.cap==0 && e.to>0) {
				i=e.to-102;
				C[y][x]=V[y][i].back();
				V[y][i].pop_back();
			}
		}
	}
	
	FOR(y,H) {
		FOR(x,W) cout<<C[y][x]<<" ";
		cout<<endl;
	}
	
	
	
	FOR(x,W) {
		FOR(i,H) FOR(y,H-1) if(C[y][x]>C[y+1][x]) swap(C[y+1][x],C[y][x]);
	}
	
	FOR(y,H) {
		FOR(x,W) cout<<C[y][x]<<" ";
		cout<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1312
package main

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

func main() {
	nextReader = newScanner()

	a := nextInt()
	b := nextInt()
	s := ""
	if a == b {
		s = "a == b"
	} else if a < b {
		s = "a < b"
	} else if a > b {
		s = "a > b"
	}
	fmt.Printf("%s\n", s)
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}



Measured memory_bytes: 1080
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #pragma comment(linker, "/STACK:2000000")
  #pragma comment(linker, "/HEAP:2000000")
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  bool fun(int n)
  {
    int ans=0;
    while(n)
    {
      ans++;
      n/=10;
    }
    return bool(ans%2);

  }
  int32_t main()
  {        
    IOS
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
      ans+=(fun(i));
    }
    cout<<ans;

    return 0;
} 

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer i;
  for(i=nil->next;i!=nil;i=i->next){
    if(i->key==key) return i;
  }
  return NULL;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t->prev==nil){
    nil->next=t->next;
    t->next->prev=nil;
  }
  else if(t->next==nil){
    t->prev->next=nil;
    nil->prev=t->prev;
  }
  else{
  t->prev->next=t->next;
  t->next->prev=t->prev;
  }
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer i;
  i=nil->prev;
  if (i==nil) return;
  deleteNode(i);
}

void delete(int key){
  NodePointer a;
  a=listSearch(key);
  if(a==NULL) return;
  deleteNode(a);
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next=x;
  x->next->prev=x;
  x->prev=nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}






Measured memory_bytes: 32948
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;

#if 0
#define INT8_MIN	(-127)
#define INT8_MAX	( 128)
#define UINT8_MAX	( 255)
#define INT16_MIN	(-32768)
#define INT16_MAX	( 32767)
#define UINT16_MAX	( 65535)
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18

void func(void);
#pragma endregion

int main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}



void func(void)
{
	uint8 n;
	scanf("%d", &n);
	vector< uint8 > s(n);
	for(int i=0; i<n; i++){
		scanf("%d", &s[i]);
	}

	uint32 point = 0;
	sort(s.begin(), s.end());
	for(int i=0; i<n; i++){
		point += s[i];
	}

	if(point % 10 != 0){
		printf("%d\n", point);
		return;
	}

	for(int i=0; i<n; i++){
		if((point - s[i]) % 10 != 0){
			printf("%d\n", (point - s[i]));
			return;
		}
	}

	printf("%d\n", 0);

	return;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf 1e16
#define MOD 1e9+7
#define gcd __gcd //最大公約数,gcd(x,y)
int lcm(int a, int b){return a/gcd(a, b)*b;} //(int)最小公倍数,lcm(x,y)
ll llcm(ll a, ll b){return a/gcd(a, b)*b;}//(ll)最小公倍数,lcm(x,y)


int main(){
  int N,K,i;
  string S;
  char a;

  cin >> N >> S >> K;

  a = S[K-1];

  for(i=0 ; i<N ; i++){
    if(S[i] != a){
      S.replace(i,1,"*");
    }
  }
  cout << S << endl;
}


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

struct Card {
	char suit, value;
};

void bubble(struct Card A[], long N){
	for (long i = 0; i < N; i++){
		for (long j = N - 1; j >= i; j--){
			if (A[j].value < A[j - 1].value) swap(A[j], A[j - 1]);
		}
	}
}

void selection(struct Card A[], long N){
	for (long i = 0; i < N; i++){
		long minj = i;
		for (long j = i; j < N; j++) if (A[j].value < A[minj].value) minj = j;
		swap(A[i], A[minj]);
	}
}

void print(struct Card A[], long N){
	for (long i = 0; i < N; i++){
		if (i > 0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], long N){
	for (long i = 0; i < N; i++) if (C1[i].suit != C2[i].suit) return false;
	return true;
}

int main(){
	Card C1[100], C2[100];
	
	long N;
	cin >> N;

	for (long i = 0; i < N; i++) cin >> C1[i].suit >> C1[i].value;
	for (long i = 0; i < N; i++) C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;

	print(C2, N);
	if (isStable(C1, C2, N)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll h, n; cin>>h>>n;
  ll sm=0;
  rep(i, n){
    ll b; cin>>b;
    sm+=b;
  }
  if(sm<h) cout << "No";
  else cout << "Yes";
}

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

int main(void){
    int n;
    cin >> n;
    int first = n / 100;
    int second = n % 100;

    if(first <= 12 && first){
        if(second <= 12 && second){
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
        return 0;
    } 

    if(second <= 12 && second){
        cout << "YYMM" << endl;
        return 0;
    }

    cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())
n = int(input())
ans = 0
for i in range(1, n+1):
    if len(str(i)) % 2 == 1: ans += 1
print(ans)

Measured memory_bytes: 5052
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	String T = sc.next();
	HashSet<Character> set = new HashSet<Character>();
	for(int i = 0; i<S.length(); i++) {
	    if(S.charAt(i) == T.charAt(i)) continue;
	    if(set.contains(T.charAt(i))) {
		System.out.println("No");
		return;
	    }
	    set.add(T.charAt(i));
	    S = S.replace(S.charAt(i), '*').replace(T.charAt(i),S.charAt(i)).replace('*',T.charAt(i));
	}
	if(S.equals(T)) {
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }

}

Measured memory_bytes: 42920
#include <bits/stdc++.h>
#define mp(i,j) make_pair(i,j)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;

int main(){
	int n,l,a_sum=0,close_to_zero=1000;
	cin>>n>>l;
	for(int i=1;i<=n;++i){
		int apple=l+(i-1);
		a_sum+=apple;
		if(abs(apple)<abs(close_to_zero))
			close_to_zero=apple;			
	}
	a_sum-=close_to_zero;
	cout<<a_sum<<endl;	
	return 0;
}

Measured memory_bytes: 256
x = int(input())

a = 0
b = -1

while True:
    a5 = pow(a, 5)
    b5 = pow(b, 5)
    if(a5-b5 == x):
        print("{} {}".format(a, b))
        break
    if(a5+b5 == x):
        print("{} {}".format(a, -b))
        break
    if(-a5-b5 == x):
        print("{} {}".format(-a, b))
        break
    if(-a5+b5 == x):
        print("{} {}".format(-a, -b))
        break

    b += 1
    if(a==b-1):
        a +=1
        b =0


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

using namespace std;

typedef long long ll;

int main () {

    int a, b; cin >> a >> b;

    if(a > 9 || a < 1 || b < 1 || b > 9) {
        cout << -1 << endl;
        return 0;
    }

    else {
        cout << a*b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int N;
vector<int> h;
vector<int> a;
vector<size_t> dp;
 
void update_max(int i, size_t val)
{ 
  for (; i < N; i = (i | (i+1)))
    dp[i] = max(dp[i], val);
}
 
size_t get_max(int r)
{ 
  size_t res = 0;
  for (; r >= 0; r = (r & (r+1)) - 1)
    res = max(res, dp[r]);
  return res;
}
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
 
  cin >> N;
 
  h.resize(N);
  a.resize(N);
 
  dp = vector<size_t>(N+1, 0);
 
  for (int i = 0; i < N; ++i)
  { 
    cin >> h[i];
  }
  for (int i = 0; i < N; ++i)
  { 
    cin >> a[i];
  }
  size_t res = 0;
 
  for (int i = 0; i < N; ++i)
  {
    const size_t cur_max = get_max(h[i]-1) + a[i];
    update_max(h[i], cur_max);
    res = max(res, cur_max);
  }
  cout << res << endl;
 
  return 0;
}

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

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

    int ans = -1, sum = 0;
    for (int i = 0; i + 1 < N; i++) {
        if (H[i] < H[i + 1]) {
            ans = max(ans, sum);
            sum = 0;
            continue;
        }
        sum++;
    }
    ans = max(ans, sum);

    cout << ans << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


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


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	string s;
	cin>>s;
	ll n=s.size();
	bool flag=true;
	if(s[n-1]=='1'||s[0]=='0'){
		cout<<-1<<en;
		return;
	}

	vec<P> ans;
	ll pre=1;
	REP(i,n-1){
		if(s[i]!=s[n-2-i]){
			cout<<-1<<en;
			return;
		}
		ll now=i+2;
		ans.push_back({pre,now});
		if(s[i]=='1') pre=now;
	}

	for(auto i:ans) cout<<i.first<<" "<<i.second<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 3264
n,m=map(int,input().split())
x=list(map(int,input().split()))
x=sorted(x)

if n>=m:
    print(0)
elif n==1:
    ans=max(x)-min(x)
    print(ans)
else:
    delta=[0]*(m-1)
    for i in range(m-1):
        delta[i]=x[i+1]-x[i]
    delta_s=sorted(delta)
    ans=sum(delta_s[:-n+1])
    print(ans)

Measured memory_bytes: 13968
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t L, R, d;
  cin >> L >> R >> d;
  int64_t result = (R / d) - ((L - 1) / d);
  cout << result << endl;
  return 0;
}


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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	int h[n], a[n];
	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < n; i++) cin >> a[i];
	
	int size{1};
	while (size <= n) size *= 2;
	
	vector<long long> dp(n + 1), sgt(2*size);
	for (int i = 0; i < n; i++) {
		int l{size}, r{size + h[i] - 2};
		long long max_value{};
		while (l <= r) {
			if (!(r&1)) max_value = max(max_value, sgt[r--]);
			r /= 2, l /= 2;
		}
		
		dp[h[i]] = max_value + a[i];
		
		int z{size + h[i] - 1};
		sgt[z] = dp[h[i]];
		while (z != 1) {
			sgt[z/2] = max(sgt[z/2], sgt[z]);
			z /= 2;
		}
	}
	
	long long ans{};
	for (int i = 0; i <= n; i++) ans = max(ans, dp[i]);
	cout << ans;
}

Measured memory_bytes: 10516
if __name__ == '__main__':

	B = ['I','V','X','L','C','D','M']
	C = [ 1 ,  5, 10, 50,100,500,1000]

	while True:
		try:
			A = list(input())
			leng = len(A)
			cnt = 0

			if leng == 1:
				cnt = C[B.index(A[0])]
			elif leng == 2:
				before = C[B.index(A[0])]
				after = C[B.index(A[1])]

				if before == after:
					cnt = C[B.index(A[0])] * 2
				elif before < after:
					cnt = after - before
				elif before > after:
					cnt = before + after

			else:
				cnt = C[B.index(A[0])]
				for i in range(1,leng):
					before = C[B.index(A[i-1])]
					after = C[B.index(A[i])]

					if before == after:
						cnt += C[B.index(A[i])]
					elif before < after:
						cnt = cnt -  before + (after - before)
					elif before > after:
						cnt = cnt +  after

			print(cnt)

		except EOFError:
			break




Measured memory_bytes: 5576
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
const ll N=1000009;
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    vector<ll> a(N,0);
    ll n,p;
    cin>>n;
    f(i,0,n){
        cin>>p;
        a[p]++;
    }
    ll c=0;
    f(i,1,1000009){
        if(a[i]==0)
            continue;
        if(a[i]==1)
            c++;
        for(ll j=i*2;j<1000009;j+=i){
            a[j]=0;
        }
    }
    cout<<c;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;


int a[maxN];
int b[maxN];
ll get(ll x)
{
	ll cnt = 0;
	while(x)
	{
		x = x%__builtin_popcount(x);
		cnt++;
	}
	return cnt;
}
ll power(ll x,ll p,ll m)
{
	if(p == 0)
	{
		return 1;
	}
	ll t = power(x,p/2,m);
	t = t*t%m;
	if(p%2 == 1)
	{
		t = t * x% m;
	}
	return t;
}
ll ans[maxN];
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt = 0;
	for(int i=1;i<=n;i++)
	{
		a[i] = s[i-1]-'0';
		if(a[i])
			cnt++;
	}
	for(int i=1;i<=n;i++)
	{
		b[i] = get(i);
	}
	if(cnt>1)
	{
		
		ll sum1 = 0; //mod cnt-1
		for(int i=1;i<=n;i++)
		{
			sum1 = (sum1*2%(cnt-1)+a[i])%(cnt-1); 
		}
		ll sum2 = 0; //mod cnt+1;
		for(int i=1;i<=n;i++)
		{
			sum2 = (sum2*2%(cnt+1)+a[i])%(cnt+1); 
		}
		for(int i=1;i<=n;i++)
		{
			if(a[i] == 0)
			{
				ll x = sum2 + power(2,n-i,cnt+1);
				x %= (cnt+1);
				ans[i] = b[x]+1;
			}
			else
			{
				ll x = sum1 - power(2,n-i,cnt-1)+cnt-1;
				x %= (cnt-1);
				ans[i] = b[x]+1;
			}
		}	
	}
	else if(cnt == 1)
	{
		ll sum2 = 0; //mod cnt+1;
		for(int i=1;i<=n;i++)
		{
			sum2 = (sum2*2%(cnt+1)+a[i])%(cnt+1); 
		}
		for(int i=1;i<=n;i++)
		{
			if(a[i] == 0)
			{
				ll x = sum2 + power(2,n-i,cnt+1);
				x %= (cnt+1);
				ans[i] = b[x]+1;
			}
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			ans[i] = 1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6844
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <queue>
#include <iterator>
#include <limits>
#define PI 3.1415926535
#include <sstream>
#define MAX 100
#define swap(a,b,t) (t=a,a=b,b=t)
using namespace std;
string getstring(char a)
{
       string s(1,a);
       return s;
}

int main()
        { 
        int x=0;
        bool t=false;
        string s,m;
        cin>>s;
        m=getstring(s[5]);
        m+= getstring(s[6]);
        stringstream geek(m);
        geek>>x;
        if(x<=4)
        cout<<"Heisei";
        else
        cout<<"TBD";
        //system("pause");
        return 0;
        } 
        
        





Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

long long int n, k;
vector<vector<int>> graph;
vector<int> parent;

void setparent(int now) {
	for (int i = 0; i < graph[now].size(); i++) {
		int next = graph[now][i];
		if (next == parent[now]) continue;
		parent[next] = now;
		setparent(next);
	}
}

long long int solve(int now) {
	long long int restk = k - 2;
	if (parent[now] == -1) restk = k - 1;
	long long int res = 1;
	for (int i = 0; i < graph[now].size(); i++) {
		int next = graph[now][i];
		if (next == parent[now]) continue;
		res *= (max((long long int)0, restk) * solve(next)) % mod;
		res %= mod;
		restk--;
	}
	// cout << now << " " << res << endl;
	return res;
}

int main() {
	cin >> n >> k;
	graph = vector<vector<int>>(n);
	parent = vector<int>(n, -1);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	setparent(0);
	cout << (k * solve(0)) % mod << endl;
}

Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <math.h>
using namespace std;


int main() {

    int N;
    cin >> N;
    int X[N];
    for(int i = 0; i < N; i++ ) cin >> X[i];

    int minHp = INT_MAX;

    for(int i = 1; i <= 100; i++ ){
        int hp = 0;
        for (int j = 0; j < N; j ++){
            hp += pow(X[j] - i, 2);
        }
        minHp = min(hp, minHp);
    }

    cout << minHp << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>s(n);
    for(ll i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s.begin(),s.end());
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=s[i];
    }
    if(ans%10!=0){
        cout << ans << endl;
        return 0;
    }
    ll del=0;
    for(ll i=0;i<n;i++){
        if(s[i]%10!=0){
            del=s[i];
            break;
        }
    }
    ans-=del;
    if(del==0) ans=0;
    cout << ans << endl;
}

Measured memory_bytes: 3600
def comb(a):
    if a < 2:
        return 0
    else:
        return a * (a-1) // 2


N = int(input())
A = list(map(int, input().split()))
ans = []
total = 0
dct = {}
for a in A:
    if (dct.get(a) != None):
        total -= comb(dct[a])
        dct[a] += 1
        total += comb(dct[a])
    else:
        dct[a] = 1
for a in A:
    print(total - comb(dct[a])+comb(dct[a]-1))


Measured memory_bytes: 24748
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    ans = 0
    for i in range(N):
        for j in range(N):
            if A[i] > A[j]:
                if i < j:
                    ans += K * (K + 1) // 2
                else:
                    ans += K * (K - 1) // 2
                ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9528
n = gets.to_i
a = n.times.map{gets.chomp.split(" ").map(&:to_i)}
for i in 1..n-1
  tmp = [(a[i-1][0]+a[i][0]-1)/a[i][0],(a[i-1][1]+a[i][1]-1)/a[i][1]].max
  a[i][0] *= tmp
  a[i][1] *= tmp
end
puts a[-1][0]+a[-1][1]

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define pb push_back
typedef long long ll;
#define mod pow(10,9)+7
using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = max(max(a * c, a * d), max(b * c, b * d));
	cout << ans;

	return 0;
}

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

int main(){
  int N, W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  rep(i, N){
    cin >> v[i] >> w[i];
  }
  vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
  rep(i,N){
    for (int j = 0; j <= W; j++){
      if(j >= w[i]) {
        dp[i + 1][j] = max(dp[i][j - w[i]] + v[i],  dp[i][j]);
      }else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<int> h(n,0);
    rep(i,n) cin >> h[i];
    sort(h.rbegin(),h.rend());
    ll ans = 0;
    for(ll i = (k);i<n;i++){
        ans+=h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int g1[100010],g2[100010],a[100010];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	g1[0]=a[0];
	for(int i=1;i<n;i++)
	{
		g1[i]=__gcd(g1[i-1],a[i]);
	}
	g2[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
	{
		g2[i]=__gcd(g2[i+1],a[i]);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			ans=max(ans,g2[i+1]);
		}
		else
		{
			if(i==n-1)
			ans=max(ans,g1[i-1]);
			else
			ans=max(__gcd(g1[i-1],g2[i+1]),ans);	
		}
	}
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

#define ll long long 
#define mod 1000000007

int main()
{
	ll n,k;
	cin>>n>>k;
	if(n<k) swap(n,k);
	if(n%3LL==0 || k%3LL==0)
	{
		cout<<0<<endl;
		return 0;
	}
	ll s1,s2,d1,d2,s3=INT_MAX,d3=INT_MAX;
	for(ll i=1;i<k;i++)
	{
		ll q1=i*n;
		ll q2=n/2*(k-i);
		ll q3=(n-n/2)*(k-i);
		 s1=max(q1,max(q2,q3));
		 s2=min(q1,min(q2,q3));
		 s3=min(s3,s1-s2);
	}
	//ll re1=s1-s2;
	swap(n,k);
	for(ll i=1;i<k;i++)
	{
		ll q1=i*n;
		ll q2=n/2*(k-i);
		ll q3=(n-n/2)*(k-i);
		 d1=max(q1,max(q2,q3));
		 d2=min(q1,min(q2,q3));
		 d3=min(d3,d1-d2);
	}
	//ll re2=d1-d2;
	cout<<min(min(n,k),min(s3,d3))<<endl;
	return 0;
}

Measured memory_bytes: 256
const main = (input) => {
  input = input.split(' ');
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  const c = parseInt(input[2], 10);
  const d = parseInt(input[3], 10);
  
  const resultA = Math.abs(a-b);
  const resultB = Math.abs(a-c);
  const resultC = Math.abs(b-c);
  
  if (resultB<=d|| resultA<=d&&resultC<=d) {
    console.log("Yes");
  }else{
    console.log("No");
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 2e5+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}


void solve(){
	ll n,x,y,ans;
	cin >> n;
	bff;
	x=n/1.08;
	rep(i,x-1,x+2 && !f){
		y=i*1.08;
		if(y==n){
			ans=i;
			f=true;
		}
	}
	if(f)
		cout << ans;
	else
		cout << ":(";
}

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


Measured memory_bytes: 256