akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

inline D inprd(const P &a, const P &b){ return (conj(a) * b).X; }
inline D outprd(const P &a, const P &b){ return (conj(a) * b).Y; }
inline D sign(D d){ return (d<0)?-1:d>0?1:0; }

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

#define RI  v[0]
#define UP  v[1]
#define LE  v[2]
#define DW  v[3]

int movex[4] = {1, 0,-1, 0};
int movey[4] = {0,-1, 0, 1};
const char *str = "RULD";

class mc {
public:
    int v[4];
} m[5][5];

int main(){
    vector<string> sv;
    string s;
    cin.binary;
    while(getline(cin, s)){
        sv.push_back(s);
    }

    if(sv.size() != 9) throw;

    for(int i = 0; i < 5; i++){
        s = sv[i*2];
        REP(j,4){
            if(s[j] == '1'){
                m[i][j].RI = m[i][j+1].LE = 1;
            }
        }
    }
    for(int i = 0; i < 4; i++){
        s = sv[i*2+1];
        REP(j,5){
            if(s[j] == '1'){
                m[i][j].DW = m[i+1][j].UP = 1;
            }
        }
    }

    int nx = 0, ny = 0;
    int dir = 0;
    while(1){
        REP(i,4){
            int dir2 = (dir+1-i+4)%4;
            if(m[ny][nx].v[dir2]){
                printf("%c", str[dir2]);
                nx += movex[dir2];
                ny += movey[dir2];
                if(nx < 0 || nx >= 5 || ny < 0 || ny >= 5) throw;
                dir = dir2;
                break;
            }
        }
        if(nx == 0 && ny == 0) break;
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
    cin>>n>>m;
    if(n == m)
    {
    	cout<<"Yes";
    }
    else
    {
    	cout<<"No";
    }

}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")

int main()
{
	vector<int> a(4);
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	int ans = inf;
	sort(a.begin(), a.end());
	do
	{
		ans = min(ans, abs((a[0] + a[1]) - (a[2] + a[3])));
	} while (next_permutation(a.begin(), a.end()));

	cout << ans << "\n";
}


Measured memory_bytes: 3172
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
template<typename T>
vector<T> smallest_prime_factors(T n) {

	vector<T> spf(n + 1);
	for (int i = 0; i <= n; i++) spf[i] = i;


	for (T i = 2; i * i <= n; i++) {

		// 素数だったら
		if (spf[i] == i) {

			for (T j = i * i; j <= n; j += i) {

				// iを持つ整数かつまだ素数が決まっていないなら
				if (spf[j] == j) {
					spf[j] = i;
				}
			}
		}
	}

	return spf;
}
int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> mp;
	rep(i, 0, n)cin >> a[i];
	int g = a[0];
	rep(i, 1, n) {
		g = gcd(g, a[i]);
	}
	auto spf = smallest_prime_factors(1000000);
	bool pa = true;
	rep(i, 0, n) {
		while (1) {
			if (a[i] == 1)break;
			int v = spf[a[i]];
			if (mp[v])pa = false;
			mp[v]++;
			while (a[i] % v == 0) {
				a[i] /= v;
			}
		}
	}
	if (pa)puts("pairwise coprime");
	else if (g == 1)puts("setwise coprime");
	else puts("not coprime");
	return 0;
}


Measured memory_bytes: 14860
#include <bits/stdc++.h>
int main(void)
{
  long long s, c;
  std::cin >> s >> c;
  if(s >= c / 2)
    std::cout << c / 2 << std::endl;
  else
    std::cout << (s * 2 + c) / 4 << std::endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}



int main() {
  int H,W;
  cin >> H >> W;
  vector<string> g(H);
  rep(i,H) cin >> g[i];
  vector<vector<int>> memo(H,vector<int>(W,10000));
  memo[0][0]=0;
  rep(i,H){
    rep(j,W) {
      if (i>0) {if (g[i][j]==g[i-1][j]) chmin(memo[i][j],memo[i-1][j]);
      else chmin(memo[i][j],memo[i-1][j]+1);}
      if (j>0) {if (g[i][j]==g[i][j-1]) chmin(memo[i][j],memo[i][j-1]);
      else chmin(memo[i][j],memo[i][j-1]+1);}
    }
  }
  int res=memo[H-1][W-1];
  if (res%2==1) res = (res+1)/2;
  else if (g[0][0]=='#') res = res/2+1;
  else res/=2;
  cout << res << endl;
}

Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a,b,c,d=map(int,input().split())
ans=-float('inf')
ans=max(ans,a*c)
ans=max(ans,a*d)
ans=max(ans,b*c)
ans=max(ans,b*d)
print(ans)

