akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc153/tasks/abc153_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, A;
    cin >> H >> A;
    cout << DIV(H, A) << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> a(n);
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    ll sum = 0;
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            sum+=a[i]*a[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const char WALL = '#';

int main(){
    ll h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;

    vector<string> s(h);
    REP(i, h){ cin >> s.at(i); }

    vector<vector<ll>> dist(h, vector<ll>(w, numeric_limits<ll>::max()));
    reverse_priority_queue<array<ll, 3>> que;
    dist.at(ch).at(cw) = 0;
    que.push({0, ch, cw});
    while(!que.empty()){
        const auto arr = que.top(); que.pop();
        const ll d = arr.at(0);
        const ll i = arr.at(1);
        const ll j = arr.at(2);
        if(dist.at(i).at(j) < d){ continue; }

        const ll di[] = {-1, 1, 0, 0};
        const ll dj[] = {0, 0, -1, 1};
        REP(k, 4){
            const ll ni = i + di[k];
            const ll nj = j + dj[k];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w || s.at(ni).at(nj) == WALL){
                continue;
            }
            if(dist.at(ni).at(nj) > d){
                dist.at(ni).at(nj) = d;
                que.push({d, ni, nj});
            }
        }

        for(ll ni = i - 2; ni <= i + 2; ++ni){
            for(ll nj = j - 2; nj <= j + 2; ++nj){
                if(ni < 0 || ni >= h || nj < 0 || nj >= w || s.at(ni).at(nj) == WALL){
                        continue;
                }
                if(dist.at(ni).at(nj) > d + 1){
                    dist.at(ni).at(nj) = d + 1;
                    que.push({d + 1, ni, nj});
                }
            }
        }
    }
    if(dist.at(dh).at(dw) == numeric_limits<ll>::max()){
        cout << -1 << endl;
    }else{
        cout << dist.at(dh).at(dw) << endl;
    }
    return 0;
}


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


def solve(N: int, M: int, V: int, P: int, A: "List[int]"):

    A.sort(reverse=True)

    I = N

    for i in range(P, N):
        if A[P-1] > A[i] + M:
            I = i
            break

    l = P-1
    r = I
    m = (l + r)//2

    while l + 1 != r:

        k = (V-P)*M - M*(N-I)
        for i in range(P-1, I):
            if i == m:
                continue
            k -= min(A[m] + M -A[i], M)
            if k <= 0:
                l = m
                m = (l+r)//2
                break
        if k > 0:
            r = m
            m = (l+r)//2

    print(l+1)







    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, V, P, A)

if __name__ == '__main__':
    main()


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);
const int MAX_K = 105;
const int SQ = 112345;
ll dp[MAX_K][SQ];
ll ac[MAX_K][SQ];

