akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

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

  vector<vector<int>> s(w, vector<int>(w));
  if(w >= 3) {
    for(int i = 0; i < w; i++) {
      for(int j = 0; j < w; j++) {
        if(abs(i - j) < 2) {
          int st = 0, ma = 0;
          if(i == j)
            for(int l = max(0, i - 1); l <= min(w - 2, i); l++) ma += 1 << l;
          else {
            for(int l = max(0, (i + j) / 2 - 1);
                l <= min(w - 2, (i + j) / 2 + 1); l++) {
              if(l == (i + j) / 2) st += 1 << l;
              ma += 1 << l;
            }
          }
          for(int l = 0; l < (1 << w - 1); l++) {
            if((l & ma) != st) continue;
            int t = l, p = 0;
            int f = 1;
            while(t) {
              if(t & 1 == p && p) f = 0;
              p = t & 1;
              t >>= 1;
            }
            if(f) s[i][j]++;
          }
        }
      }
    }
  } else
    s = vector<vector<int>>(w, vector<int>(w, 1));
  vector<vector<ll>> o(w, vector<ll>(w, 1)), t;
  for(int i = 0; i < w; i++)
    for(int j = 0; j < w; j++) o[i][j] = s[i][j];
  for(int i = 1; i < h; i++) {
    t = vector<vector<ll>>(w, vector<ll>(w, 0));
    for(int p = 0; p < w; p++)
      for(int q = 0; q < w; q++)
        for(int r = 0; r < w; r++)
          t[p][q] = t[p][q] + s[p][r] * o[r][q] % MOD, t[p][q] %= MOD;
    o = t;
  }
  printf("%lld\n", o[0][k - 1]);
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d %d %d', $a, $b, $h, $m);
$y = $m / 60;
$x = ($h + $y) / 12;
$rad = deg2rad(($x - $y) * 360);
$ans = sqrt($a ** 2 + $b ** 2 - 2 * $a * $b * cos($rad));
echo $ans;


