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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.ne(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

ll n;
ll a[2][3];
ll v[3], c[3];
ll dp[25000005];
void solve() {
    cin >> n;
    rep(i, 2) rep(j, 3) cin >> a[i][j];
    rep(i, 3) { v[i] = a[1][i] - a[0][i]; c[i] = a[0][i]; }
    rep(i, 3) reps(j, n) {
        if (j >= c[i]) maxs(dp[j], dp[j - c[i]] + v[i]);
    }

    ll m = 0;
    reps(j, n) maxs(m, dp[j]);
    n += m;

    fillArray(dp, 0);
    rep(i, 3) { v[i] = a[0][i] - a[1][i]; c[i] = a[1][i]; }
    rep(i, 3) reps(j, n) {
        if (j >= c[i]) maxs(dp[j], dp[j - c[i]] + v[i]);
    }

    m = 0;
    reps(j, n) maxs(m, dp[j]);
    n += m;

    cout << n << endn;
}

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


Measured memory_bytes: 195584
#include <stdio.h>
#define MAX 100

void Graph(void);
void Initialization(void);
int i,j,n;
int adj[MAX][MAX];

int main(){
    int head,capa,contents;
    
    Initialization();
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&head,&capa);
        for(j=0;j<capa;j++){
            scanf("%d",&contents);
            adj[head-1][contents-1]=1;
        }
    }
    Graph();
    return 0;

}

void Initialization(){
    for(i=0;i<MAX;i++){
        for(j=0;j<MAX;j++){
            adj[i][j]=0;
        }
    }
}
void Graph(void){
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(j!=0) printf(" ");
            printf("%d",adj[i][j]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

long long N, X, Y, COUNT = 0;
static bool visited[200000] = {};
static vector<long long> V[200000];

void DFS(int P) {
	visited[P] = true;
	if (P < 100000) X++;
	else Y++;
	for (int R : V[P]) {
		if (!visited[R]) DFS(R);
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		x--, y+=99999;
		V[x].push_back(y);
		V[y].push_back(x);
	}
	for (int i = 0; i < 100000; i++) {
		X = 0, Y = 0;
		if (!visited[i]) DFS(i);
		COUNT += X * Y;
	}
	cout << COUNT - N;
}

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

typedef long long ll;
ll INF = 1001001001001;
ll d[300][300];
int d2[300][300];

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  for (int i = 0; i < 300; ++i) {
    for (int j = 0; j < 300; ++j) {
      d[i][j] = INF;
      if (i == j) { d2[i][j] = 0; }
      else { d2[i][j] = 300; }
    }
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    --a; --b;
    if (c > l) continue; // 使えない道
    d[a][b] = c;
    d[b][a] = c;
  }
  for(int k = 0; k < n; ++k) {
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n; ++j) {
      if (d[i][j] <= l) d2[i][j] = 1;
    }
  }
  for(int k = 0; k < n; ++k) {
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
        d2[i][j] = min(d2[i][j], d2[i][k]+d2[k][j]);
      }
    }
  }


  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    // cerr << s << " " << t << " ";
    if (d2[s][t] == 300) cout << -1 << endl;
    else cout << d2[s][t]-1 << endl;
  }
}



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

