akhauriyash/Code-Regression huggingface dataset:
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut M=0;
    let mut m=1000;
    for _ in 0..read::<i32>(){
        let a=read::<i32>();
        if a<m{m=a}
        if a>M{M=a}
    }
    println!("{}",M-m)
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<d.size(); i++) cin >> d.at(i);
  sort(d.begin(),d.end());
  d.erase(unique(d.begin(),d.end()),d.end());
  cout << d.size() << endl;
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

int main() {
    
    get2(n,m);

    vector<ll> A(m);
    vector<vector<ll>> C(m, vector<ll>());

    rep(i,m) {
        get2(a,b);
        A[i]=a;

        rep(j,b) {
            get(c);
            C[i].push_back(--c);
        }
    }
    
    ll val = pow(2,n)+1e-9;
    // cout<<val<<endl;
    vector<vector<ll>> dp(val, vector<ll>(m+1,-1));
    
    rep(i,m+1)
        dp[0][i]=0;

    rep2(i,1,val)
        dp[i][0]=INF;

    std::function<ll(ll,ll)> solve = [&](ll mask, ll idx) {

        // cout<<mask<<" "<<idx<<endl;
        if(idx==-1)
            return INF;

        if(dp[mask][idx]!=-1)
            return dp[mask][idx];

        ll ans = solve(mask, idx-1);
        ll orig = mask;

        for(auto i:C[idx-1])
            if((1<<i)&mask)
                mask = mask ^ (1<<i);

        ans = min(solve(mask, idx-1)+A[idx-1],ans);

        return dp[orig][idx] = ans;
    };

    ll mini = INF;
    for(ll i=1;i<=m;i++) {
        mini = min(solve(val-1,i),mini);
    }

    printf("%lld\n",mini==INF ? -1 : mini);

    return 0;  
}

Measured memory_bytes: 32640
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	bool ans=false;
 	for (int i = 0; i < 2; i++){
 		int x;
 		cin >> x;
 		if(x%2==0){
 			ans=true;
 		}
 	}
 	if(ans){
 		cout << "Even"  << endl;
 	}else{
 		cout << "Odd" << endl;
 	}
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int cnt = 0;
void selectionSort(vector<int>& v) {
	rep(i, 0, v.size()) {
		int minj = i;
		rep(j, i, v.size()) {
			if (v[j] < v[minj]) {
				minj = j;
			}
		}
		swap(v[i], v[minj]);
		if (i != minj)++cnt;
	}
}

int main() {
	init();

	int N;cin >> N;
	vector<int>vec(N);
	rep(i, 0, N)cin >> vec[i];
	selectionSort(vec);
	rep(i, 0, N) {
		cout << vec[i];
		if (i == N - 1)cout << "\n";
		else cout << " ";
	}
	cout << cnt << "\n";

	return 0;
}


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

