akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main (void)
{
	int n, m, p, k;
	while(true)
	{
	k = 0;
	p = 1;
	cin >> n >> m;
	if(n == 0&& m == 0) break;
	int nx[n], mx[m];
	for(int i = 0;i < n; i++)
	{
		cin >> nx[i];
	}
	for(int j = 0;j < m;j++)
	{
		cin >> mx[j];
	}
	do
	{
		p += mx[k];
		k++;
		if(p >= n) break;
		p += nx[p-1];

	}
	while(p < n);

	cout << k << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int W = stdIn.nextInt();
		int H = stdIn.nextInt();
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		int r = stdIn.nextInt();
		
		if(x - r < 0 || y - r < 0 || W < x + r || H < y + r) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 17168
#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<
int ,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>pbd_set;
typedef pair<int,int> ii;
typedef pair<ii,int> pii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pii> vpii;
typedef long long int ll;
typedef unsigned long long int ull;

#define mi 1000000007
#define rep(i,a,b) for(i=a;i<b;i++)
#define repv(i,a,b) for(i=b-1;i>=a;i--)
#define pr(arr,n) rep(i,0,n) cout<<arr[i]<<" "; cout<<endl;
#define pr1(arr,n) rep(i,1,n+1) cout<<arr[i]<<" "; cout<<endl;
#define inf INT_MAX
#define gc getchar_unlocked
#define PB push_back
#define MP make_pair
#define fi first
#define se second
#define SET(a,b) memset(a,b,sizeof(a))
#define MAX 500005
#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#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 trace5(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;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

int mult(int x,int y)
{
  ll ans,x1=(ll)x,y1=(ll)y;
  ans=(x1*y1)%mi;
  return (int)ans;
}
int gcd(int a,int b) { return b==0 ? a : gcd (b,a%b);}
int lcm(int a,int b) { return a*(b/gcd(a,b));}

ll pow1(ll a,ll b)
{
  ll ans=1;
  while(b>0)
    {
      if(b&1) ans=(ans*a)%mi;	
      a=(a*a)%mi; b>>=1;
    }	
  return ans;
}
ll pre[200005],a[200005];
int main()
{
  ll n,i,j;
  sll(n);
  rep(i,1,n+1)
    {
      sll(a[i]);
      pre[i]=pre[i-1]+a[i];
    }
  ll ans=1e15;
  rep(i,1,n)
    ans=min(ans,abs(pre[n]-2*pre[i]));
  lldout(ans);
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    int a, b, c;
    while (N--) {
        cin >> a >> b >> c;
        int l=max(a,max(b,c));
        int x, y;
        if (a==l) {
            x=b;
            y=c;
        } else if (b==l) {
            x=a;
            y=c;
        } else if (c==l) {
            x=a;
            y=b;
        }
        if (l==sqrt(pow(x,2)+pow(y,2))) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2988
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for _ in range (D)]
M = 26
INF = 10**20

def judge(t,idx,val):
    last = [0]*M
    score = 0
    for i in range(D):
        ti = t[i]
        if i==idx:
            ti = val
        score += S[i][ti-1]
        last[ti-1] = i+1
        for m in range(M):
            score -= C[m]*(i+1-last[m])
    return score

from random import randint
import time
start = time.time()
ans = [0]*D
lasts = [0]*(M+1)


score = 0
for i in range(D):
    contest = 0
    max_score = -INF
    for m in range(M):
        new_score = score
        new_score += S[i][m]
        for m2 in range(M):
            if m==m2:continue
            new_score -= C[m2]*(i+1-lasts[m2])
        if new_score>max_score:
            contest = m+1
            max_score = new_score
    
    ans[i] = contest
    lasts[contest-1] = i+1
    score = max_score

while (time.time()-start<1.7):
    # 解を変更
    idx = randint(0,D-1)
    val = randint(1,26)
    # スコアが上がっているか？
    new_score = judge(ans, idx, val)
    if new_score>score:
        score = new_score
        ans[idx] = val

for a in ans:
    print(a)

Measured memory_bytes: 81088
n,k=map(int, input().split())
v=list(map(int, input().split()))

ans=0
mai=len([t for t in v if t<0])           
v2=sorted(v)
if k>=n:
    if k-n>=mai:
        ans=max(ans, sum(v2[mai:]))
    else:
        ans=max(ans, sum(v2[k-n:]))
    
for i in range(min(n+1,k+1)):
    for j in range(min(k-i+1,n-i+1)):
        if j==0:
            g=v[:i]
        else:
            g=v[:i]+v[-j:]
        g.sort()
        mai=len([t for t in g if t<0])
        if k-i-j>=mai:
            ans=max(ans, sum(g[mai:]))
            #print(g,sum(g[mai:]))
        else:
            ans=max(ans, sum(g[k-i-j:]))
            #print(g,sum(g[k-i-j:]))
print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
// #define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[500010], factinv[500010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,500010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve() 
{   
    int n;
    cin >> n;
    string ans = "";
    int pw = 26;
    while(n!=0)
    {   
        int hi = n/26;
        int left = n - n/26*26;
        left = (left + 25)%26; 
        ans = (char)('a'+left) + ans;
        // left = (left + 27)%26;
        left++;
        n -= left;
        n/=26;
    }
    cout << ans << endl;
}     

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define  IOS ios_base::sync_with_stdio(false),cin.tie(NULL)




int main()
{
	IOS;
	string s;
	cin >> s;

	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3;
	else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))cout << 2;
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')cout << 1;
	else cout << 0;


}

Measured memory_bytes: 3628
# https://atcoder.jp/contests/abc085/tasks/abc085_d
# 5 500
# 35 44
# 28 83
# 46 62
# 31 79
# 40 43
# 9
n, h = gets.split.map(&:to_i)
a = []
b = []
n.times {
  x, y = gets.split.map(&:to_i)
  a << x
  b << y
}
max_a = a.max
count = 0

b.sort!.reverse!.each do |v|
  break unless (v > max_a) && (h > 0)
  h -= v
  count += 1
end
count += (h + max_a - 1)/max_a if h > 0
puts count


Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int>P;

int main(){
    int n,a;
    cin>>n>>a;
    cout<<n*n-a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

bool ng(int a,int b,int c){
    return (a==1&&b==2&&c==3);
}

int main()
{
ll ans=0,n;

cin >> n;

ll dp[101][4][4][4]={};
dp[0][0][0][0]=1;
for(int i = 0; i < n; i++)
for(int a = 0; a < 4; a++)
for(int b = 0; b < 4; b++)
for(int c = 0; c < 4; c++)
for(int d = 0; d < 4; d++){
    if(ng(b, c, d) || ng(c, b, d) || ng(b, d, c)) continue;
    if(ng(a, c, d) || ng(a, b, d)) continue;
    dp[i+1][b][c][d]=(dp[i+1][b][c][d]+dp[i][a][b][c])%1000000007;
}
for(int a = 0; a < 4; a++)
for(int b = 0; b < 4; b++)
for(int c = 0; c < 4; c++){
    ans=(ans+dp[n][a][b][c])%1000000007;
}
cout << ans << endl;
return 0;
}





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


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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int k = in.nextInt();
            ArrayList<String> arrayList = new ArrayList<>(5000);
            for (int i = 0; i <s.length() ; i++) {
                for (int j = 0; j <k ; j++) {
                    if (i+j < s.length()) arrayList.add(s.substring(i ,i+j+1));
                }
            }
            Collections.sort(arrayList);
            int ind = 1;
            int i = 0;
            if (ind == k) out.println(arrayList.get(0));
            else {
                for (i = 1; i < arrayList.size(); i++) {
                    if (arrayList.get(i).equals(arrayList.get(i - 1))) continue;
                    ind++;
                    if (ind == k) break;
                }
                out.println(arrayList.get(i));
            }











        }

    }

    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 int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 25940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace IPT1_7C
{
    class Program
    {
        static void Main(string[] args)
        {
            // input array num r, c 
            string[] in_num = Console.ReadLine().Split(' ');
            int r = int.Parse(in_num[0]);
            int c = int.Parse(in_num[1]);
            // create array_RC (r+1, c+1)
            int[,] array_RC = new int[r + 1, c + 1];
            // loop r
            for (int i = 0; i < r + 1; i++)
            {
                string[] in_line = new string[c + 1];
                if (i < r)
                {
                    // input line data
                    in_line = Console.ReadLine().Split();
                }
                // loop c
                for (int j = 0; j < c + 1; j++)
                {
                    if ((j < c) && (i < r))
                    {
                        // set array_RC <- line data
                        array_RC[i, j] = int.Parse(in_line[j]);
                        array_RC[i, c] += array_RC[i, j];
                    }
                    if (i < r)
                    {
                        // calc line sum, column sum
                        array_RC[r, j] += array_RC[i, j];
                    }
                    if (j < c)
                        // print line
                        Console.Write(array_RC[i, j] + " ");
                    else
                        Console.Write(array_RC[i, j]);
                    // loop end c
                }
                Console.Write("\n");
            // loop end r
            }
            // pirnt last line
        }
    }
}

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