int main(){
    int x, a;
    cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15

struct lex_compare {
    bool operator() (pp(ll) p1,pp(ll) p2){
        ll x1 = (p1.ff*(p1.ss-p1.ss/2));
        ll x2 = (p2.ff*(p2.ss-p2.ss/2));
        return x1 > x2;
    }
};

int main(){
    FIO;
    string s,t; cin >> s >> t;
    ll ans = t.size();
    for(int i = 0;i<=s.size()-t.size();i++){
        ll temp = 0;
        for(int j = i;j<i+t.size();j++){
            if(s[j] != t[j-i]){
                temp++;
            }
        }
        ans = min(ans,temp);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N,M;
    cin >> N >> M ;
    if(N%2==1){
        for(int i=1;i<=M;i++){
            cout << i << " " << N-i << endl;
        }
    }
    else{
        int i;
        int K=(N/4)*2;
        for(i=1;i<=M;i++){
            if(i>N/4){break;}
            cout << i << " " << K-i+1 << endl;
            

        }
        int j=0;
        while(i+j<=M){
            cout << K+2+j << " " << N-j << endl;
            j+=1;
        }

    }
}

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

void Sort(int length[], int N){
  int i,j,k,m ;
  for(i=1;i<N;i++){
    k=i ;
    m=length[i] ;
    j=i-1 ;
    while(length[j]<m && j>=0){
      length[j+1] = length[j] ;
      j-- ;
    }
    length[j+1] = m ;
  }
}


int main(){
  int N,K,length[51],i,sum=0 ;

  cin >> N >> K ;
  for(i=0;i<N;i++){
    cin >> length[i] ;
  }

  Sort(length,N) ;


  for(i=0;i<K;i++){
    sum = sum + length[i] ;
  }

  cout << sum << endl ;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 4 * (int)1e5 + 10;
int x[maxN], y[maxN];
int a[2 * maxN];
int n;
int cnt[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    vector < pair < int, int > > all;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        all.emplace_back(x[i], 2 * i);
        all.emplace_back(y[i], 2 * i + 1);
        a[2 * i] = x[i];
        a[2 * i + 1] = y[i];
    }
    if (n == 1) {
        cout << 0;
        return 0;
    }
    sort(all.begin(), all.end());
    int rmin = all[0].first;
    ll best = 3e18;
    if (all.back().second / 2 != all[0].second / 2) {
        int posmin = all[0].second / 2;
        int posmax = all.back().second / 2;
        int rmax = all.back().first;
        set < pair < int, int > > cur_mins;
//        set < pair < int, int > > all_cands;

        for (int i = 0; i < n; i++) {
            if (i != posmin && i != posmax) {
                cnt[i] = 2;
//                all_cands.insert({a[2 * i], 2 * i});
//                all_cands.insert({a[2 * i + 1], 2 * i + 1});
                cur_mins.insert(min(make_pair(a[2 * i], 2 * i), make_pair(a[2 * i + 1], 2 * i + 1)));
            }
            else {
                cnt[i] = 1;
                int who;
                if (i == posmin) who = all[0].second ^ 1;
                else who = all.back().second ^ 1;
//                all_cands.insert({a[who], who});
                cur_mins.insert({a[who], who});
            }
        }
        for (int i = 0; i + 1 < all.size(); i++) {
            if (i > 1) {
                int to_del = all[i - 1].second;
                cnt[to_del / 2]--;
                if (cnt[to_del / 2] == 0) break;
                if (make_pair(a[to_del], to_del) < make_pair(a[to_del ^ 1], (to_del ^ 1))) {
                    cur_mins.erase({a[to_del], to_del});
                    cur_mins.insert({a[to_del ^ 1], (to_del ^ 1)});
                }
            }
            auto it = *(--cur_mins.end());
            if (it < all[i]) continue;
            best = min(best, 1LL * (rmax - rmin) * (it.first - all[i].first));
        }
    }
    int bmax = all.back().first;
    int posmin = all[0].second / 2;
    int posmax = all.back().second / 2;
    int rmax = rmin;
    int bmin = bmax;
    for (int i = 0; i < n; i++) {
        if (posmin == i) {
            bmin = min(bmin, a[all[0].second ^ 1]);
        }
        else if (posmax == i) {
            rmax = max(rmax, a[all.back().second ^ 1]);
        }
        else {
            rmax = max(rmax, min(a[2 * i], a[2 * i + 1]));
            bmin = min(bmin, max(a[2 * i], a[2 * i + 1]));
        }
    }
    best = min(best, 1LL * (rmax - rmin) * (bmax - bmin));
    cout << best;
    return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> connect(M);
    int P[M];
    for (int i = 0; i < M; i++) {
        int num_switch;
        cin >> num_switch;
        for (int j = 0; j < num_switch; j++) {
            int s; cin >> s;
            connect[i].push_back(s);
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> P[i];
    }

    // {0, 1, ..., n-1} の部分集合の全探索
    int res = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        int LightOn = 0;
        for (int i = 0; i < M; i++) {
            int on = 0;
            for (int j = 0; j < connect[i].size(); j++) {
                if (bit & (1 << connect[i][j]-1)) on++;
            }
            if (on % 2 == P[i]) LightOn++;
        }
        if (LightOn == M) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
r = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

dp = Array.new(n + 1, -99999)
dp[0] = 0
n.times do |i_|
  i = i_ + 1
  m.times do |j|
    dp[i] = [dp[i], dp[i - r[a[j]]] + 1].max if i - r[a[j]] >= 0
  end
end
a.sort!
a.reverse!
ans = []
while n > 0
  m.times do |j|
    if n - r[a[j]] >= 0 && dp[n - r[a[j]]] == dp[n] - 1
      ans.push(a[j])
      n -= r[a[j]]
      break
    end
  end
end
puts ans.join

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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	a -= 1;
	for (int i = (b - a); i <= (b + a); i++) {
		cout << i;
		if (i != (a + b)) {
			cout << ' ';
		}
	}
	return 0;
}

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

class heavy_light_decomposition {
	const int n;
	vector<vector<int>> g;
	vector<int> in, out, size, head, par;
	int it;
	void erase_par(int v, int prev) {
		par[v] = prev;
		for (auto& u : g[v]) {
			if (u == g[v].back()) break;
			if (u == prev) swap(u, g[v].back());
			erase_par(u, v);
		}
		g[v].pop_back();
	}
	void dfs1(int v) {
		for (auto& u : g[v]) {
			dfs1(u);
			size[v] += size[u];
			if (size[u] > size[g[v][0]]) swap(u, g[v][0]);
		}
	}
	void dfs2(int v) {
		in[v] = it++;
		for (auto u : g[v]) {
			head[u] = (u == g[v][0] ? head[v] : u);
			dfs2(u);
		}
		out[v] = it;
	}
public:
	heavy_light_decomposition(int n_)
		: n(n_), g(n), in(n, -1), out(n, -1), size(n, 1), head(n), par(n, -1), it(0) {}
	heavy_light_decomposition(const vector<vector<int>>& G)
		: n(G.size()), g(G), in(n, -1), out(n, -1), size(n, 1), head(n), par(n, -1), it(0) {}
	void add_edge(int u, int v) {
		g[u].push_back(v);
		g[v].push_back(u);
	}
	void build(int rt = 0) {
		for (auto v : g[rt]) erase_par(v, rt);
		dfs1(rt);
		head[rt] = rt;
		dfs2(rt);
	}
	int get_id(int v) {
		return in[v];
	}
	int get_lca(int u, int v) {
		while (true) {
			if (in[u] > in[v]) swap(u, v);
			if (head[u] == head[v]) return u;
			v = par[head[v]];
		}
	}
	void path_query(int u, int v, function<void(int, int)> f) {
		while (true) {
			if (in[u] > in[v]) swap(u, v);
			f(max(in[head[v]], in[u]), in[v] + 1);
			if (head[u] == head[v]) return;
			v = par[head[v]];
		}
	}
	void path_query(int u, int v, function<void(int, int, bool)> f) {
		while (true) {
			if (in[u] <= in[v]) {
				f(max(in[head[v]], in[u]), in[v] + 1, false);
				if (head[u] == head[v]) return;
				v = par[head[v]];
			}
			else {
				f(max(in[head[u]], in[v]), in[u] + 1, true);
				if (head[u] == head[v]) return;
				u = par[head[u]];
			}
		}
	}
	void edge_path_query(int u, int v, function<void(int, int)> f) {
		while (true) {
			if (in[u] > in[v]) swap(u, v);
			if (head[u] != head[v]) {
				f(max(in[head[v]], in[u]), in[v] + 1);
				v = par[head[v]];
			}
			else {
				if (u != v) f(in[u] + 1, in[v] + 1);
				break;
			}
		}
	}
	void edge_path_query(int u, int v, function<void(int, int, bool)> f) {
		while (true) {
			if (in[u] > in[v]) {
				if (head[u] != head[v]) {
					f(max(in[head[u]], in[v]), in[u] + 1, true);
					u = par[head[u]];
				}
				else {
					if (u != v) f(in[v] + 1, in[u] + 1, false);
					break;
				}
			}
			else {
				if (head[u] != head[v]) {
					f(max(in[head[v]], in[u]), in[v] + 1, false);
					v = par[head[v]];
				}
				else {
					if (u != v) f(in[u] + 1, in[v] + 1, false);
					break;
				}
			}
		}
	}
	void subtree_query(int v, function<void(int, int)> f) {
		f(in[v], out[v]);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	heavy_light_decomposition hld(n);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int c;
			cin >> c;
			hld.add_edge(i, c);
		}
	}
	hld.build();
	int q;
	cin >> q;
	while (q--) {
		int u, v;
		cin >> u >> v;
		printf("%d\n", hld.get_lca(u, v));
	}
	return 0;
}



Measured memory_bytes: 14256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  map<int,int>m;
  cin>>n;
  rep(i,n){
    int a;
    cin>>a;
    m[a]++;
  }
  ll ans=0;
  for(auto itr : m){
    if(itr.first>itr.second){
      ans+=itr.second;
    }else{
      ans+=(itr.second-itr.first);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N;
  scanf("%d", &N);
  int mult_four = 0, odd = 0, even = 0;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &v[i]);
  }
  for (int i = 0; i < N; ++i) {
    if (v[i] % 4 == 0) { ++mult_four; }
    else if (v[i] % 2 == 1) { ++odd; }
    else { ++even; }
  }
  string ans = "Yes";
  if (odd > mult_four + 1) { ans = "No"; }
  else {
    mult_four -= (odd - 1);
    if (even % 2 == 1 and mult_four <= 0) { ans = "No"; }
  }
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;

	vector<pii> g[N];
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(pii(b, i));
		g[b].push_back(pii(a, i));
	}

	int edge_max = 0;
	int root_node = -1;
	for(int i = 1; i <= n; i++) {
		if(edge_max < g[i].size()) {
			edge_max = g[i].size();
			root_node = i;
		}
	}

	vector<int> used_color(n + 1, 0);	// 1st assigned color in each node
	vector<int> edge_color(n, 0);	// edge to color
	queue<pii> que;

	used_color[root_node] = -1;
	que.push(pii(root_node, -1));

	while(!que.empty()) {
		pii p = que.front();	// node, edge
		que.pop();
		int color = 1;
		for(auto q : g[p.first]) {
			if(used_color[q.first] != 0) continue;
			if(color == used_color[p.first]) color++;
			used_color[q.first] = color;
			edge_color[q.second] = color;
			color++;
			que.push(q);
		}
	}

	cout << edge_max << endl;
	rep(i, n - 1) cout << edge_color[i] << endl;
	return 0;
}


