akhauriyash/Code-Regression huggingface dataset:
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
sys.setrecursionlimit(10 ** 7)
mod = 10**9 + 7

n, q = map(int, input().split())
stx = []
for _ in range(n):
    s, t, x = map(int, input().split())
    stx.append([x, s - x, t - x])
stx.sort(reverse=True)
d = [int(input()) for _ in range(q)]

N = q
N0 = 2**(N-1).bit_length()
data = [None]*(2*N0)
INF = (-1, 10**9 + 1)
def update(l, r, v):
    L = l + N0; R = r + N0
    while L < R:
        if R & 1:
            R -= 1
            data[R-1] = v

        if L & 1:
            data[L-1] = v
            L += 1
        L >>= 1; R >>= 1
def _query(k):
    k += N0-1
    s = INF
    while k >= 0:
        if data[k]:
            s = max(s, data[k])
        k = (k - 1) // 2
    return s
def query(k):
    return _query(k)[1]



import bisect

for i, (x, start, last) in enumerate(stx):
    l = bisect.bisect_left(d, start)
    r = bisect.bisect_left(d, last)
    update(l, r, (i, x))

for i in range(q):
    res = query(i)
    if res == 10**9 + 1:
        print(-1)
    else:
        print(res)
    



Measured memory_bytes: 116780
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;


vl pow_;
void pow_ini(ll n) {
	pow_.clear();
	pow_.push_back(n);
	rep(j, 62) {
		ll nxt = pow_[j] * pow_[j];
		nxt %= mod;
		pow_.push_back(nxt);
	}
	return;
}

ll pow1(ll k) {
	ll ans = 1;
	rep(ntmp, 62) {
		if ((k >> ntmp) % 2 == 1) {
			ans *= pow_[ntmp];
			ans %= mod;
		}
	}
	return ans;
}

vl fact;
vl fact_inv;

void fact_ini(ll n) {
	fact.resize(n + 1);
	fact[0] = 1;
	for (ll i = 1; i <= n; i++) {
		ll fact_tmp = fact[i - 1] * i;
		fact_tmp %= mod;
		fact[i] = fact_tmp;
	}
	fact_inv.resize(n + 1);
	pow_ini(fact[n]);
	fact_inv[n] = pow1(mod - 2);
	for (ll i = n - 1; i >= 0; i--) {
		fact_inv[i] = fact_inv[i + 1] * (i + 1);
		fact_inv[i] %= mod;
	}
}

ll nCm(ll n, ll m) {
	assert(m >= 0);
	assert(n < fact.size());
	assert(n >= m);
	ll ans = fact[n] * fact_inv[m];
	ans %= mod;
	ans *= fact_inv[n - m];
	ans %= mod;
	return ans;
}

int main() {
	fact_ini(220000);
	ll B, W;
	cin >> B >> W;
	ll x = 1;
	ll yallB = 0;
	ll yallW = 0;
	ll n, m;
	for (int i = 0; i < B + W; i++) {
		x *= 2;
		yallB *= 2;
		yallW *= 2;
		x %= mod;
		yallB %= mod;
		yallW %= mod;
		ll xtmp = x * 2;
		ll ytmp = x;
		ytmp -= yallB;
		ytmp += yallW;
		ytmp += mod;
		ytmp %= mod;
		pow_ini(xtmp);
		ll z = pow1(mod - 2) * ytmp;
		z %= mod;
		cout << z << endl;
		if (i >= W - 1)
			yallW += nCm(i, W - 1);
		if (i >= B - 1)
			yallB += nCm(i, B - 1);
	}
	return 0;
}

Measured memory_bytes: 5632
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong p)
{
	llong sum = 0;
	int j = 0;
	int c = 0;
	for (int i = 0; i < k; i++) {
		for (; j < n; j++) {
			sum += T[j];
			if (sum > p) {
				sum = 0;
				break;
			}
			c++;
		}
	}
	return c;
}

llong solve()
{
	llong left = 0;
	llong right = MAX * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n) right = mid;
		else left = mid;
	}
	return right;

}

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> T[i];
	}
	llong ans = solve();
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3872
n = int(input())
F = [0] * 300 ** 2

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp = (x+y+z)**2 - x*y - y*z - z*x
            F[tmp] += 1

for f in F[1:n+1]:
    print(f)


