akhauriyash/Code-Regression huggingface dataset:
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define INF 999999999
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


ll H;

void input(){
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> H;
}

map<ll,ll> dp_b;

ll dp(ll H){
  if(dp_b[H]) return dp_b[H];
  else if(H==1) return dp_b[H]=1;
  else return dp_b[H]=1+2*dp(H/2);
}

int solve(){
  input();
  ll ans = dp(H);
  cout << ans << endl;
  return 0;
}

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


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
use rand::Rng;
//use std::collections::HashSet;
use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
        D:usize,
        C:[i64;26],
        S:[[i64;26];D]
    }
    let mut ans = 0;
    let mut rng = rand::thread_rng();
    let mut T = vec![0; D];
    let mut Tmax = vec![0; D];
    let mut cnt = 0;
    loop {
        for i in 0..D {
            T[i] = rng.gen::<usize>() % 26;
        }
        let mut last = vec![vec![0i64; 26]; D];
        for d in 0..D {
            let i = T[d];
            last[d][i] = d as i64 + 1;
            for e in d + 1..D {
                if T[e] != i {
                    last[e][i] = d as i64 + 1;
                } else {
                    break;
                }
            }
        }
        let mut x = 0;
        for d in 0..D {
            let i = T[d];
            x += S[d][i];
            //println!("ss{}", x);
            for j in 0..26 {
                x -= C[j] * (d as i64 + 1 - last[d][j]);
                //println!("C[{}]={} -> {}", j, C[j], x);
            }
        }
        if ans < x {
            for k in 0..D {
                ans = x;
                Tmax[k] = T[k];
            }
        }
        if cnt > 100 {
            break;
        }
        cnt += 1;
    }
    for i in 0..D {
        println!("{}", Tmax[i] + 1);
    }
}


Measured memory_bytes: 2824
use std::io;
 
fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}
 
macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}
 
fn divisor(l: i32, u: i32, n: i32) -> i32 {
    let mut count = 0;
    for i in l..u+1 {
        if n % i == 0 {
            count += 1;
        }
    }
    count
}
 
fn main() {
    from_line!(a: i32, b: i32, c: i32);
 
    println!("{}", divisor(a, b, c));
}


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