Measured memory_bytes: 7424
/**
 * Created by hiramekun at 02:24 on 2020-05-22.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll h;
    cin >> h;
    ll ans = 0;
    ll now = 1;
    while (h) {
        ans += now;
        now *= 2;
        h /= 2;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

const int size = 3005;

int dp[size][size];

int main()
{
	std::string s1;
	std::string s2;
	std::cin >> s1 >> s2;
	for (int i = 0; i < s1.size(); ++i)
	{
		for (int j = 0; j < s2.size(); ++j)
		{
			if (s1[i] == s2[j])
				dp[i + 1][j + 1] = dp[i][j] + 1;
			else
				dp[i + 1][j + 1] = std::max(dp[i][j + 1], dp[i + 1][j]);
		}
	}
	int i = s1.size();
	int j = s2.size();
	std::string ans;
	ans.reserve(i < j ? i : j);
	while (true)
	{
		if (dp[i][j] == dp[i - 1][j])
			--i;
		else if (dp[i][j] == dp[i][j - 1])
			--j;
		else
		{
			--i;
			--j;
			ans.push_back(s1[i]);
		}
		if (dp[i][j] == 0)
			break;
	}
	std::reverse(ans.begin(), ans.end());
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 35456
// C - GP 2
#include <bits/stdc++.h>

using namespace std;

#define	MOD 998244353

struct FactTable {
	vector<long long> a;
	FactTable(int n) : a(n + 1, 1) { for (int i = 2; i < a.size(); i++) a[i] = a[i - 1] * i % MOD; }
	inline long long operator()(int n) { return a[n]; }
} fact(2000000);

long long minv(long long a)
{
	long long r = 1;
	for (long long n = MOD - 2; n > 0; a = a * a % MOD, n >>= 1)
		if (n & 1) r = r * a % MOD;
	return r;
}

long long cnr(int n, int r)
{
	if (r < 0 || r > n) return 0;
	if (r == 0 || r == n) return 1;
	return fact(n) * minv(fact(r)) % MOD * minv(fact(n - r)) % MOD;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	long long n, m;
	cin >> n >> m;

	long long ans = 0;

	for (int k = 0; k <= min(m, n); k++) {
		if ((3 * m - k) % 2) continue;
		long long c = (3 * m - k) / 2;
		ans = (ans + cnr(c + n - 1, c) * cnr(n, k) % MOD) % MOD;
	}

	long long r = 0;
	for (int k = 0; k <= min(m, n); k++) {
		if ((m - k) % 2) continue;
		long long c = (m - k) / 2;
		r = (r + cnr(c + n - 1, c) * cnr(n, k) % MOD - cnr(c + n - 2, c) * cnr(n - 1, k) % MOD + MOD) % MOD;
	}
	ans = (ans - r * n % MOD + MOD) % MOD;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 16000
// AOJ 2801: Suntan
// 2017.11.21 bal4u@uu

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

long long s[100001], t[100001]; int N;
long long a[100001];

char buf[50], *p;
long long getlong()
{
	long long n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int bsch(int l, long long x)
{
	int m, r = N+1;

    while (l < r) {
        m = (l + r) >> 1;
        if (t[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int i, k;
	long long ans, T, x, y;
	
	fgets(p=buf, 50, stdin), T = getlong();
	fgets(buf, 50, stdin), N = atoi(buf);
	for (i = 1; i <= N; i++) {
		fgets(p=buf, 50, stdin);
		s[i] = getlong(), p++, t[i] = getlong();
		a[i] = a[i-1] + (t[i]-s[i]);
	}
	s[N+1] = t[N+1] = 1LL << 62;

	ans = 0;
	for (k = bsch(0, T), i = 1; i <= N; i++) {
		x = s[i] + T; k = bsch(k, x);
		y = a[k]-a[i-1];
		if (x > s[k+1]) y += x-s[k+1];
		if (y > ans) {
			ans = y;
			if (ans == T) break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4196
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        System.out.println(solve(N));

        sc.close();
    }

    static String solve(int N) {
        return String.format("ABC%d", N);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
//define
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007
//main
signed main(){
  int N,M,O,P,count=0,count2=mod,count3=0,stack=0;
  str S,T;
  double l,s;
  cin>>N;
  vint p(N);
  rep(0,N){
    cin>>p[i];
  }
  sort(all(p));
  cout<<p[N/2]-p[N/2-1]<<endl;
}


Measured memory_bytes: 640
import sys
n = int(input())
a = list(map(int, input().split()))
if n==0:
    if a[0]<2:
        print(a[0])
    else:
        print(-1)
    sys.exit()
tree = [0 for _i in range(n+2)]
tree[0] = 1
for i in range(1,n+1):
    tree[i] = tree[i-1]*2
    tree[i] -= a[i]
tree[n] += a[i]
for i in range(n, 0, -1):
    if tree[i-1]*2 < a[i]:
        print(-1)
        sys.exit()
    x = min(tree[i-1], a[i])
    a[i-1] += x
if a[0]>1:
    print(-1)
else:
    print(sum(a))

Measured memory_bytes: 670096
package main

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

var sc = bufio.NewScanner(os.Stdin)
const mod = 1000000007

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Point struct {
	X, Y int
}

func fact(x int) int {
	ans := 1

	for i := 2; i <= x; i++ {
		ans *= i
		ans %= mod
	}

	return ans
}

//func modinv(a, m int) int {
//	b, u, v := m, 1, 0
//	for b != 0 {
//		t := a/b
//		a -= t * b
//		a, b = b, a
//		u -= t * v
//		u, v = v, u
//	}
//
//	u %= m
//	if u < 0 {
//		u += m
//	}
//	return u
//}

func mul(a, x int) int {
	if x == 0 {
		return 1
	}

	ans := 1
	for x > 1 {
		if x%2 == 1 {
			ans = ((ans%mod)*(a%mod))%mod
		}
		a = ((a%mod)*(a%mod))%mod
		x /= 2
	}

	return ((ans%mod)*(a%mod))%mod
}

func modinv(a, m int) int {
	return mul(a, m-2)
}

func main() {
	sc.Split(bufio.ScanWords)

	x, y := nextInt(), nextInt()
	if (x+y)%3 != 0 {
		fmt.Println(0)
		return
	}

	c := (x+y)/3
	// AパターンとBパターンの回数を探す
	a, b := -1, -1
	for i := 0; i <= c; i++ {
		if i + 2*(c-i) == x && 2*i + (c-i) == y {
			a, b = i, c-i
		}
	}

	if a == -1 || b == -1 {
		fmt.Println(0)
		return
	}

	fmt.Println(fact(c)*modinv(fact(a)*fact(b), mod)%mod)
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static int mod=(int)1e9+7;
    static long mod(long x){
        return ((x%mod+mod)%mod);
    }
    static long add(long x,long y){
        return mod(mod(x)+mod(y));
    }
    static long mul(long x,long y){
        return mod(mod(x)*mod(y));
    }

    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n=sc.nextInt();
        long a[]=sc.readArrayLong(n);
       long sum=0;
       for (int i=0;i<n;i++){
           sum=(sum+a[i]);
       }
       long sum1=0;
       for (int i=0;i<n-1;i++){
           sum-=a[i];
          sum1+=((sum%mod*a[i]%mod))%mod;

       }
        System.out.println(sum1%mod);

        out.flush();

    }









    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortReverse(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
//        Collections.sort.(l);
        Collections.sort(l,Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long[] readArrayLong(long n) {
            long[] a=new long[(int)n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }


}


Measured memory_bytes: 56336
N = int(input())
Alst = list(map(int, input().split()))
Blst = list(map(int, input().split()))
Clst = list(map(int, input().split()))

ans = sum(Blst)

for i in range(N-1):
    if Alst[i] + 1 == Alst[i+1]:
        ans += Clst[Alst[i]-1]

print(ans)

Measured memory_bytes: 9196
n, m, x =map(int,input().split())
s = [list(map(int, input().split())) for _ in range(n)]
ans = 10000000
for i in range(2 ** n):
  bag = [0]*(m+1)
  for j in range(n):
    if ((i>>j)&1):
        for _ in range(m+1):
          bag[_] += s[j][_]
  ##print(bag)
  if (min(bag[1:]) >= x and ans > bag[0]):
    ans = bag[0]
    
if ans == 10000000:
  print("-1")
else:
  print(ans)
    
    

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long n,m; cin>>n>>m;
  if(n>2&&m>2) cout<<(n-2)*(m-2);
  else if(min(n,m)==1&&max(n,m)>2) cout<<max(n,m)-2;
  else if(n==1&&m==1) cout<<1; else cout<<0;
  return 0;
}


Measured memory_bytes: 3560
package main

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

var sc *bufio.Scanner

func init() {
        // 100MB
        bufsize := 100 * 1024 * 1024
        sc = bufio.NewScanner(os.Stdin)
        sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
        sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
        s := readStringArray(n)
        a := make([]int, n)
        for i := range a {
                a[i], _ = strconv.Atoi(s[i])
        }
        return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
        a := make([]string, n)
        for i := 0; i < n; i++ {
                sc.Scan()
                a[i] = sc.Text()
        }
        return a
}
func max(ns ...int) int {
        max := ns[0]
        for _, n := range ns {
                if n > max {
                        max = n
                }
        }
        return max
}
func min(ns ...int) int {
        min := ns[0]
        for _, n := range ns {
                if n < min {
                        min = n
                }
        }
        return min
}
func abs(x int) int {
        if x < 0 {
                return -x
        }
        return x
}

type happy []int

func main() {
        n := readInt()
        happies := make([]happy, n)
        for i := 0; i < n; i++ {
                a, b, c := readInt3()
                happies[i] = []int{a, b, c}
        }

        dp := make([][]int, n)
        for i := range dp {
                dp[i] = make([]int, 3)
        }

        dp[0] = happies[0]
        for i := range dp {
                if i == 0 {
                        //fmt.Printf("%3d: %5d %5d %5d\n", i, dp[i][0], dp[i][1], dp[i][2])
                        continue
                }
                for j := 0; j < 3; j++ {
                        for k := 0; k < 3; k++ {
                                if j == k {
                                        continue
                                }
                                dp[i][j] = max(dp[i][j], dp[i-1][k]+happies[i][j])
                        }
                }
                //fmt.Printf("%3d: %5d %5d %5d\n", i, dp[i][0], dp[i][1], dp[i][2])
        }

        fmt.Println(max(dp[n-1]...))
}

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


struct dice{
    int top;
    vector<int> d;
    void set(){
        for(int i=0;i<6;i++){
            cin >> d.at(i);
        }
        return;
    }
    void roll(char c){
        if(c=='E'){
            top=d.at(0);
            d.at(0)=d.at(3);
            d.at(3)=d.at(5);
            d.at(5)=d.at(2);
            d.at(2)=top;//ここをtopにすることで配列の更新が行われるようになる
        }
        else if(c=='N'){
            top=d.at(0);
            d.at(0)=d.at(1);
            d.at(1)=d.at(5);
            d.at(5)=d.at(4);
            d.at(4)=top;
        }
        else if(c=='W'){
            top=d.at(0);
            d.at(0)=d.at(2);
            d.at(2)=d.at(5);
            d.at(5)=d.at(3);
            d.at(3)=top;
        }
        else if(c=='S'){
            top=d.at(0);
            d.at(0)=d.at(4);
            d.at(4)=d.at(5);
            d.at(5)=d.at(1);
            d.at(1)=top;
        }
        else if(c=='R'){
            roll('N');
            roll('W');
            roll('S');
        }
        else if(c=='L'){
            roll('N');
            roll('E');
            roll('S');
        }
        return;
    }
    void settf(int t,int f){
        int i;
        for(i=0;i<6;i++) if(d.at(i)==t) break;
        if(i==1) roll('N');
        else if(i==2) roll('W');
        else if(i==3) roll('E');
        else if(i==4) roll('S');
        else if(i==5){
            roll('N');
            roll('N');
        }
        for(i=1;i<5;i++) if(d.at(i)==f) break;
        if(i==2) roll('R');
        else if(i==3) roll('L');
        else if(i==4){
            roll('R');
            roll('R');
        }
        return;
    }
};

int main() {
    int n;cin >> n; 
    vector <dice> D(n);
    for(int i=0;i<n;i++){
    D.at(i).d={0,0,0,0,0,0};
    }
    bool flag=true;
    for(int i=0;i<n;i++){
    D.at(i).set();
    }
    int i;
    for(int j=0;j<n-1;j++){
        for(int k=j+1;k<n;k++){
            for(i=1;D.at(j).d.at(0)==D.at(j).d.at(1)&&i<5;i++){//これは、、、隣り合う面に同じ数字が入力された場合のこと
                D.at(j).roll('R');
            }//ループを抜けるころには上面と前面が違う数字になっている
            if(D.at(j).d.at(0)==D.at(j).d.at(1)){//これは上面と側面の数字がすべて同じ場合のこと
                for(flag=false,i=1;D.at(j).d.at(5)==D.at(j).d.at(1)&&i<5;i++){//
                    D.at(j).roll('R');//回転する意味？
                }
            }
            if(!flag){//全部の面が同じ数字のときと下面だけ違う数字の場合
                D.at(j).settf(D.at(j).d.at(5),D.at(j).d.at(1));//下面が上面に来るようにする
                flag=true;
            }
            //基本的な場合（さいころの面が全部違う場合）はこれ以降
            D.at(k).settf(D.at(j).d.at(0),D.at(j).d.at(1));//2つ目のさいころの面を、1つ目のサイコロの上面、前面が一致するようにセット　上面、前面が一致してなかったら何も起こらない
            for(int i=0;i<6;i++){//上面、前面が一致しない場合はどのように考える？iは０からでは？<-そう
                if(D.at(j).d.at(i)!=D.at(k).d.at(i))flag=false;
            }
            if(flag)break;
        }
        if(flag)break;
    }
    if(flag) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3104
n = int(input())
ans = 'Yes'
dic = []
iw = input()
dic.append(iw)
for i in range(1,n):
    p = i - 1
    w = input()
    if w in dic or dic[p][-1]!=w[0]:
        ans = 'No'
    dic.append(w)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const long long MX=1e18;
const long long MD=1e9+7;
const int N=1e5+5;
long long n,w,dp[100005],pr[101],wi[101];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>w;
    for(int i=0;i<n;i++)cin>>wi[i]>>pr[i];
    memset(dp,-1,sizeof dp);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=w-wi[i];j>=0;j--)
        {
            if(dp[j]!=-1)
            {
                dp[j+wi[i]]=max(dp[j+wi[i]],dp[j]+pr[i]);
            }
        }
    }
    long long ans=0;
    for(int i=0;i<=w;i++)ans=max(ans,dp[i]);
    cout<<ans;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;

    if(b % a == 0) {
        cout << a + b;
    }
    else {
        cout << b-a;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int x[n+5];
    int y[200005]={0};
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        y[x[i]]++;
    }
    sort(y,y+200005,greater<int>());
    long long sum=0;
    for(int i=k;i<200005;i++)
    {
        sum+=y[i];
    }
cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
 using namespace std;
 #define rep(i, c) for(int i = 0; i < (int)c; i++)
 const int inf = 1000000000; // 10^9

 int main() {
 int n, k;
 cin >> n >> k;
 vector<int>health(n);

 for (int i = 0; i < n; i++)
 {
     cin >> health[i];
 }
 sort(health.begin(), health.end());

 long long atakos = 0;

 for (int i = 0; i < n-k; i++)
 {
     atakos+=health[i];
 }
 cout << atakos;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, k, a[N];
long long pre[N], amk[N], ans;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&k);
	for(int i = 1; i <= n; i++){
		scanf("%d",a + i);
		pre[i] = pre[i - 1] + (a[i] > 0)*a[i];
		amk[i] = amk[i - 1] + a[i];
	}
	for(int i = k; i <= n; i++){
		ans = max(ans, pre[n] - pre[i] + pre[i - k]);
		ans = max(ans, pre[n] - pre[i] + pre[i - k] + amk[i] - amk[i - k]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ans = 0;
    ans = d[N / 2] - d[N / 2 - 1];
    if (ans >= 0)
    {
        cout << ans << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#18:10~
#Aが短いものから貪欲で行けそう
from heapq import *
n,m=map(int,input().split())
#何日かかるのかで(1-indexed)
ab=[[] for i in range(m)]
for i in range(n):
    a,b=map(int,input().split())
    #超えないように
    if a<=m:
        ab[a-1].append(b)
x=[]
l=0
ans=0
for i in range(m-1,-1,-1):
    for j in ab[m-1-i]:
        heappush(x,-j)
        l+=1
    if l:
        l-=1
        ans+=heappop(x)
print(-ans)

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

using namespace std;

namespace abreto {

typedef vector<int> vi;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back

const int maxn = 5;
int t[maxn];
int order[maxn];

void main(void)
{
    for (int i = 0; i < maxn; i++)
    {
        cin >> t[i];
        order[i] = i;
    }
    int least = (int) 1e9;
    do {
        int passed = 0;
        for (int i = 0; i < maxn; i++)
        {
            if (passed > 0)
                passed = ((passed - 1) / 10 + 1) * 10;
            passed += t[order[i]];
        }
        least = min(least, passed);
    } while (next_permutation(order, order + maxn));
    cout << least << '\n';
}

}

int main(void)
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    abreto::main();
    return 0;
}


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

for x in range(1, 3500 + 1):
    for y in range(1, 3500 + 1):
        q = 4 * x * y - n * (x + y)     
        if q <= 0: continue

        p = n * x * y
        if p % q == 0:
            z = p // q
            print(x, y, z)
            exit()

Measured memory_bytes: 3316
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s;
    cin >> s;
    int m = stoi(s.substr(5, 2));
    int d = stoi(s.substr(8, 2));
    cout << (m <= 4 ? "Heisei" : "TBD") << endl;
    /*
    int n;
    cin >> n;
    double ret = 0;
    for (int i = 0; i < n; i++)
    {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY")
            ret += x;
        else
            ret += x * 380000;
    }
    cout << fixed << setprecision(10) << ret << endl;
    */
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int H, W, i, j;
	scanf("%d %d", &H, &W);
	while (H!=0 || W!=0)
	{
		for (i=1; i<=H; i++)
		{
			for (j=1; j<=W; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d", &H, &W);
	}
	return 0;
}

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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int T, X;
	
	cin >> T >> X;
	cout << fixed << setprecision(5) << (double)T / X;
	
	return 0;
}//main