using namespace std;
int main() {
    int N,M,p,i;
    int num_wa= 0;
    int score = 0;
    cin >> N >> M;
    //int ac = (int*)malloc(N*sizeof(int));
    int* ac = new int[N+1]{0};
    int* wa = new int[N+1]{0};
    char S[2];
    for(i=0;i<M;i++){
        cin >> p >> S;
        if( ac[p] == 0){ //過去にACしてない。ACズミはむし
            if(S[0] == 'A'){ //今回が初回AC
                score++;
                ac[p] = 1;
                num_wa += wa[p];
            }else{
                wa[p]++;
            }
        }
    }

    cout << score << ' ' <<  num_wa << endl;
    return 0;


 /*int N,M,i;
 cin >>N>>M;
 int* ac_b = new int[N]{0};
 int* pe = new int[N]{0};
 int ac_n;
 int pes;
 int j;
 char s[2];

 for(i=0;i<M;i++){
     cin>>j>>s;
     j=j-1;
     if(ac_b[j]==0){
      if(s[0]=='A') {
          ac_b[j]=1;
          ac_n++;
      }else{
          pe[j]++;
      }
     }
 }
 for(i=0;i<N;i++){
     if(ac_b[i]==1){
         pes=pes+pe[i];
     }
 }

 cout<<ac_n<<' '<<pes<<endl;
return 0;*/

}

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

