akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
const ll INF=1e10+1;
using namespace std;
#define NOT_EXIST -1

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

int main(){
	ll N,M;
	cin >> N >> M;
	vector<ll> dp(N+1,0);
	rep(i,M){
		ll l,r;
		cin >> l >> r;
		dp[l]++;
		dp[r+1]--;
	}
	for(ll i=1;i<=N;i++){
		dp[i] = dp[i] + dp[i-1];
	}

	ll ans = 0;
	for(ll i=1;i<=N;i++){
		if(dp[i]==M) ans++;
	}
	cout << ans << endl;
}

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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	int t, i, j, k;
	ll arr[10004], temp;
	fo(i, 10004)
	arr[i] = 0;
	cin >> t;
	Fo(i, 1, 101) {
		Fo(j, 1, 101) {
			Fo(k, 1, 101) {
				temp = i * i + j * j + k * k + i * j + j * k + k * i;
				if (temp <= 10000)
					arr[temp]++;
			}
		}
	}
	Fo(i, 1, t + 1) {
		cout << arr[i] << endl;

	}

	return 0;
}

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

#define FOR(i, s, e) for (int (i) = (s); (i) < (e); (i)++)

int main() {
    int N; cin >> N;
    int h[110]; FOR(i, 0, N) cin >> h[i];

    int ans = 0;

    for(; ;) {
        int x = 0, y;
        FOR(i, 0, N) {
            if (h[i] == 0 ) {
                y = i;
                if (x < y) {
                    FOR(j, x, y) {
                        h[j] --;
                    }
                    ans ++;
                }
                x = i + 1;
            }
        }
        if (h[N -1] != 0) {
            FOR(j, x, N) h[j] --;
            ans ++;
        }

        int num = 0;
        FOR(i, 0, N) {
            if(h[i] == 0) num++;
        }
        if(num == N) break;
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 256
import heapq
import itertools
from collections import defaultdict


n, m, r = map(int, input().split())
visiting_town = list(map(int, input().split()))

edges = [[] for i in range(n+1)]
for _ in range(m):
    _from, to, distance = map(int, input().split())
    edges[_from].append([to, distance])
    edges[to].append([_from, distance])


comp_edges = defaultdict(dict)
for _from in visiting_town:
    seen = [False] * (n+1)
    todo = []
    for to, dist in edges[_from]:
        heapq.heappush(todo, [dist, to])

    while todo:
        dist, node = heapq.heappop(todo)
        if seen[node]:
            continue

        seen[node] = dist
        for to, add_dist in edges[node]:
            if seen[to] or to == _from:
                continue
            new_dist = dist + add_dist
            heapq.heappush(todo, [new_dist, to])

    for to in visiting_town:
        if to == _from:
            continue
        comp_edges[_from][to] = seen[to]

candidates = []
for route in itertools.permutations(visiting_town):
    result = 0
    for _from, to in zip(route[:-1], route[1:]):
        if to in comp_edges[_from]:
            dist = comp_edges[_from][to]
            result += dist
        else:
            break
    candidates.append(result)

print(min(candidates))


Measured memory_bytes: 11080
use proconio::input;
fn main() {
    input!(n: usize);
    let mut n = n;
    let mut v = Vec::new();
    while n > 0 {
        n -= 1;
        let now = n % 26;
        n /= 26;
        v.push(now);
    }
    v.reverse();
    let alpha = b"abcdefghijklmnopqrstuvwxyz";
    let mut ans = vec![];
    for &e in &v {
        ans.push(alpha[e] as char);
    }

    let ans: String = ans.iter().collect();
    println!("{}", ans);
}


Measured memory_bytes: 2188
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 4005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int k, N, idx;
string S;
vi R, G, B, vec;
char leftC;

map<char, int> dic[MAXN];

char colorLeft(char c1, char c2){
    if((c1 == 'R' && c2 == 'G') || (c1 == 'G' && c2 == 'R')) return 'B';
    else if((c1 == 'R' && c2 == 'B') || (c1 == 'B' && c2 == 'R')) return 'G';
    else return 'R';
}

void solve(){
    for(int i = 0; i < N; ++i){
        for(int j = i+1; j < N; ++j){
            if(S[i] == S[j]) continue;

            leftC = colorLeft(S[i], S[j]);

            ans += dic[j+1][leftC];

            if(2 * j - i < N && S[2 * j - i] == leftC) ans--;
        }
    }

    cout << ans << endl;
}

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

    map<char, int> tmp;

    for(int i = N; i >= 1; --i){
        dic[i] = tmp;
        tmp[S[i-1]]++;
    }

    dic[0] = tmp;

    solve();
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int main(){
   unsigned long long n, i = 0, num, ans = 0;
    vector <unsigned long long> d;
    cin >> n;
    for(i = 0; i < 5; i++){
        cin >> num;
        d.push_back(num);
    }
    sort(d.begin(), d.end());
    
    
    if(n%d[0] == 0){
        ans = n/d[0]+5;
        if(ans > 5){
            ans -= 1;
        }
    }
    else{
        ans = n/d[0]+5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <climits>
#include <cmath>
#define lli long long int
using namespace std ;

lli eval(vector<lli> &weight, vector<lli> &val, vector<vector<lli> > &dp, int ind, lli w)
{
	if(ind < 0 && w < 0) return INT_MIN ;
	if(ind < 0) return 0 ;
	if(w < 0) return INT_MIN ; 

	if(dp[ind][w] != -1) return dp[ind][w] ;

	dp[ind][w] = INT_MIN ;

	lli dtake = eval(weight,val,dp,ind-1,w) ;
	lli take = eval(weight,val,dp,ind-1,w - weight[ind]) ;

	if(take != INT_MIN) take+= val[ind] ;

	return dp[ind][w] = max(take,dtake) ;

}

int main(int argc, char const *argv[])
{
	lli n,w ;
	cin>>n>>w ;

	vector<lli> weight(n),val(n) ;
	for(int i = 0 ; i < n ; i++)
	{
		cin>>weight[i]>>val[i] ;
	}

	vector<vector<lli> > dp(n,vector<lli> (w+1,-1)) ;
	cout<<eval(weight,val,dp,n-1,w)<<endl ;
	return 0;
}

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

using namespace std;

int main()
{
	stack<int> s1;
	stack<pair<int , int> > s2;
	char ch;
	int sum = 0;
	for (int i=0; cin>>ch; i++)
	{
		if (ch == '\\') s1.push(i);
		else if (ch == '/' && s1.size() > 0)
		{
			int j = s1.top();
			s1.pop();
			sum += i-j;
			int a = i-j;
			while (s2.size()>0 && s2.top().first>j)
			{
				a += s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(j, a));
		}
	}
	
	vector<int> ans;
	while (s2.size() > 0)
	{
		ans.push_back(s2.top().second);
		s2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i=0; i<ans.size(); i++)
	{
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i;
    long long int a[n+1],b[n+1];
    long long s=0;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    vector< pair<long long,long long> >v;
    for(i=1;i<=n;i++)
    {
        cin>>b[i];
        v.push_back(make_pair(b[i],a[i]));
    }
    int c=0;
    long long ans1=0;
    sort(v.rbegin(),v.rend());
    long long ans=0;
    for(i=0;i<v.size();i++)
    {
        if(v[i].second<v[i].first)
        {
        //    cout<<v[i].first<<" "<<v[i].second<<endl;
            ans+=v[i].first-v[i].second;
            c++;
        }
    }
    vector< long long>v1;
    for(i=0;i<v.size();i++)
    {
        if(v[i].first<v[i].second)
        {
            v1.push_back(v[i].second-v[i].first);
        }
    }
    int flag=0;

    sort(v1.begin(),v1.end());
    for(i=v1.size()-1;i>=0;i--)
    {
        if(ans1>=ans)
        {
            flag=1;
            break;
        }
        ans1+=v1[i];
        c++;
    }
    if(ans1>=ans)
    {
        flag=1;
    }
    if(flag==0)
    {
        cout<<"-1\n";
    }
    else
    {
        cout<<c<<endl;
    }
}


Measured memory_bytes: 4336
//============================================================================
// Name        : ITP_1_3_B.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int x;
	for(int i=1;1;++i) {
		cin >> x;
		if (x==0) {
			break;
		}
		cout << "Case " << i << ": " << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007LL
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define pll              pair<long long,long long>
using namespace std;
//queue<ll> q;
ll cnt=0;
//vector<ll> adj[3000005];
//vector<ll> a(1000005),b(100005);
//vector<bool> vis(3000005,false);
//ll ed,ve;
ll timer =0;
set<ll> s;
vector<pll> vp;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
              const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.se >b.se);
    }
    else
        return (a.fi<b.fi);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
/*ll  dfs(ll node)
{
   vis[node]=true;
   ll c=1;
   //ll c=adj[node].size();
   for(auto x:adj[node])
   {
       if(vis[x]==false)
       {
           c+=dfs(x);
       }
   }
   a[node]=c;
   return c;
}
void bfs(ll node)
{
    vis[node]=true;
    for(auto x:adj[node])
    {
        if(vis[x]==false)
        {
            bfs(x);
        }
    }
}*/
int main()
{
 fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
       ll k,n,i=0,j=0,c=0,d=0,e=0,f=0,g=0,h=0,sum=0,maxi=0,to=0;
       cin>>n;
       vector<pll> a(n);
       for(i=0;i<n;i++)
       {
           cin>>c>>d;
           a[i]={c,d};
       }
       for(i=0;i<n;i++)
       {
           c=0;
           for(j=i;j<i+3 && j<n;j++)
           {
               e=a[j].fi;
               f=a[j].se;
               if(e==f)
               {
                   c++;
               }
               else
                break;
           }
           if(c==3)
           {
               f=mod;
               break;
           }
       }
       if(f==mod)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;

     }
}


Measured memory_bytes: 3672
def is_prime(x):
    if x == 2:
        return True
    if x < 2 or x%2==0:
        return False
    i = 3
    while i <= x**(0.5):
        if x%i==0:
            return False
        i+=2
    return True
 
if __name__=='__main__':
    N=int(input())
    cnt=0
    for _ in range(N):
        if is_prime(int(input())): cnt+=1
    print(cnt)


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

int main()
{
	string S, T;
	cin >> S >> T;

	long long ans = 0;
	for( int i = 0; i < S.size(); i++ ) {
		if( S[i] != T[i] ) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
typedef long long ll;
typedef pair<int,int> pii;
template<class T> void print(T & x){ cout << x; }
template<class T,class U> void print(pair<T,U> & p){cout << "("; print(p.first); cout << ", "; print(p.second); cout << ")"; }
template<class T> void print(vector<T> & v) {
  cout << "{";
  if (sz(v)) print(v[0]);
  for (int i = 1; i < sz(v); i++) cout << ", ", print(v[i]);
  cout << "}\n";
}

string S;

int solve(int m){
  vector<int> sm(sz(S));
  int cnt = 0;
  for(int i=0; i<sz(S); i++){
    if(S[i] == '1') cnt++;
    else cnt--;
    sm[i] = cnt;
  }
  for(int i=sz(S)-2; i>=0; i--)
    sm[i] = max(sm[i], sm[i+1]);
  int add = 0;
  int minim = 0;
  cnt = 0;
  for(int i=0; i<sz(S); i++){
    if(S[i] != '?')
      cnt += (S[i]-'0')*2-1;
    else{
      if(sm[i]+add+2 <= m)
        cnt++, add += 2;
      else
        cnt--;
    }
    minim = min(minim, cnt);
  }
  return m-minim;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> S;
  int z = 0;
  int cnt = 0;
  for(int i=0; i<sz(S); i++){
    if(S[i] == '1') cnt++;
    else cnt--;
    z = max(z, cnt);
  }
  cout << min(solve(z), solve(z+1)) << endl;
}


Measured memory_bytes: 8188
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<pair<int, int>> xy(n);
  REP(i, n) {
    int x, y; cin >> x >> y;
    if (x > y) swap(x, y);
    xy[i] = {x, y};
  }
  sort(ALL(xy));
  vector<pair<int, int>> idx(n);
  map<int, int> red, blue;
  REP(i, n) {
    int x, y; tie(x, y) = xy[i];
    idx[i] = {-y, i};
    ++red[x];
    ++blue[y];
  }
  ll ans = 1LL * (red.rbegin()->first - red.begin()->first) * (blue.rbegin()->first - blue.begin()->first);
  REP(i, n) {
    int x, y; tie(x, y) = xy[idx[i].second];
    --red[x];
    if (red[x] == 0) red.erase(x);
    --blue[y];
    if (blue[x] == 0) blue.erase(y);
    ++red[y];
    ++blue[y];
    chmin(ans, 1LL * (red.rbegin()->first - red.begin()->first) * (blue.rbegin()->first - blue.begin()->first));
  }
  red.clear();
  blue.clear();
  REP(i, n) {
    int x, y; tie(x, y) = xy[i];
    ++red[x];
    ++blue[y];
  }
  REP(i, n) {
    int x, y; tie(x, y) = xy[i];
    --red[x];
    if (red[x] == 0) red.erase(x);
    --blue[y];
    if (blue[x] == 0) blue.erase(y);
    ++red[y];
    ++blue[y];
    chmin(ans, 1LL * (red.rbegin()->first - red.begin()->first) * (blue.rbegin()->first - blue.begin()->first));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 31488
using System;
class Program
{
    static void Main(string[] args)
    {
        var t = Read(4);
        long[] p = new long[4];
        p[0]=t[2]-t[3]+t[1];
        p[1]=t[3]+t[2]-t[0];
        p[2]=t[0]-t[3]+t[1];
        p[3]=t[1]+t[2]-t[0];
        Write($"{p[0]} {p[1]} {p[2]} {p[3]}");
    }
 
    static void Write(string s) { Console.WriteLine(s); return; }
    static void Write(long n) { Console.WriteLine(n.ToString()); return; }
    static string ReadStr() { return Console.ReadLine(); }
    static string[] ReadStrs() { return Console.ReadLine().Split(' '); }
    static long Read() { return long.Parse(Console.ReadLine()); }
    static long[] Read(long n)
    {
        long[] p = new long[n];
        string[] t = Console.ReadLine().Split(' ');
        for(long i = 0; i < n; i++) { p[i] = long.Parse(t[i]); }
        return p;
    }
    static long abs(long n) { return (n > 0) ? n : -n; }
    static long gcd(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
    static long gcd(long a, long b) { return (a==0)?b:gcd(b % a, a); }
    static long lcm(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
    static long lcm(long a, long b) { return a * b / gcd(a, b); }
    static long max(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p>n[i])?p:n[i]; } return p; }
    static long min(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p<n[i])?p:n[i]; } return p; }
    static void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    static void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    static void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
    static string clip(string s, int start, int count)
    {
        if (start + count < s.Length) { s = s.Remove(start + count); }
        if (start > 0) { s = s.Remove(0, start); }
        return s;
    }
    static long ConvToLong(string n, int b)
    {
        long m = 0; long t = 1;
        for (int i = n.Length - 1; i >= 0; i--)
        {
            int k = int.Parse(n[i].ToString());
            m += t * k;
            t *= b;
        }
        return m;
    }
}

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

#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 INF 1e9



int main(){
  string S;
  cin >> S;
  ll N = stoll(S);
  int ans = 0;
  while(N){
    ans += N % 10;
    N /= 10;
  }
  REP(i, S.size()){
    if(S[i]=='0'){
      continue;
    }
    else{
      string s = S;
      s[i] = S[i]-1;
      FOR(j, i+1, s.size()){
        s[j] = '9';
      }
      N = stoll(s);
      // cout << "s:" << s << " " << N << endl;
      int sum = 0;
      while(N){
        sum+= N % 10;
        N /= 10;
      }
      ans = max(sum, ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;

    if(5 >= A){
        cout << 0 << endl;
    }else if(12 >= A){
        cout << B/2 << endl;
    }else{
        cout << B << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
int main(){
    fastio;
    file();
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    string res="";
    for(int i=0;i<n;++i){
        res=res+a[i]+b[i];
    }
    cout<<res<<endl;
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int dig[3] = {3, 5, 7};
    vector<ll> num753s;
    for(ll i = 0; i <= 5000000; i++) {
        ll num4 = i;
        ll num753 = 0;
        ll pow10 = 1;
        int used = 0;
        while(num4) {
            int r = num4 % 4;
            if(!r) {
                used = 0;
                break;
            }
            used |= 1 << r;
            num753 += pow10 * dig[r - 1];
            num4 /= 4;
            pow10 *= 10;
        }
        if(num753 >= 1e9)
            break;
        if(used == 14)
            num753s.push_back(num753);
    }
    int N;
    cin >> N;
    cout << lower_bound(num753s.begin(), num753s.end(), N + 1) - num753s.begin()
         << endl;
    return 0;
}

Measured memory_bytes: 640
num = int(raw_input())
line = raw_input()

A = line.strip().split(" ")
print " ".join(A)
#A = map(int, item_str)

for i in range(1, num):
    v = int(A[i])
    j = i - 1
    for j in range(j, -1, -1):
        if int(A[j]) > v:
            A[j+1] = A[j]
            j -= 1
        else:
            break
    A[j+1] = str(v)
    #A_str = map(str, A)
    print " ".join(A)

Measured memory_bytes: 6464
#include <iostream>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main(){
    int x;
    int i=1;
    while(1){
        cin >> x;
        if(x == 0) break;
        cout << "Case " << i++ << ": " << x << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

if sum(a) < sum(b):
    print(-1)
else:
    x = sorted([a[i]-b[i] for i in range(n)], reverse=True)
    s = -sum(d for d in x if d < 0)
    ans = sum(1 for d in x if d < 0)
    i = 0
    while s > 0:
        s -= x[i]
        ans += 1
        i += 1
    print(ans)

Measured memory_bytes: 18356
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
 int main() { 
 ll a,b,c,d,i,j=0,k=0,x,n=0,f; 
    vector<ll>v[100];
  cin>>a>>b;
  
for(i=1;i<=a;i++)
  {
  for(j=1;j<=b;j++)
  {
      cin>>c;
   v[i].push_back(c);
  }
  }
 for(i=1;i<=a;i++)
 {
 for(j=i+1;j<=a;j++)
  {
    
 for(f=0;f<b;f++)
 {
   c=v[i][f]-v[j][f];
   k+=c*c;   
 }
   x=sqrt(k);
    if(x*x==k)n++;k=0;
}
 }
cout<<n<<endl;
  }

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int low[10],va,vb,dis,a;
	double t;
	for(;;){
		if(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&low[0],&low[1],&low[2],&low[3],&low[4],&low[5],&low[6],&low[7],&low[8],&low[9],&va,&vb) == EOF){break;}
		dis = 0;t=0;
		for(a=0;a<10;a++){dis+=low[a];}
		for(a=0;a<10;a++){
			double l;
			t+=(double)low[a]/va;
			l=t*(double)(va+vb);
			if(dis<=l){break;}
		}
		printf("%d\n",a+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#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, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N+1), B(M+1);
  rep(i,N) cin >> A[i+1];
  rep(i,M) cin >> B[i+1];
  rep(i,N) A[i+1] += A[i];
  rep(i,M) B[i+1] += B[i];
  int A_best = 0;
  rep(i,N+1) {
    if (A[i] > K) break;
    A_best = i;
  }
  int B_best = 0;
  rep(i,M+1) {
    if (A[A_best] + B[i] > K) break;
    B_best = i;
  }
  int ans = A_best + B_best;
  for (int i = A_best; i >= 0; i--) {
    for (int j = B_best; j <= M; j++) {
      if (A[i] + B[j] > K) {
        break;
      }
      B_best = j;
    }
    ans = max(ans, i + B_best);
  }
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main() {
	int n, m, x;

	cin >> n >> m >> x;
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}

	int left = 0, right = 0;
	for (auto c : a) {
		if (c < x) { left++; }
		else { right++; }
	}

	cout << ((left < right) ? left : right) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll INF = 1e16;

ll n, mod;
vvl G;
vl dp1;  // dp1[v] : 頂点vを根とする下方向の部分木の場合の数
vl dp2;  // dp2[v] : 頂点vを根とする上方向の部分木の場合の数
vl ans;  // ans[v] : 頂点vを黒で塗るときの場合の数

void dfs1(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    ll x = 1;
    for(ll to : G[v]) {
        if(to == p) {
            continue;
        }
        dfs1(to, v);
        // 帰りの処理はこのへんに書く
        x = x * dp1[to] % mod;
    }
    dp1[v] = x + 1;
}

void dfs2(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    if(p == -1) {
        dp2[v] = 1;
    }
    vl ruiL(G[v].size(), 1);
    rep(i, (ll)G[v].size()) {
        ll to = G[v][i];
        if(i-1 >= 0) {
            ruiL[i] = ruiL[i-1];
        }
        if(to == p) {
            continue;
        }
        ruiL[i] = dp1[to] * ruiL[i] % mod;
    }
    vl ruiR(G[v].size(), 1);
    for(ll i = G[v].size()-1; i >= 0; i--) {
        ll to = G[v][i];
        if(i+1 < (ll)G[v].size()) {
            ruiR[i] = ruiR[i+1];
        }
        if(to == p) {
            continue;
        }
        ruiR[i] = dp1[to] * ruiR[i] % mod;
    }
    rep(i, (ll)G[v].size()) {
        ll to = G[v][i];
        if(to == p) {
            continue;
        }
        ll x = 1;
        if(i-1 >= 0) {
            x = x * ruiL[i-1] % mod;
        }
        if(i+1 < (ll)G[v].size()) {
            x = x * ruiR[i+1] % mod;
        }
        dp2[to] = (x * dp2[v] + 1) % mod;
        dfs2(to, v);
    }
}

void dfs3(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    ans[v] = dp2[v];
    for(ll to : G[v]) {
        if(to == p) {
            continue;
        }
        ans[v] = ans[v] * dp1[to] % mod;
        dfs3(to, v);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    
    cin >> n >> mod;    
    
    G.resize(n);
    rep(i, n-1) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        G[x].pb(y);
        G[y].pb(x);
    }

    dp1.resize(n);
    dp2.resize(n);
    ans.resize(n);
    dfs1(0);
    dfs2(0);
    dfs3(0);

    rep(v, n) {
        out(ans[v]);
    }

    re0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b; cin>>n>>a>>b;
    if ((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }else{
        cout<<min(a+(b-a-1)/2, n-b+1+(b-a-1)/2)<<endl;
    }
    return 0;
}


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

const int MAX=310;
const int INF=998877;
char s[MAX];
int n,k,dp[MAX][MAX][MAX];
int build(int l,int r,int c){
    if(c>k) return -INF;
    if(l>=r) return 0;
    if(dp[l][r][c]==0){
        int t=(s[l]==s[r-1]);
        if(l==r-1) dp[l][r][c]=build(l+1,r-1,c+1-t)+1;
        else dp[l][r][c]=build(l+1,r-1,c+1-t)+2;
        dp[l][r][c]=max(dp[l][r][c],build(l+1,r,c));
        dp[l][r][c]=max(dp[l][r][c],build(l,r-1,c));
    }
    return dp[l][r][c];
}
int main(){
    scanf("%s%d",s,&k);
    n=strlen(s);
    printf("%d\n",build(0,n,0));
}


Measured memory_bytes: 112768
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    i64 x = 0, x2 = 0;
    i64 i = 0;
    bool flg = true;
    while ((1ll << (i + 1)) <= k) i++;
    if ((1ll << i) <= k) x2 = (1ll << i);
    i--;
    for (; i >= 0; i--) {
        int cnt = 0;
        for (int j = 0; j < n; j++) {
            if (a[j] & (1ll << i)) cnt++;
        }
        if (cnt < (n + 1) / 2) {
            // 1にする
            if (!flg || x2 + (1ll << i) <= k) x2 += (1ll << i);
            x += (1ll << i);
        } else {
            // 0にする
            if ((1ll << i) & k) flg = false;
        }
    }

    i64 ret = 0, ret2 = 0;
    for (int i = 0; i < n; i++) {
        ret += x ^ a[i];
        ret2 += x2 ^ a[i];
    }
    std::cout << std::max(ret, ret2) << std::endl;

    return 0;
}


Measured memory_bytes: 1024
/// Author : HASEBUL HASSAN TANIM ///
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define pp pop_back
#define scan(t) scanf("%d",&t)
#define sscan(t) scanf("%lld",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define LL long long
#define ull unsigned long long
#define rock(cont) cont.begin(), cont.end()
#define roll(a,n) arr,arr+n
#define rep(i,n) for(int i=0 ; i<n ; i++)
#define repp(i, n) for(int i=1 ; i<=n ; i++)
#define print(t) printf("%d",t)
#define pprint(t) printf("%lld",t)
#define co(x) cout<<x
#define nl printf("\n")
#define el cout<<endl
#define INF (int)1e9

const int RT = 10000000;

vector<int>prime;
vector<LL>factor;
bitset<10000003> status;



int gcd(LL a,LL b){ return b==0 ? a: gcd(b,a%b);}
int lcm(LL a,LL b) { return a* (b/gcd(a,b));}

vector<int> Divisors(int n)
{
    vector<int> v;
    int limit=sqrt(n);
    for (int i=1; i<=limit; i++)
    {
        if (n%i==0)
        {
            if (n/i == i)
                v.push_back(i);
            else
            {
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    return v;
}

void sieve()
{
    int rt = sqrt(RT);
    //for(int i = 4; i <= rt; i+=2) status[i]=true;
    for(int i = 3; i <= rt; i+=2)
        if(!status[i])
            for(int j = i*i; j < RT; j+=(i<<1))
                status[j] = true;

    prime.push_back(2);

    for(int i = 3; i <= RT; i+=2)
        if(!status[i])
            prime.push_back(i);
}

LL primefac(LL n)
{
    int pf_idx=0,pf=prime[pf_idx],SIZE=prime.size();
    LL ANS=1,step=0;
    while(pf*pf<=n&&pf<SIZE)
    {
        if(n%pf==0)
        {
            while(n%pf==0) {n/=pf;}
            ANS=pf;
            step++;
        }
        pf=prime[++pf_idx];
        //cout<<pf<<" "<<n<<" "<<ANS<<endl;
    }
    if(n!=1) { ANS=max(ANS,n); step++; }
    if(step>1)
    {
      return ANS;
    }
    else
    {
        return -1;
    }
}

int main()
{
    int n,arr[200005]={0},x;
    scan(n);
    for(int i=2;i<=n;i++)
    {
        scan(x);
        arr[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        print(arr[i]);
        el;
    }
}


Measured memory_bytes: 4620
#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n);
	int a[n], ans[n], print[n];
	for(int i=0;i<n;i++){
		scanf("%d", &a[i]);
		ans[i]=0;
	}
	
	int num=0;
	int ballnum=0;
	for(int i=n-1;i>=0;i--){
		for(int j=i+1;j<=n;j+=(i+1)){
			if(j==i+1)	continue;
			num+=ans[j-1];
		}
		if(num%2!=a[i]){
			ans[i]=1;
			print[ballnum]=i+1;
			ballnum++;
		}	
		num=0;
	}
	
	printf("%d\n", ballnum);
	for(int i=0;i<ballnum;i++){
		printf("%d ", print[i]);
	}
	
	
	
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VP A(N);
	REP(i, N)cin >> A[i].first >> A[i].second;
	long double ans = 0;
	
	REP(q, N) {
		int i = q, j = (q + 1) % N;
		int a = A[i].first;
		int b = A[i].second;
		int c = A[j].first;
		int d = A[j].second;
		ans += (a*d - c * b) / 2.0;
		
	}
	
	printf("%.1Lf\n", ans);
	return 0;
}




Measured memory_bytes: 3248
def get_postorder(PRE, IN):
  if not PRE: return []

  result = []
  root = PRE[0]
  ri = IN.index(PRE[0])
  result.extend(get_postorder(PRE[1:ri+1], IN[:ri]))
  result.extend(get_postorder(PRE[ri+1:],  IN[ri+1:]))
  result.append(root)
  return result


N = int(input())
PRE = list(map(int, input().split()))
IN  = list(map(int, input().split()))
print(*get_postorder(PRE, IN))

Measured memory_bytes: 7600
////package CodeChef;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.LinkedHashSet;
import java.util.StringTokenizer;

public class Main{
   public static int mod=1000000007;
   public static int minPlus=mod;
	public static void main(String[] ard)  throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		String s=br.readLine().trim();
		////LinkedHashSet<Character> h=new LinkedHashSet<Character>();
		///for(int i=0;i<s.length();i++)h.add(s.charAt(i));
		String ans="None";
		for(char i='a';i<='z';i++)
		{
			if(!s.contains(""+i)){ans=""+i;break;}
		}
		pw.println(ans);
		pw.close();
	}
	public  static void go (String num, String s, int sum, int i) {
	    if (i>=num.length()) {
	      int t = 0;
	      long rs = 0;
	      StringTokenizer st = new StringTokenizer(s,"+");
	      t = st.countTokens();
	      while (st.hasMoreTokens()) {
	        rs+=Long.parseLong((String)st.nextToken());
	      }
	      if (rs == sum) minPlus = Math.min(minPlus,t);
	    } else {
	      if (i == 0) go (num,""+num.charAt(i), sum, i+1);
	      else {
	        go (num,s+"+"+num.charAt(i),sum,i+1);
	        go (num,s+num.charAt(i),sum,i+1);
	      }
	 
	    }
	        
	 
	  }
	public static int pa(int n)
	{     int a=0;
	      int b=0;
		
		if(n<=0)return 1;
		System.out.println("kumar");
		 a+=pa(n-1);
		 System.out.println("prabhat");  
		 b+=pa(n-1);
		//System.out.println( callme("vikrant"));
	   
		return a+b;
	}
	public static  String callme(String s)
	{
		return s;
	}
	public static boolean palin(String s)
	{
		int i=0;
		int j=s.length()-1;
		while(i!=j)
		{
			if(s.charAt(i)!=s.charAt(j))return false;
			i++;
			j--;
		}
	   return true;	
	}
	

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 




////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

signed main(){
  string s;cin>>s;
  int i = 0;
  if(s[i] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')cout << "Yes";else cout << "No" << endl;}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	int n;
	cin >> n;

	int l, i = 0, c[20] = { 0 }, v[20] = { -1 };
	while (cin >> l) {
		v[i] = l;
		i++;
		if (i >= n) {
			break;
		}
	}
	i = 0;
	while (cin >> l) {
		c[i] = l;
		i++;
		if (i >= n) {
			break;
		}
	}
	int total = 0;
	int t,r;

	for (t = 0; t < n; t++) {
		r= v[t] - c[t];
		if (r > 0) {
			total += r;
		}
	}

	cout << total;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque
N,K = [int(x) for x in stdin.readline().rstrip().split()]
V = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
rev_V = V[::-1]

for L in range(0, K+1):
        for R in range(0, K+1):
            if L + R > min(K,N):
                break
            
            tmp = V[0:L] + rev_V[0:R]
            tmp.sort()
            tmp = deque(tmp)
            num = K - (L+R)
            stone = -1
            cnt = 0
            while stone < 0:
                if cnt >= num or len(tmp) == 0:
                    break
                stone = tmp.popleft()
                if stone >= 0:
                    tmp.append(stone)
                    break
                cnt += 1
            ans = max(ans, sum(tmp))

print(ans)

Measured memory_bytes: 3316
//Therefore.java
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        String n=sc.next();
        int a=Integer.parseInt(n);

        if(0<a&&a<10){
           if(a==2||a==4||a==5||a==7||a==9){
            System.out.println("hon");
           }
           if(a==1||a==6||a==8){
            System.out.println("pon");
           }
           if(a==3){
            System.out.println("bon"); 
           }
        }
        if(10<=a&&a<100){
            if(n.charAt(1)=='2'||n.charAt(1)=='4'||n.charAt(1)=='5'||n.charAt(1)=='7'||n.charAt(1)=='9'){
             System.out.println("hon");
            }
            if(n.charAt(1)=='0'||n.charAt(1)=='1'||n.charAt(1)=='6'||n.charAt(1)=='8'){
             System.out.println("pon");
            }
            if(n.charAt(1)=='3'){
             System.out.println("bon"); 
            }
        }
        if(100<=a&&a<1000){
            if(n.charAt(2)=='2'||n.charAt(2)=='4'||n.charAt(2)=='5'||n.charAt(2)=='7'||n.charAt(2)=='9'){
             System.out.println("hon");
            }
            if(n.charAt(2)=='0'||n.charAt(2)=='1'||n.charAt(2)=='6'||n.charAt(2)=='8'){
             System.out.println("pon");
            }
            if(n.charAt(2)=='3'){
             System.out.println("bon"); 
            }
        }       
        sc.close();
    }
}

Measured memory_bytes: 35664
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] cnt = new int[4];
		for(int i=0;i<3;i++){
			cnt[A[i]]++;
			cnt[B[i]]++;
		}
		
		Array.Sort(cnt);
		bool chk = true;
		int[] tr = new int[]{1,1,2,2};
		for(int i=0;i<4;i++) chk &= cnt[i] == tr[i];
		Console.WriteLine(chk ? "YES" : "NO");
		
	}
	int[] A,B;
	public Sol(){
		A = new int[3];
		B = new int[3];
		for(int i=0;i<3;i++){
			var d = ria();
			A[i] = d[0] - 1;
			B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
from collections import deque as dq
d=dq([1,2,3,4,5,6,7,8,9])
k=int(input())
for i in range(k):
  x=d.popleft()
  if x%10!=0:
    d.append(10*x+(x%10)-1)
  d.append(10*x+x%10)
  if x%10!=9:
    d.append(10*x+(x%10)+1)
print(x)

Measured memory_bytes: 11908
#!/usr/bin/env python3


def main():
    n = int(input())
    k = int(input())
    l = list(map(int,input().split()))

    tmp = 0
    for x in l:
        if x <= (k/2):
            tmp+=(2*x)
        else:
            tmp+=(2*(k-x))
    print(tmp)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int n,a[30];
	long long b,c;
	c=1;
	scanf("%d",&n);
	for(b=n;b>0;b--){
		a[b]=b;
		c=c*a[b];
	}
	printf("%lld\n",c);
	return 0;
}

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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )


void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}


const int N = 1e5 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;


int main(){
    init();

    int n;  cin >> n;
    pii arr[n];
    for(int i = 0;i < n;i++){
        cin >> arr[i].F;
        arr[i].S = i + 1;
    }

    sort(arr, arr + n);

    for(int i = 0;i < n;i++){
       cout << arr[i].S << " ";
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int K;
  	string S;
  
  	cin >> K >> S;
  
 	if(S.size() <= K){
      cout << S;
    }
  	else{
     for(int i = 0; i <K ; i++){
       cout << S[i];
     }
     cout << "...";
    }
}

Measured memory_bytes: 3616
N,K=gets.chomp.split(' ').map{|n| n.to_i}
A=gets.chomp.split(' ').map{|n| n.to_i}
# 200000マンはおK
T=Array.new(200000) { |i| 0 }
A.each{|i|
	T[i] += 1
}
# 順序つきキューに入れる
T = T.reject{|i| i == 0}.sort
l = T.size
if(l <= K)
	puts 0
else
	puts T[0..(l-1-K)].inject(0){|sum, n| sum + n}
end


Measured memory_bytes: 22776
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  int n,h,w;
  cin >> n >> h >> w;
  int ans = 0;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    if(a >= h && b >= w)ans++;
  }
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
// ABC167Ddoubling.cpp
// doubling
//#include "pch.h"
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
long long d[60][200000] = {};
int main()
{
	long long n, k;
	cin >> n >> k;
	vector<long long>a(n+1);
	for (long long i = 1; i <= n; i++) cin >> a.at(i);
	int dgt = 0;
	long long num = k;
	vector<int>bt;
	while (num > 0) {
		bt.push_back(num % 2);
		num = num / 2;
		dgt++;
	}
	for (int i = 1; i <= n; i++) {
		d[0][i] = a[i];
	}
	for (int i = 1; i < dgt; i++) {
		for (int j = 1; j <= n; j++) {
			d[i][j]=d[i-1][d[i-1][j]];
		}
	}
	ll ans = 1;
	for (int i = bt.size() - 1; i >= 0; i--) {
		if (bt.at(i) == 1) ans = d[i][ans];
	}
	cout << ans << endl;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int k;
	cin>>k;
	queue<int64_t>q;
	for(int i=1;i<=9;++i)q.push(i);
	int64_t ans;
	for(int i=1;i<=k;++i){
		ans=q.front();
		q.pop();
		for(int j=-1;j<=1;++j){
			int tmp=ans%10+j;
			if(tmp<0||tmp>9)continue;
			q.push(ans*10+tmp);
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 1792
//im so sorry
#include <bits/stdc++.h>
using namespace std;
#define ll long long

double getAverage(vector<ll> &v, ll a) {
	double sum=0;
	for (ll i=0; i<a; i++)
		sum+=v[i];
	return sum/a;
}

int main() {
	vector<vector<ll>> choose(51,vector<ll>(51,1));
	for (ll i=1; i<51; i++)
		for (ll j=1; j<i; j++)
			choose[i][j] = choose[i-1][j] + choose[i-1][j-1];
		
	ll n,a,b; cin>>n>>a>>b;
	vector<ll> v(n);
	for (ll i=0; i<n; i++)
		cin>>v[i];
	sort(v.begin(),v.end(),greater<ll>());

	ll ans=0;
	if (v[a-1]==v[0]) {
		for (ll i=0; v[0]==v[a+i-1] and a+i<=b; i++) {
			ll count1 = count(v.begin(), v.begin()+a+i, v[0]);
			ll count2 = count(v.begin(), v.end(), v[0]);
			ans+=choose[count2][count1];
		}
	}
	else {
		ll count1 = count(v.begin(), v.begin()+a, v[a-1]);
		ll count2 = count(v.begin(), v.end(), v[a-1]);
		ans+=choose[count2][count1];
	}

	cout << fixed << setprecision(20) << getAverage(v,a) << endl;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	ll x, a, b;
	cin >> x >> a >> b;
	if(a - b >= 0) printf("delicious\n");
	else if(a - b >= -x) printf("safe\n");
	else printf("dangerous\n");
	return 0;
}

Measured memory_bytes: 256
# this is copy from https://atcoder.jp/contests/abc042/submissions/2435693
def create_fact_mod(num_max, mod)
  $fmod = Array.new(num_max+1)
  $fmod[0]=1
  $fmod[1]=1
  (2..num_max).each do |i|
    $fmod[i] = ($fmod[i-1] * i)%mod
  end
end

def create_seq_inv(num_max, mod)
  $simod = Array.new(num_max+1)
  $simod[0]=1
  $simod[1]=1
  (2..num_max).each do |i|
    $simod[i] = (mod-mod/i) * $simod[mod%i] % mod
  end
end

def create_fact_inv_mod(num_max, mod)
  $fimod = Array.new(num_max+1)
  $fimod[0] = 1
  $fimod[1] = 1
  (2..num_max).each do |i|
    $fimod[i] = ($fimod[i-1] * $simod[i]) % mod
  end
end

def comb_mod(n, k, mod)
  $fmod[n] * $fimod[n-k] * $fimod[k] %mod
end

h, w, a, b = gets.strip.split.map(&:to_i)
MOD = 10**9+7


create_fact_mod(h+w, MOD)
create_seq_inv(h+w, MOD)
create_fact_inv_mod(h+w, MOD)

sum = 0
i=1
loop do
  ww = b+i
  hh = a+i
  break if ww > w || hh > h

  c1 = comb_mod(h-hh+ww-1, ww-1, MOD)
  c2 = comb_mod(hh+w-ww-1, hh-1, MOD)
  sum += c1*c2 % MOD
  sum %= MOD
  i += 1
end

p sum


Measured memory_bytes: 6524