akhauriyash/Code-Regression huggingface dataset:
/*
{
######################
#       Author       #
#        Gary        #
#        2020        #
######################
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int up[100000+20];
int n;
int a[100000+20];
vector<int> g[100000+20];
bool check(vector<int> v,LL x,LL sum){
	for(auto& it:v){
		if(it*2>sum){
			sum-=(2*it+1-sum)/2;
			return (sum/2)>=x;
		}
	}
	return (sum/2)>=x;
}
void dfs(int now,int prev=0){
	if((!prev)+g[now].size()==1){
		up[now]=a[now];
		return ;
	}
	LL sum=0;
	vector<int> v;
	for(auto it:g[now]){
		if(it!=prev){
			dfs(it,now);
			sum+=up[it];
			v.PB(up[it]);
		}
	}
	if(sum<a[now]){
		cout<<"NO"<<endl;
		exit(0);
	}
	if(!check(v,sum-a[now],sum)){
		cout<<"NO"<<endl;
		exit(0);
	}
	up[now]=a[now]+a[now]-sum;
	if(up[now]<0){
		cout<<"NO"<<endl;
		exit(0);
	}
}
int main(){
	fastio;
	int n;
	R(n);
	rb(i,1,n)
		R(a[i]);
	rb(i,1,n-1){
		int u,v;
		R2(u,v);
		g[u].PB(v);
		g[v].PB(u);
	}
	int root=-1;
	rb(i,1,n)
		if(g[i].size()!=1) root=i;
	if(root==-1){
		cout<<(a[1]==a[2]? "YES":"NO");
		return 0;
	}
	dfs(root);
	if(up[root]==0)
	cout<<"YES"<<endl;
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}
/** 程序框架：
  *
  *
  *
  *
  **/


Measured memory_bytes: 19768
#include <stdio.h>

int main(void) {
  int n,x,t;
  scanf("%d",&n);
  scanf("%d",&x);
  scanf("%d",&t);
  if(n%x>1)
  printf("%d",n/x*t+t);
  else
  printf("%d",n/x*t);
  return 0;
}

Measured memory_bytes: 1736
use std::io::*;
use std::str::FromStr;
use std::cmp;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}