int main(){
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s==u){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%lld ",a)
using namespace std;
int n;
ll l,r,lbound,rbound,mid=0,qaq;
ll now;
int a[100050];
bool flag,f;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); l=2;
	for (int i=1;i<=n;i++)
	  a[i]=read();
	  r=1e18;
	  lbound=l; rbound=r;
	while (l<=r) {
	  f=false;
	  mid=(l+r)>>1; now=mid;
	  for (int i=1;i<=n;i++) {
	    now=(now/a[i])*a[i];
	    if (now<2&&i!=n) {
	      f=true; break;
	    }
	    if (now<a[i]) {
	      f=true; break;
	    }
	  }
	  if (now<2) f=true;
	    if (now==2) flag=true;
	    //printf("%d\n",now);
	  if (not f) r=mid-1;
	  else l=mid+1;
    }
    while (lbound<=rbound) {
    	f=false;
      mid=(lbound+rbound)>>1; now=mid;
      for (int i=1;i<=n;i++) {
        now=(now/a[i])*a[i];
        if (now<2&&i!=n) {
	      f=true; break;
	    }
	    if (now<a[i]) {
	      f=true; break;
	    }
	  }
	  if (now<=2) f=true;
        if (now==2) flag=true;
      //printf("%d\n",now);
      if (not f) rbound=mid-1;
      else lbound=mid+1;
  }
    if (flag) out(l),out(rbound);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
/**  I'm Klaus, NicKlaus :v **/
using namespace std;
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define LOG2(X) ((unsigned) (8*sizeof(int) - __builtin_clz((X)) - 1))
ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	#ifdef LOCAL_JUDGE
		//freopen("in_out/in.txt", "rt", stdin);
		//freopen("int_out/out.txt", "wt", stdout);
	#endif
	int n, k;
	cin>>n;
	vector<int> a(n);
	int ans = 0, cur = 0;
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<n; i++){
		if(i){
			if(a[i] <= a[i-1]){
				cur++;
				ans = max(ans,cur);
			}else{
				ans = max(ans,cur);
				cur=0;
			}
		}else{
			cur = 0;
			ans = cur;
		}
	}
	cout<<ans<<endl;	
	return 0;
}


