akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[100010];
int main(){
	scanf("%s",s);
	int n=strlen(s),ans=n;
	for(int i=1;i<n;i++)
		if(s[i]!=s[i-1])
			ans=min(ans,max(i,n-i));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        while(true) {
            int n = stdIn.nextInt();
            if(n == 0) break;
            int[] s = new int[n];
            int sum = 0;
            for(int i = 0; i < n; i++) {
                s[i] = stdIn.nextInt();
                sum += s[i];
            }
            double m = sum/(double)n;
            double a = 0.0;
            for(int i = 0; i < n; i++) {
                a += (s[i] - m)*(s[i] - m);
            }
            a= a/(double)n;
             
            System.out.println(Math.sqrt(a));
             
        }
    }
}


Measured memory_bytes: 31364
program ABC153D
    implicit none
    integer(8)::H,result,i
    read(5,*)H
    result=0
    i=0
    do
        H=H/2
        result=result+2**i
        if(H<=0)then
            exit
        end if
        i=i+1
    end do

    print'(i0)',result
end program ABC153D

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int N;
	char s[101];
	scanf("%d", &N);
	scanf("%s", s);
	int max = 0;

	for(int i=0;i<N;i++){
		bool b1[26];
		bool b2[26];
		int num = 0;
		for(int j=0;j<26;j++){
			b1[j] = false;
			b2[j] = false;
		}
		for(int j=0;j<i;j++){
			b1[s[j]-'a'] = true;
		}
		for(int j=i;j<N;j++){
			b2[s[j]-'a'] = true;
		}
		for(int j=0;j<26;j++){
			if(b1[j]&&b2[j]) num++;
		}
		if(num>max) max = num;
	}

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

	return 0;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int tmp;
	ll n, a, b;
	cin >> n >> a >> b;
	ll sho = n / (a+b);
	ans += sho * a;
	ll amr = n - sho * (a+b);
	ans += min(amr , a);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
typedef struct{
  double x;
  double y;
}point;
void kock(int, point, point);

int main(){

  int n;
  point p1, p2;

  scanf("%d", &n);
  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  printf("%.8f %.8f\n", p1.x, p1.y);
  kock(n, p1, p2);
  printf("%.8f %.8f\n",p2.x, p2.y);
  return 0;
}
void kock(int n,point p1,point p2){

  double rad = 60.0 * M_PI / 180.0;
  point a, b, c;

  if(n==0) return;

  a.x = (2*p1.x + p2.x) / 3;
  a.y = (2*p1.y + p2.y) / 3;
  b.x = (p1.x+2 * p2.x) / 3;
  b.y = (p1.y+2 * p2.y) / 3;
  c.x = (b.x-a.x) * cos(rad) - (b.y-a.y) * sin(rad) + a.x;
  c.y = (b.x-a.x) * sin(rad) + (b.y-a.y) * cos(rad) + a.y;

  kock(n-1, p1, a);
  printf("%.8f %.8f\n", a.x, a.y);
  kock(n-1, a, c);
  printf("%.8f %.8f\n", c.x, c.y);
  kock(n-1, c, b);
  printf("%.8f %.8f\n", b.x, b.y);
  kock(n-1, b, p2);
}



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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


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


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<double> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  const double INF = 1e18;
  auto dp=make_v<double>(n+1,m+1);
  fill_v(dp,-INF);
  dp[0][0]=0;
  for(Int i=0;i<n;i++){
    for(Int j=0;j<m;j++){
      double sum=0;
      for(Int k=1;i+k<=n;k++){
	sum+=a[i+k-1];
	chmax(dp[i+k][j+1],dp[i][j]+sum/k);
      }
    }
  }
  
  cout<<dp[n][m]<<endl;
  return 0;
}



Measured memory_bytes: 5128
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

const static int nmax = 40, abmax = 10;

int dp[nmax + 1][nmax * abmax + 1][nmax * abmax + 1];

int main() {
    int n;
    string S;
    cin >> S;
    n = S.length();
    llong ans = 0;
    rep (i, 1 << (n - 1)) {
        llong sum = 0;
        llong a = S[0] - '0';
        rep (j, n - 1) {
            if (i & (1 << j)) {
                sum += a;
                a = 0;
            }
            a = a * 10 + S[j + 1] - '0';
        }
        sum += a;
        ans += sum;
    }

    cout << ans << endl;

    return 0;
}


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