Measured memory_bytes: 68200
n = int(input())

lst = []
for i in range(7):
    lst.append(6**i)
for i in range(1, 6):
    lst.append(9**i)

dp = [0]*100001
for i in range(1, n+1):
    candi = []
    for j in lst:
        if i >= j:
            candi.append(dp[i-j]+1)
    dp[i] = min(candi)
print(dp[i])

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
using namespace std;

void solve()
{
  ll k;
  cin >> k;
  ll ans = 0;
  for (ll i = 1; i <= k; ++i)
  {
    for (ll j = 1; j <= k;++j){
      for (ll r = 1; r <= k;++r){
        ll x = gcd(i, j);
        ll y = gcd(x, r);
        ans += y;
      }
    }
  }
  cout << ans;
}

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


Measured memory_bytes: 3648
x = int(input())

if 400<=x<600:
    print(8)
elif 600<=x<800:
    print(7)
elif 800<=x<1000:
    print(6)
elif 1000<=x<1200:
    print(5)
elif 1200<=x<1400:
    print(4)
elif 1400<=x<1600:
    print(3)
elif 1600<=x<1800:
    print(2)
elif 1800<=x<2000:
    print(1)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll s(n);
    rep(i,n) cin>>s[i];
    int L = n-1;
    ll ans=0;
    FOR(c,1,L/2){
        // cout<<"C = "<<c<<"\n";
        int u=0,v=n-1;
        ll sum=0;
        while(v>c && !(L%c==0 && u>=v)){
            sum+=s[u]+s[v];
            // cout<<sum<<" ("<<s[u]<<","<<s[v]<<")\n";
            chmax(ans,sum);
            u+=c; v-=c;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

int ans=0,n;
vector<int>s;

void binarysearch(int key){
        int left=0,right=n,mid;
        while(left<right){
                mid=(left+right)/2;
                if(s[mid]==key){
                        ans++;
                        return;
                }
                else if(key<s[mid])right=mid;
                else left=mid+1;
        }
        return;
}

int main(){
        cin>>n;
        s.resize(n);
        for(int i=0;i<n;i++)cin>>s[i];
        int q;
        cin>>q;
        vector<int>t(q);
        for(int i=0;i<q;i++){
                cin>>t[i];
                binarysearch(t[i]);
        }
        cout<<ans<<endl;
        return 0;
}



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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

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

    ll A[32] = {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};
    _PR(A[K-1]);

    return 0;
}

/*



*/

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

int main() {
	int N;
	int a;
	int output = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		bool repeat = true;
		while (repeat) {
			if (a % 2 == 0) {
				a = a / 2;
				output++;
			} else {
				repeat = false;
			}
		}
	}
	printf("%d", output);

	return 0;
}

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

namespace ABC_120
{
    class C
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int counter = 0;
            Stack<char> stack = new Stack<char>();

            for(int i = 0; i < S.Length; i++)
            {
                char c = S[i];

                if (stack.Count==0 || stack.Peek() == c)
                {
                    stack.Push(c);
                }
                else
                {
                    counter += 2;
                    stack.Pop();
                }

            }
            Console.WriteLine(counter);
        }

    }
}


Measured memory_bytes: 13232
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<time.h>
#include<random>
using namespace std;


//10のn乗
template<typename T>
constexpr  T pow10(int32_t n) {
	T ret = 1;
	for (int32_t i = 0; i < n; ++i) {
		ret *= 10;
	}
	return ret;
}


//桁数。０なら０を返す
constexpr  int32_t digits(int32_t v) {
	if (v < 0) v *= -1;

	if (v >= pow10<int32_t>(5)) {
		if (v >= pow10<int32_t>(7)) {
			if (v >= pow10<int32_t>(9)) return 10;
			if (v >= pow10<int32_t>(8)) return 9;
			return 8;
		}
		if (v >= pow10<int32_t>(6)) return 7;
		return 6;
	}
	if (v >= pow10<int32_t>(3)) {
		if (v >= pow10<int32_t>(4)) return 5;
		return 4;
	}
	if (v >= pow10<int32_t>(2)) return 3;
	if (v >= pow10<int32_t>(1)) return 2;
	if (v >= pow10<int32_t>(0)) return 1;
	return 0;
}