Measured memory_bytes: 16432
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
long long a[100];
int main()
{
    int n;
    cin>>n;
    int a,b,c,d;
    a=n%10;
    n/=10;
    b=n%10;
    n/=10;
    c=n%10;
    n/=10;
    d=n;
    if(a==b&&b==c)
        cout<<"Yes"<<endl;
    else if(b==c&&c==d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, tank, a, b, c;
long long dist[309][309], dist2[309][309];
set<pair<long long, int> > st;
bool vis[309];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> tank;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			dist[i + 1][j + 1] = 1e18;
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		if (c > tank) continue;
		dist[a][b] = c;
		dist[b][a] = c;
	}
	for (int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof(vis));
		st.clear();
		st.insert({ 0, i });
		vis[i] = true;
		while (!st.empty()) {
			auto cur = st.begin();
			int ix = cur->se;
			st.erase(cur);
			for (int j = 1; j <= n; j++) {
				if (j == ix) continue;
				if (dist[ix][j] < 1e18) {
					if (vis[j]) {
						if (dist[i][j] > dist[i][ix] + dist[ix][j]) {
							st.erase({ dist[i][j], j });
							dist[i][j] = dist[i][ix] + dist[ix][j];
							st.insert({ dist[i][j], j });
						}
					}
					else {
						vis[j] = true;
						dist[i][j] = dist[i][ix] + dist[ix][j];
						st.insert({ dist[i][j], j });
					}
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			if (dist[i + 1][j + 1] > tank)
				dist[i + 1][j + 1] = 1e18;
			else dist[i + 1][j + 1] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof(vis));
		st.clear();
		st.insert({ 0, i });
		vis[i] = true;
		while (!st.empty()) {
			auto cur = st.begin();
			int ix = cur->se;
			st.erase(cur);
			for (int j = 1; j <= n; j++) {
				if (j == ix) continue;
				if (dist[ix][j] < 1e18) {
					if (vis[j]) {
						if (dist[i][j] > dist[i][ix] + dist[ix][j]) {
							st.erase({ dist[i][j], j });
							dist[i][j] = dist[i][ix] + dist[ix][j];
							st.insert({ dist[i][j], j });
						}
					}
					else {
						vis[j] = true;
						dist[i][j] = dist[i][ix] + dist[ix][j];
						st.insert({ dist[i][j], j });
					}
				}
			}
		}
	}
	int q, s, t;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> s >> t;
		if (dist[s][t] != 1e18)
			cout << dist[s][t] - 1 << E;
		else cout << -1 << E;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e3+7;
int a[MAXN][MAXN];
int b[MAXN];
bool vis[MAXN];
queue<int> Q[MAXN];
int main(){   
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
	{
		b[i]=0;
		for(int j=0;j<n-1;++j)
		{
			cin>>a[i][j];
			a[i][j]--;
			Q[i].push(a[i][j]);
		}
	}
	int ans=0;
	while(true)
	{
		bool flag=0;
		for(int i=0;i<n;++i)
		{
			if(Q[i].empty()) continue;
			if(Q[Q[i].front()].front()==i)
			{
				b[i]=b[Q[i].front()]=max(b[i],b[Q[i].front()])+1;
				Q[Q[i].front()].pop();
				Q[i].pop();
				flag=1;
			}
		}
		if(!flag)
		{
			cout<<-1<<endl;
			return 0;
		}
		int num=0;
		for(int i=0;i<n;++i)
		    num+=Q[i].size();
		if(num==0) break;
	}
	for(int i=0;i<n;++i)
	    ans=max(ans,b[i]);
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8576
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

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

// const int kMaxN;

int A, B;
int ans = 0;

int main() {
  cin >> A >> B;

  FOR(i, A, B+1) {
    int d0 = i%10;
    int d1 = (i%100 - d0) / 10;
    int d2 = (i%1000 - d1 - d0) / 100;
    int d3 = (i%10000 - d2 - d1 - d0) / 1000;
    int d4 = (i - d3 - d2 - d1 - d0) / 10000;

    // << d1 << d2 << d3 << d4 <<
    // cout << d1 << endl;
    if (d0 == d4 && d1 == d3) { ++ans; }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (int i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int N, K;
    MaxHeap<pii> maxs;
    MinHeap<pii> mins;

    cin >> N >> K;
    rep(i, N) {
        int t, d;
        cin >> t >> d;
        maxs.emplace(d, t);
    }

    i64 manzoku = 0;
    int used[100010] {};
    i64 x = 0;

    rep(i, K) {
        const i64 value = maxs.top().first;
        const i64 type = maxs.top().second;
        maxs.pop();
        mins.emplace(value, type);
        manzoku += value;
        if (++used[type] == 1) ++x;
    }

    i64 ans = manzoku + x*x;

    while(!maxs.empty()) {
        const i64 nval = maxs.top().first;
        const i64 ntype = maxs.top().second;
        maxs.pop();
        if (used[ntype]) continue;

        i64 dval = -1, dtype = -1;
        while(!mins.empty()) {
            dval = mins.top().first;
            dtype = mins.top().second;
            mins.pop();
            if (used[dtype] > 1) break;
            dval = -1;
            dtype = -1;
        }

        if (dtype == -1) break;
        --used[dtype];
        ++used[ntype];
        manzoku -= dval;
        manzoku += nval;
        ++x;

        chmax(ans, manzoku + x*x);
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 5232
#include<bits/stdc++.h>
#define Mod 1000000007
#define Val(x) (((long long)x) % Mod)
#define maxn 200005
using namespace std;
int n;
vector<int> G[maxn];
int fac[maxn],sz[maxn],dp[maxn];
int Pow(int base,int n) {
	int ret = 1;
	while(n > 0) {
		if(n & 1)	ret = Val(ret * base);
		base = Val(base * base);
		n >>= 1;
	}
	return ret;
}
int inv(int val) {
	return Pow(val,Mod-2);
}
void dfs1(int u,int pa) {
	dp[u] = sz[u] = 1;
	for(int v : G[u])
		if(v != pa) {
			dfs1(v,u);
			sz[u] += sz[v];
			dp[u] = Val(dp[u] * dp[v]);
			dp[u] = Val(dp[u] * inv(fac[sz[v]]));
		}
	dp[u] = Val(dp[u] * fac[sz[u] - 1]);
}
int ans[maxn];
void dfs2(int u,int pa,int up) {
	dp[u] = Val(dp[u] * inv(fac[sz[u] - 1]));
	ans[u] = Val(Val(dp[u] * up) * fac[n - 1]);
	for(int v : G[u])
		if(v != pa) {
			int down = Val(Val(dp[u] * inv(dp[v])) * fac[sz[v]]);
			down = Val(down * up);
			down = Val(Val(down * fac[n - sz[v] - 1]) * inv(fac[n - sz[v]]));
			dfs2(v,u,down);
		}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	fac[0] = 1;
	for(int i=1;i<maxn;i++)
		fac[i] = Val(fac[i-1] * i);
	cin >> n;
	for(int i=1,u,v;i<n;i++) {
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs1(1,1);
	dfs2(1,1,1);
	for(int i=1;i<=n;i++)
		cout << ans[i] << endl;
	return 0;
}


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

using namespace std;

int gm[1001][1001];
int to[1001];
set<pair<int,int > > playNow; 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)for(int j=0;j<n-1;j++)cin>>gm[i][j],gm[i][j]--;
    int day=0;
    vector<int > at(n,0);
    for(int i=0;i<n;i++){
        int ag = gm[i][0];
        if(i == gm[ag][0])playNow.insert({min(i,ag),max(i,ag)});
    }
    while(1){
        if(playNow.empty())break;
        vector<int > players;
        for(auto v:playNow){
            at[v.first]++;
            at[v.second]++;
            players.push_back(v.first);
            players.push_back(v.second);
        }
        playNow.clear();
        for(auto p:players){
            if(at[p]==n-1)continue;
            int ag = gm[p][at[p]];
            if(p == gm[ag][at[ag]])playNow.insert({min(p,ag),max(p,ag)});
        }
        day++;
    }
    for(int i=0;i<n;i++){
        if(at[i] != n-1){
            cout<<-1<<'\n';
            return 0;
        }
    }
    cout<<day<<'\n';
    return 0;
}



Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

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

    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> bridge(M);
    REP (i, M) {
        ll a, b;
        cin >> a >> b;
        bridge[i] = make_pair(b, a);
    }

    sort(bridge.begin(), bridge.end());

    ll now = 0;
    ll ans = 0;
    REP (i, M) {
        ll a = bridge[i].second;
        ll b = bridge[i].first;

        if (a < now) continue;
        ans++;
        now = b;
        // cout << b << "\n";
    }

    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//

//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	string s; cin >> s;

	FOR(i, 1, s.size() + 1)
	{
		if (s[i] == s[i - 1])
		{
			cout << i << " " << i + 1 << endl;
			return 0;
		}

		if (i == 1) continue;

		if (s[i] == s[i - 2])
		{
			cout << i-1 << " " << i + 1 << endl;
			return 0;
		}
	}

	cout << -1 <<" "<< -1 << endl;

	//
	// your code finished

	return 0;
}

Measured memory_bytes: 512
def main():
 
    N, M = map(int, input().split())
    sc = []
    for _ in range(M):
        s, c = map(int, input().split())
        sc.append([s, c])
 
    start = pow(10, N-1)
    if N == 1: start = 0
    
    for v in range(start, pow(10, N)):
        t = str(v)
        if all(t[s-1] == str(c) for s, c in sc):
            return v
    return -1
 
if __name__ == '__main__':
    print(main())

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

using namespace std;

#define int long long

const int MOD1 = 1e9 + 7;
const int MOD2 = 1e9 + 9;

const int DIM = 1e5 + 7;
const int alpha = 26;

int n;
string s;

int power1[DIM];
int power2[DIM];

void precalc()
{
	power1[1] = 1;
	power2[1] = 1;
	
	for(int i = 2; i <= n; i++)
	{
		power1[i] = (power1[i - 1] * alpha) % MOD1;
		power2[i] = (power2[i - 1] * alpha) % MOD2;
	}
}

int hash1[DIM];
int hash2[DIM];

bool check(int len)
{
	int cod1 = 0;
	int cod2 = 0;
	
	for(int i = 1; i <= len; i++)
	{
		cod1 = (cod1 * alpha + s[i] - 'a') % MOD1;
		cod2 = (cod2 * alpha + s[i] - 'a') % MOD2;
	}
	
	hash1[1] = cod1;
	hash2[1] = cod2;
	
	for(int i = len + 1; i <= n; i++)
	{
		cod1 = (cod1 - (power1[len] * (s[i - len] - 'a')) % MOD1 + MOD1) % MOD1;
		cod2 = (cod2 - (power2[len] * (s[i - len] - 'a')) % MOD2 + MOD2) % MOD2;
		
		cod1 = (cod1 * alpha + s[i] - 'a') % MOD1;
		cod2 = (cod2 * alpha + s[i] - 'a') % MOD2;
		
		hash1[i - len + 1] = cod1;
		hash2[i - len + 1] = cod2;
	}
	
	set <pair <int, int> > s;
	
	for(int i = len; i <= n - len + 1; i++)
	{
		pair <int, int> p = {hash1[i], hash2[i]};
		
		if(s.find(p) != s.end())
			return true;
		
		s.insert({hash1[i - len + 1], hash2[i - len + 1]});
	}
	
	return false;
}

main()
{
	cin >> n;
	cin >> s;
	
	s = ' ' + s;
	
	precalc();
	
	int l = 1;
	int r = n;
	
	int res = 0;
	
	while(l <= r)
	{
		int mid = (l + r) / 2;
		
		if(check(mid))
		{
			l = mid + 1;
			res = mid;
		}
		else
		{
			r = mid - 1;
		}
	}
	
	cout << res;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
typedef long double ld;
#define pi 3.14159265358979

int  main()
{
	int a,b,c,d; cin >> a >> b >> c >> d;
	if ((c >= a && c <= b) || (b >= c && b <= d) || (a >= c && a <= d))
		cout << abs(max(a, c) - min(b, d)) << endl;
	else
		cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (n, l): (usize, usize) = read();
    let mut s: Vec<String> = readn(n);
    s.sort();
    let mut ans = "".to_string();
    for si in s {
        ans += &si;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    while(true)
    {
        var list = readLine()!!.split(" ").map(String::toInt)
        var a = list[0] / list[1]
        var b = list[0] % list[1]
        var c = list[0].toDouble() / list[1].toDouble()
        println("%d %d %f".format(a,b,c))
        return
    }
}


Measured memory_bytes: 33736
#include<stdio.h>
int main(){
  int n,a[200001],i,sec=0,max=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
    if(a[i]>max){
      sec=max;
      max=a[i];
    }
    else if(a[i]>sec){
      sec=a[i];
    }
  }
  for(i=0; i<n; i++){
    if(a[i]==max){
      printf("%d\n",sec);
    }
    else{
      printf("%d\n",max);
    }
  }
  return 0;
}


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

int main() {
	int n, x, t,ans;
	cin >> n >> x >> t;
	ans = n / x;
	if (n%x != 0) {
		ans += 1;
	}
	ans *= t;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#define MAXN 200010
using namespace std;
const int maxn = 1010;
typedef long long ll;
int main(){
    ll a, b, c;
    cin>>a>>b>>c;
    ll x = c-a-b;
    if(x>0&&x*x>4*a*b){
        printf("Yes\n");
    }else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    int ans = (power(2, n) + (mod - 1)) % mod;
    int t1 = 1, t2 = 1;
    rep(i, a) t1 = Div(Mul(t1, n - i), i + 1);
    rep(i, b) t2 = Div(Mul(t2, n - i), i + 1);
    cout << (ans - t1 - t2 + mod * 10LL) % mod << endl;


    return 0;
}
// 4 6 4 1

Measured memory_bytes: 256
N, Y = input().split()
N = int(N)
Y = int(Y)

yen = int(Y/1000)
m_1 = int(Y/1000)
m_5 = int((m_1-m_1%5)/5)
m_10 = int((m_1-m_1%10)/10)

t = 0
for x in range(0,m_10+1):
    test1 = yen - 10*x
    if test1 < 0: break
    for y in range(0,m_5+1):
        if t == 1:break
        z = test1 - 5*y
        if z < 0:break
        if z == N-x-y:
            print(x,y,z)
            t = 1
            
if t == 0:
    print(-1,-1,-1)

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

int main()
{
	string s;
	while (getline(cin,s))
	{
		string ss = "";
		for (int i = 0; i < s.size(); i++)
		{
			if (s[i] == ' ' || s[i] == '.')
			{
				ss += s[i];
			}
			else
			{
				ss += (s[i] - ' ');
			}
		}
		cout << ss << endl;
	}
	return 0;
}

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

using namespace std;
#define WHITE 0 //未到達
#define GLAY 1 //訪問中
#define BLACK 2 //訪問完了
#define INF 1000000001


void dfs(const vector<vector<int> > &adj_list,
     const int id, vector<int> &color,const int color_id){
    color[id] = color_id;
    for(auto itr = adj_list[id].begin();itr != adj_list[id].end(); itr++){
        int v = *itr;
        if(color[v] == -1){
            color[v] = color_id;
            dfs(adj_list,v,color,color_id);
        }
    }
    return;
}

void assignColor(const vector<vector<int> > &adj_list, vector<int> &color,const int n){
    int color_id = 0;
    for(int u = 0; u < n; u++){
        if(color[u] == -1){
            dfs(adj_list,u,color,color_id);
            color_id++;
        }
    }
}


int main(){
    int n,m;
    int s,t;
    int q;

    cin >> n >> m;
    vector<vector<int> > adj_list(n);
    vector<int> color(n,-1);


    for(int i = 0; i < m; i++){
        cin >> s >> t;
        adj_list[s].push_back(t);
        adj_list[t].push_back(s);
    }

    assignColor(adj_list,color,n);

    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> s >> t;
        if(color[s] == color[t]) cout << "yes\n";
        else cout << "no\n";
    }

    return 0;
}


Measured memory_bytes: 13336
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    vector<int> vec;
    int a, k;
    string ans = ":(";
    for (int i = 0; i < 5; i++) {
        cin >> a;
        vec.push_back(a);
    }
    cin >> k;
    sort(vec.begin(), vec.end());
    if(vec[4] - vec[0] <= k) ans = "Yay!";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

string o,e;
cin>>o>>e;
if(o.length()==e.length()){
    for(int i=0;i<o.length();i++){
        cout<<o[i]<<e[i];
    }
    cout<<endl;
}else{
    for(int i=0;i<e.length();i++){
        cout<<o[i]<<e[i];
    }
    cout<<o[o.length()-1]<<endl;
}


return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int input_N[200],count_N, stop_N=0 ,answer_N=0;
  cin >> count_N ;
  count_N--;
  
  for(int i=0; i <= count_N ; i++){
    cin >> input_N[i] ;
  }
  
  for(int k=0 ; k <= count_N ; k++){
    if(input_N[k]%2 == 1){
      stop_N++;
    }
    else{
      input_N[k] = input_N[k]/2;
    }
    
    if(k == count_N && stop_N > 0 ){}
    if(k == count_N && stop_N == 0){
      k = -1;
      answer_N++;
    }
  }
  cout << answer_N << endl;
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
int main(){
 char s[0];
scanf("%c",s);
  if((s[0]>= 'a') && (s[0]<='z')){
  printf("a");
    return 0;
  }
  else{
    printf("A");
    return 0;
  }
}

Measured memory_bytes: 1584
//kruskal tree
#include <cstdio>
#include <algorithm>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<int,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int i,j,J,n,m,r,R;
	for(;scanf("%d%d",&n,&m),n;printf("%d\n",R)){
		for(i=0;i<m;i++)scanf("%d%d%d",a+i,b+i,&node[i].first),node[i].second=i,a[i]--,b[i]--;
		for(sort(node,node+m),R=-1,i=0;i<=m-n+1;i++){
			for(J=j=0;j<n;j++)parent[j]=j;
			for(j=i;j<m;j++)if(unite(a[node[j].second],b[node[j].second]))if(r=node[j].first-node[i].first,++J==n-1){if(R==-1||R>r)R=r;break;}
		}
	}
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll comb(ll x){
	ll ans=1;
	ans=x*(x-1)/2;
	return ans;
}

int main(){
	ll n,m,ans=0;
	int a,dp[M]={};
	cin>>n>>m;
	rep(i,n){
		cin>>a;
		dp[i+1]=(dp[i]+a)%m;
	}
	sort(dp+1,dp+n+1);
	REP(i,1,n+1){
		if(dp[i]==0)ans++;
		else break;
	}
	REP(i,1,n+1){
		ll cnt=1;
		REP(j,i+1,n+1){
			if(dp[i]==dp[j])cnt++;
			else break;
		}
		ans+=comb(cnt);
		i+=cnt-1;
	}
	print(ans);
}

Measured memory_bytes: 640
#coding:utf-8
import itertools
import numpy as np
ls_S = []
N,M = map(int,input().split())
for m in range(M):
    S = list(map(int,input().split()))
    S = [s-1 for s in S]
    ls_S.append(S[1:])
ptns = list(itertools.product(range(0,2), repeat=N))
ptns = np.array(ptns)
#print (ptns)
#print (ls_S)
P = list(map(int,input().split()))
def check(P,ls):
    for i in range(len(P)):
        if P[i] == ls[i]:
            pass
        else:
            return 0
    return 1
sm = 0        
for ptn in ptns:
    ans = []
    for S in ls_S:
        #print ("a",sum(ptn[S]))
        ans.append(sum(ptn[S])%2)
    #print (ans)
    sm += check(P,ans)
print (sm)


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

const int MAX_N = 110000;

int memo[MAX_N]; // memo[i] が i についての答え
int rec(int n) {
    if (n == 0) return 0; // 終端条件
    if (memo[n] != -1) return memo[n]; // すでに探索済みならリターン

    int res = n; // INF の気持ち

	// 1, 9, 9^2, ..., を試す (n を超えない範囲で)
    for (int pow9 = 1; pow9 <= n; pow9 *= 9) res = min(res, rec(n - pow9) + 1);

     // 1, 6, 6^2, ..., を試す (n を超えない範囲で)
    for (int pow6 = 1; pow6 <= n; pow6 *= 6) res = min(res, rec(n - pow6) + 1);
  
 	// メモしながらリターン
    return memo[n] = res;
}

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

    // テーブルを -1 で初期化
    for (int i = 0; i < MAX_N; ++i) memo[i] = -1;
    cout << rec(N) << endl;
}

Measured memory_bytes: 3840
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
		int n=ni(),W=ni(),wt[]=new int[n+1],v[]=new int[n+1];

        for(int i=1;i<=n;i++){
            wt[i]=ni();
            v[i]=ni(); 
        }

        long dp[][]=new long[n+1][W+1];

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

                dp[i][j]=dp[i-1][j];//don't take current sack

                if(wt[i]<=j)//you can may take this sack. In tha case you'll be left with j-wt[i] wt
                    dp[i][j]=Math.max(dp[i][j]
                        ,v[i] + dp[i-1][j-wt[i]]);
            }
        }    	 
        pn(dp[n][W]);
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 138524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) {if(a<b) {a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) {if(a>b) {a=b;return 1;} return 0;}
const ll INF = 1LL<<60;

ll solve() {
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> w[i] >> v[i];
    }
    ll w1 = w[0];
    for ( int i = 0; i < N; i++ ) {
        w[i] -= w1;
    }
    vector<vector<ll>> dp(N+1, vector<ll>(3*N+1, -INF));
    dp[0][0] = 0;
    for ( int i = 0; i < N; i++ ) {
        for ( int k = N-1; k >= 0 ; k-- ) {
            for ( int j = 0; j <= 3*N; j++ ) {
                if ( k * w1 + j > W ) break;
                if ( j + w[i] <= 3*N && dp[k][j] != -INF ) {
                    chmax(dp[k+1][j + w[i]], dp[k][j] + v[i]);
                }
            }
        }
    }
    ll m = 0;
    for ( int k = 1; k <= N; k++ ) {
        for ( int j = 0; j <= 3*N ; j++ ) {
            if ( k * w1 + j > W ) break;
            chmax(m, dp[k][j]);
        }
    }
    
    return m;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
      	long result = 0;
      	boolean flag = true;
      	long temp = 10;
      	if(n%2 == 1 || n < 10) System.out.println(0);
      	else {
          while(n/temp > 0) {
            result += n / temp;
            if(flag) temp *= 5;
            else temp *= 2;
          }
          System.out.println(result);
        }
    }
}

Measured memory_bytes: 22996
n,m=map(int,input().split())
A=[input() for i in range(n)]
B=[input() for i in range(m)]

for i in range(n):
  for j in range(n):
    k=j+m
    if k <= n:
      if A[i][j:k]== B[0]:
        o=1
        for l in range(i+1,i+m):
          if l<n:
            if A[l][j:k]!=B[o]:
              break
            else:
              o+=1
        if o==m:
          print('Yes')
          exit()
print('No')



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

const int MAX = 21000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() {
    COMinit();
    long long H, W, K; cin >> H >> W >> K;
    long long res = 0;
    for (long long k = 1; k <= K; ++k) {
        long long tmp1 = (k + 1) * COM(H + W, H) % MOD;
        long long tmp2 = k * (k - 1) % MOD * COM(H + W - 2, H - 1) % MOD;
        long long tmp = (tmp1 + tmp2) % MOD * fac[H] %  MOD * fac[W] % MOD * finv[H+W-K] % MOD;
        res = (res + tmp) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 492416
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MODD 1000000007
#define ll long long
using namespace std;

int dp[111111];

int main() {
    string S;
    cin>>S;
    
    int N=S.size();
    dp[N]=true;
    
    
    vector<string> tmp;
    tmp.push_back("dream");
    tmp.push_back("dreamer");
    tmp.push_back("erase");
    tmp.push_back("eraser");
    
    for(int j=N-1;j>=0;j--) {
        dp[j]=false;
        for(int k=0;k<tmp.size();k++) {
            int L=tmp[k].size();
            // j to j+L-1
            if (j+L-1 >= N)
                continue;
            

            
            if (S.substr(j,L) == tmp[k]) {
                dp[j]|=dp[j+L];
            }
            
        }
        
    }
    
    if (dp[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    
    
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	long int num[1000];
	char ope[1000];
	long int answer = 0;

	CI answer;

	for (int i = 0; i < 100; ++i) {
		CI ope[i];
		if (ope[i] == '=') {
			CO answer E
			return 0;
		}
		CI num[i];

		if (ope[i] == '+') {
			answer += num[i];
		}
		if (ope[i] == '-') {
			answer -= num[i];
		}
		if (ope[i] == '*') {
			answer *= num[i];
		}
		if (ope[i] == '/') {
			answer /= num[i];
		}
		

	}
}

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

typedef long long ll;

using namespace std;


const ll N=100001;

int dp[667][2010];

const ll mod=1000000000+7;




int main(){

    int S;
    cin>>S;

    int p=S/3;

    for(int i=3;i<=S;++i){
        dp[1][i]=1;
        
    }
/*
    for(int i=0;i<=p;i++){
        for(int j=0;j<=S;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */

    for(int i=1;i<=p;i++){
        for(int j=3*i;j<=S;++j){
           for(int k=3;k<=S-j;++k){
               dp[i+1][j+k]=(dp[i+1][j+k]+dp[i][j])%mod;
           }
    
        }
        /*
        
        cout<<"========="<<endl;
         for(int i=0;i<=p;i++){
        for(int j=0;j<=S;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
        
    }
    */
    
    }

    ll ans=0;

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

        ans=(ans+dp[i][S])%mod;
    }


cout<<ans<<endl;
    
}



Measured memory_bytes: 8108
#include <cmath>
#include <chrono>
#include <random>
#include <ctime>
#include <algorithm>
#include <iosfwd>
#include <iostream>
#include <list>
#include <ostream>
#include <streambuf>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fori(i, n) for(ll i = 0; i < (n); ++i)
#define forI(i, n) for(ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define ff first
#define ss second

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define pt pair<ll, ll>
#define x first
#define y second

pll operator+ (pll a, pll b){ return {a.x + b.x, a.y + b.y}; }

ll rand0m() {
    return (ull(rand()) << 15ull | ull(rand()));
}                   //[0 ... n)
ll rand0m(ll x) {
    return rand0m() % x;
}               //[0 ... n)
ll rand0m(ll minn, ll maxx) {
    return rand0m(maxx - minn + 1) + minn;
}   //[minn ... maxx]

const ll MAXN = 1e5 + 1;
const ll mod = 1e9 + 7;
const ll INF = 2e9 + 1000;

ll n, m, k;
ll a[MAXN];
ll dp[MAXN + 2];

void solve() {
    cin >> n;
    fori(i, n) cin >> a[i];
    forI(i, n) dp[i] = INF;
    fori(i, n - 1){
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i + 1] - a[i]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i + 2] - a[i]));
    }
    cout << dp[n - 1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
}

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

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;
	
	vector<int> c;
	for(int i=1; i<=9; i++) {
		for(int j=1; j<=9; j++) {
			c.push_back(i*j);
		}
	}
	
	bool f = false;
	for(int i=0; i<c.size(); i++) {
		if(c[i] == N) f = true;
	}
	
	cout << (f ? "Yes" : "No") << endl;
	
	return 0;
}


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

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef pair<int, int> pint;
typedef vector<pint> vpint;