int main(void)
{	
	char s[3];
	scanf("%s",s);
	
	if(s[0]=='9' ||s[1]=='9'){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vector<int>x(N),y(M);
  for(int i=0;i<N;i++)cin>>x[i];
  for(int i=0;i<M;i++)cin>>y[i];
  for(int Z=X+1;Z<=Y;Z++){
    bool ok=true;
    for(int i=0;i<N;i++){
      if(!(x[i]<Z))ok=false;
    }
    for(int i=0;i<M;i++){
      if(!(y[i]>=Z))ok=false;
    }
    if(ok){
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>


//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
//#define TEST //*******************************************************************************************************************************************

//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
#ifdef TEST
    #define dout cout
#else
    #define dout dummy
#endif

using namespace std;
stringstream dummy; //????¨????????????°??¨dout?????????????????????????????????


int main(void) {
    int n;
    cin >> n;
    
    int a[n];
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }

#ifdef TEST
    //display a[]
    for(int k=0; k<n; k++) {
        cout << a[k] << " ";
    }
    cout << endl;
#endif
    

    //bubble sort procedure
    int cnt = 0;
    for(int i=0; i<n-1; i++) {
        for(int j=n-1; j>i; j--) {
            if( a[j-1] > a[j] ) {
                swap(a[j-1], a[j]);
                cnt++;
            }
#ifdef TEST
            dout << "i=" << i << " : j=" << j << " : ";
            //display a[]
            for(int k=0; k<n; k++) {
                dout << a[k] << " ";
            }
            dout << endl;
#endif

        }
    }

    //output
    //display a[]
    for(int k=0; k<n; k++) {
        if(k==0) cout << a[k];
        else cout << " " << a[k];
    }
    cout << endl;

    //times of swap
    cout << cnt << endl;
    
    return 0;
}

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

int main(void) {
	int n, q, b, e, k;
	scanf("%d", &n);
	vector<int> v;
	int temp;
	for (int loop = 0; loop < n; loop++) {
		scanf("%d", &temp);
		v.push_back(temp);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d%d", &b, &e, &k);
		cout << count(v.begin() + b, v.begin() + e, k) << endl;
	}
}


Measured memory_bytes: 3252
s = input()
kisuu = s[::2]
gusuu = s[1::2]
flag = 0
for i in range(len(kisuu)):
    if kisuu[i] == "L":
        flag = 1
for i in range(len(gusuu)):
    if gusuu[i] == "R":
        flag = 1
if flag == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7,inv2=(P+1)>>1;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2e5+5;
int c[N],d[N],a[N],zr[N],st[N],e[N],ie[N],cnt[N];
int n,top,res,ret;
inline void chg(R int x,R int y){for(;x<=n;x+=x&-x)++c[x],upd(d[x],y);}
inline int qc(R int x){R int res=0;for(;x;x-=x&-x)res+=c[x];return res;}
inline int qd(R int x){R int res=0;for(;x;x-=x&-x)upd(res,d[x]);return res;}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n),ret=1;
	fp(i,1,n)scanf("%d",&a[i]),++cnt[a[i]];
	fd(i,n-1,1)cnt[i]+=cnt[i+1];
	fp(i,1,n){
		cnt[i]-=n-i,ret=mul(ret,cnt[i]);
		if(cnt[i]<=0)return puts("0"),0;
	}
	top=e[0]=1;
	fp(i,1,n){
		R int x=mul(cnt[i]-1,ksm(cnt[i],P-2));
		if(!x)st[++top]=i;
		zr[i]=top,e[i]=x?mul(e[i-1],x):e[i-1];
		ie[i]=ksm(e[i],P-2);
	}
	fp(i,1,n){
		R int coef=mul(mul(ret,inv2),e[a[i]]);
		upd(res,mul(coef,inc(qd(a[i]),P-qd(st[zr[a[i]]]-1))));
		chg(a[i],ie[a[i]]);
	}
//	printf("%d\n",res);
	fp(i,1,n)c[i]=d[i]=0;
	fd(i,n,1){
		R int coef=mul(mul(ret,inv2),e[a[i]]);
		upd(res,P-mul(coef,inc(qd(a[i]-1),P-qd(st[zr[a[i]]]-1))));
		upd(res,mul(ret,qc(a[i]-1)));
		chg(a[i],ie[a[i]]);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;
int main()
{
	int N,u,i,k;
    cin >> N;
	u=N;
  k=1000;
	for(i=0;i<3;i++){
		k/=10;
		if(u/k==7){
			cout <<"Yes"<< endl;
			return 0;
		}else{
			u=u%k;
		}
	}
			
	cout <<"No"<< endl;
			return 0;
	
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<int>e[100005];
vector<int>edge[100005];
int used[100005];
int w[100005],k;
vector<int>E[100005];
ll W[100005];
int in[100005];
ll dp[100005];
int cnt[100005],c[100005];
int par[100005],ran[100005];
ll ans,add;
void init(){ for(int i=0;i<100005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
void dfs(int v,int u,int d){
	used[v] = d;//cout << v << endl;
	for(int i=0;i<e[v].size();i++){
		if(e[v][i] == u) continue;
		if(used[e[v][i]] && used[e[v][i]] < used[v]){
			cnt[e[v][i]]--;
			cnt[v]++;
			unite(e[v][i],v);
			//cout << v << " " << e[v][i] << endl;
			continue;
		}
		else if(used[e[v][i]]) continue;
		dfs(e[v][i],v,d+1); edge[v].pb(e[v][i]);edge[e[v][i]].pb(v); //cout << v << " " << e[v][i] << endl;
	}
}
int dfs2(int v,int u){
	int sum = 0;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i] == u) continue;
		int a = dfs2(edge[v][i],v);
		if(a>0){
		    //cout << edge[v][i] << " f" << v << endl;
			unite(edge[v][i],v);
		}
		sum += a;
	}
	sum += cnt[v];
	return sum;
}
pair<ll,bool> dfs3(int v,int p){
	ll ret = 0; bool ok = (c[v] >= 3);
	for(int i=0;i<E[v].size();i++){
		if(E[v][i] == p) continue;
		pair<ll,bool> t = dfs3(E[v][i],v);
		ret = max(ret,t.fi);
		ok |= t.sc;
	}
	if(ok){
		ret = 0;
		ans += W[v];
		//cout << v << endl;
	}
	else ret += W[v];
	add = max(add,ret);
	return mp(ret,ok);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d",&w[i]);
	for(int i=0;i<m;i++){
		int a,b; scanf("%d%d",&a,&b); a--; b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	init(); dfs(0,-1,1); dfs2(0,-1);
	for(int i=0;i<n;i++){
		W[find(i)] += w[i];
		c[find(i)] ++;
		for(int j=0;j<e[i].size();j++){
			if(find(i) != find(e[i][j])){
				E[find(i)].pb(find(e[i][j]));
				E[find(e[i][j])].pb(find(i));
			}
		}
	}
	for(int i=0;i<n;i++){
		SORT(E[i]); ERASE(E[i]);
	}
	dfs3(find(0),-1);
	cout << ans+add << endl;
}

Measured memory_bytes: 29800
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++){for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << p.first << " " << p.second;}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){for(auto &z:v)os << z << " ";cout<<"|"; return os;}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,x,m;cin>>n>>x>>m;
  ll sz=45;
  auto nxt=vec(sz,m,0LL);
  auto sum=vec(sz,m,0LL);
  rep(i,0,m){
    nxt[0][i]=(i*i)%m;
    sum[0][i]=i;
  }
  rep(i,0,sz-1){
    rep(j,0,m){
      nxt[i+1][j]=nxt[i][nxt[i][j]];
      sum[i+1][j]=sum[i][j]+sum[i][nxt[i][j]];
    }
  }
  //rep(i,0,sz)cout<<nxt[i][x] spa sum[i][x]<<endl;
  ll now=x;
  rep(i,0,sz){
    if(n&1){
      res+=sum[i][now];
      now=nxt[i][now];
    }
    n>>=1;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 74472
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> N;
    string ans = N >= 1000 ? "ABD" : "ABC";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
typedef struct{
  int x;
  char c;
}card;
card B[100000];
 
int Partition(int p, int r){
  card t;
  int x,i,j;
  x = B[r].x;
  i = p-1;
  for( j = p; j< r;j++){
    if (B[j].x <= x){
      i = i+1;
      t=B[i];
      B[i]=B[j];
      B[j]=t;
    }
  }
    t = B[i+1];
    B[i+1] = B[r];
    B[r] = t;
  return i+1;
}
 
void Quicksort(int p,int r){
  int q;
  if( p < r){
     q = Partition( p, r);
     Quicksort( p, q-1);
     Quicksort( q+1, r);
      }
  }
 
void merge(int left,int mid,int right,card A[]){
  int i,j,k;
  int n1 = mid-left;
  int n2 = right-mid;
  card L[100000],R[100000];
 
  for(i = 0;i<n1;i++){
    L[i]=A[left+i];
  }
 
  for(i = 0;i<n2;i++){
    R[i]=A[mid+i];
  }
   
  L[n1].x=INT_MAX;
  R[n2].x=INT_MAX;
  i=0;
  j=0;
  for(k = left; k<right; k++){
    if(L[i].x<=R[j].x){
      A[k]=L[i++];
    }
    else {
      A[k]=R[j++];
     }
  
  }
   
}
void mergeSort(int left,int right,card A[]){
  if(left+1 < right ){
  int mid = (left+right)/2;
  mergeSort(left,mid,A);
  mergeSort(mid,right,A);
  merge(left,mid,right,A);
  }
}
 
int main(){
  int i,p,n;
  char c;
  card C[100000];
  scanf("%d%c",&n,&c);
 
  for(i=0;i<n;i++){
    scanf("%c%d%c",&C[i].c,&C[i].x,&c);
    B[i]=C[i];
  }
 
  p=0;
  mergeSort(0,n,C);
  Quicksort(0,n-1);
  for(i=0;i<n;i++){
    if(C[i].c!=B[i].c){
      printf("Not stable\n");
      break;
    }
    if(i==n-1)printf("Stable\n");
  }
 
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].c,B[i].x);
    }
 
  return 0;
}