using namespace std;

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

    int x,a;
    cin>>x>>a;

    if(x>=a)
        cout<<"10";
    else
        cout<<"0";
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split(" ").map((input)=>Number(input));
  if(input[0] + input[1] == 15){
     console.log("+");
     }else if(input[0] * input[1] == 15){
    console.log("*");
  }else{
    console.log("x");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

string s, c, c2;
int ans = 1;

int main()
{
	cin >> s;
	c = s[0];
	for (int i = 1; i < (int)s.size(); i++)
	{
		c2 = s[i];
		if (c == c2 )
		{
			if (i < s.size() - 1)
			{
				ans++, i++;
				c = s[i] + s[i - 1];
			}
		}
		else
		{
			c = s[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int N,A,B;
string S;

int main() {
    cin >> N >> A >> B;
    cin >> S;
    int count_b = 0;
    int past = 0;
    for(int i = 0; i < N; i++) {
        //cout << past << endl;
        if(past < A+B) {
            if(S.at(i) == 'a') {
                cout << "Yes" << endl;
                past++;
            }
            else if(S.at(i) == 'b') {
                count_b++;
                if(count_b <= B) {
                    cout << "Yes" << endl;
                    past++;
                }
                else cout << "No" << endl;
            } else cout << "No" << endl;
        } else cout << "No" << endl;
    }
}


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

using namespace std;

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

    vector<int>v(n+1);
    v[0]=0;

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

    vector<int>dp(k+1);

    for(int j=1;j<=k;j++)
    {
        for(int i=1;i<=n;i++)
        {
           if(j>=v[i]&&dp[j-v[i]]==0)
           {
               dp[j]=true;
           }
        }
    }
  if(dp[k]==1)
    cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;
return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<string.h>

int main(){
    int n0=0,n1=0;
    char c='0';
    while(c=='0' || c=='1'){
        scanf("%c",&c);
        if(c=='0') n0 += 1;
        else if(c=='1') n1 += 1;
    }
    printf("%d",n0>n1? 2*n1:2*n0);
}

Measured memory_bytes: 128
str = input()
num = int(str)
const = len(str)
numbers = len(str)
even = 0
con = 0
a = str[even:const]
b = int(a)
if numbers%2==1:
    pass
else:
    even += 1
    numbers -= 1
    a = str[even:const]
    b = int("9"*(numbers))
while numbers > 0:
    con += (b - 10**(numbers-1) + 1)
    even += 2
    numbers -= 2
    if numbers>0:
        a = str[even:const]
        b = int("9"*(numbers))
print(con)

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

int main(){
    long a,b;
    char op;

    cin >> a >> op >> b;

    if( op == '+'){
        cout << a+b << endl;
        return 0;
    }else if( op == '-' ){
        cout << a-b << endl;
        return 0;
    }

    return 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <cmath>
#define fs first
#define sc second
using namespace std;
const int maxn = 5e5+10;
using pii = pair<int,int>;
typedef long long ll;

set<int> st[26];
char str[maxn];
int N,Q;

int main(){
    cin>>N;
    scanf("%s",str+1);
    for(int i = 1;i<=N;i++) st[str[i]-'a'].insert(i);
    cin>>Q;
    while(Q--){
        int op,a,b;char c;
        scanf("%d",&op);
        if(op == 1){
            scanf("%d %c",&a,&c);
            st[str[a]-'a'].erase(a);
            str[a] = c;
            st[str[a]-'a'].insert(a);
        }else{
            scanf("%d%d",&a,&b);
            int cnt = 0;
            for(int i = 0;i<26;i++){
                auto it = st[i].lower_bound(a);
                if(it == st[i].end() || *it > b) continue;
                cnt+=1;
            }
            printf("%d\n",cnt);
        }
    }


    return 0;
}

Measured memory_bytes: 24192
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;

int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
	else cout << "consonant" << endl;

	return 0;
}


Measured memory_bytes: 256
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,t,y=100000000000,m;
	 	cin>>n;
	 	ll a[n+1];
	 	for(i=1;i<=n;i++)
	 	cin>>a[i];
	 	for(i=1;i<=n;i++)
	 	{
	 		if(i%2!=0&&a[i]%2!=0)
	 		l++;
		 }
		 cout<<l<<endl;
  	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

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

int main(void)
{
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    int answer = 0;
    rep(i, n) {
        vector<int> a(m);
        rep(j, m) cin >> a[j];
        int total = 0;
        rep(j, m) {
            total += a[j] * b[j];
        }
        if (total + c > 0) answer++;
    }
    cout << answer << endl;
 }


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

int main() {
  string S,T;
  cin >> S >> T;
  int mincount=100000;
  int A=T.size();
  int B=S.size();
  for(int i=0;i<B-A+1;i++){
    int count=0;
    string U=S.substr(i,A);
    for(int j=0;j<A;j++){
      if(U.at(j)!=T.at(j)){
        count++;
      }
    }
    mincount=min(mincount,count);
  }
  cout << mincount << endl;
}
    

Measured memory_bytes: 3640
n = int(input())
numbers = list(map(int,input().split()))
alice = []
a = sum(numbers)
numbers.sort()
b = int(n/2)
if n%2 == 0 :
    for i in range(b) :
        alice.append(int(numbers[2*i+1])) 
else :
    for j in range(b+1) :
        alice.append(int(numbers[2*j])) 

x = sum(alice)
y = a - x
print(x - y)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  int N,X;
  cin>>N>>X;
  int ans=1;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  int pos=0;
  for(int i=0;i<N;i++){
    pos+=L[i];
    if(pos>X){
      break;
    }
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, flag = 0, count = 0, p = 0;

  cin >> N;
  

  for(int i = 1;i <= N;i++){
    cin >> p;
    if(p == i && flag == 0){
      count++;
      flag = 1;
    } else {
      flag = 0;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a)-1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a)-1; (i) >= (b); (i)--)
#define PI acos(-1.0)
#define DEBUG(C) cerr << C << endl;
#define VI vector <int>
#define VII vector <VI>
#define VL vector <LL>
#define VLL vector <VL>
#define VD vector <double>
#define VDD vector <VD>
#define PII pair <int, int>
#define PDD pair <double, double>
#define PLL pair <LL, LL>
#define VPII vector <PII>
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a, b) for (auto &&a:b)
#define FIND(s, e) (s.find(e) != s.end())
#define EB emplace_back

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

class TopologicalSort {
private:
    vector <bool> is;
    vector <vector <int>> g;
    vector <int> tsort;
    void dfs(int now) {
        if (is[now]) return;
        is[now] = true;
        for (auto &&el:g[now]) {
            dfs(el);
        }
        tsort.emplace_back(now);
    }
public:
    TopologicalSort() {}
    TopologicalSort(vector <vector <int>> graph) {
        g = graph;
        is.resize(g.size());
    }
    vector <int> sort() {
        for (int i = 0; i < g.size(); i++) {
            dfs(i);
        }
        reverse(tsort.begin(), tsort.end());
        return tsort;
    }
};

int main(void) {
    int V, E;
    VII graph;
    cin >> V >> E;
    graph.resize(V);
    REP(i, E) {
        int a, b;
        scanf("%d%d", &a, &b);
        graph[a].EB(b);
    }
    TopologicalSort ts(graph);
    auto ans = ts.sort();
    FORE(el, ans) cout << el << endl;
}

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define print(n) cout << n << "\n"

int main(){
    ll n,k;
    cin >> n >> k;

    n %= k;
    n = min(n,k-n);
    print(n);

    return 0;
}

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

#define vv vector< vector< int > >
#define ll long long


int main(){
    int n;
    cin >> n;
    vv tree(n);
    for(int i = 0; i < n; ++i){
        int a, k;
        cin >> a >> k;
        a--;
        for(int j = 0; j < k; ++j){
            int b;
            cin >> b;
            b--;
            tree[a].push_back(b);
        }
    }
    vector<int> dist(n, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for (int nv : tree[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    for(int v = 0; v < n; v++) cout << v+1 << " " << dist[v] << endl;
    return 0;
}



Measured memory_bytes: 3156
/* 2017/07/22*/
#include <stdio.h>

int main()
{
  int H, W;
  scanf("%d %d", &H, &W);
  char a[H][W+1];
  for(int i = 0; i < H; i++){
    scanf("%s", a[i]);
  }
  for(int j = 0; j < W + 2; j++){
      printf("#");
  }
  printf("\n"); 
  for(int i = 0; i < H; i++){
    printf("#");
    printf("%s#\n", a[i]);
  }
  for(int j = 0; j < W + 2; j++){
      printf("#");
  }
  return 0;
}


Measured memory_bytes: 128
def resolve():
    N = int(input())
    dp = [[0] * 3 for _ in range(N)]
    table = [list(map(int, input().split())) for _ in range(N)]

    dp[0][0] = table[0][0] # a0
    dp[0][1] = table[0][1] # b0
    dp[0][2] = table[0][2] # c0

    for i in range(1, N):
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + table[i][0]
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + table[i][1]
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + table[i][2]

    res = max(dp[N-1])
    print(res)    

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 74092
#include<bits/stdc++.h>
using namespace std;
#define maxn 2000
short a[maxn][maxn];
int W,H,A,B;
int main()
{
	std::cin>>H>>W>>A>>B;
	for(int i=1;i<=A;i++)
	for(int j=1;j<=B;j++)
	a[i][j]=0;	
	for(int i=A+1;i<=W;i++)
	for(int j=1;j<=B;j++)
	a[i][j]=1;
	for(int i=1;i<=A;i++)
	for(int j=B+1;j<=H;j++)
	a[i][j]=1;	
	for(int i=A+1;i<=W;i++)
	for(int j=B+1;j<=H;j++)
	a[i][j]=0;
 
    for(int j=1;j<=H;j++)   {
	for(int i=1;i<=W;i++)
    cout<<a[i][j];
    puts("");
	}
	return 0;
}

Measured memory_bytes: 5248
#include "bits/stdc++.h"
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || b + c == a || c + a == b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N, B = map(int, input().split())
R = N-B
MOD = 10**9+7

# パスカルの三角形
C = [[0 for i in range(N + 1)] for j in range(N + 1)]
C[0][0] = 1
C[1][0] = 1
C[1][1] = 1
for i in range(2, N+1):
    C[i][0] = 1
    C[i][i] = 1
    for j in range(1, i):
        C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD

for i in range(1, B+1):
    print((C[R+1][i] * C[B-1][i-1]) % MOD)

Measured memory_bytes: 99300
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

template<typename T = int64_t> T toInteger(const string&);

template<> int toInteger<int>(const string& s) {
  return stoi(s);
}

template<> int64_t toInteger<int64_t>(const string& s) {
  return stoll(s);
}

template<typename T = int64_t> T toInteger(const string& s, int n) {
  T res = 0;
  for (char c : s) {
    if (isdigit(c)) res = res * n + c - '0';
    else if (isalpha(c)) res = res * n + tolower(c) - 'a' + 10;
  }
  return s[0] == '-' ? -res : res;
}

int main() {
  string a, b;
  cin >> a >> b;
  int n = toInteger<int>(a + b);
  for (int i = 0; i * i <= n; ++i) {
    if (i * i == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        int mod = 1_000_000_007;
        Mod_nCr mn = new Mod_nCr(mod, 220000);
        
        long ans = 0L;
        for(int i=b+1; i<=w; i++){
            long x = mn.nCr(h-a+i-2, i-1);
            long y = mn.nCr(a-1+w-i, w-i);
            ans += ((x%mod)*(y%mod))%mod;
        }
        
        System.out.println(ans%mod);
    }
}

class Mod_nCr{
    int mod;
    long[] fact;
    long[] rfact;
    
    public Mod_nCr(int mod, int max){
        this.mod = mod;
        fact = new long[max];
        rfact = new long[max];
        
        fact[0] = 1;
        rfact[0] = 1;
        
        for(int i=1; i<max; i++){
            fact[i] = (fact[i-1]*i)%mod;
            rfact[i] = mod_inverse(fact[i], mod);
        }
    }
    
    //
    private long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
    
    private long mod_inverse(long a, long m){
        return mod_pow(a, m-2, m);
    }
    
    //
    public long nCr(int n, int r){
        return fact[n]*rfact[r]%mod * rfact[n-r]%mod;
    }
}



Measured memory_bytes: 27988
N = map(int, input().split())
T = list(map(int,input().split()))
x = 100000
for i in range(1,len(T)):
  s1 = sum(T[0:i])
  #print('s1 {}'.format(s1))
  s2 = sum(T[i:len(T)])
  #print('s2 {}'.format(s2))
  s_abs = abs(s1-s2)
  if(x > s_abs):
    x = s_abs
print(x)

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

const int N = 3e3 + 5;

ll a[N];
ll dp[N][N][2];

ll solve(int i, int j, int p) {
  if (j < i)
    return 0;
  if (dp[i][j][p] != -1)
    return dp[i][j][p];
  
  if (p) {
    dp[i][j][p] = max(solve(i+1, j, !p) + a[i],
                      solve(i, j-1, !p) + a[j]);
  } else {
    dp[i][j][p] = min(solve(i+1, j, !p) - a[i],
                      solve(i, j-1, !p) - a[j]);
  }
  return dp[i][j][p];
}

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      dp[i][j][0] = dp[i][j][1] = -1;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << solve(0, n-1, 1) << '\n';
  return 0;
}

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

int main()
{
	int D,G;
	int p[15]={},c[15]={};
	int ans=2e9;
	
	cin >> D >> G;
	for(int i=0;i<D;i++)
		cin >> p[i] >> c[i];
	
	for(int i=1;i<(1<<D);i++)
	{
		int tmp=0;
		int cnt=0;
		for(int j=D-1;j>=0;j--)
		{
			if(i & (1<<j))
			{
				for(int k=0;k<p[j];k++)
				{
					if(tmp>=G)break;
					tmp+=(j+1)*100;
					if(k==p[j]-1)tmp+=c[j];
					cnt++;
				}
			}
		}
		if(tmp>=G)ans=min(ans,cnt);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long rui(int n) {
	if (n == 0) {
		return 1;
	}
	else {
		long long x = rui(n - 1);
		return 2 * x;
	}
}
vector<vector<int> > nyu(int h, int w) {
	vector<vector<int> > a(h+2, vector<int>(w+2, h*w+1));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i+1][j+1];
		}
	}
	return a;
}
int ra(int i, int j, int h, int w) {
	if (1 <= i and i <= h) {
		if (1 <= j and j <= w) {
			return 1;
		}
	}
	return 0;
}
int idx(int ka, int x) {
	if (ka == 0 or ka==2) {
		return x - 1;
	}
	if (ka == 1) {
		return x + 2;
	}
	return x;
}
int idy(int ka, int y) {
	if (ka == 2) {
		return y + 1;
	}
	if (ka == 3) {
		return y - 2;
	}
	return y;
}
int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int> > a;
	int poi = 0;
	vector<int> nex(2*h*w);
	vector<int> ney(2*h*w);
	a = nyu(h, w);
	vector<vector<int> > ho(h + 2, vector<int>(w + 2, 0));
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (a[i - 1][j] > a[i][j] and a[i + 1][j] > a[i][j]) {
				if (a[i][j - 1] > a[i][j] and a[i][j + 1] > a[i][j]) {
					nex[poi] = i;
					ney[poi] = j;
					poi++;
					ho[i][j] = i * w + j;
				}
			}
		}
	}
	int ba = 0;
	int hu = -1;
	while (hu != 0) {
		hu = 0;
		int co = poi;
		for (int so = ba; so < co;so++) {
			int i = nex[so];
			int j = ney[so];
			int x = i;
			int y = j;
			for (int ka = 0; ka < 4; ka++) {
				x = idx(ka, x);
				y = idy(ka, y);
				if (a[x][y] > a[i][j] and ra(x, y, h, w) == 1) {
					if ( ho[x][y] != ho[i][j]) {
                                      	hu++;
					      nex[poi] = x;
					      ney[poi] = y;
					      poi++;
                                      if(ho[x][y]!=0 or ho[i][j]==h * w + w + 1)
                                      {
						ho[x][y] = h * w + w + 1;
                                      }
                                      else{
                                      ho[x][y]=ho[i][j];
                                      }
                                 }
				}
			}
		}
		ba = co;
	}
	int ans = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (ho[i][j] == h*w+w+1) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 26328
S = list(map(str, input()))
listA = ["0"]
listB = ["1"]
countA = 0
countB = 0

for i in range(len(S)):
  listA.append(str((i+1)%2))
  listB.append(str(i%2))
  if listA[i] != S[i]:
    countA = countA + 1
  if listB[i] != S[i]:
    countB = countB + 1

if countA <= countB:
  print(countA)
else:
  print(countB)


Measured memory_bytes: 16608
package main

import (
	"bufio"
	"fmt"
	"os"
)

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var a, b, t int
	fmt.Fscanf(r, "%d %d %d\n", &a, &b, &t)

	times := t / a

	fmt.Fprintln(w, b*times)
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

class Program {
    static void Main (string[] args) {
        int n = int.Parse(Console.ReadLine ());
        string[] s = new string[n];


        for(int i = 0;i<n;i++){
            string temp = Console.ReadLine();
            char[] moji = temp.ToCharArray();
            Array.Sort(moji);
            s[i] = new string(moji);           
        }

        Array.Sort(s);
        int cnt = 1;
        long ans = 0;

        for(int i = 0;i<n-1;i++){
            if(s[i] == s[i + 1]){
                cnt++;
            }
            else{
                 ans = ans + GetMcn(cnt,2);
                 cnt = 1;    
            }

            if(i+1 == n -1){
                ans = ans + GetMcn(cnt,2);
            }
        }

        Console.WriteLine(ans);

    }
public static Int64 GetMcn(int m, int n)
{
    Int64 val;
    if (m < n) return 0;
    n = Math.Min(n, m - n);
    if (n == 0) val = 1;
    else val = GetMcn(m - 1, n - 1) * m / n;
    return val;
}
}

Measured memory_bytes: 24148
from sys import exit

from copy import deepcopy
import numpy as np

import bisect

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    s = input()
    
    for i in range(len(s)-1):
        if s[i:i+2] == "AC":
            print('Yes')
            exit()

    print('No')

main()

Measured memory_bytes: 14500
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define pb push_back
#define SZ(a) ((int)a.size())
//#define TEST
 
const int oo = 1e9;
const int Maxn = 1e5;
const int N = 3e5 + 100;
const double PI = (-2.00) * asin(-1);
 
typedef pair<int, pair<int, int> > iii;
typedef pair<int, int> ii;    

signed main()
{
    #ifdef TEST
        freopen("test.inp", "r", stdin);
    #endif // TEST  
     ios_base::sync_with_stdio(false);                                      
     cin.tie(0); cout.tie(0);

     int res = 0;
     FOR(i, 1, 5) {
        int x; cin >> x;
        if(!x) res = i;
     }
     cout << res;
    
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    string S; cin >> S;

    vector<mint> dp(2*N+1);
    
    dp[0] = 1;
    int k = 0;
    rep(i,2*N) {
        if ((S[i] == 'W') ^ (i%2)) {
            dp[i+1] = dp[i]*k;
            k--;
        } else {
            dp[i+1] = dp[i];
            k++;
        }
    }
    if (k != 0) {
        cout << 0 << endl;
        return 0;
    }
    rep(i,N) dp[2*N] *= (i+1);

    cout << dp[2*N].a << endl;
}

Measured memory_bytes: 2196
#include<bits/stdc++.h>
typedef long long     ll;
using namespace std;
map<ll,ll>mp;
int main()
{
    ll x,n,pos,con=1000,non=1000;
    cin>>x>>n;
    if(n==0)
    {
        cout << x << endl;
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        mp[a]=1;
    }
    for(int i=x; i<=101; i++)
    {
        if(mp[i]==0)
        {
            con=i-x;
            pos=i;
            break;
        }
    }
    for(int i=x-1; i>=0; i--)
    {
        if(mp[i]==0)
        {
            non=x-i;
            if(non<=con)
                pos=i;
            break;
        }
    }
    cout << pos << endl;
}


Measured memory_bytes: 3644
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    ds: [usize; n],
  }
  let m = n / 2;
  let mut pop = vec![0; 100_001];
  for &d in &ds {
    pop[d] += 1;
  }
  let mut ans = 0;
  let mut sum = 0;
  for k in 0 .. 100_001 {
    if sum == m {
      ans += 1;
    }
    sum += pop[k];
  }

  println!("{}", ans);
}


Measured memory_bytes: 6396
public class Hello{
    public static void Main(){
        string str = System.Console.ReadLine();
        int X = int.Parse(str);
        //var N = int.Parse(System.Console.ReadLine());
        int ans = 0;
        
        while(X > 0){
            if(X>=500){
                X -= 500;
                ans += 1000;
            }else if(X>=5){
                X -= 5;
                ans += 5;
            }else{
                break;
            }
        }
        
        System.Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17472
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e5;


ll A[MAXN+5],dp[15][MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	string s;
	sc(s);
	dp[0][le(s)]=1;
	v=t=1;
	fd(i,le(s)-1,0){//	debug(i);
		if(s[i]=='?'){
			fu(j,0,9){
				fu(h,0,12){
					dp[(j*t+h)%13][i]=(dp[(j*t+h)%13][i]+dp[h][i+1])%Base;
				}
			}
		}
		else{
			ll j=s[i]-'0';
			fu(h,0,12){
					dp[(j*t+h)%13][i]=(dp[(j*t+h)%13][i]+dp[h][i+1])%Base;
				}
		}
		v=(v*10)%Base;
		t=t*10%13;
	}
	pr(dp[5][0]);
	re 0;
	// Hack it if you can :)
}

int main(){
//	INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 10704
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
     Scanner sc=new Scanner(System.in);
     if(sc.hasNextInt()) 
      {
        int n=sc.nextInt();
        int arr[][]=new int[n][2];
     	for(int i=0;i<n;i++)
     	{
           arr[i][0]=sc.nextInt();
	   arr[i][1]=sc.nextInt();  
 	}
        deployB obj=new deployB();
          boolean ans=obj.solve(arr,n);
          if(ans==true)
          System.out.println("Yes");
          else
          System.out.println("No");  
      }
        
  }
    
}
class deployB
{
    public boolean solve(int a[][],int n)
    {
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            if(a[i][0]==a[i][1])
            {
                cnt++;
            }
            else
                cnt=0;
            if(cnt==3)
                return true;
        }
        return false;
    }
    
}


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

int main() {
  int n, ans;
  cin >> n;
  n--;
  vector<int> B(n);
  for (int i = 0; i < n; i++) cin >> B[i];
  
  ans = B[0];
  for (int i = 0; i < n-1; i++) ans += min(B[i], B[i+1]);
  ans += B[n-1];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, i, x;

	cin >> n;
	i = 1;
	3 <= n <= 10000;

	while (i <= n - 1)
	{
		i++;
		x = i;

		if (x % 3 == 0)
		{
			cout << " " << i;
		}
		else if (x % 10 == 3)
		{
			cout << " " << i;
		}
		else if ((x / 10) % 10 == 3)
		{
			cout << " " << i;
		}
		else if ((x / 100) % 10 == 3)
		{
			cout << " " << i;
		}
		else if ((x / 1000) % 10 == 3)
		{
			cout << " " << i;
		}
	}
	cout << endl;
}

Measured memory_bytes: 1164
n = int(input())
_, *B = map(int, input().split())
B = set(B)
for x in range(2**n):
    if all([x&1<<s for s in B]):
        if x == 0:
            print('0:')
        else:
            bits = [i for i, b in enumerate(f'{x:b}'[::-1]) if b == '1']
            print(f'{x}: {" ".join(map(str, bits))}')


Measured memory_bytes: 5728
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

var dp = make(map[string]map[int]map[bool]int)
var n string
var k int

func main() {
	n, k = readString(), readInt()

	fmt.Println(dfs(n, 0, true))

	// fmt.Println(dp)
}

func dfs(num string, cnt int, isFull bool) int {
	// fmt.Println(num, cnt, isFull)
	if cnt > k {
		return 0
	}

	if v, ok := dp[num][cnt][isFull]; ok {
		return v
	}

	if _, ok := dp[num]; !ok {
		dp[num] = make(map[int]map[bool]int)
	}

	if _, ok := dp[num][cnt]; !ok {
		dp[num][cnt] = make(map[bool]int)
	}

	if len(num) == 1 {
		if cnt == k {
			dp[num][cnt][isFull] = 1 // zero
		} else if cnt+1 == k {
			t, _ := strconv.Atoi(num)
			dp[num][cnt][isFull] = t // except zero
		} else {
			dp[num][cnt][isFull] = 0
		}
		return dp[num][cnt][isFull]
	}

	ans := 0
	next := num[1:]
	top, _ := strconv.Atoi(num[0:1])
	if isFull && top == 0 {
		dp[num][cnt][isFull] = dfs(next, cnt, true)
		return dp[num][cnt][isFull]
	}

	if isFull {
		ans += dfs(next, cnt+1, true)
		ans += dfs("9"+next[1:], cnt+1, false) * (top - 1) // except zero and the largest num
		ans += dfs("9"+next[1:], cnt, false)               // zero
	} else {
		ans += dfs("9"+next[1:], cnt+1, false) * 9
		ans += dfs("9"+next[1:], cnt, false)
	}

	dp[num][cnt][false] = ans
	return dp[num][cnt][false]
}

func comb(n, r int) int {
	if r == 0 {
		return 1
	}
	return comb(n, r-1) * (n - r + 1) / r
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define pb push_back
#define ALL(v) v.begin(),v.end()
const long long INF = 1LL << 60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
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; }
using Graph = vector<vector<int>>;
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> cnt;
    ll MAX = 0;
    ll sum = 0;
    rep(i, N)
    {
        cin >> A[i];
        ++cnt[A[i]];
        chmax(MAX, A[i]);
        sum += A[i];
    } 
    int Q;
    cin >> Q;
    vector<P> S;
    rep(i, Q) 
    {
        ll a, b;
        cin >> a >>b;
        S.emplace_back(P(a, b));
    }
    rep(i, Q) 
    {
        ll a = S[i].first;
        ll b = S[i].second;
        // rep(k, cnt[a]) sum -= a;
        // rep(k, cnt[b]) sum += b;
        sum -= (ll)(a*cnt[a]);
        sum += (ll)(b*cnt[a]);
        cnt[b] += cnt[a];
        cnt[a] = 0;
        cout << sum << endl;
    }
    return 0;
}

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

int main()
{
  int length;
	string str;
  cin >> length;
  cin >> str;
  int strl = str.length();
  
  if(length<strl)
  {
  cout<<str.substr(0,length) + "...";
  }
  else
  {
  cout<<str;
  }
}

Measured memory_bytes: 3628
l = [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]
K = int (input ())
print (l[K-1])

Measured memory_bytes: 9184
import itertools
Antennas = []
for i in range(5):
    Antennas.append(int(input()))
    
K = int(input())

combi = list(itertools.combinations(Antennas, 2))

flag = True
for c in combi:
    if abs(c[0]-c[1]) > K:
        flag = False

if flag:
    print('Yay!')
else :
    print(':(')

Measured memory_bytes: 3060
use proconio::input;
use proconio::marker::Usize1;

struct UnionFind {
    n: usize,
    par: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut uf = UnionFind {
            n,
            par: Vec::with_capacity(n),
            size: Vec::with_capacity(n),
        };
        for i in 0..n {
            uf.par.push(i);
            uf.size.push(1);
        }
        uf
    }

    fn root(&mut self, x: usize) -> usize {
        if self.par[x] != x {
            self.par[x] = self.root(self.par[x]);
        }
        self.par[x]
    }

    fn unite(&mut self, x: usize, y: usize) -> () {
        if self.root(x) != self.root(y) {
            let rx = self.root(x);
            let ry = self.root(y);
            self.par[rx] = ry;
            self.size[ry] += self.size[rx];
        }
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    fn is_root(&self, x: usize) -> bool {
        x == self.par[x]
    }
}

#[proconio::fastout]
pub fn main() {
    input! {
        n:usize,
        abs:[(Usize1,Usize1)],
    }
    //let n: usize;
    //let abs: Vec(usize, usize);
    let mut uf = UnionFind::new(n);
    for ab in abs {
        uf.unite(ab.0, ab.1);
    }
    let ans = (0..n)
        .filter(|&i| uf.is_root(i))
        .map(|i| uf.size[i])
        .max().unwrap();
    println!("{:}", ans);
}


Measured memory_bytes: 10780
#include <bits/stdc++.h>
using namespace std;
int main(){
	int K;
	cin >> K;
   long lu[1000000];
   for(int i=0;i<9;i++){
   	lu[i] = i+1;
   }
   int nxt = 9;
   int start = 0;
   int last = 9;
   while(nxt < K){
   	int i=start;
   	start = last;
   	while(i < last){
   		if(lu[i] % 10 > 0){
   			lu[nxt] = lu[i] * 10 + (lu[i] % 10) - 1;
   			nxt++;
   		}
   		lu[nxt] = lu[i] * 10 + (lu[i] % 10);
   		nxt++;
   		if(lu[i] % 10 < 9){
   			lu[nxt] = lu[i] * 10 + (lu[i] % 10) + 1;
   			nxt++;
   		}
   		i++;
   		if(nxt > K)break;
   	}
   	last = nxt;
   }
   cout << lu[K - 1] << endl;
}

Measured memory_bytes: 2688
#include<stdio.h>
#include<algorithm>
using namespace std;
int g[500][500];
int l[500];
int r[500];
int G[500][500];
int bell[500];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",l+i,r+i);
	}
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++)
			scanf("%d",&g[i][j]);
	for(int k=0;k<a;k++)
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++)
				g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(i==j)G[i][j]=-999999999;
			if(r[i]+g[i][j]<r[j]){
				G[i][j]=r[j]-max(l[j],(r[i]+g[i][j]));
			}else G[i][j]=-999999999;
		//	printf("%d %d: %d\n",i,j,G[i][j]);
		}
	}
	for(int i=0;i<a;i++){
		bell[i]=-999999999;
		if(g[b-1][i]<r[i])bell[i]=r[i]-max(l[i],g[b-1][i]);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			for(int k=0;k<a;k++){
				if(bell[k]<bell[j]+G[j][k])
					bell[k]=bell[j]+G[j][k];
			}
		}
	}
	int ret=0;
	for(int i=0;i<a;i++)ret=max(ret,bell[i]);printf("%d\n",ret);
}

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

#define  io  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  int  long long
#define  endl  '\n'
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________



int32_t main()
{ 
  io;


  string s,t;
  cin>>s>>t;

  vector<int> a(26,0),b(26,0);

  for(char c: s)
    a[c-'a']++;
  
  for(char c: t)
    b[c-'a']++;

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  bool ok=true;

  for(int i=0;i<26;i++)
  {
    ok &= (a[i]==b[i]);
  }

  cout<<(ok?"Yes":"No");
  
 return 0;
}

Measured memory_bytes: 916