Measured memory_bytes: 640
line1 = input().split()
n = int(line1[0])
x = int(line1[1])
L = list(map(int,input().split()))

d = 0
for i,l in enumerate(L):
	d += l	
	if d > x:
		print(i+1)
		break
	elif i==n-1:
		print(i+2)
		break

Measured memory_bytes: 3060
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, A, B = map(int, readline().split())
    S = input()
    cnt_a = 0
    cnt_b = 0

    for char in S:
        flag = False
        if char == "a":
            if cnt_a + cnt_b < A + B:
                cnt_a += 1
                flag = True
        elif char == "b":
            if cnt_a + cnt_b < A + B:
                if cnt_b < B:
                    cnt_b += 1
                    flag = True
        print("Yes" if flag else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 75592
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int A[200010],B[200010],num[200010];
int N,M,W,C,D,E,G,K;
int ans,ans2,sum,sum2,cnt,cnt2,Max=0,Min=INF;
string S,T;
vector<int> V;
set<int> U;
map<int,int> H;
bool F,Q[200010];

signed main(){
	cin>>N>>M>>W;
	if(N+M<W-1){
		cout<<(N+M+1)+M<<endl;
	}
	else{
		cout<<M+W<<endl;
	}
	return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < S.size(); ++i) {
    cout << (char)(((S.at(i) + N) - 'A') % 26 + 'A');
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 5;
struct Node {
    int id, num;
}node[maxn];
bool cmp(Node &a, Node &b) {
    return a.num < b.num;
}
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", &node[i].num), node[i].id = i + 1;
    sort(node, node + n, cmp);
    for (int i = 0; i < n ; i++)
        printf("%d ", node[i].id);
    return 0;
}


Measured memory_bytes: 1536
N = gets.to_i

require 'prime'

@m = (1 .. Math.log2(10**12).ceil).each_with_object([0]){|i, o| o << o.last + i}
puts N.prime_division.inject(0){|s, (p, e)| s + @m.bsearch_index{_1 > e} - 1}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 998244353;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};
int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  combination C(n*3);
  mint ans = 0;
  for(int i = 0; i <= k; ++i) {
    mint add = C(n-1, i);
    add *= m;
    add *= modpow(m-1, n-1-i);
    ans += add;
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 12684
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)					(x).begin(),(x).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> p(M);
	vector<string> S(M);
	REP(i, M) cin >> p[i] >> S[i];

	vector<int> AC(N + 1, 0), WA(N + 1, 0);
	REP(i, M) {
		int prgNo = p[i];
		if (AC[prgNo] == 0) {
			if (S[i] == "AC") {
				AC[prgNo]++;
			} else {
				WA[prgNo]++;
			}
		}	
	}

	int ans1 = 0;
	int ans2 = 0;
	REP(i, N + 1) {
		if (AC[i]) ans1++;
		if (AC[i] && WA[i]) ans2 += WA[i];
	}
	cout << ans1 << " " << ans2 << endl; 
	return 0;
}



Measured memory_bytes: 6912
import java.util.*;

public class Main{

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    if(n==0) break;