Measured memory_bytes: 2956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <limits.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE 100100
#define NIL -1
#define MAX_N 100100

double sq(double num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

int main() {
	cin >> n;
	ll ans = 1;
	while (n >= ans * 2) {
		ans *= 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def main(str)
  lines = str.split("\n")
  _n = lines[0].to_i
  as = lines[1].split(" ").map(&:to_i)
  _q = lines[2].to_i
  bcs = lines[3..-1].map { |x| x.split(" ").map(&:to_i) }
  ahash = as.each_with_object(Hash.new(0)) { |x, m| m[x] += 1 }
  asum = ahash.map { |k, v| k * v }.sum
  ans = bcs.map do |b, c|
    val = ahash[b] || 0
    ahash[c] += val
    ahash[b] = 0
    asum += (c - b) * val
  end
  ans.map(&:to_s).join("\n")
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("11
12
16", main("4
1 2 3 4
3
1 2
3 4
2 4"))
    assert_equal("8
4
4", main("4
1 1 1 1
3
1 2
2 1
3 5"))

    assert_equal("102
200
2000", main("2
1 2
3
1 100
2 100
100 1000"))
  end
end




Measured memory_bytes: 38876
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	string s, t;
	cin >> s >> t;
	
	int n = s.length();
	int m = t.length();
	int i, j;
	
	int ans = 11451419;
	rep(i, n - m + 1) {
		int cst = 0;
		rep(j, m) {
			if (t[j] != s[i + j]) {
				cst++;
			}
		}
		ans = min(ans, cst);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
li = [input() for i in range(n)]

for i in range(n-1):
    if li[i][-1] == li[i+1][0]:
        flag = True
    elif li[i][-1] != li[i+1][0]:
        flag = False
        break
if flag == True and len(li) == len(set(li)):
    print("Yes")
else:
    print("No")

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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    // A
    int cnt = min(a, k);
    k -= cnt;
    ans += cnt;
    // B
    cnt = min(b, k);
    k -= cnt;
    // C
    cnt = min(c, k);
    ans -= cnt;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
#define er erase
#define in insert
#define pi pair <int, int>
# define sz(x) (int)((x).size())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1999999973;
const int N = 2e5 + 11;

int dp[N][3],n,k,x;
vector<int>v;

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);

//ifstream cin("flip.in");
//ofstream cout("flip.out");

    cin >> n;

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

        for(int j = 0; j < 3; j++){

                cin >> x; 

                for(int jj = 0; jj < 3; jj++){

                    if(jj!=j)dp[i][j] = max(dp[i][j] , dp[i-1][jj] + x);

                }

        }

    }

    int ans = max({dp[n][0] , dp[n][1] , dp[n][2]});
    rc(ans);

return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int N;
std::string S;

int main(int argc, char **argv) {
    std::cin >> N;
    std::cin >> S;

    int x = 0;
    int ret = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'I') {
            x++;
        } else {
            x--;
        }
        ret = std::max(ret, x);
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
//#define int long long
int32_t main()
{


	int n; cin >> n;n--;
	int ans = 0;
	rep(i,1,n){
		ans += n/i;
	}
	cout << ans;
 //  rep(n,1,10)
	// {
 //  	// int n = 100;
 //   int ans =0;
 //   rep(i,1,n){
 //   	rep(j,1,n){
 //   		rep(k,1,n){
 //   			ans += ((i * k + j) == n);
 //   		}
 //   	}
 //   }
 //   cout << ans << " ";
 // }
}

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

int main(){
  int i,j,n,max,sum,a[5001];
  while(1){
    cin>>n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin>>a[i];
    }
    max=a[0];
    for(i=0;i<n;i++){ 
      sum=0;
      for(j=i;j<n;j++){
	sum+=a[j];
	if(max<sum)max=sum;	
      }
    }
    cout<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

vector< vector<int> > edges;
vector<int> visited;
vector<int> dist;


void visit(int node, int L) {
    if (visited[node] == 1) {
        return;
    }

    dist[node] = L;
    visited[node] = 1;

    for(int i = 0; i < edges[node].size(); i++) {
        visit(edges[node][i], L + 1);
    }
}


int main(int argc, char** argv) {
    int N;
    int u, v;
    int A, B;

    cin >> N >> u >> v;
    u -= 1;
    v -= 1;

    edges.resize(N, vector<int>());
    visited.resize(N, 0);
    dist.resize(N, 0);

    for(int i = 0; i < N - 1; i++) {
        cin >> A >> B;
        A -= 1;
        B -= 1;
        edges[A].push_back(B);
        edges[B].push_back(A);
    }

    visit(u, 0);
    vector<int> dist1(N, 0);
    for(int i = 0; i < N;i++) {
        dist1[i] = dist[i];
    }

    dist.resize(N, 0);
    visited.resize(N, 0);
    for(int i = 0; i < N;i++) {
        dist[i] = 0;
        visited[i] = 0;
    }
    visit(v, 0);
    vector<int> dist2(N, 0);
    for(int i = 0; i < N;i++) {
        dist2[i] = dist[i];
    }

    int moves = dist1[v] - 1;
    int tmp;
    for(int i = 0; i < N; i++) {
        if (i != u && i != v && dist1[i] < dist2[i]) {
            moves = max(dist2[i] - 1, moves);
        }
    }

    cout << moves << endl;
}


Measured memory_bytes: 9856
N=int(input())
S=[""]*N
T=[""]*N
for i in range(N):
  S[i]=list(input().split())
  S[i][1]=-int(S[i][1])
  T[i]=S[i]
S.sort(key=lambda x:(x[0],x[1]))
for i in range(N):
  for j in range(N):
      if(T[j]==S[i]):
        print(j+1)

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

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i, n) {
    string ss;
    cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  string min_s;
  rep(i, n) {
    min_s += s.at(i);
  }
  cout << min_s << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mxn 200005
#define mod 998244353ll
using namespace std;
ll p10[mxn], p11[mxn], lazy[4*mxn], seg[4*mxn];
int N;
void propagate(int n, int s, int e)
{
    lazy[n*2]= lazy[n];
    lazy[n*2 +1]= lazy[n];
    int mid= (s+e)/2;
    seg[n*2]= (((p11[mid-s+1]*lazy[n])%mod)*p10[N-mid+1])%mod;
    seg[n*2 +1]= (((p11[e-mid]*lazy[n])%mod)*p10[N-e+1])%mod;
    lazy[n]= 0;
    return;
}
void update(int n, int s, int e, int l, int r, int d)
{
    if(s>=l && e<=r)
    {
        lazy[n]= d;
        seg[n]= (((p11[e-s+1]*d)%mod)*p10[N-e+1])%mod;
        return;
    }
    if(s>r || e<l)return;
    if(lazy[n])propagate(n, s, e);
    int mid= (s+e)/2;
    update(n*2, s, mid, l, r, d);
    update(n*2 +1, mid+1, e, l, r, d);
    seg[n]= (seg[n*2]+seg[n*2 +1])%mod;
    return;
}
int main()
{
    p10[1]= 1;
    p11[1]= 1;
    for(int i=2; i<mxn-2; i++)
    p10[i]= (p10[i-1]*10)%mod,
    p11[i]= (p11[i-1]+p10[i])%mod;
    int n, q;
    scanf("%d %d", &n, &q);
    N= n;
    for(int i=1; i<=n; i++)
    update(1, 1, N, i, i, 1);
    while(q--)
    {
        int l, r, d;
        scanf("%d %d %d", &l, &r, &d);
        update(1, 1, N, l, r, d);
        printf("%lld\n", seg[1]);
    }
    return 0;
}


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

int main() {
  int N;
  string A;
  cin >> N;
  
  vector<int> vec(4);
  for(int i=0;i<N;i++){
    cin >> A;
    if(A=="AC"){vec.at(0)++;}
    if(A=="WA"){vec.at(1)++;}
    if(A=="TLE"){vec.at(2)++;}
    if(A=="RE"){vec.at(3)++;}
  }  
  
  cout << "AC x " << vec.at(0) << endl
  << "WA x " << vec.at(1) << endl
  << "TLE x " << vec.at(2) << endl 
  << "RE x " << vec.at(3) << endl;
}

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

using namespace std;

int main(void) {
  long long s;
  cin >> s;

  const int v = 1000000000;

  int x = (v - s % v) % v;
  int y = (s + x) / v;

  cout << "0 0 1000000000 1 " << x << " " << y << endl;
}

Measured memory_bytes: 256
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''


K = int(input())

runrun = []
runrun.append([1, 2, 3, 4, 5, 6, 7, 8, 9])


if K <= 9:
    print(K)
    sys.exit()


keta = 10
for i in range(1, 20):
    max = 9*pow(3, i-1)

    if max>=K:
        keta = i
        break

for i in range(2, keta+2):
    temp = []
    for j in range(len(runrun[i-2])):

        last = runrun[i-2][j] % 10

        tugi = (last+1) 
        same = last
        mae = (last-1) 

        if tugi != 10:
            temp.append(runrun[i-2][j]*10 + tugi)
        temp.append(runrun[i-2][j]*10 + same)
        
        if mae != -1:
            temp.append(runrun[i-2][j]*10 + mae)

    runrun.append(temp)

sum_size = 0
nokori  =0
for i in range(100):
    runrun[i].sort()
    sum_size+=len(runrun[i])
    if sum_size >= K:
        keta = i
        nokori = K- sum_size+len(runrun[i])
        break

runrun[keta].sort()

print(runrun[keta][nokori-1])
        













Measured memory_bytes: 32364
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);} while(0)
  #define trcc(v) do { cerr << "name : " << #v << "\n"; int cnt = 0; each(x , v){cerr << (cnt++) << " : "; trc(x); } } while(0)
#else
  #define trc(...)
  #define trca(...)
  #define trcc(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(s,t)   rep(i,sz(s)){in(s[i] , t[i]);}
#define in3(s,t,u) rep(i,sz(s)){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  inl(N,T);
  vl a(N); in(a);
  vl rui(N + 1);
  repr(i,N){
    rui[i] = max(rui[i + 1] , a[i]);
  }
  trc(rui);
  map<ll,int> m;
  rep(i,N - 1){
    if(rui[i + 1] > a[i]) m[rui[i + 1] - a[i]]++;
  }
  trcc(m);
  out((--m.end())->second);

}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
class Quatre{
  public:
    int a, b, c, d;
    Quatre(int w, int x, int y, int z){
        a = w;
        b = x;
        c = y;
        d = z;
    }
};
void Main(){
    int H = read(), W = read();
    vector<Quatre> Q;
    vector<vector<int> > A(H, vector<int>(W));
    for (int i = 0; i<H; i++) {
        for (int j = 0; j<W; j++) {
            A[i][j] = read();
        }
    }
    for (int i = 0; i<H-1; i++) {
        for (int j = 0; j<W; j++) {
            if (A[i][j]%2 == 1) {
                A[i+1][j]++;
                Q.push_back(Quatre(i+1, j+1, i+2, j+1));
            }
        }
    }
    for (int j = 0; j<W-1; j++) if (A[H-1][j]%2 == 1) {
        A[H-1][j+1]++;
        Q.push_back(Quatre(H, j+1, H, j+2));
    }
    printf("%d\n", (int)Q.size());
    for (auto q:Q) printf("%d %d %d %d\n", q.a, q.b, q.c, q.d);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 5236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int[] vals = new int[N];
		int xor = 0;
		for (int i = 0; i < N; i++) {
			vals[i] = sc.nextInt();
			xor ^= vals[i];
		}
		for (int i = 0; i < N; i++) {
			out.print((xor ^ vals[i]) + " ");
		}
		out.println();
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 58756
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int x[5];
	cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) {
			cout << i + 1 << endl;
		}
	}


	return 0;
}

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

int a, b;

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

	cout << a / b << " " << a%b << " " << fixed << setprecision(5) << (double)a / (double)b << "\n";

	return 0;
}