fn main() {
    let (n, k):(u32, usize) = read_tuple2();
    let mut ps:Vec<u32> = (0..n).map(|_|read()).collect();
    ps.sort();
    let ans:u32 =ps[0..k].iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 2164
import java.util.*;
public class Main {
	static int cnt=0,n;
	static int bfs(int sum,int mae){
		if(sum==n)return 1;
		if(sum>n)return 0;
		return bfs(sum+mae+1,mae+1);
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(true){
			cnt=0;
			n = in.nextInt();
			if(n==0)break;
			for(int i=1;i<n;i++){
				cnt+=bfs(i,i);
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 19836
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

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

int MOD = 1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


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

	int mx=0, mx2=0; int cnt=0;
	int N; cin >> N;
	REP(i, N) {
		cin >> A[i];
		chmax(mx, A[i]);
	}

	REP(i, N) {
		if (A[i] == mx) {
			cnt++;
		}
	}
	if (cnt == 1) {
		REP(i, N) {
			if (A[i] == mx)continue;
			chmax(mx2, A[i]);
		}
		REP(i, N) {
			if (A[i] == mx) {
				print(mx2);
			}
			else print(mx);
		}
	}
	else {
		REP(i, N) {
			print(mx);
		}
	}
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif */

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    ll x,k,d;
    cin>>x>>k>>d;
    ll ans;
    if(x < 0)
      x = -x;
    if(k <= (x/d))
      cout<<(x - k*d)<<endl;
    else
    {
      ll rem = k - x/d;
      if(rem&1)
      {
        ans = d - x%d;
      }
      else
        ans = x%d;
      cout<<abs(ans)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b;
    map<string,long int>mp;
    string str,r;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&a);
        cin>>str;
        if(a==0)
        {
            scanf("%d",&b);
            mp[str]=b;
        }
        else if(a==2)
            mp.erase(str);
        else if(a==3)
        {
            cin >> r;
            auto x = mp.lower_bound(str);
            auto y = mp.upper_bound(r);
            for(; x != y; x++)
                cout << (*x).first << " " << (*x).second << "\n";
        }
        else{
            if(mp.count(str))  cout << mp[str] << endl;
            else            cout << 0 << endl;
        }
    }
    return 0;
}




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


int solve(){
  int n;  cin >> n;
  for(int i=0; i<n; i++){
    int a;  cin >> a;
    if(a%2==0){
      bool out = true;
      if(a%3==0){
        out = false;
      }
      if(a%5==0){
        out = false;
      }
      if(out){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 1;
}

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


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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c;

	if( a > b ){ d = a; a = b; b=d; }
	if( b > c ){ d = b; b = c; c=d; }
	if( a > b ){ d = a; a = b; b=d; }
	cout << a << " " << b << " " << c << endl; 

	return 0;
}

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

using namespace std;


int N;
vector<int> v;



int main()
{

	cin >> N;

	v = vector<int>(N);
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}

	double ans = 0.0;

	sort(v.begin(), v.end());
		

	int div = 1;


	ans = 0;
	ans = v.at(0);

	for (int i = 1; i < N; i++) {
		ans += v.at(i);
		ans /= (double)2;
	}

	cout << fixed;
	cout << setprecision(10) << ans << endl;


	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
main ()
{ int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if (a>=1 && a<=13)
if (b>=1 && b<=13)
if (c>=1 && c<=13)
{ if (a+c+b>=22)
printf("bust\n");
else printf("win\n");
}}

Measured memory_bytes: 128
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

import Data.Map.Strict as M

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = Data.List.map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = Data.List.map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
-- 	ss <- Data.List.map B.unpack . B.lines <$> B.getContents
	ss <- Data.List.map B.unpack <$> replicateM n B.getLine
	mapM_ putStrLn $ solve ss

solve ss = runST $ do
	counts <- newSTRef ( M.empty :: M.Map String Int )
	forM_ ss $ \s -> do
		modifySTRef counts =<< 
			M.insert s . succ . fromMaybe 0 . M.lookup s <$> readSTRef counts
	ma <- maximum . M.elems <$> readSTRef counts
	sort . M.keys . M.filter ( == ma ) <$> readSTRef counts

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

const int N = 2e5+2;

int n;
int a[N];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a+i);
    }
    int ans = 0;
    int cur = 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] != cur) ++ans;
        else ++cur;
    }
    if (cur == 1) return !printf("-1");
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int K;
VI ans;


int S(int x){
    int res = 0;
    while(x > 0){
        res += x%10;
        x /= 10;
    }
    return res;
}


double g(int x){
    return (double)x/S(x);
}