	    String[] name = new String[n];
	    double[] eff = new double[n];
	    for(int i=0; i<n; i++){
		name[i] = sc.next();
		int p = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), 
		    c = sc.nextInt(), d = sc.nextInt(), e = sc.nextInt(), 
		    f = sc.nextInt(), s = sc.nextInt(), m = sc.nextInt();
		double time = a+b+c+(d+e)*m;
		double income = f*m*s-p;
		eff[i] = income/time;
	    }

	    for(int i=0; i<n-1; i++){
		int maxI = i;
		for(int j=i+1; j<n; j++){
		    if(eff[j]>eff[maxI]) maxI = j;
		    else if(eff[j]==eff[maxI]){
			if(compare(name[j], name[maxI])==1) maxI = j;
		    }
		}
		String tmps = name[i];
		name[i] = name[maxI];
		name[maxI] = tmps;
		double tmpd = eff[i];
		eff[i] = eff[maxI];
		eff[maxI] = tmpd;
	    }

	    for(int i=0; i<n; i++) System.out.println(name[i]);
	    System.out.println("#");
	}
    }

    int compare(String s1, String s2){
	int len1 = s1.length();
	int len2 = s2.length();
	for(int i=0; i<Math.min(len1, len2); i++){
	    if(s1.charAt(i)<s2.charAt(i)) return 1;
	    else if(s1.charAt(i)>s2.charAt(i)) return -1;
	}
	if(len1<len2) return 1;
	else if(len1>len2) return -1;

	return 0;
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//for dfs, I prepare container(tree) at global
vector<int> to[200005];
int ans[200005];
void dfs(int v, int p = -1){
	for(int u: to[v]){
		if(u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}

//#define int int64_t
signed main()
{
	int n, q; cin >> n >> q;
	for(int i = 0, i_len = (int)n-1; i < i_len; ++i){
		int a, b;
		cin >> a >> b;
		--a;--b;
		to[a].emplace_back(b);
		to[b].emplace_back(a);		
	}
	//ans.resize(n);
	for(int i = 0, i_len = (int)q; i < i_len; ++i){
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	dfs(0);

	for(int i = 0, i_len = (int)n; i < i_len; ++i){
		cout << ans[i] << '\n';
	}

}

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

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int color[N], d[N], f[N], tt;
int nt[N];

int next(int M[N][N], int n, int u) {
    for (int v = nt[u]; v < n; ++v) {
        nt[u] = v + 1;
        if (M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int M[N][N], int n, int r) {
    for (int i = 0; i < n; ++i) nt[i] = 0;

    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;

    while (!S.empty()) {
        int u = S.top();
        int v = next(M, n, u);
        if (v != -1) {
            if (color[v] == WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        } else {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}
void dfs(int M[N][N], int n) {
    for (int i = 0; i < n; ++i) {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;

    for (int i = 0; i < n; ++i) {
        if (color[i] == WHITE) dfs_visit(M, n, i);
    }
    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {

    int n;
    cin >> n;

    int M[N][N] = {0};
    int u, k, v;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        --u;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            --v;
            M[u][v] = 1;
        }
    }

    dfs(M, n);

    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef pair<int, int> pii;

double EPS = 1e-9;

int n;
double x[110], y[110], z[110], r[110];

double pow2(double x) { return x * x; }
double dist(double x1, double y1, double z1, double x2, double y2, double z2) {
	return sqrt( pow2(x1 - x2) + pow2(y1 - y2) + pow2(z1 - z2) );
}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	
	bool sameSet(int x, int y) { return root(x) == root(y); }
	
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	
	int size(int x) { return -data[root(x)]; }
};

struct Edge {
	int f, t; double c;
	Edge(int _f, int _t, double _c) : f(_f), t(_t), c(_c) {}
};
bool operator < (const Edge& a, const Edge& b) { return a.c + EPS < b.c; }

void solve() {
	vector<Edge> edges;
	
	for_(i,0,n) for_(j,i + 1,n) {
		double d = dist(x[i], y[i], z[i], x[j], y[j], z[j]);
		edges.push_back( Edge(i, j, max(0.0, d - r[i] - r[j])) );
	}
	
	sort(allof(edges));
	
	UnionFind uf(n);
	double ans = 0.0;
	int e_size = (int)edges.size();
	
	for_(i,0,e_size) {
		Edge e = edges[i];
		if (!uf.sameSet(e.f, e.t)) {
			uf.unionSet(e.f, e.t);
			ans += e.c;
		}
	}
	
	printf("%.3lf\n", ans);
}

int main() {
	while (cin >> n, n) {
		for_(i,0,n) cin >> x[i] >> y[i] >> z[i] >> r[i];
		solve();
	}
	return 0;
}

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

/*
全探索
*/
string binary(int bina, int num){
    string ans = "";
    for (int i = 0; i<num ; i++)
    {
        ans = to_string(bina%2) + ans;
        bina = bina/2;
    }
    return ans;
}

void solve(){
    int n,m;
    cin >> n >> m;
    vector<pair<int, vector<int>>> vec;
    rep(i,m){
        int k;
        vector<int> v;
        cin >> k;
        rep(j,k){
            int s;
            cin >> s;
            v.emplace_back(s);
        }
        vec.emplace_back(make_pair(k,v));
    }
    vector<int> p;
    rep(i,m){
        int tmp;
        cin >> tmp;
        p.emplace_back(tmp);
    }
    bool b[n];
    rep(i,n){
        b[i] = false;
    }
    /*
    配列bを整数値iで表現する。
    i -> bの変換
    iを二進法表記

    各bのパターンについて、
    vecの各要素vec[j]={s[0],s[1],...,s[k-1]}を考え、
    int tmp=0;
    b[s[x]]==trueならtmp++
    tmpの偶奇がp[j]に一致すればok。
    これが任意のjで成立すれば、count++
    */
    
    int count = 0;
    rep(i,pow(2,n)){
        rep(j,n){
            char chr=binary(i,n)[j];
            if(chr=='1') b[j]=true;
            else b[j]=false;
        }
        //cout << binary(i,n) << endl;

        bool ok=true;
        rep(j,m){
            int k=vec[j].first;
            vector<int> s = vec[j].second;
            int tmp=0;
            rep(x,k){
                if(b[s[x]-1]==true) tmp++;
            }
            //cout << "i:" << binary(i,n) << ", " << j << "番目の電球：" << tmp << endl;
            if(tmp%2!=p[j]) ok=false;
        }
        if(ok) count++;
    }

    cout << count << endl;


}

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

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next(),16);
    int b = Integer.parseInt(sc.next(),16);
    String answer = "=";
    if(a>b){
      answer = ">";
    }else if(a<b){
      answer = "<";
    }
    System.out.println(answer);
    }
  }


Measured memory_bytes: 23636
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int M,j,i=1,res,D,N,count=0,v,mod,a[10001];
  long int Max=-999,d,x[1001],y[1001],z[1001],sum[1001],cx[1001],cy[1001],cz[1001],f=-1;
  scanf("%d %d",&N,&M);
  for(i=0;i<N;i++)
    scanf("%ld %ld %ld",&x[i],&y[i],&z[i]);
  for(i=0;i<8;i++){
    d = 0;
    if(i & 1){
      for(j=0;j<N;j++)
        cx[j] = -x[j];
    }else
      for(j=0;j<N;j++)
        cx[j] = x[j];
    if((i >> 1) & 1){
      for(j=0;j<N;j++)
        cy[j] = -y[j];
    }else
      for(j=0;j<N;j++)
        cy[j] = y[j];
    if((i >> 2) & 1){
      for(j=0;j<N;j++)
        cz[j] = -z[j];
    }else
      for(j=0;j<N;j++)
        cz[j] = z[j];
    for(j=0;j<N;j++)
      sum[j] = cx[j] + cy[j] + cz[j];
    sort(sum,sum+N);
    for(j=N-1;j>=N-M;j--)
      d += sum[j];
    Max = max(Max,d);
  }
  
  printf("%ld\n",Max);
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
#define task "tet"
using namespace std;
const ll N = 1e6 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;
struct tempo{
    string x;
    ll cond,diff;
};
tempo s[N];
ll n,i,cur,j,depth;
ll Get1(string x){
    ll n = x.size(),deep = 0,maxx = -inf;
    for (ll i = n - 1;i >= 0;i--){
        if (x[i] == '(') deep++;
        else deep--;
        maxx = max(maxx,deep);
    }
    return maxx;
}
ll Get2(string x){
    ll n = x.size(),deep = 0,minn = inf;
    for (ll i = 0;i < n;i++){
        if (x[i] == '(') deep++;
        else deep--;
        minn = min(minn,deep);
    }
    return minn;
}
ll Count(string x){
    bool flag = true;
    ll n = x.size(),deep = 0;
    for (ll i = 0;i < n;i++){
        if (x[i] == '(') deep++;
        else deep--;
        if (deep < 0) flag = false;
    }
    if (flag) return 0;
    else{
        if (deep > 0) return 1;
        return 2;
    }
}
bool lf(tempo x,tempo y){
    if (x.cond < y.cond) return true;
    else if (x.cond > y.cond) return false;
    else return x.diff > y.diff;
}
bool chk(){
    for (i = 1;i <= n;i++){
        string p = s[i].x;
        for (j = 0;j < p.size();j++){
            if (p[j] == '(') depth++;
            else depth--;
            if (depth < 0) return false;
        }
    }
    return (depth == 0);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n;
    for (i = 1;i <= n;i++){
        cin>>s[i].x;
        s[i].cond = Count(s[i].x);
        if (s[i].cond == 1) s[i].diff = Get2(s[i].x);
        if (s[i].cond == 2) s[i].diff = Get1(s[i].x);

    }
    sort(s + 1,s + n + 1,lf); //cout<<s[1].x<<"\n";
    if (chk()) cout<<"Yes";
    else cout<<"No";

}


Measured memory_bytes: 43948
#import numpy as np
from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph)
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！

def main():
    n,a,b,*h=map(int,open(0).read().split())
    h=array(h)

    ok=-1
    ng=max(h)+10
    
    def judge(t):
        H=deepcopy(h)
        H-=b*t
        H=H[H>0]
        if sum((H-1)//(a-b)+1)<=t:
            return 1
        else:
            return 0
    
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
#        print(mid,"NY"[judge(mid)])
        if judge(mid):
            ng=mid
        else:
            ok=mid
    l=ok+1
    print(l)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24316
N = int(input())
S = [input() for _ in range(N)]

S = sorted(S)
newS = sorted(list(set(S)))
frq = [0] * len(newS)

si = index = 0
for i in range(N):
    if i == N-1:
        frq[index] = N - si
    elif S[i] != S[i+1]:
        frq[index] = i + 1 - si
        si = i + 1
        index += 1
    
ma = max(frq)
for i in range(len(newS)):
    if frq[i] == ma:
        print(newS[i])

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

void doStdOut(const char *str);

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

	if(a < b && b < c){ doStdOut("Yes"); }
	else{ doStdOut("No"); }

	return 0;
}

void doStdOut(const char *str){ cout << str << endl; }

Measured memory_bytes: 3048
r = input().split()
a = int(r[0])
b = int(r[1])
c = int(r[2])

m1 = min(a,b,c)
m3 = max(a,b,c)

if a == m1:
    m2 = min(b,c)
elif b == m1:
    m2 = min(a,c)
else:
    m2 = min(a,b)

print(m1,m2,m3)

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

int main() {

    ll a;
    long double b;
    cin >> a >> b;
    ll ans = a * b;

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

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,ans="";
	cin >> s;
	FOR(i,0,s.size()){
		if(s[i]=='0'){
			ans += '0';
		}else if(s[i]=='1'){
			ans += '1';
		}else{
			ans = ans.substr(0,ans.size()-1);
		}
	}
	cout << ans << endl;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    rep(i,n){
        if(i == (k-1)){
            if(s[i] == 'A') cout << 'a';
            if(s[i] == 'B') cout << 'b';
            if(s[i] == 'C') cout << 'c';
        }
        else cout << s[i];
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
#define all(x) (x).begin(),(x).end()

//Nは桁数が大きい場合があるので文字列として受け取る
string N;
vector<int> n;  //Nの各桁の数字を格納するベクター
int dp[120][2][5];

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

  //ベクターnを構成
  for(auto a : N){
    n.push_back(a-'0');
  }
  int l = N.size();  //nの長さ

  dp[0][0][0] = 1;  //初期条件。他は0で初期化されている
  for(int i = 0; i < l; i++){
    for(int smaller = 0; smaller < 2; smaller++){
      for(int j = 0; j < 4; j++){
            for(int x = 0; x <= (smaller ? 9 : n[i]); x++){
              int num;
              if(x>0) num = j + 1;
              else num = j;
              dp[i + 1][smaller || x < n[i]][ num ] += dp[i][smaller][j];          
        }
      }
    }
  }

  cout << dp[l][0][k] + dp[l][1][k] << endl;

  return 0;
}

Measured memory_bytes: 256
/*
Author- Aasav Badera
Time- Sun Mar 22 17:46:21 2020
*/
#include<bits/stdc++.h> 
#define ll                 long long                            
#define pb                 push_back                                                     
#define s                  second
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define rep(i, a, b)         for(ll  i=a;i<b;i++)
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define f                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define mp                 make_pair
#define yes                cout << "YES" << endl;
#define no                 cout << "NO" << endl;
#define inf                1e18L+1
#define endl               '\n' 
using namespace std;
#define N  300005
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    ll tests = 1;
    // cin >> tests;
    while(tests--)
    {
    	ll l;
    	cin >> l;
    	double k1 = (l*1.000000000000000000000000000)/3;
    	double k2 = 1.0000000000000000*((k1*1.00000000000000000) * (k1*1.00000000000000000) * (l - 2*k1*1.00000000000000000));
    	cout << setprecision(12) << k2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*input
FFTTF

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#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())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=16005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

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

vector<int> a,b;

bool v[maxn];

int main()
{
	//IOS;
	string s;
	cin>>s;
	int x,y;
	cin>>x>>y;
	bool f=0;
	int cnt=0;
	bool QAQ=1;
	for(char c:s){
		if(c=='F') cnt++;
		else{
			if(f) b.pb(cnt);
			else{
				if(QAQ){
					x-=cnt;
				}
				else a.pb(cnt);
			}
			cnt=0;
			f=!f;
			QAQ=0;
		}
	}
	if(f) b.pb(cnt);
	else{
		if(QAQ) x-=cnt;
		else a.pb(cnt);
	}
	x=abs(x);y=abs(y);
	bool flag=1;
	REP(I,1){
		ll tt=0;
		for(int i:a) tt+=i;
		if(tt%2!=x%2||tt<x){
			flag=0;
			break;
		}
		ll des=(tt-x)/2;
		memset(v,0,sizeof v);
		v[0]=1;

		for(int i:a){
			for(int j=des-i;j>=0;j--) if(v[j]){
				v[i+j]=1;
			}
		}
		if(!v[des]) flag=0;
	}
	REP(I,1){
		ll tt=0;
		for(int i:b) tt+=i;
		if(tt%2!=y%2||tt<y){
			flag=0;
		}
		ll des=(tt-y)/2;
		memset(v,0,sizeof v);
		v[0]=1;

		for(int i:b){
			for(int j=des-i;j>=0;j--) if(v[j]){
				v[i+j]=1;
			}
		}
		if(!v[des]) flag=0;
	}
	if(flag) cout<<"Yes\n";
	else cout<<"No\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,pr=0;
    cin >> n;
    vector<P> p(n);
    rep(i,n) cin >> p[i].second >> p[i].first;
    sort(p.begin(),p.end());
    rep(i,n){
        pr+=p[i].second;
        if(pr>p[i].first){
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}   

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair < pair <int, int> , int> ppi;
typedef pair < pair <int, int> , ll> ppll;
typedef pair <ll, ll> pll;
typedef string str;

# define endl		 '\n'
# define sep		 ' '
# define F 			 first
# define S 			 second
# define pb			 push_back
# define fast_io 	 ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll md = 1e9+7;

ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a%b);}
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b);}
ll pw(ll a, ll b){
	if (b == 1) return (a+md)%md;
	if (b%2 == 0) return (pw(a*a, b/2)+md)%md;
	else return (a*pw(a*a, b/2)+md)%md;
}

const int xn = 1e6+10;
const int xm = 5e4+10;

int cnt[5];

int main(){
	fast_io;
	
	ll a, b;
	cin >> a >> b;
	
	cout << lcm(a, b) << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(int a,int b)
{
    return a>b;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int arr[n];
    long long  sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    sort(arr,arr+n,comp);
    int flag=0;
    for(int i=0;i<m;i++)
    {
        if(arr[i]*4*m<sum)
        flag=1;
    }
    if(flag==0)cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256