Measured memory_bytes: 3272
// CF2017A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <algorithm>
#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;
    string head = s.substr(0, 4);
    if (s.size() < 4) {
        cout << "No" << endl;
        return 0;
    }
    if (head != "YAKI") {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3080
H, W, A, B = map(int, input().split())
C = H - A
D = W - B
p = 1000000007

def power(a, b): #a^b (mod p)を求める #二分累乗法を使う
    if b == 0:
        return 1
    elif b % 2 == 0:
        return power(a, b//2) ** 2 % p
    else:
        return power(a, b//2) ** 2 * a % p

f = [1] #f[i] = i! % p
for i in range(H+W):
    f.append(f[i] * (i+1) % p)

I_f = [0] * (H+W+1) #I_f[i] = (i!)^(-1) % p
I_f[H+W] = power(f[H+W], p-2)
for i in reversed(range(H+W)):
    I_f[i] = I_f[i+1] * (i+1) % p

def combi(a, b): #(a+b)!/a!b! (mod p)を求める
    return f[a+b] * I_f[a] * I_f[b] % p

x = 0
for i in range(C):
    x = (x + combi(i, B-1) * combi(D-1, H-i-1)) % p
print(x)


Measured memory_bytes: 24828
#include<cstdio>
int n,m,bcj[100005];
int findf(int x)
{
	if(x==bcj[x])
		return x;
	return bcj[x]=findf(bcj[x]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		bcj[i]=i;
	for(int i=1;i<=m;++i)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(findf(a)!=findf(b))
			bcj[findf(a)]=findf(b);
	}
	int ans=-1;
	for(int i=1;i<=n;++i)
		ans+=(i==bcj[i]);
	printf("%d",ans);
}

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

typedef long int32;
typedef unsigned long uint32;
typedef long long int64;
typedef unsigned long long uint64;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> graphi;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rFOR(i,a,b) for(int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x,n) FOR(i,0,n) cout << x[i] << " "; cout << endl

// Custom global variable >>>>>>>>>>>>>



// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
auto main() -> int
{
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
  #endif
  // Fast I/O
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  // Code starts here ---

  int n;
  cin >> n;
  vi arr(n);
  FOR(i,0,n) cin >> arr[i];
  set<int> arr1(arr.begin(), arr.end());

  int a = *prev(arr1.end());
  int b = *prev(prev(arr1.end()));

  int d = 0;
  for(auto i:arr) if(i == a) d++;

  if(d > 1) {
    FOR(i,0,n) cout << a << "\n";
  } else {
    for(auto i: arr) {
      if(i != a) cout << a << "\n";
      else cout << b << "\n";
    }
  }

  // --------------------
  #ifdef DEBUG
    cerr << endl << "Time:" << double(clock())/CLOCKS_PER_SEC << " secs" << endl;
  #endif
}


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

int main() {
char c;
cin >> c;
if(c == 'a' || c == 'i' || c == 'u' || c == 'o' || c == 'e')
  cout << "vowel" << endl;
else
  cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	ll n;
	cin>>n;
	if(n%10==2 || n%10==7 || n%10==5 || n%10==4 || n%10==9)cout<<"hon";
	else if(n%10==3)cout<<"bon";
	else cout<<"pon";	
}

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

int main() {
  vector<int> cnt(4);
  int tmp;
  rep(i, 6) {
    cin >> tmp;
    tmp--;
    cnt[tmp]++;
  }
  rep(i, 4) {
    if (cnt[i] == 3) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
    


Measured memory_bytes: 384
N = gets.chomp.to_i
h = gets.chomp.split(" ")
line = [0] * (N + 1)

(1..N).each do |k|
  if k == 1 then
    line[k] = 0
  elsif k == 2 then
    line[k] = line[k-1] + (h[1].to_i - h[0].to_i).abs
  else
    line[k] = [line[k-1] + (h[k-1].to_i - h[k-2].to_i).abs, line[k-2] + (h[k-1].to_i - h[k-3].to_i).abs].min
  end
end

puts line[N]

Measured memory_bytes: 11020
#include <iostream>
#include<vector>
#include <cmath>
 
using namespace std;
 
int main() 
{
   
   int n;
   long long int result=1;
   cin>>n;
   long long int input;
   long long int wrong=pow(10,18);
   bool isBad = false;
   for (int i = 0; i < n; i++)
   {
       cin>>input;

      if (input == 0) {
          cout << 0;
          return 0;
      }

      if (log10(input) + log10(result) > 18) {
          isBad = true;
      }

      if (isBad == false) {
          result=result*input;
      }
   }


   if (result > wrong || isBad == true)
   {
   cout<<-1;
   }
   else
    {
    	cout<<result;
    }
}

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

typedef long long ll;

ll check(map<int, bool> a, map<int, bool> b, map<int, bool> c){
    ll ans = 0;
    for(auto x: a){
        for(auto y: b){
            int target = x.first + y.first;
            if(target % 2 == 0 && c.count(target/2) != 0){
                ans++;
            }
        }
    }
    return ans;
}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    cin >> N;
    string S ;
    cin >> S;
    map<int, bool> a,b,c;
    for(int i = 0; i < N; i++){
        if(S[i] == 'R' ) a[i] = true;
        if(S[i] == 'G' ) b[i] = true;
        if(S[i] == 'B' ) c[i] = true;
    }
    ll ans = 0;
    ans = a.size() * b.size() * c.size();
    ans -= check(a,b,c);
    ans -= check(a,c,b);
    ans -= check(b,c,a);
    cout << ans << endl;
}


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))
#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) ((x) / (y))
#define DIVROUND(x, y) (MOD(x, y) * 2 >= (y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

using ll = long long;

int main() {
  ll S;
  cin >> S;

  ll z = static_cast<ll>(sqrt(S));
  while (z * z < S) {
    ++z;
  }

  if (z * z == S) {
    printf("%d %d %d %d %d %d\n", 0, 0, z, 0, 0, z);
  } else {
//    for (int x1{1}; x1 <= z; ++x1) {
      int x1 = DIVCEIL(S+1, z);
      for (int y1{1}; y1 <= z; ++y1) {
        if (abs(x1 * z - 1 * y1) == S) {
          printf("%d %d %d %d %d %d\n", 0, 0, x1, y1, 1, z);
          return 0;
        }
      }
//    }
  }

  return 0;
}


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

int arr[1005][1005];
int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  memset(arr, 0, sizeof(arr));

  //if b = 0
  if (b == 0){
    if (a == 0){
      for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
          if (j == w)
            cout << "1" << endl;
          else
            cout << "1";
        }
      }
    }
    else{
      for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
          if (j <= a)
            arr[i][j] = 1;
        
          if (j == w)
            cout << arr[i][j] << endl;
          else
            cout << arr[i][j];
        }
      }
    }
  }

  else if (a == 0){
    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        if (i <= b)
          arr[i][j] = 1;

        if (j == w)
          cout << arr[i][j] << endl;
        else
          cout << arr[i][j];
      }
    }
  }


  //if normal
  else{
    for (int i = 1; i <= h; i++){
      for (int j = 1; j <= w; j++){
        //if i and j in square one
        if (i <= b && j <= a)
          arr[i][j] = 1;
        else if ((i >= b+1) && (j >= a+1)){
          arr[i][j] = 1;
        }

        if (j == w)
          cout << arr[i][j] << endl;
        else
          cout << arr[i][j];
      }
    }
  }
  return 0;
}

Measured memory_bytes: 7536
import sys, math, itertools, collections, bisect
n,k=map(int,input().split())
h=[]
for i in range(n):
    tmp=int(input())
    h.append(tmp)
h.sort()
min=10000000000
for i in range(len(h)-k+1):
    tmp2=h[i+k-1]-h[i]
    if min>tmp2:
        min=tmp2
print(min)


Measured memory_bytes: 50264
n = gets.to_i
arms = n.times.map do
  x, l = gets.split(' ').map(&:to_i)
  [x - l, x + l]
end
arms.sort_by! do |a|
  a[1]
end
tmp = arms.first[0]
res = 0
arms.each do |a|
  if tmp <= a[0]
    res += 1
    tmp = a[1]
  end
end
p res


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

int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  a = N / 1000;
  b = N / 100 % 10;
  c = N / 10 % 10;
  d = N % 10;
  
  if ( a==b && b==c) cout <<  "Yes" << endl;
  else if ( b==c && c==d) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256