signed main(){
    cin >> K;

    repe(i, 1, 999) ans.pb(i);
    int p10 = 10, n = 9;
    repe(i, 1, 12){
        repe(j, 1, 999) if(j*p10+n <= 1e15-1) ans.pb(j*p10+n);
        n *= 10;
        n += 9;
        p10 *= 10;
    }

    sort(ALL(ans), greater<int>());
    UNIQUE(ans);

    auto it = begin(ans);
    double m = g(*it);
    it++;
    while(it != end(ans))
        if(chmin(m, g(*it), true)) it++;
        else it = ans.erase(it);

    reverse(ALL(ans));
    rep(i, 0, K) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<vector>
using namespace std;

long long num[200005];

void debugout ( long long value ){
    cout << value  << endl;
}


int main(){

    int maxLength;
    cin >> maxLength;

    string s;
    cin >> s;

    int realLength = s.length();

    if( realLength <= maxLength ){
        cout << s << endl;
    } else {
        for( int i = 0 ; i < maxLength ; i++){
            cout << s[i];
        }

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





Measured memory_bytes: 3600
/*input
2
1
2 0
1
1 0

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
typedef vector<int> vii;
typedef pair<int,int> pii;
#define F first
#define S second
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void solve(){
	int n;cin>>n;
	vector<pair<int,int>> a[n];
	for(int i=0;i<n;++i){
		int x;cin>>x;
		for(int j=0;j<x;++j){
			int y,z;cin>>y>>z;
			a[i].pb({y,z});
		}
	}int ans = 0;
	for(int i=0;i<(1<<n);++i){
		bool honest[n];
		for(int u=0;u<n;++u){
			if((i>>u)&1)
				honest[u] = true;
			else
				honest[u] = false;

		}
		int t=0;
		bool possible = true;
		// cout<<"start: "<<i<<endl;
		for(int j=0;j<n;++j){
			// cout<<"j: "<<j<<endl;
			if(honest[j]){
				++t;
				for(auto xx:a[j]){
					// cout<<xx.first<<' '<<xx.second<<endl;
					if(xx.second==1){
						if(!honest[xx.first-1]){
							possible = false;
						}
					}
					else{
						if(honest[xx.first-1])
							possible = false;
					}
				}
			}
		}
		
		if(possible)
			ans=max(ans,t);
	}
	cout<<ans<<endl;
}

signed main(){
	IOS
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main() {
	char b;
	cin >> b;
	if(b == 'A') {
		cout << "T" << endl;
	}
	if(b == 'T') {
		cout << "A" << endl;
	}
	if(b == 'G') {
		cout << "C" << endl;
	}
	if(b == 'C') {
		cout << "G" << endl;
	}

    return 0;
}

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

#define f(i,a,b) for( ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based



using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 1e5 + 100;
const ll inf = 1e9;
const ll mod = 1e9+7;



int main(){
	fastio;
	ll m,d,ans = 0;
	cin >> m >> d;
	f(i,1,m+1){
		f(j,10,d+1){
			ll x = j/10, y = j%10;
			if(x>1 && y>1 && x*y == i) ans++;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

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

    auto slen = (int) s.length();
    auto tlen = (int) t.length();

    if (slen < tlen) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    set<string> st;
    for (auto i = 0; i <= slen - tlen; ++i) {
        auto flag = true;
        for (int j = 0; j < tlen; ++j) {
            if (s[i + j] != '?' && s[i + j] != t[j]) {
                flag = false;
            }
        }

        if (flag) {
            string ans = s;
            for (int k = 0; k < tlen; ++k) {
                ans[i + k] = t[k];
            }
            replace(ans.begin(), ans.end(), '?', 'a');
            st.insert(ans);
        }
    }

    if (st.empty()) {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << *st.begin() << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

bool isprime(llong num){
    if(num==1){
        return false;
    }
    if(num==2){
        return true;
    }
    for(int i=2; i<=sqrt(num); i++){
        if(num%i==0){
            return false;
        }
    }
    return true;
}

//約数列挙
void EnumerateFactor(vector<vector<llong> > &factor_list, llong num){
    llong cnt=0;
    for(int i=1; i<=sqrt(num); i++){
        if(num%i==0){
            factor_list[cnt].push_back(i);
            factor_list[cnt].push_back(num/i);
            cnt++;
        }
    }
}

int main(){
    llong n;
    llong ans=INF;
    llong temp=-1*INF;
    vector<vector<llong> > factor_list(100000);
    string A, B;

    scanf("%lld", &n);
    EnumerateFactor(factor_list, n);
    for(int i=0; i<factor_list.size(); i++){
        if(factor_list[i].size()==0){
            break;
        }
        A = to_string(factor_list[i][0]);
        B = to_string(factor_list[i][1]);
        temp = max(A.size(), B.size());
        ans  = min(temp, ans);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 4992
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
a = int(input())


if (n%500 <= a):
    print("Yes")
else:
    print("No")




Measured memory_bytes: 9036
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
int main(){
    string s;
    cin>>s;
    int num=0,cnt=0;
    for (int i=0;i<s.length();i++){
        num=num*10+s[i]-'0';
        cnt+=s[i]-'0';
    }
    if (num%cnt==0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
 
using namespace std;
 
int kInf = 1 << 20;
int dtime[101][101];
int dcost[101][101];
 
int n, m;
 
void wf() {
    for(int k = 1; k <= m; k++)
        for(int i = 1; i <= m; i++)
            for (int j = 1; j <= m; j++) {
                dtime[i][j] = min(dtime[i][j], dtime[i][k] + dtime[k][j]);
                dcost[i][j] = min(dcost[i][j], dcost[i][k] + dcost[k][j]);
            }
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    while (cin >> n >> m, n || m) {
        fill(dtime[0], dtime[101], kInf);
        fill(dcost[0], dcost[101], kInf);
        for (int i = 0; i < 101; i++)
            dtime[i][i] = dcost[i][i] = 0;
        for (int i = 0; i < n; i++) {
            int a, b, cost, time;
            cin >> a >> b >> cost >> time;
            dtime[a][b] = dtime[b][a] = time;
            dcost[a][b] = dcost[b][a] = cost;
        }
        wf();
        int k;
        cin >> k;
        for (int i = 0; i < k; i++) {
            int p, q, r;
            cin >> p >> q >> r;
            if(r)
                cout << dtime[p][q] << endl;
            else
                cout << dcost[p][q] << endl;
        }
    }
}

Measured memory_bytes: 1276
n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
arm = [list(map(int, input().split())) for j in range(n)]  # 入力
ans = -9999999999  # 最小
for item in range(1, (1<<10)):  # 2 ** 10 == 1024
    fund = 0
    for i in range(n):  # 店の数
        cou = 0  # かぶる数
        for x in range(10):  # 月-金(5) * 2
            if (item >> x) % 2 == 1 and arr[i][x] == 1:  # その時間で被るかどうか
                cou += 1
        fund += arm[i][cou]
    ans = max(ans, fund)  # 最大値更新
print(ans)

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

using namespace std;

string S;
bool check_1 = true, check_2 = true;

int main()
{
    cin >> S;

    for (int i = 0; i < S.length(); i += 2) {
        if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D'))
            check_1 = false;
    }

    for (int i = 1; i < S.length(); i += 2) {
        if (!(S[i] == 'L' || S[i] == 'U' || S[i] == 'D'))
            check_2 = false;
    }

    if (check_1 && check_2) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
//n=\prod_i l[i]^e[i] (i=j\iff l[i]=l[j])
int factorize(long long n, long long l[], long long e[]){
    long long k=n;
    int i=0;
    if(k%2==0){
        int e2=0;
        while(k%2==0){
            e2++;
            k/=2;
        }
        l[i]=2;
        e[i]=e2;
        i++;
    }
    for(long long q=3;q*q<=n;q+=2){
        if(k%q==0){
            int ei=0;
            while(k%q==0){
                ei++;
                k/=q;
            }
            l[i]=q;
            e[i]=ei;
            i++;
            if(k==1)break;
        }
    }
    if(k>1){
        l[i]=k;
        e[i]=1;
        i++;
    }
    return i;
}
int main(){
    long long n,p,l[20],e[20];
    scanf("%lld%lld",&n,&p);
    int m=factorize(p,l,e);
    long long ans=1;
    for(int i=0;i<m;i++){
        for(int j=0;j<e[i]/n;j++)ans*=l[i];
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 128
#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++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100;


int main(){
  int N = in(), K = in(), h, count = 0;

  rep(i, N){
    h = in();
    if(h >= K) count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>

using namespace std;
int n;
char st[30010];
int nex[30010][10];

bool check(int a,int b,int c){
    int st=nex[0][a];
    if (st==-1) return false;
    st=nex[st][b];if (st==-1) return false;
    st=nex[st][c];
    if (st!=-1)
        return true;
    return false;

}

int main()
{

    scanf("%d",&n);
    scanf("%s",st+1);
    for (int i=n;i>=0;--i){
        if(i==n){
            for (int j=0;j<10;++j)
                nex[i][j]=-1;
            continue;
        }
        for (int j=0;j<10;++j)
            nex[i][j]=nex[i+1][j];
        nex[i][ st[i+1]-'0' ] = i+1;
    }
    int ans=0;
    for (int i=0;i<10;++i)
    for (int j=0;j<10;++j)
    for (int k=0;k<10;++k)
    if (check(i,j,k))
        ans++;
    printf("%d\n",ans);


}





Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
//using System.Numerics;
class Program
{       
    public void Slove()
    {
        int n = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
        array = array.Select((x, i) => x - i - 1).ToArray();
        int center = array.OrderBy(x => x).ToArray()[n / 2];
        System.Console.WriteLine(array.Sum(x => (long)Math.Abs(x - center)));
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k,a,b;
    cin >> k >> a>> b;
    for(int i= a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3656
using System;

namespace A___On_the_Way
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var c = int.Parse (input[2]);
            if (Math.Min (a, b) < c && c < Math.Max (a, b))
                Console.WriteLine ("Yes");

            else
                Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Problem0028
    {
        static void Main()
        {
            const int maxItems = 100;
            var nums = new Dictionary<int, int>(maxItems);
            foreach (var i in ReadNumbers().Take(maxItems))
            {
                if (nums.ContainsKey(i))
                    ++nums[i];
                else
                    nums[i] = 1;
            }
            var maxCount = nums.Max(kv => kv.Value);
            foreach (var n in nums.Where(kv => kv.Value == maxCount).Select(kv => kv.Key))
                Console.WriteLine(n);
        }

        static IEnumerable<int> ReadNumbers()
        {
            string line;
            while (!string.IsNullOrEmpty(line = Console.ReadLine()))
                yield return int.Parse(line);
        }
    }
}

Measured memory_bytes: 6368
N, Q = map(int, input().split())
S = input()
s = [0] * N

for i in range(1, N):
    s[i] += s[i - 1]
    if S[i] == "C" and S[i - 1] == "A":
        s[i] += 1

for _ in range(Q):
    l, r = map(int, input().split())
    print(s[r - 1] - s[l - 1])


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

using namespace std;

int solve() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> lens(N);
  for (int i = 0; i < N; ++i) {
    cin >> lens[i];
  }
  int cnts = 0;
  sort(lens.begin(), lens.end());
  for (int i = N - 1; i >= 2; --i) {
    for (int j = i - 1; j >= 1; --j) {
      int remain = lens[i] - lens[j] + 1;
      auto end = lens.begin() + j;
      auto it = lower_bound(lens.begin(), end, remain);
      if (it >= end) {
        break;
      }
      cnts += end - it;
    }
  }
  return cnts;
}

int main() {
  cout << solve() << endl;
}

Measured memory_bytes: 256
A,B,N=map(int,input().split())
x=B-1
def f(t):
    return int(t//1)
if N>=B:
    M=f(A*x/B)-A*f(x/B)
    print (M)
else:
    N=f(A*N/B)-A*f(N/B)
    print (N)


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

int main(){
	ll n,a,b;
	cin >> n >> a >> b;
	if(n%(a+b) <= a) cout << a*(n/(a+b))+n%(a+b) << endl;
	else cout << a*(n/(a+b))+a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int  main()
{
  long long int  n;
  cin>>n;
  long long int  k;
  cin>>k;
  long long int  a[n];
  for(long long int  i=0; i<n; i++)
    cin>>a[i];
  long long int  dp[n];
  dp[0]=0;
	for(long long int  i=1; i<=min(k,n); i++)
	{
		dp[i]=abs(a[i]-a[0]);
		//cout<<dp[i]<<"\n";
	}
  for(long long int  i=k+1; i<n; i++)
  { 
  	long long int  g=100000000000000;
  	long long int  f;
    for(long long int  i1=0; i1<k; i1++)
    {
    	if(g>dp[i-1-i1]+abs(a[i]-a[i-1-i1]))
    	{
    		g=dp[i-1-i1]+abs(a[i]-a[i-1-i1]);
    		f=i1;
    		//cout<<f<<"\n";
		}
	}
	//cout<<g<<"\n"<<f<<"\n";
	dp[i]=g;
  }
  for(long long int  i=0; i<n; i++)
  {
  	//cout<<dp[i]<<"\n";
  }
  cout<<dp[n-1];
}


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

int main(){

    long long int N,K;
    cin>>N>>K;
    if(K%2==1) cout<<(N/K)*(N/K)*(N/K)<<endl;
    else {
        long long int A=N/(K/2);
        if(A%2==0) cout<<A*A*A/4<<endl;
        else cout<<(A/2)*(A/2)*(A/2)+(A/2+1)*(A/2+1)*(A/2+1)<<endl;
            
        }
}

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

int main() {
    uint N;
    cin >> N;
    vector<int> A(N, 0);
    int numGu = 0, numKi = 0;
    for (size_t i=0; i<N; ++i) {
        cin >> A[i];
        if (A[i] % 2 == 0) ++numGu;
        else ++numKi;
    }

    // 奇数をまとめて偶数へ(奇数+奇数=偶数だから)
    numGu += numKi / 2;
    // 奇数の残り分
    numKi = numKi % 2;

    // 偶数をまとめる
    if (numGu > 0) numGu = 1;

    if (numGu + numKi == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define loop(i,a,b) for(int i=a;i<b;i++)
#define scnarr(arr, n) for (int i = 0; i < n; ++i) cin >> arr[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>

//Constants
const int MOD = 1000000007; /* 1e9 + 7*/
const int MAXN = 1000005; /*1e6 +5 */


int spf[1000009]; // stores the smallest prime factor of a number

void sieve()
{
spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;
    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

/* Iterative Function to calculate (x^y)%p in O(log y) */
int power(int x,  int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

void solve()
{
    int n,d,c=0;
    cin>>n>>d;
    int visx[300001]={0} , visy[300001]={0};
    loop(i,0,n)
    {
        int x,y;
        cin>>x>>y;
        if((x*x + y*y <= d*d))
        {


            c++; 
        }
    }
    cout<<c<<endl;
}

int32_t main()
{
   // faster;
    /*sieve();
    int t;cin>>t;
    while(t--)*/
        solve();

    return 0;
}


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


int main(){
	
	string str,Ostr;

	getline(cin , str);
    	    
   for(int i =0 ; i< str.length(); i++)
   {
   	if(islower(str.at(i)))
		{
			if(i == 0 || str.at(i-1) == ' ')
			
			 Ostr += toupper(str.at(i));
		}	
   }
   
	cout<<Ostr;
}

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

int main(){
	int d, e;
	while (1){
		cin >> d >> e;
		double min = 100000;
		if (d == 0 && e == 0) break;
		for (int i = 0; i <= d; i++){

			for (int j = i; j <= d; j++){
				if (i + j == d){
					double cost = sqrt(i*i + j*j);
					double gap = sqrt((cost - e) * (cost - e));

					if (gap < min){
						min = gap;
					}
				}
			}

		}
		cout << min << endl;
	}

	return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long H; cin >> H;
  long long cnt=0;
  while(H>1){
    H = H/2;
    cnt++;
  }
  
  long long ans=1;
  long long tmp=1; 
  for(long long j=0; j<cnt; j++){
    tmp = tmp*2;
    ans += tmp;
  }
  cout << ans;
  return 0;
}

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

using namespace std;


int main(){

 int n,r;
  cin>>n>>r;

  if(n>10){
   cout<<r<<endl;
  }else{
   cout<<(r+(100*(10-n)) )<<endl;
  }


return 0;
}

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	string s, t;
	cin >> s >> t;
	t.pop_back();
	if(s == t) cout << "Yes";
	else cout << "No";

	return 0;
}


Measured memory_bytes: 3612
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int dfs(const int v, vector< vector<int> >& g, vector<int>& dp){
    for(auto to : g[v]){
        dp[to] = dfs(to, g, dp);
    }

    sort(g[v].begin(), g[v].end(), [&](int i, int j){ return dp[i] > dp[j]; });

    int res = 0;
    rep(i, g[v].size()){
        chmax(res, dp[g[v][i]] + i + 1);
    }

    return res;
}

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

    int n;
    cin >> n;

    vector< vector<int> > g(n);
    reps(i, n - 1){
        int a;
        cin >> a;
        g[--a].emplace_back(i);
    }

    vector<int> dp(n, -1);

    dp[0] = dfs(0, g, dp);

    cout << dp[0] << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 12416
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

struct RollingHash {
  static const ll base1 = 1007, base2 = 2009;
  static const ll mod1 = 1000000007, mod2 = 1000000009;
  vector<ll> hash1, hash2, power1, power2;

  // construct
  RollingHash(const string &S) {
    ll n = (ll)S.size();
    hash1.assign(n + 1, 0);
    hash2.assign(n + 1, 0);
    power1.assign(n + 1, 1);
    power2.assign(n + 1, 1);
    for (ll i = 0; i < n; ++i) {
      hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      power1[i + 1] = (power1[i] * base1) % mod1;
      power2[i + 1] = (power2[i] * base2) % mod2;
    }
  }

  // get hash of s[l..r-1]
  inline P get(ll l, ll r) const {
    long long res1 = hash1[r] - hash1[l] * power1[r - l] % mod1;
    if (res1 < 0) res1 += mod1;
    long long res2 = hash2[r] - hash2[l] * power2[r - l] % mod2;
    if (res2 < 0) res2 += mod2;
    return {res1, res2};
  }

  // get lcp of S[a:] and T[b:]
  inline int getLCP(int a, int b) const {
    int len = min((int)hash1.size() - a, (int)hash1.size() - b);
    int low = 0, high = len;
    while (high - low > 1) {
      int mid = (low + high) >> 1;
      if (get(a, a + mid) != get(b, b + mid))
        high = mid;
      else
        low = mid;
    }
    return low;
  }
};

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s, t;
  cin >> s >> t;

  RollingHash rlh(t + s);
  P ht = rlh.get(0, t.size());
  repLRE(i, (ll)t.size(), (ll)s.size()) {
    P htmp = rlh.get(i, i + t.size());
    if (ht == htmp) cout << i - t.size() << endl;
  }

  return 0;
}



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

int main() { 
  // string ans= "";
  // string str;
  int n;
  int l;
  int sum1 = 0;
  int sum2 = 0;

  cin >> n;
  cin >> l;
  
  for(int i=0;i<n;i++){
    sum1 += l + i;
  }

  if(l >= 0){
    cout << sum1-l << endl;
  }
  else if(l > -n && 0 >= l){
    cout << sum1 << endl;
  }
  else if(-n >= l){
    cout << sum1-(l+n-1) << endl;
  }
 
  return 0;
  }


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a, b, i, key;
  scanf("%d %d",&a,&b);
  while(1){
    if(a >= b){
      if(a % b == 0){
	printf("%d\n",b);
	break;
      }
      a = a % b; 
    }
    else if(a <= b){
      if(b % a == 0){
	printf("%d\n",a);
	break;
      }
      b = b % a;
    }
  }
  return 0;
}

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

int main(int argc, const char * argv[])
{
    double rad,diam,area;
    
    scanf("%lf",&rad);
    
    diam = rad *  2. * M_PI;
    area = rad * rad * M_PI;
    
    printf("%.6lf %.6lf\n",area,diam);
    return 0;
}

Measured memory_bytes: 652
while line = gets do
	n = line.to_i
	count = 0
	if n > 36 then
		puts 0
	else
		n = 36-n if n > 18
		[9,n].min.downto(0) do |a|
			if a <= n then
				[a,n-a].min.downto(0) do |b|
					if b <= n then
						[b,n-a-b].min.downto(0) do |c|
							if c <= n then
								[c,n-a-b-c].min.downto(0) do |d|
									if d == n-a-b-c then
										if a == b and b == c and c == d then
											count += 1
										elsif (a == b and b == c) or (b == c and c == d) then
											count += 4
										elsif a == b and c == d then
											count += 6
										elsif a == b or b == c or c == d then
											count += 12
										else
											count += 24
										end
									end
								end
							end
						end
					end
				end
			end
		end
		p count
	end
end

Measured memory_bytes: 8784
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int ans = 0;
        int n = sc.nextInt();
        int A[] = new int[n];
        int temp = 0 ;
        for (int i = 0;i<n ;i++){
            temp = sc.nextInt();
            int able = 0;
            while (temp%2 == 0){
                temp /= 2;
                able++;

            }
            A[i] = able;

        }
        ans = A[0];
        for(int i = 0 ;i<n ;i++){
            if(ans >=A[i]){
                ans = A[i];
            }
        }


        System.out.println(ans);
    }


}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long ;
using P = pair<int, int>;