Measured memory_bytes: 256
N=int(input())
L=[[0,0,0]]
for _ in range(N):
    l=list(map(int,input().split()))
    L.append(l)

for i in range(N):
    tsub=L[i+1][0]-L[i][0]
    dist=L[i+1][1]-L[i][1]+L[i+1][2]-L[i][2]

    if tsub%2==0:
        if dist%2!=0 or tsub<dist:
            print("No")
            exit()
    else:
        if dist%2==0 or tsub<dist:
            print("No")
            exit()
print("Yes")



Measured memory_bytes: 27324
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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


int main(void) {
  ll x, y;

  cin >> x >> y;

  if (x % y == 0) {
	cout << "-1" << endl;
  } else {
	cout << x * (y - 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
board = ['#', '.']
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        exit()
    for row in range(h):
        for column in range(w):
            print(board[(row + column) % 2], end='')
        print()
    print()



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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int m = max(max(a,b),c);
    int s = a*b*c/m;
    cout << s/2 << endl;
}

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

using namespace std;

const int MOD = 1000000007;

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<int> A(N);
        vector<int> B(M);
        for(auto& t : A) cin >> t;
        for(auto& t : B) cin >> t;
        vector<vector<long long>> dp(N+1, vector<long long>(M+1, 0));
        dp[0][0] = 1;
        for(int i=1;i<=N;i++) dp[i][0] = 1;
        for(int j=1;j<=M;j++) dp[0][j] = 1;
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                if(A[i] == B[j]){
                    dp[i+1][j+1] = dp[i][j];
                }
                dp[i+1][j+1] += dp[i+1][j];
                dp[i+1][j+1] += dp[i][j+1];
                dp[i+1][j+1] += MOD - dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
        }
        cout << dp[N][M] << endl;
    }
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<128>>;
#define _overload3(_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(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << (x) << '\n'
typedef long long lint;
const int INF = 2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const lint LINF = 1e18;
typedef vector<int> vint;
typedef pair<int, int> pint;
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
void print() { cout << endl; }
template <class T, class... A> void print(const T &first, const A &... rest) {
    cout << first;
    print(rest...);
}
template <class... A> void print(const A &... rest) { print(rest...); }
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;
}
int modulo(int a, int b, int n) {
    long long x = 1, y = a;
    while(b > 0) {
        if(b % 2 == 1) {
            x = (x * y) % n; // multiplying with base
        }
        y = (y * y) % n; // squaring the base
        b /= 2;
    }
    return x % n;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

int N, M;
vector<vector<int>> graph(100001, vector<int>());
int dp[100001];
vector<bool> flag(100001, false);

int f(int x) {
    if(flag[x]) {
        return dp[x];
    }
    flag[x] = true;
    int fans = 0;
    for(int tmp : graph[x]) {
        chmax(fans, f(tmp) + 1);
    }
    return dp[x] = fans;
}

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

    cin >> N >> M;
    // rep(i, N + 1) { graph[i][0] = 0; }
    int start, end;
    rep(i, 1, M + 1) {
        cin >> start >> end;
        graph[start].push_back(end);
    }
    // rep(i, 1, N + 1) {
    //     for(int x : graph[i]) {
    //         print(x);
    //     }
    // }
    int ans = 0;
    rep(i, 1, N + 1) { chmax(ans, f(i)); }
    print(ans);
}


