akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
ll encode(vector<stack<ll>> s){
    ll res=0;
    rep(i,3){
        while(!s[i].empty()){
            ll p=s[i].top();
            s[i].pop();
            if(p==-1)continue;
            res+=(ll)pow(3,p)*i;
        }
    }
    return res;
}
int main(){
    while(true){
        ll n,k;cin >> n >>k;
        if(n==0&&k==0)break;
        ll hash=0;
        rep(i,3){
            ll p;cin >> p;
            rep(j,p){
                ll a;cin >> a;a--;
                hash+=(ll)pow(3,a)*i;
            }
        }
        vl seen((ll)pow(3,n),-1);
        queue<ll> que;
        que.push(hash);
        seen[hash]=0;
        while(!que.empty()){
            ll hash=que.front();que.pop();
            if(seen[hash]>k){
                cout << -1 <<endl;
                break;
            }
            if(hash==0||hash==(ll)pow(3,n)-1){
                cout << seen[hash] <<endl;
                break;
            }
            vector<stack<ll>> v(3);
            rep(i,3)v[i].push(-1);
            ll hoge=hash;
            rep(i,n){
                ll a=hash%3;
                v[a].push(i);
                hash/=3;
            }
            rep(i,3){
                if(i==0||i==1){
                    if(v[i].top()>v[i+1].top()){
                        ll h=pow(3,v[i].top())+hoge;
                        if(seen[h]==-1){
                            que.push(h);
                            seen[h]=seen[hoge]+1;
                        }
                    }
                }
                if(i==1||i==2){
                    if(v[i-1].top()<v[i].top()){
                        ll h=-pow(3,v[i].top())+hoge;
                        if(seen[h]==-1){
                            que.push(h);
                            seen[h]=seen[hoge]+1;
                        }
                    }
                }                
            }
        }
    }
}


Measured memory_bytes: 115060
x,n=map(int,input().split())
Ps=list(map(int,input().split()))
numlist=[]
for i in range(102):
    numlist.append(i)
for p in Ps:
    numlist.remove(p)
import bisect
a=bisect.bisect_left(numlist,x)
b=a-1
if abs(numlist[a]-x)>=abs(numlist[b]-x):
    print(numlist[b])
else:
    print(numlist[a])

Measured memory_bytes: 9200
def calc():
    answers = []
    while True:
        a, op, b = input().split()
        a = int(a)
        b = int(b)
        if op == "?":
            break
        if op == "+":
            wa = a + b
            answers.append(wa)
        elif op == "-":
            sa = a - b
            answers.append(sa)
        elif op == "*":
            seki = a * b
            answers.append(seki)
        elif op == "/":
            shou = int(a / b)
            answers.append(shou)
    for ans in answers:
        print(ans)


calc()



Measured memory_bytes: 5600
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	//bool minus = false;
	//if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return n; }
	//return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

typedef vector<int> v;
struct graph {
	struct node {v n; int gid = 0;};
	vector<node> nodes;
	int gid_counter = 1;

	graph(int n) {
		nodes.resize(n);
	}
	void read(int n) {
		while (n--) {
			int s = in(), t = in();
			nodes[s].n.push_back(t);
			nodes[t].n.push_back(s);
		}
	}
	void traverse(int id, int gid) {
		node &n = nodes[id];
		if (n.gid)
			return;
		n.gid = gid ? gid : gid_counter++;
		for (int i: n.n)
			traverse(i, n.gid);
	}
	bool find(int s, int t) {
		node &n = nodes[s];
		traverse(s, n.gid);
		return n.gid == nodes[t].gid;
	}
};

int main() {
	graph g(in());
	g.read(in());
	int q = in();
	while (q--) {
		int s = in();
		out(g.find(s, in())? "yes" : "no", '\n');
	}
}




Measured memory_bytes: 10240
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<map>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
	int n, a, b;cin>>n>>a>>b;
	int x, y, z;x=y=z=0;
	for(int i=0;i<n;i++){
		int p;cin>>p;
		if(p<=a)x++;
		else if(p<=b)y++;
		else z++;
	}
	cout<<min(x, min(y, z))<<endl;
}

Measured memory_bytes: 256
n=int(input())
if n<600:
    print(8)
elif n<800:
    print(7)
elif n<1000:
    print(6)
elif n<1200:
    print(5)
elif n<1400:
    print(4)
elif n<1600:
    print(3)
elif n<1800:

    print(2)
else:
    print(1)


Measured memory_bytes: 61656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  
  int card[4][13] = {};
  for(int i=0;i<n;i++){
    string suit;
    int x;
    cin>>suit>>x;
    
    if(suit=="S") card[0][x-1]=1;
    if(suit=="H") card[1][x-1]=1;
    if(suit=="C") card[2][x-1]=1;
    if(suit=="D") card[3][x-1]=1;
}

  string str[4]={"S","H","C","D"};
  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
      if(card[i][j]==1) continue;
      cout<<str[i]<<" "<<j+1<<endl;
      }
  }

  return 0;
}


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