//桁数。０なら０を返す
constexpr  int32_t digits(int8_t v) {
	if (v < 0) v *= -1;

	if (v >= pow10<int8_t>(2)) return 3;
	if (v >= pow10<int8_t>(1)) return 2;
	if (v >= pow10<int8_t>(0)) return 1;
	return 0;
}

//ｎ桁目の数を返す。
template<typename T>
constexpr  int32_t digit(const T& value, int32_t n) {

	return (value / pow10<T>(n - 1)) % 10;
}

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

	int c[9][9];

	for (int i = 1; i <= 9; ++i) {
		for (int j = 1; j <= 9; ++j) {
			c[i - 1][j - 1] = 0;
		}
	}

	for (int i = 1; i <= n; ++i) {
		if(i % 10 > 0) c[digit(i, digits(i)) - 1][(i % 10) - 1]++;
	}

	uint64_t ret = 0;
	for (int i = 1; i <= 9; ++i) {
		for (int j = i; j <= 9; ++j) {
			ret += (uint64_t)c[i-1][j-1] * (uint64_t)c[j-1][i-1] * (i == j ? 1 : 2);
		}
	}

	cout << ret << endl;
}


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

int main() {
  int n, m, x;
  scanf("%d %d %d", &n, &m, &x);
  vector<vector<int>> ca(n, vector<int>(m));//c[i][0]にはci
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= m; j++) cin >> ca[i][j];
  }
  int ans = 1300000;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<12> s(tmp);
    vector<int> xij(m + 1, 0);//xij[0]に合計金額
    for(int i = 0; i < n; i++) {
      if(s.test(i)) {
        for(int j = 0; j < m + 1; j++) {
          xij[j] += ca[i][j];
        }
      }
    }
    bool flag = true;
    for(int i = 1; i <= m; i++) {
      if(xij[i] < x) {
        flag = false;
        break;
      }
    }
    if(flag == true) ans = min(ans,xij[0]);
  }
  if(ans == 1300000) cout << -1;
  else cout << ans;
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

int main() {
  int x, t;
  cin >> x >> t;
  if (x - t < 0) {
    cout << 0 << endl;
  } else {
    cout << x - t << endl;
  }
}

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

int N, mx;
vector<vector<pair<int, int>>> G;
vector<int> ans;

void dfs(int v, int pv, int c) {
  for (auto g : G.at(v)) {
    if (g.first == pv) continue;
    ans.at(g.second) = c++ % mx + 1;
    dfs(g.first, v, c);
  }
}

int main() {
  cin >> N;
  G.resize(N);
  ans.resize(N - 1);
  for (int i = 0, a, b; cin >> a >> b; i++)
    G.at(--a).push_back({--b, i}), G.at(b).push_back({a, i});
  for (auto g : G) mx = max(mx, (int) g.size());
  dfs(0, -1, 0);
  cout << mx << "\n";
  for (auto a : ans) cout << a << "\n";
}

Measured memory_bytes: 6912
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
typedef pair<int,int>P;
P s[500005];
int main()
{
     int n,m;
     scanf("%d%d",&n,&m);
     int maxn=0;
     for(int i=0;i<n;i++)
     {
          scanf("%d%d",&s[i].second,&s[i].first);
          maxn=max(maxn,s[i].second);
     }
     sort(s,s+n);
     long long sum=0;
     for(int i=n-1;i>=0;i--)
     {
          if(s[i].first<maxn) break;
          m-=s[i].first;
          sum++;
          if(m<=0) break;
     }
     if(m>0)
     {
          sum+=(m/maxn);
          if(m%maxn) sum++;
     }
     printf("%lld\n",sum);
}


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

long long f[405][405];
long long clz=1E9+7;
long long a[405],b[405];
long long n,c;
long long sm[405][405],p[405][405];

