akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define ll long long
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
using namespace std;
const int MAXN=1e5+9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	set<pii> s;
	for(int i=1;i<=m+1;i++)
	{
		int ff=i;
		int ss=m+1-i+1;
		if(ff>ss)
		{
			continue;
		}
		if(ff==ss)
		{
			continue;
		}
		s.insert(mk(ff,ss));
	}
	for(int i=m+2;i<=2*m+1;i++)
	{
		int ff=i;
		int ss=2*m+1-(i-m-2);
		if(ff>ss)
		{
			continue;
		}
		if(ff==ss)
		{
			continue;
		}
		s.insert(mk(ff,ss));
	}
	assert(s.size()>=m);
	int cnt=1;
	for(auto it=s.begin();it!=s.end();it++)
	{
		if(cnt>m)
		{
			break;
		}
		cout<<(it->first)<<" "<<(it->second)<<endl;
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 7856
#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef pair<int,int> P;

int H, W, N;
int y[200005], x[200005];
vector<int> A[200005];

void solve(){
  
  int ans = H;
  
  for(int i=0;i<N;i++) A[x[i]].push_back(y[i]);
  
  int pre = 0;
  
  for(int i=1;i<200005;i++){
    
    if( pre < i ) pre = i;
    
    sort( A[i].begin(), A[i].end() );
    
    int idx = -1;
    
    for(int j=0;j<(int)A[i].size();j++){
      
      if( pre > A[i][j] ){
	idx++;
	continue;
      }
      
      if( pre == A[i][j] ){
	idx = j;
	pre++;
      }
      else break;
      
    }
    
    if( idx + 1 < (int)A[i].size() ) ans = min( ans, A[i][idx+1] - 1 );

    pre++;
    
  }
  
  cout<<ans<<endl;
  
}

signed main(){
  
  cin>>H>>W>>N;
  
  for(int i=0;i<N;i++) cin>>y[i]>>x[i];
  
  solve();
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string po[3];
  int id[3]={};
  REP(i,3)cin>>po[i];
  int cur = 0;
  while(true){
    if(po[cur].size()==id[cur])break;
    cur = po[cur][id[cur]++]-'a';
  }
  printf("%c\n",cur+'A');
  return 0;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 173
//B
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    map<string, int> cnt;
    REP(i, n) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    cout << "AC x " << cnt["AC"] << endl;
    cout << "WA x " << cnt["WA"] << endl;
    cout << "TLE x " << cnt["TLE"] << endl;
    cout << "RE x " << cnt["RE"] << endl;
    return 0;
}


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

Measured memory_bytes: 26216
#include<bits/stdc++.h>
using namespace std;
template <typename T> inline void read(T &s)
{
	s = 0;char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) s = ((s+(s<<2))<<1)+ch-'0',ch = getchar();
}
int T;
long long n,A,B,C,D;
map <long long,long long> mp;
priority_queue < pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>> >Q;
inline long long Div2(long long x)
{
	if(x/2 > 1000000000) return A;
	return min(x/2*D,A);
}
inline long long Div3(long long x)
{
	if(x/3 > 1000000000) return B;
	return min(x/3*2*D,B);
}
inline long long Div5(long long x)
{
	if(x/5 > 1000000000) return C;
	return min(x/5*4*D,C);
}
inline void push(pair<long long,long long> A)
{
	if(A.second != n && (!mp[A.second] || mp[A.second] > A.first)) mp[A.second] = A.first,Q.push(A);
}
int main()
{
	// freopen("1.out","w",stdout);
	read(T);
	while(T--)
	{
		read(n),read(A),read(B),read(C),read(D),mp.clear();
		while(!Q.empty()) Q.pop();
		Q.push(make_pair(0ll,n)),mp[n] = 0;
		while(!Q.empty())
		{
			long long x = Q.top().first,y = Q.top().second;Q.pop();
			// cout << "mp[" << y << "]" << x << endl;
			if(y == 0) {printf("%lld\n",x);break;}
			push(make_pair(x+Div2(y-y%2)+(y%2) * D,y/2));
			if(y%2 == 1) push(make_pair(x+Div2(y+1)+D,y/2+1));
			if(y%3 <= 1) push(make_pair(x+Div3(y-y%3)+(y%3) * D,y/3));
			else push(make_pair(x+Div3(y+1)+D,y/3+1));
			if(y%5 <= 2) push(make_pair(x+Div5(y-y%5)+(y%5) * D,y/5));
			else push(make_pair(x+Div5(y+(5-y%5))+(5-(y%5)) * D,y/5+1));
			while(!Q.empty() && mp[Q.top().second] != Q.top().first) Q.pop();
		}
	}
}