ll N, m, a, r, c, h, ans;

int main(){
    cin >> N;
    rep(i, N) {
        string S;
        cin >> S;
        if (S[0] == 'M') m++;
        if (S[0] == 'A') a++;
        if (S[0] == 'R') r++;
        if (S[0] == 'C') c++;
        if (S[0] == 'H') h++;
    }
    ll d[] = {m, a, r, c, h};
    rep(bit, 1<<5) {
        ll t = 1, cnt = 0;
        rep(i, 5) {
            if (bit>>i & 1) {
                t *= d[i];
                cnt++;
            }
        }
        if (cnt == 3) ans += t;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

vector<int> a;
static int n;

void init()
{
	cin >> n;
	CINV(a, n);
}

struct BIT {
	vector<int> v;
	int sz;
	BIT(int n) {
		sz = n+1;
		v.RS(sz, 0);
	}
	void add(int x) {
		for (int i = x; i <= sz; i += i & -i) v[i]++;
	}
	int get(int x) {
		int res = 0;
		for (int i = x; i > 0; i -= i & -i) res += v[i];
		return res;
	}
};

bool isok(int x)
{
	vector<int> b(n+1);
	b[0] = 0;
	rep(i, n) {
		if (a[i] >= x) b[i+1] = 1;
		else b[i+1] = -1;
		b[i+1] += b[i];
	}
	BIT bit(3 * n);
	ll res = 0;
	rep(i, n+1) {
		int t = bit.get(b[i] + n + 1);
		res += t;
		bit.add(b[i] + n + 1);
	}
	ll other = (ll) n * (n + 1) / 2 - res;
	return res >= other;
}

void solve()
{
	int ok = 29;
	int ng = 31;
	ng = 1111111111;
	ok = 1;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (isok(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}




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

char pos[15+1];

int step(int n) {
	if (n == 0) return 0;
	return 3*step(n-1) + 1;
}

int step2(char dest, int n) {
	if (n == 0) return 0;
	if (dest == 'A') {
		if (pos[n] == 'A') return step2('A', n-1);
		if (pos[n] == 'B') return step2('C', n-1) + 1 + 2*step(n-1);
		return step2('A', n-1) + 2 + 4*step(n-1);
	} else /* if (dest == 'C') */ {
		if (pos[n] == 'C') return step2('C', n-1);
		if (pos[n] == 'B') return step2('A', n-1) + 1 + 2*step(n-1);
		return step2('C', n-1) + 2 + 4*step(n-1);
	}
}

int main() {
	int n, m;
	while (cin >> n >> m, n && m) {
		for (int i = 0; i < 3; i++) {
			int k; cin >> k;
			for (int j = 0; j < k; j++) {
				int l; cin >> l;
				pos[n-l+1] = 'A' + i;
			}
		}
		int a = step2('A', n);
		int b = step2('C', n);
		a = a<b ? a : b;
		cout << (a<=m ? a : -1) << endl;
	}
	return 0;
}

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

int main()
{
  int n,m;
  cin>>n>>m;
  long s=0;
  int arr[n];
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
      s+=arr[i];
  }
  int count=0,p=1;
  float f=s/(4.0*m);
  for(int i=0;i<n;i++)
  {
      if(arr[i]>=f)
      {
          count++;
      }
      if(count>=m)
      {
          cout<<"Yes";p=0;
          break;
      }
  }
  
  if(p)
  {
      cout<<"No";
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;


int main(){
  int a,b;
  cin >> a >> b;
  if(a > b){
    cout << "a > b" << endl;
  }
  else if(b > a){
    cout << "a < b" << endl;
  }
  else{
    cout << "a == b" << endl;
  }

  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poligon{
	int A;int B;int C;
  bool operator<(const poligon& right)const{
		return A==right.A ? B==right.B ? C<right.C : B<right.B : A<right.A;
	}
};
int main(){
  int N;
	vector<poligon> V;
	cin>>N;
	FOR(i,0,N){
		int a,b,c;
		cin>>a>>b>>c;
		if(a>b){
			swap(a,b);
		}
		if(b>c){
			swap(b,c);
		}
		if(a>b){
			swap(a,b);
		}
		poligon P;
		P.A=a;
		P.B=b;
		P.C=c;
		V.PB(P);
	}
	sort(V.begin(),V.end());
	int cnt=N;
	int now=0;
	while(now<N){
		while(now<N-1&&V[now].A==V[now+1].A&&V[now].B==V[now+1].B&&V[now].C==V[now+1].C){
			now++;
			cnt--;
		}
		now++;
	}
	cout<<N-cnt<<endl;
 return 0;
}



Measured memory_bytes: 3156
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n, q = LI()
    nt = collections.deque()

    for _ in range(n):
        name, time = LSS()
        nt.append([name, int(time)])

    endtime = 0
    while nt:
        name, time = nt.popleft()
        if time>q:
            nt.append([name, time-q])
            endtime += q
        else:
            endtime+=time
            print(name, endtime)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 13304
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

typedef long long LL;

LL k;

bool check(LL n){
    LL m = n;
    int c[20], tot = 0;
    int digitsum = 0;
    while(n > 0){
        c[++tot] = n % 10;
        n /= 10;
        digitsum += c[tot];
    }
    //reverse(c + 1, c + 1 + tot);
    LL now = 1;
    for(int i = 1;i <= tot;i++){
        if(c[i] != 9){
            break;     
        }
        now *= 10;
    }
    if(now * digitsum >= m)
        return true;
    else
        return false;
}

LL power[15];


int main(){
    cin >> k;
    power[0] = 1;
    for(int i = 1;i <= 15;i++){
        power[i] = power[i - 1] * 10;
    } 
    vector<LL> ans;
    for(int i = 1;i < 10000;i++){
        if(check(i)){
            ans.push_back(i);
            //cout << i << endl;
        }
    } 
    for(int i = 5;i <= 15;i++){
        for(int j = 100;j < 1000;j++){
            LL tmp = j * power[i - 3] + (power[i - 3] - 1);
            if(check(tmp)){
                //cout << tmp << endl;
                ans.push_back(tmp);
            }
        }
    }
    sort(ans.begin(), ans.end());
    for(int i = 0;i < k;i++){
        printf("%lld\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;


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

	cin >> N;
	string s;
	cin >> s;
	if (N < 3200)cout << "red\n";
	else cout << s << endl;

}


Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int gugu = N*(N-1)/2;
		int kiki = M*(M-1)/2;
		
		System.out.println(gugu+kiki);
	}
}

Measured memory_bytes: 25300
//??????2???1??¨???1???2???????????????1???2??¨???2???1?????°??????????????¨???????????????
//a[0] + ??? + a[n-1] = r - mn (a[i] >= 0)????????????a[0]???a[n]????????¶???????????° ??? ??????
//????????????[r - mn + n - 1]C[n-1]????????¨?????´??????0<=m<=n<=r<=10000????????§?????????????????????
//????????????(r-mn+n-1)!/(n-1)!/(r-mn)!????????????DivTa baityou.
#include <iostream>
#include <cstdio>
using namespace std;

class BigInt{
public:
	int d[30000];	//1000?????°??§?????£?????????(??????????°???????????????????)
	int n;			//?????§?????°
	
	BigInt(int n){
		this->n = n;
		for( int i = 0; i < n; i++ ) d[i] = 0;
		d[0] = 1;
	}
	void mult(int x){
		for( int i = 0; i < n; i++ ){
			d[i] *= x;
		}
		for( int i = 0; i < n; i++ ){
			d[i+1] += (d[i] / 1000);
			d[i] %= 1000;
		}
	}
	void div(int x){
		for( int i = n-1; i >= 0; i-- ){
			if( i > 0 )
				d[i-1] += (d[i] % x) * 1000;
			d[i] /= x;
		}
	}
	void output(int p, bool isPut0=true){
		if( isPut0 )
			printf("%03d", d[p]);
		else
			printf("%d", d[p]);
	}
	void disp(int r){
		for( int i = r-1; i >= 0; i-- )
			printf("%d", d[i]);
		puts("");
	}
};
BigInt big(29000);

int main()
{
	int n, m, r;
	int i;
	
	cin >> n >> m >> r;
	if( r - m*n < n ){ cout << 0 << endl; return 0; }
	
	for( i = r - m*n + n - 1; i >= n; i-- )
		big.mult(i);
	for( i = 1; i <= r - m*n; i++ )
		big.div(i);
	
	i = 28999;
	while( big.d[i] == 0 ){ i--; }
	big.output(i--, false);
	while( i >= 0 ){
		big.output(i);
		i--;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  int result = 0;
  for (int i=A; i<=B; i++) {
    string num = to_string(i);
    if (num[0]==num[4]&&num[1]==num[3]) result++;
  }
  cout << result << endl;
  return 0;
}

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

using namespace std;

int main(){

  long long int a, b;
  string op;
  
  cin >> a >> op >> b;
  
  if(op == "+"){
    cout << a + b << endl;
  }
  else{
	cout << a - b << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    string x ;
    cin >> x ;
    if(x == "Sunny")
        cout << "Cloudy" ;
    else if(x == "Cloudy")
        cout << "Rainy" ;
    else if(x == "Rainy")
        cout << "Sunny" ;
    return 0 ;
}


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

int main(){
  ll N,K;
  cin >> N >> K;
  ll res = 0;
  for(int b = N; b > K; b--){
    res += (N/b) * (b - K);
    ll mod = N % b;
    if(mod >= K){
      res += mod - K + 1;
    }
  }
  if(K == 0){
    cout << N * N << endl;
  }else{
    cout << res << endl;
  }
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct snode{
  int64 val;
  int index;
} node;

int cmp(const void *a,const void *b){
  node *aa=(node *)a;
  node *bb=(node *)b;
  if(aa->val!=bb->val) return aa->val-bb->val<0?-1:1;
  if(aa->index!=bb->index) return aa->index-bb->index<0?-1:1;
  return 0;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  node *b=(node *)malloc(sizeof(node)*(n+1));
  node *c=(node *)malloc(sizeof(node)*(n+1));
  b[0].val=0;
  b[0].index=0;
  c[0]=b[0];
  for(i=1;i<=n;i++){
    b[i].val=b[i-1].val+a[i-1];
    b[i].index=i;
    c[i]=b[i];
  }
  qsort(c,n+1,sizeof(node),cmp);

  int64 cnt=0;
  for(i=0;i<n;i++){
    node t=b[i];
    int l=0;
    int r=n+1;
    while(l+1<r){
      int m=(l+r)/2;
      if(cmp(&t,&(c[m]))>=0){
	l=m;
      } else 
	r=m;{
      }
    }
    if(r<n+1 && c[r].val!=t.val) continue;
    int ll=r;
    l=0;
    r=n+1;
    while(l+1<r){
      int m=(l+r)/2;
      if(t.val-c[m].val>=0){
	l=m;
      } else {
	r=m;
      }
    }
    int rr=l;
    cnt+=rr-ll+1;
  }
  printf("%lld\n",cnt);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 10364
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
      
      	int result = 0;
      	for(int i = 1 ; i <= n ; i++ ) {
          	if ( String.valueOf(i).length() % 2 == 1 ) {
              result++;
            }
        }
      	System.out.println(result);
	}
}

Measured memory_bytes: 28116
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m=gsmi
a=gsmi

puts max(n-sum(a),-1)

Measured memory_bytes: 14620
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <cstdio>

using namespace std;

typedef long long ll;


#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

ll N, M;
vec<pair<ll, ll> > AB(100010);

bool sortfn(pair<ll, ll> lhs, pair<ll, ll>rhs) {
   if (lhs.first == rhs.first) {
      return (lhs.second < rhs.second);
   }
   return (lhs.first > rhs.first);
}

int main() {
   cin >> N >> M;
   rep1(i, N) {
      ll c, d;
      cin >> c >> d;
      AB.push_back(make_pair(c, d));
   }
   sort(AB.begin(), AB.end(), sortfn);
   ll money = 0;
   ll cnt = 0;
   while (cnt < M) {
      auto item = AB.back();
      AB.pop_back();
      money += item.first * min(item.second, M - cnt);
      cnt += min(item.second, M - cnt);
   }
   cout << money << endl;
}


Measured memory_bytes: 4864
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
vector<pair<llint, llint> > vec;

int main(void)
{
  cin >> n;
  llint x;
  for(int i = 1; i <= n; i++){
    cin >> x;
    vec.push_back(make_pair(x, 1));
  }
   for(int i = 1; i <= n; i++){
    cin >> x;
    vec.push_back(make_pair(x, 2));
  }
  sort(vec.begin(), vec.end());
  
  llint cnt = 0, cnt2 = 0, ans = 1;
  for(int i = 0; i < vec.size(); i++){
    if(vec[i].second == 1){
      if(cnt2 == 0) cnt++;
      else ans *= cnt2, ans %= mod, cnt2--;
    }
    else{
      if(cnt == 0) cnt2++;
      else ans *= cnt, ans %= mod, cnt--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6384
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
#define rep(i,n) for(int i=0;i<(n);++i)
const double PI=3.14159265358979323846; 
const int INF = 1001001001;

using namespace std;


vector<int> to[100005];
int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    --a,--b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while(!q.empty()){
    int v = q.front(); q.pop();
    for(int u : to[v]){
      if(dist[u] != INF) continue;
      dist[u] = dist[v]+1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i,n){
    if(i==0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
}


Measured memory_bytes: 10244
x,y = gets.split.map(&:to_i)
count = "-1 -1 -1"
(0..x).each do |n|
    (0..(x-n)).each do |m|
        l = x - n - m
        count = "#{n} #{m} #{l}" if 10000 * n + 5000 * m + 1000 * l == y
    end
end
print count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
  #define FASTIO std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  using namespace std;
  #define endl '\n'
  #define deb cout<<"sab_badhiya"<<endl;
  typedef long long int ll;
  // const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
  const long INF = 1000 * 1000 * 1000 + 7;
  vector<ll>p, q, r;
  int main() {
    FASTIO
    ll x, y, a, b, c;
    priority_queue<pair<int, int>>m;
    cin >> x >> y >> a >> b >> c;
    p.resize(a);
    q.resize(b);
    r.resize(c);
    for (int i = 0; i < a; i++) {
      cin >> p[i];
      m.push({p[i], 0});
    }
    for (int i = 0; i < b; i++) {
      cin >> q[i];
      m.push({q[i], 1});
    }
    for (int i = 0; i < c; i++) {
      cin >> r[i];
      m.push({r[i], 2});
    }
    sort(r.rbegin(), r.rend());
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    long long int ans = 0;

    ll total =  x + y, f, g;
    while(total) {
      f = m.top().first;
      g = m.top().second;
      m.pop();
      if (g == 1 && y == 0) {
        continue;
      }
      else if(g == 0 && x == 0) {
        continue;
      }
      else if(g == 1 && y != 0) {
        y--;
        total--;
        ans += f;
      }
      else if(g == 0 && x != 0) {
        x--;
        total--;
        ans += f;
      }
      else if(g == 2) {
        ans += f;
        total--;
      }
    }
    cout << ans << endl;
  }


Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	long double a,b;
	cin>>a>>b;
	int c=a*b;
	cout<<c<<endl;
}




Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;

    vector<int> q[33];
    rep(i,n){
        int a,b;
        cin >>a >>b;
        q[a].pb(b);
    }

    priority_queue<int,vector<int>,greater<int>> pq;
    int ans = 0;
    for(int i=1; i<=31; ++i){
        for(int e:q[i]) pq.push(e);

        while(!pq.empty() && pq.top()<i) pq.pop();

        if(!pq.empty()){

            ans += 2;
            pq.pop();
        }
        else ++ans;
    }

    cout << ans*50 << endl;
    return 0;
}



Measured memory_bytes: 3160
#include<iostream>
using namespace std;
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0016
int main(){
    int a,b;
    while(1){
        cin>>a>>b;
        if(a==0&&b==0){
            break;
        }
        if(a>b){
            cout<<b<<" "<<a<<endl;
        }
        else if(a<b){
            cout<<a<<" "<<b<<endl;
        }
        else{
            cout<<a<<" "<<b<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3076
import sys
input = sys.stdin.readline

A, B, C, D = map(int, input().split(' '))
a_switch = set()
b_switch = set()
for i in range(A+1, B+1):
    a_switch.add(i)
for i in range(C+1, D+1):
    b_switch.add(i)
ans = len(a_switch & b_switch)
print(ans)

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

const ll MOD = 1'000'000'007;
const int LEN = 60;

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

  vector<bitset<LEN>> a;
  for (int i = 0; i < n; ++i) {
    ll x;
    cin >> x;
    a.emplace_back(x);
  }

  vector<ll> c(LEN);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < LEN; ++j) {
      c[j] += a[i][j];
    }
  }

  auto f = [&](int i) {
    ll res = c[i] * (n - c[i]) % MOD;
    for (int j = 0; j < i; ++j) {
      res *= 2;
      res %= MOD;
    }
    return res;
  };

  ll ans = 0;
  for (int i = 0; i < LEN; ++i) {
    ans += f(i);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mod 1000000007 
int main()
{  
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	int i;
	for(i=a;i<=b;i++)
		if(i%k==0){
			cout<<"OK";
			return 0;
		}
	cout<<"NG";
}

Measured memory_bytes: 3636
using System;

public class Hello
{
    public const long E7 = 1000000007;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var m = long.Parse(line[0]);
        var n = long.Parse(line[1]);
        var ret = power(m, n) % E7;
        Console.WriteLine(ret);
    }
    public static long power(long x, long n)
    {
        if (n == 0) return 1L;
        if (n % 2 == 0)
        {
            var ww = (x * x) % E7;
            var t = power(ww, n / 2L) % E7;
            return t;
        }
        else
        {
            var t2 = power(x, n - 1) % E7;
            return x * t2;
        }
    }
}


Measured memory_bytes: 9200
//Keep Working Hard
  // I__Like__Food  

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

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define tracel5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 500;

const int INF = (1LL << 30) - 1;
  int dp[N][N];
  int dp2[N][N];


int32_t main()
{



    IOS

    for(int i = 0; i < N;i++)
    {
    	for(int j = 0; j < N;j++)
    	{
    		dp[i][j] = INF;
    		dp2[i][j] = INF;
    	}
    }


    int n,m,l;
    cin >> n >> m >> l;



    for(int i = 1; i<= m; i++)
    {
    	int a,b,c;
    	cin >> a >> b >> c;
    	dp[a][b] = min(dp[a][b],c);
    	dp[b][a] = min(dp[a][b],dp[b][a]);
    }



    for(int k = 1; k <= n; k++)
    {
    	for(int i = 1; i <= n; i++)
    	{
    		for(int j = 1; j <= n; j++)
    		{
    			dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j]);

    		}
    	}
    }


    for(int i = 1; i <= n; i++)
    {
    	for(int j = 1; j <= n; j++)
    	{
    		//trace3(i,j,dp[i][j]);
    		if(dp[i][j] <=l)
    		{
    			dp2[i][j] = 1;
    			dp2[j][i] = 1;
    		}
    	}
    }




    for(int k = 1;  k <= n; k++)
    {
    	for(int i = 1; i <= n; i++)
    	{
    		for(int j = 1; j <= n; j++)
    		{
    			dp2[i][j] = min(dp2[i][j],dp2[i][k] + dp2[k][j]);
    		}
    	}
    }


    int q;
    cin >> q;

    while(q--)
    {
    	int x,y;
    	cin >> x >> y;
    	//trace2(x,y);
    	if(dp2[x][y] == INF )dp2[x][y] = 0;
    	cout << dp2[x][y] - 1<< endl;
    }










    return 0;
}




Measured memory_bytes: 4480
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg



int main()
{
	int a;
	cin >> a;

	if (a % 1000 == 0) {

		std::cout <<0<< endl;
	}
	else {
		std::cout << 1000-a%1000 << endl;
	}



	return 0;
}



Measured memory_bytes: 3632
from collections import defaultdict
from bisect import bisect_right
import sys
input=sys.stdin.readline


def solve():
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    dd = defaultdict(list)
    cc = defaultdict(list)

    for i, j in enumerate(A):
        dd[j].append(i)

    pos, loop = 0, 1
    ans = []

    while pos < N:
        num = A[pos]
        pp = bisect_right(dd[num], pos)
        if pp < len(dd[num]):
            pos = dd[num][pp]+1
        else:
            pos = dd[num][0]+1            
            loop += 1
        cc[loop].append(pos)

    pos = cc[K%loop][0] if cc[K%loop] else 0
    while pos < N:
        num = A[pos]
        pp = bisect_right(dd[num], pos)
        if pp < len(dd[num]):
            pos = dd[num][pp]+1
        else:
            ans.append(num)
            pos += 1
    print(*ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 104840
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < h; i++) {
        cout << "#";
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            cout << c;
        }
        cout << "#" << endl;
    }
    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }
    cout << endl;
}


Measured memory_bytes: 384
#include<iostream>
#define int long long
using namespace std;
signed main() {
	int n, a[123], sum = 0, ans = 0; cin >> n;
	for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; }
	for (int i = 0; i < n; i++) { sum -= a[i]; ans += a[i] * sum; }
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include<cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stdio.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

bool is_integer( double x ){
  return std::floor(x)==x;
}

int main() {
	int N,cnt=0;
	cin>>N;
	for (int n = 1; n <=N; ++n)
	{
	cnt=0;
		
		for (int x = 1; x*x <= n; ++x)
		{
				for (int y = 1; y*y <= n; ++y)
			{
				double zz=(-(x+y)+sqrt(-3*(x*x+y*y)-2*x*y+4*n));

						if (zz>0&&is_integer(zz)&& int(zz)%2==0)
						{
							cnt++;
						}
			}
		}

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

}


return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 200050;
int n,fa[N],siz0[N],siz1[N],deg[N];

LL Ans = 0;
struct Union_Find_Set{
	int fa[N],v0[N],v1[N];
	inline void init(int n,int *s0,int *s1){ for (int i = 1; i <= n; ++i) fa[i] = i,v0[i] = s0[i],v1[i] = s1[i]; }
	inline int Find(int x){ return x == fa[x] ? x : (fa[x] = Find(fa[x])); }
	inline void Merge(int x,int y){
		x = Find(x),y = Find(y);
		Ans += 1ll * v1[y] * v0[x];
		fa[x] = y; v0[y] += v0[x],v1[y] += v1[x];
	}
}S;
struct Data{
	int x,v0,v1;
	Data(int xx=0,int vv0=0,int vv1=0){ x = xx,v0 = vv0,v1 = vv1; }
	bool operator < (Data w) const{ return 1ll * v0 * w.v1 < 1ll * w.v0 * v1; }
}t;
priority_queue<Data>H;

int main(){
	int i,x,f;
	read(n);
	for (i = 2; i <= n; ++i) read(fa[i]),++deg[fa[i]];
	for (i = 1; i <= n; ++i) read(siz1[i]),siz0[i] = 1 - siz1[i];
	S.init(n,siz0,siz1);
	for (i = 1; i <= n; ++i) H.push(Data(i,siz0[i],siz1[i])),deg[i] = -1;
	while (!H.empty()){
		t = H.top(),H.pop(),x = S.Find(t.x);
		if (S.v0[x] != t.v0 || S.v1[x] != t.v1 || x == 1) continue;
		f = S.Find(fa[x]); S.Merge(x,f);// --deg[f];
		H.push(Data(f,S.v0[f],S.v1[f]));
	//	if (!deg[f]) H.push(data(f,S.v0[f],S.v1[f])),deg[f] = -1;
	}
	cout << Ans << '\n';
	return 0;
}

Measured memory_bytes: 12440
#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define reg register
	#define Rint register int
	#define FOR(i,a,b) for(register int i=(a),ed_##i=(b);i<=ed_##i;++i)
	#define ROF(i,a,b) for(register int i=(a),ed_##i=(b);i>=ed_##i;--i)
	#define FORit(templ,arr,i,a,b) for(register templ *i=(arr)+(a),*ed_##i=(arr)+(b)+1;i!=ed_##i;++i)
	#define ROFit(templ,arr,i,a,b) for(register templ *i=(arr)+(a),*ed_##i=(arr)+(b)-1;i!=ed_##i;--i)
	#define GO(x,p,e,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
	#define MEM(x,v) memset(x,v,sizeof(x))
	#define fir first
	#define sec second
	#define pq priority_queue
	#define MP make_pair
	typedef long long LL;
	typedef double DB;
	typedef pair<int,int> PII;
	#define Templ(T) template<typename T>
	inline int read(){
		reg int ans=0,f=1; reg char c=getchar();
		while(!isdigit(c)) f^=(c=='-'), c=getchar();
		for(;isdigit(c);c=getchar()) ans=(ans<<1)+(ans<<3)+(c^48);
		return f?ans:-ans;
	}
	Templ(_Tp) inline int chkmin(_Tp &x,_Tp y){ return x>y?x=y,1:0; }
	Templ(_Tp) inline int chkmax(_Tp &x,_Tp y){ return x<y?x=y,1:0; }
	#define using_mod
	const int mod = 998244353;
	#ifdef using_mod
	inline void inc(int &x, const int &y){ x += y; if(x >= mod) x -= mod; }
	inline void dec(int &x, const int &y){ x -= y; if(x < 0) x += mod; }
	inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res;}
	#endif
	Templ(_Tp) inline _Tp gcd(_Tp x,_Tp y){ return y?gcd(y,x%y):x; }
	inline int VSC_Local(){
		#ifdef VSC_Compile
		while(getchar() != '\n');
		#endif
		return 0;
	}
	#define FILE(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
	#define PBTXDY
}
using namespace my_std;

const int N = 20010;
int n, K, usd[N];
char sc[N], ans[N];

int main(){
	n = read(), K = read() - 1;
	scanf("%s", sc + 1);
	reg char mn = 'z';
	Rint len = 0, mxl = 0;
	FOR(i, 1, n) sc[2 * n + 1 - i] = sc[i], chkmin(mn, sc[i]);
	ROF(i, n * 2, n + 1){
		Rint l = i;
		while(sc[l] == mn && i - l < n) --l;
		chkmax(mxl, i - l);
		i = l;
	}
	if(K >= 13 || n <= (1 << K) * mxl){
		FOR(i, 1, n) putchar(mn);
		return VSC_Local();
	}
	ROF(i, n * 2, n + 1){
		Rint l = i;
		while(sc[l] == mn && i - l < n) --l;
		if(i - l == mxl) usd[i] = 1;
	}
	len = n - (1 << K) * mxl;
	FOR(i, 1, n) ans[i] = 'z';

	function<void(int)> check = [&](int x){
		FOR(i, 1, len){
			if(sc[x - i] > ans[i]) return;
			if(sc[x - i] < ans[i]){
				FOR(j, 1, len) ans[j] = sc[x - j];
				return;
			}
		}
	};

	FOR(i, n + 1, n * 2) if(usd[i]) check(i - mxl + 1);
	FOR(i, len + 1, n) putchar(mn);
	FOR(i, 1, len) putchar(ans[i]);
	return VSC_Local();
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  ll n, s; cin >> n >> s;

  if (n < s) {
    cout << -1 << endl;
    return 0;
  }

  if (n == s) {
    cout << n+1 << endl;
    return 0;
  }
  
  int rt = sqrt(n);
  ll ans = -1;

  for (int b=2; b<=rt+1; ++b) {
    ll num = n;
    ll value = 0;
    while (num > 0) {
      value += num % b;
      num /= b;
    }
    if (value == s) {
      ans = b;
      break;
    }
  }

  if (ans != -1) {
    cout << ans << endl;
    return 0;
  }

  for (int d=rt-1; d>0; --d) {
    ll mod = s - d;
    if (mod < 0) continue;
    if ((n-mod)%d == 0 && (n-mod)/d > mod) {
      ans = (n-mod)/d;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(0, A - B - B) << endl;
    return 0;
}

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

void insertionSort(vector<int> A,int N)
{
  for(int i=1;i<N;i++){
    int v=A[i];
    int j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(int k=0;k<N;k++){
      if(k!=N-1)
        cout<<A[k]<<" ";
      else cout<<A[k];
    }
    cout<<endl;
  }
}
int main()
{
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int k=0;k<N;k++){
      if(k!=N-1)
        cout<<A[k]<<" ";
      else cout<<A[k];
    }
    cout<<endl;
  insertionSort(A,N);
  return 0;
}



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

int main(int argc, char **argv)
{
	int N;
	scanf("%d", &N);
	int a[200001];
	for (int i = 1; i <= N; i++)
		scanf("%d", &a[i]);
	int n = 0, c = 1;
	for (int i = 1; i <= N; i++) {
		if (a[i] != c) {
			++n;
			continue;
		}
		++c;
	}
	if (c > 1)
		printf("%d\n", n);
	else
		printf("-1\n");
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long
#define endl "\n"
using namespace std;
int n  , m, x  , c , k ;
const int N = 1000000;
int z ;
int inf = 1e14;
int dp[N][5];
int a[N];

int r , g , b;


signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    cin >> n ;
    int cnt = 0;

    for (int i=1;i<=round(sqrt(n));i++){
        if (n % i == 0){
            int a = i , b = n/i;
            m = a-1 , k = b;
            if (m!=0){
                if (n % m == k){
                    cnt+=m;
                    //cout << m << endl;
                }
            }
            if (a == b){
                continue;
            }
            m = b-1 , k = a;
            if (m!=0){
                if (n % m == k){
                    cnt+=m;
                    //cout << m << endl;
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
from collections import Counter
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[0]
for i in range(n):
    b.append((a[i]+b[-1])%m)
b2=Counter(b)
ans=0
for i,j in b2.most_common():
    if j>1: ans+=j*(j-1)//2
print(ans)

Measured memory_bytes: 19488
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n;
    cin >> n;
    int vs[n];
    int cs[n];
    for(int i = 0; i < n; i++){
        cin >> vs[i];
    }
    for(int i = 0; i < n; i++){
        cin >> cs[i];
    }
    int s = 0;
    for(int i = 0; i < n; i++){
        if(vs[i] > cs[i]){
            s += (vs[i]-cs[i]);
        }
    }
    cout << s << endl;
    
    return 0;
}


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


def solv(r, g, b, n):
    ans = 0
    r, g, b = sorted([r, g, b])
    for bn in range(n // b + 1):
        n1 = n - bn * b
        for gn in range(n1 // g + 1):
            n2 = n1 - gn * g
            if n2 % r == 0:
                ans += 1
    return ans


if __name__ == '__main__':

    r, g, b, n = map(int, input().split())

    ans = solv(r, g, b, n)

    print(ans)


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		run();
	}

	static void run() {
		new Main().solver();
	}

	long MOD = 1_000_000_000 + 7;

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			if (s.charAt(0) == 'U')
				c[i] = 1;
			else if (s.charAt(0) == 'D')
				c[i] = -1;
			else if (s.charAt(0) == '-')
				c[i] = 0;
		}
		c = reduce(c);
		n = c.length;
		long[][] dp = new long[n + 1][n + 1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
			if (c[i] == -1) {// D
				for (int j = 0; j <= i; j++) {
					if (j >= 1) {
						dp[i + 1][j - 1] += j * j * dp[i][j];
						dp[i + 1][j - 1] %= MOD;
					}
					dp[i + 1][j] += j * dp[i][j];
					dp[i + 1][j] %= MOD;
				}
			} else if (c[i] == 1) {// U
				for (int j = 0; j <= i; j++) {
					dp[i + 1][j + 1] += dp[i][j];
					dp[i + 1][j] += j * dp[i][j];
					dp[i + 1][j + 1] %= MOD;
					dp[i + 1][j] %= MOD;
				}
			}
		}
		System.out.println(dp[n][0]);
	}

	int[] reduce(int[] c) {
		int len = 0;
		for (int i = 0; i < c.length; i++) {
			if (c[i] != 0)
				len++;
		}
		int[] ret = new int[len];
		int count = 0;
		for (int i = 0; i < c.length; i++) {
			if (c[i] != 0) {
				ret[count++] = c[i];
			}
		}
		return ret;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 26748
import java.lang.Integer.max

fun main() {
    val (N, M, K) = nextIntList()
    val aList = nextIntList()
    val bList = nextIntList()

    val aSumList = sizedArray(N + 1, 0L)
    aList.forEachIndexed { index, i ->
        aSumList[index + 1] = aSumList[index] + i
    }
    val bSumList = sizedArray(M + 1, 0L)
    bList.forEachIndexed { index, i ->
        bSumList[index + 1] = bSumList[index] + i
    }

    var res = 0
    var bIndex = M
    run {
        aSumList.forEachIndexed { index, a ->
            if (a > K) return@run
            while (a + bSumList[bIndex] > K) {
                bIndex--
            }
            res = max(res, index + bIndex)
        }
    }
    println(res)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 93688