akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


void print_vec(vll a)
{
	cout << "start printing the vector\n";
	for (ll i = 0; i < a.size(); i++)
		cout << a[i] << " ";
	cout << "\n";
}
void print_mat(vector<vll> a)
{
	cout << "start printing the matrix\n";
	for (ll i = 0; i < a.size(); i++)
	{
		for (ll j = 0; j < a[i].size(); j++)
		{
			cout << a[i][j] << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	ll n;
	cin >> n;
	vll arr(n + 1, 0);
	for (ll i = 1; i < 100; i++)
	{
		for (ll j = i; j < 100; j++)
		{
			for (ll k = j;; k++)
			{
				ll val = i * i + j * j + k * k + i * j + i * k + k * j;
				if (val <= n)
				{
					set<ll> st;
					st.insert(i);
					st.insert(j);
					st.insert(k);
					ll  p = st.size();
					if (p == 1)
					{
						arr[val] += 1;
					}
					else if (p == 2)
					{
						arr[val] += 3;
					}
					else
					{
						arr[val] += 6;
					}
				}
				else
					break;

			}
		}
	}
	for (ll i = 1; i <= n; i++)
	{
		cout << arr[i] << "\n";
	}
}

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(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes";
  else
     cout<<"No";
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll q=1;
  for(ll i=1;i<=q;i++)
    solve();
}

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

#define INF 1e18
#define PI 3.141592653589793238
typedef long long ll;
#define N 100010

int main() {
    int n,m,h[N],ma[N];cin>>n>>m;
    for(int i=1; i<=n; i++){
        cin>>h[i];
        ma[i]=0;
    }
    for(int i=0; i<m; i++){
        int a,b;cin>>a>>b;
        ma[a]=max(ma[a], h[b]);
        ma[b]=max(ma[b], h[a]);
    }
    int ans=0;
    for(int i=1; i<=n; i++){
        if(h[i]>ma[i]) ans++;
    }
    cout<<ans<<endl;


    return 0;
}

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

using namespace std;

int gcd(int x, int y) {
  while (y) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        int foo = gcd(i, j);
        foo = gcd(foo, k);
        sum += (long long)foo;
      }
    }
  }
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k;
  cin >> k;
  k--;
  char c = s.at(k);
  rep(i, s.size()){
    if(s.at(i) == c) cout << s.at(i);
    else cout << '*';
  }
  cout << endl;
  return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	ll x[n]={0};
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		x[l-1]++;
		x[r]--;
	}
	ll s=0;
	for(int i=0;i<n;i++){
		s+=x[i];
		x[i]=s;
		// cout<<x[i]<<" ";
	}
	ll cnt=0;
	for(int i=0;i<n;i++){
		if(x[i]==m){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int n;
	cin >> n;
	ll ans = 1;
	repr(i, 1, n+1) {
		ans *= i;
		ans = ans%MOD;
	}

	cout << ans << endl;

	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++)
template <typename T>
inline bool chmin (T& a, T b)
{
  if(a > b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  long long N;
  cin >> N;
  vector<long long> h (N);
  rep(i, N)
  {
    cin >> h[i];
  }
  vector<long long> dp (N, INFINITY);
  dp[0] = 0;

  for(long long i = 1; i < N; i++)
  {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  //for(long long x : dp) cout << x << " ";
  cout << dp[N-1] << endl;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int A[5];

int main()
{
    REP(i, 5)
    {
        cin >> A[i];
    }
    sort(A, A + 5);
    int k;
    cin >> k;
    if (A[4] - A[0] <= k)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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 (b<a) { a=b; return 1; } return 0; }


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

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
using ll = long long;

int main() {
	ll n, p;
	cin >> n >> p;
	ll r = 1;
	if(n == 1){r = p;}
	else{
		for(ll i = 2; i*i <= p; i++){
			ll c = 0;
			while(p%i == 0){
				p /= i;
				c++;
			}
			r *= pow(i, c/n);
		
		}
	}
	cout << r;
	return 0;
}

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

using namespace std;

long long n,s,k,mx,fs,sc,i,t[1000005];
long long e,e1;


int main() 
{
    cin>>n;
    for (i=1; i<=n; i++)
        cin>>t[i];
    sort(t+1,t+n+1);
    for (i=n; i>1 && (!e || !e1); i--)
        if (t[i]==t[i-1])
        {
            if (!e) e=t[i],i--; else e1=t[i],i--;
        }
    cout<<e*e1;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
const int MAX=1e9+7;
const int mod=1e9+7;
#define INF 0x3f3f3f3f
#define ll long long
int s[10],c[10],a[10];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n, m, ans[] = { 10,10,10 }; cin >> n >> m;
	int x, y;
	bool flag = false;
	for(int i=0;i<m;i++) {
		cin >> x >> y;
		if (ans[x - 1] != 10 && ans[x - 1] != y) flag = true;
		else ans[x - 1] = y;
	}
	if (ans[0] == 0 && n != 1 || flag)cout << -1;
	else {
			for(int i=0;i<n;i++) {
			if (i == 0 && ans[0] == 10 && n!= 1)cout << 1;
			else if (ans[i] == 10)cout << 0;
			else cout << ans[i];
		}
	}
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    vector<long long> a(n);
    for(long long i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    cout<<a[0];
    for(long long i=1;i<a.size();i++){
        cout<<" "<<a[i];
    }   
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3548
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  for(int c=1,w; cin>>w,w; c++){
    int n,tr[1001][2] = {0};
    cin >>n;
    for(int i=1; i<=n; i++){
      scanf("%d,%d",&tr[i][0],&tr[i][1]);
    }
    int dp[1001][1001] = {0};
    for(int i=1; i<=n; i++){
      for(int j=0; j<=w; j++){
	if(j>=tr[i][1]){dp[j][i] = max(dp[j][i-1],dp[j-tr[i][1]][i-1]+tr[i][0]);}
	else{dp[j][i] = dp[j][i-1];}
      }
    }
    int pr = dp[w][n], val;
    for(int j=0; j<=w; j++){
      if(pr == dp[j][n]){val = j;break;}
    }
    cout <<"Case "<<c<<":"<<endl;
    cout <<pr<<endl<<val<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
/* 
要するにWW....BBの形になったら終わり
一回の試行でWが一個左にずれると考えれば良い
左から数えてn番目のWは自分のインデックス- (n - 1)回で規定の位置に来る
あとは総和を求めるだけ
*/

#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  string S;
  cin >> S;
  
  long long ans = 0;
  long long Wcount = 0;
  for(long i = 0; i < S.length(); ++i)
  {
    if(S[i] == 'W')
    {
      ans += i - Wcount;
      ++Wcount;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

const int T = 5000;
//const int T = 10;
int N,K;
bitset<T> bef[T+10],aft[T+10];
int a[T+10];

int main(){
	cin>>N>>K;
	REP(i,N)cin>>a[i];
	bef[0].set(0);
	REP(i,N){
		bef[i+1] = (bef[i] | (bef[i]<<a[i]));
//		cout<<bef[i+1]<<endl;
	}
	aft[N].set(0);
	for(int i=N-1;i>=0;i--){
		aft[i] = (aft[i+1] | (aft[i+1]<<a[i]));
//		cout<<aft[i]<<endl;
	}
	int ans = 0;
	REP(i,N){
		bool found = false;
		//judge bef[i] and aft[i+1]
		//using a[i]
		//K-a[i] <= b < K
		int mini = max(K-a[i],0);
		//start: [mini, K)
		int l = mini, r = K;
		int c = 0;
		for(int t = mini;t<K;t++){
			if(aft[i+1].test(t))c++;
		}
		for(int j=0;j<K;j++){
			if(bef[i].test(j) and c>0){
				found = true;
				break;
			}
			l--;r--;
			if(l>=0 and aft[i+1].test(l))c++;
			if(r>=0 and aft[i+1].test(r))c--;
		}
		if(found){
			ans++;
		}
	}
	ans = N-ans;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

struct uf_tree {
    std::vector<int> parent;
    int __size;
    uf_tree(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (parent[y] < parent[x]) std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() { return __size; }
};

signed main() {
    int n;
    while (cin >> n && n) {
        vector<pair<int, int>> ps(n);
        vector<pair<int, int>> ps2(n);
        rep(i, n) {
            int x, y;
            cin >> x >> y;
            ps[i] = make_pair(x, i);
            ps2[i] = make_pair(y, i);
        }
        sort(all(ps));
        sort(all(ps2));
        vector<tuple<int,int,int>> es;
        rep(i, n - 1) {
            int dx = ps[i + 1].first - ps[i].first;
            int a = ps[i].second;
            int b = ps[i + 1].second;
            es.emplace_back(dx, a, b);
        }
        rep(i, n - 1) {
            int dy = ps2[i + 1].first - ps2[i].first;
            int a = ps2[i].second;
            int b = ps2[i + 1].second;
            es.emplace_back(dy, a, b);
        }
        sort(all(es));

        int ans = 0;
        uf_tree t(n);
        for (auto &e : es) {
            int w, a, b;
            tie(w, a, b) = e;
            // dump(w, a, b);
            if (!t.is_same(a, b)) {
                t.unite(a, b);
                dump(w, a, b);
                ans += w;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 11632
#include <iostream>
#include <cstdio>
#include <stack>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
//#include <unordered_map>
#define N 1000010
//#define lson x<<1
//#define rson x<<1|1
//#define mid ((lt[x].l+lt[x].r)/2)
//#define ID(x, y) ((x)*m+(y))
//#define CHECK(x, y) ((x)>=0 && (x)<n && (y)>=0 && (y)<m)
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL INF=0x3f3f3f3f;
void Open()
{
    #ifndef ONLINE_JUDGE
        freopen("F:/in.txt","r",stdin);
        //freopen("F:/my.txt","w",stdout);
    #endif // ONLINE_JUDGE
}
LL n, ans;
LL w[N], l[N], sum[N];
vector<LL> G[N];
LL lis[N];
LL dfs(LL u, LL fa)
{
    sum[u] = w[u];
    for(LL i = 0; i < G[u].size(); i++)
    {
        LL v = G[u][i];
        if(v == fa) continue;
        sum[u] += dfs(v, u);
    }
    LL tail = 0;
    for(LL i = 0; i < G[u].size(); i++)
    {
        LL v = G[u][i];
        if(v == fa) continue;
        lis[tail++] = sum[v];
    }
    sort(lis, lis+tail);
    for(LL i = tail-2, cnt = 1; i >= 0; i--, cnt++)
    {
        ans += lis[i]*cnt;
    }
    return sum[u];
}
int main2()
{
//    Open();
    scanf("%lld", &n);
    for(LL i = 0; i < n; i++){
        scanf("%lld%lld", &w[i], &l[i]);
        if(l[i] != -1) G[l[i]].push_back(i);
    }
    ans = 0;
    for(LL i = 0; i < n; i++)
    {
        if(l[i] == -1) dfs(i, -1);
    }
    printf("%lld\n", ans);
    exit(0);
}
extern int main2(void) __asm__ ("_main2");
int main()
{
    int size = 200 << 20;  // 256Mb
    char *p = (char *)malloc(size) + size;
    __asm__ __volatile__(
        "mov  %0, %%rsp\n"		//??????????????¶????????\??????bad register name '%rsp'????????¶??????????°?rsp??¢???esp?°±??????(???????°±??????????????????????????¨?????¨???????????°???????????????)
        "push $_exit\n"
        "jmp _main2\n"
        :: "r"(p));
    return 0;
}

Measured memory_bytes: 129256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=lin(5)
num=min(arr)
if n <=num:
    print(5)
else:
    print(4+ceil(n/num))

Measured memory_bytes: 63340
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    Scanner obj = new Scanner(System.in);
    while(true){
      int a = obj.nextInt();
      char op = obj.next().charAt(0);
      int b = obj.nextInt();
     
      if(op == '+'){
        System.out.println(a + b);}
      else if(op == '-'){
        System.out.println(a - b);}
      else if(op == '*'){
        System.out.println(a * b);}
      else if(op == '/'){
        System.out.println(a / b);}
      else{
        break;}
    }
  }
}

Measured memory_bytes: 26376
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  double n;
  cin >> n;
  
  if(n==1) cout << 1 << endl;
  else if(n!=2*floor(n/2)) cout << (n-floor(n/2))/n << endl;
  else cout << n/n/2 << endl;
 
  
}

Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    
    if n == 0:
        print(0)
        sys.exit()

    ans = ""
    while n:
        if n%2:
            n -= 1
            ans += "1"
        else:
            ans += "0"
        n //= (-2)

    print(ans[::-1])


if __name__ == "__main__":
    main()

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

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

  vector<long long> v(N + 1, 0);
  for (int i = 0; i < N; i++) v[i + 1] = a[i] + v[i];

  long long ans = 2000000010;
  for (int i = 1; i < N; i++) {
    long long x = v[i];
    long long y = v[N] - x;
    ans = min(ans, abs(x - y));
  }

  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
    char s[100],s1[100];
    cin>>s;
    int j,lung=0;
    for(int i=0; i<strlen(s); i++){
        s1[i]='2';
        if(s1[i]=='B'&&i==0){
            continue;
        }
        else{
        if(s[i]=='0'){
            s1[i]='0';
        }
        else if(s[i]=='1'){
            s1[i]='1';
        }
        else{
            lung=0;
            j=i;
            while(s[j]=='B'){
                lung++;
                j++;
            }
            for(j=i-1; j>=i-lung; j--){
                s1[j]='2';
            }
        }
    }
    }
    for(int i=0; i<strlen(s); i++){
        if(s1[i]!='2'){
            cout<<s1[i];
        }
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N=int(input())
tasks=[list(map(int,input().split())) for i in range(N)]
able_finish = 'Yes'
time = 0
ts = tasks
ts.sort(key=lambda x:x[1])
for t in ts:
  time += t[0]
  #print(time,t[0],t[1])
  if time >t[1]:
    able_finish = 'No'
print(able_finish)    

Measured memory_bytes: 62588
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){
    if(b==0)
    return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;base%=mod;
        pow/=2;
    }return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}

const int M = 2e5 + 5;

int arr[4][4];
set<int> se;

int main(){

    for(int i = 1 ; i <= 3 ; i++){
        for(int j = 1 ; j <= 3 ; j++){
            si(arr[i][j]);
        }
    }
    int n;
    si(n);

    for(int i = 1 ; i <= n ; i++){
        int el;
        si(el);
        se.insert(el);
    }

    // rows
    for(int i = 1 ; i <= 3 ; i++){
        bool ok = true;
        for(int j = 1 ; j <= 3 ; j++){
            if(se.count(arr[i][j]) == 0){
                ok = false;
            }
        }
        if(ok){
            cout<<"Yes";
            return 0;
        }
    }

    // cols
    for(int j = 1 ; j <= 3 ; j++){
        bool ok = true;
        for(int i = 1 ; i <= 3 ; i++){
            if(se.count(arr[i][j]) == 0){
                ok = false;
            }
        }
    if(ok){
            cout<<"Yes";
            return 0;
        }
    }

    bool ok = true;

    for(int i = 1 ; i <= 3 ; i++){

            if(se.count(arr[i][i]) == 0){
                ok = false;
            }

    }
    if(ok){
            cout<<"Yes";
            return 0;

    }


    ok = true;

    int j = 3;
    for(int i = 1 ; i <= 3 ; i++){

            if(se.count(arr[i][j]) == 0){
                ok = false;
            }
        j--;
    }


    if(ok){
            cout<<"Yes";
            return 0;
        }

    cout<<"No";


}



Measured memory_bytes: 256
import math
a,b,c,d=map(int,input().split())
mc = b//c-(a-1)//c
md = b//d-(a-1)//d
cd = (c*d)//math.gcd(c,d)
mcd = b//cd - (a-1)//cd

print(b-a+1 - mc-md+mcd)


Measured memory_bytes: 9024
mod = 10**9 + 7
h, w = list(map(int, input().split()))

def solve(h, w):
    prev = [None, 1] + [0]*(w-1)

    for _ in range(h):
        line = input()
        # print('line: ', line)
        next = [0] + [None]*w
        for j in range(w):
            if line[j] == '.':
                next[j+1] = (prev[j+1] + next[j]) % mod
            else:
                next[j+1] = 0
        prev = next

        # print(_, next)
    return next[-1]

print(solve(h, w))

"""
"""


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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int zero,one;
  zero=0;
  one=0;  
  for (int i=0;i<n;i++){
    if (s[i]=='0'){
      zero++;
    }
    if (s[i]=='1'){
      one++;
    }
  }
  cout << min(one,zero)*2 << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

int div[16]={1,5,3,3,3,3,3,4,3,4};
char dict[16][16]={
  "*",
  ".,!? ",
  "abc",
  "def",
  "ghi",
  "jkl",
  "mno",
  "pqrs",
  "tuv",
  "wxyz"
};

int main(){
  int n,i,l,c;
  char s[2048];
  scanf("%d",&n);
  while(n>0){
    n--;
    scanf("%s",s);
    l=strlen(s);
    s[l]='*';
    c=0;
    for(i=0;i<l;i++){
      if(s[i]=='0'){
        if(c!=0){
          printf("%c",dict[s[i-1]-'0'][(c-1)%div[s[i-1]-'0']]);
        }
        c=0;
      }
      else{c++;}
    }printf("\n");
  }
  return 0;
}



Measured memory_bytes: 1972
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int N;

int main() {
	cin >> N;
	string S;
	cin >> S;
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (S[i] != S[i - 1]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  
  ll res = 0;
  
  for (auto & m : mp){
    ll s = m.second;
    res += s * (s-1) / 2;
  }
  
  cout << res;
  
  return 0;
}

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


int main()
{
	int n, m;
	cin >> n >> m;
	int a;
	multiset<int> st;
	for (int i = 0; i < n; i++){
		cin >> a;
		st.insert(a);
	}
	for (int i = 0; i < m; i++){
		int b = *(--(st.end()));
		st.erase(--(st.end()));
		b /= 2;
		st.insert(b);
	}

	long long res = 0;

	for (auto x : st) res += x;

	cout << res << endl;

}



Measured memory_bytes: 4992
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] hw = scanner.nextLine().split(" ", 2);
        int h = Integer.parseInt(hw[0]);
        int w = Integer.parseInt(hw[1]);
        for (int i = 0; i < h; i++) {
            String line = scanner.nextLine();
            System.out.println(line);
            System.out.println(line);
        }
    }
}


Measured memory_bytes: 22736
x,k,d=map(int,input().split())
if abs(x)>=k*d:
    print(abs(x)-k*d)
else:
    x=abs(x)
    a=x%d
    #print(x//d)
    k=k-x//d
    #print(k)
    k=k%2
    #print(x)
    #print(k)
    if k==0:
        print(a)
    else:
        print(d-a)

Measured memory_bytes: 61712
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll c[20],a[20][20];
ll b[20];
int main(){
    ll n,m,x,ans=1e11;
    cin>>n>>m>>x;
    rep(i,0,n){
        cin>>c[i];
        rep(j,0,m){
            cin>>a[i][j];
        }
    }

    for(int mask = 0; mask < (1 << n); mask++){
        ll tmp=0;
        rep(i,0,20)b[i]=0;
        rep(i,0,n) {
            if(mask&(1<<i)){
                tmp+=c[i];
                rep(j,0,m) b[j]+=a[i][j];
            }
        }
        bool pp=true;
        rep(i,0,m)if(b[i]<x)pp=false;
        if(pp)ans=min(ans,tmp);
    }
    if(ans==1e11)cout<<-1;
    else cout<<ans;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for(int i = 0; i < n; i++)
#define irep(i,n) for(int i = n-1; i>=0; i--)
#define FOR(a,b) for(int i=a; i<b+1; i++)
using namespace std;
typedef long long ll;

int main() {
    int n,d;
    cin >> n >> d;
    if(n%(2*d+1)==0){
        cout << n/(2*d+1) << endl;
    }
    else{
        cout << n/(2*d+1)+1 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    
    int a,b;
    scanf("%d %d",&a,&b);
    if((-1000<=a)&&(b<=1000))
    {
        if(a < b)
            printf("a < b\n");
        else if(a > b)
            printf("a > b\n");
        else
            printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, D;
  cin >> N >> D;

  int ret = 0;
  int B = 0;
  while(B<N){
    ret++;
    B += 2*D+1;
  }

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


Measured memory_bytes: 256
// AOJ CGL_7_F Tangent to a Circle
// 2018.5.3 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { double x, y, r; } C;

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF 1e8
#define EPS 1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vmul(PP p1, PP p2) { PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return vabs(vsub(p1, p2)); }

void tangentCP(PP *po, C c, PP p)
{
	PP c0 = vset(c.x, c.y);
	double L = vabs(vsub(c0, p));
	double M = sqrt(L*L - c.r*c.r);
	double theta = asin(c.r / L);
	PP v = vsmul(vsub(c0, p), 1/L);		// 単位ベクトル
	PP a = vset(cos(theta), sin(theta)), b = vset(cos(theta), -sin(theta));
	po[0] = vadd(p, vsmul(vmul(v, a), M));
	po[1] = vadd(p, vsmul(vmul(v, b), M));
}

int cmp(PP *a, PP *b)
{
	if (EQ(a->x, b->x)) return dcmp(a->y - b->y);
	return dcmp(a->x - b->x);
}

int main()
{
	int i;
	C c;
	PP pp[2], p;

	p.x = in(), p.y = in();
	c.x = in(), c.y = in(), c.r = in();
	tangentCP(pp, c, p);
	qsort(pp, 2, sizeof(PP), cmp);
	for (i = 0; i < 2; i++) {
		printf("%.10lf %.10lf\n", pp[i].x, pp[i].y);
	}
	return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> pix(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> pix.at(i).at(j);
    }
  }
  
  vector<bool> is_row_whight(H);
  for (int i = 0; i < H; i++) {
    is_row_whight.at(i) = true;
  }
  
  vector<bool> is_col_whight(W);
  for (int i = 0; i < W; i++) {
    is_col_whight.at(i) = true;
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (pix.at(i).at(j) == '#') {
        is_row_whight.at(i) = false;
        is_col_whight.at(j) = false;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (is_row_whight.at(i)) {
      continue;
    }
    for (int j = 0; j < W; j++) {
      if (!is_col_whight.at(j)) {
        cout << pix.at(i).at(j);
      }
      if (j == W - 1) {
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 3652
N = int(input())
S = input()
s1 = S[1:]
b = []
b.append(s1.count('E'))
j = 1
while j < N:
  b.append(0)
  b[j] = b[j-1]
  if S[j] == 'E':
    b[j] += -1
  if S[j-1] == 'W':
    b[j] += 1
  j += 1
print(min(b))

Measured memory_bytes: 15820
import sys
input = sys.stdin.readline

import heapq

def dijkstra(start, edge):
    n = len(edge)
    dist = [float("inf")]*n
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, v = heapq.heappop(que)
        if dist[v] < d:
            continue
        for nv, nd in edge[v]:
            if dist[nv] > d + nd:
                dist[nv] = d + nd
                heapq.heappush(que, (dist[nv], nv))
    return dist
  
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(1, n):
  G[i].append((i-1, 0))
for _ in range(m):
  l, r, c = map(int, input().split())
  G[l-1].append((r-1, c))

D = dijkstra(0, G)
ans = D[n-1]
if ans == float("inf"):
  ans = -1
print(ans)

Measured memory_bytes: 44016
from collections import defaultdict
N, M = map(int, input().split())

a_dic = defaultdict(int)
for _ in range(N):
    a_list = list(map(int, input().split()))[1:]

    for a in a_list:
        a_dic[a] += 1

ans = 0
for val in a_dic.values():
    if val == N:
        ans += 1

print(ans)


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

#define i64 long long int

int main() {
	i64 n;
	cin>>n;
	
	i64 ans = n-1;
	
	for(i64 i=2;i*i<=n;i++)
		if(n%i==0) ans = min(ans, i + (n/i) - 2);
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

for i in range(n):
    A[i] //= 400
    if A[i] > 7:
        A[i] = "*"
        
over3200 = A.count("*")

base = len(set(A))

if over3200 > 0:
    base -= 1

if over3200 == n:
    print(1,base+over3200)
else:
    print(base,base+over3200)

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)
ll N,M,B[100010],A[100010],price = 0,cnt = 0;
vector<pair <ll,ll> > P;
int main(){
  cin >> N >> M;
  rep(i,N){
    cin >> A[i] >> B[i];
    P.push_back(make_pair(A[i],B[i]));
  }
  sort(all(P));
  rep(i,N){
    ll tmp = M-cnt; 
    if(P[i].second<=tmp){
      cnt += P[i].second;
      price += P[i].first*P[i].second;
    }else{
      cnt += tmp;
      price += P[i].first*tmp;
    }
    //cout << cnt << " " << price << endl;
    if(cnt == M){
      break;
    }
  }
  cout << price << endl;
}

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



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

int a, b, n;

int main() {
  while (1) {
    if (scanf("%d%d%d", &a, &b, &n) != 3) return 0;
    int ans = 0;
    for (int i=0; i<n; i++) {
      a -= a/b*b;
      a *= 10;
      int t = a/b;
      ans += t;
    }
  
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	int a[n];
	ll sum1,sum2;
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll pre[n+1];
	pre[0]=0;
	for(int i=1;i<=n;i++){
		pre[i]=pre[i-1]+a[i-1];}
	ll dp[n][n];
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<n;j++){
			if(i>j)  dp[i][j]=0;
			else if(i==j)  dp[i][j]=a[i];
			else{
				sum1=pre[j+1]-pre[i+1];
				sum2=pre[j]-pre[i];
				dp[i][j]=max(a[i]+sum1-dp[i+1][j],a[j]+sum2-dp[i][j-1]);
			}
		}
	}
	ll ans=2*dp[0][n-1]-pre[n];
		cout<<ans<<endl;
	}

Measured memory_bytes: 70656
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, L;
pair<int, int> p[100100];
int l[100100], r[100100];

signed main(){
    cin >> N >> L;
    for(int  i = 0; i < N; i++){
        int a,b;
        cin >> a >> b;
        p[i] = mk(a, b);
    }
    sort(p, p + N);
    for(int i = 0; i < N; i++){
        int num = p[i].first;
        int dir = p[i].second;
        if(dir){
            l[i] = -(num - i - 1);
        }
        else {
            l[i] = num - i - 1;
        }
        if(i > 0)l[i] += l[i - 1];

        num = p[N-1-i].first;
        dir = p[N-1-i].second;
        if(dir){
            r[N-1-i] = L - i - num;
        }
        else {
            r[N-1-i] = -(L - i - num);
        }
        r[N-1-i] += r[N-1-i + 1];
    }
    int ans = r[0];
    for(int i = 0; i < N; i++){
        ans = max(ans, l[i] + r[i + 1]);
    }
    cout << ans << endl;
    

    return 0;
}

/*

*/


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int N;
int P[MAX_N];
int main()
{
    ZERO(P);
    cin >> N;
    for(int i=1; i <= N; ++i) {
        scanf("%d", &P[i]);
    }
    int ans = 0;
    for(int cur=1; cur <= N; ++cur) {
        if(P[cur] == cur) {
            if(cur != N) {
                swap(P[cur], P[cur+1]);
            } else {
                swap(P[cur], P[cur-1]);
            }
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
using namespace std;

#define iter(i, n) forw(i, 1, n)
#define forw(i, a, b) for (int i = a; i <= b; ++i)

typedef long long i64;
typedef unsigned long long u64;
typedef vector<i64> Info;

const int NR = 2e5 + 100;

i64 f[200];
int p[NR];
string s, t;
i64 L, R;
int n;

Info c[200];

Info add(Info a, Info b) {
	Info c(26);
	for (int i = 0; i < 26; ++i) c[i] = a[i] + b[i];
	return c;
}

Info count(string s) {
	Info a(26);
	for (char c : s) ++a[c - 'a'];
	return a;
}

Info print(int n, i64 L, i64 R) {
//	printf("%d %lld %lld\n", n, L, R);
	if (L == 1 && R == f[n]) {
		return c[n];
	}

	if (n < 2) {
		return count((n == 0 ? s : s + t).substr(L - 1, R - L + 1));
	}

	i64 t = f[n - 1];
	if (R <= t) return print(n - 1, L, R);
	else if (L > t) return print(n - 2, L - t, R - t);
	else {
		return add(print(n - 1, L, t), print(n - 2, 1, R - t));
	}
}

string per(string s) {
	int j = -1, n = s.length();
	p[0] = -1;
	for (int i = 1; i < n; ++i) {
		for (; j >= 0 && s[i] != s[j + 1]; j = p[j]);
		if (s[i] == s[j + 1]) ++j;
		p[i] = j;
	}
	return s.substr(0, n - 1 - p[n - 1]);
}



int main() {
	//freopen("77F.in", "r", stdin);
	cin >> s >> L >> R;
	s = s.substr(0, s.length() / 2);
	t = per(s);
	f[0] = s.length();
	c[0] = count(s);
	f[1] = f[0] + t.length();
	c[1] = add(c[0], count(t));
	for (n = 2; (u64) f[n - 1] + f[n - 2] <= 1e18; ++n)
		f[n] = f[n - 1] + f[n - 2], 
		c[n] = add(c[n - 1], c[n - 2]);
	Info tmp = print(n, L, R);
	for (int i = 0; i < 26; ++i) printf("%lld ", tmp[i]);
	puts("");
	return 0;
}


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

#define MAX 1299709+1
int main(){
  int b[MAX]={0},i,j;
  b[0]=b[1]=1;
  for(i=4;i<MAX;i+=2)b[i]=1;
  for(i=3;i*i<MAX;i+=2)
    if(!b[i])for(j=i+i;j<MAX;j+=i)b[j]=1;

  int n,c;

  while(cin>>n,n){
    c=0;
    for(i=n;i>2;i--){
      if(!b[i])break;
      c++;
    }
    for(i=n;i<MAX;i++){
      if(!b[i])break;
      c++;
    }
    if(b[n])cout<<c<<endl;
    else puts("0");
  }
}

Measured memory_bytes: 5944
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, C] = input[0].map(Number);

  return C >= A && C <= B ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29656
import sys
input = sys.stdin.buffer.readline

def main():
    N,P = map(int,input().split())
    
    is_prime = [True for i in range(int(P**(1/2))+1)]
    is_prime[0] = is_prime[1] = False
    
    for i in range(2,int(P**(1/2)+1)):
        if not is_prime[i]:
            continue
        j = 2*i
        while j<=int(P**(1/2)):
            is_prime[j] = False
            j += i

    ans = 1
    for i in range(1,int(P**(1/2)+1)):
        count = 0
        if is_prime[i]:
            while P%i == 0:
                count += 1
                P//=i
            z = pow(i,count//N)
            ans *= z
    
    z = pow(P,1//N)
    print(ans*z)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 10904
n = int(input())
P = list(map(int, input().split()))
X = list(map(int, input().split()))

dp = [0]*n
child = [[] for i in range(n)]
for i in range(n-1):
    child[P[i]-1].append(i+1)

for i in range(n-1, -1, -1):
    if not child[i]:
        dp[i] = 0
    else:
        su = 0
        re = 0
        for c in child[i]:
            z = min(X[c], dp[c])
            su += z
        if su > X[i]:
            print("IMPOSSIBLE")
            exit(0)
        can = X[i] - su
        ss = set([0])
        for c in child[i]:
            z = min(X[c], dp[c])
            rest = max(X[c], dp[c]) - z
            re += rest
            pp = set(ss)
            for s in ss:
                if s + rest <= can:
                    pp.add(s + rest)
            ss = pp
        dp[i] = su + re - max(ss)
print("POSSIBLE")


Measured memory_bytes: 41200
import heapq
heap = []
while True:
    op = input().split()
    if op[0] == 'end':
        break
    elif op[0] == 'insert':
        heapq.heappush(heap, -int(op[1]))
    elif op[0] == 'extract':
        print(-heapq.heappop(heap))

Measured memory_bytes: 47288
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32
import heapq

# refer to https://atcoder.jp/contests/abc137/submissions/6814694

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    from collections import defaultdict
    d = defaultdict(list)

    for i in range(N):
        d[A[i]].append(-B[i])

    h = []
    res = 0
    heapq.heapify(h)

    # i日以下で追加できるものを追加していく
    # 　⇒「editorialの後ろから見ていく」になる
    for i in range(1, M+1):
        # ちょうどi日で実施できるものの候補をすべてpushする
        if d[i]:
            for v in d[i]:
                heapq.heappush(h, v)
        
        # でもその日に実行できるバイトは一つだけなので、一つを取り出す。
        # こうするとi+1...のときに、参照されなかったものも候補になる
        if h:
            res += heapq.heappop(h)
        
        # print(i, h, res)

    print(-res)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


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

int main()
{
    int N, K;
    scanf("%d %d", &N, &K);
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        int h;
        scanf("%d", &h);
        if(h >= K) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<int> a;
  for (int i = 0; i < N; ++i) {
    int t;
    cin >> t;
    a.push_back(t);
  }

  int p = -1;
  for (int i = 0; i < N - 1; ++i) {
    if (a[i] + a[i + 1] >= L) {
      p = i;
      break;
    }
  }

  if (p == -1) {
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    for (int i = 0; i < p; ++i) {
      cout << i + 1 << endl;
    }
    for (int i = N - 2; i > p; --i) {
      cout << i + 1 << endl;
    }
    cout << p + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1400
#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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    auto B = A;
    sort(all(B));
    map<int, int> M;
    rep(i, N / 2) {
        M[B[i]] = B[N / 2];
    }
    rep(i, N / 2, N) {
        M[B[i]] = B[N / 2 - 1];
 }
    rep(i, N) {
        output(M[A[i]]);
    }
    return 0;
}


Measured memory_bytes: 12928
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
s=sum(a)
for i in range(n):
  x=a[i]
  y=b[i]
  a[i]-=min(x,y)
  b[i]-=min(x,y)
  if b[i]>0:
    a[i+1]-=min(a[i+1],b[i])
print(s-sum(a))

Measured memory_bytes: 18624
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;
/*ある村には、高さ 1,(1+2),(1+2+3),…,(1+2+3+…+999) メートルの 999 本の塔が、西から順に 1 メートル間隔で立っています。

長く降り続けた雪がようやく収まったので、まだ雪に完全には埋もれていない、互いに 1 メートル離れたある 2 つの塔の、雪に埋もれていない部分の高さを測ったところ、西側の塔は a メートル、東側の塔は b メートルでした。

積雪量と標高が村内のどこでも等しいと仮定したとき、雪が何メートル積もっているか求めてください。

ただし、雪は必ず 1 メートル以上積もっているものとします。*/
int main(){
	int h = 0, prev = 0;
	int a, b;
	cin >> a >> b;
	for(int i = 0; i <= 999; i++){
		prev = h;
		h += i;
		if((h - prev) == (b - a)){
			cout << h - b << endl;
			return 0;
		}
	}
}


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


int main() {
  ll n; cin >> n; vi vec(n);
  rep(i,n) {
    ll x; cin >> x; vec.at(i) = x;
  }
  
  ll mini = 1000000000; 
  
  rep(i,99){
    ll sum = 0;
    rep(j,n){
      sum += (vec.at(j)-i)*(vec.at(j)-i);
    }
    
    mini = min(mini,sum);
  }
  
  cout << mini << endl;
}

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

main(){
  int n,q;
  cin>>n;
  vector<int>v(n);
  r(i,n)cin>>v[i];
  cin>>q;
  while(q--){
    int a;
    cin>>a;
    if(*lower_bound(v.begin(),v.end(),a)==a)cout<<1<<endl;
    else cout<<0<<endl;
  }
}


Measured memory_bytes: 3104