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

using namespace std;

#define ll long long int
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<ll>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)

void solve()
{
    int n;
    cin>>n;
    map<string,int> mp;
    for(int i=0;i<n;i++)
    {
        string temp;
        cin>>temp;
        mp[temp]++;
    }
    int maxi=INT_MIN;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        if(it->second>maxi)
        maxi=it->second;
    }
    for (auto it = mp.begin(); it!=mp.end(); it++)
    {
        if(it->second==maxi)
        cout<<it->first<<"\n";
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 19224
package main

import (
	"fmt"
	"math"
)

var A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z int
var mod int = pow(10, 9) + 7
var ans int

func main() {
	fmt.Scan(&N, &K)

	red := N - K
	blue := K

	for i := 1; i <= K; i++ {
		ans = combination(red+1, i) * combination(blue-1, i-1) % mod
		fmt.Println(ans)
	}
}

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

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [10000]int
var finv [10000]int
var inv [10000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	for i := 2; i < 10000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] > a[j] }


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n, x, m;
    cin >> n >> x >> m;
    ll x2 = x;
    if(x == 0) ans = 0;
    else if(x == 1) ans = n;
    else{
        vector<int> to(m+1, -1);
        while(to[x] < 0){
            to[x] = x * x % m;
            x = x * x % m;
        }
        ll looplen = 0, loopsum = 0;
        ll init = x;
        do{
            looplen++;
            loopsum += x;
            x = to[x];
        }while(x != init);
        //cout << loopsum << " " << looplen << " " << loopsum * (n / looplen) << endl;
        while(x2 != x){
            ans += x2;
            x2 = x2 * x2 % m;
            n--;
            if(n == 0) break;
        }
        ans += loopsum * (n / looplen);
        n %= looplen;
        while(n){
            ans += x2;
            x2 = x2 * x2 % m;
            n--;            
        }
    }  
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
ll pows(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,e,f,p,q,r,l,g,h,w,count1=0,prod=1,a,b,c,d,index,x1,x2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
ld aa,bb,cc;
cin>>aa>>bb>>cc;
ld pp=(cc-aa-bb);
ld xx=2*sqrt(aa*bb);
if(pp>xx)
{
  cout<<"Yes";
}
else
{
  cout<<"No";
}
}


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

signed main(){
  
  int n;
  cin>>n;
  
  double ans = 0;

  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ans += 1.0 / a;    
  }
  
  ans = 1.0 / ans;

  printf("%.8f\n", ans);
  
  return 0;
}


Measured memory_bytes: 256
loop do
  n = gets.to_i
  break if n == 0
  ary = []
  sum = 0
  0.upto(n-1) do |i|
    ary[i] = gets.to_i
  end
  ary.delete_at(ary.find_index(ary.max))
  ary.delete_at(ary.find_index(ary.min))
  ary.each do |x|
    sum += x
  end
  puts sum / ary.size
end

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

#define INF (1e9)
#define INF_LL (1e17)

using LL = long long;
using ULL = unsigned long long;

using namespace std;

LL N;

