akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    ll n;
    cin >> n;
    vector<ll> yaku(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i) {
            yaku[j]++;
        }
    }
    ll ans = 0;
    rep(i, n) {
        if (i == 0) continue;
        ll now = n - i;
        ans += yaku[now];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11108
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    std::string s;
    std::cin >> s;

    for (int i = 0; i < s.length() - 1; i++) {
        if (s.substr(i, 2) == "AC") {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_i
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	vector<double> p (n+1);
	vector<double> dp (n+1);
	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	/*
	for (int i = 0; i < n; i++) {
		
		dp[1] = p[1]*(1-p[2]) = p[1]*(1-p[2]) + p[2]*(1-dp[1])
		dp[2] = p[1]*p[2] = dp[2]*(1-p[3]) + (dp[1])*p[3];
		dp[3] = p[3]*dp[2]
		
		dp[1] = p[1]*(1-p[2]) + p[2]*(1-p[1]);
		dp[2] = p[2]*dp[1];
		
		dp[1] = p[1]*(1-p[2])*(1-p[3])*(1-p[4]);
		dp[2] = p[2]*dp[1]*(1-p[3])*(1-p[4]);
		dp[3] = p[3]*dp[2]*(1-p[4]);
		dp[4] = p[4]*p[3]*p[2]*p[1];
	}
	*/
	dp[0]=1;
	for (int i = 1; i <= n; i++) {
		dp[i] = p[i]*dp[i-1];
		for (int j = i-1; j >= 1; j--) {
			dp[j] = dp[j]*(1-p[i]) + p[i]*dp[j-1];
		}
	}
	printf("%.10lf\n", dp[n/2 + 1]);
	return 0;
}

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

namespace b62
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int H = int.Parse(input[0]);
            int W = int.Parse(input[1]);

            string[] line = new string[H];
            for(int i = 0; i < H; i++)
            {
                line[i] = Console.ReadLine();
            }
            for(int n = 0; n < W+2; n++)
            {
                Console.Write("#");
            }
            Console.WriteLine();
            for(int i = 0; i < H; i++)
            {
                Console.WriteLine("#"+line[i]+"#");
            }
            for(int n = 0; n < W + 2; n++)
            {
                Console.Write("#");
            }
            Console.WriteLine();
        }
    }
}


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

//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(ll i=0;i<(n);i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;

//function
template<typename T>
istream& operator>>(istream& stream,vector<T> &v){
  for(int i=0;i<v.size();i++) cin>>v[i];
  return stream;
}
template<typename T>
ostream& operator<<(ostream& stream,vector<T> &v){
  for(int i=0;i<v.size();i++) cout<<v[i]<<endl;
  return stream;
}


int main(){
	int n;
	cin>>n;
	vector<string> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	
	vector<int> col(n,0);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i][j]=='#'){
			col[j]++;
			}
		}
	}
	if(accumulate(ALL(col),0)==0){
		cout<<-1<<endl;
		return 0;
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		cnt+=(col[i]==n);
	}
	int res=1e8;
	for(int i=0;i<n;i++){
		int cmd=0;
		int ire=0;
		for(int j=0;j<n;j++){
			if(a[i][j]=='.'){
				cmd++;
				for(int k=0;k<n;k++){
					if(a[k][i]=='#'){
						break;
					}
					if(k==n-1){
						ire=1;
					}
				}
			}

		}
		res=min(res,cmd+ire+n-cnt);
	}
  cout<<res<<endl;
  return 0;
}


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

using namespace std;

#define mz 1000000007
#define pq priority_queue

bitset <4000005> bs;