Measured memory_bytes: 8192
from collections import deque

H, W = list(map(int, input().split()))


masu = [input() for _ in range(H)]

# search for kuro
kuro = 0
for row in masu:
    for s in row:
        if s == '#':
            kuro += 1


# search for minimum dist by bfs
que = deque([(0, 0, 0)])
move = [(1, 0), (-1, 0), (0, 1), (0, -1)]
visited = [[False for _ in range(W)] for _ in range(H)]

# print(len(visited[0]), len(visited))

while (que):
    i, j, cost = que.popleft()
    # print(i, j)

    visited[j][i] = True
    if (j == H - 1) and (i == W - 1):
        break
    for movex, movey in move:
        tmpx, tmpy = i + movex, j + movey
        # visited[tmpy][tmpx] = True

        # if (tmpx < 0) or(tmpx >= W) or (tmpy < 0) or (tmpy >= H):
        if not(tmpx in range(W)) or not(tmpy in range(H)):
            continue

        if (masu[tmpy][tmpx] == '.') and not(visited[tmpy][tmpx]):
            que.append((i + movex, j + movey, cost + 1))
            visited[tmpy][tmpx] = True
else:
    print(-1)
    exit()
# print(sum(visited[4]))
print(H * W - kuro - cost - 1)


Measured memory_bytes: 3316