int main()
{
  cin >> N;
  int ans = 0;
  while(N > 0){
    ++ans;
    N -= ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3fLL
#define endl '\n'
typedef long long ll;
int main(){
    ios::sync_with_stdio(0);
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= m; j++){
            if (i * m + j * n - 2 * i * j == k){
                cout << "Yes" << endl; return 0;
            }
        }
    }
    cout << "No" << endl; return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mpp make_pair
#define pii pair<int,int>
#define pb push_back
const int maxn = 1e5 + 5;
int mp[6][6] , sum[6][6];
ll cnt[15];
map<pair<int,int> , bool> Q;
int ask (int x , int y , int a , int b)
{
    return sum[a][b] - sum[x - 1][b] - sum[a][y - 1] + sum[x - 1][y - 1];
}
int main()
{
    ios::sync_with_stdio(false);
    ll n , m , q; cin >> n >> m >> q;
    cnt[0] = (n - 2) * (m - 2);
    while (q--){
        int a , b; cin >> a >> b;
        for (int i = a - 2 ; i <= a + 2 ; i++){
            for (int j = b - 2 ; j <= b + 2 ; j++){
                int x = i - (a - 2) + 1 , y = j - (b - 2) + 1;
                if (i <= 0 || i > n || j <= 0 || j > m)
                    mp[x][y] = -1e5;
                else
                    mp[x][y] = Q[mpp(i , j)];
                sum[x][y] = sum[x - 1][y] + sum[x][y - 1] - sum[x - 1][y - 1] + mp[x][y];
            }
        }
        for (int i = a ; i <= a + 2 ; i++){
            for (int j = b ; j <= b + 2 ; j++){
                int x = i - (a - 2) + 1 , y = j - (b - 2) + 1;
                if (i <= 0 || i > n || j <= 0 || j > m) continue;
                int res = ask(x - 2 , y - 2 , x , y);
                if (res < 0) continue;
                cnt[res]--;
                cnt[res + 1]++;
            }
        }
        Q[mpp(a , b)] = 1;
    }
    for (int i = 0 ; i <= 9 ; i++) cout << cnt[i] << endl;
    return 0;
}


Measured memory_bytes: 159776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;
//階乗できるよ
ll kaizyo(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  string s; cin >> s;
  ll k; cin >> k;
  ll count = 0;

  int size_s = s.size();

  if(size_s == 1) {
    count = floor(k / 2);
    cout << count << endl;
    return 0;
  }

  if(s.at(0) == s.at(size_s - 1)) {
    ll count_front_same_num = 1, count_back_same_num = 1;
    bool flag1 = false;
    rep(i,size_s) {
      if(i == 0) continue;
      if(s.at(i) == s.at(i - 1)) {
        count_front_same_num++;
      }
      else{
        flag1 = true;
        break;
      }
    }

    if(flag1) {
      for(int i = size_s - 1; i > 0; i--){
        if(s.at(i) == s.at(i - 1)) {
          count_back_same_num++;
        }
        else {
          break;
        }
      }      
    }

    if(!flag1) {
      count = floor(k * size_s / 2);
      cout << count << endl;
      return 0;
    }

    rep(i,size_s) {
      if(i == 0) continue;
      if(s.at(i) == s.at(i - 1)) {
        s.at(i) = '*';
        count++;
        //cout << i << endl;
      }
    }

    count = count * k;

    count = count - (floor(count_front_same_num / 2) + floor(count_back_same_num / 2) - floor((count_front_same_num + count_back_same_num) / 2)) * (k - 1);
    cout << count << endl;
    return 0;
  }

  rep(i,size_s) {
    if(i == 0) continue;
    if(s.at(i) == s.at(i - 1)) {
      s.at(i) = '*';
      count++;
      //cout << i << endl;
    }
  }

  count = count * k;


  cout << count << endl;
  //cout << s << endl;
}



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

#define rep(i,n) for(signed i=1;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if


int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  int s;
  cin>>s;
  
  int a[1000000];
  a[0]=s;
  rep(i,1000000){
    if(a[i]==1)a[i]=s;
    if(a[i-1]%2==0)a[i]=a[i-1]/2;
    elif(a[i-1]%2==1)a[i]=3*a[i-1]+1;
    for(j=0;j<i;++j){
        if(a[j]==a[i]){
            cout<<(i+1)<<endl;
            return 0;
        }
    }
  }
  
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(char c: s) cnt += (c == 'o');
    if(cnt >= 8) cout << "YES" << endl;
    else if(cnt + (15 - s.size()) >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

typedef long long LL;
const int Maxn = 111111;
struct Edge {
	int v, id;
	Edge *nxt;
} pool[Maxn*2], *tree[Maxn], *tail = pool;
inline void addedge(const int &u, const int &v, const int &id) {
	tail->v = v, tail->id = id;
	tail->nxt = tree[u], tree[u] = tail++;
}

int n, a[Maxn], w[Maxn];
bool isleaf[Maxn];

void dfs(int u, int fa, int lastid) {
	w[lastid] = a[u];
	isleaf[u] = true;
	for (Edge *p = tree[u]; p; p = p->nxt) {
		if (p->v != fa) {
			isleaf[u] = false;
			dfs(p->v, u, p->id);
			w[lastid] -= w[p->id];
		}
	}
	if (!isleaf[u]) {
		w[lastid] += a[u];
	}
}
void solve() {
	if (n == 2) {
		if (a[1] == a[2]) {
			puts("YES");
		} else {
			puts("NO");
		}
		return;
	}
	for (int i = 1, cnum; i <= n; ++i) {
		cnum = 0;
		for (Edge *p = tree[i]; p; p = p->nxt) {
			++cnum;
		}
		if (cnum > 1) {
			dfs(i, 0, 0);
			break;
		}
	}
	if (w[0] != 0) {
		puts("NO");
		return;
	}
	for (int i = 1; i < n; ++i) {
		if (w[i] < 0) {
			puts("NO");
			return;
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (!isleaf[i]) {
			LL tot = 0;
			for (Edge *p = tree[i]; p; p = p->nxt) {
				tot += w[p->id];
			}
			for (Edge *p = tree[i]; p; p = p->nxt) {
				if (w[p->id] > tot/2) {
					puts("NO");
					return;
				}
			}
		}
	}
	puts("YES");
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i){
		scanf("%d", &a[i]);
	}
	for (int i = 1, x, y; i < n; ++i) {
		scanf("%d%d", &x, &y);
		addedge(x, y, i), addedge(y, x, i);
	}
	solve();
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>

int main(){
  int x, y, z, w;
  
  std::cin >> x;
  std::cin >> y;
  std::cin >> z;
  std::cin >> w;
  if(x==y && z==w){
    std::cout << "yes" << std::endl;
  }else if(x==z && y==w){
    std::cout << "yes" << std::endl;
  }else if(x==w && y==z){
    std::cout << "yes" << std::endl;
  }else{
    std::cout << "no" << std::endl;
  }
  
  return 0; 
}

Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;

    if(N % 2 == 0){
        cout << N / 2 - 1 << endl;
    }
    else{
        cout << N / 2 << endl;
    }

    return 0;
}

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

int main() {
    
    int a, b;
    cin >> a >> b;
    
    if((a==1 && b==2) || (a==2 && b==1)) cout << "3" << endl;
    else if((a==1 && b==3) || (a==3 && b==1)) cout << "2" << endl;
    else if((a==2 && b==3) || (a==3 && b==2)) cout << "1" << endl;
    
    
    
	return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> num(N);
    rep(i,N)cin >> num[i];
    ll ans = 1;
    rep(i,N){
        if(num[i] == ans){
            ans++;
        }
    }
    ans--;
    if(ans == 0){
        cout << "-1\n";
        return 0;
    }
    cout << N - ans << endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b;
    if (a != 1 && b != 1)
    {
        c = 1;
    }
    else if (a != 2 && b != 2)
    {
        c = 2;
    }
    else
    {
        c = 3;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 610
ll n,k,a[N],b[N];
bool c[N];
ll g[N][N],f[N][N];
ll F(ll x){
    if(x%2==1)return 0;
    ll res=1;
    for(x-=1;x>0;x-=2)res=res*x%mod;
    return res;
}
ll G(ll i,ll j,ll x){
    if(i<=j)return i<=x&&x<=j;
    return x<=j||i<=x;
}
int main(){
    cin>>n>>k;n*=2;
    lol(i,n)c[i]=0;
    lol(i,k){
	cin>>a[i]>>b[i];a[i]--,b[i]--;
	c[a[i]]=c[b[i]]=1;
    }
    lol(i,n)lol(j,n){
	ll cnt=0;
	for(ll r=i;r<=(i<=j?j:n-1);r++)cnt+=not c[r];
	for(ll r=0;i>j&&r<=j;r++)cnt+=not c[r];
	g[i][j]=F(cnt);
    }
    ll ans=0;
    lol(len,n)lol(i,n-len){
	ll j=i+len;
	f[i][j]=0;
	bool ok=1;
	lol(r,k)ok&=not(G(i,j,a[r]) xor G(i,j,b[r]));
	if(!ok)continue;
	ll res=g[i][j];
	for(ll r=i;r<j;r++)res=(res-f[i][r]*g[(r+1)%n][j])%mod;
	f[i][j]=res;
	if(len==n-1){ans=(ans+f[i][j])%mod;}
	else ans=(ans+f[i][j]*g[(j+1)%n][(i-1+n)%n])%mod;
    }
    if(ans<0)ans+=mod;cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define INF 2147483647
#define fi first
#define se second
int abs(int a,int b){
  int c=max(a,b)-min(a,b);
  return c;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  int b[100000],c[100000];
  int d[100000];
  int e=0,f=0;
  cin>>a;
  for(int i=0;i<a;i++) cin>>b[i];
  for(int i=0;i<a;i++) cin>>c[i];
  for(int i=0;i<a;i++) d[i]=b[i]-c[i];
  for(int i=0;i<a;i++){
    if(d[i]>0) e+=d[i];
    //else f+=d[i];
  }
  cout<<e-f<<"\n";
}


Measured memory_bytes: 2304
import java.util.*;

class Main{

    int n, m;
    ArrayList<int[]>[] edge;
    int[] dist;
    int INF = Integer.MAX_VALUE;
             
    @SuppressWarnings("unchecked")
    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            int m = sc.nextInt();
            if(n==0 && m==0) break;

            edge = new ArrayList[n];
            for(int i=0; i<n; i++) edge[i] = new ArrayList<int[]>();
            dist = new int[n];
            Arrays.fill(dist, INF);

            for(int i=0; i<m; i++){
                int u = sc.nextInt()-1, v = sc.nextInt()-1;
                int d = sc.nextInt(), c = sc.nextInt();
                edge[u].add(new int[]{v, d, c});
                edge[v].add(new int[]{u, d, c});
            }

            dijstra();

            int[] cost = new int[n];
            Arrays.fill(cost, INF);

            for(int i=0; i<n; i++){
                for(int j=0; j<edge[i].size(); j++){
                    int to = edge[i].get(j)[0];
                    int d = edge[i].get(j)[1];
                    int c = edge[i].get(j)[2];
                    if(dist[i]==dist[to] + d) cost[i] = Math.min(cost[i], c);
                }
            }

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

            System.out.println(ans);
        }
    }

    void dijstra(){
        //pos, cost(dist)
        PriorityQueue<int[]> q = new PriorityQueue<int[]>(10, new Comparator<int[]>(){
                public int compare(int[] a, int[] b){
                    return a[1] - b[1];
                }
            });

        q.add(new int[]{0, 0});

        while(q.size()>0){
            int[] qq = q.poll();
            int pos = qq[0], cost = qq[1];

            if(dist[pos]<=cost) continue;
            dist[pos] = cost;

            for(int i=0; i<edge[pos].size(); i++){
                int to = edge[pos].get(i)[0];
                int d = edge[pos].get(i)[1];

                q.add(new int[]{to, cost+d});
            }
        }
    }

    public static void main(String[] args){
        new Main().solve();}
}

Measured memory_bytes: 167244
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    int N, MA, MB; cin >> N >> MA >> MB;
    vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(401, vector<int>(401, INF)));
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    for(int i=0; i<N; i++)
        cin >> A[i] >> B[i] >> C[i];
    
    dp[0][0][0] = 0;
    for(int i=0; i<N; i++){
        for(int a=0; a<=400; a++){
            for(int b=0; b<=400; b++){
                if(a-A[i] >= 0 && b-B[i] >= 0){
                    dp[i+1][a][b] = min(dp[i][a-A[i]][b-B[i]] + C[i], dp[i][a][b]);
                }else{
                    dp[i+1][a][b] = dp[i][a][b];
                }
            }
        }
    }

    int ans = INF;
    for(int a=1; a<401; a++){
        for(int b=1; b<401; b++){
            if(a*MB != b*MA) continue;
            ans = min(ans, dp[N][a][b]);
        }
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 27264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong(),y=sc.nextLong();
		long res=1;

		long max = Math.max(x, y);
		long min = Math.min(x, y);
		while(true) {
			res = max%min;
			if(res==0) break;
			max = min;
			min = res;
		}
		System.out.println(min);

	}
}



Measured memory_bytes: 26324
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <numeric>
#include <algorithm>

using namespace std;

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

    vector<int> v;
    for (int i = 0; i < N; ++i)
    {
        int j;
        cin >> j;
        v.push_back(j);
    }

    int total = accumulate(v.begin(), v.end(), 0);
    auto residual = X - total;

    auto light = *min_element(v.begin(), v.end());

    cout << (N + residual / light) << endl;

    return 0;
}

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