Measured memory_bytes: 69440
import java.util.*;
public class Main{
	public static void main(String args[]){
		
		Scanner ob = new Scanner(System.in);
		int K = ob.nextInt();
		String S = ob.next();
		String D = "...";
		String R = "";
		
		if(S.length() > K){
			for(int i = 0; i < K; i++){
				R += S.charAt(i);
			}
			R += "...";
			
			System.out.println(R);
		}
		else{
			System.out.println(S);
		}
	}
}

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

int c[10][1005];

int main(void) 
{
    const int INF =1001001001;

    int c[10][1005];
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = INF;

    // 1 << h-1 = 2^(h-1)
    //線を引くor引かないの２通り
    rep(div, 1 << (h-1))
    {
         //2進数でビットが立っているところで分ける(div)
        int group =0;
        vector<int> id(h);
        rep(i,h)
        {
            id[i] = group;
            //シフトして１(線を引く)なら次からのグループをインクリする
            if(div >> i&1) group++;
        }
        //グループ数を表す為にインクリ
        group++;

        //縦グループ数分、横全て初期化
        rep(i,group)rep(j,w) c[i][j] = 0;
        rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j] -'0');
        
        //縦に切っていく
        int num = group - 1;
        vector<int> now(group);
        auto add = [&](int j)
        {
            rep(i,group) now[i] += c[i][j];
            rep(i,group) if(now[i] > k) return false;           
            return true;
        };
        rep(j,w)
        {
            if(!add(j))
            {
                num++;
                now = vector<int>(group);
                if(!add(j))
                {
                    num = INF;
                    break;
                }                
            }         
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000001
#define MAX 1000002
using namespace std;

int H;
int heap[MAX];

void MaxHeapify(int A[], int i) {
	int l = i * 2, r = i * 2 + 1, largest;
	if (l <= H && A[l] > A[i]) {
		largest = l;
	}
	else {
		largest = i;
	}
	if (r <= H && A[r] > A[largest]) {
		largest = r;
	}
	if (largest != i) {
		swap(A[i], A[largest]);
		MaxHeapify(A, largest);
	}
}

void BuildMaxHeap(int A[]) {
	for (int i = H / 2; i >= 1; i--) {
		MaxHeapify(A, i);
	}
}

int main()
{
	cin >> H;
	for (int i = 0; i < MAX; i++) {
		if (i >= 1 && i <= H)
			cin >> heap[i];
		else
			heap[i] = -INF;
	}
	BuildMaxHeap(heap);
	for (int i = 1; i <= H; i++) {
		cout << ' ' << heap[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 6984
n, m = [int(i) for i in input().split()]
a = []
b = []
c = []
d = []
for k in range(n):
    tmp = [int(i) for i in input().split()]
    a.append(tmp[0])
    b.append(tmp[1])
for k in range(m):
    tmp = [int(i) for i in input().split()]
    c.append(tmp[0])
    d.append(tmp[1])

for i in range(n):
    point = 1
    min_dis = abs(a[i] - c[0]) + abs(b[i] - d[0])
    for j in range(1, m):
        dis = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if min_dis > dis:
            point = j + 1
            min_dis = dis
    print(point)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{

if(a+b<10)
{
	cout<<1<<endl;
}
else if(a+b<100)
{
	cout<<2<<endl;
}
else if(a+b<1000)
{
	cout<<3<<endl;
}
else if(a+b<10000)
{
	cout<<4<<endl;
}
else if(a+b<100000)
{
	cout<<5<<endl;
}
else if(a+b<1000000) 
{
	cout<<6<<endl;
}
else if(a+b<10000000)
{
	cout<<7<<endl;
}
}
return 0;
}

Measured memory_bytes: 3040
s=gets.chomp
t=gets.chomp

n, m=s.size, t.size
cand=[]
n.times do |i|
  next if i+m>n
  ok=true
  m.times do |j|
    ok&=(s[i+j]==t[j] or s[i+j]=='?')
  end
  cand.push((s[0...i]+t+s[(i+m)...n]).gsub(/\?/, 'a')) if ok
end

if cand.empty?
  puts 'UNRESTORABLE'
else
  puts cand.sort[0]
end

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		new AOJ0156().doIt();
	}
	
	class AOJ0156{
		int mx,my;
		char[][] map;
		int[][] cost;
		int[] sx,sy;
		void doIt(){
			sx = new int[4];sx[0]=0;sx[1]=1;sx[2]=0;sx[3]=-1;
			sy = new int[4];sy[0]=1;sy[1]=0;sy[2]=-1;sy[3]=0;
			while(true){
				mx = in.nextInt();
				my = in.nextInt();
				if(mx+my == 0)return;
				map = new char[my+2][mx+2];
				cost = new int[my+2][mx+2];
				for(int i=0;i<my+2;i++){
					Arrays.fill(map[i], '.');
					Arrays.fill(cost[i], -1);
				}
				for(int i=0;i<my;i++){
					char input[] = in.next().toCharArray();
					for(int s=0;s<mx;s++)map[i+1][s+1] = input[s];
				}
//				print();
				PriorityQueue<State> q = new PriorityQueue<State>();
				q.add(new State(0, 0, 0,false));int result = 0;
				while(q.size()>0){
					State now = q.remove();
//					System.out.println(now.x+" "+now.y+" "+now.cost);
					if(map[now.y][now.x]=='&'){
						result = now.cost;
						break;
					}
					for(int i=0;i<4;i++){
						int nx = now.x+sx[i];
						int ny = now.y+sy[i];
						if(nx<0||nx>=mx+2||ny<0||ny>=my+2)continue;
						if(cost[ny][nx]>=now.cost)continue;
						boolean plus = map[now.y][now.x]=='.'&&map[ny][nx]=='#';
						cost[ny][nx] = plus?now.cost+1:now.cost;
						q.add(new State(nx, ny, cost[ny][nx], map[ny][nx]=='#'));
					}
				}
				System.out.println(result);
//				for(int i=0;i<my+2;i++){
//					for(int s=0;s<mx+2;s++)System.out.print(cost[i][s]);
//					System.out.println();
//				}
			}
		}		
		void print(){
			for(int i=0;i<my+2;i++){
				for(int s=0;s<mx+2;s++)System.out.print(map[i][s]);
				System.out.println();
			}
		}
		
		class State implements Comparable<State>{
			int x,y,cost;
			boolean isHori;
			public State(int x,int y,int cost,boolean isHori) {
				this.x = x;
				this.y = y;
				this.cost = cost;
				this.isHori = isHori;
			}
			public int compareTo(State o) {
				return cost-o.cost;
			}
		}
	}
	
}

Measured memory_bytes: 40252
#include<stdio.h>
 
int main()
{
    int x;
    scanf("%d",&x);
     
    int f[777];
     
    f[0]=f[1]=1;
     
    int i;
    for(i=2;i<=x;i++)
    {
        f[i]=f[i-1]+f[i-2];
    }
     
    printf("%d\n",f[x]);
     
    return 0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

#define UF_NUM 505050

li n, q;
string s;

li sum[100100];

inline bool ok(li i) {
    if (i == 0)return false;
    return (s[i - 1] == 'A' && s[i] == 'C');
}

int main() {
    cin >> n >> q;
    cin >> s;
    sum[0] = 0;
    rep(i, n) {
        if (ok(i)) {
            sum[i + 1] = sum[i] + 1;
        } else {
            sum[i + 1] = sum[i];
        }
    }

    rep(i, q) {
        li l, r;
        cin >> l >> r;
        l--;
        r--;
        li tres = sum[r + 1] - sum[l];
        if (ok(l))tres--;
        cout << tres << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
  int n;
  cin >> n;
  double a;
  if (n%2 == 0) {
    a = 1/2.0;
  }
  else {
    a = (double)(n + 1)/(2*n);
  }
  printf("%.16lf\n", a);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int x;
	cin >> x;
	if (x == 7 or x == 5 or x == 3) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}

Measured memory_bytes: 3524
#include<stdio.h>
int main()
{
  char A[5],B[5];
  int i=0;
  int count=0;
    scanf("%s",A);
    scanf("%s",B);
  for(i=0;i<=2;i++)
  {
    if(A[i]==B[i]) 
    {
         count=count+1;
    }
  }
    printf("%d",count);
    return 0;
       }


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef long double R;
typedef complex<R> P;

const R EPS = 1e-10;
const R PI = acos((R)(-1));

bool solve() {
    R w, h, a, b, ab;
    cin >> w >> h >> a >> b >> ab;
    if (!w) return false;
    bool ch = (a > b);
    if (ch) {
        swap(a, b);
    }
    R ra = sqrt(a/PI);
    R rb = sqrt(b/PI);
    if (min(w, h) < 2*ra || min(w, h) < 2*rb) {
        cout << "impossible" << endl;
        return true;
    }
    R l = 0, r = PI;
    for (int i = 0; i < 100; i++) {
        R md1 = (l+r)/2;
        R md2 = asin(ra/rb*sin(md1));
        R sm = 0;
        sm += ra*ra*(md1 - sin(md1)*cos(md1));
        sm += rb*rb*(md2 - sin(md2)*cos(md2));
        if (sm < ab) {
            l = md1;
        } else {
            r = md1;
        }
    }
    R l1 = l;
    R l2 = asin(ra/rb*sin(l1));
    R rc = ra*cos(l1)+rb*cos(l2);
//    cout << "debug " << ra << " " << rb << " " << rc << endl;
    if (abs(P(w-ra-rb, h-ra-rb)) < rc) {
        cout << "impossible" << endl;
        return true;
    }
    P ap, bp;
    bp = P(rb, rb);
    ap = bp + polar(rc, arg(P(w-ra-rb, h-ra-rb)));
    if (ch) {
        swap(ap, bp);
        swap(ra, rb);
    }
    printf("%.10Lf %.10Lf %.10Lf %.10Lf %.10Lf %.10Lf\n",
        ap.real(), ap.imag(), ra, bp.real(), bp.imag(), rb);
    return true;
}

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

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,tmp=1;
    cin >> n;
    while (tmp*2 <= n) {
            tmp*=2;

    }
    cout << tmp;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define fr first
#define sc second

int main(){
	static ll n,m;
	cin >> n >> m;
	
	static ll dp[2][5002] = {};
	static ll t = 0, t_ = 1;
	dp[t][0] = 1;
	for(int i = 1 ; i <= n ; i ++){
		int d = min((ll)i-1,n-i)+1;
		for(int j = 0 ; j <= n-1 ; j ++){
			if(j-d < 0)dp[t_][j] = dp[t][j];
			else{
				dp[t_][j] = dp[t][j]+dp[t_][j-d];
				if(dp[t_][j]>=m)dp[t_][j] -= m;
			}
		}
		swap(t,t_);
	}
	ll ret = 0;
	for(int i = 0 ; i <= n-1 ; i ++){
		ret += dp[t][i];
	}
	cout << ret%m << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,walk[100],c[10],coun[10],re[10];
stack<int> stk;
vector<int> v[100];
void path(int x,int lv){
	re[0] = v[x].size();
	for(int i=0;i<v[x].size();i++){
		for(int j=0;j<lv;j++){
			if(walk[j] == v[x][i]){
				re[0]--;
				break;
			}
		}
	}
	//printf("%d %d %d\n",lv,re[0],v[x].size());
	if(re[0] > 0){
		for(int i=0;i<v[x].size();i++){
			c[0] = 0;
			for(int j=0;j<lv;j++){
				if(walk[j] == v[x][i]){
					c[0] = 1;
					break;
				}
			}
			if(c[0] == 0){
				walk[lv] = v[x][i];
				path(v[x][i],lv+1);
			}
		}
	}
	else{
		if(lv == n){
			coun[0]++;
		}
		return;
	}
}
int main(){
	memset(walk,0,sizeof walk);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	walk[0] = 1;
	path(1,1);
	printf("%d",coun[0]);
}

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

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

	string ans = "NO";

	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) ans = "YES";

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long inf = 4523372036854775807;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	int sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
bool a[100000];
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != '0')
			a[i] = 1;
	}
	int ans = s.size(), n = s.size(), sum = 0;
	for (int i = 0; i < s.size() - 1; i++) {
		if (a[i] != a[i + 1]) {
			ans = min(ans, max(i + 1, (n - i - 1)));
		}
	}
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define nl '\n'
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define all(a) a.begin(),a.end()
#define F first
#define S second
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[N],h[N];

void solve()
{
	ll n;
	cin>>n;
	rep(i,1,n)cin>>h[i];
	a[1]=0;
	a[2]=abs(h[2]-h[1]);
	rep(i,3,n)
	{
		a[i] = min(a[i-1]+abs(h[i]-h[i-1]) , a[i-2]+abs(h[i]-h[i-2]));
		//cout<<a[i]<<" ";
	}
    cout<<a[n];
}



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

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

int n, m;
pair<int, bool> bomb[100100];
bool b[100100];
int l[200200], r[200200];

int first_larger_or_equal(int pos){
	int l = 0, r = n-1;
	while(l <= r){
		int mid = (l+r) >> 1;
		if(bomb[mid].first >= pos) r = mid-1;
		else l = mid+1;
	}
	return l;
}

vector< pair<int, int> > v[100100]; 
bool ans[200200];
bool used[200200];

bool dfs(int now){
	used[now] = 1;
	bool ret = 0;
	rep(i, v[now].size()){
		if(!used[v[now][i].first]){
			ans[v[now][i].second] = dfs(v[now][i].first);
			ret ^= ans[v[now][i].second];
		}
	}
	return ret ^ b[now];
}

int main(){
	scanf("%d %d", &n, &m);
	rep(i, n) scanf("%d %d", &bomb[i].first, &bomb[i].second);
	sort(bomb, bomb+n);
	rep(i, m){
		scanf("%d %d", &l[i], &r[i]);
		l[i] = first_larger_or_equal(l[i]);
		int R = r[i];
		r[i] = first_larger_or_equal(r[i]);
		if(r[i] == n || bomb[r[i]].first > R) r[i]--;
		v[l[i]].push_back(make_pair(r[i]+1, i));
		v[r[i]+1].push_back(make_pair(l[i], i));
	}
	bomb[n].second = 0;
	rep(i, n+1) b[i] = (i ? bomb[i-1].second : 0) ^ bomb[i].second;
	rep(i, n){
		if(!used[i]){
			bool ret = dfs(i);
			if(ret){
				cout << "-1" << endl;
				return 0;
			}
		}
	}
	vector<int> res;
	rep(i, m){
		if(ans[i]) res.push_back(i);
	} 
	cout << res.size() << endl;
	rep(i, res.size()) cout << res[i]+1 << " ";
	cout << endl; 
	return 0;
}

Measured memory_bytes: 17788
import java.util.Scanner;
public class Main {
	
	static int count, H, W;
	static int[][] move = {{1,0}, {-1,0}, {0,1}, {0,-1}};
	static char[][] r;
	
	static void dfs(int i, int j) {
		for(int k=0; k<4; k++) {
			int ni = i + move[k][0];
			int nj = j + move[k][1];
			if(0<=ni && ni<H && 0<=nj && nj<W && r[ni][nj] != '#') {
				r[ni][nj] = '#';
				count++;
				dfs(ni, nj);
			}
		}
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				W = sc.nextInt();
				H = sc.nextInt();
				if(W+H == 0) break;
				
				r = new char[H][W];
				int si = 0;
				int sj = 0;
				
				for(int i=0; i<H; i++) {
					char[] s = sc.next().toCharArray();
					for(int j=0; j<W; j++) {
						r[i][j] = s[j];
						if(s[j] == '@') {
							si = i;
							sj = j;
						}
					}
				}
				count = 1;
				r[si][sj] = '#';
				dfs(si, sj);
				System.out.println(count);
			}
		}
	}
}



