akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

//macro
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,a,b) for(int i=(int)(b) - 1;i>=(int)(a);i--)
#define rrep(i,n) RREP(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define INFL 1145148100000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define equals(a,b)(fabs((a)-(b))<EPS)

//alias
using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vs = vector<string>;
using P = pair<ll, ll>;
template<class T> using heap = priority_queue<T>;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H);	rep(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n)os << v[i] << (i == n - 1 ? "\n" : " "); return os; }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template<class T> inline void print(const T &x) { cout << x << '\n'; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;

int main() {
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(all(t), greater<char>());
	if (s < t) {
		print("Yes");
	}
	else {
		print("No");
	}
	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++)
int main() {
  int a,b,c,x,y;
  cin >> a>>b>>c>>x>>y;
  int mini=1e9;
  rep(i,max(x,y)+1){
    int z=x,w=y;
    int ans=0;
    ans+=2*c*i;
    z-=i;
    w-=i;
    if(z>=0){
    ans+=z*a;
    }
    if(w>=0){
    ans+=w*b;
    }
    mini=min(mini,ans);
  }
  cout << mini;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]){
        cout << "Yes" << endl;
    }else {
        cout <<"No" << endl;
    }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define pi acos(-1.0)
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main(int argc, char const *argv[])
{
   FastIO;
   string n;
   cin>>n;
   for(int i=0;i<n.size();i++)
   {
       if(n[i]=='7')
       {
          cout<<"Yes"<<endl;
          return 0;
       }


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

}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int DP[2100][2100];

int main() {
	
	int M, N;
	cin >> M >> N;
	
	string str1, str2;
	cin >> str1 >> str2;
	
	str1 = "ppppp" + str1 + "ppppppp";
	str2 = "ppppp" + str2 + "ppppppp";
	
	M += 6;
	N += 6;
	
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			if(str1[i] == 'I' || str2[j] == 'I'){
				DP[i][j] = 1;
			}else{
				DP[i][j] = -1;
			}
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			if(DP[i][j] > 0){
				if(str1[i + 1] == 'O' && str1[i + 2] == 'I'){
					DP[i + 2][j] = max(DP[i + 2][j], DP[i][j] + 1);
				}
				if(str2[j + 1] == 'O' && str2[j + 2] == 'I'){
					DP[i][j + 2] = max(DP[i][j + 2], DP[i][j] + 1);
				}
				if(str1[i + 1] == 'O' && str2[j + 1] == 'I'){
					DP[i + 1][j + 1] = max(DP[i + 1][j + 1], DP[i][j] + 1);
				}
				if(str1[i + 1] == 'I' && str2[j + 1] == 'O'){
					DP[i + 1][j + 1] = max(DP[i + 1][j + 1], DP[i][j] + 1);
				}
			}
			ans = max(ans, DP[i][j]);
			//cout << DP[i][j] << " ";
		}
		//cout << endl;
	}
	
	if(ans == 0){
		cout << 0 << endl;
	}else{
		cout << ans * 2 - 1 << endl;
	}
	return 0;
}




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

const int N=2e5+100,inf=2e7;
int n,p[N],f[2][N],s[N],c[N],cnt1,cnt2,mx1,mx2;
char Ans[N];