int main(){
    int n , m; cin >> n;
    vector<int> a(n);
    rep(i ,n) cin >> a[i];
    cin >> m;
    vector<int> b(m);
    rep(i ,m) cin >> b[i];
    int z = min ( n , m);
    rep(i , z){
        if(a[i] > b[i] ) {cout << 0 << endl; return 0;}
        else if(a[i] < b[i]) {cout << 1 << endl; return 0;}
    }
    if( m <= n ) cout << 0 << endl;
    else if( m > n ) cout << 1 << endl;
}


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

int main() {
    int N, K;
    string S;
    cin >> N >> S >> K;
    for (int i = 0; i < N; i++) {
        if (S[i] != S[K - 1]) {
            S[i] = '*';
        }
    }
    cout << S << endl;
    return 0;
}

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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  ll N,P;
  string S;
  cin>>N>>P>>S;
  if(P==2||P==5){
    reverse(S.begin(),S.end());
    map<ll,bool> m;
    rep(i,N) {
      int t = S[i] - '0';
      if(t%P==0) m[i] = true;
    }
    ll ans = 0;
    for(auto x:m) ans += N-x.first;
    cout<<ans<<endl;
  }
  else{
    reverse(S.begin(),S.end());
    vector<ll> MOD(N+1,0);
    ll B = 1LL;
    rep(i,N){
      ll t = S[i] - '0';
      MOD[i+1] = (MOD[i] + t*B)%P;
      B = (B*10)%P;
    }
    map<ll,ll> m;
    rep(i,N+1){
      m[MOD[i]]++;
    }
    ll ans = 0;
    for(auto x:m) ans += x.second*(x.second-1)/2;
    cout<<ans<<endl;
  }
}

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