int main2() {
  CLR(dp, 0);
  CLR(ac, 0);
  int N = nextInt();
  int K = nextInt();

  vector<int> v;
  v.push_back(0);
  for (int i = 1; i <= N; i++) {
    v.push_back(i);
    if (i < N/i) {
      v.push_back(N/i);
    } else break;
  }
  sort(ALL(v));

  const int M = v.size() - 1;
  for (int j = 1; j <= M; j++) {
    dp[1][j] = v[j]-v[j-1];//在第一位 商是和v[j]的有dp[1][j]个  
    ac[1][j] = (ac[1][j-1] + dp[1][j]) % MOD;//前缀和 
  }

  for (int i = 2; i <= K; i++) {
    for (int j = 1; j <= M; j++) {
      int op = lower_bound(ALL(v), N/v[j]) - v.begin();//这一位商是N/v[j],那么上一位小于等于N/v[j] 
	  //1 2 3 4 5 8 16 
      dp[i][j] = (v[j]-v[j-1]) * ac[i-1][op] % MOD;
      ac[i][j] = (ac[i][j-1] + dp[i][j]) % MOD;
    }
  }
  ll ans = ac[K][M];
  cout << ans << endl;
  return 0;
}
int main() {
#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 184960
class UnionFind:
    """
    - sizeを指定
    - 要素をグループにまとめる(unite) 
    - 要素同士が同じグループか判定する(isSame)
    - 分離はできない
    - par: 親の番号(はじめ par[i]==i つまりすべての頂点が根)
    - 始め各要素は別々のグループ"""
    def __init__(self, size: int):
        self.par = [-1]*size
        for i in range(size):
            self.par[i] = i 
    
    def root(self, x: int) -> int:
        """根を求める"""
        if self.par[x] == x: # if root
            return x
        else:
            self.par[x] = self.root(self.par[x]) # 経路圧縮
            return self.par[x]
    
    def isSame(self, x:int, y:int)->bool:
        """x と y が同じ集合に属するか否か"""
        return self.root(x)==self.root(y)
    
    def unite(self, x:int, y:int):
        """x と y の属する集合を併合"""
        x = self.root(x)
        y = self.root(y)
        if x == y: return
        self.par[x] = y


H,W = map(int, input().split())
s = [input() for _ in range(H)]
uf = UnionFind(H*W) 

def pos2int(h,w):
    # 座標->[0 - H*W]
    return h*W + w

for h in range(H):
    for w in range(W):        
        for dh, dw in zip((0, 1), (1, 0)):
            if not(0<=h+dh<H and 0<=w+dw<W):
                continue
            if s[h][w] != s[h+dh][w+dw]: # 同じグループにする
                uf.unite(pos2int(h, w), pos2int(h+dh, w+dw))
                
white = [0] * H*W
black = [0] * H*W
 
for h in range(H):
    for w in range(W):
        n = pos2int(h, w)
        r = uf.root(n)
        # print(n, r)
        if s[h][w] == ".":
            white[r] += 1
        else:
            black[r] += 1
# print(white)
# print(black)
ans = 0
for h in range(H):
    for w in range(W):
        n = pos2int(h, w)
        ans += white[n] * black[n]
print(ans)

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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a>9 || b>9) cout<<-1<<endl;
    else cout<<a*b<<endl;
    
    return 0;
}

Measured memory_bytes: 3620
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N, M = invr()
K = []
for i in range(N):

    temp = inlist()
    temp = temp[1:]
    K.append(set(temp))
res = K[0]
for i in range(1, N):
    res = res.intersection(K[i])
print(len(res))