int main()
{
    int n;
    int num,x,y=0;
    bs[0]=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&num);
        bs|=bs<<num;
    }
    x=bs.count();
    x=x/2+1;
    for(int i=0;i<=4000000;i++)
    {
        if(bs[i])
            y++;
        if(y==x)
        {
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}


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

using namespace std;

int main(){
 	
    int N;
    
    cin>>N;
    
    vector<int> h(N);
    
  	for(int i=0;i<N;i++){
      cin>>h[i];
    }
    
    int dp[N];
    
    dp[0]=h[0];
    dp[1]=abs(h[0]-h[1]);
    dp[2]=abs(h[0]-h[2]);
    
    for (int i=3;i<N;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        
    }
    cout<<dp[N-1]<<endl;
   
  	
}

Measured memory_bytes: 1024
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

    ll sum = LLONG_MAX;

    for (ll i = v[0]; i <= v[v.size() - 1]; i++) {
        ll ans = 0;
        for (int j = 0; j < n; j++) {
            ll k = abs(v[j] - i);
            ans += pow(k, 2);
        }
        sum = min(sum, ans);
    }
    cout << sum << endl;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int k,q; scanf("%d%d",&k,&q);
	vector<lint> d0(k);
	rep(i,k) scanf("%lld",&d0[i]);

	rep(_,q){
		lint n,x,m; scanf("%lld%lld%lld",&n,&x,&m);

		vector<lint> d(k);
		rep(i,k) d[i]=d0[i]%m;

		lint res0=0;
		res0+=count(d.begin(),d.end(),0)*((n-1)/k);
		res0+=count(d.begin(),d.begin()+(n-1)%k,0);

		lint last=x;
		last+=accumulate(d.begin(),d.end(),0LL)*((n-1)/k);
		last+=accumulate(d.begin(),d.begin()+(n-1)%k,0LL);
		lint res1=last/m-x/m;

		printf("%lld\n",(n-1)-res0-res1);
	}

	return 0;
}


Measured memory_bytes: 384
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI 3.14159265358979323846264338327950L

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b){
    if(a % b == 0){
        return(b);
    }
    else{
        return(gcd(b, a % b));
    }
}

bool isPalindrome(string s){
    REP(i, s.length() / 2){
        if(s[i] != s[(s.length() - 1) - i]){
            return false;
        }
    }
    return true;
}

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, i, j, k, l, tmp, ans;
ll D, x, y;
ll cnt;

ll sevenUp(ll i){
    return i * 10 + 7;
}