const int N = 5000 + 5;
const int lgN = 13;
const int M = 200 + 5;
const ll inf = (ll)1e18;

int n, m, B[M][N][lgN];
ll dp[N], A[N];

ll query(int x, int l, int r) {
  int k = __lg(r - l + 1);
  return max(B[x][l][k], B[x][r - (1 << k) + 1][k]);
}
ll calc(int l, int r) {
  ll sum = 0;
  for(int i = 1 ; i <= m ; ++i) sum += query(i, l, r);
  return sum - (A[r] - A[l]);
}
void DP(int l, int r, int ql, int qr) {
  if(l > r) return;
  int mid = l + (r - l) / 2;
  ll val = -inf, pos = 0;
  for(int i = ql ; i <= min(mid, qr) ; ++i) {
    ll ret = calc(i, mid);
    if(ret > val) val = ret, pos = i;
  }
  dp[mid] = val;
  DP(l, mid - 1, ql, pos);
  DP(mid + 1, r, pos, qr);
}

void init() {
  cin >> n >> m;
  for(int i = 2 ; i <= n ; ++i) cin >> A[i], A[i] += A[i - 1];
  for(int i = 1 ; i <= n ; ++i) {
    for(int j = 1 ; j <= m ; ++j) cin >> B[j][i][0];
  }
  for(int k = 1 ; k <= m ; ++k) {
    for(int j = 1 ; (1 << j) <= n ; ++j) {
      for(int i = 1 ; i + (1 << j) - 1 <= n ; ++i) {
        B[k][i][j] = max(B[k][i][j - 1], B[k][i + (1 << (j - 1))][j - 1]);
      }
    }
  }
}
void solve() {
  DP(1, n, 1, n);
  ll ans = -inf;
  for(int i = 1 ; i <= n ; ++i) ans = max(ans, dp[i]);
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  init();
  solve();
}