Measured memory_bytes: 3188
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/29
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 100;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int main(int argc, char* argv[]) {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b <= c) puts("0 0");
    else {
        if (c <= a) printf("%lld %lld\n", a - c, b);
        else {
            printf("0 %lld\n", b - c + a);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=20,M=1e9+7;
int n,m,Q,x,y,flag[N+1][N],ne[1<<N][N],g[1<<N],dp[1<<N];
inline void reduce(int &x){if (x>=M)x-=M;}
int main(){
	scanf("%d%d%d",&n,&m,&Q);
	n--;
	while (Q--){
		scanf("%d%d",&x,&y);
		y--;
		scanf("%d",&flag[x][y]);
		flag[x][y]++;
	}
	dp[0]=1;
	for (int i=0;i<1<<n;i++)
		for (int j=n-1;j>=0;j--)
			if (i&(1<<(j+1)))ne[i][j]=1<<(j+1);
			else ne[i][j]=ne[i][j+1];
	for (int i=1;i<=m;i++)
		for (int j=0;j<n;j++){
			for (int k=0;k<1<<n;k++)
				if (flag[i][j]!=2){
					if (!(k&(1<<j)))reduce(g[k]+=dp[k]);
				}
			for (int k=0;k<1<<n;k++)
				if (flag[i][j]!=1){
					if (!(k&(1<<j)))reduce(g[k^(1<<j)^(ne[k][j])]+=dp[k]);
					else reduce(g[k]+=dp[k]);
				}
			for (int k=0;k<1<<n;k++)dp[k]=g[k],g[k]=0;
		}
	int ans=0;
	for (int i=0;i<1<<n;i++)reduce(ans+=dp[i]);
	printf("%d\n",ans);
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    for (int i = 0; i < M; ++i) {
        int num;
        cin >> num;
        sum += num;
    }
    if (sum > N) cout << -1 << endl;
    else cout << N - sum << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#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++)

int main(){
    int n;
    cin >> n;
    int a , b , c , d;
    a = 0;
    b = 0;
    c = 0;
    d = 0;
    string k[n];
    rep(i,n){
        cin >> k[i];
        if(k[i] == "AC")a++;
        else if(k[i] == "WA")b++;
        else if(k[i] == "TLE")c++;
        else d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 6588
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef struct {
	int m[6];
} Dice;

Dice d;
string s;

void roll(char c, Dice *d) {
	switch (c) {
	case 'N':
		swap(d->m[0], d->m[1]);
		swap(d->m[1], d->m[5]);
		swap(d->m[5], d->m[4]);
		break;
	case 'S':
		swap(d->m[0], d->m[4]);
		swap(d->m[4], d->m[5]);
		swap(d->m[5], d->m[1]);
		break;
	case 'E':
		swap(d->m[0], d->m[3]);
		swap(d->m[3], d->m[5]);
		swap(d->m[5], d->m[2]);
		break;
	case 'W':
		swap(d->m[0], d->m[2]);
		swap(d->m[2], d->m[5]);
		swap(d->m[5], d->m[3]);
		break;
	}
}
int main() {
	for (int i = 0; i < 6; i++) cin >> d.m[i];
	cin >> s;
	for (int i = 0; i < s.size(); i++) roll(s[i], &d);
	cout << d.m[0] << endl;
}


Measured memory_bytes: 3140
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

ans = 10**10

for pat in range(4**N):
    a = b = c = 0
    mp = 0
    for i in range(N):
        k = (pat >> (2*i)) & 0b11
        if k == 0:
            pass            
        if k == 1:
            a += l[i]
            mp += 10
        elif k == 2:
            b += l[i]
            mp += 10
        elif k == 3:
            c += l[i]
            mp += 10
    if a != 0 and b != 0 and c != 0:
        mp += -30 + abs(A-a) + abs(B-b) + abs(C-c)
        if mp < ans:
            ans = mp

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var As = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
            var cond = (double)As.Sum() / (double)(NM[1] * 4);
            int count = 0;
            for (int i = 0; i < NM[0]; i++)
            {
                if (As[i] >= cond)
                {
                    count++;
                }
            }
            if (count>=NM[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13396
weather = "S" + input()
candicate = []
ans = 0
for i in range(1, 4):
  if weather[i] == "R":
    if weather[i-1] == "S":
      candicate.append(ans)
      ans = 1
    else:
      ans += 1
candicate.append(ans)
print(max(candicate))

Measured memory_bytes: 9108
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];

  int ans = 0;
  REP(i, N){
    if((K | A[i]) ==  K) ans += B[i];
  }
  REP(i, 32){
    if(!((K >> i)&1)) continue;
    int cur = (((K >> i) & ((K >> i)-1)) << i)+(1 << i)-1;
    int ret = 0;
    REP(i, N){
      if((cur | A[i]) ==  cur) ret += B[i];
    }
    chmax(ans, ret);
  }

  cout << ans << "\n";

  return 0;
}

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

int main(){
    int n; cin>>n;
    int gmax = 1e9;
    int ans;
    for(int i=0; i<=100000; i++){
        vector<int> v;
        int num = i;

        while(num > 0){
            v.emplace_back(num % 10);
            num /= 10;
        }

        int m = v.size();
        bool valid = true;
        for(int j=0; j<m; j++){
            if(v[j] != v[m-1-j]) valid = false;
        }

        if(valid){
            if(abs(n - i) < gmax){
                gmax = abs(n - i);
                ans = i;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n;
	cin >> n;
	map<ll, ll> mp;
	ll sum = 0;
	for(int i = 1; i <= n; i ++)
	{
		ll x;
		cin >> x;
		sum += x;
		mp[x] ++;
	}
	if(!sum)
		return cout << "Yes", 0;
		vector<ll> v;
		set<int> s;
		for(auto it : mp)
		{
			s.insert(it.S);
			v.pb(it.F);
		}		
	if(mp.size() == 3)
	{
		ll x = (v[0] ^ v[1]);
		if(s.size() == 1 && (x == v[2]))
			return cout << "Yes", 0;
	}
	else
	{
		if(v[0] == 0)
		{
			if(mp[v[1]] == mp[v[0]] * 2)
				return cout << "Yes", 0;
		}
		else
		if(v[1] == 0)
		{
			if(mp[v[0]] == mp[v[1]] *2)
				return cout << "Yes", 0;
		}
	}
	cout << "No";




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 6264
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
//using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int kazu[9]={3,6,4,2,5,4,3,2,1};
int go[9][12]={
	{
		10,13,
		11,14,
		12,15,
	},{
		00,23,
		01,40,
		02,41,
		20,42,
		21,43,
		22,44,
	},{
		30,12,
		31,13,
		10,14,
		11,15,
	},{
		20,22,
		21,23,
	},{
		10,15,
		11,50,
		12,51,
		13,52,
		14,53,
	},{
		40,44,
		41,60,
		42,61,
		43,62,
	},{
		50,53,
		51,70,
		52,71,
	},{
		60,62,
		61,80,
	},{
		70,71,
	}
};
void encode(void){
	int n;cin>>n;
	string s;cin>>s;
	s+="111111111";
	int bas=8,num=0;
	cout<<"I";
	for(auto it:s){
		int suu=go[bas][num*2+it-'0'];
		bas=suu/10;num=suu%10;
		cout<<(char)(bas+'A');
	}
}
void decode(void){
	int i,j,m;cin>>m;
	string t;cin>>t;
	int bas=10,num=0;
	string ans;ans.reserve(m);
	for(i=m-1;i>=0;i--){
		if(bas==10&&t[i]=='I'){bas=8;num=0;continue;}
		if(bas==10){continue;}
		int doc=t[i]-'A';
		for(j=0;j<kazu[doc]*2;j++){
			if(go[doc][j]==bas*10+num){
				bas=doc;num=j/2;
				if(i<m-10){ans.pub('0'+j%2);}
				break;
			}
		}
	}
	REV(ans);
	cout<<ans<<endl;
}
int main(void){
	string str;cin>>str;
	if(str=="decode"){decode();}
	else{encode();}
	return 0;
}
/*
IHGFGFEFGFGHIHIH
*/


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

int main(){
  int N;
  cin >> N;
  vector <int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  for(int i=0;i<N-1;i++){
    if(A[i] == A[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    auto calc = [](int x1, int y1, int x2, int y2) { return abs(x1 - x2) + abs(y1 - y2); };
    rep(i, n) {
        int dist = INT_MAX;
        int ans = -1;
        rep(j, m) {
            if (chmin(dist, calc(a[i], b[i], c[j], d[j]))) {
                ans = j+1;
            }
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 3656
import java.util.*;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String a = sc.nextLine();
        String[] ac = a.split("");
        int sum = 0;
        for (int i = 0; i < ac.length; i++) {
            sum = sum + Integer.valueOf(ac[i]);
        }
        BigDecimal b1 = new BigDecimal(a);
        BigDecimal[] r = b1.divideAndRemainder(new BigDecimal(sum));
        if (r[1].compareTo(BigDecimal.ZERO)==0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
def mod_inv(n: int, mod: int)->int:
    b, u, v = mod, 1, 0
    while b > 0:
        t = n // b

        n -= t * b
        u -= t * v

        n, b = b, n
        u, v = v, u

    return (u+mod) % mod


def _11(N: int, A: list)->list:
    MOD = 10**9 + 7

    d = {}
    l, r = 0, 0
    for i, a in enumerate(A):
        if a in d:
            l, r = d[a], N-i
        else:
            d[a] = i

    c1, c2 = [1]*(N+2), [1]*(N+2)
    for i in range(N+1):
        c1[i+1] = (c1[i] * (N+1-i) * mod_inv(i+1, MOD)) % MOD
        c2[i+1] = (c2[i] * (l+r-i) * mod_inv(i+1, MOD)) % MOD

    return [(c1[k+1]-c2[k]+MOD) % MOD for k in range(N+1)]


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = _11(N, A)
    print('\n'.join(map(str, ans)))


Measured memory_bytes: 28728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  while(cin>>a,a){
    string s;
    cin>>s;
    while(a--){
      string ns;
      int t=0;
      s+='a';
      for(int i=0;i<(int)s.size()-1;i++){
	if(s[i]!=s[i+1]){
	  int b=i-t+1;
	  t=i+1;
	  string p;
	  while(b){
	    p+=(char)(b%10+'0');
	    b/=10;
	  }
	  reverse(p.begin(),p.end());
	  ns+=p;
	  ns+=s[i];
	}
      }
      s=ns;
     }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 1340
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int cnt = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i.ToString().Length%2 == 1)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13140
K=int(input())
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[K-1])

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

int n, k ;

int a[200010] ;

vector < int > lis ;

int main(){
	#define NAME "MINCHANGE"
	//freopen( NAME".inp" , "r" , stdin ) ; freopen( NAME".out" , "w" , stdout ) ;

	ios_base :: sync_with_stdio(false) ;

	cin >> n >> k ;

	for (int i = 1; i <= n; ++ i) cin >> a[i] ;

	sort(a + 1, a + n + 1) ;		
				
	int cur = a[1], cnt = 1 ;

	for (int i = 2; i <= n; ++ i){
		if(a[i] != cur){
			lis.push_back(cnt) ;
			cur = a[i] ;
			cnt = 1 ;
		}
		else cnt ++ ;
	}

	lis.push_back(cnt) ;

	sort(lis.begin(), lis.end()) ;

	int ans = 0 ;

	for (int i = 0; i < (int)lis.size() - k; ++ i){
		ans += lis[i] ;
	}

	cout << ans << endl ;

	return 0 ;
}

Measured memory_bytes: 2168
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, X;
	std::vector<int> M;
	std::cin >> N >> X;
	M.resize(N);
	for (auto& m : M) {
		std::cin >> m;
	}
	
	int result = N;
	int rest = X;
	for (auto m : M) {
		rest -= m;
	}
	std::sort(M.begin(), M.end());
	result += rest / M.front();
	std::cout << result << "\n";
}


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

void solve(){
	int v,m;
	while(cin >> v >> m, (v!=0 && m!=0) ){
		int change = m-v;
		
		int th = change/1000;
		change -= th*1000;

		int fifh = change/500;
		change -= fifh*500;

		int ah = change/100;
		
		cout << ah << " " << fifh << " " << th << endl;
	}
	return;
}

int main(void){
	solve();
	int i; cin >> i;
	return 0;
}

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

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

	string s;

	cin >> s;

	for(int i=0;i<s.length();i++)
	{
		if(i%2==0)
		{
			if(s[i]=='L')
			{
				cout << "No" << '\n';
				return 0;
			}
		}
		else
		{
			if(s[i]=='R')
			{
				cout << "No" << '\n';
				return 0;
			}
		}
	}
	cout << "Yes" << '\n';
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second
using ll = long long;
using P = pair<ll ,ll>;
using Tu = tuple<ll, ll, ll>;
const ll INFLL = 1LL<<60LL;
const ll INF = 1LL<<60LL;
const ll MOD = 1e9+7;



using ld = long double;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> a(N);
  vector<ll> b(M);
  for(int i=0;i<N;i++)
    cin >> a[i];
  for(int i=0;i<M;i++)
    cin >> b[i];
  vector<vector<ll>> dp(N+1, vector<ll>(M+1));
  vector<vector<ll>> dp2(N+1, vector<ll>(M+1));
  dp[0][0] = 1;
  for(int i=0;i<=N;i++)
    for(int j=0;j<=M;j++){
      if(i < N){
	dp[i+1][j] += dp[i][j];
	dp[i+1][j] %= MOD;
      }
      if(j < M){
	dp2[i][j+1] += dp[i][j] + dp2[i][j];
	dp2[i][j+1] %= MOD;
      }
      if(i < N && j < M && a[i] == b[j]){
	dp[i+1][j+1] += dp[i][j] + dp2[i][j];
	dp[i+1][j+1] %= MOD;
      }
    }
  cout << (dp[N][M] + dp2[N][M]) % MOD << endl;
  /*for(int y=0;y<=N;y++){
    for(int x=0;x<=M;x++)
      cout << dp[y][x] + dp2[y][x] << " ";
    cout << endl;
    }*/
}


Measured memory_bytes: 62976
using System;

namespace killme
{
    public static class Program
    {
        public static void Main()
        {
            try
            {
                var a = int.Parse(Console.ReadLine());
                var s = Console.ReadLine();
                var ret = a >= 3200 ? s : "red";
                Console.WriteLine(ret);
            }
            finally
            {
                Console.ReadLine();
            }
        }
    }
}


Measured memory_bytes: 11092
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define inf 1000000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    speed
    //global var
    int d,t,s;cin>>d>>t>>s;
    if(d<=t*s){cout<<"Yes\n";}
    else{cout<<"No\n";}
}
//try thinking from a different angle after spending some time


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 55;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

pii pp[MAXN];

set<pii> px, py;

set<pii> st;

int dis[MAXN];

int used[MAXN];

void upd_set(int ind, int new_dis) {
	if (!used[ind] && dis[ind] > new_dis) {
		st.erase(mp(dis[ind], ind));
		dis[ind] = new_dis;
		st.insert(mp(dis[ind], ind));
	}
}

void process_coord(set<pii> &ps, int ind, int coord) {
	set<pii>::iterator it = ps.find(mp(coord, ind));
	set<pii>::iterator it1 = it;
	it1++;
	
	if (it1 != ps.end()) {
		int to = it1->_2;
		upd_set(to, it1->_1 - it->_1);
	}
	
	if (it != ps.begin()) {
		int old_v = it->_1;
		it--;
		int to = it->_2;
		upd_set(to, old_v - it->_1);
	}
	
	ps.erase(mp(coord, ind));
}

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d%d", &pp[i]._1, &pp[i]._2);
		px.insert(mp(pp[i]._1, i));
		py.insert(mp(pp[i]._2, i));
	}
	REP(i, 0, n) {
		if (i > 0) {
			dis[i] = INF;
		}
		st.insert(mp(dis[i], i));
	}
	ll ans = 0ll;
	while(!st.empty()) {
		int ind = st.begin()->_2;
		ans += st.begin()->_1;
		st.erase(st.begin());
		used[ind] = 1;
		
		process_coord(px, ind, pp[ind]._1);
		process_coord(py, ind, pp[ind]._2);
	}
	
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 自分の得意な言語で
		// Let's チャレンジ！！

		Scanner sc = new Scanner(System.in);

		// モンスター体力
		long h = sc.nextLong();

		// 攻撃回数
		long re = 0;
		long deep = 1;

		// 初めの1匹を攻撃
		re = attck(h, re, deep);

		System.out.println(re - 1);

	}

	private static long attck(long h, long re, long deep) {
		if (h == 1) {
			return (long) Math.pow(2, deep);
		}
		deep++;
		return attck(h / 2, (long) Math.pow(2, deep), deep);
	}

}

Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int k = scan.nextInt();
			int x = 0;
			int y = 0;
			int t = 0;
			for(int i = 0;i < k;i++){
				x = scan.nextInt();
				y = scan.nextInt();
				if((x <= y && y <= n-x+1) || (n-x+1 <= y && y <= x)){
					t = (x > n/2)?(n+1-x)%3:x%3;
				}else{
					t = (y > n/2)?(n+1-y)%3:y%3;
				}
				System.out.println((t==0)?3:t);
			}
		}
	}
}

Measured memory_bytes: 25224
import numpy as np


if __name__ == '__main__':
    # input
    N, T = map(int,input().split())
    menu = list()
    for i in range(N):
        menu_i = tuple(map(int,input().split()))
        menu.append(menu_i)
    menu.sort()
    dp = np.zeros(T, int)
    ans = 0
    # print(N,T,menu)

    for ab in menu:
        # print(ab[0],ab[1])
        ans = max(ans, dp[-1]+ab[1])
        dp[ab[0]:] = np.maximum(dp[ab[0]:], dp[:-ab[0]] + ab[1])
    print(ans)


Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, l, sum = 0, mi = 0;
	cin >> n >> l;

	int h = n + l - 1;
	if(h<0) mi = h;
	else if(l>=0) mi = l;
	else mi = 0;

	for(int i=l;i<l+n;i++)
		sum += i;
	cout << sum - mi << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    string s;
    cin >> s;
    int size = s.length();
    int cnt = 0;
    int j = 0;
    for(int i = size-1; i>=size/2 ;--i){
        if(s[j] != s[i]){
            cnt++;
        }
        j++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
int main(void){
  int n,flg=0,cnt=0,a[200];
  int min=100000000;
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    cnt=0;
    if(a[i]%2!=0){
      flg=1;
    }
    while(a[i]%2==0){
      cnt++;
      a[i]/=2;
    }
    if(min>cnt&&cnt>=1){
      min=cnt;
    }
  }
  if(flg==0){
    printf("%d",min);
  }else {
    printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

int INF = 1e15;

signed main() {
    int N, M, R;
    cin >> N >> M >> R;
    vi r(R);
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }
    SORT(r);

    vvi w(N, vi(N, INF));
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        w[a][b]=c;
        w[b][a]=c;
    }

    rep(k, N) rep(i, N) rep(j, N) {
        w[i][j] = min(w[i][j], w[i][k]+w[k][j]);
    }

    int res = INF;
    do {
        int temp = 0;
        FOR(i, 1, R) {
            temp += w[r[i-1]][r[i]];
        }
        res = min(res, temp);
    } while (next_permutation(ALL(r)));
   
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 512
N,M=map(int,input().split())
hope=[tuple([int(i) for i in input().split()]) for j in range(M)]
hope.sort(key=lambda x:x[1])
ans=0
prebroke=0#prebroke=2 :島2と島3を結ぶ橋
for s,g in hope:
    if s<=prebroke:
        continue
    else:
        ans+=1
        prebroke=g-1
print(ans)

Measured memory_bytes: 18204
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#define F first
#define S second
#define qq queue
#define dq deque
#define vc vector
#define INF ((int)(2e9))
#define LINF ((int)(1e18))
// NO "fir0x()"!
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define ll long long
#define B cout << "BreakPoint\n";
#define read(_nowans) scanf("%d",&_nowans)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_nowans1,_nowans2) scanf("%d %d",&_nowans1,&_nowans2)
#define msn(_data,_nowans) memset(_data,_nowans,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define read3(_nowans1,_nowans2,_nowans3) scanf("%d %d %d",&_nowans1,&_nowans2,&_nowans3)
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print( int _x ){ printf("%d\n",_x); }
_tp<_tyn T>void print( T _data[] , int _size ){
	for( int i = 1 ; i <= _size ; i++ )
		cout << _data[i] << " ";
	cout << endl;
}
#define MAXN 200100
#define MOD (1000000007LL)

ll n , m , bann , banm;
ll fact[MAXN];

void init(){
	fact[0] = fact[1] = 1LL;
	for( ll i = 2 ; i <= max( n , m ) * 2 + 2 ; i++ )
		fact[i] = ( fact[i-1] * i ) % MOD;
}

//	(a/b) % p != (a%p) / (b%p)
//	(a/b) % p != (a%p) / (b%p)
//	(a/b) % p != (a%p) / (b%p)
// 重要的事情说三遍

// (a/b) % p = (a*inv(a)) % p = (a%p) * inv(a)%p
// a^(p-1) == 1 (%p)
// a^(p-2) == inv(a) (%p)
// inv(a) = a^(p-2) (%p)

ll qpow( ll a , ll x ){	// a ^ x
	ll ret = 1LL;
	while(x){
		if( x & 1 ){
			ret *= a;
			ret %= MOD;
		}
		a *= a;
		a %= MOD;
		x >>= 1;
	}
	return ret;
}

ll inv( int a ){
	return qpow( a , MOD-2 ) % MOD;
}

//			     k!
//C(r,k) = 	------------	( r <= k )
//		 	 (k-r)!r!

ll rck( ll r , ll k ){
	ll ret = fact[k];
	ret *= inv( fact[r] );
	ret %= MOD;
	ret *= inv( fact[k-r] );
	ret %= MOD;
	return ret;
}

ll getways( ll r , ll k ){
	return rck( r-1 , r+k-2 );
}

ll ans = 0LL;
int main(){
	//n = m = 20;init();while(1){cin >> n >> m;cout << rck( n-1 , n+m-2 ) << endl << endl << endl;}
	//fin( "D.txt" );

	while( cin >> n >> m >> bann >> banm ){
		ans = 0LL;
		init();

		for( ll i = banm + 1 ; i <= m ; i++ ){
			ll nowans = ( getways( i , n-bann ) * getways( m-i+1 , bann ) ) % MOD;
			ans += nowans;
			ans %= MOD;
		}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  if(A==0){
    if(B<100)cout << B << endl;
    else cout << B+1 << endl;
  }else if(A==1){
    if(B<100)cout << B*100 << endl;
    else cout << (B+1)*100 << endl;
  }else{
    if(B<100)cout << B*10000 << endl;
    else cout << (B+1)*10000 << endl;
  }
}

    

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
void digit(int n){
  int res = 0;
  while(n > 0) {
    n /= 10;
    res++;
  }
  for(int i = 0; i < 6 - res; i++){
    cout << 0;
  }
}
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> p(m, vector<int>(4));
  for(int i = 0; i < m; i++) {
    cin >> p[i][1] >> p[i][0];
    p[i][2] = i;
  }
  sort(p.begin(), p.end());
  vector<int> a(n, 0);
  for(int i = 0; i < m; i++) {
    a[p[i][1]]++;
    p[i][3] = a[p[i][1]];
  }
  for(int i = 0; i < m; i++){
    swap(p[i][0], p[i][2]);
  }
  sort(p.begin(), p.end());
  for(int i = 0; i < m; i++){
    digit(p[i][1]);
    cout << p[i][1];
    digit(p[i][3]);
    cout << p[i][3] << '\n';
  }
  return 0;
}

Measured memory_bytes: 7424
e, y = gets.split.map(&:to_i)
case e
    when 0
        case y
        when 1868..1911
            puts "M#{y-1867}"
        when 1912..1925
            puts "T#{y-1911}"
        when 1926..1988
            puts "S#{y-1925}"
        else
            puts "H#{y-1988}"
        end
    when 1
        puts 1867 + y
    when 2
        puts 1911 + y
    when 3
        puts 1925 + y
    when 4
        puts 1988 + y
end


Measured memory_bytes: 6884
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 764
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        (w, h): (usize, usize),
        (x, y): (usize, usize),
    }
    let ans: f64 = w as f64 * h as f64 / 2 as f64;
    let count = if w == x * 2 && h == y * 2 { 1 } else { 0 };
    println!("{:.10} {}", ans, count);
}


Measured memory_bytes: 2196
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

perms = list(permutations([i for i in range(1, N+1)]))

a = perms.index(P) + 1
b = perms.index(Q) + 1

print(abs(a - b))


Measured memory_bytes: 8052
#[allow(dead_code)]
fn main() {
    let x = i::u();
    let c = x / 100;
    println!(
        "{}",
        if x >= c * 100 && x <= c * 105 {
            "1"
        } else {
            "0"
        }
    );
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
n = int(input())
b = list(map(int, input().split()))
max = 0
for i in range(n):
  if (i == 0):
    max += b[i]
  elif (i < n-1):
    if(b[i] < b[i-1]):
      max += b[i]
    else:
      max += b[i-1]
  else:
    max += b[i-1]

print(max)

Measured memory_bytes: 3064
inputs= list(map(int,input().split()))
k = inputs[0]
s = inputs[1]
answer = 0
for i in range(k+1):
  x = i
  for l in range(k+1):
    y = l
    z = s-x-y
    if z >= 0 and z <= k :
      answer += 1
print(answer)

Measured memory_bytes: 3060