const int INF = 1e9;

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

  int ans = INF;

  //  P[i問目] = <問題数, 全完ボーナス>
  vpint P(D);
  forn (i, D) cin >> P[i].fi >> P[i].se;

  //  全完する問題を決め打つ
  for (int bit = 0; bit < (1 << D); ++bit) {
    vi S(D, 0); //  解いた問題は1にする
    int score = 0, cnt = 0;
    for (int i = 0; i < D; ++i) {
      if (bit & (1 << i)) {
        //  i番目の問題を解く
        score += (i+1) * 100 * P[i].fi + P[i].se;
        cnt += P[i].fi;
        S[i] = 1;
      }
    }
    //  まだ得点が足りないなら得点が高いものから解いていく
    int solving = D;
    while (score < G) {
      //  もしsolving番目の問題を解いていたらスルー
      solving--;
      if (S[solving]) continue;
      forn (i, P[solving].fi) {
        score += (solving+1) * 100;
        ++cnt;
        if (score >= G) break;
      }
      if (score < G) score += P[solving].se;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

int main() {
	int h1, h2, k1, k2;
	int a, b, c, d;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	if (h1*a + h2*b + h1 / 10 * c + h2 / 20 * d > k1*a + k2*b + k1 / 10 * c + k2 / 20 * d)cout << "hiroshi" << endl;
	else if (h1*a + h2*b + h1 / 10 * c + h2 / 20 * d < k1*a + k2*b + k1 / 10 * c + k2 / 20 * d)cout << "kenjiro" << endl;
	else cout << "even" << endl;
}

Measured memory_bytes: 3100
n, x = [int(num) for num in input().split()]
list = []
for i in range(n):
	list.append(int(input()))
    
counter = 0
#お菓子を全部作る
counter += len(list)
x -= sum(list)

#mの小さいお菓子に集中投下
counter += x // min(list)

print(counter)


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

typedef long long ll;

vector<int> v;

ll dfs(ll i, ll N, ll K, ll *a, ll m) {
    if (i == N) {
        if (v.size() < K)
            return 999999999999;
        
        return 0;
    }

    ll ans;
    if (a[i] <= m) {
        v.push_back(i);
        ans = m+1-a[i]+dfs(i+1, N, K, a, m+1);
        v.pop_back();
        ans = min(ans, dfs(i+1, N, K, a, m));
        return ans;
    }
    else {
        v.push_back(i);
        ans = dfs(i+1, N, K, a, a[i]);
        v.pop_back();
        return ans;
    }
}

int main() {
    ll N, K;   cin >> N >> K;
    ll *a = new ll[N];
    for (int i = 0; i < N; i++)
        cin >> a[i];
    
    cout << dfs(0, N, K, a, 0) << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const ll INF=1000000000000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static ll n;
	static ll x[200010],y[200010];
	scanf("%lld",&n);
	rep(i,n)scanf("%lld%lld",&x[i],&y[i]);
	
	ll M=0,R=0,B=0;
	ll m=INF,r=INF,b=INF;
	rep(i,n){
		R = max( R , max(x[i],y[i]) );
		B = max( B , min(x[i],y[i]) );
		r = min( r , max(x[i],y[i]) );
		b = min( b , min(x[i],y[i]) );
	}
	M = R;
	m = b;
	
	ll ret = (R-r)*(B-b);
	
	priority_queue<P,vector<P>,greater<P>> que;
	rep(i,n){
		que.push(P(min(x[i],y[i]),max(x[i],y[i])));
	}
	while(1){
		P p = que.top(); que.pop();
		if(p.sc <= p.fr)break;
		que.push(P(p.sc,p.fr));
		B = max( B , p.sc );
		b = que.top().fr;
		ret = min( ret , (M-m)*(B-b) );
	}
	cout << ret << endl;
}



Measured memory_bytes: 9584
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

string s,t;
cin>>s>>t;

cout<<t<<s<<endl;
return 0;

}
/*
oder atc

atcoder

*/


Measured memory_bytes: 256
local n = io.read("*n")
io.write("11")
local cnt = 1
local ofst = 21

local function isprime(x)
  local a = math.ceil(math.sqrt(x))
  for i = 2, a do
    if(x % i == 0) then return false end
  end
  return true
end

local t = {}
while(cnt < n) do
  if(isprime(ofst)) then
    cnt = cnt + 1
    io.write(" " .. ofst)
  end
  ofst = ofst + 10
end
io.write("\n")


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          long[] ban = ReadLine().Split(' ').Select(long.Parse).ToArray();
          long ans = ban[1] * (ban[0] / 2);
          if(ban[0] == 1 || ban[1] == 1){
              WriteLine(1);
              return;
          }
          if(ban[0] % 2==1){
              if(ban[1] % 2==1) ans += ban[1] / 2 + 1;
              else ans += ban[1] / 2;
          }
          WriteLine(ans);
      }
   }
}