Measured memory_bytes: 39144
import java.io.*;
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		int n = sc.nextInt();
		@SuppressWarnings("unused")
		int l = sc.nextInt();

		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		Arrays.sort(s);

		for (String e : s) {
			pr.print(e);
		}
		pr.println();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 10000
#include <stdio.h>

int main(void)
{
	double x[20], y[20];
	int i = 0, j;
	double sum = 0;
	
	while(scanf("%lf,%lf", &x[i], &y[i]) != EOF) {
		i++;
	}
	for(j = 1; j < i; j++) {
		x[j] -= x[0];
		y[j] -= y[0];
	}
	for(j = 1; j < i - 1; j++) {
		double s;
		
		s = x[j] * y[j + 1] - x[j + 1] * y[j];
		sum += (s > 0) ? s / 2.0 : (-1) * s / 2.0;
	}
	printf("%f\n", sum);
	
	return 0;
}


Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <limits>
#include <vector>
#define ll long long
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    string S;
    cin >> S;
    vector<int> vec;
    vector<int> cha;
    int cnt = 1;

    for(int i = 0;i < S.size();i++){
        if(i == S.size() - 1){
            if(S[i+1] == S[i]){
                cnt++;
                vec.pb(cnt);
            }
            else{
                cha.pb(i);
                vec.pb(cnt);
            }
        }
        else{
            if(S[i] == S[i+1]){
                cnt++;
            }
            else{
                vec.pb(cnt);
                cha.pb(i);
                cnt = 1;
            }
        }
    }

    /*rep(i,cha.size()){
        cout << cha[i] << " ";
    }
    cout << endl;

    rep(i,vec.size()){
        cout << vec[i] << " ";
    }
    cout << endl;*/

    cnt = 0;
    int right = 0,left = 0;

    for(int i = 0;i < S.size();i++){
        if(cha[cnt] == i){
            right = (vec[cnt] + 1)/2 + vec[cnt + 1]/2;
            left = vec[cnt]/2 + (vec[cnt + 1] + 1)/2;//RRR 3 LL 2 R 1 LL 2 RRR 3 LLLLL 5
            cout << right << " " << left << " ";
            i++;
            cnt += 2;
        }
        else{
            cout << 0 << " ";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1524
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 1;
int n , k , c;
int a[N] , pr[N] , pr2[N]; 
main(){
	scanf("%lld"  , &n);
    rep(i , 1 , n)
		scanf("%lld" , a + i);
	sort(a + 1 , a + 1 + n);
	rep(i , 1,  n)
		pr[i] = pr[i - 1] + a[i];
    int ans = 1;
	rep(i ,1 , n-1)
		pr2[i] = (int)(2ll * pr[i] >= a[i + 1]) + pr2[i - 1];   
	rep(i , 1 , n-1){
		ans += (pr2[n - 1] - pr2[i - 1] == n - i);
	}
	ret(ans);
					
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000000;
// clang-format on

int N, M;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;

  if (N == M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		String[] str = new String[N];
		for (int i = 0; i < N; i++) {
			str[i] = scn.next();
		}
		Arrays.parallelSort(str);
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		for (int i = 0; i < N; i++) {
			String s = str[i];
			if (s.contentEquals("AC")) {
				AC++;
			} else if (s.contentEquals("WA")) {
				WA++;
			} else if (s.contentEquals("TLE")) {
				TLE++;
			} else if (s.contentEquals("RE")) {
				RE++;
			}
		}
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);
	}
}

Measured memory_bytes: 55480
using System;

namespace ABC062B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int H = Int32.Parse(bufs[0]);
            int W = Int32.Parse(bufs[1]);

            string[] keep = new string[H];

            for (int i = 0; i < H; i++)
            {
                keep[i] = Console.ReadLine();
            }

            for (int i = 0; i < W + 2; i++)
            {
                Console.Write('#');
            }
            Console.WriteLine();

            for (int i = 0; i < H; i++)
            {
                Console.WriteLine("#{0}#", keep[i]);
            }

            for (int i = 0; i < W + 2; i++)
            {
                Console.Write('#');
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int H, W;
    cin >> H >> W;
    char S[H+2][W+2] = {};
    REP(i,H){
        REP(j,W){
            cin >> S[i+1][j+1];
        }
    }
    REP(i,H){
        REP(j,W){
            int c = 0;
            if(S[i+1][j+1] == '#'){
                cout << "#" ;
                continue;
            }
            REP(k,3){
                REP(l,3){
                    if(S[i+k][j+l] == '#'){
                        c++;
                    }
                }
            }
            cout << c ;
        }
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val diff = 100000000000L
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val branch = Array(n + 1) { mutableListOf<Pair<Int, Long>>() }
    val visited = Array(n + 1) { false }
    val dist = Array(n + 1) { Long.MIN_VALUE }
    (1..m).forEach {
        val (l, r, d) = readLine()!!.split(' ').map(String::toLong)
        branch[l.toInt()].add(Pair(r.toInt(), d))
        branch[r.toInt()].add(Pair(l.toInt(), -d))
    }

    var baseDist = 0L
    for (startPos in 1..n) {
        val queue = ArrayDeque<Int>()
        if (visited[startPos]) continue
        queue.add(startPos)
        visited[startPos] = true
        dist[startPos] = baseDist
        baseDist += diff
        while (queue.isNotEmpty()) {
            val cur = queue.pollFirst()!!
            val bs = branch[cur]
            for (b in bs) {
                val (to, cost) = b
                if(visited[to]){
                    if(dist[to]!=dist[cur]+cost){
                        println("No")
                        return
                    }
                }else{
                    queue.add(to)
                    visited[to]=true
                    dist[to] = dist[cur]+cost
                }
            }
        }
    }

    println("Yes")
}


Measured memory_bytes: 140136
N,M = map(int, input().split())
ans = 0
S = [""]*N
for _ in range(M):
  s, c = map(int,input().split())
  if S[s-1] == "" or S[s-1] == c:
    S[s-1] = c
  elif S[s-1] != "" and S[s-1] != c:
    print(-1)
    exit(0)
if N != 1:
  if S[0] == "":
    S[0] = 1
  if S[0] == 0:
    print(-1)
    exit(0)
  for i in range(1,N):
    if S[i] == "":
      S[i] = 0
elif N == 1:
  if S[0] == "":
    S[0] = 0
print(''.join(map(str,S)))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a+b<c+d){
		printf("Right");
	}
	if(a+b==c+d){
		printf("Balanced");
	}
	if(a+b>c+d){
		printf("Left");
	}
	return 0;
}