void init(){
    p[0][0]=1;
    scanf("%lld%lld",&n,&c);
    for(long long i=1;i<=n;++i){
        
        scanf("%lld",&a[i]);
    }
    for(long long i=1;i<=n;++i){
        scanf("%lld",&b[i]);
    }
    for(long long i=1;i<=400;++i){
        p[i][0]=1;
        sm[i][0]=1;
        for(long long j=1;j<=400;++j){
            p[i][j]=(p[i][j-1]*i)%clz;
        }
    }
    for(long long i=1;i<=400;++i){
        for(long long j=0;j<=400;++j){
            sm[i][j]=(sm[i-1][j]+p[i][j])%clz;
        }
    }
    memset(f,0,sizeof(f));
    f[0][0]=1;
    for(int i=1;i<=n;++i){
        for(int j=0;j<=c;++j){
            for(int k=0;k<=j;++k){
                long long t=(sm[b[i]][k]-sm[a[i]-1][k]+clz)%clz;
                f[i][j]=(f[i][j]+f[i-1][j-k]*t)%clz;
            }
        }
    }
    printf("%lld",f[n][c]);
}

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

Measured memory_bytes: 4224
import java.util.*;

public class Main
{
    static class Task
    {
        long a;
        long b;

        Task(long a, long b)
        {
            this.a = a;
            this.b = b;
        }


    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n;
        n = sc.nextInt();
        
        long sum = 0;
        int flag = 1;


        ArrayList<Task> taskArray = new ArrayList<Task>();

        for(int i = 0; i<n; i++)
        {
            taskArray.add(new Task(sc.nextLong(), sc.nextLong()));
        }
        taskArray.sort((task1,task2)->Long.compare(task1.b, task2.b));
        
        for( int i = 0; i<n; i++)
        {
            sum += taskArray.get(i).a;

            if(sum > taskArray.get(i).b)
            {
                flag = 0;
                break;
            }

        }