int main(){
    cin >> N;
    vector<int> ws;
    vector<int> rs;
    // w を trueとする
    string s;
    cin >> s;
    REP(i, N){
        if(s[i] == 'W'){
            ws.push_back(i);
        }else{
            rs.push_back(i);
        }
    }
    // Rは降順になるようにする
    reverse(rs.begin(), rs.end());


    // 全て片方の場合
    if(ws.size() == 0 || ws.size() == N){
        cout << 0 << endl;
        return 0;
    }
    // 既に左右に正しく分かれている場合
    if(rs[0] < ws[0]){
        cout << 0 << endl;
        return 0;
    }

    ll cnt = 0;
    i = 0;
    while(true){
        if(rs[i] > ws[i]){
            cnt++;
        }else{
            break;
        }
        i++;
        // wの方が多いとき
        if(i + 1 > rs.size()){
            cnt += ws.size() - rs.size();
            break;
        }else if(i + 1 > ws.size()){
            break;
        }
    }



    cout << cnt << endl;

    return 0;
}

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

  int n,hantei = 0;
  string color;
  cin >> n;
  
  for (int i = 0 ; i < n; i++) {
    cin >> color;
    if ( color == "Y" )
      hantei = 1;
    }
  
  if (hantei){
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
	
const ll siz = 1e5;	
const ll mod = 1e9;
const ll MAXX = 1e18;

map<pair<ll, ll>, ll> col;
vector<ll> graph[siz + 10];
ll ma = 0;

void dfs(ll node, ll par) {
	ll color = 1;
	if (color == col[make_pair(node, par)]) {
		color++;
	}
	for (ll i = 0; i < graph[node].size(); i++) {
		ll v = graph[node][i];
		if (v != par) {
			pair<ll, ll> a = make_pair(node, v);
			pair<ll, ll> b = make_pair(v, node);
			col[a] = col[b] = color;
			dfs(v, node);
			color++;
			if (color == col[make_pair(node, par)]) {
				color++;
			}	
		}
	}
	ma = max(color - 1, ma);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("INP.txt", "r", stdin);
	//freopen("OUT.txt", "w", stdout);
	ll n;
	cin >> n;
	vector<pair<ll, ll>> hold;
	for (ll i = 1; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		hold.push_back(make_pair(a, b));
	}
	dfs(1, 1);
	cout << ma << '\n';
	for (ll i = 0; i < hold.size(); i++) {
		cout << col[hold[i]] << '\n';
	}
	return 0;
}


Measured memory_bytes: 21876
#include <stdio.h>
int main(void){
    int n,m,i;
    scanf("%d%d",&n,&m);
    int s,c;
    int a[3]={-1,-1,-1};
    for(i=0;i<m;i++){
        scanf("%d%d",&s,&c);
        if(a[s-1]!=-1 && a[s-1]!=c){
            printf("-1");
            return 0;
        }
        a[s-1]=c;
    }
    if(n!=1 && a[0]==0){
        printf("-1");
        return 0;
    }
    if(n==1 && a[0]==-1) a[0]=0;
    if(n!=1 && a[0]==-1) a[0]=1;
    for(i=0;i<n;i++){
        if(a[i]==-1) printf("0");
        else printf("%d",a[i]);
    }
    return 0;
}


Measured memory_bytes: 128
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
#a,b間の距離
d=abs(b-a)
#速度差
V=v-w
if V<=0:
    print("NO")
    exit()
T=d/V
if T<=t:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9192
#include <stdio.h>

int main() {
    int num;
    int kind;
    int sweet_num;
    int cnt = 0;


    scanf("%d %d", &num, &kind);
    int sweet_have[num];

    for(int i = 0; i < kind; i++) {
        scanf("%d",&sweet_num);
        for(int j = 0; j < sweet_num; j++) {
            int num_num;
            scanf("%d",&num_num);
            sweet_have[num_num - 1] = 1;
        }
    }

    for(int m = 0; m < num; m++) {
        if(sweet_have[m] != 1) {
            cnt++;
        }
    }

    printf("%d",cnt);

    return 0;
}

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


int main(){
    ll N, M,ans = 0;
    cin >> N >> M;
    vector<ll> score(M,0);
    for(int i = 0; i < N; i++){
        ll K;
        cin >> K;
        for(int j = 0; j < K; j++){
            ll tmp;
            cin >> tmp;
            tmp--;
            score[tmp]++;
        }
    }
    for(int i = 0; i < M; i++){
        if(score[i] == N){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	
	ll h, w;
	cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << endl;
	}
	else
	{
		if ((h * w) % 2) {
			cout << h * w / 2 + 1 << endl;
		}
		else
		{
			cout << h * w / 2 << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 256
#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;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int ans = 0;
  rep(i, n){
    if((i+1) % 2 == 1 && a.at(i) % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

int main(void) {
	long long int n;
	long long int maxi = -1e18;
	priority_queue<int, vector<int>, greater<int> > first;
	priority_queue<int> second;

	cin >> n;

	vector<long long int> first_total(3 * n + 1,0), second_total(3 * n + 1,0);
	vector<long long int> a(3 * n + 1, 0);
	
	for (int i = 1; i <= 3*n; i++) {
		cin >> a[i];
	}

	for (int i = 1; i <= n; i++) {
		first.push(a[i]);
		first_total[n] += a[i];
	}

	for (int i = n+1; i <= 2 * n; i++) {
		first.push(a[i]);
		first_total[i] = first_total[i - 1] + a[i] - first.top();
		first.pop();
	}

	for (int i = 3*n; i >= 2 * n+1; i--) {
		second.push(a[i]);
		second_total[2 * n] += a[i];
	}

	for (int i = 2 * n-1; i >= n; i--) {
		second.push(a[i + 1]);
		second_total[i] = second_total[i + 1] + a[i+1] - second.top();
		second.pop();
		
	}

	for (int i = n; i <= 2 * n; i++) {
		maxi = max(maxi, first_total[i] - second_total[i]);
	}

	cout << maxi << endl;

	return 0;

}

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


struct Dinic{
  const int INF=1<<28;
  
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.push(e.to);
        }
      }
    }
  }
  
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        int d = dfs(e.to,t,min(f,e.cap));
	     if(d>0){
	       e.cap-=d;
	       G[e.to][e.rev].cap+=d;
	       return d;
	     }
      }
    }
    return 0;
  }
  
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
	     fl+=f;
	     lim-=f;
      }
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }
};

