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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, k;
	cin >> n >> k;

	ll a = 1;
	for (int i = 0; i < n; i++) {
		if (2 * a <= a + k) {
			a *= 2;
		} else {
			a += k;
		}
	}

	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())
s.sort()
t.sort()
t.reverse()

ans = 'No'
n_con = min(len(s), len(t))
for i in range(n_con):
	if s[i] != t[i]:
		com_list = [s[i], t[i]]
		com_list.sort()
		if com_list[0] == s[i]:
			ans = 'Yes'
			break
if s[:n_con] == t[:n_con] and len(s) < len(t):
	ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int m,n,h[100005],a,b,good[100005]={0},ans=0;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		if(h[a]>h[b]){
			good[b]=1;
		}
		if(h[b]>h[a]){
			good[a]=1;
		}
		if(h[a]==h[b]){
			good[a]=1,good[b]=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(good[i]==0){
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 4388
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

void print(char x, int t) {
	while(t--)
		cout << x;
}

signed main() {
	EmiliaMyWife

	int x, y, a, b;
	cin >> x >> y >> a >> b;
	print('U', b-y);
	print('R', a-x);
	print('D', b-y);
	print('L', a-x);
	print('D', 1);
	print('R', a-x+1);
	print('U', b-y+1);
	print('L', 1);
	print('U', 1);
	print('L', a-x+1);
	print('D', b-y+1);
	print('R', 1);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
	int sum_price, sum_num;
	int price, num; 
	int i = 0;
	sum_price = sum_num = 0;

	while(scanf("%d,%d", &price, &num) != EOF){
		sum_price += (price * num);
		sum_num += num;
		i++;
	}

	printf("%d\n%.0f\n", sum_price, floor(((double)sum_num / i) + 0.5));

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define mod 1000000007
#define p ((mod+1)>>1)
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
int fir[200010],dis[400010],nxt[400010],id;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int siz[200010],p2[200010];
void dfs(int x){
	siz[x]=1;
	for(int i=fir[x];i;i=nxt[i]){
		if(siz[dis[i]])continue;
		dfs(dis[i]);
		siz[x]+=siz[dis[i]];
	}
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),a,b;
	for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a);
	dfs(1);
	p2[0]=1;for(int i=1;i<=n;++i)p2[i]=1ll*p2[i-1]*p%mod;
	int ans=0,s=mod+1-p2[n-1];
	for(int i=1;i<=n;++i){
		int res=s,sz;
		for(int j=fir[i];j;j=nxt[j])if(siz[dis[j]]<siz[i])sz=siz[dis[j]],res=(res-1ll*p2[n-1-sz]*(mod+1-p2[sz])%mod+mod)%mod;
		if(i!=1)sz=n-siz[i],res=(res-1ll*p2[n-1-sz]*(mod+1-p2[sz])%mod+mod)%mod;
		ans=(ans+1ll*res*p)%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int x;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	for(int i=1;i<=5;i++){
		cin>>x;
		if(x==0){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = B;
		if (A >= 13) {
			X = B;
		} else if (6 <= A && A <= 12) {
			X = B / 2;
		} else if (A <= 5) {
			X = 0;
		}

		System.out.println(X);

	}
}


Measured memory_bytes: 22996
#include <iostream>

using namespace std;

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

    int a[50], b[50];
    for (int i = 0; i < m; i++)
        cin >> a[i] >> b[i];

    int city[50];
    for (int i = 0; i < n; i++)
        city[i] = 0;

    for (int i = 0; i < m; i++) {
        city[a[i]-1] += 1;
        city[b[i]-1] += 1;
    }

    for (int i = 0; i < n; i++)
        cout << city[i] << endl;

    return 0;
}

Measured memory_bytes: 256
main = do
  s <- getLine :: IO String
  print $ f s 0 0

f :: String -> Int -> Int -> Int
f []  a b = max a b
f [x] a b = if x `elem` "ATGC" then max (a+1) b else max a b
f (x:xs) a b
  | x `elem` "ATCG" = f xs (a+1) b
  | otherwise   = f xs 0 $ max a b

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

int ruijyo_10 (int a) {
  int ans = 1;
  if (a == 0) {
    return 1;
  }
  else {
    for (int i = 0; i < a; i++) {
      ans *= 10;
    }
  return ans;
  }
}

int main() {
  int a, b;
  cin >> a >> b;
  vector<int> n(5);
  int count = 0;
  for (int i = a; i < b + 1; i++) {
    int t = i;
    for (int j = 0; j < 5; j++) {
      int tmp = t;
      n.at(j) = tmp / ruijyo_10(4 - j);
      t %= ruijyo_10(4 - j);
    }
    if ((n.at(0) == n.at(4)) && (n.at(1) == n.at(3))) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
//LightOJ - 1019


#include <bits/stdc++.h>
#define LL long long
#define pii pair <LL, LL>
#define inf 1000000000000000000
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

map <LL, vector <pii> > adj;
LL dist[100005], processed[100005];

void Dijkstra(LL source)
{
    priority_queue <pii> pq;
    dist[source] = 0;
    pq.push({0, source});
    while(!pq.empty())
    {
        LL u = pq.top().second;
        pq.pop();
        if(processed[u]) continue;
        processed[u] = 1;
        LL len = adj[u].size();
        for(int i = 0; i < len; i++)
        {
            LL node = adj[u][i].first;
            LL cost = adj[u][i].second;
            if(dist[u]+cost < dist[node])
            {
                dist[node] = dist[u]+cost;
                pq.push({-dist[node], node});
            }
        }
    }
}
int main()
{
    FASTER;
    int N, M;
    cin >> N;
    M = N - 1;
    while(M--)
    {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
    int Q, K;
    cin >> Q >> K;
    for(int i = 1; i <= N; i++) dist[i] = inf;
    Dijkstra(K);

    while(Q--){
        LL x, y;
        cin >> x >> y;
        cout << dist[x]+dist[y] << "\n";
    }
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   ll a,x; cin>>a>>x;
   ll b,w; cin>>b>>w;
   ll t; cin>>t;
   ll d=abs(b-a),v=x-w;
   if(v<=0)puts("NO");
   else if(d>t*v)puts("NO");
   else puts("YES");
   return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9+7;

string s;
bool used[51];
vector<string> anss;
void init(){
    for(int i=0;i<30;i++) used[i]=0;
    anss.clear();
}

void dfs(int now,string t){
    
    if(now==s.size()){
        anss.push_back(t);
    }else{
        //既に使った or 変化前・変化後共にaである
		//つまり、変化させることができない
        if(used[s[now]-'a']==1 || s[now]=='a'){
            t[now]=s[now];
            dfs(now+1,t);
        }
		//変化前を使っていない and zじゃない(変化後zというのはありえない)
        if(!used[s[now]-'a'+1] && s[now]!='z'){
            t[now] = char(s[now]+1);
            used[s[now]-'a'+1] = 1;
            dfs(now+1,t);
            used[s[now]-'a'+1] = 0;
        }
    }
    return;
}
 
signed main(){
    while(cin>>s && s != "#"){
        init();
        dfs(0,s);

        cout<<anss.size()<<endl;

        if(anss.size()<=10){
            for(int i=0;i<anss.size();i++) cout << anss[i] << endl;
        }else{
            for(int i=0;i<5;i++) cout << anss[i] << endl;
            for(int i=anss.size()-5;i<anss.size();i++){
                cout << anss[i] << endl;
            }
        }
    }
}


Measured memory_bytes: 4184
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define ull unsigned long long
#define ALL(v) ((v).begin()), ((v).end())
#define INCREASING(v) sort(ALL(v))
#define DECREASING(v) INCREASING(v), reverse(ALL(v))
#define SZ(v)   ((int)((v).size()))
#define LP(c,x,n)  for(int c=x;c<n;c++)
#define LO(c,n,x)  for(int c=n;c>=x;c--)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define PI ( 2 * acos(0.0))
#define EPS 1e-8
#define INF 1.0/0.0
#define Yala_Besor3a ios_base::sync_with_stdio(0),ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ReadFile freopen("delivery.in","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
using namespace std;
const int OO = 0x3f3f3f3f,NegOO= -1*OO,N =1e5+5,mod =998244353 ;
int n,k;
int arr[N];
int dp[N];
int solve(int i)
{
    if(i>=n-1)return 0;
    int &rf=dp[i];
    if(~rf)return rf;
    rf=OO;
    LP(c,1,k+1)
    {
        if(i+c>n-1)continue;
        rf=min(rf,solve(i+c)+abs(arr[i+c]-arr[i]));
    }
    return rf;
}
int main()
{
    cin>>n>>k;
    LP(c,0,n)cin>>arr[c];
    memset(dp,-1, sizeof(dp));
    cout<<solve(0)<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int k = 4, n;

struct Row {
  int len;
  deque<int> r;

  Row(){len = 0;}

  void Print(){
    printf("%d", r[0]);
    for(int i = 1;i < sz(r);++i)
      if(r[i]) printf(" %d", r[i]);
    printf("\n");
  }

  void Init(const vi& from){
    r = deque<int>(all(from));
    len = sz(r);
  }

  void PushFront(int w){
    r.push_front(w);
    ++len;
  }

  void Decrease(){
    if(r.back() == 0) r.pop_back();
    --r.back();
    if(r.back() > 0)
      while(sz(r) < len) r.pb(k);
  }
};

int Generator(int pos, Row& ans, int add_one = 1){
  if(pos == n - 1){
    int mid = (k + 1) / 2;
    if(add_one && (k & 1)) --mid;
    ans.Init({mid});
    return (k + add_one) % 2;
  }

  if(k % 2 == 0){
    vi use;
    use.pb(k / 2);
    for(int i = pos + 1;i < n;++i) use.pb(k);
    ans.Init(use);
    return (0 + add_one) % 2;
  }

  int left = Generator(pos + 1, ans);
  int total = (k * left + add_one) % 2;

  ans.PushFront((k + 1) / 2);

  if(add_one && (total & 1) == 0)
    ans.Decrease();

  return total;
}

int main(){
  scanf("%d%d", &k, &n);

  Row ans;
  Generator(0, ans, 0);

  ans.Print();

  return 0;
}


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

int main(){
	int a[3][3];
	int flag_a[3][3];
	int ans=0;
	string str[]={"No","Yes"};
	rep(i,3){
		rep(j,3){
			cin>>a[i][j];
			flag_a[i][j]=0;
		}
	}
	int n;
	cin>>n;
	rep(i,n){
		int b;
		cin>>b;
		rep(j,3){
			rep(k,3){
				if(a[j][k]==b)flag_a[j][k]=1;
			}
		}
	}
	rep(i,3){
		if(flag_a[i][0]==1&&flag_a[i][1]==1&&flag_a[i][2]==1){
			ans=1;
		}
		if(flag_a[0][i]==1&&flag_a[1][i]==1&&flag_a[2][i]==1){
			ans=1;
		}
	}
	if(flag_a[0][0]==1&&flag_a[1][1]==1&&flag_a[2][2]==1)ans=1;
	if(flag_a[0][2]==1&&flag_a[1][1]==1&&flag_a[2][0]==1)ans=1;

	cout<<str[ans]<<endl;
	return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;

my ($n, $a, $b);
{
  my $in = <STDIN>;
  ($n, $a, $b) = split(" ", $in);
}
my $MOD = 1e9 + 7;
my $modpow = sub {
  my ($a, $n, $MOD) = @_;
  my $res = 1;
  while ($n > 0) {
    $res = $res * $a % $MOD if $n & 1;
    $a = $a * $a % $MOD;
    $n >>= 1;
  }
  return $res;
};
my $modinv = sub {
  my ($a, $MOD) = @_;
  return $modpow->($a, $MOD - 2, $MOD);
};
sub comb {
  my ($n, $k) = @_;
  my $a = 1;
  my $b = 1;
  for (my $i=0; $i<$k; $i++) {
    $a *= $n - $i;
    $a %= $MOD;
    $b *= $i + 1;
    $b %= $MOD;
  }
  $a * $modinv->($b, $MOD) % $MOD;
}

my $ans = $modpow->(2, $n, $MOD) - 1;
$ans += $MOD - comb($n, $a, $MOD);
$ans += $MOD - comb($n, $b, $MOD);
print $ans % $MOD, "\n";

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

for _ in range(k):
    b = [0] * (n + 2)
    for i in range(n):
        b[max(0, i - a[i])] += 1
        b[min(n + 1, i + a[i] + 1)] -= 1
    a[0] = b[0]
    cnt = a[0]
    for i in range(1, n):
        a[i] = a[i - 1] + b[i]
        cnt += a[i]

    # print(*a)
    if cnt == n**2:
        break

print(*a)


Measured memory_bytes: 157388
#include <stdio.h>
#include <string.h>
int main(){
	int N;
	scanf("%d",&N);
	char target[25];
	scanf("%s",target);
	char kanban[N][100];
	int i,j,k,l;
	for(i=0;i<N;i++){
		scanf("%s",kanban[i]);
	}
	int tar=strlen(target);//目標の文字数
	int ans=0;
	int flag=0;
	int breakflag=0;
	for(i=0;i<N;i++){//i:何番目の看板かを指す
		flag=0;
		breakflag=0;
		int moji=strlen(kanban[i]);
		for(j=0;j<moji-2;j++){//j:元の看板の何文字目かを指す
			if(target[0]==kanban[i][j]){/*最初の文字を探す*/
				for(k=1;k<49;k++){//k:文字と文字の間隔を指す
					flag=1;
					for(l=1;l<tar;l++){
						if(j+(k*l)>99){
							flag=0;
							break;//過剰アクセス防止
						}
						if(target[l]!=kanban[i][j+(k*l)]){//その後もあっているかを調べる
							flag=0;
							break;
						}
					}
					if(flag==1){
						ans++;
						breakflag=1;
						break;
					}
				}
			}
			if(breakflag==1){
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	int n ; cin >> n;
	int a[n-1],b[n-1],c[n-1];
	rep(i,n-1) cin >>a[i] >> b[i] >> c[i];
	a[n-1] = b[n-1] = c[n-1] = 0;

	rep(i,n){
		int t = 0;
		For(j,i,n-1){
			if(t<b[j]) t = b[j];
			else if(t % c[j] == 0);
			else t = t+c[j]-t%c[j];
			t+=a[j];
		}
		cout << t << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  int n;
  int a[200000];
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  long long int sum = 0;
  for (int i = 0; i < n - 1; i++)
  {
    if (a[i] > a[i + 1])
    {
      sum += a[i] - a[i + 1];
      a[i + 1] = a[i];
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 4332
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N, T;
  scanf("%d", &N);
  scanf("%d", &T);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  std::vector<int > Amax(N+1);
  Amax[N]=-1;
  for (int i=N-1; i>=0; i--){
    Amax[i]=std::max(Amax[i+1], A[i]);
  }
  int maxdiff=-1;
  for (int i=0; i<N; i++){
    maxdiff= std::max(maxdiff, Amax[i]-A[i]);
  }
  int maxpairnum=0;
  for (int i=0; i<N; i++){
    if (Amax[i]-A[i]==maxdiff) maxpairnum++;
  }
  std::cout << maxpairnum << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3508
import java.util.Scanner;

public class Main {
		public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String  n = scan.next();
		String ans = null;

		String temp = n.substring(n.length()-1);
		int num = Integer.parseInt(temp);
		if(num == 3) {
			ans = "bon";
		} else if(num == 0 || num == 1 || num == 6 || num == 8) {
			ans = "pon";
		} else {
			ans = "hon";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27004
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class CMultipleClocks {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in>>n;
        vector<ll> t(n);
        rep(i,n) in>>t[i];
        if(n==1){
            out<<t[0]<<endl;
            return;
        }
        ll res = LCM(t[0],t[1]);
        for (int j = 2; j < n; ++j) {
            res = LCM(res,t[j]);
        }
        out<<res<<endl;
	}
};


int main() {
	CMultipleClocks solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 888
/*input
2 100
85 2 3
60 10 10
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#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())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<'('<<P.F<<','<<P.S<<')';
    return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        
        b>>=1;
    }
    return res;
}

ll n,x;

struct Exam{
    ll b,l,r;
    Exam(){}
    Exam(int b,int l,int r):b(b),l(l),r(r){}
}e[maxn];

ll f(Exam A){
    return A.b*A.l+(x-A.b)*A.r;
}

bool cmp(Exam A,Exam B){
    return f(A)>f(B);
}

ll pre[maxn];

int main(){
    // freopen("input.txt","r",stdin);
    IOS;
    cin>>n>>x;
    REP(i,n){
        ll b,l,r;
        cin>>b>>l>>r;
        e[i]=Exam(b,l,r);
    }
    sort(e,e+n,cmp);
    ll goal=0;
    REP(i,n) goal+=e[i].b*e[i].l;

    pre[0]=0;
    REP(i,n) pre[i+1]=pre[i]+f(e[i]); 

    ll ans=0;
    REP(i,n) ans+=e[i].b;

    for(int i=0;i<n;i++){
        ll sum,pt;
        {
            int l=0,r=n;
            while(l!=r-1){
                int mid=(l+r)/2;
                ll s=pre[mid];
                if(mid>=i+1) s-=f(e[i]);
                if(s>=goal) r=mid;
                else l=mid;
            }
            pt=l;
            sum=pre[l];
            if(l>=i+1){
                sum-=f(e[i]);
                pt--;
            }
        }
        ll rem=goal-sum;
        ll cur=pt*x;

        // cout<<pt<<' '<<rem<<"\n";

        if(rem>f(e[i])) continue;
        else if(rem>=e[i].l*e[i].b){
            cur+=e[i].b;
            rem-=e[i].l*e[i].b;
            cur+=(rem+e[i].r-1)/e[i].r;
        }
        else{
            cur+=(rem+e[i].l-1)/e[i].l;
        }
        if(ans>cur) ans=cur;

    }
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 5120
#include<cstdio>
int n,m;
int l,r;
int main() {
	scanf("%d %d",&n,&m);
	l=1,r=n;
	for(int i=1,u,v;i<=m;i++) {
		scanf("%d %d",&u,&v);
		if(u>l) l=u;
		if(v<r) r=v;
	}
	if(r<l) printf("0");
	else printf("%d",r-l+1);
	return 0;
}

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

struct line{
    int h,p,q;
    bool operator<(const line &rhs){
        return h>rhs.h;
    }
};

const int MAX_M=1010;

int n,m,a,h,p,q;
vector<line> ls(MAX_M);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m >> a,n){
        for (int i=0;i<m;++i){
            cin >> h >> p >> q;
            ls[i]=line{h,p,q};
        }
        sort(ls.begin(),ls.begin()+m);
        for (int i=0;i<m;++i){
            if (ls[i].p==a) a=ls[i].q;
            else if (ls[i].q==a) a=ls[i].p;
        }
        cout << a << '\n';
    }
}


Measured memory_bytes: 3152
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		
		// 計算
		int result = min(a, b) + min(c, d);
		
		// 出力
		System.out.println(result);
		
	}
}




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

int a, b, x, y;

void solve() {
  for(int i = 0; i < 1009; i++) {
    x = i * 0.08;
    y = i * 0.1;
    if (a == x && b == y) {
      cout << i << endl;
      return;
    } 
  }
  cout << -1 << endl;
  return;
}

int main() {
  cin >> a >> b;
  solve();
  
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A, B;
	cin >> A >> B;

	REP(i, 10000){
		int a = i * 0.08;
		int b = i * 0.1;
		if(a == A && b == B){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;


	return 0;
}


Measured memory_bytes: 888
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>
#include <sstream> 

using namespace std;

int main(){
    string s ;
    cin >> s;
    replace(s.begin(), s.end(), '/', ' ');
    istringstream iss(s);

    string a[3];
    iss >> a[0] >> a[1] >> a[2];
    int num[3];
    int i = 0;
    for(i = 0; i < 3; i++){
        num[i] = stoi(a[i]);
        if(num[i] >  2019 && i == 0){
            cout << "TBD" << endl;
            i = 9;
        }else if(num[i] > 4 && i == 1){
            cout << "TBD" << endl;
            i = 9;
        }
    }

    if(i != 10){
        cout << "Heisei" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int n;
ll a[100001];
ll s[100001],s1[100001];
int f1(ll x, int st, int end){
    if(st > end) return -1;
    int mid=(st+end)/2;
    if(a[mid] >= x){
        int lans=f1(x,st,mid-1);
        if(lans==-1) return mid;
        return lans;
    }
    return f1(x,mid+1,end);
}
int f2(ll x, int st, int end){
    if(st > end) return -1;
    int mid=(st+end)/2;
    if(a[mid] <= x){
        int rans=f2(x,mid+1,end);
        if(rans==-1) return mid;
        return rans;
    }
    return f2(x,st,mid-1);
}  
int f3(ll x, ll diff, int st, int end){
    if(st > end) return -1;
    int mid=(st+end)/2;
    ll d=x-a[mid];
    if( d <= diff){
        int lans=f3(x,diff,st, mid-1);
        if(lans==-1) return mid;
        return lans;
    }
    return f3(x,diff,mid+1,end);
}
int f(ll x, int st, int end, int in2, int in1){
   // cout<<st<<" "<<end<<"\n";
    if(st > end) return -1;
    int mid=(st+end)/2;
    ll d1=a[mid]-x;
    ll d2=1e14;
    if(mid < n-1) d2=a[mid+1]-x;
    int in31=f3(x,d1,0,in2);
    int in32=f3(x,d2,0,in2);
    int c1=n-1-mid;
    int a1=mid-in1+1;
    if(in31!=-1){
        a1+=in2-in31+1;
    }
    int a2=mid-in1+1;
    if(in32!=-1){
        a2+=in2-in32+1;
    }
   // cout<<a1<<" "<<a2<<"\n";
    if( (c1>=a1 && c1<=a2) || (c1-1>=a1 && c1-1<=a2) ) return mid;
    if(a2 < c1) return f(x,mid+1,end,in2,in1);
    else return f(x,st,mid-1,in2,in1);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int q;
    cin>>n>>q;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        s[i]=a[i];
        if(i!=0) s[i]+=s[i-1];
    }
    for(int i=0;i<n;i++){
        if(i%2==0) s1[i]=a[i];
        if(i>0) s1[i]+=s1[i-1];
    }
    while(q--){
        ll x;
        cin>>x;
        int in1=f1(x,0,n-1);
        if(in1==-1){
            if(n%2==0) cout<<s[n-1]-s1[n-1]<<"\n";
            else cout<<s1[n-1]<<"\n";
            continue;
        }
        //cout<<in1<<"\n";
        int in2=f2(x,0,n-1);
       // cout<<in2<<"\n";
        if(in1==in2) in2--;
        int in3=f(x,in1,n-1,in2,in1);
        //cout<<in3<<"\n";
        if(in3==-1){
            int c1=n-in1;
            int r=in2+1-c1;
              ll g=s[n-1];
            ll h=0;
            if(in1>=1) h=s[in1-1];
            if(r<=0){
               // cout<<"oewiehfwef";
                cout<<g-h<<"\n";
            }
            else{
                int num=n-2*c1;
                if(num%2==0) cout<<s[num-1]-s1[num-1]+g-h<<"\n";
                else cout<<s1[num-1]+g-h<<"\n";
            } 
            continue;
        }
        else{
            ll g=s[n-1];
            ll h=0;
            if(in3+1>=1) h=s[in3+1-1];
            ll c1=n-in3-1;
            ll r=in3-c1+1;
            if(r<=0){
              //  cout<<"ewehf";
                cout<<g-h<<"\n";
            }
            else{
                int num=n-2*c1;
                if(num%2==0) cout<<s[num-1]-s1[num-1]+g-h<<"\n";
                else cout<<s1[num-1]+g-h<<"\n";
            }
            continue;
        }
    }
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n>>k;
	k*=2;
	k++;
	ret((n/k+(n%k>0?1:0)))	
	
	return 0;
}

Measured memory_bytes: 256
S=input()
T=input()
cnt_min=1001
for i in range(len(S)-len(T)+1):
  #部分文字列を切り出す
  s=S[i:i+len(T)]
  cnt=0
  for i,s_ in enumerate(s):
    if T[i] != s_:
      cnt+=1
  if cnt_min > cnt:
    cnt_min = cnt

print(cnt_min)

Measured memory_bytes: 9112
#include <vector>
#include <functional>
#include <algorithm>
#include <iostream>
#include <climits>
using namespace std;

// 抽象 SegmentTree (0-indexed・一点更新・区間取得)
template <typename MonoidType, typename UpdateType>
struct SegmentTree {
    using UpdateFunc  = function< MonoidType(MonoidType, UpdateType) >;
    using CombineFunc = function< MonoidType(MonoidType, MonoidType) >;

    // node, identity element
    int n;
    vector<MonoidType> node;
    MonoidType E0;

    // update / combine function
    UpdateFunc  upd_f;
    CombineFunc cmb_f;

    void build(int m, vector<MonoidType> v = vector<MonoidType>()) {
        if(v != vector<MonoidType>()) m = v.size();
        n = 1; while(n < m) n *= 2;

        node = vector<MonoidType>(2*n-1, E0);
        if(v != vector<MonoidType>()) {
            for(int i=0; i<m; i++) {
                node[n-1+i] = v[i];
            }
            for(int i=n-2; i>=0; i--) {
                node[i] = cmb_f(node[2*i+1], node[2*i+2]);
            }
        }
    }

    // initialize
    SegmentTree() {}
    SegmentTree(int n_, MonoidType E0_,
                UpdateFunc upd_f_, CombineFunc cmb_f_,
                vector<MonoidType> v = vector<MonoidType>()) :
        E0(E0_), upd_f(upd_f_), cmb_f(cmb_f_) {
        build(n_, v);
    }

    // update k-th element (applied value: x)
    void update(int k, UpdateType x) {
        k += n - 1;
        node[k] = upd_f(node[k], x);
        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = cmb_f(node[2*k+1], node[2*k+2]);
        }
    }

    // range query for [a, b)
    MonoidType query(int a, int b, int l=0, int r=-1, int k=0) {
        if(r < 0) r = n;
        if(r <= a or  b <= l) return E0;
        if(a <= l and r <= b) return node[k];
        int mid = (l + r) / 2;
        MonoidType vl = query(a, b, l, mid, 2*k+1);
        MonoidType vr = query(a, b, mid, r, 2*k+2);
        return cmb_f(vl, vr);
    }
};


// Range Minimum Query
// query 1: update
// query 2: range minimum
void DSL_2_A() {
    int N, Q; cin >> N >> Q;
    SegmentTree<int, int> seg(N, INT_MAX,
                              [](int a, int b) { return b; },
                              [](int a, int b) { return min(a, b); });

    int indexed = 0;
    for(int i=0; i<Q; i++) {
        int query_type; cin >> query_type;
        int x, y; cin >> x >> y;
        if(query_type == 0) {
            x -= indexed;
            seg.update(x, y);
        }
        if(query_type == 1) {
            x -= indexed, y -= indexed;
            y++;
            cout << seg.query(x, y) << endl;
        }
    }
}

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



Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    long long ta = a, tb = b;

    if(ta%x != 0) ta += (x - ta%x);
    if(tb%x != 0) tb -= tb%x;
        

    cout << (tb-ta)/x + 1 << endl;;
    return 0;
}

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

cards = [ [False for i in range(13) ] for j in range(4) ]


mark = ["S", "H", "C", "D"]

for i in range(n):
	li = list(input().split())
	m = li[0]
	num = int(li[1])

	cards[mark.index(m)][num - 1] = True
	
for i in range(4):
	for j in range(13):
		if not cards[i][j]:
			print(mark[i], j+1)




Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n+2];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    multiset<int>s;
    int j=0,mx=0;
    for(int i=0;i<n;i++){
        s.emplace(a[i]);
        while(*s.rbegin()-*s.begin()>2){
            s.erase(s.find(a[j]));
            j++;
        }
        mx=max(mx,(int)s.size());
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 8668
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sum(a)

for i in range(n):
  a[i],a[i+1]=max(0,a[i]-b[i]),max(a[i+1]+min(0,a[i]-b[i]),0)
  
  
print(c-sum(a))




Measured memory_bytes: 19156
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <limits.h>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 1e6 + 7;
const LL mod = 1e9 + 7;
//vector<ll> ans;
//ll kpow(ll a, ll b)
//{
//	ll ans = 1;
//	ans %= mod;
//	while(b)
//	{
//		if(b&1) ans = (ans%mod)*(a%mod)%mod;
//		a = (a%mod) * (a%mod) % mod;
//		b >>= 1;
//	}
//	return ans%mod;
//}
int main(void)
{
	LL n;
//	cin >> n;
//	ll a = kpow(10, n)%mod;
//	ll b = kpow(9, n)%mod;
//	b = b * 2%mod;
//	ll c = kpow(8, n)%mod;
//	cout << (a - (b - c))%mod;
    cin >> n;
    if (n == 1)
        cout << 0;
    else
    {
        LL sum = 1;
        for (int i = 0; i < n; i++)
        {
            sum = sum * 10 % mod;
        }
        LL ans = 0;
        LL t = 1;
        for (int i = 0; i < n; i++)
        {
            t = t * 9 % mod;
        }
        t = t * 2 % mod;
        ans = ans + t % mod;
        t = 1;
        for (int i = 0; i < n; i++)
        {
            t = t * 8 % mod;
        }
        ans = ans - t % mod;
        sum = (sum - ans + mod) % mod;
        cout << sum;
    }
    return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int dp[100][100];
int naive(int x, int y) {
	int& ret = dp[x][y];
	if (ret >= 0) return ret;
	if (x <= 1 && y <= 1) return ret = 0;
	for (int i = 1; 2*i <= x; ++i) {
		if (!naive(x-2*i, y+i)) return ret = 1;
	}
	for (int i = 1; 2*i <= y; ++i) {
		if (!naive(x+i, y-2*i)) return ret = 1;
	}
	return ret = 0;
}

int main() {
	ll X, Y;
	cin >> X >> Y;
	if (abs(X-Y) <= 1) {
		cout << "Brown" << endl;
	} else {
		cout << "Alice" << endl;
	}
	//memset(dp, -1, sizeof(dp));
	//for (int i = 0; i < 50; i++) {
	//	for (int j = 0; j < 50; j++) {
	//		if (naive(i, j) == 0) {
	//			cout << i << " " << j << endl;
	//		}
	//	}
	//}
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int f(int a,ll b){
	int count=0;
	while(a!=0 || b!=0){
		a/=10;
		b/=10;
		count++;
	}
	return count;
}

int main(){

	ll n;
	cin>>n;

	int ans=mod;
	double k=sqrt(n);
	for(int i=1;i<=k;i++){
		if(n%i==0)ans=min(ans,f(i,n/i));
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int d,m1,m2,m3,i;
m1=0;
m2=0;
m3=0;
for(i=0;i<10;i++){
d=0;
scanf("%d",&d);
if(d>m1){
m3=m2;
m2=m1;
m1=d;
}else if(d>m2){
m3=m2;
m2=d;
}else if(d>m3){
m3=d;
}
}
printf("%d\n%d\n%d\n",m1,m2,m3);
return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#define MAX 100000000;
int adj[1000][1000];
int cost[100];
int check[100];
int mst[100];
int v, count;

void input(int n) {
  int node, k, v, c;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &node, &k);
    for (int j = 0; j < k; j++) {
      scanf("%d%d", &v, &c);
      adj[node][v] = c;
    }
  }
}

void setup(int n) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (adj[i][j] == 0)
	adj[i][j] = MAX;
}

void minimum(int num) {
  int min, sum = 0, minicost;
  int i, j;
  cost[num] = 0;
  mst[count++] = num;
  check[num]++;

  while (1) {
    minicost = MAX;
    for (i = 0; i < count; i++) {
      //printf("node:%d\n", mst[i]);
      for (j = 0; j < v; j++)
	if (minicost > adj[mst[i]][j] + cost[mst[i]] && check[j] == 0) {
	  min = j;
	  minicost = adj[mst[i]][j] + cost[mst[i]];
	  //printf("minj = %d\n", min);
	  //printf("edge = %d cost = %d total = %d\n", adj[mst[i]][j], cost[mst[i]], minicost);
	}
    }
    //printf("node:%d minicost = %d\n", min, minicost);
    cost[min] = minicost;
    check[min]++;
    mst[count++] = min;
    if (count == v)
      break;
  }
}

int main(void) {
  int n;

  scanf("%d", &n);
  v = n;
  input(n);

  setup(n);

  /* for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      printf(" %d", adj[i][j]);
    printf("\n");
    }*/
  
  minimum(0);

  for (int i = 0; i < n; i++)
    printf("%d %d\n", i, cost[i]);
  
  return 0;
}




Measured memory_bytes: 2192
N = int(input())
A = list(map(int,input().split( )))
def f(tail,head):
    if tail < head:
        return 1
    elif tail > head:
        return -1
    else:
        return 0

actions = ['stay' for _ in range(N)]

if N > 2:
    i = 0
    while f(A[i],A[i+1]) == 0:
        i += 1
        if i+1 == N-1:
            break
    if f(A[i],A[i+1]) == 1:
        actions[i] = 'buy'
    else:
        actions[i] = 'stay'
    before = f(A[i],A[i+1])
    for j,(tail,head) in enumerate(zip(A[i+1:],A[i+2:])):
        now = f(tail,head)
        if now == before:
            before = now
        elif now == 0:
            before = before
        else:
            if before == -1:
                actions[j+i+1] = 'buy'
            else:
                actions[j+i+1] = 'sell'
            before = now

else:
    if f(A[0],A[1]) == 1:
        actions[0] = 'buy'
actions[-1] = 'sell'

def action(stock,money,a,price):
    if a == 'stay':
        return stock,money
    elif a == 'buy':
        stock += money//price
        money = money%price
        return stock,money
    else:
        money += stock*price
        stock = 0
        return stock,money
    
stock = 0
money = 1000
for a,price in zip(actions,A):
    stock,money = action(stock,money,a,price)
print(money)

Measured memory_bytes: 9304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (b), _a = (a); i >= _a; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<"debug : "<<x<<endl
#define debug2(x,y) cout<<"debug : "<<x<<" | "<<y<<endl
#define debug3(x,y,z) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<endl
#define debug4(x,y,z,w) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<" | "<<w<<endl
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define sz(x) ((long long)x.size())
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define M 1000000007          // 1e9+7
#define INF 10000000000       // 1e9
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;
 
bool cus(pair<int,int> a, pair<int,int> b){
    if(a.ff<b.ff)
        return true;
    if(a.ff>b.ff)
        return false;
    return a.ss<b.ss;
}
 
ll gcd(ll a, ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}


void solve(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll mx = a*c;
    mx = max(mx, a*d);
    mx = max(mx, b*c);
    mx = max(mx, b*d);
    cout << mx << endl;
  }

int main () 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
 
    //ll t = 1;
    //cin>>t;
    //while(t--)
        solve();
 
    return 0;
}
  

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

using ll = long long;

int main() {
    int V, E, r, s, t, d;
    cin >> V >> E >> r;
    vector<vector<pair<int, int>>> edge(V);
    rep(i, E) {
        cin >> s >> t >> d;
        edge[s].push_back(make_pair(t, d));
    }
    vector<ll> dist(V, 1e18);
    priority_queue<pair<ll, int>> q;
    q.push(make_pair(0, r));
    while (!q.empty()) {
        auto p = q.top();
        q.pop();
        if (-p.first >= dist[p.second]) continue;
        dist[p.second] = -p.first;
        rep(i, edge[p.second].size()) {
            q.push(make_pair(-dist[p.second] - edge[p.second][i].second, edge[p.second][i].first));
        }
    }
    rep(i, V) {
        if (dist[i] == 1e18) cout << "INF\n";
        else cout << dist[i] << "\n";
    }
}


Measured memory_bytes: 16476
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		
      	if (a*b %2 == 0){
          System.out.println("Even");
        } else{
          System.out.println("Odd");
        }
	}
}

Measured memory_bytes: 23764
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;


int main() {
  ll N;

  cin >> N;

  int ans[N];
  vector<P> aLst[N];

  queue<ll> que;
  for (int i = 0; i < N; ++i) {
    ll u, v, w;
    cin >> u >> v >> w;
    P tmp0(v - 1, w);
    aLst[u - 1].emplace_back(tmp0);
    P tmp1(u - 1, w);
    aLst[v - 1].emplace_back(tmp1);
  }

  que.push(0);
  ans[0] = 0;

  unordered_map<ll, bool> visited;

  while (!que.empty()) {
    ll cur = que.front();
    que.pop();
    // cout << "cur=" << cur << endl;
    for (size_t i = 0; i < aLst[cur].size(); ++i) {
      ll cur_child = aLst[cur][i].first;
      if (visited.count(cur_child) == 0) {
        que.push(cur_child);
        visited[cur_child] = true;
        if (aLst[cur][i].second % 2 == 0) {
          ans[cur_child] = ans[cur];
        } else {
          ans[cur_child] = 1 - ans[cur];
        }
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 12452