struct SegmentTree
{
	#define Mx N<<2
	#define ls k<<1
	#define rs k<<1|1
	int L[Mx],R[Mx],mx[Mx];
	void build(int k,int l,int r)
	{
		L[k]=l, R[k]=r, mx[k]=-inf;
		if(l == r) return;
		int mid=(l+r)>>1;
		build(ls,l,mid), build(rs,mid+1,r);
	}
	void Modify(int k,int x,int sum)
	{
		//cout<<L[k]<<" "<<R[k]<<" "<<x<<" "<<sum<<endl;
		if(L[k] == R[k]) {mx[k]=sum; return;}
		int mid=(L[k]+R[k])>>1;
		if(x<=mid) Modify(ls,x,sum);
		else Modify(rs,x,sum);
		mx[k]=max(mx[ls],mx[rs]);
	}
	int Query(int k,int l,int r)
	{	
		if(l<=L[k] && R[k]<=r) return mx[k];
		int mid=(L[k]+R[k])>>1,ret=-inf;
		if(l<=mid) ret=max(ret,Query(ls,l,r));
		if(r>mid) ret=max(ret,Query(rs,l,r));
		return ret;
	}
}Tr[2];
bool chk(int MX,int Q)
{
	if(Q<0) return 0;
	//cout<<MX<<" "<<Q<<" "<<Tr[1].Query(1,max(1,MX),n)<<endl;
	if(Q&1) return Tr[1].Query(1,max(1,MX),n)>=Q;
	return Tr[0].Query(1,max(1,MX),n)>=Q;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&p[i]), s[i]=max(p[i],s[i-1]),
		c[i] = (s[i] == p[i])?2:1;
	//for(int i=1;i<=n;++i) cout<<c[i]<<" "; puts("");
	for(int i=n;i>=1;--i)
	{
		s[i]=s[i+1];
		if(c[i] == 2) ++s[i];
	}
	Tr[0].build(1,1,n), Tr[1].build(1,1,n);
	for(int i=n;i>=1;--i)
	{
		f[0][i]=(c[i] == 2)?2:-inf, f[1][i]=(c[i] == 1)?1:-inf;
		if(c[i] == 2)
			f[0][i]=max(Tr[0].Query(1,p[i],n)+2,f[0][i]),
			f[1][i]=max(Tr[1].Query(1,p[i],n)+2,f[1][i]);
		else
			f[0][i]=max(Tr[1].Query(1,p[i],n)+1,f[0][i]),
			f[1][i]=max(Tr[0].Query(1,p[i],n)+1,f[1][i]);
		Tr[0].Modify(1,p[i],f[0][i]), Tr[1].Modify(1,p[i],f[1][i]);
		
	}
	for(int i=1;i<=n;++i)
	{
		Tr[0].Modify(1,p[i],0), Tr[1].Modify(1,p[i],-inf);
		//cout<<f[0][i]<<" "<<f[1][i]<<" "<<Tr[1].Query(1,1,n)<<endl;
		int c1=cnt1, c2=cnt2;
	//放在X后
		c1=(p[i]>mx1)?c1+1:c1;
		if(chk(mx2,c1-c2+s[i+1]))
		{
			Ans[i]='0', cnt1=c1, mx1=max(p[i],mx1); continue;
		}
		if(chk(max(p[i],mx1),c2-c1+s[i+1]))
		{
			Ans[i]='0', cnt1=c1, mx1=max(p[i],mx1); continue;
		}
	//放在Y后
		c1=cnt1, c2=(mx2<p[i])?c2+1:c2;
		Ans[i]='1', cnt2=c2, mx2=max(mx2,p[i]);
	}
	if(cnt1 != cnt2) {puts("-1"); return 0;}
	puts(Ans+1);
	return 0;
}

Measured memory_bytes: 23296
#include <stdio.h>
 
int main(void){
  int money;
  int happiness;
  
  do{
    scanf("%d",&money);
  }while(money < 0 || money >1000000000);
  
  happiness = (money / 500) * 1000 + ((money%500) / 5) * 5;
  
  printf("%d",happiness);
  
  return 0;
}

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

long long nos[100010];
int N;
long long cons;
map<pair<int,bool>, long long> dp;
long long maxval(int bidx, bool p){
	if(bidx == -1) return 0;
	auto key = make_pair(bidx, p);
	if(dp.count(key) != 0) return dp[key];
	long long mask = 1LL << bidx;
	int tot = 0;
	for(int i=0;i<N;i++) if(nos[i] & mask) tot += 1;
	if(p && (cons & mask) == 0) return dp[key] = mask * tot + maxval(bidx-1, true);
	return dp[key] = max(mask * tot + maxval(bidx-1, false), mask * (N-tot) + maxval(bidx-1, p));
}
	
	
	
int main(){
	cin>>N>>cons;
	for(int i=0;i<N;i++) cin>>nos[i];
	cout<<maxval(60, true)<<endl;
	return 0; 
}

Measured memory_bytes: 1024
def f(s, cost, route, ans):
    route.append(s)
    ans += cost[s]
    del cost[s]
    for k, c in data.items():
        if s in k:
            a, b = k
            b = b if s == a else a
            if not b in route:
                if not b in cost or c < cost[b]:
                    cost[b] = c
    if cost:
        s = sorted(cost.items(), key=lambda x: x[1])[0][0]
        return f(s, cost, route, ans)
    else:
        return ans

while True:
    n, m = map(int, raw_input().split())
    if n == m == 0: break
    data = {}
    for i in range(m):
        a, b, c = map(int, raw_input().split())
        data[(a, b)] = c
    else:
        print f(0, {0:0}, [], 0)