        if(flag == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}



Measured memory_bytes: 112936
import java.util.Scanner;

/**
 * C - management
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 社員数
        int n = sc.nextInt();
        // 社員番号
        int[] a = new int[n];
        for( int i = 1; i < n; i++ ) {
            int member = sc.nextInt();
            a[member - 1]++;
        }

        // 結果：それぞれの直属の部下の人数
        for( int i = 0; i < n; i++ ) {
            System.out.println( a[i] );
        }

        sc.close();
    }
}


Measured memory_bytes: 62340
N, A, B = map(int, input().split())
s = 0
for i in range(1,N+1):
  a = i%10
  b = (i//10)%10
  c = (i//100)%10
  d = (i//1000)%10
  e = (i//10000)%10
  f = (a+b+c+d+e)
  if A <= f <= B:
    s += i
print(s)

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;



public class Main {

	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod=(int)1e9+7;
	static ArrayList<Integer> gr[];
	static int ar[][];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	//static long dp[];

	public static void main(String[] args) throws IOException {
		int t =1;// sc.nextInt();
		
		while (t-- > 0) {
			int n=sc.nextInt();
			
			ar=new int[n+1][4];
			for(int i=1;i<=n;i++) {
				for(int j=1;j<=3;j++)
				ar[i][j]=sc.nextInt();
			}
		
		System.out.println(solve(n));
		}

	}
	
	static long solve(int n) {
		long dp[][]=new long[n+1][4];
		dp[0][0]=0;
		for(int i=1;i<=n;i++) {
			for(int j=1;j<=3;j++) {
				long sum=Integer.MIN_VALUE;
				for(int k=1;k<=3;k++) {
					if(k!=j)sum=Math.max(sum,dp[i-1][k]);
					
				}
				dp[i][j]=ar[i][j]+sum;
			}
		}
		
		return Math.max(dp[n][1], Math.max(dp[n][2], dp[n][3]));
		
	}


}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
  ll H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  ll start = H1*60 + M1;
  ll end = H2*60 + M2;
  PRINT(end-K-start);
  return 0;
} 


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

int main() {
  int N, s;
  string a;
  cin>>N;
  vector<tuple<string, int, int>> p(N);

  for (int i=0;i<N;i++){
    cin>>a>>s;
    p.at(i)=make_tuple(a, 100-s, i+1);
  }
  sort(p.begin(), p.end());

  for (tuple<string, int, int> t : p) {
    string x;
    int y, z;
    tie(x, y, z) = t;
    cout << z << endl;
  }
}


Measured memory_bytes: 256
n,k,s=map(int,input().split())
a=[s]*k
b=[3]*(n-k)+[s]*k
p=max(s//2-1,1)
for i in range(n-k):
    if i%p==0:
        a.append(s-1)
    else:
        a.append(2)
if s!=2 and s!=1:
    print(*a)
else:
    print(*b)

Measured memory_bytes: 7268
<?php

$dict = array('A' => 0, 'B' => 0, 'AB' => 0, 'O' => 0);
while (true) {
    $a = explode(',', rtrim(fgets(STDIN)));
    if (feof(STDIN)) {
        break;
    }
    $dict[$a[1]]++;
}
foreach ($dict as $v) {
    echo $v . PHP_EOL;
}

Measured memory_bytes: 6600
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    map<string,ll>mp;
    ll ans = 0;
    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    for(auto x : mp)ans += x.second * (x.second - 1);
    cout << ans / 2 << endl;
}

Measured memory_bytes: 11136
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main{
	public static String toBinary(int x){
		String s = Integer.toBinaryString(x);
		for(int i = s.length(); i < 6; i++){
			s = "0" + s;
		}
		return s;
	}
    
	public static void main(String[] $){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < N; i++){
			list.add(sc.nextInt());
		}

		Collections.sort(list, Collections.reverseOrder());
		long sum = 0;
		for(int i = 0; i < N/2; i++){
			sum = sum + list.get(i);
		}
		for(int i = 1; i < N/2+N%2; i++){
			sum = sum + list.get(i);
		}
		
		System.out.println(sum);
		
	}
} 

Measured memory_bytes: 64984
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  unordered_map<int, int> p;
  int n, k, a[100010], q;
  cin >> n >> k >> q;
  for (int i = 0; i < q; ++i) cin >> a[i];
  for (int i = 0; i < q; ++i) ++p[a[i] - 1];
  for (int i = 0; i < n; ++i)
    if (k - q + p[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
}


Measured memory_bytes: 7716
// 全探索（next_permutation）
// 100*D + 10*(B+E) + (A+C+F) = 100*G + 10*H + I

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	vector<int>input(9);
	for (int i = 0; i < 9; i++)cin >> input[i];

	int ret = 0;
	vector<int>v{ 1,2,3,4,5,6,7,8,9 };

	do {
		bool can = true;
		for (int i = 0; i < 9; i++) {
			if (input[i] > 0 && input[i] != v[i]) {
				can = false;
				break;
			}
		}
		if (!can)continue;

		if (v[0] + 10 * v[1] + v[2] + 100 * v[3] + 10 * v[4] + v[5] == 100 * v[6] + 10 * v[7] + v[8])ret++;
	} while (next_permutation(v.begin(), v.end()));

	cout << ret << endl;
	return 0;
}


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

int main(){
  int N, Y;
  int k;
  cin >> N >> Y;
  //iが1万円札, jが5千円札, kが千円札とする．
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
	  if(i+j>N) break;
	  k = N-i-j;
	  if(i*1000+j*5000+k*10000==Y){
	    cout << k << " " << j << " " << i << endl;
	    return 0;
	  }
	  /*
	  for(int k=0;k<=N;k++){
		// i, jが決定するとkの数は自動的に決まる(k=N-i-j)
		
		if(i+j+k>N) break;
	    if(i*1000+j*5000+k*10000 > Y) break;
		if(i*1000+j*5000+k*10000==Y){
	      if(i+j+k==N){
		    cout << k << " " << j << " " << i << endl;
	        return 0;
		  }
		}
		
	  }*/

	}
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int M = N * A;
  if (M >= B) {
    cout << B << endl;
  }
  if (M < B) {
    cout << M << endl;
  }
 
    
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, int> pli;
typedef vector<pli> vli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

const int P = 131;
const int P1 = 3124;
const int mod = 900000007;
vl pw(1000001, 1);
vl pw1(pw.size(), 1);

pli nx(pli x, char t) {
  return {x.first * P + t, (x.second * (ll)P1 + t) % mod};
}

vli mhash(const string & s) {
  vli h(s.size() + 1);
  if (pw.size() < h.size()) {
    pw.resize(h.size());
    pw1.resize(h.size());
  }
  for (int i = 0; i < s.size(); ++i) {
    h[i+1] = nx(h[i], s[i]);
    pw[i+1] = pw[i] * P;
    pw1[i+1] = pw1[i] * P1 % mod;
  }
  return h;
}

int up(int x) {
  if (x < 0) return x + mod;
  return x;
}

pli geth(const vli& v, int b, int len) {
  return pli(v[b+len].first - pw[len] * v[b].first, up((v[b+len].second - pw1[len] * v[b].second) % mod));
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vs s(n);
  vector<vli> h(n);
  set<pli> was;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    reverse(s[i].begin(), s[i].end());
    h[i] = mhash(s[i]);
    was.insert(h[i].back());
  }
  ll res = 0;
  for (int i = 0; i < n; ++i) {
    vi c(26);
    for (int j = s[i].size() - 1; j >= 0; --j) {
      ++c[s[i][j] - 'a'];
      if (j == s[i].size() - 1) continue;
      for (int t = 0; t < 26; ++t) if (c[t]) {
        pli x = nx(h[i][j], 'a' + t);
        if (was.count(x)) {
          res += 1;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 63548
//Love and Freedom.
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<bitset>
#define inf 20021225
#define ll long long
#define mxn 2100
using namespace std;

int n,s[mxn],a[mxn];
bitset<4000500> b;
int main()
{
	int sum = 0;
	scanf("%d",&n); b[0]=1;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),b|=b<<a[i],sum+=a[i];
	sum = (sum+1)>>1;
	while(!b[sum])	sum++;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1664
import sys
readline = sys.stdin.readline
write = sys.stdout.write

fmt = "{:5d}".format
def solve():
    N = int(readline())
    if N == 0:
        return False
    A = [list(map(int, readline().split())) for i in range(N)]
    for ln in A:
        write("".join(map(fmt, ln)))
        write(fmt(sum(ln)))
        write("\n")
    b = [sum(A[i][j] for i in range(N)) for j in range(N)]
    write("".join(map(fmt, b)))
    write(fmt(sum(b)))
    write("\n")
    return True
while solve():
    ...


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

int main(){
	int x,y,w,h,r;
	cin >> w >> h >> x >> y >> r;
	
	if((x<=w-r)&&(x>=r)&&(y<=h-r)&&(y>=r )) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int n; cin >> n;
    vi v(n);
    int sum = 0;
    forn(n) {cin >> v[i]; sum += v[i]; }
    v.push_back(0);
    sort(all(v));
    for(int i = 0; i < n; i++) {
        sum -= v[i];
        if(sum % 10) {
            cout << sum;
            return 0;
        }
        sum += v[i];
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w[10],a,b,i;
  double t,d;
  while(cin>>w[0]){
  for(i=1;i<10;i++)scanf(",%d",&w[i]);
  int sum[10]={0};
  sum[0]=w[0];
  for(i=1;i<10;i++)sum[i]+=sum[i-1]+w[i];
  scanf(",%d,%d",&a,&b);
  t=(double)sum[9]/(a+b);
  d=(double)t*a;
  for(i=0;i<10;i++)if(d<=sum[i]){
    cout<<i+1<<endl;
    break;
  }
  }
}

Measured memory_bytes: 3140
import sys
from collections import defaultdict as dd
input = sys.stdin.readline

N = int(input())
d = list(map(int, input().split()))
mod = 998244353

if d[0] > 0:
  print(0)
  exit(0)
e = dd(int)
e[0] = 1
for i in range(1, N):
  if d[i] == 0:
    print(0)
    exit(0)
  e[d[i]] += 1
res = 1
for k in range(1, max(e.keys()) + 1):
  res *= pow(e[k - 1], e[k], mod)
  res %= mod
  #print(res)
print(res % mod)

Measured memory_bytes: 61988
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int N;
	cin >> N;
	vector<vector<pair<int,int>>>tree(N);
	vector<int>weight(N);
	rep(i, N - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		tree[u].push_back(make_pair(v,w));
		tree[v].push_back(make_pair(u,w));
	}

	vector<int>answer(N, -1);
	stack<pair<int, int>>dfs;
	dfs.push(make_pair(0, 0));
	while (!dfs.empty()) {
		auto p = dfs.top();
		dfs.pop();
		answer[p.first] = p.second;
		for (auto x : tree[p.first])if(answer[x.first] ==-1) {
			if (x.second % 2) {
				dfs.push(make_pair(x.first, p.second ^ 1));
			}
			else {
				dfs.push(make_pair(x.first, p.second));
			}
		}
	}
	rep(i, N)cout << answer[i] << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  set<int> ans;
  for(int i=0;i<n;i++) {
    int a;
    cin >> a;
    ans.insert(a);
  }
  cout << ans.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
vi c[N];  // color to vertices
vi g[N];
int s[N], t[N];  // in and out in the euler tour
int u[2*N];  // Euler tour
int d[N] = {}, w[N];  // depth, weight
int dfs(int a, int p, int k){
	u[k] = a;
	s[a] = k++;
	w[a] = 1;
	for(auto &i : g[a]){
		if(i == p) continue;
		d[i] = d[a] + 1;
		k = dfs(i, a, k);
		w[a] += w[i];
	}
	u[k] = a;
	t[a] = k++;
	return k;
}
set<int> st;

int main(){
	int n; scanf("%d", &n);
	FOR(i, 1, n+1){
		int a; scanf("%d", &a);
		c[a].EB(i);
	}
	REP(i, n-1){
		int a, b; scanf("%d%d", &a, &b);
		g[a].EB(b);
		g[b].EB(a);
	}
	g[0].EB(1);
	g[1].EB(0);
	dfs(0, -1, 0);

	REP(i, (n+1)*2) DEBUG("%2d ",   i ); DEBUG("\n");
	REP(i, (n+1)*2) DEBUG("%2d ", u[i]); DEBUG("\n");

	FOR(k, 1, n+1){
		c[k].EB(0);
		sort(ALL(c[k]), [](auto &x, auto &y){ return d[x] > d[y]; });
		DEBUG("k=%d\n", k);
		ll ans = 1LL * n * (n+1) / 2;
		for(auto &i : c[k]){
			st.emplace(t[i]);
			DEBUG(" i=%d\n", i);
			for(int &j : g[i]){
				if(d[i] > d[j]) continue;
				ll z = w[j];
				for(auto it = st.upper_bound(s[j]); *it <= t[j]; ){
					DEBUG("   *it = %d\n", *it);
					z -= w[u[*it]];
					it = st.erase(it);
				}
				DEBUG("   %d: %lld\n", j, z);
				ans -= z * (z+1) / 2;
			}
		}
		printf("%lld\n", ans);
	}
}



Measured memory_bytes: 46776
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
   vector<string>vec(a);
   for(int i=0;i<a;i++)
{
    cin>>vec.at(i);
}
sort(vec.begin(),vec.end());
for(int j=0;j<a;j++){
    cout<<vec.at(j);
}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
//#define bint int1024_t
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define F first
#define pll pair<ll,ll>
#define S second
#define pi 3.1415926536
#define mod int(1e9+7)
//ios_base::sync_with_stdio(false);cin.tie(NULL);
#define testcases ll t; cin>>t; while(t--)

using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

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

    string s,t;
    cin>>s>>t;
    if(t.substr(0,s.length())==s) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3668
#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 pb push_back

const int N = 1e5 + 10;
typedef pair<int, int> ii;
int n, cnt;
int a[N];
bool visit[N];
set<int> yes, no;
ii eg[N];

void bad()  {
    cout << "-1"; exit(0);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s; cin >> s;
    n = s.length();
    FOR(i, 0, n - 1)    {
        char x = s[i];
        if(x == '0') no.insert(i + 1), no.insert(n - i - 1);
        else yes.insert(i + 1), yes.insert(n - i - 1);
    }
    if(yes.find(n) != yes.end()) bad();

    for(auto it = no.begin(); it != no.end(); ++it) {
        if((*it) == 1 || yes.find(*it) != yes.end()) bad();
    }
    visit[1] = true;
    int cur = 1, ver = 1, nex = 1;
    while(cur < n)  {
        if(no.find(cur) != no.end()) {
            while(nex < n && visit[nex]) nex ++;
            visit[nex] = true;
            eg[++cnt] = ii(ver, nex);
            cur += 1;
        } else {
            while(nex < n && visit[nex]) nex ++;
            cur += 1;
            eg[++cnt] = ii(ver, nex);
            visit[nex] = true;
            ver = nex;
        }
    }
    FOR(i, 1, cnt) cout << eg[i].fi << ' ' << eg[i].se << '\n';
}



Measured memory_bytes: 7120
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int p=0,f=1; char c=getchar();
	while(c<'0'||c>'9'){ if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ p=(p<<3)+(p<<1)+(c^48); c=getchar();}
	return f*p;
}
int n,h[21],maxx[21],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
		if(maxx[i-1]<=h[i]){
			ans++;
			maxx[i]=h[i];
		}
		else maxx[i]=maxx[i-1];
	}
	printf("%d",ans);
	return 0;
}

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

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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define int long long int
#define all(v) v.begin(),v.end()
#define ov(v) for(int i=0;i<(v).size();i++)cout<<v[i]<<" ";cout<<endl;
#define N 10000
using namespace std;
void solve()
{
	int n;
	cin>>n;
	vector<int>v(n);
	int mx,x,ans = 0;
	cin>>mx;
	for(int i = 1;i<n;i++)
	{
		cin>>x;
		ans+=max(0LL,mx-x);
		mx = max(x,mx);
	}
	cout<<ans<<endl;

}
signed main() 
{
	// int t;
	// cin>>t;
	// while(t--)
	solve();
	return 0; 
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z>>w;
if(x<=y){
  std::cout << x*z << '\n';
}else{
  std::cout << y*z+w*(x-y) << '\n';
}
}


Measured memory_bytes: 256
def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int,ss_raw()))

N = int_raw()
poss = []
for i in range(5):
    p = int_raw()
    poss.append(p)

def main():
    minp = min(poss)
    return ((N+minp-1)//minp)+4

print(main())


Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  int d,g;
  cin >> d >> g;
  vector<int> p(d);
  vector<int> c(d);
  for(int i=0;i<d;i++){
    cin >> p[i] >> c[i];
  }
  int res=10000;
  for(int i=0;i<(1<<d);i++){
    vector<int> pm(3000);
    ll sum=0;
    int ct=0;
    for(int j=0;j<d;j++)
      if((1&(i>>j))){
        ct+=p[j];
        sum+=c[j];
        sum+=100*(j+1)*p[j];
      }else
        for(int k=0;k<p[j];k++)
          pm.push_back(100*(j+1));
    sort(pm.begin(),pm.end());
    int index=pm.size()-1;
    while(index!=-1&&sum<g){
      ct++;
      sum+=pm[index--];
    }
    res=min(res,ct);
  }
  cout << res << endl;
}

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


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

int main(){

    int n, m; cin >> n >> m;
    string s; cin >> s;
    ull hash[300010];
    ull po[300010];
    hash[0] = 0;
    po[0] = 1;
    int l = 0, r = 1;
    for(int i = 1; i <= n; i++){
        po[i] = po[i - 1] * B;
        hash[i] = hash[i - 1] * B + (ull)(s[i - 1] - 'a' + 1);
    }
    
    set<ull> S;

    while(m--){
        string in; cin >> in;

        if(in == "L++") l++;
        if(in == "R++") r++;
        if(in == "L--") l--;
        if(in == "R--") r--;        
        
        ull H = hash[r] - hash[l] * po[r - l];
        S.insert(H);
    }
    
    cout << S.size() << endl;

    return 0;
}


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

int main() {
	int n, y, a=-1, b=-1, c=-1;
	cin >> n >> y;
	int flag=0;
	for (int i = 0;i <= n;i++) {
		for (int j = 0;j <= n - i;j++) {
			if (y == 10000 * i + 5000 * j + 1000 * (n - i - j)) {
				a = i;b = j;c = n - i - j;
				flag = 1;
			}
			if (flag)break;
		}
		if (flag)break;
	}
	cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2==1){
    cout << "No" << "\n";
    return 0;
  }
  else if(s.substr(0,n/2)==s.substr(n/2,n)){
    cout << "Yes" << "\n";
    return 0;
  }
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3560
from math import hypot

x1, y1, x2, y2 = map(int, input().split())
dx, dy = x2-x1, y2-y1
vector_base = hypot(dx, dy)
q = int(input())

for i in range(q):
    x3, y3 = map(int, input().split()) 
    d = ((x3-x1)*dx + (y3-y1)*dy) / (vector_base**2)
    print(x1+dx*d, y1+dy*d)


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

int main(){
 int n, k;
 cin >> n >> k;
 int ans = 0;
 //vector<int> d;
 while(n > 0) {
   //d.pushback(n%k);
   n /= k;
   ans++;
 }
  cout << ans << endl;
}
   


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

const ll INF = 1LL << 60;

ll dp[110000];
ll h[110000];

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

    ll n,k;
    cin >> n >> k;
    
    rep(i,n) cin >> h[i];
    
    for(int i = 0; i < 110000; i++) dp[i] = INF;
    
    dp[0] = 0;
    
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j],dp[i] + abs(h[i] - h[i + j]));
        }
    }
    
    cout << dp[n - 1] << endl;
    
}

Measured memory_bytes: 1920