int n,m,a,b,c;
string s;
typedef pair<int,int>P;
map<P,int>M;

int main(){
  cin>>n>>m>>s;
  int S=n,T=n+1;
  Dinic D(n+2);

  r(i,n){
    int x,y=0;
    cin>>x;
    if(s[i]=='L')swap(x,y);
    D.add_edge(S,i,x);
    D.add_edge(i,T,y);
  }

  r(i,m){
    cin>>a>>b>>c; a--; b--;
    if(a>b)swap(a,b);
    M[P(a,b)]+=c;
  }

  for(map<P,int>::iterator it=M.begin();it!=M.end();it++){
    D.add_edge((*it).first.first,(*it).first.second,(*it).second);
  }

  cout<<D.flow(S,T)<<endl;
}


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

int main() {
  int N = 3, tmp;
  vector<int> sample{5, 5, 7};
  vector<int> vec(N);
  string flag = "YES";

  for (int i=0; i<N; i++) cin>>vec.at(i);

  for (int i=1; i<N; i++)
  {
    tmp = vec.at(i);
    int j = i-1;
    while (j >= 0 && tmp < vec.at(j))
    {
      vec.at(j+1) = vec.at(j);
      j--;
    }
    vec.at(j+1) = tmp;
  }

  for (int i=0; i<N; i++)
  {
    if (vec.at(i) != sample.at(i)) flag="NO";
  }

  cout << flag << endl;

  return 0;
}

Measured memory_bytes: 256
/*
AUTHOR:

'|.   '|'     |     '||    ||'     |     '|.   '|'
 |'|   |     |||     |||  |||     |||     |'|   | 
 | '|. |    |  ||    |'|..'||    |  ||    | '|. | 
 |   |||   .''''|.   | '|' ||   .''''|.   |   ||| 
.|.   '|  .|.  .||. .|. | .||. .|.  .||. .|.   '| 

*/



#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define ll int
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define all(x) x.begin(),x.end()
#define pb push_back
#define Fo(i,k,n) for(ll i=k;i<=n;i+=1)
#define deb(x) cout << #x << "=" << x << endl
#define in(a,n) Fo( i,0,n-1)cin>>a[i]
#define out(a,n) Fo( i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define IOS     ios_base::sync_with_stdio(0); cin.tie(NULL);
const ll N=2*1e6+1;


int main() {
	IOS
    ll t=1;
	//cin>>t;	
	
	Fo(_,1,t)
	{
	   //cout<<"Case #"<<_<<": ";
	   
	   ll a,b,c,k;
	   cin>>a>>b>>c>>k;
	   
	   if(k<=a+b)cout<<min(a,k);
	   else
	   {
	       cout<<a-(k-(a+b));
	   }
	 
	  
	   
	   
	   
	   
	   
	   cout<<endl;
	  
	}
	
    
}

Measured memory_bytes: 3632
H = gets.chomp.to_i
hKeys = gets.chomp.split(' ').map(&:to_i)
hKeys.unshift(nil)

(1..H).each do |i|
    print "node #{i}: key = #{hKeys[i]}, "
    print "parent key = #{hKeys[(i / 2)]}, " if i / 2.0 >= 1
    print "left key = #{hKeys[i * 2]}, " if i * 2 <= H
    print "right key = #{hKeys[i * 2 + 1]}, " if i * 2 + 1 <= H
    print "\n"
end


Measured memory_bytes: 6884
from sys import stdin
INF = int(1e9+7)
readlines = stdin.readlines


def modadd(a, b):
    # aとbを足した値をmodする(a + b mod p)
    return (a + b) % INF


def main():
    lines = readlines()
    N = int(lines[0].split()[0])
    a = set(map(int, lines[1:]))
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in a else 0
    for i in range(2, N + 1):
        if i not in a:
            dp[i] = modadd(dp[i - 1], dp[i - 2])
    print(dp[N])
    return


main()