void solver(int N, vector<int> &a, int &ans_min, int &ans_max){

    int buf{};
    map<int, int> rank;
    
    for(int i = 0; i != N; ++i){
        buf = a.at(i)/400;
        rank[buf]++;
    }

    for(auto p: rank){
        auto color_num = p.first;
        auto people_num = p.second;

        if(color_num > 7){
            ans_max += people_num;

            if(ans_min == 0) ++ans_min;
        }
        else{
            ++ans_max;
            ++ans_min;
        }
    }

    return;
}

int main(){

    int N;
    cin >> N;
    vector<int> a(N);
    for(auto iter = a.begin(); iter != a.end(); ++iter) cin >> *iter;

    int ans_min{}, ans_max{};
    solver(N, a, ans_min, ans_max);

    cout << ans_min << " "s << ans_max << endl;
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int Min=0, Max=N;
  int L, R;
  for(int i=0; i<M; i++){
    cin >> L >> R;
    Min=max(Min, L);
    Max=min(Max, R);
  }
  cout << max(Max-Min+1, 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

#define UI unsigned int
#define SI signed int
#define ULL unsigned long long
#define SLL long long


using namespace std;

int gridsV[2000][2000];
int gridsH[2000][2000];
string field[2000];

int main(void){
    int H,W;
    cin >> H >> W;
    for(int i=0;i<H;i++) cin >> field[i];
    for(int i=0;i<H;i++){
        int sum=0;
        for(int j=0;j<W;j++){
            if(field[i][j]=='#'){
                sum=0;
            }else{
                sum+=1;
            }
            gridsV[i][j]=sum;
        }
        for(int j=W-2;j>=0;j--){
            if(field[i][j+1]!='#' && field[i][j]!='#'){
                gridsV[i][j]=gridsV[i][j+1];
            }
        }
    }
    for(int j=0;j<W;j++){
        int sum=0;
        for(int i=0;i<H;i++){
            if(field[i][j]=='#'){
                sum=0;
            }else{
                sum+=1;
            }
            gridsH[j][i]=sum;
        }
        for(int i=H-2;i>=0;i--){
            if(field[i+1][j]!='#' && field[i][j]!='#'){
                gridsH[j][i]=gridsH[j][i+1];
            }
        }
    }
    int max=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int temp=gridsV[i][j]+gridsH[j][i]-1;
            if(temp>max) max=temp;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
using namespace std;
int main(void) {
	long long a, b, c;
	cin >> a >> b >> c;
	bool ok = true;
	if (c - a - b <= 0) ok = false;
	if ((c - a - b) * (c - a - b) <= 4 * a * b) ok = false;
	cout << (ok ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i =0;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long int ll;
int main(){
  int n,m;vector<int> a;string s,t;
  cin >> s;cout <<s;
  if(s[s.size()-1] == 's') cout <<"es"<<endl;
  else cout << "s"<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> hh(n, 0);
  ll res = 0;
  int l = 0;
  int r = 0;
  while (true) {
    while (hh[l] >= h[l] && l <= n - 1) {
      l++;
    }
    r = l;
    while (hh[r] < h[r] && r <= n - 1) {
      r++;
    }
    r--;
    if (l >= n || r >= n) {
      break;
    }
    for (int i = l; i <= r; ++i) {
      hh[i]++;
    }
    res++;
  }
  cout << res << endl;

  return 0;
}


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

using namespace std;

int main() {
  ll h, w;
  scanf("%lld %lld", &h, &w);
  if(h == 1 || w == 1)
    printf("1\n");
  else {
    if(h & 1) {
      if(w & 1)
        printf("%lld\n", w / 2 * h + h / 2 + 1);
      else
        printf("%lld\n", w / 2 * h);
    } else {
      if(w & 1)
        printf("%lld\n", w / 2 * h + h / 2);
      else
        printf("%lld\n", w / 2 * h);
    }
  }
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))

a = [0] * N
a[1] = abs(h[1] - h[0])
for i in range(2,N):
  a[i] = min(abs(h[i] - h[i-1]) + a[i-1], abs(h[i] - h[i-2]) + a[i-2])
print(a[-1])

Measured memory_bytes: 13928