Measured memory_bytes: 51328
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    int n;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	long p = 1;
	for(int i = 1; i <= n; i++) {
	    p *= i;
	    p %= 1000000007;
	}
	
	out(p);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
    }

    void out()
    {
	
    }
    
    void out(long n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(ll i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
    ll n,m;
    cin >> n >> m;
    map<ll, ll> mp;
    ll h[n+1];
    for(ll i=1;i<=n;i++) cin >> h[i];
    vector<ll> a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        if(h[a[i]] > h[b[i]]){
            mp[b[i]] = 1;
        }
        if(h[a[i]] < h[b[i]]){
            mp[a[i]] = 1;
        }
        if(h[a[i]] == h[b[i]]){
            if(mp[a[i]] != 1){
                mp[a[i]] = 1;
            }
            if(mp[b[i]] != 1){
                mp[b[i]] = 1;
            }
        }
    }
    cout << n - mp.size() << endl;
    return 0;
}

Measured memory_bytes: 9000
#f(r,c)=(r+c)_C_r
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
N=2*(10**6)+10
def inv(x):
    return pow(x,mod-2,mod)
Fact=[0 for i in range(N+1)]
Fact[0]=1;
for i in range(N):
    Fact[i+1]=(i+1)*Fact[i]
    Fact[i+1]%=mod
def C(n,k):
    res=Fact[n]*inv(Fact[n-k])
    res%=mod
    res*=inv(Fact[k])
    res%=mod
    return res
ans1=(((r2+2)*inv(c2+1))%mod)*C(c2+r2+2,r2+2)
ans2=(((r2+2)*inv(c1))%mod)*C(c1+r2+1,r2+2)
ans3=(((r1+1)*inv(c2+1))%mod)*C(c2+r1+1,r1+1)
ans4=(((r1+1)*inv(c1))%mod)*C(c1+r1,r1+1)
ans1%=mod
ans2%=mod
ans3%=mod
ans4%=mod
print((ans1-ans2-ans3+ans4)%mod)

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

using namespace std;

string s;
int n;
stack<int> st;