int main()
{
	int n, count = 0, sum = 1;
	static int ans[100][9] = { 0 };
	int data[100] = { 0 }, ansdata[100] = {0};
	for (int a = 0; a <= 10; a++) {
		data[a+1] = sum;
		sum = sum * 2;
	}
	while (cin >> n) {
		int data2, count2 = 0;
		for (int a = 0; a <= 10; a++) {
			if (n < data[a + 1]) {
				sum = data[a];
				data2 = a;
				ans[count][count2] = a;
				count2++;
				break;
			}
		}
		for (int a = data2-1; a > 0; a--) {
			sum = sum + data[a];
			if (sum > n) {
				sum = sum - data[a];
			}
			else {
				ans[count][count2] = a;
				count2++;
			}
			if (sum == n) {
				break;
			}
		}
		ansdata[count] = count2;
		count++;
	}
	for (int a = 0; a < count; a++) {
		for (int b = ansdata[a]-1; b>=0; b--) {
			cout << data[ans[a][b]];
			if (b != 0)
				cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};
using modint = ModInt< int(1e9)+7 >;

// powのll番
modint pow(modint a,modint b) {
    modint k = 1;
    REP(_,b.x) k*=a;
    return k;
}

void solve() {
    int N,K;
    cin >>N >> K;

    modint  ans;
    vector<modint > v(K+1,0);
    REPR(i,K) {
        if (i == 0) break;
        modint  d (K/i);
        v[i] =  d.pow(N);
        auto ni = i * 2;
        while ( ni <= K) {
            v[i] -= v[ni];
            ni += i;
        }
        modint m;
        m =   v[i] * i;
        ans += m;
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 3788
# フェルマーの小定理
N, K = map(int, input().split())

m = 1000000007


def make_factorial_table(n):
    result = [0] * (n + 1)
    result[0] = 1
    for i in range(1, n + 1):
        result[i] = result[i - 1] * i % m
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


n = max(K, N - K + 1)
fac = make_factorial_table(n)

result = []
for i in range(1, K + 1):
    result.append(mcomb(K - 1, i - 1) * mcomb(N - K + 1, i) % m)
#print('\n'.join(str(i) for i in result))
print(*result, sep='\n')


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    int ans = 2e9;
    rep(i,n-k+1){
        ans = min(ans,(h[i+k-1]-h[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
n=int(input())
a=list(map(int, input().split()))
count=0 
def h(L):
  for i in range(len(L)):
    if L[i] % 2 != 0:
      return(1)
  return(0)
while h(a) == 0:
  for j in range(n):
    a[j]=a[j]/2
  count=count+1
  
print(count)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int H, W, i,n;
	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)break;
		for (i = 0; i < H; i++)
		{
			for (n = 0; n < W-1; n++)
			{
				printf("#");
			}
			printf("#\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1016
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<iostream> 
#include<map> 
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	long long ans=1;
	for(int i=1;i<=n;i++)
	{
		ans=ans*i;
		ans=ans%1000000007;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s == "SUN") cout << 7 << endl;
	else if (s == "MON") cout << 6 << endl;
	else if (s == "TUE") cout << 5 << endl;
	else if (s == "WED") cout << 4 << endl;
	else if (s == "THU") cout << 3 << endl;
	else if (s == "FRI") cout << 2 << endl;
	else if (s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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

    int left = 0, right = 1000000;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        left = max(left, l);
        right = min(right, r);
    }
    int ans = max(0, right - left + 1);
    cout << ans << endl;
}


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

class Increase {
public:
  int n, flowMax = 1000000;
  vector<vector<int>> p;
  vector<int> parent;

  Increase(int n, vector<vector<int>> p) : n(n), p(p) { parent.resize(n); }

  int dfs(int id, int from, int flow) {
    if (parent[id] != id)
      return 0;
    parent[id] = from;
    if (id == n - 1)
      return flow;
    for (int i = 0; i < n; i++)
      if (p[id][i] > 0) {
        int next = dfs(i, id, min(flow, p[id][i]));
        if (next > 0)
          return next;
      }
    return 0;
  }

  int solve() {
    int ret = 0, flow;
    for (int i = 0; i < n; i++)
      parent[i] = i;

    while ((flow = dfs(0, -1, flowMax)) > 0) {
      int now = n - 1;
      ret += flow;
      while (parent[now] >= 0) {
        p[parent[now]][now] -= flow;
        p[now][parent[now]] += flow;
        now = parent[now];
      }
      for (int i = 0; i < n; i++)
        parent[i] = i;
    }
    return ret;
  }
};

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0)
      break;
    vector<int> b(n), r(m);
    for (int i = 0; i < n; i++)
      cin >> b[i];
    for (int i = 0; i < m; i++)
      cin >> r[i];
    int s = 0, t = n + m + 1;

    vector<vector<int>> p(n + m + 2, vector<int>(n + m + 2));
    for (int i = 0; i < n; i++)
      p[s][i + 1] = 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (__gcd(b[i], r[j]) > 1)
          p[i + 1][n + 1 + j] = 1;
    for (int i = 0; i < m; i++)
      p[n + 1 + i][t] = 1;
    Increase sol(n + m + 2, p);
    cout << sol.solve() << endl;
  }
}


Measured memory_bytes: 14804
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N,M; cin >> N >> M;
    vector<int> s(M),c(M);
    rep(i,M){
        cin >> s[i] >> c[i];
        s[i]--;
    }
    rep(i,1000){
        string t = to_string(i);
        if(t.size() != N) continue;
        bool ok = true;
        rep(j,M){
            if(t[s[j]] != c[j]+'0') ok = false;
        }
        if(ok){
            cout << t << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

    



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(int i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;
#define endl "\n"





int main() 
{ 
    
   ll n;
   sfl(n);

   ll ans=0;
   fo(i,1,n+1)
   {
	   fo(j,1,n+1)
	   {
	   	fo(k,1,n+1)
	   	{
	   		int val=__gcd(i,j);
	   		ans+=__gcd(val,k);
	   	}
	   }
   }

   pfln(ans);
   
    return(0);
}

Measured memory_bytes: 3784
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	string S;
	cin >> S;
	int len = S.size();
	for (int i = 0; i < len; ++i) {
		if (S[i] == '1') {
			S[i] = '9';
		}
		else {
			S[i] = '1';
		}
	}
	cout << S << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100010
#define INF 2140000000
#define MOD 1000000007

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

	vector<int> a(n);

	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	vector<pair<int, int> > v(m);

	for (int i = 0; i < m; ++i) {
		cin >> v[i].second >> v[i].first;
	}

	sort(v.rbegin(), v.rend());
	sort(a.begin(), a.end());

	int k = 0;

	for (int i = 0; i < (int) v.size(); ++i) {
		int s = v[i].second, val = v[i].first;

		while (k < (int) a.size() && a[k] < val && s--) {
			a[k] = val;
			k++;
		}
	}

	long long ans = 0;

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

	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 1408
# スペース区切りの整数の入力
A, B = map(int, input().split())

C = 0
if A > B:
  C = A
  A -= 1
else:
  C = B
  B -= 1
  
if A > B:
  C += A
else:
  C += B 


# 出力
print("{}".format(C))

Measured memory_bytes: 2940
n,x,y= map(int,input().split(' '))
arr=[0 for i in range(n)]

for i in range(1,n+1):
    for j in range(i+1,n+1):
        dist= j-i
        alt_dist= abs(x-i)+1+abs(y-j)
        if alt_dist<dist:
            dist=alt_dist
        arr[dist]+=1
for a in arr[1:]:
    print(a)

Measured memory_bytes: 3444
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)>sum(B):
    ans='No'
else:
    l=sum(B)-sum(A)
    cnt_a=l*2
    cnt_b=l
    for i in range(n):
        if A[i]>B[i]:
                cnt_b-=(A[i]-B[i])
        else:
            if (B[i]-A[i])%2==0:
                cnt_a-=(B[i]-A[i])
            else:
                cnt_a-=(B[i]-A[i])+1
                cnt_b-=1
    if cnt_a==cnt_b and cnt_a>=0:
        ans='Yes'
    else:
        ans='No'
print(ans)

Measured memory_bytes: 4596
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j, k;

  //input
  
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 1; i < n+1; i++) scanf("%d",&A[i]);

  //countingsort

  k = VMAX;

  for(i = 0; i < k+1; i++) C[i] = 0;

  for(j = 1; j < n+1; j++) C[A[j]]++;

  for(i = 1; i < k+1; i++) C[i] = C[i] + C[i-1];
  
  for(j = n; j > 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  //output
  
  for(i = 1; i < n; i++) printf("%d ",B[i]);
  printf("%d\n",B[i]);

  free(A);
  free(B);
  
  return 0;
}




Measured memory_bytes: 9204
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, A, B) = Slice3<long>();
            var sum = 0L;
            for (var i = 1; i <= N; ++i)
            {
                var t = i.ToString().Select(s => s - '0').Sum();
                if (A <= t && t <= B)
                    sum += i;
            }
            WriteLine(sum);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 29364
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = input()
a = n.split("/")

if int(a[0]) <= 2019 and int(a[1]) <= 4 and int(a[2]) <= 30:
    print("Heisei")
else:
    print("TBD")




Measured memory_bytes: 6864
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

void binary(int n, int roop, int *arr){
  rep(i, roop){
    if(n != 0){
      arr[i] = n%2;
      n/=2;
    }
    else
      arr[i] = 0;
  }
}


int main(){
  int N, M, X;
  cin >> N >> M >> X;
  int A[N][M];
  int C[N];
  rep(i, N){
    cin >> C[i];
    rep(j, M)
      cin >> A[i][j];
  }
  //

  int min = 1000000000;
  int bit[N];
  rep(i, pow(2, N) ){
    binary(i, N, bit);
    
    int alg[M];
    rep(j, M)
      alg[j] = 0;
    
    int money = 0;
    //本を買うかどうか
    rep(j, N){
      if(bit[j] == 1){
	money += C[j];
	rep(k, M)
	  alg[k] += A[j][k];
      }
    }

    bool flag = true;
    rep(j, M){
      if(alg[j] < X){
	flag = false;
	break;
      }
    }
    
    if(flag && money < min)
      min = money;
  }


  if(min == 1000000000)
    cout << -1 << endl;
  else
    cout << min << endl;

  
  
  return 0;
}


Measured memory_bytes: 4064
from collections import deque

s = input()
c = int(input())

que = deque(s)

flipped = False
for i in range(c):
    query = input()
    
    if query[0] == '1':
        flipped = not flipped
    
    else:
        t, f, c = query.split()
        if (f == '1') ^ flipped:
            que.appendleft(c)
        
        else:
            que.append(c)



ans = ''.join(que)

if flipped:
    ans = ans[::-1]

print(ans)


Measured memory_bytes: 8684
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    vector<vector<int>> c(4, vector<int>(4, 0));
    rep(i, 3) rep(j, 3) cin >> c.at(i+1).at(j+1);

    int tmp1 = c.at(1).at(1) - c.at(2).at(1);
    int tmp2 = c.at(1).at(2) - c.at(2).at(2);
    int tmp3 = c.at(1).at(1) - c.at(3).at(1);
    int tmp4 = c.at(1).at(3) - c.at(3).at(3);
    int tmp5 = c.at(1).at(3) - c.at(2).at(3);
    int tmp6 = c.at(2).at(2) - c.at(3).at(2);
    int tmp7 = c.at(2).at(1) - c.at(3).at(1);
    int tmp8 = c.at(2).at(3) - c.at(3).at(3);

    dump(tmp1);
    dump(tmp2);
    dump(tmp3);
    dump(tmp4);
    dump(tmp5);
    dump(tmp6);
    dump(tmp7);
    dump(tmp8);

    bool tmp = (tmp1==tmp2) && (tmp3==tmp4) && (tmp6==tmp8) && (tmp2==tmp5) && (tmp5==tmp1) && (tmp7==tmp8);
    if(tmp) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second
#define ld long double 

//CHECK FOR N = 1 OR OTHER DUMB TESTS 

using namespace std;

int n;
ld a[100100];

int main() {
	//ifstream cin("tst.in");
	//ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
		
	sort(a + 1, a + n + 1);
	long double ans = 0;
	ld cnt = 1;
	ld mul = 2.0;
	ans = a[1] + a[2];
	ans /= mul;
	for (int i = 3; i <= n; i++) {
		ans += a[i];
		ans /= mul;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import copy

def main():
    H,W,K = map(int,input().split())
    c = []
    for h in range(H):
        c.append(list(map(str,input())))
    
    ans = 0
    for hh in range(2**H):
        for ww in range(2**W):
            C = copy.deepcopy(c)
            for h in range(H):
                if ((hh >> h)&1):
                    C[h] = ['R' for i in range(W)]
            for w in range(W):
                if ((ww >> w)&1):
                    for i in range(H):
                        C[i][w] = 'R'
            count = 0
            for i in range(H):
                for j in range(W):
                    if C[i][j] == '#':
                        count += 1
            if count == K:
                ans += 1
    
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9356
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 1010


int main() {
	char a[N + 1][N+1];
	f(i, N + 1) {
		f(j,N+1)a[i][j] = 0;
	}
	queue<pair<pair<int, int> ,int> >q;
	int n,m;
	int x, y, z;
	int ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n, &m);
	f(i,n)scanf("%s", a[i]);
	f(i, n) {
		f(j, m) {
			if (a[i][j] == '#') {
				q.push(make_pair(make_pair(i, j), 0));
				ans++;
			}
		}
}
	ans = 0;
	while (!q.empty()) {
		x = q.front().first.first;
		y = q.front().first.second;
		z = q.front().second;
		if (x > 0) {
			if (a[x - 1][y] == '.') {
				q.push(make_pair(make_pair(x-1, y), z+1));
				ans = z + 1;
				a[x - 1][y] = '#';
			}
		}
		if (x < (n - 1)) {
			if (a[x + 1][y] == '.') {
				q.push(make_pair(make_pair(x + 1, y), z + 1));
				ans = z + 1;
				a[x + 1][y] = '#';
			}
		}
		if (y > 0) {
			if (a[x][y-1] == '.') {
				q.push(make_pair(make_pair(x, y - 1), z + 1));
				ans = z + 1;
				a[x][y - 1] = '#';
			}
		}
		if (y < (m - 1)) {
			if (a[x][y + 1] == '.') {
				q.push(make_pair(make_pair(x, y + 1), z + 1));
				ans = z + 1;
				a[x][y + 1] = '#';
			}
		}
q.pop();
	}

	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 13328
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

bool solve() {
	int n; cin >> n;
	int a[n]; REP (i,n) cin >> a[i];
	int sum = 0;
	map<int,int> ma;
	REP (i,n) {
		int p = a[i]; sum ^= p;
		int cnt = 0;
		while (!(p & 1)) {
			cnt++;
			p/=2;
		}
		ma[cnt]++;
	}
	vi sm;
	while (sum != 0) {
		sm.pb(sum%2);
		sum /= 2;
	}
	// DEBUG(sm);
	int tmp = 0;
	int ans = 0;
	// for (auto&& a : ma) cout << a.second << " "; cout << endl;
	for (int i = sm.size()-1;i >= 0;i--) {
		if (sm[i]^tmp) {
			if (ma.find(i) != ma.end()) ma[i]--;
			else {
				cout << -1 << endl;
				return 0;
			}
			ans++;
			tmp++; tmp%=2;
		}
	}
	cout << ans << endl;
}

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


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

static const int LEN = 500000;
static const int SENTINEL = 2000000000;
int cnt = 0;
int L[LEN/2+1], R[LEN/2+1];

void merge(int A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i != n1; ++i)
    {
        L[i] = A[left + i];
    }

    for (int i = 0; i != n2; ++i)
    {
        R[i] = A[mid + i];
    }

    L[n1] = SENTINEL;
    R[n2] = SENTINEL;

    int i = 0;
    int j = 0;

    for (int k = left; k != right; ++k)
    {
        ++cnt;

        if (L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main()
{
    int A[LEN];
    int n;

    scanf("%d", &n);

    for (int i = 0; i != n; ++i)
    {
       scanf("%d", &A[i]);
    }

    mergeSort(A, 0, n);

    for (int i = 0; i != n; ++i)
    {
       if (i != 0)
       {
           printf(" ");
       }

       printf("%d", A[i]);
    }

    printf("\n");
    printf("%d\n", cnt);

    return 0;
}


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

int main(){
    
    int K,N;
    
    //　標準入力を行わせる
    cin>>K>>N;

    // 配列の設定
    int i;

    //　各身長の入力とその格納
    int cnt;
    for (i = 0; i < K;i++){
        int b;
        cin>>b; 
        if(N <= b)cnt++;

    
    }

    cout<<cnt<<endl; 

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  string s,a;
  cout<<n-1<<endl;
  cin>>a;
  if(a[0]=='V')return 0;
  int r=-1,m,l=n;
  while(l-r>0){
    m=(r+l)/2;
    cout<<m<<endl;
    cin>>s;
    if(s[0]=='V')break;
    if(s[0]==a[0]){
      if((m-r)%2)l=m;
      else {
	r=m;
	a[0]=s[0];
      }
    }else{
      if((m-r)%2){
	a[0]=s[0];
	r=m;
      }else l=m;
    }
  }
  if(s[0]!='V'){
    cout<<r<<endl;
    cin>>s;
    if(s[0]!='V')cout<<l<<endl;
  }
  return 0;
}


Measured memory_bytes: 852
X = int(input())
A = -1
while True:
    A += 1
    if (A ** 5 - X) >= 0:
        temp_num = ((A ** 5 - X) ** (1/5)) // 1
        plus_minus = 1
    else:
        temp_num = ((X - A ** 5) ** (1/5)) // 1
        plus_minus = -1
    if A ** 5 -  (plus_minus * temp_num) ** 5 == X:
        B = plus_minus * temp_num
        break
    elif A ** 5 - (plus_minus * (temp_num + 1)) ** 5 == X:
        B = plus_minus * (temp_num + 1)
        break
print(A,int(B))
    
    

Measured memory_bytes: 9392
# 2020/08/22
# AtCoder Beginner Contest 176 - C

# Input
n = int(input())
a = list(map(int,input().split()))
alen = len(a)

# Calc
hmax = 0
fsum = 0
for i in range(alen):
    if hmax < a[i]:
        hmax = a[i]
    fsum = fsum + (hmax - a[i])

# Output
print(fsum)


Measured memory_bytes: 32392
O=input()
E=input()

if len(O)==len(E)+1:
    E+=" "
    ans=""
    for o, e in zip(O, E):
        ans+=o
        ans+=e
    print(ans[:-1])
else:
    ans=""
    for o, e in zip(O, E):
        ans+=o
        ans+=e
    print(ans)

    

Measured memory_bytes: 2940
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (s, w) = (v[0], v[1]);
    if w >= s {
        println!("unsafe");
    } else {
        println!("safe");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>k>>a>>b;
  if(a%k==0 || b%k==0)
  {
    cout<<"OK";
    return 0;
  }
  if((b/k )-(a/k)>=1)
  {
    cout<<"OK";
    return 0;
  }
  else cout<<"NG";
}

Measured memory_bytes: 3648
n=int(input())
a=list(map(int, input().split()))
buf,ans=0,0
for i in range(n):
    if a[i]%2==0 and (a[i]%5==0 or a[i]%3==0):
        ans+=1
    if a[i]%2==0:
        buf+=1
if ans==buf:
    print('APPROVED')
else:
    print('DENIED')

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

int main()
{
    int a, b, sum = 0;
    cin >> a >> b;
    int ara[b];
    for(int i = 0 ; i < b ; i++) cin >> ara[i];
    for(int i = 0 ; i < b ; i++){
        sum += ara[i];
    }
    if(sum >= a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;





	return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

struct UnionFind {
    vector<int> ig;
    vector<vector<int>> gi;
    int gn;
    UnionFind(int N) {
        ig.resize(N); gi.resize(N);
        for (int i = 0; i < N; i++) {
            ig[i] = i; gi[i] = {i};
        }
        gn = N;
    }
    void merge(int a, int b) {
        if (same(a, b)) return;
        gn--;
        int x = ig[a], y = ig[b];
        if (gi[x].size() < gi[y].size()) swap(x, y);
        for (int j: gi[y]) {
            ig[j] = x;
        }
        gi[x].insert(gi[x].end(), gi[y].begin(), gi[y].end());
        gi[y].clear();
    }
    bool same(int a, int b) {
        return ig[a] == ig[b];
    }
};


const int MN = 200100;
int n;
ll a[MN], as[MN];

ll calc(ll x) {
    ll mi = as[n-1]-x;
    for (int i = n-2; i >= 2; i--) {
        mi = min(mi, 2*as[i]-mi);
    }
    return a[0]-mi+as[1];
}

int main() {
    ios::sync_with_stdio(0);
    cout << setprecision(20);

    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> a[i];
    }
    as[0] = 0;
    for (int i = 0; i < n-1; i++) {
        as[i+1] = as[i]+a[i];
    }

    map<int, int> mp;
    int m;
    cin >> m;
    UnionFind uf(m);
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        int y = as[n-1]-x;
        if (mp.count(y)) {
            uf.merge(i, mp[y]);
        } else {
            mp[y] = i;
        }
    }

    for (int i = n-2; i >= 2; i--) {
        while (true) {
            assert(mp.size());
            auto it = mp.end(); it--;
            auto p = *it;
            if (p.first <= as[i]) break;
            int np = 2*as[i]-p.first;
            mp.erase(it);
            if (mp.count(np)) {
//                cout << "M " << p.second << " " << mp[np] << endl;
                uf.merge(p.second, mp[np]);
            } else {
                mp[np] = p.second;
            }
        }
    }

    int res[MN];
    for (auto p: mp) {
//        cout << p.first << " " << p.second << endl;
        for (int d: uf.gi[uf.ig[p.second]]) {
            res[d] = a[0] - p.first + as[1];
        }
    }

    for (int i = 0; i < m; i++) {
        cout << res[i] << endl;
    }
/*    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        cout << calc(x) << endl;
    }*/
    return 0;
}


Measured memory_bytes: 27232
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

void dfs(int s, int cnt, VVI &es, VI &d, vector<bool> &visited)
{
    d[s] = cnt;
    visited[s] = true;
    for (auto &&dst : es[s])
    {
        if (visited[dst])
            continue;
        dfs(dst, cnt + 1, es, d, visited);
    }
}

void solve()
{
    int n;
    cin >> n;
    VVI es(n);
    int a, b;
    REP(i, 0, n - 1)
    {
        cin >> a >> b;
        es[a - 1].push_back(b - 1);
        es[b - 1].push_back(a - 1);
    }
    VVI d(2, VI(n));
    vector<vector<bool>> visited(2, vector<bool>(n));
    dfs(0, 0, es, d[0], visited[0]);
    dfs(n - 1, 0, es, d[1], visited[1]);
    int cnt = 0;
    REP(i, 0, n)
    cnt += (d[0][i] <= d[1][i]);

    if (cnt * 2 <= n)
        cout << "Snuke" << endl;
    else
        cout << "Fennec" << endl;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 12792
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

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

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

ll euq(ll a, ll b) {return b ? euq(b, a%b) : a;}

int main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N);
    vector<ll> dist(N);
    rep(i, N) {
        cin >> x[i];
        dist[i] = abs(X-x[i]);
    }

    ll res = 0;
    rep(i, N) {
        res = euq(res, dist[i]);
    }

    cout << res << endl;
    return 0;
   

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#define ll long long
#define rg register
using namespace std;

inline int read(){
	int sum=0,f=1;char c=getchar();
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0'){sum=sum*10+c-'0';c=getchar();}
	return f*sum;
}

const int N=500005;
const int Mod=1000000007;
int n,m,p[N],tot;
int s[N],jc[N]={1};
int inv[N];

inline ll C(int m,int n){
	return 1ll*jc[n]*inv[m]%Mod*inv[n-m]%Mod;
}

inline ll fpow(int a,int b){
	ll ret=1;
	for(;b;a=1ll*a*a%Mod,b>>=1) if(b&1) ret=1ll*ret*a%Mod;
	return ret;
}
	
signed main(){
//	freopen("test.in","r",stdin);
	n=read();m=read();
	for(int i=1;i<N;i++) jc[i]=1ll*jc[i-1]*i%Mod;
	for(int i=0;i<N;i++) inv[i]=fpow(jc[i],Mod-2);
	for(int i=2;i*i<=m;i++){
		if(m%i) continue;
		p[++tot]=i;
		while(m%i==0) m/=i,s[tot]++;
	}
	if(m>1) p[++tot]=m,s[tot]++;
	ll ans=1;
	for(int i=1;i<=tot;i++){
		ans=1ll*ans*C(n-1,n-1+s[i])%Mod;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<double> p(n);
	rep(i,n) cin >> p[i];
	
	vector<vector<double>> dp(n+1, vector<double>(n+1));
	dp[1][0] = 1 - p[0];
	dp[1][1] = p[0];
	
	for(int i = 1; i < n; i++){
		rep(j,n+1){
			if(j-1 >= 0){
				dp[i+1][j] = dp[i][j] * (1-p[i]) + dp[i][j-1] * p[i];
			}
			else{
				dp[i+1][j] = dp[i][j] * (1-p[i]);
			}
		}
	}
	
	double res = 0;
	rep(j,n+1){
		if(j >= n/2 + 1) res += dp[n][j];
	}
	
	printf("%.10f", res);
	return 0;
}

Measured memory_bytes: 70656
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int divisors=0;
	while(1){
		divisors=0;
		for(int i=2;i*i<=n;i++){
			if(n%i==0){
				divisors+=1;
			}
		}
		if(divisors==0){
			printf("%d",n);
			return 0;
		}
		n++;
	}
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

vector<ll> factors(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i ++) if(n % i == 0) ret.push_back(i), ret.push_back(n/i);
    Sort(ret);
    Unique(ret);
    return ret;
}

int main(void){
    Cin(ll, n);
    vector<ll> ans;
    {
        auto f = factors(n);
        for(ll x : f){
            if(x == 1) continue;
            ll n1 = n;
            while(n1 % x == 0) n1 /= x;
            if(n1 % x == 1) ans.push_back(x);
        }
    }
    {
        auto f = factors(n-1);
        for(ll x : f){
            if(n % x == 1) ans.push_back(x);
        }
    }
    
    Cout(ans.size());
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, K, x[55], y[55];
long long ans = 1e18 * 4;
int main() {
	cin >> n >> K;
	rep(i, n)cin >> x[i] >> y[i];
	rep(i, n) {
		rep(j, n) {
			rep(k, n) {
				rep(l, n) {
					int cnt = 0;
					rep(m, n)if (min(x[i], x[j]) <= x[m] && max(x[i], x[j]) >= x[m] && min(y[k], y[l]) <= y[m] && max(y[k], y[l]) >= y[m])cnt++;
					if (cnt >= K)ans = min(ans, (long long)abs(x[i] - x[j])*abs(y[k] - y[l]));
				}
			}
		}
	}
	cout << ans << endl;
	getchar();getchar();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
	char a[100005];
	int x=0,y=0,s=0;
	scanf("%s",&a);
	for(int i=0;i<strlen(a);i++){
		if(x==y){
			x++;
			if(a[i]=='p')
			s--;
		} 
    	else{
			y++;
			if(a[i]=='g')
			s++;
		} 
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mp make_pair
#define ft first
#define sd second
#define ue printf("what?\n");
#define pb push_back
#define oo 0x3F3F3F3F	
#define OO 3000000000000000000LL
#define EPS 0
#define maxn 200000
#define pi acos(-1)
#define mod 1000000007
#define mdc __gcd
#define N 100010
#define M 20
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

int v[N];

main()
{
	int n, k, i, ans, le, ri;
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++)
		scanf("%d", &v[i]);
	ans = oo;
	for(i=0; i<n-k+1; i++)
	{
		le = v[i], ri = v[i + k - 1];
		if(ri < 0) ans = min(ans, -le);
		else if(le > 0) ans = min(ans, ri);
		else ans = min(ans, min(ri + (ri - le), -le + (ri - le)));
		
	}
	printf("%d\n", ans);
}
		


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int a,b=-1,c=1001,d;
  scanf("%d",&a);
  for(int i=0; i<a; i++){
    scanf("%d",&d);
    if(b<d){b=d;}
    if(d<c){c=d;}
  }
  printf("%d",b-c);
  return 0;}

Measured memory_bytes: 128
#include <stdio.h>
int a;
int b;
char op;


main(){
		while(1){
		scanf("%d %c %d",&a,&op,&b);
		
		if(op == '+'){
			printf("%d\n",a+b);
		}else if(op == '-'){
			printf("%d\n",a-b);
		}else if(op == '*'){
			printf("%d\n",a*b);
		}else if(op == '/'){
			printf("%d\n",a/b);
		}else{
			break;
		}
		}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int X;
    cin >> X;
    int mx = 1;
    for (int i = 2; i * i <= X; i++) {
        int k = i * i;
        for (; k <= X; k *= i) {
            mx = max(mx, k);
        }
    }
    cout << mx << '\n';
}


Measured memory_bytes: 3588