Measured memory_bytes: 128
s = input()
n = len(s)
dp = [[0]*13 for _ in range(n+1)]
dp[n][0] = 1
mod = 10**9+7

s = ''.join(list(reversed(s)))

for i in range(n):
    if s[i] =="?":
        dif = pow(10,i,13)
        for j in range(13):
            for k in range(10):
                dp[i][(j+k*dif)%13] += dp[i-1][j]
                dp[i][(j+k*dif)%13] %=mod
    else:
        dif = (pow(10,i,13)*int(s[i]))%13
        #print(dif,i)
        for j in range(13):
            dp[i][j] = dp[i-1][(j-dif)%13]
            
print(dp[n-1][5])

Measured memory_bytes: 65500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vec ans(2e5+10),dp(2e5+10),a(2e5+10);
ll n;
vector<set<ll>> G(2e5+10);

void dfs(ll f, ll ff,ll R) {
  ll l=0,r=R;
  while(r-l>1) {
    ll m=(r+l)/2;
    if(dp[m]<a[f]) l=m;
    else r=m;
  }
  ll pre=dp[r];
  dp[r]=a[f];
  if(r==R) ans[f]=R++;
  else ans[f]=R-1;
  for(ll t:G[f]) if(t!=ff) dfs(t,f,R);
  dp[r]=pre;
}