Measured memory_bytes: 4316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long k = in.nextLong();
            long ans = 0;
            if (n <= k)
                ans = Math.min(n, k - n);
            else {
                long z = (n - 1) / k;
                n -= z * k;
                if (n <= k)
                    ans = Math.min(n, k - n);
                else
                    ans = n;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
const int nn=400005;
int n,m,tot=0,f[nn],col[nn]; char co[nn]; ;
struct dat{
    int from,to,next;
}e[nn*2];
void adde(int x,int y){ e[++tot]=(dat){x,y,f[x]}; f[x]=tot; }
bool dfs(int now){
    col[now]=1;
    for(int i=f[now];i;i=e[i].next){
        int to=e[i].to;
        if(col[to]==1){ return 1;}
        if(col[to]==0&&dfs(to)) return 1;
    }
    col[now]=2;
    return 0;
}
int main(){
    scanf("%d%d",&n,&m); scanf("%s",co+1);
    for(int a,b,i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        if(co[a]==co[b]) adde(a,b+n),adde(b,a+n);
        if(co[a]!=co[b]) adde(a+n,b),adde(b+n,a);
    }
    for(int i=1;i<=n;i++)if(!col[i])if(dfs(i)){printf("Yes\n"); return 0;}
    printf("No\n");
    return 0;
}

Measured memory_bytes: 13312
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    static Scanner cin = new Scanner();

    internal static void Main(string[] args) {
        int N = cin.nextInt();
        var pow = new int[] { 1, 2, 4, 8, 16, 32, 64 };
        WriteLine(pow.Where(i => i <= N).Max());
    }
}




class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

int N,A[200000],res[200000];
vector<int>v[200000],V;

void dfs(int x,int from){
	int it=lower_bound(V.begin(),V.end(),A[x])-V.begin();
	if(it==V.size()){
		V.push_back(A[x]);
		res[x]=V.size();
		for(int i:v[x]){
			if(i==from)continue;
			dfs(i,x);
		}
		V.pop_back();
	}
	else{
		res[x]=V.size();
		swap(V[it],A[x]);
		for(int i:v[x]){
			if(i==from)continue;
			dfs(i,x);
		}
		swap(V[it],A[x]);
	}
}

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0,0);
	for(int i=0;i<N;i++){
		cout<<res[i]<<endl;
	}
}


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

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'


int main(){
	IoFast;
	int n;
	cin >> n;
	int ar[2 * n];
	fillArr(2 * n,ar);
	sort(ar,ar + 2 * n);
	int ans = 0;
	int i = 0;
	while(i < 2 * n){
		ans += ar[i];
		i+=2;
	}
	cout << ans << endl;

}



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

int main()
{
  int n, cnt;
  cnt = 0;
  string s;
  cin >> n >> s;
  for(int i = 0; i < n; i++)
    if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') cnt++;
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        if(H == 0){
            System.out.println(H);
            System.out.println(0);
            return;
        }
        long count = Main.countMaxMonster(H);
        System.out.println(count);
    }

    public static long countMaxMonster(long H){
        if(H == 1) return 1;
        long count = Main.countMaxMonster(H / 2 )* 2 + 1 ;
        return count;
    }

}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N;
    cin>>N;
    long long temp = 0;
    long long ans = N/500;
    ans *= 1000;
    N%=500;
    temp = N/5;
    temp*=5;
    ans += temp;
    cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
 
#define NIL -1
 
static const int MAX = 500;
static const int INFTY = (1<<21);
 
main(){
  int n, i, j, e, sum,min,length;
  int key[MAX],pass[MAX],pi[MAX],M[MAX][MAX];
 
  scanf("%d", &n);
 
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
 
  for(i=0;i<n;i++){
    key[i]=INFTY;
    pi[i]=NIL;
    pass[i] = 0;
  }
  key[0]=0;
 
  while(length!=NIL){
    min=INFTY;
    length=NIL;
    for(i=0;i<n;i++){
      if(key[i]<min && pass[i]!=1){
      length=i;
      min=key[i];
      }
    }
    pass[length]=1;
    for(i=0;i<n;i++){
      if(key[i] >= M[length][i] && pass[i]!=1){
    key[i] = M[length][i];
    pi[i] = length;
      }
    }
  }
   
  sum = 0;
 
  for ( i = 0; i < n; i++ ){
    if ( pi[i] != -1 ) sum += M[i][pi[i]];
  }
 
  printf("%d\n", sum);
 
  return 0;
}