Measured memory_bytes: 19084
def main():
    S = input()
    ans = {"AKIHABARA", "KIHABARA", "AKIHBARA", "AKIHABRA", "AKIHABAR",
           "KIHBARA", "AKIHABR", "KIHABAR", "KIHBRA", "AKIHBR",
           "KIHABR", "KIHBAR", "KIHABRA", "AKIHBAR", "AKIHABAR", "KIHBR"}
    print("YES" if S in ans else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
s = input()
n = len(s)

i = 0
numA = 0
res = 0
while i < n-1:
    if s[i] == 'A':
        numA += 1
    elif s[i] == 'B' and s[i+1] == 'C':
        res += numA
        i += 1
    else:
        numA = 0
    i += 1
print(res)


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

int main(){
    ll n, k; cin >> n >> k;
    vector<pair<ll, ll>> ab;
    for(ll i=0; i<n; i++){
        ll a, b; cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }
    sort(ab.begin(), ab.end());
    
    ll ans = 0;
    /*for(int i=0; i<n; i++){
        if(k > ab[i].second){
            k -= ab[i].second;
        }else if(k <= ab[i].second){
            ans = ab[i].first;
            break;
        }
    }*/
    ll tmp = 0;
    for(ll i=0; i<n; i++){
        tmp += ab[i].second;
        if(tmp >= k){
            cout << ab[i].first << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;

}

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

int main()
{
    int n;
    cin >> n;
    int a[100002];
    map<int, int> mp;
    int num[3] = {-1, -1, -1};
    int count[3] {0};
    int now = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        num[now] = itr->first;
        count[now] = itr->second;
        now++;
        if(now == 3) break;
    }
    if(n % 3 == 0 && count[0] == count[1] && count[1] == count[2] && count[0] == n / 3){
        if((num[0] ^ num[1] ^ num[2]) == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(n % 3 == 0 && count[0] + count[1] == n && count[0] == count[1] * 2){
        if(num[1] == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(n % 3 == 0 && count[0] + count[1] == n && count[1] == count[0] * 2){
        if(num[0] == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(count[0] == n && num[0] == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4224
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;

const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 1, 0,-1};
const int dy4[6] = {-1, 0, 1,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};
void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}

ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 6e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1000000007;
/*************************************************************************/

void solve() {
    ll h,w;
    cin>>h>>w;
    if(h==1 || w ==1) {
        cout<<1<<endl;
        return;
    }
    cout<<(h*w + 1)/2<<endl;
}


int main()
{
// #ifndef ONLINE_JUDGE
//   freopen("i.txt", "r", stdin);
//   freopen("o.txt", "w", stdout);
// #endif
  solve();
  return 0;
}





Measured memory_bytes: 256
import numpy as np
n, k, q = input().split(' ')
n, k, q = int(n),int(k), int(q)
hum = [k]*n
for i in range(q):
    ind = input()
    hum[int(ind)-1] += 1
hum_last = np.array(hum)-q
for i in range(len(hum_last)):
    if hum_last[i] <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 16840
N,K = map(int,input().split())


mod = 10 ** 9 + 7
MAX = N+K
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod



def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()
'''
def cmb(n,k):
    if k>n:
        return 0
    elif k > (n+1)/2:
        return cmb(n,n-k)
    tmp = 1
    for i in range(n-k+1,n+1):
        tmp *= i
    for i in range(1,k+1):
        tmp //= i
    tmp %= mod
    return tmp    
'''        
    
for i in range(1,K+1):
    cr = cmb(N-K+1,i)
    cb = cmb(K-1,i-1)
    ans = cr*cb
    ans %= mod
    print(ans)
    

Measured memory_bytes: 3824
#include <iostream>
using namespace std;
int main() {
	int a[3],t;
	for (int i=0;i<3;i++)
		cin >> a[i];
	for (int i=0;i<2;i++){
		for (int j=0;j<3-i;j++){
			if (a[j]<a[j-1]){
				t=a[j];
				a[j]=a[j-1];
				a[j-1]=t;
			}
		}
	}
	for (int i=0;i<3;i++)
		cout << a[i] << (i!=2?" ":"");
	cout << endl;
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi; 
typedef pair<pair<ll ,ll >,ll > pii; 

int main(){

    ll N;
    cin >> N;

    ll t_N = N;
    ll sum = 0;

    while(t_N > 0){
        sum += t_N % 10;
        t_N = t_N / 10;
    }

    if(N % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; string s; cin >> n >> s;
  ll r = count(all(s),'R');
  ll g = count(all(s),'G');
  ll b = count(all(s),'B');
  
  ll ans = r*g*b;
  
  for(ll i=0; i <= n-1; i++){
    for(ll j=1; (i+2*j) <= n-1; j++){
      if(s[i] != s[i+j] and s[i+j] != s[i+2*j] and
         s[i+2*j] != s[i]) ans--;
    }
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#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 repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

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

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

	ll ans=1;
	bool up=0;
	bool dn=0;

	ll cr;
	cin >> cr;

	rep(i,n-1) {
		ll a;
		cin >> a;
		if (cr<a) up=1;
		if (cr>a) dn=1;
		if(up&&dn) {
			up=0;
			dn=0;
			++ans;
		}
		cr=a;
	}
	cout << ans << LF;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,x,y;
    cin>>n;
    ll a[n];
    ll freq[100005]={0};
    for(i=0;i<n;i++){
        cin>>a[i];
        freq[a[i]]+=1;
        ans+=a[i];
    }
    ll q;
    cin>>q;
    while(q--){
        cin>>i>>j;
        if(freq[i]!=0){
            ans=ans-(freq[i]*i)+(freq[i]*j);
            freq[j]+=freq[i];
            freq[i]=0;
            cout<<ans<<endl;
        }
        else{
            cout<<ans<<endl;
        }
    }
   


    return 0;
}

Measured memory_bytes: 5164
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
a.reverse!
b.reverse!
sum = 0
n.times do |i|
  if b[i] >= a[i]
    sum += a[i]
    b[i] -= a[i]
    a[i] = 0
    if b[i] >= 1
      if a[i+1] - b[i] >= 0
        a[i+1] -=  b[i]
        sum += b[i]
      else
        sum += a[i+1]
        a[i+1] = 0
      end
    end
  else
    sum += b[i]
    a[i] -= b[i]
  end
end
puts sum

Measured memory_bytes: 15388
from math import ceil,floor,comb,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def bfs():
    d = [[inf]*w for i in range(h)]

    dy = [0, 1, 0, -1]
    dx = [1, 0, -1, 0]
 
    que = deque([])
    que.append((sy, sx))
    d[sy][sx] = 0
    ret = 0
 
    while que:
        p = que.popleft()
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]
 
            if 0 <= ny < h and 0 <= nx < w and maze[ny][nx] != '#' and d[ny][nx] == inf:
                que.append((ny,nx))
                d[ny][nx] = d[p[0]][p[1]] + 1
                ret = max(ret, d[ny][nx])
 
    return ret

h, w = MAP()
maze = [input() for i in range(h)]
ans = 0

for sy in range(h):
    for sx in range(w):
        if maze[sy][sx] == '#':
            continue
        else:
            ans = max(ans, bfs())

print(ans)

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

using namespace std;
int pre[100005];
bool marked[100005];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,q,l,r;
    string s;
    cin>>n>>q;
    cin>>s;
    for(int i=0;i<(int)s.size()-1;++i){
        if(s[i]=='A'&&s[i+1]=='C') pre[i+2]=1,marked[i+2]=true;
    }
    for(int i=1;i<100004;++i){
        pre[i]=pre[i]+pre[i-1];
    }
//    for(int i=0;i<=n;++i) cout<<pre[i]<<" ";
    cout<<endl;
    while(q--){
        cin>>l>>r;
        int ans=pre[r]-pre[l-1];
        if(marked[l]) --ans;
        cout<<ans<<endl;
    }
    return 0;
}



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

a.sort(reverse = True)
comfort = 0

if n%2 == 0:
    for i in range(n//2):
        if i == 0:
            comfort += a[i]
        else:
            comfort += 2*a[i]
    print(comfort)
else:
    for j in range((n-1)//2):
        if j == 0:
            comfort += a[j]
        else:
            comfort += 2*a[j]
        if j == ((n-1)//2-1):
            comfort += a[j+1]
    print(comfort)

Measured memory_bytes: 31508
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scin = new Scanner(System.in);
		int numCount = Integer.parseInt(scin.nextLine());
		String[] vals = scin.nextLine().split(" ");
		
		int[] nums = new int[vals.length];
		for (int i = 0; i < vals.length; i++) {
			nums[i] = Integer.parseInt(vals[i]);
		}
		
		for (int i = 0; i < nums.length; i++) {
			String out = "node " + (i+1) + ": key = " + nums[i] + ", ";
			int parrentVal = (i + 1) / 2;
			if (parrentVal > 0) {
				out += "parent key = " + nums[parrentVal - 1] + ", ";
			}
			
			int leftVal = (2 * (i + 1));
			if (leftVal - 1 < nums.length) {
				out += "left key = " + nums[leftVal - 1] + ", ";
					
				//left key = 2, right key = 3, 
			}
			
			int rightVal = (2 * (i + 1)) + 1;
			if (rightVal - 1 < nums.length) {
				out += "right key = " + nums[rightVal - 1] + ", ";
					
				//left key = 2, right key = 3, 
			}
				
			System.out.println(out);
		}
		
	}
	
	
}


Measured memory_bytes: 27584
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define loop(i,m,p) for ($$ i = m; i < p; ++i)

using namespace std;


int main()
{
  $$ x;
  cin>>x;
  if ((x==7)||(x==5)||(x==3))
  {
    cout<<"YES";
  }
  else
    cout<<"NO";

    return 0;

}


Measured memory_bytes: 256
N, C = map(int, input().split())
latest = 0
P = [[] for i in range(C)]
for i in range(N):
    s, t, c = map(int, input().split())
    P[c-1].append((s, t))
    latest = max(latest, t)

Dup = [0 for i in range(latest + 2)]
for i in range(C):
    P[i].sort()
    for j in range(len(P[i])):
        Dup[P[i][j][0]] += 1
        Dup[P[i][j][1] + 1] -= 1
        if j >= 1:
            if P[i][j][0] == P[i][j-1][1]:
                Dup[P[i][j][0]] -= 1
                Dup[P[i][j][0] + 1] += 1
for i in range(1, latest + 2):
    Dup[i] += Dup[i-1]
print(max(Dup))

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

int par[12345];

void Init() {
  for(int i = 0; i < 12345; ++i) {
    par[i] = i;
  }
}

int Find(int x) {
  if( par[x] == x ) {
    return x;
  }
  else {
    return par[x] = Find(par[x]);
  }
}

void Unite(int x, int y) {
  x = Find(x);
  y = Find(y);
  if( x == y ) return;
  if( rand() & 0x01 ) {
    par[x] = y;
  }
  else {
    par[y] = x;
  }
}

bool Same(int x, int y) {
  return Find(x) == Find(y);
}

int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  Init();
  for(int i = 0; i < q; ++i) {
    int c, x, y;
    scanf("%d %d %d", &c, &x, &y);
    if( c == 0 ) {
      Unite(x, y);
    }
    else {
      printf("%d\n", Same(x, y) ? 1 : 0);
    }
  }
  
  return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	if (S[5] == '1' || S[6] >= '5')
		cout << "TBD" << endl;
	else
		cout << "Heisei" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#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 int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n; cin >> n;
    /*for (int i = 1; i <= n; i++) {
        for (int j = 1; j * j <= n; j++) {
            for (int k = j; k * k <= n; k++) {
                int l = sqrt(2 * i - j * j - k * k);
                if ()
            }
        }
    }
    */

    for (int N = 1; N <= n; N++) {
        int cnt = 0;
        for (int i = 1; i * i <= 2 * N; i++) {
            for (int j = 1; j * j <= 2 * N; j++) {
                double k = 0.1;
                if (2 * N - i * i - j * j > 0) k = sqrt(2 * N - i * i - j * j);
                //cout << k << endl;
                if (floor(k) == k && k >= 1) {
                    if ((-1) * i + j + k >= 2 && i - j + k >= 2 && i + j - k >= 2) cnt++;
                }
                //if (N == 3) cout << i << j << k << endl;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3620
// IlyM

#include <bits/stdc++.h>

#define pb push_back
#define sp " "
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (unsigned long long a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
string a;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>a;
	if (a[2]==a[3] && a[4]==a[5]) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char S[200001];
	scanf("%s", S);
	
	int i, count[2019] = {1}, tmp[2] = {0, 1};
	long long ans = 0;
	for (i = 0; S[i] != 0; i++);
	for (i--; i >= 0; i--) {
		tmp[0] = (tmp[0] + tmp[1] * (S[i] - '0')) % 2019;
		ans += count[tmp[0]]++;
		tmp[1] = tmp[1] * 10 % 2019;
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1936
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
// #include <iostream>
// #include <iomanip>
// #include <sstream>
using namespace std;
// const int dx[] = {0, 1, 0, -1};
// const int dy[] = {1, 0, -1, 0};
// const int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
// const int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dx[] = {2, 2, -2, -2, 1, 1, -1, -1};
// const int dy[] = {-1, 1, 1, -1, 2, -2, 2, -2};
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define test_ fr(_iii_, 0, 66)pf(">");puts("in")
#define deb(x) fr(_iii_, 0, 66)cerr<<'>';cerr<<#x"="<<x<<"\n"
#define fr(i, a, b) for(int i = a ; i < (int)b ; i++)
#define frr(i, a, b) for(int i = a ; i >= (int)b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false)
#define boost2 cin.tie(NULL)
#define ln puts("")
#define mems(a) memset(a, 0, sizeof(a))
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
int on_bit(int x, int pos) {x |= (1 << pos); return x;}
int off_bit(int x, int pos) {x &= ~(1 << pos); return x;}
bool is_on_bit(int x, int pos) {return ((x & (1 << pos)) != 0);}
int flip_bit(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int on_bit_all(int x, int pos) {x = (1 << pos)-1; return x;}
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}


int main() {
	int n, time_limid;
	sf("%d %d",&n,&time_limid);
	int res = INF;
	fr(i,0,n){
		int ci, ti;
		sf("%d %d",&ci,&ti);
		if(ti <= time_limid)res = min(res, ci);
	}
	if(res==INF)puts("TLE");
	else pf("%d\n",res);
	return 0;
}

Measured memory_bytes: 128
N = input()
A = input()
a = A.split(' ')

si = []
for i in a:
    j = int(int(i) % 4)
    si.append(j)

kazu = []
for i in range(4):
    j = si.count(i)
    kazu.append(j)

x = int(int(kazu[2]) % 2)
if x == 0:
    y = int(int(kazu[1]) + int(kazu[3]) - 1)
else:
    y = int(int(kazu[1]) + int(x) + int(kazu[3]) - 1)

if int(kazu[0]) >= int(y):
    print('Yes')
else:
    print('No')

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

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

	vector<int> p(N);
	rep(i, N) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int sum = 0;
	rep(i, K) {
		sum += p[i];
	}
	cout << sum << endl;
}

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

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll>A(N);
    map<ll, ll>mp1;
    map<ll, ll>mp2;
    set<ll>s;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if ((i+1)-A[i] >= 2) {
            mp1[(i+1)-A[i]]++;
        }
        s.insert(A[i]+i+1);
        mp2[A[i]+i+1]++;
    }
    ll ans = 0;
    for (auto ite = s.begin(); ite != s.end(); ite++) {
        ans += mp1[*ite] * mp2[*ite];
    }
    cout << ans << endl;
}


Measured memory_bytes: 38988
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

// 約数を全部出してくれる
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

ll X;

int Main() {
    cin >> X;
    vl dv = divisor(X);
    
    for(auto &e: dv) {
//        cout << e << endl;
        ll A = e;
        ll B = X/e;
        
        ll r = sqrt(B);
        rep(i, r+1) {
            ll a = i;
            ll b = i-A;
            ll hoge = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
            if(hoge == B) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

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


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b; cin>>a>>b;
    if(a<=b) print(a);
    else print(a-1);
    return 0;
}

Measured memory_bytes: 256