int main()
{
	cin >> n >> s;
	int i;
	int stt=0,enn=0;
	for(i=0;i<n;i++)
	{
		if(s[i]=='(')
		{
			st.push(i);
		}
		else
		{
			if(st.empty())
				stt++;
			else
				st.pop();
		}
	}
	cout << string(stt,'(')+s+string(st.size(),')') << endl;
}

Measured memory_bytes: 256
//abc103_c.cpp
//Sat Jul 21 20:50:52 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 100000000
using namespace std;
using ll=long long;
typedef pair<int,int> P;

long long gcd (long long a, long long b){ //最大公倍数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

long long lcm (long long a, long long b){ //最大公約数
	long long temp = gcd(a,b);
	return (a/temp)*b;
}

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

	ll a[n];
	ll rans = 0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		rans += a[i]-1;
	}

	cout << rans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);


		int n = sc.nextInt();

		int a[] = new int[n];

		for(int i = 0; i < n - 1; i++){
			a[sc.nextInt() - 1]++;
		}

		for(int i = 0; i < n; i++){
			System.out.println(a[i]);
		}
	}

}


Measured memory_bytes: 55656
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  vector<char> v;
  for(int i = 0; i < 4; i++){
    char c; cin >> c;
    v.push_back(c);
  }
  sort(v.begin(), v.end());
  if(v[0] == v[1] && v[0] != v[2] && v[2] == v[3]) cout << "Yes\n";
  else cout << "No\n";
  return;
}

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


Measured memory_bytes: 764
import java.util.Scanner;

public class Main{
	static final int  MAX = 200000;
	static final int SENTINEL = 2000000000;
	static int []L = new int[MAX / 2 + 2];
	static int []R = new int[MAX / 2 + 2];

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
		}
		scan.close();
		long ans = mergeSort(a, N, 0, N);
		System.out.println(ans);
	}

	static long merge(int []A, int n, int left, int mid, int right) {
		int i, j, k;
		long cnt = 0;
		int n1 = mid- left;
		int n2 = right - mid;
		for(i = 0; i < n1; i++) {
			L[i] = A[left + i];
		}
		for(i = 0; i < n2; i++) {
			R[i] = A[mid + i];
		}
		L[n1] = SENTINEL;
		R[n2] = SENTINEL;
		i = 0;
		j = 0;
		for(k = left; k < right; k++) {
			if(L[i] <= R[j]) {
				A[k] = L[i++];
			}else {
				A[k] = R[j++];
				cnt += n1 - i;	// mid + j - k - 1
			}
		}
		return cnt;
	}

	static long mergeSort(int []A, int n, int left, int right) {
		int mid;
		long v1, v2, v3;
		if(left + 1 < right) {
			mid = (left + right) / 2;
			v1 = mergeSort(A, n, left, mid);
			v2 = mergeSort(A, n, mid, right);
			v3 = merge(A, n, left, mid, right);
			return v1 + v2 + v3;
		}else {
			return 0;
		}
	}
}


Measured memory_bytes: 103936
#E
mod=10**9+7
def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a

N=int(input())
A=list(map(int,input().split()))
Ainv=[]
for i in range(N):
    Ainv.append(pow(A[i],mod-2,mod))
SSS=0
for u in Ainv:
    SSS=(SSS+u)%mod
    
data=[0]*(max(A)+1)
for i in range(N):
    h=prime_factorize(A[i])
    cnt=1
    for i in range(1,len(h)):
        if h[i]==h[i-1]:
            cnt+=1
        else:
            data[h[i-1]]=max(data[h[i-1]],cnt)
            cnt=1
    if h:
        data[h[-1]]=max(data[h[-1]],cnt)
ans=1
for i in range(1,len(data)):
    if data[i]==0:
        continue
    else:
        ans=ans*pow(i,data[i],mod)%mod
print(ans*SSS%mod)

Measured memory_bytes: 55900
N = int(input())

if N <= 111:
  print(111)
elif N <= 222:
  print(222)
elif N <= 333:
  print(333)
elif N <= 444:
  print(444)
elif N <= 555:
  print(555)
elif N <= 666:
  print(666)
elif N <= 777:
  print(777)
elif N <= 888:
  print(888)