Measured memory_bytes: 804
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define IOS std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
const int N = 1e6+20;
const ll Mod = 1e5;
const int INF = 0x3f3f3f3f;
int main(){
  int n,k;
  cin>>n>>k;
  double a = (double)1.0/n;
  double rst = 0;
  for(int i = 1; i <= n; i++){
    ll t = 0;
    ll tmp = i;
    while(tmp < k){
      tmp<<=1;
      t++;
    }
    // cout<<t<<endl;
    rst += (double)a*pow(1.0/2,(double)t);
  }
  printf("%.12lf\n",rst);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
nl = [input().split() for i in range(n)]
for j in range(n-2):
    if nl[j][0]==nl[j][1]:
        if nl[j+1][0]==nl[j+1][1]:
            if nl[j+2][0]==nl[j+2][1]:
                print('Yes')
                break
else:
    print('No')

Measured memory_bytes: 62400
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int i;
  double n, t, v, y;

  while(cin >> n){
    i = 1;
    while(1){
      y = 5 * (i - 1);
      t = sqrt(y / 4.9);
      v = 9.8 * t;
      if(n <= v) break;
      ++i;
    }
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 0
/*input
31415926535897932384626433832795028841971693993751058209749445923078164062862089986280
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    string s;
    cin>>s;
    int ans=0;
    REP(i,sz(s)) ans+=(s[i]-'0');
    if(ans%9) cout<<"No";
    else cout<<"Yes";
}


Measured memory_bytes: 3780
n = int(input())
# 100000
# 1-9 9 100-999 900 10000-99999 90000
if n <= 9:
    print(n)
    exit()
if n > 9 and n <= 999:
    print(9 + max(n-99,0))
    exit()
if n > 999 and n <= 99999:
    print(9 + 900 + max(n-9999,0))
    exit()
if n > 99999 :
    print(9 + 900 + 90000)
    exit()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    int D, T, S;
    cin >> D >> T >> S;

    if (D-T*S>0) puts("No");
    else puts("Yes");
    
    return 0;
}





Measured memory_bytes: 3620
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = int(1e9) + 7

stair = [True] * N
for i in a:
    stair[i-1] = False

# DP
dp = [0] * N
if stair[0]:
    dp[0] = 1
if N >= 2:
    if stair[1]:
        dp[1] = dp[0] + 1
    else:
        dp[1] = 0

for i in range(2, N):
    if not stair[i]:
        dp[i] = 0
        continue
    if stair[i-1] and stair[i-2]:
        dp[i] = (dp[i-1] + dp[i-2])%MOD
    elif stair[i-1]:
        dp[i] = dp[i-1]
    elif stair[i-2]:
        dp[i] = dp[i-2]

print(dp[N-1])



Measured memory_bytes: 50904
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int n;
	char s[5000];
	scanf("%s",&s);
	n=strlen(s);
	int flag=1,sum=0;
	if(s[0]!='A'){
		flag=0;
	}
	if(s[1]=='C'||s[n-1]=='C'){
		flag=0;
	}
	for(int i=0;i<n;i++){
		if((s[i]<'a'&&(s[i]!='A'&&s[i]!='C'))||s[i]>'z'){
			flag=0;
		}
		if(i!=0){
			if(s[i]=='A'){
				flag=0;
			}
		}
		if(s[i]=='C'){
			sum++;
		}
	}
	if(sum!=1){
		flag=0;	
	}
	if(flag==0){
		printf("WA\n");
	}
	else{
		printf("AC\n");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (uint64_t i = 0; i < (uint64_t)(n); i++)
bool debug = false;

int main() {
  uint64_t Ans = 0;  // 回答
  uint64_t N; cin >> N; // 数値の数
  vector<uint64_t> A(N);   // 各ボールに書かれた整数
  map<uint64_t,uint64_t> Cnt;   // 各ボールの値毎の球数
  rep(i,N){
    cin >> A.at(i);
    Cnt[A.at(i)]++;
  }

  // P1:N 個の中から、同じ数字を取り出す組み合わせ数
  //    →各数値毎の玉の数を数えておいて、M*(M-1) の合計
  // P2:N 個の中から、k 番目のボールと同じ値のボールを２個取り出す組み合わせ数
  //    → P*(P-1)/2
  // P3:N-1 個の中から、k 番目のボールと同じ値のボールを取り出す組み合わせ数
  //    → (P-1)*(P-2)/2
  //  -P*(P-1)/2+(P-1)*(P-2)/2 = (P-1)*(P-2-P)/2 = -(P-1)
  uint64_t P1=0;
  for(auto m:Cnt){
    if (m.second>=2){
      P1 += m.second * (m.second-1) /2 ;
    }
  }
//  cout << "P1:" << P1 << endl;

  rep(k,N){   // k が除かれるボールの番号：０～Ｎ－１
    Ans = 0;
    if(Cnt[A.at(k)]>=2){
      Ans = P1 - (Cnt[A.at(k)]-1);
    } else {
      Ans = P1;
    }
    cout << Ans << endl;
  }
}


Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/
 
char d[55][55];
int black,white;
int w,h;
 
void init(){
  rep(i,55){
    rep(j,55){
      d[i][j]='.';
    }
  }
  black=white=0;
}
 
void bfs(int sy,int sx){
  d[sy][sx]='#';
  if(debug)cout<<"start"<<endl;
  if(debug)rep(i,h){rep(j,w)cout<<d[i][j]<<" ";cout<<endl;}
  int cnt=1;
  bool bb=false,ww=false;
  queue<int>q;
  q.push(sx);q.push(sy);
  while(!q.empty()){
    int x,y;
    x=q.front();q.pop();
    y=q.front();q.pop();
    rep(i,4){
      if(0<=x+dx[i]&&x+dx[i]<w&&0<=y+dy[i]&&y+dy[i]<h&&d[y+dy[i]][x+dx[i]]!='#'){
    if(d[y+dy[i]][x+dx[i]]=='W'){
      ww=true;
    }else if(d[y+dy[i]][x+dx[i]]=='B'){
      bb=true;
    }else{
      cnt++;
      q.push(x+dx[i]);q.push(y+dy[i]);
      d[y+dy[i]][x+dx[i]]='#';
    }
      }
    }
  }
  if(!bb&&ww)white+=cnt;
  else if(bb&&!ww)black+=cnt;
}
 
int main(){
  while(cin>>w>>h){
    if(w==0&&h==0)break;
    init();
    rep(i,h)rep(j,w)cin>>d[i][j];
    rep(i,h)rep(j,w)if(d[i][j]=='.')bfs(i,j);
    cout<<black<<" "<<white<<endl;
  }
 
  return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()



int main()
{
   int n, k, q;
   int c;
   cin >> n >> k>> q;
   c = q;
   int arr[n+1];
   for(int i = 0; i <= n; i++) arr[i] = 0;
   int a;
   while(q--)
   {
       cin >> a;

       arr[a]++;
   }
   for(int i = 1; i <= n; i++)
   {
       if(k-c+arr[i]>0) cout <<"Yes\n";
       else cout <<"No\n";
   }

return 0;
}




Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// greatest common divisor and least common multiple
// gcd is calculated by Euclidean Algorithm
// lcm = m * n / gcd(m,n)
template <typename T = int>
T gcd(T a, T b) {
    if (a < b)
        return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template <typename T = int>
T lcm(T m, T n) {
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main() {
    ll n, x, d;
    cin >> n >> x >> d;
    if (d == 0) {
        cout << (x == 0 ? 1 : n + 1) << "\n";
        return 0;
    }
    if (x == 0) {
        d = 1;
    } else {
        ll g = gcd(abs(x), abs(d));
        if (d < 0)
            g *= -1;
        x /= g;
        d /= g;
    }
    vector<vector<pair<ll, int>>> imos(min(n + 1, d));
    for (ll i = 0; i <= n; ++i) {
        ll l = (0 + i - 1) * (i) / 2;
        ll r = (n - 1 + n - i) * (i) / 2;
        l += x * i / d;
        r += x * i / d;
        ll idx = i % d;
        imos[idx].emplace_back(l, 1);
        imos[idx].emplace_back(r + 1, -1);
    }
    ll ret = 0;
    for (int i = 0; i < min(n + 1, d); ++i) {
        sort(imos[i].begin(), imos[i].end());
        ll prev  = -INF;
        ll depth = 0;
        for (auto &p : imos[i]) {
            if (depth > 0) {
                ret += p.first - prev;
            }
            prev = p.first;
            depth += p.second;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 14336
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int a, b, c;
long long k;

int read() {
  if (scanf("%d%d%d%lld", &a, &b, &c, &k) < 4) {
    return false;
  }
  return true;
}

void solve() {
  if (k & 1) {
    printf("%d\n", b - a);
  } else {
    printf("%d\n", a - b);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a;
  scanf("%d", &a);
  long long int arr[a], max = 1e18, prod = 1, flag = 0, kosong = 0;
  
  for (int i = 0; i < a; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : kosong = 1;
  }

  (kosong) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

Measured memory_bytes: 2504
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    sort(ALL(h));
    if (k >= n)
    {
        cout << 0 << endl;
    }
    else
    {
        ll ans = 0;
        for (ll i = 0; i < n - k; i++)
        {
            ans += h[i];
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 1792
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		long k = in.nextLong();
		long[] a = new long[n];
		long[] b = new long[m];
		for(int i = 0; i < n; i++) {
			a[i] = in.nextLong();
		}
		for(int i = 0; i < m; i++) {
			b[i] = in.nextLong();
		}
		long add = 0L;
		int i;
		for(i = 0; i < n; i++) {
			if(add + a[i] <= k) {
				add += a[i];
			}else {
				break;
			}
		}
		long ans = i;
		i -= 1;
		main:
		for(int j = 0; j < m; j++) {
			if(add + b[j] <= k) {
				add += b[j];
				ans = Math.max(ans, (i + 1) + (j + 1));
			}else {
				boolean flag = false;
				while(i >= 0) {
					add -= a[i];
					i -= 1;
					if(add + b[j] <= k) {
						ans = Math.max(ans, (i + 1) + (j + 1));
						add += b[j];
						flag = true;
						break;
					}
				}
				if(flag == false) break;
			}
		}
		System.out.println(ans);
	}
}

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

int colorsize;
const int MAXN = 1e5;
vector<vector<int>> to(MAXN);

map<P,int> mp;

void dfs(int v, int col){
   // cout << v << " " << col << "---" << endl;
	col++;
	for(auto next : to[v]){
		if(mp.find(P(v,next)) == mp.end()){
			mp[P(v,next)] = col%colorsize + 1;
			mp[P(next,v)] = col%colorsize + 1;
			dfs(next,col);
			col++;
		}
	}
	return;
}

int main(){
	int n;
	cin >> n;
	
	vector<int> a(n-1),b(n-1);
	rep(i,n-1){
		int x,y;
		cin >> x >> y;
		--x; --y;
		a[i] = x;
		b[i] = y;
		to[x].push_back(y);
		to[y].push_back(x);
		
	}
	
	
	
	
	rep(i,n) colorsize = max(colorsize, (int)to[i].size());
	
	dfs(0,-1);
	
	cout << colorsize << endl;
	rep(i,n-1) cout << mp[P(a[i],b[i])] << endl;
	
	return 0;
}

Measured memory_bytes: 19328
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  map<int, int> cnt;
  while (n--) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  vector<ii> a;
  for (auto& it : cnt) {
    if (it.second > 1) a.emplace_back(it.first, it.second);
  }
  sort(a.begin(), a.end(), greater<ii>());
  int64 ret = 0;
  for (auto& it : a) {
    if (it.second >= 4) ret = max(ret, (int64)it.first * it.first);
  }
  if (a.size() >= 2) {
    ret = max(ret, (int64)a[0].first * a[1].first);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>

#define OVER 2000000000

int main()
{
    int n;
    int *a;
    int *a_ng;
    int q;
    int x;
    int y;
    int ng = 0;
    int tmp;
    int i;
    
    scanf("%d", &n);
    
    a = (int *)malloc(sizeof(int) * (n + 2));
    a_ng = (int *)malloc(sizeof(int) * (n + 2));
    
    a[0] = OVER * (-1);
    a_ng[0] = 0;
    for(i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        a_ng[i] = 0;
    }
    a[i] = OVER;
    a_ng[i] = 0;
    
    for(i = 1; i <= n; i++)
    {
        if(a[i] > a[i + 1])
        {
            ng++;
            a_ng[i] = -1;
        }
    }
    
    if(ng == 0)
    {
        puts("0");
    }
    else
    {
        scanf("%d", &q);
        
        for(i = 0; i < q; i++)
        {
            scanf("%d%d", &x, &y);
            
            tmp = a[x];
            a[x] = a[y];
            a[y] = tmp;
            
            if(a[x - 1] <= a[x])
            {
                if(a_ng[x - 1] != 0)
                {
                    ng--;
                    a_ng[x - 1] = 0;
                }
            }
            else
            {
                if(a_ng[x - 1] == 0)
                {
                    ng++;
                    a_ng[x - 1] = -1;
                }
            }

            if(a[x] <= a [x + 1])
            {
                if(a_ng[x] != 0)
                {
                    ng--;
                    a_ng[x] = 0;
                }
            }
            else
            {
                if(a_ng[x] == 0)
                {
                    ng++;
                    a_ng[x] = -1;
                }
            }
            
            if(a[y - 1] <= a [y])
            {
                if(a_ng[y - 1] != 0)
                {
                    ng--;
                    a_ng[y - 1] = 0;
                }
            }
            else
            {
                if(a_ng[y - 1] == 0)
                {
                    ng++;
                    a_ng[y - 1] = -1;
                }
            }
            
            if(a[y] <= a [y + 1])
            {
                if(a_ng[y] != 0)
                {
                    ng--;
                    a_ng[y] = 0;
                }
            }
            else
            {
                if(a_ng[y] == 0)
                {
                    ng++;
                    a_ng[y] = -1;
                }
            }

            if(ng == 0)
            {
                printf("%d\n", i + 1);
                break;
            }
        }
        
        if(ng > 0)
        {
            puts("-1");
        }
    }
    
    return 0;
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>
#include <list>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 1000000007;
const ll mmm = 100000000000;

vector<ll> make_ST(ll n,ll first){

    ll i = 0;
    vector<ll> ret(0,0);

    while ((1<<(i-1)) < n){
        
        for (ll j = 0 ; j < (1<<i) ; j++){
            ret.push_back(first);
        }

        i++;

    }

    return ret;
}

void RMQ_upd(ll num,ll point,vector<ll>& tree){

    ll i = (tree.size()-1)/2 + point;
    if (tree[i] < num) return;
    tree[i] = num;
    while (i > 0){
        i = (i-1)/2;
        tree[i] = min(tree[i*2+2] , tree[i*2+1]);
    }
    return ;
}

ll RMQ_query(ll a,ll b,ll k,ll l,ll r,vector<ll>& tree){

    if ((r <= a) || (b <= l)) return mmm;
    if ((a <= l) && (r <= b)) return tree[k];

    ll c1 = RMQ_query(a,b,2*k+1,l,(l+r)/2,tree);
    ll c2 = RMQ_query(a,b,2*k+2,(l+r)/2,r,tree);

    return min(c1,c2);
}

int main(){

    ll N,Q,A,B;
    cin >> N >> Q >> A >> B;
    vector<ll> x(Q+1);
    x[0] = A;
    rep(i,0,Q) cin >> x[i+1];

    vector<ll> treeL = make_ST(N+2,mmm);
    vector<ll> treeR = make_ST(N+2,mmm);

    ll add = 0;
    RMQ_upd(-1*B,B,treeL);
    RMQ_upd(B,B,treeR);

    rep(i,1,Q+1){

        ll Lmin = RMQ_query(0,x[i]+1,0,0,(treeL.size()+1)/2,treeL) + add + x[i];
        ll Rmin = RMQ_query(x[i],N+2,0,0,(treeR.size()+1)/2,treeR) + add - x[i];
        ll nmin = min(Lmin,Rmin);

        add += abs(x[i]-x[i-1]);
        RMQ_upd(nmin-x[i-1]-add,x[i-1],treeL);
        RMQ_upd(nmin+x[i-1]-add,x[i-1],treeR);
        
    }

    ll ans = mmm;
    rep(v,0,N+1){
        ll j = (treeL.size()-1)/2 + v;
        ll tm1 = treeL[j] + add + v;
        ll tm2 = treeR[j] + add - v;
        ans = min(ans , min( tm1 , tm2 ));
    }

    cout << ans << endl;

}

Measured memory_bytes: 15072
#include <bits/stdc++.h>
 
using namespace std;
 
int main ()
{
  int n, m;
  cin >> n >> m;
  int a[m + 9];
  for (int i = 0; i < m; i++)
  {
    cin >> a[i];
    n -= a[i];
  }
  
  if (n >= 0)
    cout << n;
  else
    cout << "-1";
  
  return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int MAXN = 1010;

struct node{
    int c,t;
}No[MAXN];

const int INF = 1e5+10;
int main()
{
    int N,T;
    cin >> N >> T;
    for(int i = 1 ; i <= N ; i++)
    {
        cin>>No[i].c>>No[i].t;
    }
    int ans = INF;
    int ansi = -1;
    for(int i = 1 ; i <= N ; i++)
    {
        if(No[i].t<=T)
        {
            ans = min(ans,No[i].c);
           // if(No[i].c < ans)
           // {
            //    ans = No[i].c;
            //    ansi = i;
            //}
        }
    }
    ans == INF?cout<<"TLE"<<endl:cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

ll A[100005];

int main ()
{
    int n, m; cin >> n >> m;
    vector< pair<ll, ll> > maxsum;
    for (int i = 1; i <= n; i++) {
        ll a; cin >> a;
        maxsum.pb( {a, 1} );
    }

    for (int i = 1; i <= m; i++) {
        ll b, c; cin >> b >> c;
        maxsum.pb( {c, b} );
    }

    sort(maxsum.begin(), maxsum.end());
    reverse(maxsum.begin(), maxsum.end());
    ll sum = 0;
    int usados = 0;
    int id = 0;
    while (usados < n)
    {
        if (n - usados >= maxsum[id].second)
        {
            sum += maxsum[id].second * maxsum[id].first;
            usados += maxsum[id].second;
        } else {
            sum += maxsum[id].first * (n - usados);
            usados = n;
        }
        id++;
    }
    //cout << usados << "/" << n << endl;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 6512
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(A: int, V: int, B: int, W: int, T: int):
    if V<W:
        print(NO)
    else:
        diff_v = V-W
        diff_d = abs(A-B)

        if diff_v * T >= diff_d:
            print(YES)
        else:
            print(NO)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, V, B, W, T)

if __name__ == '__main__':
    main()


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

int main(){
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	if(s1[s1.size() - 1] == s2[0] && s2[s2.size() - 1] == s3[0]) cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
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: 3188
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int n;
    cin >> n;
    vector<ll> a(n + 1, 0);
    rep (i, n) cin >> a[i + 1];

    rrep (i, n) a[i] += a[i - 1];

    map<ll, ll> mp;
    rep (i, n + 1) mp[a[i]]++;

    ll ans = 0;
    for (auto x: mp) ans += (ll)x.se * (x.se - 1) / 2;

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


Measured memory_bytes: 14336
#include<stdio.h>

int main(void)
{
	int w,h,x, y,r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if (x >= 0 + r&&x <= w - r&&y >= 0 + r&&y <= h - r)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 2112
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int N, R; cin >> N >> R;
	if (N >= 10) cout << R << endl;
	else cout << R + 100 * (10 - N) << endl;
}

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

if N % 2:
    for a in range(1, M + 1):
        b = N - a
        print(a, b)
else:
    even = min(N // 4, M)
    odd = M - even
    for a in range(1, 1 + even):
        b = N + 1 - a
        print(a, b)
    for a in range(even + 1, M + 1):
        b = N - a
        print(a, b)


Measured memory_bytes: 9268
n = int(input())
ab = []
A = 0

for i in range(n):
  a,b = map(int,input().split())
  ab.append([b,a])

ab.sort()

for j in range(n):
  A += ab[j][1]
  if A>ab[j][0]:
    print('No')
    exit()
    
print('Yes')

Measured memory_bytes: 35608
S = list(input())

set_s = set(S)
set_all = set(list("abcdefghijklmnopqrstuvwxyz"))

set_diff = set_all - set_s

diff = []
for val in set_diff:
    diff.append(val)

ans = sorted(diff)

if len(ans) == 0:
    print("None")
else:
    print(ans[0])


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

struct UnionFind{
  vector<int> d;
  UnionFind(int n) : d(n, -1){}
  int find(int x){
    if(d.at(x) < 0) return x;
    return d.at(x) = find(d.at(x));
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d.at(x) > d.at(y)) swap(x, y);
    d.at(x) += d.at(y);
    d.at(y)= x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d.at(find(x)); }
};

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

  vector<pair<int, int>> ab(m);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    ab.at(i) = {a, b};
  }
  
  int ans = 0;
  rep(i, m){
    UnionFind uf(n);
    rep(j, m){
      if(j == i) continue;
      uf.unite(ab.at(j).first, ab.at(j).second);
    }
    rep(i, n-1){
      if(uf.same(i, i+1) == false){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#n=int(input())
n,p=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

def prime_factorize(n):
    n_origin=n+0
    primelist=[]
    a=2
    while a*a<=n_origin:
        if n%a!=0:
            a+=1
            continue
        ex=0
        while n%a==0:
            ex+=1
            n=n//a
        primelist.append([a,ex])
        a+=1
    if n!=1:
        primelist.append([n,1])
    return primelist

primelist=prime_factorize(p)
ans=1
for p,e in primelist:
    ans=ans*(p**(e//n))
print(ans)

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

int main(void){
    int len[11], n, max=0, sum=0;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> len[i];
        if(len[i]>max) max=len[i];
        sum += len[i];
    }
    if(max<sum-max) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define vi vector <ll>
#define hell 1000000007
#define pii pair <ll,ll>
#define inf (ll)(1e16)
#define pb push_back
#define p 31

using namespace std;

void solve()
{
    string s;
    cin>>s;
    rep(i,1,s.length()+1)
    {
        if(i%2==1&&s[i-1]!='R'&&s[i-1]!='U'&&s[i-1]!='D')
        {
            cout<<"No";
            return;
        }
        else if(i%2==0&&s[i-1]!='L'&&s[i-1]!='U'&&s[i-1]!='D')
        {
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


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




int main(void)
{
    int N;
    char name[26];
    char str[101];
    int count;
    int i, j, k, l;
    int p;
    
    scanf("%d", &N);
    scanf("%s", name);
    
    count = 0;
    for (i = 0; i < N; i++){
        scanf("%s", str);
        for (j = 0; j <= strlen(str)- strlen(name); j++){
            if (str[j] == name[0]){
                for (k = 0; k <= (strlen(&str[j]) - strlen(name) + 1) / (strlen(name) - 1); k++){
                    p = 0;
//printf("<%s k=%d>", &str[j], k);
                    for (l = 0; l < strlen(name); l++){
//printf("[%c %c]", name[l], str[j + p]);
                        if (name[l] != str[j + p]){
                            break;
                        }
                        p += (k + 1);
                    }
                    if (l == strlen(name)){
//printf("<%s>", str);
                        count++;
                        goto NEXT;
                    }
                }
            }
        }
NEXT:;
    }
    
    printf("%d\n", count);
    
    return (0);
}

Measured memory_bytes: 608