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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int H, W, A, B;

int main() {
	read(H), read(W), read(A), read(B);
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			putchar((i <= B) ^ (j <= A) ^ '0');
		}
		putchar('\n');
	}
}


Measured memory_bytes: 4656
from math import factorial
def f(a, b):
    if a == 0 or b == 0:
        return 1
    else:
        return factorial(a) // (factorial(a - b) * factorial(b))
n, p = map(int, input().split())
a = [int(x) % 2 for x in input().split()]
e, o = a.count(0), a.count(1)
if p == 0:
    print((2**e)*sum([f(o, i) for i in range(0, o+1, 2)]))
else:
    print((2**e)*sum([f(o, i) for i in range(1, o+1, 2)]))

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

int main(){
       int n;
       long long a;
       long long min = 1000000;
       long long max = -1000000;
       long long sum = 0;

       cin>>n;

       for(int i=1;i<=n;i++){
	      cin>>a;

	      if(a>max) max = a;
	      if(a<min) min = a;

	      sum += a;
       }

       cout<<min<<' '<<max<<' '<<sum<<endl;
       
       return 0;
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void Dump(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

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

    auto v = vai(3);
    cin >> v[0] >> v[1] >> v[2];
    
    cout << v.min() << " " << v.max() << endl;

    return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main() {

    int t = 1;
    //cin>>t;

    while(t--) {

        string s1,s2;
        cin>>s1>>s2;
        s1 += char(s2[s2.length()-1]);
        if(s2==s1)cout<<"Yes\n";
        else cout<<"No\n";

    }

}




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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

ll dp[200010],n,c[200010];
vector<int>v[200010];

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c[i];
		v[c[i]].eb(i);
	}
	return;
}

void solve(){
	dp[0]=1;
	for(int i=0;i<n-1;i++){
		dp[i+1]=(dp[i+1]+dp[i])%MOD;
		int it=lower_bound(ALL(v[c[i]]),i)-v[c[i]].begin();
		if(it==v[c[i]].size()-1)continue;
		it++;
		if(i+1==v[c[i]][it])continue;
		dp[v[c[i]][it]]=(dp[v[c[i]][it]]+dp[i])%MOD;
	}
	cout<<dp[n-1]<<endl;
	return;
}

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

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

void solve(std::string s) {

  if (s[0] == s[s.size() - 1]) {
    if (s.size() % 2 == 0) {
      cout << "First" << endl;
    } else {
      cout << "Second" << endl;
    }
  } else {
    if (s.size() % 2 == 0) {
      cout << "Second" << endl;
    } else {
      cout << "First" << endl;
    }
  }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string s;
  std::cin >> s;
  solve(s);
  return 0;
}


Measured memory_bytes: 512
using System;
using System.IO;
using System.Linq;