Measured memory_bytes: 4424
#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);
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	FOR(i,0,tx-sx)cout<<'R';
	FOR(i,0,ty-sy)cout<<'U';
	FOR(i,0,tx-sx)cout<<'L';
	FOR(i,0,ty-sy+1)cout<<'D';
	FOR(i,0,tx-sx+1)cout<<'R';
	FOR(i,0,ty-sy+1)cout<<'U';
	cout<<"LU";
	FOR(i,0,tx-sx+1)cout<<'L';
	FOR(i,0,ty-sy+1)cout<<'D';
	cout<<"R"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  string S;
  cin >> S;
  if ((S.length() >= 4) && (S[0] == 'Y') && (S[1] == 'A') && (S[2] == 'K') && (S[3] == 'I')){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
#define INF	1e9
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
vector <int> a[MAXN];
int l[MAXN], r[MAXN], depth[MAXN];
bool halted;
void dfs(int pos, int fa) {
	depth[pos] = depth[fa] + 1;
	l[pos] = -INF; r[pos] = INF;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) dfs(a[pos][i], pos);
}
void update(int x, int y) {
	l[x] = max(l[x], l[y] - 1);
	r[x] = min(r[x], r[y] + 1);
	if (l[x] > r[x]) halted = true;
}
void work(int pos, int fa) {
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) {
			work(a[pos][i], pos);
			update(pos, a[pos][i]);
		}
}
void getans(int pos, int fa) {
	r[pos] = l[pos];
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) {
			update(a[pos][i], pos);
			getans(a[pos][i], pos);
		}
}
int main() {
	int n; read(n);
	for (int i = 1; i < n; i++) {
		int x, y;
		read(x), read(y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	dfs(1, 0);
	int k; read(k);
	bool mark;
	for (int i = 1; i <= k; i++) {
		int x, y;
		read(x), read(y);
		l[x] = r[x] = y;
		if (i == 1) mark = depth[x] % 2 ^ y % 2;
		else if ((depth[x] % 2 ^ y % 2 ) != mark) halted = true;
	}
	if (halted) {
		printf("No\n");
		return 0;
	}
	work(1, 0);
	if (halted) {
		printf("No\n");
		return 0;
	}
	getans(1, 0);
	printf("Yes\n");
	for (int i = 1; i <= n; i++)
		printf("%d\n", l[i]);
	return 0;
}

Measured memory_bytes: 13824
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws Exception{
    	int a,b;
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String line = br.readLine();
        String[] rArray = line.split(" ");
        a = Integer.parseInt(rArray[0]);
        b = Integer.parseInt(rArray[1]);

        System.out.println(a*b + " " +(a+b)*2);
    }
}

Measured memory_bytes: 24192
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
import heapq
n=int(input())
A=list(map(int,input().split()))
idx={}
for i,a in enumerate(A):
    idx[a]=i
hq=[]
right=[n-1]*n
for i in range(n):
    while hq and -hq[0]>A[i]:
        h=-heapq.heappop(hq)
        right[idx[h]]=i-1
    heapq.heappush(hq,-A[i])
hq=[]
left=[0]*n
for i in range(n-1,-1,-1):
    while hq and -hq[0]>A[i]:
        h=-heapq.heappop(hq)
        left[idx[h]]=i+1
    heapq.heappush(hq,-A[i])
ans=0
for i in range(n):
    ans+=A[i]*(i-left[i]+1)*(right[i]-i+1)
print(ans)

Measured memory_bytes: 46956
import scala.io.{StdIn => in}
import java.lang.{Character => char}

object Main extends App {
  val Array(n, k) = in.readLine.split(" ").map(_.toInt)
  val s = in.readLine
  val ans = s.take(k-1) + char.toLowerCase(s(k-1)) + s.drop(k)
  println(ans)
}

Measured memory_bytes: 27328
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string a,b;
	cin >> a >> b;
	string ab, ba;
	REP(i,stoi(b)) ab += a;
	REP(i,stoi(a)) ba += b;
	
	cout << (ab < ba ? ab : ba) << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  int H[100000];
  int min = 1000000010;
  int max = 0;
  bool flg = true;

  cin >> N;
  int index = N-1;
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (int i = N-1; i >= 0; i--) {
    if (min > H[i]) {
      min = H[i];
      max = min;
      index = i;
    }
    if (max < H[i] && index > i) {
      max = H[i];
      if (max-min > 1) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 640
H, W = map(int, input().split())
A = [input() for _ in range(H)]

t = ""
for i in range(W + 2):
    t += "#"
t += "\n"

res = ""

res += t

for a in A:
    res += "#{0}#\n".format(a)

res += t

print(res, end="")

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int ans;
int main() {
    scanf("%s",s);
    int n=strlen(s);
    for (int i=0;i<n-1;i++) {
        if (s[i]!=s[i+1]) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    long A[] = new long[N+1];
    for(int i=0; i<N+1; i++) A[i] = sc.nextInt();
    long B[] = new long[N];
    for(int i=0; i<N; i++) B[i] = sc.nextInt();
    long ans = 0;
    long tmp = 0;
    for(int i=0; i<N; i++){
      tmp += B[i];
      ans += Math.min(tmp, A[i]);
      tmp = Math.max(0, Math.min(tmp - A[i], B[i]) );
    }
    ans += Math.min(tmp, A[N]);
    out.println(ans);
  }
}

Measured memory_bytes: 25288
K, A, B = map(int, input().split())
ans = 0
if B>A+1:
  if K>=A+1:
    ans += B
    K -= A+1
    k = K//2
    ans += (B-A)*k
    ans += K%2
  else:
    ans = K+1
    
  
else:
  ans = K+1

print(ans)    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

map<string,int>mp;


int n;
string s;

int main()
{
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll K; cin >> K;
    if(K%2==0){
        cout << -1 << endl;
        return 0;
    }
    if(K%5==0){
        cout << -1 << endl;
        return 0;
    }
    ll out=0;
    ll tmp=7;
    for(ll i=1;i<=1000000;i++){
        //cerr << i << "\t" << tmp << endl;
        if(tmp%K==0){
            out = i;
            break;
        }
        tmp += (modpow(10,i,K)*7)%K;
    }
    cout << out << endl;
    return 0;
}


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

int main () {
  int N, K; cin >> N >> K;
  
  int64_t ans =0;
  for (int i=1; i<=N; i++) {
    ans = K*pow((K-1),(N-1));
  }
  cout << ans  << endl;
}
  

Measured memory_bytes: 256
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import copy
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)


def main():
    N = I()
    c = [1] * (N + 1)
    
    for i in range(2, N + 1):
        k = i
        while k <= N:
            c[k] += 1
            k += i

    ans = sum(i * c for (i, c) in enumerate(c))
    print(ans)
main()


Measured memory_bytes: 146920
#include<iostream>
#include<stdio.h>
using namespace std;


int main(){
    
    while(1){
        int h, w;
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i=0; i<h; i++){
            if(i==0||i==h-1){
                for(int j=0; j<w; j++){
                    cout << "#";
                } 
            }else{
                for(int j=0; j<w; j++){
                    if(j==0||j==w-1){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                } 
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;

typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define REP(i,l,r) for(int i=l;i>=r;i--)
#define fi first
#define se second
#define eb emplace_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define int ll
const int mod = 1e9+7 ;

int n,m,a,b;
int fft[200007], fft_sz = 1;
int fact(const int& n){
	for(;n > fft_sz; ++fft_sz) fft[fft_sz+1] = (fft[fft_sz]*(fft_sz+1)) % mod;
	return fft[n];
}
int mul (const int& a, const int& b){
	return a * b %mod;
}
int mi(const int& a, const int& b){
	int ans = (a-b) % mod;
	return (ans < 0 ? ans + mod : ans);
}
int binpow(int a, int b){
	int res = 1;
	while(b){
		if (b & 1) res = mul(res,a);
		a = mul(a,a), b >>= 1;
	}
	return res;
}
int divide(const int& a, const int& b){
	assert(b > 0);
	return mul(a,binpow(b,mod-2)); 
}
int c(const int& a, const int& b){
	assert(b >= a);
	return divide(fact(b), mul(fact(a), fact(b-a)));
}
int path0(const int& n, const int& m){
	return c(n-1, n+m-2);
}
int path(const int& r, const int& c, const int& row, const int& col){
	return path0(row-r+1, col-c+1);
}

signed main() {
	fastio ;
	fft[0] = fft[1] = 1LL;
	cin >> n >> m >> a >> b;
	int ans = path0(n,m);
	for(int i = 0, r = n, c = b; i < a; ++i, --r){
		ans = mi(ans, mul(path(1,1 ,r,c), path(r,c+1, n,m)));
	}
	cout << (ans % mod) << endl;
}



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

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;


char alp[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M',
         'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

int ind;
string S;

string dfs(){
  string ret = "";
  char c = S[ind];
  if(c == '['){
    ind++;
    string rev = dfs();
    ind++;
    reverse(rev.begin(), rev.end());
    ret += rev;
    ret += dfs();
  }else if(('A'<=S[ind] && S[ind]<='A'+26) || S[ind]=='?'){
    char ac;
    if(S[ind]=='?') ac = 'A';
    else ac = S[ind];
    ret += ac;
    ind++;
    ret += dfs();
  }else if(S[ind] == '+' || S[ind] == '-'){
    int cnt = 0;
    while(S[ind] == '+' || S[ind] == '-'){
      if(S[ind] == '+') cnt++;
      else cnt--;
      ind++;
    }
    if(S[ind]=='?') ret += 'A';
    else  ret += alp[( (S[ind]-'A') + cnt + 26000) % 26];
    ind++;
    ret += dfs();
  }
  return ret;
}

int main() {
  while(1){
    cin>>S;
    if(S==".") break;
    ind = 0;
    cout<<dfs()<<endl;
  }
  return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1e5 + 10;

int n, Q, m;

long long q[N], t[N], s[N];

int find(long long k, int n)
{
	int t = 0;
	for (int i = 19; ~i; --i)
	{
		if (t + (1 << i) > n) continue;
		if (q[t + (1 << i)] <= k) t += 1 << i;
	}
	return t;
}

int main()
{
	gii(n, Q);
	q[++m] = n;
	for (int i = 1; i <= Q; ++i)
	{
		long long x;
		scanf("%lld", &x);
		while (x <= q[m]) --m;
		q[++m] = x;
	}
	t[m] = 1;
	for (int i = m; i; --i)
	{
		long long k = q[i];
		int p = find(k, i - 1);
		while (p)
		{
			t[p] += (k / q[p]) * t[i];
			k %= q[p];
			p = find(k, p - 1);
		}
		s[1] += t[i], s[k + 1] -= t[i];
	}
	long long ans = 0;
	for (int i = 1; i <= n; ++i) ans += s[i], printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4096
n = int(input())
ans = n

for i in range(n//6+1):
    cnt = 0
    k = i
    while k != 0:
        cnt += k % 6
        k = k // 6
    j = (n-i*6) // 9
    k = j
    while k != 0:
        cnt += k % 9
        k = k // 9
    ans = min(ans, cnt+(n-i*6-j*9))

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int n, a, b;
  	scanf("%d %d %d", &n, &a, &b);
  
  	if( (a*n) > b)
      	printf("%d", b);
  	else
      	printf("%d", a*n); 	
  
  	return 0;
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> split(string str, char chr) {
	vector<int> ret; str += chr;
	int q = 0;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == chr) ret.push_back(q), q = 0;
		else q = q * 10 + str[i] - 48;
	}
	return ret;
}
long long days(int y) {
	long long ret = 146097LL * (y / 400);
	for (int i = 0; i < y % 400; i++) {
		ret += ((i == 0 || (i % 4 == 0 && i % 100 != 0)) ? 366 : 365);
	}
	return ret;
}
vector<int> solve(long long z) {
	int l = 0, r = 50000000;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (days(m) > z) r = m;
		else l = m;
	}
	int y = l, m = -1;
	long long w = z - days(y);
	for (int i = 0; i < 12; i++) {
		int e = -1;
		if(i == 1) e = ((y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) ? 29 : 28);
		else if (i == 3 || i == 5 || i == 8 || i == 10) e = 30;
		else e = 31;
		if (w < e) { m = i; break; }
		w -= e;
	}
	return vector<int>({ y, m + 1, (int)(w) + 1 });
}
string s;
int main() {
	while (cin >> s, s != "#") {
		vector<int> v = split(s, '.');
		if (v.size() == 3) {
			long long l = 0, r = 5000000000;
			while (r - l > 1) {
				long long m = (l + r) / 2;
				vector<int> w = solve(m);
				if (w < v) l = m;
				else r = m;
			}
			int ret = (r + 1136777) % 1872000;
			printf("%d.%d.%d.%d.%d\n", ret / 144000, ret % 144000 / 7200, ret % 7200 / 360, ret % 360 / 20, ret % 20);
		}
		else {
			long long w = v[0] * 144000 + v[1] * 7200 + v[2] * 360 + v[3] * 20 + v[4];
			vector<int> ret = solve(w + 735223);
			printf("%d.%d.%d\n", ret[0], ret[1], ret[2]);
		}
	}
}

Measured memory_bytes: 3248
N = int(input())

c = []
for i in range(10 * 10):
    c.append(0)

for i in range(N):
    s = str(i + 1)
    a = int(s[0])
    b = int(s[-1])
    c[a * 10 + b] += 1

cc = 0
for i in range(10):
    for j in range(10):
        cc += c[i * 10 + j] * c[j * 10 + i]

print(cc)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    if (n >= 30) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3640
from functools import reduce
from fractions import gcd
from collections import defaultdict
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        S = input()[:-1]
        d[S] += 1
    
    print("AC x " + str(d["AC"]))
    print("WA x " + str(d["WA"]))
    print("TLE x " + str(d["TLE"]))
    print("RE x " + str(d["RE"]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 73100
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int a[n];
    int s=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    sort(a,a+n, greater<int>());
    int val = s/(4*m) + (s%(4*m)!=0);
    int ans = 0;
    for(int i=0;i<n;i++){
        if(a[i]<val) break;
        ans++;
    }
    if(ans>=m) cout<<"Yes";
    else cout<<"No";
	return 0;
}


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

int main() {
	int n;
	long t=1, a=1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int ti, ai;
		int temp;
		cin >> ti >> ai;
		temp = t % ti;
		if (temp != 0) {
			t += ti - temp;
		}
		temp = a % ai;
		if (temp != 0) {
			a += ai - temp;
		}
		if (t / ti * ai >= a) {
			a = t / ti * ai;
		}
		else {
			t = a / ai * ti;
		}
	}
	cout << t + a;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    /*
     * 整数 -> nextInt() (遅い場合は下のni())
     * 単語 -> next()
     * 1行 -> nextLine()
     * 注意 : nextLIneをnext(),nextInt()のあとに呼び出す場合、次が改行だと改行だけ取ってしまうので注意
     */
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int ans = Integer.MAX_VALUE;
        for(int a=1;a<N;a++){
            int b = N - a;

            int c = sum(a) + sum(b);
            ans = Math.min(ans,c);
        }
        System.out.println(ans);
    }

    public static int sum(int x){
        int ret = 0;
        while(x>0){
            ret += x%10;
            x /= 10;
        }
        return ret;
    }
}


Measured memory_bytes: 22100
import bisect

n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Acum = [A[0]] + [0]*(n-1)
Bcum = [B[0]] + [0]*(m-1)
for i in range(1,n):
    Acum[i] = Acum[i-1] + A[i]
for i in range(1,m):
    Bcum[i] = Bcum[i-1] + B[i]
maxn = 0
Bcum = [0] + Bcum
for i in range(m+1):
    if Bcum[i] <= k:
        maxn = max(maxn,i + bisect.bisect_right(Acum, k-Bcum[i]))
print(maxn)

Measured memory_bytes: 48884
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数群
int N, M;
vector<int> vec;
int ans = 0;
vector<pair<int,int>> ab;

bool joint(int a,int b) {
	if (a > b) {
		int tmp = a;
		a = b;
		b = tmp;
	}

	rep(i, M) {
		if (ab[i].first == a && ab[i].second == b) {
			return true;
		}
	}
	return false;
}

int judge() {

	bool flag = true;
	rep(i, N - 1) {
		if (!joint(vec[i], vec[i + 1])) flag = false;
	}

	if (flag) {
		//cout << "true" << endl;
		return 1;
	}
	else {
		//cout << "false" << endl;
		return 0;
	}
}

//解法
void solve(int num) {

	//値を繰り返し、前に出ていた値なら次へ
	rep(i, N) {

		bool flag = true;
		rep(j, num) {
			if (vec[j] == i) flag = false;;
		}
		if (!flag) continue;

		vec[num] = i;

		if (num == N - 1) {
			rep(i, N) {
				//cout << vec[i] << "->";
			}
			ans+=judge();
		}
		else {
			solve(num + 1);
		}

	}

}

int main() {
	//入力
	cin >> N >> M;
	vec.resize(N);
	ab.resize(M);
	rep(i, M) {
		cin >> ab[i].first >> ab[i].second;
		ab[i].first--;
		ab[i].second--;
	}
	vec[0] = 0;
	solve(1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=2e5+50;

int n,top;
char a[N],s[N];

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	scanf("%s",s+1); 	
	n=strlen(s+1); 
	rep(i,1,n){
		if(top&&a[top]=='S'&&s[i]=='T')--top;
		else a[++top]=s[i];
	}
	printf("%d\n",top);
	return 0;
}

Measured memory_bytes: 640
/**
*    created: 24.06.2020 13:39:27
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    int t = n / k;
    int s = n / (k / 2);
    if (k % 2 == 1) cout << t * t * t << endl;
    else cout << t * t * t + (s-t)*(s-t)*(s-t) << endl;
    return 0;
}

Measured memory_bytes: 3664
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <time.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

int main(){
	int h,w,n;
	cin >> h >> w >> n;
	cout << (n+max(h,w)-1)/max(h,w) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstdio> 
#include<algorithm>
using namespace std;

typedef struct node{
	int a[30];
}node;

node no;
node sa[5];
queue<node> q1;

void sas(node no);

int main(){
	int i,j,k;
	int a,b,c;
	int n,m;
	int s=0;
	int s1[35];
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<30;j++){
			cin>>no.a[j];
		}
		q1.push(no);
		int ii=-1;
		while(!q1.empty()){
			ii++;
			int js=q1.size();
			for(j=0;j<js;j++){
				no=q1.front();
				q1.pop();
				int ss1=0;
				for(k=1;k<9;k++){
					if(no.a[k]==no.a[0])ss1++;
				}
				if(no.a[9]==no.a[10] && no.a[9]==no.a[11])ss1++;
				if(no.a[12]==no.a[13] && no.a[12]==no.a[14])ss1++;
				if(ss1==10){
					s=1;
					break;
				}
				sas(no);
			}
			if(s==1){
				s=ii;
				break;
			}
		}
		s1[i]=s;
		s=0;
		while(!q1.empty()){
			q1.pop();
		}
	}
	for(i=0;i<n;i++){
		cout<<s1[i]<<endl;
	}
	return 0;
	
}
void sas(node no){
	node noi;
	noi=no;
	swap(noi.a[0],noi.a[23]);
	swap(noi.a[3],noi.a[26]);
	swap(noi.a[6],noi.a[29]);
	swap(noi.a[9],noi.a[20]);
	swap(noi.a[15],noi.a[17]);
	q1.push(noi);
	noi=no;
	swap(noi.a[6],noi.a[21]);
	swap(noi.a[7],noi.a[22]);
	swap(noi.a[8],noi.a[23]);
	swap(noi.a[12],noi.a[17]);
	swap(noi.a[9],noi.a[11]);
	q1.push(noi);
	noi=no;
	swap(noi.a[2],noi.a[21]);
	swap(noi.a[5],noi.a[24]);
	swap(noi.a[8],noi.a[27]);
	swap(noi.a[11],noi.a[18]);
	swap(noi.a[12],noi.a[14]);
	q1.push(noi);
	noi=no;
	swap(noi.a[0],noi.a[27]);
	swap(noi.a[1],noi.a[28]);
	swap(noi.a[2],noi.a[29]);
	swap(noi.a[14],noi.a[15]);
	swap(noi.a[18],noi.a[20]);
	q1.push(noi);
}
		

Measured memory_bytes: 10832
ab = [[int(x) for x in input().split()][::-1] for _ in range(int(input()))]
ab.sort()
ab.reverse()
d = 10000000000
for b,a in ab:
    b = min(b,d)
    d = b-a
if d < 0:
    print('No')    
else:
    print('Yes')    

Measured memory_bytes: 37728
#include <cstdio>
#define min(a, b) (a>b?b:a)
int main() {
	long long a, b, c;
	scanf("%lld%lld%lld\n", &a, &b, &c);
	if(a%2&&b%2&&c%2) {
		printf("%lld", min(min(a*b, b*c), a*c));
	}
	else puts("0");
}


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: i64 = read();
    let b: i64 = read();
    let mut x: Vec<i64> = vec![];
    for _ in 0..n {
        let xi = read();
        x.push(xi);
    }
    let mut ans = 0;
    
    for i in 1..n {
        let dist = x[i] - x[i-1];
        if a * dist < b {
            ans += a * dist;
        } else {
            ans += b;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
# define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	int a[5];
	for(int i=0;i<5;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		cout<<i+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3604
/*
2725 ??´??¨?????? 1_2 A
*/
import java.util.Scanner;

    public class Main{
        public void solve(){
        Scanner sc = new Scanner(System.in);
        int a,b,c;
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		if(a<b && b<c){
			System.out.println("Yes");
			}else{
				System.out.println("No");
			}
        }
    public static void main(String[]args){
    Main obj = new Main();
    obj.solve();
    }
    }

Measured memory_bytes: 17160
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;
const ll INF = 1e16;
int n, k;
ll h[MAXN];

void solve() {
  sort(h, h + n);
  ll ans = INF;
  for (int i=0;i+k-1<n;i++) {
    ans = min(ans, h[i+k-1] - h[i]);
  }
  cout << ans << endl;
}

int main() {
  cin >> n >> k;
  for (int i=0;i<n;i++) {
    cin >> h[i];
  }
  solve();
}


Measured memory_bytes: 1024
# region header
import sys
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos, pi, e
from operator import itemgetter
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
S = Counter(rs())
if list(S.values()) == [2, 2]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63596
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int k=0;
    for(int i=0;i<n;i++){
      while((a[i]&1)==0){
        a[i]/=2;
        k++;
      }
    }
    System.out.println(k);
  }
}

Measured memory_bytes: 36388
#include<bits/stdc++.h>
#define par pair<int,int>
#define fi first
#define se second
using namespace std;
const int _=305,yl=1e9+7;
int f[_][_][_],n,m,ans;
vector<par>e[_];
int inc(int &x,int y){x+=y;if(x>=yl)x-=yl;}
int main(){
	cin>>n>>m;
	while(m--){
		int l,r,x;cin>>l>>r>>x;
		e[r].push_back(par(l,x));
	}
	f[1][0][0]=3;
	for(int i=1;i<=n;++i)
		for(int j=0;j<i;++j)
			for(int k=j;k<i;++k){
				for(par x:e[i]){
					if(x.se==1&&k>=x.fi)f[i][j][k]=0;
					if(x.se==2&&(k<x.fi||j>=x.fi))f[i][j][k]=0;
					if(x.se==3&&j<x.fi)f[i][j][k]=0;
				}
				if(i==n)inc(ans,f[i][j][k]);
				inc(f[i+1][j][k],f[i][j][k]);
				inc(f[i+1][j][i],f[i][j][k]);
				inc(f[i+1][k][i],f[i][j][k]);
			}
	cout<<ans<<endl;
}


Measured memory_bytes: 108800
A = int(input())

if A<10:
    kotae=A
elif 10<=A<100:
    kotae=9
elif 100<=A<1000:
    kotae=A-90
elif 1000<=A<10000:
    kotae=909
elif 10000<=A<100000:
    kotae=A-9090
elif A==100000:
    kotae=90909
print(kotae)

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

int main(){
  int a,b,sum,ans;
  cin >> a >> b;
  sum = 0; ans = 0;
  for(int i = 0;i < b-a;i++){
    sum += i+1;
  }
  ans = sum - b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = k; i <= n+1; i++) {
        int mx = n*i - (i-1)*i/2;
        int mn = (i-1)*i/2;
        ans += (mx-mn+1)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),K = sc.nextInt(); 
		long[][] NK = new long[N][6]; 
		int[] dp = new int[N]; 
		for(int i = 0; i < N; i++) dp[i] = 0;
		for(int i = 0; i < K; i++){
			int scan = sc.nextInt();
			dp[scan-1] = sc.nextInt();
		} 
		for(int i = 0; i < N; i++){
			if(dp[i] == 1){
				if(i == 0)NK[i][1] = 1;
				else{
					NK[i][0] += NK[i-1][1];
					NK[i][1] += NK[i-1][2] + NK[i-1][3] + NK[i-1][4] + NK[i-1][5];
				}
			}
			else if(dp[i] == 2){
				if(i == 0)NK[i][3] = 1;
				else{
					NK[i][2] += NK[i-1][3] % 10000;
					NK[i][3] += (NK[i-1][0] + NK[i-1][1] + NK[i-1][4] + NK[i-1][5]) % 10000;
				}
			}
			else if(dp[i] == 3){
				if(i == 0)NK[i][5] = 1;
				else{
					NK[i][4] += (NK[i-1][5]) % 10000;
					NK[i][5] += (NK[i-1][0] + NK[i-1][1] + NK[i-1][2] + NK[i-1][3]) % 10000;
				}
			}
			else{
				if(i == 0){
					NK[i][1] = 1;NK[i][3] = 1;NK[i][5] = 1;
				}else{
					if(NK[i-1][1] > 0){
						NK[i][0] += NK[i-1][1] % 10000;
						NK[i][3] += (NK[i-1][0] + NK[i-1][1]) % 10000;
						NK[i][5] += (NK[i-1][0] + NK[i-1][1]) % 10000;
					}else{
						NK[i][3] += (NK[i-1][0] + NK[i-1][1]) % 10000;
						NK[i][5] += (NK[i-1][0] + NK[i-1][1]) % 10000;
					}
					if(NK[i-1][3] > 0){
						NK[i][1] += (NK[i-1][2] + NK[i-1][3]) % 10000;
						NK[i][2] += NK[i-1][3] % 10000;
						NK[i][5] += (NK[i-1][2] + NK[i-1][3]) % 10000;
					}else{
						NK[i][1] += (NK[i-1][2] + NK[i-1][3]) % 10000;
						NK[i][5] += (NK[i-1][2] + NK[i-1][3]) % 10000;
					}
					if(NK[i-1][5] > 0){
						NK[i][1] += (NK[i-1][4] + NK[i-1][5]) % 10000;
						NK[i][3] += (NK[i-1][4] + NK[i-1][5]) % 10000;
						NK[i][4] += NK[i-1][5] % 10000;
					}else{
						NK[i][1] += (NK[i-1][4] + NK[i-1][5]) % 10000;
						NK[i][3] += (NK[i-1][4] + NK[i-1][5]) % 10000;
					}
				}
			}
		}
		int total = 0;
		for(int j = 0; j < 6; j++){
			total += NK[N-1][j]; 
		}
		System.out.println(total % 10000);
	}

}

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

int const INF = 1e9;
int const MAX_N = 2505;

vector<int> G[MAX_N];
vector<int> rG[MAX_N];
bool ok[MAX_N];
bool rok[MAX_N];
bool use[MAX_N];

void dfs(int v) {
    if(ok[v]) return;
    ok[v] = true;
    for(int nv : G[v]) {
        dfs(nv);
    }
}

void rdfs(int v) {
    if(rok[v]) return;
    rok[v] = true;
    for(int nv : rG[v]) {
        rdfs(nv);
    }
}

bool bellman_ford(vector<tuple<int,int,int>> &Es, int V, int s, vector<ll> &dist) {
    dist.resize(V,INF);
    dist[s] = 0;
    int cnt = 0;
    while(cnt < V) {
        bool end = true;
        for(auto e : Es) {
            int a,b,c;
            tie(a,b,c) = e;
            if(!use[a]) continue;
            if(!use[b]) continue;
            if(dist[a] != INF && dist[b] > dist[a] + c) {
                dist[b] = dist[a] + c;
                end = false;
            };
        }
        if(end) break;
        cnt++;
    }
    return (cnt == V);
}

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

    vector<tuple<int,int,int>> edges;
    rep(i,m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--; c -= p; c *= -1;
        edges.emplace_back(a,b,c);
        G[a].push_back(b);
        rG[b].push_back(a);
    }

    dfs(0); rdfs(n-1);
    rep(i,n) use[i] = ok[i] & rok[i];

    vector<ll> dist;
    if(bellman_ford(edges, n, 0, dist)) cout << -1 << endl;
    else cout << max(0LL,-dist[n-1]) << endl;
    return 0;
}

Measured memory_bytes: 4000
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int a, b;
	cin >> a >> b;

	string ret;
	if((a*b)%2 == 0)
		ret = "Even";
	else
		ret = "Odd";

	cout <<  ret << endl;

	return 0;
}


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

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        String S=gs();
        
        int min=Integer.MAX_VALUE;
        
        for(int i=0; i<S.length()-2;i++) {
        	int a = Integer.parseInt(S.substring(i, i+3));
        	if (Math.abs(753-a)<min) {
        		min=Math.abs(753-a);
        	}
        }
	    System.out.println(min);
	    
//        if (min==Integer.MAX_VALUE) {
//        	System.out.println("TLE");
//        }else {
//        	System.out.println(min);
//        }
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

#define INF 1000000009
#define fi first
#define se second

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  
  ll n,k;
  ll a[100009];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  
  ll x=0,y=0;
  for(int i=0;i<n-k+1;i++){
    y+=a[i]*COM(n-i-1,k-1)%mod;
    x+=a[n-i-1]*COM(n-i-1,k-1)%mod;
  }

  cout<<(x-y)%mod<<endl;
  return(0);
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long A, long long B, long long K){
  int a = 0, b = 0;
  a = (K - A > 0 ? 0 : A - K);
  K = max((ll)0, K - A);

  b = (K - B > 0 ? 0 : B - K);
  K = max((ll)0, K - B);

  cout << a << ' '  << b << endl;
}

signed main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long K;
  scanf("%lld",&K);
  solve(A, B, K);
}


Measured memory_bytes: 256