akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;

const lint M = 1000000007;

vector<lint> fac(300001); //n!(mod M)
vector<lint> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

lint mpow(lint x, lint n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    lint ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

lint comb(lint a, lint b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    lint tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main() {
  fac[0] = 1;
    ifac[0] = 1;
    for(lint i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

  int h, w, a, b;
  cin >> h >> w >> a >> b;
  lint mod = 1000000007;
  lint ans = comb(h+w-b-2, h-1) % mod;
  For(t, 1, h-a){
    ans += (comb(t+b-1, b-1) % mod * comb(h+w-t-b-2, w-b-1) % mod) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}




Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#include <algorithm>

using namespace std;

class Hash {
    public:
    
    Hash(const char *s, long long base = 1009, long long m = 1000000007) : MOD(m) {
        int n = strlen(s);
        
        hash = (long long *)malloc(sizeof(long long) * (n + 1));
        pow = (long long *)malloc(sizeof(long long) * (n + 1));
        
        hash[0] = 0;
        pow[0] = 1;
        
        for (int i = 0; i < n; i++) {
            hash[i + 1] = (hash[i] * base + s[i]) % MOD;
            pow[i + 1] = pow[i] * base % MOD;
        }
    }
    
    ~Hash() {
        free(hash);
        free(pow);
    }
    
    //xからy文字のハッシュ値
    long long get(int x, int y) {
        return (hash[x + y] - hash[x] * pow[y] % MOD + MOD) % MOD;
    }
    
    private:
    
    long long MOD;
    long long *hash;
    long long *pow;
};

int n;
char s[100001];

int calc(int x, Hash &h1, Hash &h2) {
    int i;
    set <pair<long long, long long> > s;
    
    for (i = 0; i + x <= n; i++) s.insert(make_pair(h1.get(i, x), h2.get(i, x)));
    
    return s.size();
}

int main() {
    int ans = 0, l, r, m, i;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    Hash h1(s);
    Hash h2(s, 10009, 999999937);
    
    l = 1, r = n, m = (l + r) / 2;
    
    while (r - l > 1) {
        if (calc(m, h1, h2) - calc(m - 1, h1, h2) > 0) {
            l = m;
            m = (l + r) / 2;
        } else {
            r = m;
            m = (l + r) / 2;
        }
    }
    
    printf("%d\n", calc(l, h1, h2));
    
    return 0;
}


Measured memory_bytes: 9728
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
	ll k ; 
	cin>>k ; 
	ll res = 0 ;
	ll st = 1 ;
	repu(i , 1 , 1000000){
		ll temp  = (st*7)%k ;
		res += temp ;
		if(res%k==0){
			cout<<i;
			return ;
		}
		st =  (st*10)%k ;
	}
	cout<<-1<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N,K; cin>>N; cin>>K; 
  vector<int> A (N,0);
  int SUM = 0;
  for (int i = 0; i < N; i++)
  {
      cin>>A[i];
      SUM += A[i];
  }
  vector<int> F (N,0);
  for (int i = 0; i < N; i++)
  {
      cin>>F[i];
  }
  sort(ALL(A));
  sort(ALL(F));
  reverse(ALL(F));

  // DEBUG(A);
  // DEBUG(F);
  int L = -1, R = 1e18 + 1;
  
  while(L + 1< R)
  {
    int k = K;
    int mid = (L+R)>>1;
    // DEBUG(mid);
    int flg = 0;
    for (int i = 0; i < N; i++)
    {
      int x = mid/F[i];

        k -= max(0LL,A[i] - x);
      
    }
    // DEBUG(L,R,mid,"\n");
    if(k < 0)
    {
      flg = 1;
    }
    

    if(flg)
    {
      L = mid;
    }
    else
    {
      R = mid;
    }
    // DEBUG(L,R,"\n");
  }
  cout<<R<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int r;
    cin >> r;
    if(r < 1200) cout << "ABC" << endl;
    else if(r < 2800 && 1200 <= r) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 3640
// ARC089
// D - Checker

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_K = 1000;

int N, K;
int m[2 * MAX_K + 1][2 * MAX_K + 1];

void mask(int x, int y) {
    int xl = x, xr = x + K;
    int yl = y, yr = y + K;
    xl %= 2 * K;
    xr %= 2 * K;
    yl %= 2 * K;
    yr %= 2 * K;
    m[xl][yl]++;
    m[xr][yl]--;
    m[xl][yr]--;
    m[xr][yr]++;
    if (xr < xl) {
        m[0][yl]++;
        m[0][yr]--;
    }
    if (yr < yl) {
        m[xl][0]++;
        m[xr][0]--;
    }
    if (xr < xl && yr < yl) {
        m[0][0]++;
    }
}

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

    memset(m, 0, sizeof(m));
    for (int i = 0; i < N; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'B') {
            mask(x, y);
            mask(x + K, y + K);
        } else {
            mask(x + K, y);
            mask(x, y + K);
        }
    }

    for (int j = 0; j < 2 * K; j++) {
        for (int i = 1; i < 2 * K; i++) {
            m[i][j] += m[i - 1][j];
        }
    }
    for (int i = 0; i < 2 * K; i++) {
        for (int j = 1; j < 2 * K; j++) {
            m[i][j] += m[i][j - 1];
        }
    }

    int ans = 0;
    for (int i = 0; i < 2 * K; i++) {
        ans = max(ans, *max_element(m[i], m[i] + 2 * K));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

vector<unordered_set<int>> nexts;

int dfs(int now, vector<bool> &visited) {
	visited[now] = true;
	int ret = 1;
	for (int next : nexts[now]) {
		if (visited[next]) continue;
		ret += dfs(next, visited);
	}
	return ret;
}

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

	nexts.resize(N);

	vector<pair<int, int>> prs;
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		nexts[a].insert(b);
		nexts[b].insert(a);

		prs.push_back(mp(a, b));
	}

	int ret = 0;

	for (auto &pr : prs) {
		int a = pr.first;
		int b = pr.second;
		nexts[a].erase(b);
		nexts[b].erase(a);

		vector<bool> visited(N, false);
		int tmp = dfs(0, visited);
		ret += tmp != N;

		nexts[a].insert(b);
		nexts[b].insert(a);
	}

	cout << ret << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl

typedef long long ll;

void Main()
{
	int N;
  	cin >> N;
  	vector<int> L(N);
  	int sum = 0;	
  	rep(i,N) {
      	cin >> L[i];
    	sum += L[i];
    }
	vector<int>::iterator iter = max_element(L.begin(), L.end());
  	size_t index = distance(L.begin(), iter);
	if(sum - L[index] > L[index]) {cy;}
  	else{cn;}
      
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

bool judge(int dice1[], int dice2[]);
bool subJudge(const int dice1[], const int dice2[]);
void moveE(int dice[]);
void moveN(int dice[]);
void moveS(int dice[]);
void moveW(int dice[]);
void moveR(int dice[]);

int main(void)
{	
	int dice1[6];
	for (int i = 0; i < 6; i++) cin >> dice1[i];
	int dice2[6];
	for (int i = 0; i < 6; i++) cin >> dice2[i];
	
	if (judge(dice1, dice2)) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

bool judge(int dice1[], int dice2[])
{
	for (int i = 0; i < 4; i++) {
		moveE(dice2);
		for (int j = 0; j < 4; j++) {
			moveN(dice2);
			for (int k = 0; k < 4; k++) {
				moveR(dice2);
				if (subJudge(dice1, dice2)) {
					return true;
				}
			}
		}
	}
	return false;
}

bool subJudge(const int dice1[], const int dice2[])
{
	for (int i = 0; i < 6; i++) {
		if (dice1[i] != dice2[i]) return false;
	}
	return true;
}

void moveE(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[3];
	dice[3] = dice[5];
	dice[5] = dice[2];
	dice[2] = temp;
}

void moveN(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[1];
	dice[1] = dice[5];
	dice[5] = dice[4];
	dice[4] = temp;
}

void moveS(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[4];
	dice[4] = dice[5];
	dice[5] = dice[1];
	dice[1] = temp;
}

void moveW(int dice[])
{
	int temp = dice[0];
	dice[0] = dice[2];
	dice[2] = dice[5];
	dice[5] = dice[3];
	dice[3] = temp;
}

void moveR(int dice[])
{
	int temp = dice[1];
	dice[1] = dice[2];
	dice[2] = dice[4];
	dice[4] = dice[3];
	dice[3] = temp;
}

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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int mod=1e9+7;

ll mod_pow(ll a,ll n,ll mod)	//(a^n)%mod
{	ll res=1;
	while(n){	if(n&1)	res=(res*a)%mod; n/=2; a=(a*a)%mod;	}
	return res;
}

void solve();

int main()
{
    fst;
    //test(t);
     solve();
}

/**********************<="Actual code strats here"=>*****************************/

const int maxn=1e5+2;
ll a[maxn];

void solve()
{
    ll n;
    cin>>n;
    ll sum=0;
    rep(i,0,n) 
    {
        ll x;
        cin>>x;
        ++a[x];
        sum+=x;
    }

    ll q;
    cin>>q;
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        sum-=1ll*a[x]*x;
        sum+=1ll*a[x]*y;
        a[y]+=a[x];
        a[x]=0;

        cout<<sum<<endl;
    }
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;
int dp[41][1000][1000];
int main() {
    int N, ma, mb;
    cin >> N >> ma >> mb;
    int a[N], b[N], c[N];
    rep(i, N){
        cin >> a[i] >> b[i] >> c[i];
    }

    rep(i, N+1){
        rep(j, 1000){
            rep(k, 1000){
                dp[i][j][k] = 11111111;
            }
        }
    }

    dp[0][0][0] = 0;
    rep(i, N){
        rep(j, 1000){
            rep(k, 1000){
                if (j - a[i] >= 0 && k - b[i] >= 0) {
                    dp[i + 1][j][k] = min(dp[i][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
                } else {
                    dp[i + 1][j][k] = dp[i][j][k];
                }
            }
        }
    }

    int ans = 10000000;
    REP(j, 1,1000){
        REP(k,1, 1000){
            if (j % ma == 0 && k % mb == 0 && j/ma == k/mb){
                ans = min(dp[N][j][k], ans);
            }
        }
    }

    if (ans == 10000000){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const ll LIM=1000000;

ll f(ll b, ll n)
{
    // printf("call f(%lld, %lld)\n", b,n);
    if(n<b) return n;
    else return f(b,n/b)+(n%b);
}

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

    ll ans=-1;
    if(n==s) ans=n+1;
    else if(n>s)
    {
        if(n<LIM)
        {
            for(int b=2; b<=n; ++b)
            {
                if(f(b,n)==s)
                {
                    ans=b;
                    break;
                }
            }
        }
        else
        {
            ll now=n, a=1;
            while(now>LIM)
            {
                ll fnow=f(now,n);
                ll p=now-fnow-1, q=1+a;

                ll k=p/q;
                if(p%q!=0) ++k;

                // printf("now= %lld,fnow= %lld ,k=%lld\n", now,fnow,k);


                if(fnow<=s && s<=fnow+a*k)
                {
                    if((s-fnow)%a==0)
                    {
                        ll kk=(s-fnow)/a;
                        ans=now-kk;
                    }
                }

                now-=k+1;
                ++a;
            }

            for(ll b=2; b<=now; ++b)
            {
                if(f(b,n)==s)
                {
                    ans=b;
                    break;
                }
            }
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    cout << (N+1)/2 << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){

	int n,k;
	cin>>n>>k;
	int a[n];
	long int ans=0;
	for(int i=0;i<n;i++){
	
		cin>>a[i];
		if(a[i]<=abs(k-a[i])){
			
			ans+=2*a[i];
		}
		else{
		
			ans+=2*abs(k-a[i]);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 102, K = 4;
ll dp[N][K][2];
char s[N];
int k, n;

ll rec(int x, int cnt, int f) {
    if (x == n) {
        return cnt == k;
    }
    if (cnt > k) return 0;
    ll &ret = dp[x][cnt][f];
    if (ret != -1) return ret;
    ret = 0;
    if (f) {
        for (int i = 0; i < s[x] - '0'; i++) {
            ret += rec(x + 1, cnt + (i != 0), 0);
        }
        ret += rec(x + 1, cnt + (s[x] != '0'), 1);
    } else {
        for (int i = 0; i < 10; i++) {
            ret += rec(x + 1, cnt + (i != 0), 0);
        }
    }
    return ret;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    scanf("%s\n%d", s, &k);
    n = strlen(s);
    memset(dp, -1, sizeof dp);
    printf("%lld", rec(0, 0, 1));
    return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++) 
#define lint long long
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> P;

const int MAX_S = 100001;
bool used[MAX_S];

bool comp(P x, P y){
    return x.second > y.second;
}

int main(){
    int n, k; cin >> n >> k;
    vector<P> sushi(n);
    rep(i, n){
        int t; long d; cin >> t >> d;
        sushi[i] = make_pair(t, d);
    }
    sort(all(sushi), comp);
    
    long sum = 0; long count = 0;
    multiset<long> q;
    rep(i, k){
        sum += sushi[i].second;
        if (!used[sushi[i].first]){
            count++;
            used[sushi[i].first] = true;
        }
        else{
            q.insert(sushi[i].second);
        }
    }
    long ans = sum + count * count;
    
    for(int i = k; i < n; i++){
        P s = sushi[i];
        if(used[s.first]) continue;
        else{
            if(q.empty()) break;

            used[s.first] = true;
            sum -= *(q.begin());
            q.erase(q.begin());
            sum += s.second;
            count++;
            long newans = sum + count * count;
            ans = max(ans, newans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll f(ll a) {
    ll ret = 0;
    while(a) {
        ret += a % 10;
        a /= 10;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int K;
    cin >> K;
    vector<ll> ans(K);
    ans[0] = 1;
    ll inc = 1;
    int ind = 1;
    while(ind < K) {
        if(f(ans[ind - 1] + inc * 2) * (ans[ind - 1] + inc) <= f(ans[ind - 1] + inc) * (ans[ind - 1] + inc * 2)) {
            ans[ind] = ans[ind - 1] + inc;
            ind++;
        }
        else {
            inc *= 10;
        }
    }
    rep(i, K) {
        cout << ans[i] << endl;
    }
    
    return 0;
}


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

int main() {
  ll x = 0;
  cin >> x;
  ll ans = 0;
  ans += 1000 * (x / 500);
  x %= 500;
  ans += 5 * (x / 5);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N,0);
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    vec.at(i) = a;
  }
  
  int t = 0;
  int p = 1;
  while (p != 2){
    if (t == N){
      t = -1;
      break;
    }
    
    else {
      p = vec.at(p-1);
      t++;
    }
  }
  
  cout << t << endl;
}
  

Measured memory_bytes: 640
n=int(input())
a=list(map(int, input().split()))

j, s, tot=0, 0, 0
for i in range(n):
  while j<n:
    if (s+a[j])==(s^a[j]):
      s+=a[j]
      j+=1
    else:
      break
  tot+=(j-i)
  s-=a[i]

print(tot)

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

main(){
  int N,A,B;
  cin >> N >> A >> B;

  int x1,x2,x3,x4,x5,X;
  int sum =0;
  for(int i=1;i<N+1;i++){
      x1 = i/10000;
      x2 = (i-x1*10000)/1000;
      x3 = (i-x1*10000-x2*1000)/100;
      x4 = (i-x1*10000-x2*1000-x3*100)/10;
      x5 = (i-x1*10000-x2*1000-x3*100-x4*10);
      X = x1+x2+x3+x4+x5;
    if(A <= X && X <= B){
      sum = sum + i ;
    }
  }  
  cout << sum << endl;
  }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
const long long mod = 10000000;
int a[114514], b[114514];
int ans[15];
vector<P>V;
map<P, int>M;
signed main() {
	int h, w, n; cin >> h >> w >> n;
	rep(i, n) {
		cin >> a[i] >> b[i];
		M[P(a[i], b[i])] = 1;
		for (int j = -2; j <= 0; j++) {
			for (int k = -2; k <= 0; k++) {
				if(1<=a[i]+j&&a[i]+j<=h-2&&1<=b[i]+k&&b[i]+k<=w-2)V.push_back(P(a[i]+j, b[i]+k));
			}
		}
	}
	sort(V.begin(), V.end());
	V.erase(unique(V.begin(), V.end()), V.end());

	rep(i, V.size()) {
		int cnt = 0;
		rep(j, 3) {
			rep(k, 3) {
				if (M[P(V[i].first + j, V[i].second + k)])cnt++;
			}
		}
		ans[cnt]++;
	}
	ans[0] += (h-2)*(w-2) - V.size();
	rep(i, 10)cout << ans[i] << endl;

}

Measured memory_bytes: 174052
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  string s, t;
  cin >> s;

  for(int i=0; i<s.size(); i++){
    cout << "x";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
  
#define ELEMENT_CNT_MIN (1)
#define ELEMENT_CNT_MAX (10000)
#define ELEMENT_MIN (2)
#define ELEMENT_MAX (100000000)
#define FAILUER (-1)
#define SUCCESS (0)
#define FUNC_TRUE  (1)
#define FUNC_FALSE (0)
  
int get_int_sequence(int *p_num, int min, int max, int size);
int get_int(int *p_num, int min, int max);
int judge_constraint(int test_num, int min, int max);
int put_prime_cnt_in_list(int *p_num, int size);
int is_prime(int x);
  
int main(void){
      
    int element_num;
    int element[ELEMENT_CNT_MAX];
      
    if(get_int(&element_num, ELEMENT_CNT_MIN, ELEMENT_CNT_MAX) == FAILUER)
    {
        return FAILUER ;
    }
      
    if(get_int_sequence(&element[0], ELEMENT_MIN, ELEMENT_MAX, element_num) == FAILUER)
    {
        return FAILUER ;
    }
      
    printf("%d\n", put_prime_cnt_in_list(&element[0], element_num));
      
    return SUCCESS;
}
  
int is_prime(int x)
{
    int i;
      
    if(x == 2)
    {
        return FUNC_TRUE;
    }
    if((x < 2) || (x % 2 == 0))
    {
        return FUNC_FALSE;
    }
    /* target is odd num >= 3 */
    i = 3;
    while(i <= sqrt(x))
    {
        if(x % i == 0)
        {
            return FUNC_FALSE;
        }
        i += 2;
    }
      
    return FUNC_TRUE;
}
  
int put_prime_cnt_in_list(int *p_num, int size)
{
    int i;
    int cnt = 0;
      
    for(i = 0; i < size; i++)
    {
        if(is_prime(p_num[i]) == FUNC_TRUE)
        {
            cnt++;
        }
    }
      
    return cnt;
}
  
  
int get_int_sequence(int *p_num, int min, int max, int size)
{
    int i;
      
    for(i = 0; i < size; i++)
    {
        if(get_int(&p_num[i], min, max) == FAILUER)
        {
            return FAILUER;
        }
    }
      
    return SUCCESS;
}
  
int get_int(int *p_num, int min, int max)
{
    scanf("%d", p_num);
      
    if(judge_constraint(*p_num, min, max) == FAILUER)
    {
        return FAILUER;
    }
      
    return SUCCESS;
}
int judge_constraint(int test_num, int min, int max)
{
    if(test_num < min || test_num > max)
    {
        return FAILUER;
    }
      
    return SUCCESS;
}

Measured memory_bytes: 1888
a = []
5.times do
  a << gets.to_i
end

last_order = a.min_by {|n| n % 10 == 0 ? 10 : n % 10 }
remain = 10 - last_order % 10
remain = 0 if remain == 10

sum = a.reduce(0) {|result, n| result += ((n-1)/10 + 1) * 10}
puts sum - remain

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

int main() {
  int n; ll d;
  cin >> n >> d;
  d *= d;
  int ans = 0;
  rep(i,0,n) {
    ll x,y;
    cin >> x >> y;
    ll r = x*x + y*y;
    if (r <= d) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s;
    cin >> s;
    int l = 0, r = s.size() - 1, ans = 0; 
    while(l < r){
        if(s[l] == s[r]){
            l++; r--;
        }else{
           if(s[l] == 'x'){
               l++;
               ans++;
           }else if(s[r] == 'x'){
               r--;
               ans++;
           }else{
               ans = -1;
               break;
           } 
        }
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
# include <bits/stdc++.h>
/// my holy template
# define F first    
# define S second
# define mp make_pair
# define pii pair<int,int>         
/// eveything goes according to plan
# define long long long  
# define pb push_back
# define sz(a) (int)(a.size())
/// countdown BEGAN. 10 , 9 , 8 ...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right     

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long MXLL = 9223372036854775807;
const int Sz = 1110111;

using namespace std;

inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
int n, m;     
                              
int main() 
{
  Read_rap ();

  cin >> n >> m;

  cout << (n - 1) * (m - 1);


  return 0;
} 










// Coded by Z...

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;
ll dp[65][2][2][2];

int main() {
    ll l, r;
    cin >> l >> r;
    int n = 64;
    VI bl(n), br(n);
    REP(i,n){
        bl[i] = l % 2;
        br[i] = r % 2;
        l /= 2;
        r /= 2;
    }
    reverse(ALL(bl));
    reverse(ALL(br));
    dp[0][0][0][0] = 1;
    REP(i,n) REP(fl,2) REP(fr,2) REP(g,2){
        if (dp[i][fl][fr][g] == 0) continue;
        REP(bx,2) REP(by,2){
            if (bx == 1 && by == 0) continue;
            if (!g && bx + by == 1) continue;
            if (!fl && bl[i] && !bx) continue;
            if (!fr && !br[i] && by) continue;
            (dp[i+1][fl|(bx>bl[i])][fr|(by<br[i])][g|bx|by] += dp[i][fl][fr][g]) %= mod;
        }
    }
    ll ans = 0;
    REP(fl,2) REP(fr,2) REP(g,2) ans = (ans + dp[n][fl][fr][g]) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=205;

int n,q[N],dep[N];
bool vis[N];
char st[N][N];

int main() {
	scanf("%d",&n);
	fo(i,1,n) scanf("%s",st[i]+1);
	int ans=-1;
	fo(i,1,n) {
		int hd=0,tl=1;q[tl]=i;
		fo(j,1,n) dep[j]=0;dep[i]=1;bool ok=1;
		while (hd<tl) {
			int x=q[++hd];
			fo(j,1,n) 
				if (st[x][j]=='1') {
					if (!dep[j]) dep[j]=dep[x]+1,q[++tl]=j;
					else if (abs(dep[j]-dep[x])!=1) ok=0;
				}
		}
		if (ok) fo(j,1,n) ans=max(ans,dep[j]);
	}
	printf("%d\n",ans);
	return 0;
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n;
	cin >> n;
	vi p;
	while (n--) {
		int e; cin >> e;
		p.pb(e);
	}
	int inv = 0;
	for (int i = 0; i < p.size(); i++)
		if (p[i] != i+1) inv++;
	cout << (inv < 3 ? "YES" : "NO") << ende;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
#pragma GCC optimize "trapv"
using namespace std;
typedef long long int ll;
int mx =1e6+100;
int mod = 1e9+7;
long long moduloMultiplication(long long a,
                            long long b)
{
    long long res = 0;
  
    a %= mod;
  
    while (b)
    {
        if (b & 1)
            res = (res + a) % mod;

        a = (2 * a) % mod;
  
        b >>= 1;
    }
  
    return res;
}
  
int main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    ll tot=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        tot  = (tot%mod + a[i]%mod)%mod;
    }
    //
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        tot = (tot%mod-a[i]%mod+mod)%mod;
        ll val = moduloMultiplication(tot, a[i]);
         sum  = (sum%mod + val%mod)%mod;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int lower = max(a, c);
	int  upper = min(b, d);
	int  ans;
	ans = max(0, upper - lower);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

struct graph {
  int n, *p;
  std::vector<int> *adj;
  graph (int n) : n(n) {
    adj = new std::vector<int>[n];
    p = new int[n];
    for (int i = 0; i < n; ++i)
      p[i] = -1;
  }
  void add_edge(int u, int v) {
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  void bfs(int s) {
    std::queue<int> q;
    q.push(s); p[s] = s;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int v : adj[u])
        if (p[v] == -1) {
          p[v] = u;
          q.push(v);
        }
    }
  }
};

int N, M;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);

  std::cin >> N >> M;
  graph g(N);
  for (int i = 0; i < M; ++i) {
    int u, v; std::cin >> u >> v;
    u--;  v--;
    g.add_edge(u, v);
  }
  g.bfs(0);

  bool all_has_parent = true;
  for (int u = 0; u < N; ++u)
    if (g.p[u] == -1)
      all_has_parent = false;
  if (all_has_parent) {
    std::cout << "Yes\n";
    for (int u = 1; u < N; ++u)
      std::cout << g.p[u] + 1 << "\n";
  } else {
    std::cout << "No\n";
  }

  return 0;
}


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

int main(){
	char a[4],b[8];
	int i=0,j=0;
	while(i<=3){cin>>a[i];cout<<a[i];i++;}
	cout<<" ";
	while(j<=7){cin>>b[j];cout<<b[j];j++;}
        cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i,j,n,m,max;
		while(true) {
			n=scan.nextInt();
			m=scan.nextInt();
			if(n==0 && m==0) {
				break;
			}
			
			int[] goods=new int[n];
			for(i=0;i<n;i++) {
				goods[i]=scan.nextInt();
			}
			max=0;
			for(i=0;i<n-1;i++) {
				for(j=i+1;j<n;j++) {
					if(goods[i]+goods[j]>=max && goods[i]+goods[j]<=m) {
						//System.out.println(goods[i]+" "+goods[j]+" "+max);
						max=goods[i]+goods[j];
					}
				}
			}
			if(max==0) {
				System.out.println("NONE");
			}
			else {
				System.out.println(max);
			}
		}
		scan.close();
	}
}


Measured memory_bytes: 51532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a[100]={0,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};
	int k;
	cin>>k;
	cout<<a[k];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b&b<c){
        cout<<c*10+a+b<<endl;
    }
    else if(a<=c&c<=b){
        cout<<b*10+c+a<<endl;
    }
    else if(b<=c&&c<=a){
        cout<<a*10+c+b<<endl;
    }
    else if(b<=a&&a<=c){
        cout<<c*10+a+b<<endl;
    }
    else if(c<=a&&a<=b){
        cout<<b*10+a+c<<endl;
    }
    else if(c<=b&&b<=a){
        cout<<a*10+c+b<<endl;
    }
    
}

Measured memory_bytes: 256
(n,k),a,f=$<.map{|l|l.split.map &:to_i}
m=a.sort.zip f.sort.reverse
p (0..2**40).bsearch{|i|
  s=0
  m.each{|a,f|(0<x=a-i/f)&&s+=x}
  s<=k
}

Measured memory_bytes: 40088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String... args) throws IOException {
        final int[] charCount = new int[26];
        final StringBuilder sb = new StringBuilder();
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            final int charactor = br.read();
            if (97 <= charactor && charactor <= 123) {
                charCount[charactor - 97]++;
            } else if (65 <= charactor && charactor <= 91) {
                charCount[charactor - 65]++;
            } else if (charactor == -1) {
                break;
            }
        }
 
        for (int i = 0; i < 26; i++) {
            sb.append(((char) (i + 97))).append(" : ").append(charCount[i]).append(i != 25 ? '\n' : "");
        }
 
        System.out.println(sb);
    }
}

Measured memory_bytes: 16872
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int r,D,x;
    long long sum;
    scanf("%d%d%d",&r,&D,&x);
    for(int i=1; i<=10; i++)
    {
        sum=(r*x)-D;
        printf("%lld\n",sum);
        x=sum;
    }

}


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

int main(){
    string s,t;
    cin >> s >> t;
    int s1 = s.size(),t1 = t.size();
    string make_s,make_t;
    map<char,int> ms,mt;
    for(int i=0;i<s1;i++){
        ms[s[i]]++;
    }
    for(int i=0;i<t1;i++){
        mt[t[i]]++;
    }
    for(auto x:ms){
        for(int i=0;i<x.second;i++){
            make_s += x.first;
        }
    }
    for(auto x:mt){
        for(int i=0;i<x.second;i++){
            make_t += x.first;
        }
    }
    reverse(make_t.begin(),make_t.end());
    //cout << make_s << " " << make_t << endl;
    if(make_s < make_t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<iostream>
using namespace std;
vector<int>child[100005];
int in[100005], n, m, i, j, a, b, mx, l[100005];
queue<int>q;
int main() {
	ios::sync_with_stdio(false), cin.tie(false), cout.tie(false);
	cin >> n >> m;
	for (i = 0;i < m;++i)cin >> a >> b, ++in[b], child[a].push_back(b);
	for (i = 1;i <= n;++i)if (in[i] == 0)q.push(i);
	while (q.size()) {
		a = q.front(), q.pop();
		while (child[a].size()) {
			b = child[a].back(), child[a].pop_back();
			l[b] = max(l[b], l[a] + 1), mx = max(mx, l[b]), --in[b];
			if (in[b] == 0)q.push(b);
		}
	}
	cout << mx;
}

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

#define rep(X,N) for(int X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    ll a;
    string b;
    cin >> a >> b;

    ll ans = 0;

    ans += a * (ll)(b[0] - '0') * 100;
    ans += a * (ll)(b[2] - '0') * 10;
    ans += a * (ll)(b[3] - '0');

    cout << ans / 100 << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF=(1LL<<31)-1;

ll cost[11][11];
int wall[300][300];


int main(){
    int H,W; cin >> H >> W;
    rep(i,10){
        rep(j,10){
            cin >> cost[i][j];
        }
    }
    rep(x,H){
        rep(y,W){
            cin >> wall[x][y];
        }
    }


    rep(k,10){
        rep(i,10){
            rep(j,10){
                cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
            }
        }
    }
    ll res = 0;
    rep(x,H){
        rep(y,W){
            if(wall[x][y]!=-1 && wall[x][y]!=1) res += cost[wall[x][y]][1];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3824
A,B,C,D=map(int, raw_input().split())
if C%B==0:
    T_attack=C/B
else:
    T_attack=C/B+1

if A%D==0:
    A_attack=A/D
else:
    A_attack=A/D+1

if T_attack<=A_attack:
    print "Yes"
else:
    print "No"

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

int a[200001];
multiset<int> s;
int main()
{
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++)
		if(a[i]!=0) s.insert(a[i]);
	int ans=0;
	while(s.size()>k){
		ans+=*s.begin();
		s.erase(s.begin());
	}
	cout<<ans;
}

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

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

  string s;
  cin>>s;
  vector<int> cnt(26,0);
  for(auto i : s){
    cnt[i-'a']++;
  }
  bool check = true;
  for(int i=0; i<26; ++i){
    if( cnt[i] % 2 == 1 ){ check = false; }
  }
  check  ? cout<<"Yes\n" : cout<<"No\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    println(max(0, c - (a - b)))
    return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[610001],tq,b[610001],f[610001],i,j,k,n,m;
int av(int x){
	return (x>=0)?x:-x;
}
int main(){
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (b[0]=0,i=1;i<=n;i++){
		if (b[i-1]==m){
			b[i]=m;continue;
		}
		k=(b[i-1]<m)?a[i]+b[i-1]:b[i-1]-a[i];
		if (av(m-k)<av(b[i-1]-m)) b[i]=k;else b[i]=b[i-1];
	}
	for (i=n,f[n+1]=0;i;i--){
		if (a[i]-f[i+1]<=f[i+1]+1) f[i]=a[i]+f[i+1];else f[i]=f[i+1];
	}
	scanf("%d",&tq);
	while (tq--){
		scanf("%d",&k);
		if (av(m-b[k-1])>f[k+1]) puts("YES");else puts("NO");
	}
	return 0;
}

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

def dfs(s):
  if (int(s) > N):
    return 0
  if (all (s.count(c) > 0 for c in '357')):
    ret = 1
  else:
    ret = 0
  for c in '357':
    ret += dfs(s + c)
  return ret

print(dfs('0'))

Measured memory_bytes: 3060
l = raw_input().split()
s = l[0]

def get_removals(s):
    ret = []
    for i in range(len(s) - 1):
        if int(s[i]) + int(s[i + 1]) == 1:
            ret.append(i)
    return ret

def remove(s, index):
    if index == 0:
        return s[2:]
    if index == (len(s) - 1):
        return s[:index-1]
    return  s[0:index] + s[index + 2:]

num_removals = []

ones = 0
zeros = 0
for num in s:
    if num == '0':
        ones += 1
    if num == '1':
        zeros += 1
max_candidate = min(ones, zeros) * 2

def process(s, count):
    removals = get_removals(s)
    if len(removals) == 0:
        num_removals.append(count)
        if count == max_candidate:
            print(max_candidate)
            exit()
        return
    count += 2
    max_remove = 0
    ss = []
    for removal in removals:
        s1 = remove(s, removal)
        ss.append(s1)
        num_removes = len(get_removals(s1))
        if max_remove < num_removes:
            max_remove = num_removes
    for s1 in set(ss):
        if len(get_removals(s1)) == max_remove:
            process(s1, count)

# process(s, 0)
print(max_candidate)


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, P;
    cin >> N >> P;

    if(N==1){
        cout << P << endl;
        return 0;
    }
    ll ans = 1;
    for(auto p : prime_factor(P)) {
        // cout << p.first << ":" << p.second << endl;
        if(p.second >=N){
            ll k = p.second/N;
            for(ll i=1; i<=k; i++){
                ans *= p.first;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n;
    while(cin >> n, n){
        vector<bool> used(n*2);
        set<int> card[2];
        for(int i=0;i<n;i++){
            int x;
            cin >> x;
            x--;
            card[0].insert(x);
            used[x] = true;
        }
        for(int i=0;i<n*2;i++){
            if(!used[i]) card[1].insert(i);
        }
        int turn = 0;
        int num = -1;
        while(!card[0].empty() && !card[1].empty()){
            auto itr = card[turn].upper_bound(num);
            if(itr == card[turn].end()){
                num = -1;
            }else{
                num = *itr;
                card[turn].erase(num);
            }
            turn ^= 1;
        }
        cout << card[1].size() << '\n' << card[0].size() << endl;
    }
    return 0;
}



Measured memory_bytes: 3100