class Solve{
    static void Main(string[] args){
        var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var M = arr[2];
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var answer = a.Min() + b.Min();
        for (int i = 0; i < M; i++){
            var xyc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var disctTgt = a[xyc[0] - 1] + b[xyc[1] - 1] - xyc[2];
            answer = disctTgt < answer ? disctTgt : answer;}
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 53056
#include<iostream>
#include<algorithm>

using namespace std;

int digit(long long x){
    int count=0;
        while(x>0){
            x/=10;
            count++;
        }
    return count;
}

int main(){
    long long N;
    cin>>N;
    int mini=digit(N);
        for(long long i=1;i*i<=N;++i){
            if(N%i!=0)continue;
            const long long j=N/i;
            const int compare=max(digit(i),digit(j));
            mini=min(compare,mini);

        }
    cout<<mini;
}

Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll a,b,t;
    cin >> a >> b >> t;

    cout << (t/a) * b << endl;

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
N = int(input())
A = [int(input()) for _ in range(N)]
A_sorted = sorted(A)
A = [bisect_left(A_sorted, a) for a in A]
res = 0
for i, a in enumerate(A):
    if (i-a)%2:
        res+=1
print(res//2)
    

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

using namespace std;
int main() {
    int n; cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; ++i){
        cin >> x[i];
    }
    vector<int> sorted = x;
    sort(sorted.begin(), sorted.end());
    int l = sorted[n / 2 - 1];
    int r = sorted[n / 2];

    for(int i = 0; i < n; ++i){
        if(x[i] <= l){
            cout << r << endl;
        }
        else{
            cout << l << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

int d[101],pi[101],color[101];
int ans = 0;
int A[101][101];

void prim(int n,int r){
  int i,min,u;
  for(i=1;i<=n;i++){
    d[i] = 2001;
    pi[i] = -1;
    color[i] = 0;
  }
  
  //printf("unko3\n");
  d[r] = 0;
  
  while(1){
    min = 2001;
    for(i=1;i<=n;i++){
      if(color[i] != 2 && d[i] < min){
	min = d[i];
	u = i;
	//printf("unko4\n");
      }
    }
    if(min == 2001){
      //printf("unko5\n");
      break;
    }

    color[u] = 2;

    for(i=1;i<=n;i++){
      if(color[i] != 2 && A[u][i] != -1 && A[u][i] < d[i]){
	pi[i] = u;
	d[i] = A[u][i];
	//printf("unko6\n");
      }
    }
  }
}

int main(){
  int i,j,n;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&A[i][j]);
    }
  }
  //printf("unko1\n");
  prim(n,1);
  //printf("unko2\n");
  for(i=1;i<=n;i++){
    ans += d[i];
  }
  printf("%d\n",ans);
  return 0;
  
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353

ll gcd(ll A, ll B){
    if(A<B) swap(A,B);
    while(B){
        ll w = A%B;
        A = B;
        B = w;
    }
    return A;
}

ll lcm(ll A, ll B){return A/gcd(A,B)*B;}

ll factmod(ll N){
    if(0==N) return 1LL;
    ll res = N;
    while(N>1){
        res *= --N;
        res %= MOD;
    }
    return res;
}

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

    // solution comes here

    ll N, M;
    cin >> N >> M;

    ll t = abs(N-M);
    if(t >= 2) {
        cout << 0 << nl;
        return 0;
    }

    if(1==t) {
        cout << (factmod(N)*factmod(M))%MOD << nl;
    }
    else {
        cout << (2LL*factmod(N)*factmod(M))%MOD << nl;
    }
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List

isAnyDigitThree :: Int -> Bool
isAnyDigitThree 0 = False
isAnyDigitThree n = (if n`mod`10==3 then True else isAnyDigitThree (n`div`10))

threeList :: Int -> [Int]
threeList n = [ x | x<-[1..n], (x`mod`3==0) || isAnyDigitThree x ]

main = getLine >>= putStrLn . (" "++) . unwords . (map show) . threeList . (read::String->Int)

Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define SZ(v) ((int)((v).size()))
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int nbRow,nbCol;
	cin >> nbRow >> nbCol;
	vector<string> grid(nbRow);
	for (string &s:grid) cin >> s;
	for (int targ = 0; targ < 2; ++targ) {
		for (int row = 0; row < nbRow; ++row) {
			for (int col = 0; col < nbCol; ++col) {
				int x = row%2;
				if (col == 0) x = 0;
				if (col == nbCol-1) x = 1;
				if (targ == x || grid[row][col] == '#') cout << '#';
				else cout << '.';
			}
			cout << "\n";
		}
		cout << "\n";
	}
}


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

#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

struct UnionFind
{
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int root(int x)
    {
        if(d[x]<0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y)
    {
        x = root(x); y = root(y);
        if (x==y)
        {
            return false;
        }
        if (-d[x] < -d[y]) swap(x,y); //y.size()が小でx.size()が大にしておきたい
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y){return root(x)==root(y);}
    int size(int x){return -d[root(x)];}
};

int deg[100005];
vector<int> to[100005];

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i,m)
    {
        int a,b;
        cin >> a  >> b;
        --a; --b;
        deg[a]++; deg[b]++;
        uf.unite(a,b);
    }
    rep(i,k)
    {
        int a, b;
        cin >>  a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    rep(i,n)
    {
        int ans = uf.size(i)-1-deg[i];
        for(int u: to[i])
        {
            if (uf.same(i,u)) --ans;
        }
        cout << ans << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int,int> pr;
#define fr(i, n) for(int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c)(c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x)((c).find(x) != (c).end())
#define cpresent(c, x)(find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template < class mytype >
mytype power(mytype a, mytype b, mytype m){if (b == 1) return a % m;if (b == 0) return 1;
mytype root = power < lli > (a, b / 2, m);mytype ans = (root * root) % m;if (b % 2) ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template < class type >type gcd(type a, type b){if (a == 0) return b;else return gcd(b % a, a);}
template < class type >type mod_inv(type a, type p) {return power(a, p - 2, p);}

int main()
{
    int n,weight;
    cin >> n >> weight;
    vector<lli> dp(weight + 1 , 0);
    for(int i1 = 0 ; i1 < n ; i1++) {
        int w, v;
        cin >> w >> v;
        for(int i = (weight - w) ;i >= 0; --i){
            dp[i+w] = max(dp[i+w] , dp[i] + v);
        }
    }
    lli wans = 0 ;
    for(int i = 0 ; i <= weight ; i++) wans = max(wans , dp[i]);
    cout << wans << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Vector;

class Main {
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {

		Vector<Vector<Integer>> list = new Vector<>();

		int n = scan.nextInt();
		for(int i=0; i<n; i++) {
			list.add(new Vector<Integer>());
		}

		int count = scan.nextInt();

		for(int i=0; i<count; i++) {
			int query = scan.nextInt();
			int a = scan.nextInt();

			switch(query) {

			case 0:	//pushBack
				int b = scan.nextInt();
				list.get(a).add(b);

				break;

			case 1:	//dump
				if(!list.get(a).isEmpty()) {
					for(Integer j=0; j<list.get(a).size()-1; j++) {
						System.out.print(list.get(a).get(j) + " ");
					}
					System.out.println(list.get(a).get(list.get(a).size()-1));
//					for(Integer x : list.get(a)) {
//						System.out.print(x + " ");
//					}
//					System.out.println();
				}else
					System.out.println();
				
				break;

			case 2:	//clear
				list.get(a).clear();
				
				break;
			}
		}
	}
}



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

#define fi first
#define se second
#define amen exit(0)

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll D = 100007;
const ll Inf = 1000000007;

int main()
{
    ll x, y;
    cin >> x >> y;
    if (y == 100)
        cout << 101;
    else
        cout << y;
    for (ll i = 1; i <= x; i++)
        cout << "00";
    cout << endl;
    amen;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long int lli;

int main() {
  int N;
  scanf("%d",&N);
  lli A[N];
  for (int i=0; i<N; i++) {
    scanf("%lld",&A[i]);
  }
  lli ans=0;
  while (true) {
    lli Even_number=0;
    for (int i=0; i<N; i++) {
      if (A[i]%2==0) {
        Even_number++;
      } else {
        break;
      }
    }
    if (Even_number!=N) {
      break;
    } else {
      ans++;
    }
    if (Even_number==N) {
      for (int i=0; i<N; i++) {
        A[i]/=2;
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}


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

LL gcd(LL a, LL b)  
{  
    return b==0?a:gcd(b,a%b);  
}

int main()
{
	LL n, x;
	cin >> n >> x;
	LL ans = 3 * (n - gcd(n, x));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
i = 1

loop do
  x = i
  if (x % 3 == 0) 
    printf " %d", i
  else
    loop do
      if (x % 10 == 3 ) 
        printf " %d", i
        break
      end
      x /= 10
      break if x == 0
    end
  end
  i += 1
  break if (i > n)
end
puts


Measured memory_bytes: 8900
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	diff := b - a
	west := 0
	// 結局これは等差数列の和
	for i := 1; i < diff; i++ {
		west += i
	}
	fmt.Println(west - a)
}

Measured memory_bytes: 512
var
	L,A,B,M,pre,tmpten,ans,ll,rr,mm,k,X,Y,p,g:int64;
	n,i:Longint;
	ten,sten,iten:array[0..60]of int64;
	cnt,sum:array[1..18]of int64;
	bit:array[0..62]of int64;
begin
	read(L,A,B,M);
	bit[0]:=1;
	for i:=1 to 62 do bit[i]:=bit[i-1]*2;
	pre:=-1;
	tmpten:=1;
	ans:=0;
	for n:=1 to 18 do begin
		cnt[n]:=1;
		ll:=pre;
		rr:=L;
		tmpten:=tmpten*10;
		while rr-ll>1 do begin
			mm:=(ll+rr)div 2;
			if A+B*mm<tmpten then ll:=mm else rr:=mm;
		end;
		k:=ll-pre;
		if k<0 then continue;
		pre:=ll;
		ten[0]:=tmpten mod M;
		sten[0]:=1;
		iten[0]:=0;
		if k mod 2=1 then cnt[n]:=tmpten mod M;
		for i:=1 to 60 do begin
			ten[i]:=ten[i-1]*ten[i-1]mod M;
			sten[i]:=(ten[i-1]+1)*sten[i-1]mod M;
			iten[i]:=(iten[i-1]+(iten[i-1]+bit[i-1]mod M*sten[i-1])mod M*ten[i-1])mod M;
			if(k and bit[i])<>0 then cnt[n]:=cnt[n]*ten[i]mod M;
		end;
		X:=0;
		Y:=0;
		p:=1;
		g:=0;
		for i:=60 downto 0 do begin
			if(k and bit[i])<>0 then begin
				X:=(X+sten[i]*p)mod M;
				Y:=(Y+iten[i]*p+sten[i]*g mod M*p)mod M;
				p:=p*ten[i]mod M;
				g:=(g+bit[i])mod M;
			end;
		end;
		sum[n]:=(((A+B*ll)mod M*X-B mod M*Y)mod M+M)mod M;
	end;
	p:=1;
	for i:=18 downto 1 do begin
		ans:=(ans+sum[i]*p)mod M;
		p:=p*cnt[i]mod M;
	end;
	writeln(ans);
end.


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

int main(){
    int x;
    cin >> x;
    int k = x % 10;
    if (k == 3){
        cout << "bon" << endl;
    }else if(k==0 | k == 1 | k==6| k==8){
        cout << "pon"<< endl;
    } else{
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  ll x,y;
  cin >> x >> y;
  ll cnt = 0;
  while(x <= y){
    x *= 2;
    cnt++;
  }
  cout << cnt << endl;
}


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

int main() {
	int n;
	cin>>n;
	if(n%10==2 ||  n%10==4 || n%10==5 || n%10==7 || n%10==9) cout<<"hon"<<endl;
	else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) cout<<"pon"<<endl;
	else cout<<"bon"<<endl;

	return 0;
}

Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)     for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

const int N = 1e5 + 5;
vector<int> G[N];
bool vis[N];

void DFS(int vertex){
   vis[vertex] = true;
   for(int u : G[vertex]){
        if(!vis[u])
           DFS(u);
   }
}

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  
 int n, m; cin >> n >> m;
 for(int i = 0; i < m; i++){
     int x, y; cin >> x >> y;
     G[x].eb(y);
     G[y].eb(x);
 }
 int ans = 0;
 for(int i = 1; i <= n; i++){
     if(!vis[i]){
         DFS(i);
         ans++;
     }
 }
 cout << ans - 1 << anal;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

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

int main() {
	int n,w;
	cin >> n >> w;
	int we[n],val[n];
	long long int sum = 0; 
	for(int i = 0;i < n;i++) cin >> we[i] >> val[i], sum += val[i];
	long long int dp[sum+1]; dp[0] = 0;
	for(int i = 1;i <= sum;i++)
	dp[i] = INT_MAX;
	for(int  i = 0;i < n;i++)
	{
		for(int j = sum - val[i];j >= 0;j--)
		dp[j+val[i]] = min(dp[j] + we[i],dp[j+val[i]]);
	}
	long long int answer = -1;
	for(int i = 0;i <= sum;i++) if(dp[i] <= w) answer = i;
	cout << answer << "\n";
	
	return 0;
}

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

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    double s = 0.5 * w * h;

    bool b = (2 * x == w && 2 * y == h);

    printf("%.11lf %d\n", s, b);
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>m>>n;
    if(n==0){
        cout<<m<<endl;
        return 0;
    }
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    set<ll> s;
    rep(i,n){
        cin>>a;
        s.insert(a);
    }
    ll lastz;
    ll lastnum;
    lastz=1000000000;
    lastnum=0;
    rep(i,102){
        if(s.find(i)!=s.end()) continue;
        if(lastz>abs(m-i)){
            lastz=abs(m-i);
            lastnum=i;
        }
    }
    cout<<lastnum<<endl;

    return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <deque>
#include <set>
typedef long long lld;
const int MAXA = 26;
const int MAXC = 2E5+5;
char buff[MAXC]{ };
int  dest[MAXC]{ };
std::deque<int> pos[MAXA]{ };
lld ret=0LL;
int L;

struct BinaryIndexedTree
{
	int data[MAXC]{ };

	void add(int x)
	{
		for(int i = x; i <= L; i += i & -i)
			++data[i];
	}

	int get(int x)
	{
		int sum = 0;
		for(int i = x; i >= 1; i -= i & -i)
			sum += data[i];
		return	sum;
	}
} bintr;

int main()
{
	scanf("%s", buff+1);
	L = strlen(buff+1);
	for(int i = 1; i <= L; ++i)
		pos[buff[i]-'a'].push_back(i);
	int odd = -1;
	for(int i = 0; i < MAXA; ++i)
		if(pos[i].size() & 1)
		{
			if(odd != -1)
				return puts("-1"), 0;
			odd = i;
		}
	if(odd != -1)
	{	// Handle Unique Centre
		int mid = pos[odd][pos[odd].size() / 2];
		for(int i = 0; i < MAXA; ++i)
			for(int j = 0; j*2 < (int)pos[i].size(); ++j)
				ret +=	(pos[i][j] > mid) +
					(pos[i][(int)pos[i].size()-j-1] < mid);
	}
	int cnt = 1;
	for(int i = 1; i <= L; ++i) if(!dest[i])
	{	// Record Destinations
		int beg = pos[buff[i]-'a'].front();
		int end = pos[buff[i]-'a'].back();
		pos[buff[i]-'a'].pop_front();
		if(beg == end) continue;
		pos[buff[i]-'a'].pop_back();
		dest[end] = L-cnt+1;
		dest[beg] = cnt++;
	}
	for(int i = 1; i <= L; ++i) if(dest[i])
	{	// Compute Inversions
		ret += bintr.get(L-dest[i]+1);
		bintr.add(L-dest[i]+1);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 2816
#include<iostream>
using namespace std;
#define ll long long int
#define pb push_back
#define test ll t; cin>>t; while(t--)

int main()
{
char x;
  ll ans=0;
  while(cin>>x)
  { int p=x-'0';
   ans+=p;
    if(ans%9==0) ans=0;
  }
  if(ans%9) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3616
kukuString x y = show x ++ "x" ++ show y ++ "=" ++ show (x*y)

solve 10 _ = []
solve x 9 = kukuString x 9 : solve (x+1) 1
solve x y = kukuString x y : solve x (y+1)

main = mapM_ putStrLn $ solve 1 1

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
long a, b, d;
int r;
double f;

int main()
{
    scanf("%li %li", &a, &b);
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    printf("%li %d %lf\n", d, r, f);
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T>
CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T>
T Sq(const T &t) {
  return t * t;
}

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex) exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex) exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int N = read(), K = read();
  if (round(N / 2.0) >= K)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    ll N = S.size();
    ll cnt = 0;
    for (int i = 1; i < N; i++) {
      if (S[i] == S[i - 1]) {
          if(S[i]=='0'){
            S[i] = '1';
            cnt++;
          }
          else if(S[i]=='1'){
              S[i] = '0';
              cnt++;
          }
      }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3728
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub struct Graph {
    graph: Vec<Vec<usize>>,
    vn: usize,
}

type Edge = (usize, usize);
impl Graph {
    pub fn new(edges: &[Edge], vn: usize) -> Self {
        let mut graph = vec![Vec::new(); vn];
        for &(u, v) in edges {
            graph[u].push(v);
            graph[v].push(u);
        }
        Self { graph, vn }
    }

    pub fn new_directed(edges: &[Edge], vn: usize) -> Self {
        let mut graph = vec![Vec::new(); vn];
        for &(u, v) in edges {
            graph[u].push(v);
        }
        Self { graph, vn }
    }

    pub fn add_directed_edge(&mut self, e: Edge) {
        self.graph[e.0].push(e.1);
    }

    pub fn add_edge(&mut self, e: Edge) {
        self.graph[e.0].push(e.1);
        self.graph[e.1].push(e.0);
    }

    pub fn shortest_path(&self, start: usize) -> Vec<Option<usize>> {
        let mut cost_list = vec![None; self.vn];
        let mut que = std::collections::VecDeque::new();
        cost_list[start] = Some(0);
        que.push_back(start);
        while let Some(u) = que.pop_front() {
            for &v in &self.graph[u] {
                if cost_list[v].is_some() {
                    continue;
                }
                let new_cost = cost_list[u].unwrap() + 1;
                cost_list[v] = Some(new_cost);
                que.push_back(v);
            }
        }
        cost_list
    }
}

fn solve() {
    input! {
        n: usize, u: Usize1, v: Usize1,
        edges: [(Usize1, Usize1); n - 1]
    };

    let graph = Graph::new(&edges, n);
    let td = graph.shortest_path(u);
    let ad = graph.shortest_path(v);
    let mut res = 0;
    for i in 0..n {
        let t = td[i].unwrap();
        let a = ad[i].unwrap();
        if t < a {
            res = res.max(a - 1);
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 13092
N,M = map(int,input().split())
listF=[]
for i in range(N):
    listF.append(list(map(int,input().split())))

listC=listF[0][1:]

for i in range(N-1):
    listC=list(set(listF[i+1][1:]) & set(listC))

print(len(listC))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int ninzuu[4][3][10];
int main() {
  int N; cin >>N;
  int a,b,c,d;
  for(int i=0;i<N;i++){
    cin>>a>>b>>c>>d;
    ninzuu[a-1][b-1][c-1]+=d;
  }
  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
        int kotae=max(0,ninzuu[i][j][k]);
        kotae=min(9,ninzuu[i][j][k]);
        cout<<" "<<kotae;
      }
      cout<<endl;
    }
    if(i!=3)cout<<"####################"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3108
import numpy as np
h,w = map(int,input().split())
lst = []
ans = []
for i in range(h):
    s = input()
    tmp = s.replace('.','')
    if tmp:
        lst.append(list(s))
matrix = np.array(lst)
matrix = matrix.T
for i in range(w):
    s = ''.join(matrix[i])
    tmp = s.replace('.','')
    if tmp:
        ans.append(list(s))
matrix2 = np.array(ans)
matrix2 = matrix2.T
for j in matrix2:
    s = ''.join(j)
    print(s)

Measured memory_bytes: 12620
import datetime
date_str = input()
date_formatted = datetime.datetime.strptime(date_str, "%Y/%m/%d")
last_heisei = datetime.datetime(2019, 4, 30, 0, 0, 0)
if date_formatted <= last_heisei:
  print("Heisei")
else:
  print("TBD")

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
int N,C,K;
int T[100005];
int main() {
    cin >> N >> C >> K;
    for (int i = 0; i < N; i++) cin >> T[i];
    sort(T, T + N);
    T[N] = 2000000002;
    int pt = T[0];
    int pc = 1;
    int res = 0;
    for (int i = 1; i <= N; i++) {
        pc++;
        if( pc > C || T[i]-pt > K ) {
            res++;
            pc = 1;
            pt = T[i];
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  LLI N,M,V,P;
  while(cin >> N >> M >> V >> P){
    vector<LLI> A(N+1, INT_MAX);
    FORE(i,1,N) cin >> A[i];
    sort(RALL(A));

    dump(A);

    auto check =
      [&](int k){
        if(k <= P) return true;
        if(A[k] + M < A[P]) return false;

        LLI t = 0;

        FORE(i,1,P-1){
          t += M;
        }

        FORE(i,k,N){
          t += M;
        }

        
        FOR(i,P,k){
          if(A[i] > A[k] + M) return false;
          t += min(M, A[k]+M-A[i]);
        }

        if(t < M*V) return false;
        
        return true;
      };


    int lb = 0, ub = N+1;
    while(abs(lb-ub) > 1){
      int mid = (lb+ub) / 2;

      if(check(mid)){
        lb = mid;
      }else{
        ub = mid;
      }
    }
    
    cout << lb << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 100000000005LL
#define MOD 1000000007

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

ll n,s;

ll f(ll b,ll N){
	ll a = 0;
	while(N>0){
		a += N%b;
		N /= b;
	}
	return a;
}

vector<ll> divisor(ll N){
	vector<ll> res;
	for(ll i=1;i*i<=N;i++){
		if(N%i==0){
			res.push_back(i);
			if(i!=N/i)res.push_back(N/i);
		}
	}
	return res;
}

int main()
{
	cin >> n >> s;
	if(s>n){
		cout << -1 << endl;
		return 0;
	}else if(s==n){
		cout << n+1 << endl;
		return 0;
	}
	//s<n
	for(ll b=2;b*b<=n;b++){
		if(f(b,n) == s){
			cout << b << endl;
			return 0;
		}
	}

	ll c = n-s;
	vector<ll> dv = divisor(c);
	ll b = INF;
	rep(i,0,dv.size()){
		ll a = dv[i];
		ll B = 1+c/a;
		if((double)B>sqrt((double)n) and a<B and s-B<a and a<=s){
			b = min(b,B);
		}
	}
	if(b==INF){
		cout << -1 << endl;
	}else{
		cout << b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
//~ #include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, h; cin >> n >> h;
	vector<int> a;
	vector<int> b;
	
	while (n--) {
		int A, B; cin >> A >> B;
		a.push_back(A);
		b.push_back(B);
	}
	
	sort(all(a));
	reverse(all(a));
	sort(all(b));
	reverse(all(b));
	
	int attacks = 0;
	int damage = 0, i = 0;
	while (i < (int)b.size() && damage < h && b[i] > a[0]) {
		damage += b[i], attacks++, i++;
	}
	
	int damageLeft = h - damage;
	cout << attacks + (damageLeft <= 0? 0 : (damageLeft + a[0] - 1) / a[0]) << endl;
}


Measured memory_bytes: 1276
def generator(n):
    if n == 1:
        yield [0]
    else:
        for A in generator(n - 1):
            for i in range(max(A) + 2):
                A.append(i)
                yield A
                A.pop()


n = int(input())
for A in generator(n):
    print(''.join([chr(a + 97) for a in A]))

Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    string s;
    cin >> s;
    int l = 0, r = s.size()-1;

    int ans = 0;
    while(l < r){
        if(r == l) break;
        if(s[l] == s[r]){
            l++;
            r--;
        }else if(s[l] == 'x'){
            l++;
            ans++;
        }else if(s[r] == 'x'){
            r--;
            ans++;
        }else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    string ch;
    int a, b;
    stack<int> st;
    while(cin >> ch){
        switch(ch[0]){
            case '+':
                a = st.top();
                st.pop();
                b = st.top();
                st.pop();
                st.push(a+b);
                break;
            case '-':
                a = st.top();
                st.pop();
                b = st.top();
                st.pop();
                st.push(b-a);
                break;
            case '*':
                a = st.top();
                st.pop();
                b = st.top();
                st.pop();
                st.push(a*b);
                break;
            case '/':
                a = st.top();
                st.pop();
                b = st.top();
                st.pop();
                st.push(b/a);
                break;
            default:
                st.push(atoi(ch.c_str()));
        }
    }
    cout<<st.top()<<endl;
}



Measured memory_bytes: 3212
from itertools import product
N = int(input())
count = 0
loop = len(str(N))
X = ('7','5','3')
for i in range(3, loop+1):
    for x in product(X, repeat=i):
        S = ''.join(x)
        if int(S) > N:
            continue
        c7 = S.count('7')
        c5 = S.count('5')
        c3 = S.count('3')
        if c7 and c5 and c3 and (c7+c5+c3==i):
            count += 1

print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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 INF 999999999
#define PRIME 1000000007
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  int N,x;
  multiset<int> s;
  cin >> N;
  REP(i,N){
    cin >> x;
    if(s.empty()){
      s.insert(-x);
    }
    else{
      auto itr = s.upper_bound(-x);
      if(itr != s.end()) s.erase(itr);
      s.insert(-x);
    }
  }
  cout << (int)s.size() << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int x, y;
  cin >> x >> y;
  string ans;
  if(2*x<=y && y<=4*x && y%2==0) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

#define MAX_N 100002
int par[MAX_N];
int nrank[MAX_N];



/* sample input
4
1 2
2 3
3 4

4
1 2
3 4
1 4
*/

int main()
{
	int test = 0;
	int n;
	int *cost,*cost2;
	vector<ll> *ve;

	cost = new int[100002];
	cost2 = new int[100002];
	ve = new vector<ll>[100002];
	cin >> n;
	for (ll i = 0; i < n-1; i++) {
		ll a, b;
		ll to;
		cin >> a >> b;
		to = b;
		ve[a].push_back(b);
		to = a;
		ve[b].push_back(a);
	}

	for (int i = 1; i <= n; i++) {
		cost[i] = INT_MAX;
		cost2[i] = INT_MAX;
	}

	cost[1] = 0;
	queue<ll> qtemp;
	qtemp.push(1);
	while (!qtemp.empty()) {
		ll temp = qtemp.front();
		qtemp.pop();
		ll size = ve[temp].size();
		for (ll i = 0; i<size; i++) {
			ll tempto = ve[temp][i];
			if (cost[tempto] > cost[temp]+1) {
				cost[tempto] = cost[temp] + 1;
				qtemp.push(tempto);
			}
		}
	}

	qtemp.push(n);
	cost2[n] = 0;
	while (!qtemp.empty()) {
		ll temp = qtemp.front();
		qtemp.pop();
		ll size = ve[temp].size();
		for (ll i = 0; i<size; i++) {
			ll tempto = ve[temp][i];
			if (cost2[tempto] > cost2[temp] + 1) {
				cost2[tempto] = cost2[temp] + 1;
				qtemp.push(tempto);
			}
		}
	}

	if (test) {
		for (int i = 1; i <= n; i++) {
			cout << "cost[" << i << "]:" << cost[i] << endl;
		}
	}


	ll limit = (n - 1) / 2;
	ll count=0;

	//for (ll i = 1; i <= n; i++) {
	//	if (cost[i] <= limit) {
	//		count++;
	//	}
	//}

	for (ll i = 1; i <= n; i++) {
		if (cost[i] <= cost2[i]) {
			count++;
		}
	}

	if (count > n - count) {
		cout << "Fennec";
	}
	else {
		cout << "Snuke";
	}

	return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#define min(a,b) (a<b?a:b)
int p[3],d,e,r[3],n,i,j,res,now,all,v;
int main()
{
	for(;~scanf("%d%d%d%d%d%d%d%d",&p[0],&p[1],&p[2],&d,&e,&r[0],&r[1],&r[2]),p[0];)
	{
		int use[3]={0},u=0;
		res=0;
		for(i=2;i>=0;i--)
		{
			if(p[i]>=e&&r[i]>=d)
			{
				res+=r[i]*e;
				r[i]=0;
			}
			else if(p[i]>=e)
			{
				use[i]=u=r[i];
				v=p[i]*r[i];
				for(j=i-1;j>=0;j--)
				{
					use[j]=min(r[j],d-u);
					u+=use[j];
					v+=use[j]*p[j];
					if(v>d*e&&u>=d)
					{
						res+=d*e;
						v=u=0;
						for(j=0;j<3;j++)
							r[j]-=use[j];
						break;
					}
				}
			}
			if(u!=0&&v>d*e)
			{
				res+=d*e;
				v=u=0;
				for(j=0;j<3;j++)
					r[j]-=use[j];
			}
		}
		for(i=0;i<3;i++)
			res+=p[i]*r[i];
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void) {
    int n, k, i, x = 1;

    scanf("%d", &n);
    scanf("%d", &k);

    for (i = 0; i < n; i++) {
        if (x < k) {
            x *= 2;
        } else {
            x += k;
        }
    }

    printf("%d\n", x);
    
    return 0;
}

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

int main() {
  int a,b,c,d,e,f,g,h,i;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
  if(a+e+i==b+f+g&&b+f+g==c+d+h){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
 
ll A,B,C, N;
vi l;

int dfs(int idx,int a,int b,int c)
{
	if(N == idx)
	{
		if(min({a,b,c}) == 0)
			return INT_MAX;
		return abs(a-A) + abs(b-B) + abs(c - C);  
	}

	int ret1 = dfs(idx + 1, a,b,c);

	int ret2 = dfs(idx + 1, a + l[idx],b,c);
	if(a != 0 && ret2 != INT_MAX)
		ret2 += 10;

	int ret3 = dfs(idx + 1, a,b + l[idx],c);
	if(b != 0 && ret3 != INT_MAX)
		ret3+=10;

	int ret4 = dfs(idx + 1, a,b,c + l[idx]);
	if(c != 0 && ret4 != INT_MAX)
		ret4+=10;

	
	return min({ret1,ret2,ret3,ret4});
	
}

int main()
{
	//ifstream cin("input.txt");
	cin>>N>>A>>B>>C;
	l = vi(N);
	rep(i,0,N-1)
		cin>>l[i];

	cout<<dfs(0,0,0,0);
	
}


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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,s1;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!='B')
        s1+=s[i];
        else
        {
            if(s1.length()>=1)
            s1.pop_back();
        }
    }
    cout<<s1<<endl;
	return 0; 
} 


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
using namespace std;
int n, m, c, d, a[10000], b[1440], cnt;
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> c >> d; b[c * 60 + d] = 1; }
	cin >> m; for (int i = 0; i < m; i++) { cin >> c >> d; b[c * 60 + d] = 1; }
	for (int i = 0; i < 1440; i++) {
		if (b[i] == 1) {
			if (cnt) { cout << ' '; }
			cnt++;
			cout << i / 60 << ':';
			if (i % 60 < 10) { cout << '0'; }
			cout << i % 60;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1168