Measured memory_bytes: 13396
N=gets.to_i
res = {}
N.times do |i|
  s,pp = gets.split
  if res[s] == nil
    res[s] = []
  end
  res[s] << [i+1, pp.to_i]
end
names = res.keys
names.sort!
names.each do |name|
  a = res[name].sort_by{|seq| -seq[1]}
  a.each do |ai|
    puts ai[0]
  end
end


Measured memory_bytes: 1788
#define ll long long
#define MOD 1000000007
#define MOD2 998244353
#define INF 1e12
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORE(i, a, b) for (int i = a; i <= b; i++)
#define pii pair<int, int>
#define pll pair<ll, ll>
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif //*/
    ll s, w;
    cin >> s >> w;
    if (w >= s)
        cout << "unsafe";
    else
        cout << "safe";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int D;
array<int, 26> C;
vector<array<int, 26>> S;
vector<array<pair<int, int>, 26>> A;
#ifndef GOOD
#define GOOD 7
#endif
#ifndef DEPTH
#define DEPTH 6
#endif
pair<int, int> search(int depth, vector<int>& last, int d) {
    int minus = 0;
    for (int t = 0; t < 26; t++) {
        minus += C[t] * (d + 1 - last[t]);
    }
    if (depth == 0 || d == D - 1) {
        int vmax = -1e9;
        int tmax = 0;
        for (int i = 0; i < GOOD; i++) {
            auto [score, t] = A[d][i];
            int v2 = -minus + score + C[t] * (d + 1 - last[t]);
            if (v2 > vmax) {
                vmax = v2;
                tmax = t;
            }
        }
        return {tmax, vmax};
    }
    int vmax = -1e9;
    int tmax = 0;
    for (int i = 0; i < GOOD; i++) {
        auto [score, t] = A[d][i];
        int v2 = -minus + score + C[t] * (d + 1 - last[t]);
        int tmp = last[t];
        last[t] = d + 1;
        auto [t2, v3] = search(depth - 1, last, d + 1);
        v2 += v3;
        last[t] = tmp;
        if (v2 > vmax) {
            vmax = v2;
            tmax = t;
        }
    }
    return {tmax, vmax};
}
int main() {
    cin >> D;
    for (auto &c : C) cin >> c;
    S.resize(D), A.resize(D);
    for (auto &row : S) for (auto &s : row) cin >> s;
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            A[i][j] = make_pair(S[i][j], j);
        }
        sort(rbegin(A[i]), rend(A[i]));
    }
    vector<int> last(26);
    for (int d = 0; d < D; d++) {
        auto [t, v] = search(DEPTH, last, d);
        last[t] = d + 1;
        cout << t + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 3756