elif N <= 999:
  print(999)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main()
{
	int h, n;

	cin >> h >> n;

	int ans=0;

	for (int i = 0; i < n; i++)
	{
		int input;
		cin >> input;
		ans += input;
	}

	if (ans >= h) cout << "Yes";
	else cout << "No";
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<unordered_set>
#include<vector>
#include<math.h>
#include<iomanip>

using namespace std;

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

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	for (int i = 0; i < n-2; i++) {
		if (s[i] == 'A') {
			if (s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
		}
	}
	
	cout << ans;
}

Measured memory_bytes: 256
using System;

namespace abc119A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string A = Console.ReadLine();
            int B = Int32.Parse(A.Substring(0, 4));
            int C = Int32.Parse(A.Substring(5, 2));
            int D = Int32.Parse(A.Substring(8, 2));
            if (B > 2019)
                Console.WriteLine("TBD");
            else if (C > 4)
                Console.WriteLine("TBD");
            else if (D > 30)
                Console.WriteLine("TBD");
            else
                Console.WriteLine("Heisei");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int H,W;
	cin>>H>>W;
	
	for(int i=0;i<H;i++){
		string S;
		cin>>S;
		
		cout<<S<<endl;
		cout<<S<<endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
bool got[10];
bool good(int x)
{
	while (x)
	{
		if (got[x%10])return false;
		x/=10;
	}
	return true;
}
int32_t main()
{
  BOOST;
  int n,k;
  cin>>n>>k;
  for (int i=1;i<=k;i++)
  {int a;cin>>a;got[a]=true;}
  for (int i=n;i<=99999;i++)
  {
  	if (good(i))
  	{
  		cout<<i;
  		return 0;
  	}
  }
  
  return 0;
}


Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N, M;
	List<int>[] es;
	void Solve()
	{
		var I = G();
		N = I[0];
		M = I[1];
		es = new List<int>[N];
		for (var i = 0; i < N; i++) es[i] = new List<int>();
		for (int i = 0; i < M; i++)
		{
			I = G();
			Add(I[0] - 1, I[1] - 1);
		}
		used = new bool[N];
		color = new bool[N];
		if (!DFS(0, true)) WriteLine(N * (N - 1L) / 2 - M);
		else
		{
			var x = 0;
			for (var i = 0; i < N; i++) if (color[i]) x++;
			WriteLine(x * (N - (long)x) - M);
		}
	}
	bool[] used, color;
	bool DFS(int u, bool c)
	{
		if (used[u]) return color[u] == c;
		used[u] = true;
		color[u] = c;
		foreach (var v in es[u]) if (!DFS(v, !c)) return false;
		return true;
	}
	void Add(int a, int b)
	{
		es[a].Add(b);
		es[b].Add(a);
	}
}


Measured memory_bytes: 28044
N = gets.to_i-1
X = (0..N).map{x,l = gets.split.map &:to_i; [x-l,x+l]}.sort
c = 0
i = -1
t = X[0][0]
while N >= i+=1
	l,r = X[i]
	next  if l < t
	t = r
	i.upto(N) {|j|
		l,r = X[j]
		break  if t <= l
		i,t = j,r  if r < t
	}
	c += 1
end
p c

Measured memory_bytes: 11128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X			= sc.nextInt();
		int N			= sc.nextInt();
		Integer nList[]	= new Integer[N];
		for(int i = 0; i < N; i++) {
			nList[i]	= sc.nextInt();
		}
		int ans			= X;
		Boolean flag	= true;
		for (int i = 0; i <= X && flag; i++) {
			if(!(Arrays.asList(nList).contains(X-i))) {
				ans = X-i;
				flag = false;
			}
			else if(!(Arrays.asList(nList).contains(X+i))) {
				ans =X+i;
				flag = false;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36068
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int div_ceil(int n, int d) { return (n + d - 1) / d; } 

int main() {
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, d) cin >> p.at(i) >> c.at(i);
    
    int ans = 10000;
    rep(bit, 1 << d) {
        int sum = 0;
        int cnt = 0;
        rep(i, d) if (bit >> i & 1) {
            sum += p.at(i) * (i + 1) * 100 + c.at(i);
            cnt += p.at(i);
        }
        
        revrep(i, d - 1) {
            if (g <= sum) break;
            if (bit >> i & 1) continue;
            
            int to_solve = min(p.at(i), div_ceil((g - sum), (i + 1) * 100));
            sum += to_solve * (i + 1) * 100;
            cnt += to_solve;
        }
        
        if (sum < g) continue;
        
        chmin(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	string S;
	cin >> S;
	string t = "hi";
	bool ok = true;
	for(int i = 0; i < S.size() - 1; i += 2){
		string u = S.substr(i, 2);
		ok &= (t == u);
	}
	if(S.size() % 2) ok = false;

	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>

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

using namespace std;

int main()
{
    int n;  cin >> n;
    int check = 0;

    for(int i = 1; i <= 9; i++){
        if(n % i == 0 && n / i < 10){
            check = 1;
            break;
        }
    }
    if(check == 1){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    cout << endl;
}

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;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b) / 2 << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
vector<LL>v;
int main(){
	REP(i,10){
	    LL a;
	    cin>>a;
	    v.push_back(a);
	}
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
	
	REP(i,3){
           cout<<v[i]<<endl;
        }
	return(0);
}

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

int main() {
 int n,k=0; cin>>n;
  int l[n],s[n-1],m[n-1]; for(int i=0;i<n-1;i++) m[i]=0;
  for(int i=0;i<n;i++) {
    cin>>l[i];
    k +=l[i];
  }
 ///// cout<<"k="<<k<<endl; 
  
  for(int i=0;i<n-1;i++){
    for(int j=0;j<i+1;j++){
      m[i]+=l[j];
    }
    ///cout<<m[i]<<endl;///
    s[i]=abs(2*m[i]-k);
   // cout<<s[i]<<endl;
  }
    sort(s,s+n-1);
  cout<<s[0]<<endl;
}
  
  

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

class G {
public:
  vector<vector<int>> p, inv, sp, sinv;
  int n, m;
  vector<int> b, c, depth;
  vector<bool> a;

  G(int nn, vector<vector<int>> &np, vector<vector<int>> &ninv) {
    n = nn;
    p = np;
    inv = ninv;
    a.resize(n);
    c.resize(n);
    for (int i = 0; i < n; i++) {
      c[i] = -1;
    }
  }

  void dfs(int i) {
    if (a[i])
      return;
    a[i] = true;
    for (int j = 0; j < p[i].size(); j++) {
      if (a[p[i][j]]) {
        continue;
      }
      dfs(p[i][j]);
    }
    b.push_back(i);
  }

  void dfs2(int i, int id) {
    if (c[i] > -1)
      return;
    c[i] = id;
    for (int j = 0; j < inv[i].size(); j++) {
      if (c[inv[i][j]] > -1)
        continue;
      dfs2(inv[i][j], id);
    }
  }

  void solve() {
    for (int i = 0; i < n; i++) {
      dfs(i);
    }
    int j = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (c[b[i]] > -1)
        continue;
      dfs2(b[i], j++);
    }
    m = j;
    return;
    sp.resize(m);
    sinv.resize(m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < p[i].size(); j++) {
        if (c[i] == c[p[i][j]])
          continue;
        sp[c[i]].push_back(c[p[i][j]]);
        sinv[c[p[i][j]]].push_back(c[i]);
      }
    }
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> p(n), inv(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a].push_back(b);
    inv[b].push_back(a);
  }
  G g(n, p, inv);
  g.solve();
  vector<vector<int>> c(g.m);
  for (int i = 0; i < n; i++) {
    c[g.c[i]].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    cout << c[g.c[i]][0];
    for (int j = 1; j < c[g.c[i]].size(); j++) cout << " " << c[g.c[i]][j];
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 4820
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right().to_string()
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    let s = read_line!().chars().collect::<Vec<_>>();

    let mut rn = 0u64;
    let mut gn = 0u64;
    let mut bn = 0u64;

    for &c in s.iter() {
        if c == 'R' {
            rn += 1;
        }

        if c == 'G' {
            gn += 1;
        }

        if c == 'B' {
            bn += 1;
        }
    }

    let mut cnt = 0;
    for i in 1..(n - 1) {
        let mut j = 1;
        loop {
            if s[i - j] != s[i] && s[i] != s[i + j] && s[i - j] != s[i + j] {
                cnt += 1;
            }

            if i - j == 0 || i + j == n - 1 {
                break;
            }

            j += 1;
        }
    }

    println!("{}", rn * gn * bn - cnt);
}

/*
fn main() {
    let n = parse_line!(usize);
    let s = read_line!().chars().collect::<Vec<_>>();

    let mut cnt = 0;
    for i in 0..(n - 2) {
        let si = s[i];
        for j in i..(n - 1) {
            let sj = s[j];
            if si == sj {
                continue;
            }
            for k in j..n {
                let sk = s[k];
                if si != sj && sj != sk && si != sk && (j - i != k - j) {
                    cnt += 1;
                }
            }
        }
    }
    println!("{}", cnt);
}
*/


Measured memory_bytes: 2144
#include<bits/stdc++.h>
int main()
{
    long long int a,b,c;
    scanf("%lld%lld",&a,&b);
    c=0;
    while(a>0)
    {
        a=a-b;
        c++;
    }
    printf("%lld\n",c);
    return 0;
}


Measured memory_bytes: 256