int main() {
  cin >> n;
  for(ll i=0;i<n;i++) cin >> a[i];
  for(ll i=0;i<n-1;i++) {
    ll u,v;
    cin >> u >> v;
    u--,v--;
    G[u].insert(v);
    G[v].insert(u);
  }
  for(ll i=1;i<n;i++) dp[i]=inf;
  dfs(0,-1,1);
  for(ll i=0;i<n;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 50500
n=int(input())
cnt=0
for a in range(n//4+1):
            for b in range(n//7+1):
                        if n==4*a+7*b:
                                    #print('a',a,'b',b)
                                    cnt+=1
                                    
                                    
if cnt>=1:
            print('Yes')
else:
            print('No')
            exit()


Measured memory_bytes: 3064
#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;

const int MOD=1000000007;

int dp[4000][7000];
P p[4000];
int a[4000],b[4000];
int main(){
	int n,T;cin>>n>>T;
	rep(i,n)scanf("%d%d",&p[i].first,&p[i].second);
	sort(p,p+n,[](P a,P b){return a.first<b.first;});
	rep(i,n)a[i]=p[i].first,b[i]=p[i].second;
	rep(i,n)rep(j,7000){
		if(j<T){
			dp[i+1][j+a[i]]=max(dp[i+1][j+a[i]],dp[i][j]+b[i]);
		}
		dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
	}
	int Max=0;
	rep(i,7000)Max=max(Max,dp[n][i]);
	cout<<Max<<endl;
}

Measured memory_bytes: 84224
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

d, t, s = map(int, input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 68068
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    string n;
    ll k,dp[101][2][5];//dp[digit][smaller][0,1,2,3,over]
    rep(i,101)rep(j,2)rep(k,5)dp[i][j][k] = 0;
    dp[0][0][0] = 1;

    cin>>n>>k;

    rep(i,n.size()){
        int num = n[i] - '0';
        rep(j,2)rep(d,(j)?10:num + 1)rep(k,4){
            dp[i + 1][j || d < num][k + (d != 0)] += dp[i][j][k];
        }
    }
    
    cout<<dp[n.size()][0][k] + dp[n.size()][1][k]<<endl;

    return 0;
}


Measured memory_bytes: 3596
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long Y = sc.nextLong();

        int power = 0;
        while (X <= Y) {
            Y = Y / 2;
            power++;
        }
        System.out.println(power);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, q; cin >> n >> q;
    vector<tuple<int, int, int>> stx;
    FOR(i, 0, n) {
        int s, t, x; cin >> s >> t >> x;
        stx.emplace_back(s - x, t - x, x);
    }
    VI s(n), t(n), x(n), d(q);
    cin >> d;
    SORT(stx);
    FOR(i, 0, n) {
        s[i] = get<0>(stx[i]);
        t[i] = get<1>(stx[i]);
        x[i] = get<2>(stx[i]);
    }

    map<int, int> m;
    FOR(i, 0, n)m[s[i]], m[t[i]];
    FOR(i, 0, q)m[d[i]];
    auto hoge = m.begin();
    for (int i = 0; hoge != m.end(); ++hoge, ++i)hoge->second = i;

    FOR(i, 0, n) {
        s[i] = m[s[i]];
        t[i] = m[t[i]];
    }
    FOR(i, 0, q)d[i] = m[d[i]];

    PQ<pair<int, int>> que;
    int itr = 0;
    FOR(i, 0, q) {
        while (itr < n && s[itr] <= d[i]) {
            que.emplace(x[itr], t[itr]);
            ++itr;
        }
        while (!que.empty() && que.top().second <= d[i])que.pop();
        if (que.empty())cout << "-1\n";
        else cout << que.top().first << "\n";
    }
}

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

int main() {
    int n;
    cin >> n;
    if (n%2 == 0) {
        cout << n/2 << endl; 
    }
    else {
        cout << n/2 + 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define MAX 1000005
 
int main() 
{   
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	ll a,b;
	string s,t,u;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(u==s)
		cout<<a-1<<" "<<b<<endl;
	else cout<<a<<" "<<b-1<<endl;
 
	return 0;
	}

Measured memory_bytes: 256
n, m, l = map(int, input().split())

A = []
B = []

for i in range(n) :
    A.append([int(a) for a in input().split()])
    
for j in range(m) :
    B.append([int(b) for b in input().split()])

C = []
L = []
s = 0

for i in range(l) :
    for j in range(n) :
        for k in range(m) :
            s += A[j][k] * B[k][i]
        
        L.append(s)
        s = 0
    
    C.append(L[i * n : i * n + n])
        
for i in range(n) :
    for j in range(l) :
        if j == l - 1 :
            print(C[j][i])
        else :
            print(C[j][i], end = " ")
            


Measured memory_bytes: 7096
#include "bits/stdc++.h"
using namespace std;

long long MOD = 1000000007;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

long long GCD(long long A, long long B) {
	return (B == 0 ? A : GCD(B, A % B));
}

int main() {
	long long S, ANS = 0;
	cin >> S;
	long long R = 0, SUM = 0, LD = 0, RD = 0, LM = 1, RM = 1;
	for (int L = 1; L < 100000000; L++) {
		if (L == LM) LD++, LM *= 10;
		while (SUM < S) {
			R++;
			if (R == RM) RD++, RM *= 10;
			SUM += RD;
		}
		if (SUM == S) ANS++;
		SUM -= LD;
	}
	ANS %= MOD;
	for (int i = 1; i * 9 <= S; i++) {
		long long D = S / i;
		if (S % i == 0) {
			ANS += 9 * Calc(10, D - 1) - i + 1 + MOD;
		}
		else {
			ANS++;
		}
	}
	cout << ANS % MOD << endl;
}

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

public class Main {

	static int x;
	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);
		x = in.nextInt();

		for (int i = 1; i <= x; i++) {
			if (i*(i+1)/2 >= x) {
				System.out.println(i);
				return;
			}
		}
	}

}


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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, double> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

// https://ykmaku.hatenablog.com/entry/2019/02/19/171008
int main() {
    ll i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;

    ll use_ijl = [&] {
        ll ijl = min({i, j, l});
        if (ijl == 0) return 0ll;
        ll now = 6 + ((i - 1) / 2) * 4 + ((j - 1) / 2) * 4 + ((l - 1) / 2) * 4;
        return now + (o * 2);
    }();

    ll only_ijl = [&] {
        ll now = (i / 2) * 4 + (j / 2) * 4 + (l / 2) * 4;
        return now + (o * 2);
    }();

    ll ans = max(use_ijl, only_ijl);

    cout << ans / 2 << endl;

}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    _ <- getInt
    as <- getIntList
    putStrLn . solve $ filter even as


solve es | and $ map (\e -> e `mod` 3 == 0 || e `mod` 5 == 0) es = "APPROVED"
         | otherwise = "DENIED"

Measured memory_bytes: 508
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b;
  cin >> a >> b;

  if(a+b > 9) cout << "error" ;
  else cout << a+ b;

  // cout << (a + b > 9 ? "error" : (a + b))

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256