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

int main(){
	int n; cin>>n;
	vector<pair<int,int>> v(n);
	for(int i=0;i<n;++i){
	       cin>>v[i].first;
	       v[i].second=i;
	}
	sort(v.begin(), v.end());
	vector<int> ans(n);
	for(int i=0;i<n;++i){
		ans[v[i].second]=i<n/2?v[n/2].first:v[n/2-1].first;
	}
	for(auto i: ans) cout<<i<<'\n';
}


Measured memory_bytes: 4480
import sys
from collections import deque
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N = int(input())
B = [int(v) for v in input().split()]

A = [B[0]] + [v for v in B]

for i in range(N - 1):
    if B[i] < max(A[i], A[i + 1]):
        if A[i] > B[i]:
            A[i] = B[i]
        else:
            A[i + 1] = B[i]

print(sum(A))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N;
    string S = "";
    cin >> N;
    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (int64_t i = 0; N != 0; i++) {
        int64_t a = pow(2, i + 1);
        if (N % a == 0) {
            S += '0';
        }
        else {
            S += '1';
            N -= pow(-2, i);
        }
    }
    reverse(ALL(S));
    cout << S << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,M;
    vector<pair<int,int>> vec;
    pair<int,int> p;
    cin>>N>>M;
    rep(i,M){
        cin>>p.first>>p.second;
        vec.push_back(p);
    }
    sort(vec.begin(),vec.end());
    int ans=0,last=N;
    while(!vec.empty()){
        p=vec.back();
        vec.pop_back();
        if(p.second>last) continue;
        last=p.first;
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 5, MAX_C = 2e5 + 5;

int n, c[MAX_N];
vector<int> g[MAX_N];

int sz[MAX_N];

void dfs_pre(int v, int p = 0) {
	sz[v] = 1;
	for (int &u : g[v]) {
		if (u != p) {
			dfs_pre(u, v);
			sz[v] += sz[u];
		}
	}
}

map<int, int> c_sz[MAX_N];
ll ans[MAX_C];

void dfs(int v, int p = 0) {
	pair<int, int> mx = make_pair(0, 0);
	for (int &u : g[v]) {
		if (u != p) {
			dfs(u, v);
			mx = max(mx, make_pair((int) c_sz[u].size(), u));
		}
	}
	int curr_sz = sz[mx.second] - c_sz[mx.second][c[v]];
	ans[c[v]] -= 1ll * curr_sz * (curr_sz + 1) / 2;
	c_sz[v].swap(c_sz[mx.second]);
	for (int &u : g[v]) {
		if (u != p && u != mx.second) {
			int curr_sz = sz[u] - c_sz[u][c[v]];
			ans[c[v]] -= 1ll * curr_sz * (curr_sz + 1) / 2;
			for (auto &key : c_sz[u]) {
				c_sz[v][key.first] += key.second;
			}
			c_sz[u].clear();
		}
	}
	c_sz[v][c[v]] = sz[v];
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> c[i];
	}
	for (int i = 0; i < n - 1; ++i) {
		int v, u;
		cin >> v >> u;
		g[v].emplace_back(u);
		g[u].emplace_back(v);
	}
	for (int i = 1; i <= n; ++i) {
		ans[i] = 1ll * n * (n + 1) / 2;
	}
	dfs_pre(1);
	dfs(1);
	for (int i = 1; i <= n; ++i) {
		int curr_sz = sz[1] - c_sz[1][i];
		ans[i] -= 1ll * curr_sz * (curr_sz + 1) / 2;
	}
	for (int i = 1; i <= n; ++i) {
		cout << ans[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 67620
#include<iostream>
#include<math.h>
#include<algorithm>

using namespace std;


#define INF 1000000007
int n;
int a[100000];
int b[100000];
int c[100000];
int dp[100000][3];

int dfs(int k){
  if(k == n){
    return max(dp[k-1][0] + a[n-1], max(dp[k-1][1] + b[n-1], dp[k-1][2] + c[n-1]));
  }
  dp[k][0] = max(dp[k-1][1] + b[k-1], dp[k-1][2] + c[k-1]);
  dp[k][1] = max(dp[k-1][2] + c[k-1], dp[k-1][0] + a[k-1]);
  dp[k][2] = max(dp[k-1][0] + a[k-1], dp[k-1][1] + b[k-1]);
  return dfs(k+1);
}

int main(){
  cin >> n;
  for(int i = 0; i < n ; i++){
    cin >> a[i] >> b[i] >> c[i];
    dp[n][0] = -INF;
    dp[n][1] = -INF;
    dp[n][2] = -INF;
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;
  cout << dfs(1) << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>

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

int main(){
  int n;
  string s;
  cin >>n >> s;
  if(n%2==0 && s.substr(0, n/2)==s.substr(n/2, n/2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<queue>
#include<iostream>
using namespace std;
int D[110];
int N,n,u,k,v;
int main()
{
    queue<int>Q;
    cin>>N;
    int A[N][N];
    for(int p=0;p<N;p++)
        for(int q=0;q<N;q++)
            A[p][q]=0;
    for(int p=0;p<N;p++)
        D[p]=2147483647;
    for(n=0;n<N;n++)
    {
        cin>>u>>k;
        for(int i=0;i<k;i++)
        {
            cin>>v;
            A[u-1][v-1]=1;
        }
    }
    Q.push(1);
    D[0]=0;
    while(!Q.empty())
    {
        int cur=Q.front();
        Q.pop();
            for(int j=0;j<N;j++)
            {
                if(A[cur-1][j]==1&&D[j]==2147483647)
                {
                    Q.push(j+1);
                    D[j]=D[cur-1]+1;
                }
            }
    }
    for(int i=0;i<N;i++)
    {
        if(D[i]==2147483647)
            D[i]=-1;
    }
    for(int i=0;i<N;i++)
    {
        cout<<(i+1)<<' '<<D[i]<<endl;
    }
    return 0;
}


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

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

    set<ll> st;
    map<ll,ll> mp;
    for(ll i = 0; i < N; i++)
    {
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
        st.insert(tmp);
    }

    ll stIdx = 0;
    auto first = st.begin();
    ll count = 0;
    ll ans = 1;

    if(*first == 0)
    {
        for(auto e:mp)
        {
            if(e.first == 0)
            {
                if(e.second != 1)
                {
                    cout << 0 << endl;
                    return 0;
                }
            }
            else
            {
                if(e.second != 2)
                {
                    cout << 0 << endl;
                    return 0;
                }
            }
            

        }

        for(auto itr = st.begin(); itr != st.end(); itr++)
        {
            if(*itr != stIdx * 2)
            {
                cout << 0 << endl;
                return 0;
            }
            stIdx++;
            count++;
        }

        for(ll i = 1; i < count; i++)
        {
            ans *= 2;
            ans %= 1000000007;
        }
    }
    else
    {
        for(auto e:mp)
        {
            if(e.second != 2)
            {
                cout << 0 << endl;
                return 0;
            }
        }

        for(auto itr = st.begin(); itr != st.end(); itr++)
        {
            if(*itr != stIdx * 2 + 1)
            {
                cout << 0 << endl;
                return 0;
            }
            stIdx++;
            count++;
        }

        for(ll i = 1; i <= count; i++)
        {
            ans *= 2;
            ans %= 1000000007;
        }
    }
    
    cout << ans << endl;
    return 0;
    
    
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,u,k,v,e[N][N];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int i=0;i<k;i++)
      cin>>v,e[u-1][v-1]=1;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout<<' ';
      cout<<e[i][j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
def insertion_sort(a, n):
    for i in range(n):
        v = a[i]
        j = i-1
        while((j>=0)&(v<a[j])):
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print(" ".join([str(i) for i in a]))
    return
    
n = int(input())
a = [int(i) for i in input().split()]
insertion_sort(a, n)



Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int R, S, P;
	cin >> R >> S >> P;
	string T;
	cin >> T;

	string win;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (T.at(i) == 'r') {
			win += 'p';
			ans += P;
		}
		if (T.at(i) == 's') {
			win += 'r';
			ans += R;
		}
		if (T.at(i) == 'p') {
			win += 's';
			ans += S;
		}
	}
	// cout << win << " " << ans << endl;
	for (int i = N - 1; i >= K; i--) {
		if (win.at(i) == win.at(i - K)) {
			if (win.at(i) == 'r') {
				ans -= R;
				win.at(i - K) = 'g';
			}
			if (win.at(i) == 's') {
				ans -= S;
				win.at(i - K) = 'g';
			}
			if (win.at(i) == 'p') {
				ans -= P;
				win.at(i - K) = 'g';
			}
		}
	}

	cout << ans << endl;
}

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



int main() {

	int n, x;
	cin >> n >> x;

	vector<int> m(n);

	for (int i = 0; i < n; i++) {
		cin >> m[i];
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += m[i];
	}

	int a = x - sum;//nokori

	int count = n;

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

	
	while (a - m[0] >= 0) {
		count++;
		a -= m[0];
	}

	cout << count << endl;



	return 0;

}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int A, B, X;

    //入力
	scanf("%d %d", &A, &B);

    X = B * 100/10;
	for(int i=0; i<10; i++){
        if((int)(X*0.08) == A){
            //結果出力
            printf("%d", X);            
            return 0;
        }
        X++;
    }

    //解なし
    printf("-1");
    return 0;
}

Measured memory_bytes: 128
#include <string>
#include <iostream>

using namespace std;

int main() {
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;
	if (b - a <= k && c - a <= k && d - a <= k && e - a <= k && b - c <= k && b - d <= k && b - e <= k && c - d <= k && c - e <= k && d - e <= k) {
		cout << "Yay!" << endl;
	}
	else cout << ":(" << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    vector<int> x(5);
    for (int i = 0; i < 5; i++) {
        cin >> x.at(i);
        if (x.at(i) == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 2019

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}
void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}


int main() {
	int n;
	scanf("%d", &n);
	int a1 = 0, a2 = 0;
	int i1, i2;
	REP(i, n) {
		int a;
		scanf("%d", &a);
		if (a > a2) {
			a2 = a;
			i2 = i;
		}
		if (a2 > a1) {
			int ta = a1;
			a1 = a2;
			i1 = i2;
			a2 = ta;
		}
	}
	REP(i, n) {
		if (i == i1) {
			PRINTD(a2);
			continue;
		}
		PRINTD(a1);
	}
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n;
  cin >> n;
  vector<int> cnt(13,0);
  rep(i,n){
    int x;cin >> x;
    cnt[x]++;
  }
  vector<int> all,one;
  all.push_back(0);
  rep(i,13){
    if((i == 0 && cnt[i] > 0) || cnt[i] > 2){
      cout << 0 << endl;
      return 0;
    }else if(cnt[i] == 2){
      all.push_back(i);
      all.push_back(24-i);
    }else if(cnt[i] == 1){
      one.push_back(i);
    }
  }
  int k = one.size();
  int res = 0,gg = 1 << 30;
  rep(i,all.size())for(int j = i+1;j < all.size();j++){
    gg = min(gg,min(abs(all[i]-all[j]),24-abs(all[i]-all[j])));
  }
  for(int bit = 0;bit < (1 << k);bit++){
    vector<int> use;
    rep(i,k)if(bit >> i & 1){
      use.push_back(one[i]);
    }else{
      use.push_back(24-one[i]);
    }
    int sa = gg;
    rep(i,k){
      for(int j = i+1;j < k;j++){
        sa = min(sa,min(24-abs(use[i]-use[j]),abs(use[i]-use[j])));
      }
    }
    rep(i,k)rep(j,all.size()){
      sa = min(sa,min(abs(use[i]-all[j]),24-abs(use[i]-all[j])));
    }
    res = max(res,sa);
  }
  cout << res << endl;
  



  return 0;
}

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

P = [0] * N
for i in range(Q):
    tmp = int(input()) - 1
    P[tmp] += 1

sumP = sum(P)
for n in range(N):
    ans = 'No'
    total = sumP - P[n]
    if  K - total > 0:
        ans = 'Yes'
    print(ans)

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

using namespace std;
using ll = long long;

int main(){
    int n, ans = 0;
    string s;
    cin >> n >> s;
    rep(i, 1000){
        string ch;
        stringstream ss; ss << setw(3) << setfill('0') << i;
        ss >> ch;
        int ti = 0;
        rep(j, n){
            if(s[j] == ch[ti]){
                ti++;
                if(ti == 3){ 
                    break;
                }
            }
        }
        if(ti == 3){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 384
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;


/* see https://cp-algorithms.com/data_structures/sqrt_decomposition.html#toc-tgt-4
 * Queries are inclusive l and inclusive r.
 **/

//const int BLOCK_SIZE=(int)sqrt(5e5+5)+1;
const int BLOCK_SIZE=512;

bool cmp(pair<int, int> p, pair<int, int> q) {
    if (p.first / BLOCK_SIZE != q.first / BLOCK_SIZE)
        return p < q;
    return (p.first / BLOCK_SIZE & 1) ? (p.second < q.second) : (p.second > q.second);
}

struct Query {
    int l, r, idx;

    bool operator<(Query other) const {
        return cmp(make_pair(l, r), make_pair(other.l, other.r));
    }
};

const int N=5e5+5;
int gans=0;
vi f(N);
vi a(N);

inline void moremove(int idx) {
    int v=--f[a[idx]];
    assert(v>=0);
    if(v==0)
        gans--;
}

inline void moadd(int idx) {
    int v=++f[a[idx]];
    if(v==1)
        gans++;
}

inline int moget_answer() {
    return gans;
}

vector<int> mo(vector<Query>& queries) {
    vector<int> answers(queries.size());
    sort(queries.begin(), queries.end());
    int cur_l = 0;
    int cur_r = -1;

    /* invariant: data structure will always reflect the range [cur_l, cur_r] */
    for (Query &q : queries) {
        while (cur_l > q.l) {
            cur_l--;
            moadd(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            moadd(cur_r);
        }
        while (cur_l < q.l) {
            moremove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            moremove(cur_r);
            cur_r--;
        }
        answers[q.idx] = moget_answer();
    }
    return answers;
}

/* example impl of the three functions
 * for finding number of numbers in
 * interval where freq==number */


void solve() {
    cini(n);
    cini(q);
    for(int i=0; i<n; i++) 
        cin>>a[i];

    vector<Query> que(q);
    for(int i=0; i<q; i++) {
        cin>>que[i].l>>que[i].r;
        que[i].l--;
        que[i].r--;
        que[i].idx=i;
    }

    vi ans=mo(que);

    for(int i=0; i<q; i++) {
        cout<<ans[i]<<"\n";
    }
}

signed main() {
    solve();
}



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

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> d(n);
  rep(i, n) cin >> d.at(i).first >> d.at(i).second;
  
  int cnt = 0;
  rep(i, n-2){
  	if(d.at(i).first == d.at(i).second && d.at(i+1).first == d.at(i+1).second && d.at(i+2).first == d.at(i+2).second){
      cnt = 1;
      break;
    }
  }
  
  if(cnt) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int dp[100010] = {};

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1] + 1;
		int temp = 6;
		while (temp <= i) {
			dp[i] = min(dp[i], dp[i - temp] + 1);
			temp *= 6;
		}
		temp = 9;
		while (temp <= i) {
			dp[i] = min(dp[i], dp[i - temp] + 1);
			temp *= 9;
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
nu = gets.to_i
array = gets.chomp.split(" ").map(&:to_i)
store = Array.new(10**5 + 1, 0)
count = 0
for i in 0..nu - 1
  if array[i] <= 10**5
    store[array[i]] += 1
  else
    count += 1
  end
end
for i in 1..10**5
  if (store[i] - i) >= 0
    count += (store[i] - i)
  else
    count += store[i]
  end
end

puts count


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

int main(){
    int n;
    while(cin >> n, n){
        int a[n];
        double ave = 0;
        for(int i = 0; i < n; i++)  cin >> a[i], ave += a[i];
        ave /= n;
        sort(a, a+n);
        cout << upper_bound(a,a+n,ave) - a << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

vector<vector<char>> data(25, vector<char>(25,'#'));
int h,w,ans=0;

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


int bfs(int sy, int sx){
  vector<vector<int>> done(25, vector<int>(25,inf));
  queue<P> que;

  que.push(P(sy,sx));
  done[sy][sx] = 0;								//start set
  
  while(que.size()){
    P p = que.front(); que.pop();
//    if (p.first == gy && p.second == gx) { break; }					  	// goal?   
    for(int i=0; i<4; i++){
      int new_y=p.first+dy[i], new_x=p.second+dx[i];
      if (new_y < 0 || h < new_y || new_x < 0 || w < new_x) { continue; }	// out of area??
      if (data[new_y][new_x] == '#') { continue; }					// wall?
      if (done[new_y][new_x]!=inf){continue;}		//seen?
      que.push(P(new_y,new_x));  
      done[new_y][new_x] = done[p.first][p.second]+1;
  	}
  }
  
  int maxcnt=0;
  for(int i=1; i<=h; i++){ 
    for(int j=1; j<=w; j++){ 
      if(data[i][j]!='#'){
        maxcnt=max(maxcnt,done[i][j]); 
      }  
    } 
  }
  return maxcnt;
}

int main() {
  cin >> h >> w;
  for(int i=1; i<=h; i++){ for(int j=1; j<=w; j++){ cin >> data[i][j]; } }
  
  int ans=0;
  for(int i=1; i<=h; i++){ 
    for(int j=1; j<=w; j++){ 
      if(data[i][j]!='#'){ 
        ans = max(ans,bfs(i,j)); 
      }
  } }
  
  cout << ans << endl; 
  return 0;
}  


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) = abc157e()

fun abc157e() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val q = readLine()!!.toInt()
    val queries = (1..q).map {
        readLine()!!.split(' ').map { it }
            .let { Query(if (it[0].toInt() == 1) QueryType.UPDATE else QueryType.GET, it[1].toInt(), it[2]) }
    }

    val arr = LongArray(n)
    s.forEachIndexed { index, c -> arr[index] = charToBit(c) }

    val st = SegmentTree(arr, Long::or)
    val answer = StringBuilder()

    for ((type, x, y) in queries) {
        when (type) {
            QueryType.UPDATE -> st[x - 1] = charToBit(y[0])
            else -> answer.appendln(st[x - 1..y.toInt() - 1])
        }
    }

    print(answer)
}

private fun charToBit(char: Char) = 1L shl (char - 'a')

private data class Query(val type: QueryType, val x: Int, val y: String)
private enum class QueryType { UPDATE, GET }

private class SegmentTree(init: LongArray, val monad: (Long, Long) -> Long) {
    val indices: Int
    val nodes: LongArray

    init {
        var indices = 1
        while (indices < init.size) indices = indices shl 1
        val nodes = LongArray(2 * indices - 1)
        for (i in init.indices) nodes[i + indices - 1] = init[i]
        for (i in indices - 2 downTo 0) nodes[i] = monad(nodes[2 * i + 1], nodes[2 * i + 2])
        this.indices = indices
        this.nodes = nodes
    }

    operator fun set(x: Int, value: Long) {
        var index = x + indices - 1
        nodes[index] = value
        while (index > 0) {
            index = (index - 1) / 2
            nodes[index] = monad(nodes[2 * index + 1], nodes[2 * index + 2])
        }
    }

    operator fun get(range: IntRange): Int =
        BitSet.valueOf(longArrayOf(get(range.first, range.last + 1))).cardinality()

    fun get(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = indices): Long {
        if (r <= a || b <= l) return 0
        if (a <= l && r <= b) return nodes[k]
        return monad(
            get(a, b, 2 * k + 1, l, (l + r) / 2),
            get(a, b, 2 * k + 2, (l + r) / 2, r)
        )
    }
}


Measured memory_bytes: 93324
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//sort(l,l+N,greater<int>());	降順ソート
//sort(l,l+N);	昇順ソート
//string 変数　　変数.size()で数字化


int main(void)
{
	int a, b, n;
	cin >> n >> a >> b;
	int ans;
	a *= n;
	ans = min(a, b);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,x;
  cin>>n>>x;
  n--;
  int a[n];
  double r[n],p[n],s[n];
  for(int i=0;i<n;i++) cin>>a[i]>>r[i]>>p[i]>>s[i];
  for(int i=0;i<n;i++){
    r[i]/=100;p[i]/=100;s[i]/=100;
  }
  double dp[1<<n];
  for(int i=0;i<(1<<n);i++)
    dp[i]=-1;
  function<double(int)> dfs=[&](int b){
    if(__builtin_popcount(b)==n) return 1.0;
    if(dp[b]>=0) return dp[b];
    vector<int> v;
    int y=-1;
    for(int i=0;i<n;i++){
      if(!((b>>i)&1)){
	v.push_back(i);
	y=max(y,a[i]);
      }
    }
   
    int m=v.size();
    double dp2[m+1][1<<3][1<<3];
    for(int i=0;i<=m;i++)
      for(int j=0;j<(1<<3);j++)
	for(int k=0;k<(1<<3);k++)
	  dp2[i][j][k]=0;
    dp2[0][0][0]=1;
    for(int i=0;i<m;i++){
      for(int j=0;j<(1<<3);j++){
	for(int k=0;k<(1<<3);k++){
	  dp2[i+1][j|1][k|((a[v[i]]>x)<<0)]+=dp2[i][j][k]*r[v[i]];
	  dp2[i+1][j|2][k|((a[v[i]]>x)<<1)]+=dp2[i][j][k]*p[v[i]];
	  dp2[i+1][j|4][k|((a[v[i]]>x)<<2)]+=dp2[i][j][k]*s[v[i]];
	}
      }
    }
    
    //cout<<m<<endl;

    double dp3[1<<3];
    for(int j=0;j<(1<<3);j++){
      dp3[j]=0;
      for(int k=0;k<(1<<3);k++)
	dp3[j]+=dp2[m][j][k];
    }
    
    /*/
      cout<<b<<":"<<endl;
      for(int j=0;j<(1<<3);j++)
      cout<<bitset<3>(j)<<":"<<dp3[j]<<endl;
    //*/
    
    //res=max(res,dp3[4]+(dp3[1]+dp3[6]));
    //res=max(res,dp3[1]+(dp3[2]+dp3[5]));
    //res=max(res,dp3[2]+(dp3[4]+dp3[3]));

    double aa=dp3[4]+dp2[m][1][0]+dp3[6]*(y<x);
    double bb=dp3[1]+dp2[m][2][0]+dp3[5]*(y<x);
    double cc=dp3[2]+dp2[m][4][0]+dp3[3]*(y<x);
    
    
    for(int i=1;i<(1<<m)-1;i++){
      int k=b;
      for(int j=0;j<m;j++)
	if((i>>j)&1) k|=1<<v[j];
      //cout<<bitset<3>(b)<<":"<<bitset<3>(i)<<endl;
      //for(int j=0;j<m;j++) cout<<v[j]<<endl;
      //cout<<b<<":"<<k<<endl;
      assert(k!=b);
      {
	double d=1.0;
	for(int j=0;j<m;j++){
	  if((i>>j)&1) d*=s[v[j]];
	  else d*=r[v[j]];
	}
	//res=max(res,d*dfs(k)+aa);
	aa+=d*dfs(k);
      }
      {
	double d=1.0;
	for(int j=0;j<m;j++){
	  if((i>>j)&1) d*=r[v[j]];
	  else d*=p[v[j]];
	}
	//res=max(res,d*dfs(k)+bb);
	bb+=d*dfs(k);
      }
      {
	double d=1.0;
	for(int j=0;j<m;j++){
	  if((i>>j)&1) d*=p[v[j]];
	  else d*=s[v[j]];
	}
	//res=max(res,d*dfs(k)+cc);
	cc+=d*dfs(k);
      }
    }
    //cout<<aa<<":"<<dp3[5]<<endl;
    //cout<<bb<<":"<<dp3[3]<<endl;
    //cout<<cc<<":"<<dp3[6]<<endl;
    
    double res=max({aa,bb,cc});
    if(y<x) res+=dp3[7];
    //cout<<b<<":"<<res<<endl;
    return dp[b]=res;
  };
  printf("%.12f\n",dfs(0));
  return 0;
}



Measured memory_bytes: 3380
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int room[4][3][10];
        for(int i=0;i<4;i++){
                for(int j=0;j<3;j++){
                        for(int k=0;k<10;k++){
                                room[i][j][k]=0;
                        }
                }
        }
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
                int b,f,r,v;
                cin>>b>>f>>r>>v;
                room[b-1][f-1][r-1]+=v;
        }
        for(int i=0;i<4;i++){
                for(int j=0;j<3;j++){
                        for(int k=0;k<10;k++){
                                printf(" %d",room[i][j][k]);
                        }
                        printf("\n");
                }
                if(i<3)printf("####################\n");
        }
        return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
    ll x;
    cin >> x;
    ll q = x/(ll)(11);
    ll s = x%(ll)(11);
    ll ans;
    if(s <= 6 && s!=0){
        ans = 2*q+1;
    }
    else if(s>6){
        ans = 2*q+2;
    }
    else{
        ans = 2*q;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	
	public double sign(Point a, Point b, Point c){
	//	writer.println((a.x-c.x)*(b.y-c.y) - (a.y-c.y)*(b.x-c.x));
		return Math.signum((a.x-c.x)*(b.y-c.y) - (a.y-c.y)*(b.x-c.x));
	}
	public String judge(Triangle tr, Point p, Point q){
		double x = Math.abs(sign(tr.a, tr.b, p) + sign(tr.b, tr.c, p) + sign(tr.c, tr.a, p));
		double y = Math.abs(sign(tr.a, tr.b, q) + sign(tr.b, tr.c, q) + sign(tr.c, tr.a, q));
		return (x != y) ? "OK" : "NG";
	}		
	public  void solve() throws IOException{
		int n = nextInt();
		for(int i = 0; i < n; i++){
			int p = nextInt(), q = nextInt(), r = nextInt(), s = nextInt(), t = nextInt(), u = nextInt();
			Triangle tr = new Triangle(p, q, r, s, t, u);
			int a = nextInt(), b = nextInt();
			Point alt = new Point(a, b);
			int c = nextInt(), d = nextInt();
			Point vega = new Point(c, d);
			writer.println(judge(tr, alt, vega));
		}
		writer.flush();			
	}
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}		
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

class Point {
	int x;
	int y;
	public Point(int x, int y){
		this.x = x;
		this.y = y;
	}
}
class Triangle {
	Point a;
	Point b;
	Point c;
	public Triangle(int p, int q, int r, int s, int t, int u){
		a = new Point(p, q);
		b = new Point(r, s);
		c = new Point(t, u);
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,k;
	cin>>a>>b>>k;
	for(int i=100;;i--){
		if(a%i==0&&b%i==0){
			k-=1;
			if(k==0){
				cout<<i<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>

template<typename T>
struct SegmentTree {
	using value_type = T;
	using const_reference = const value_type &;
	using F = std::function<value_type(const_reference, const_reference)>;
	using size_type = std::size_t;
	
private:
	size_type n, n_;
	value_type id_elem;
	F f;
	std::vector<value_type> node;
	
public:
	SegmentTree(size_type n, const_reference id_elem, const F & f) : n(n), id_elem(id_elem), f(f) {
		n_ = 1;
		while (n_ < n) n_ <<= 1;
		node.resize(2 * n_, id_elem);
	}
	
	SegmentTree(std::vector<value_type> v, const_reference id_elem, const F & f) :
			SegmentTree(v.size(), id_elem, f) {
		for (size_type i = 0; i < v.size(); ++i) node[i + n_] = v[i];
		for (size_type i = n_ - 1; i > 0; --i) node[i] = f(node[i << 1], node[i << 1 | 1]);
	}
	
	size_type size() const noexcept {
		return n;
	}
	
	void set(size_type i, const_reference x) {
		assert(i < size());
		node[i += n_] = x;
		while (i > 1) {
			i >>= 1;
			node[i] = f(node[i << 1], node[i << 1 | 1]);
		}
	}
	
	const_reference get(size_type i) const {
		assert(i < size());
		return node[i + n_];
	}
	
	value_type fold(size_type l, size_type r) const {
		assert(l <= r);
		assert(r <= size());
		value_type lv = id_elem, rv = id_elem;
		for (l += n_, r += n_; l < r; l >>= 1, r >>= 1) {
			if (l & 1) lv = f(lv, node[l++]);
			if (r & 1) rv = f(node[r - 1], rv);
		}
		return f(lv, rv);
	}
	
	const_reference fold_all() const {
		return node[1];
	}
	
	size_type max_right(size_type l, std::function<bool(const_reference)> g) const {
		assert(l < size());
		if (g(node[1])) return size();
		l += n_;
		
		value_type sum = id_elem;
		while (true) {
			while (~l & 1) l >>= 1;
			const value_type nex_sum = f(sum, node[l]);
			if (g(nex_sum)) { sum = nex_sum; ++l; }
			else break;
			if ((l & -l) == l) return size();
		}
		
		while (l < n_) {
			const value_type nex_sum = f(sum, node[l << 1]);
			l <<= 1;
			if (g(nex_sum)) { sum = nex_sum; l |= 1; }
		}
		
		return l - n_;
	}
};

#include <cstdio>
#include <vector>

int INF = 1'000'000'001;

int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	
	
	std::vector<int> A(N);
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	
	SegmentTree<int> seg(A, -INF, [](int a, int b) { return a < b ? b : a; });
	
	while (Q--) {
		int t, a, b;
		scanf("%d %d %d", &t, &a, &b); --a;
		if (t == 1) seg.set(a, b);
		else if (t == 2) printf("%d\n", seg.fold(a, b));
		else printf("%d\n", seg.max_right(a, [b](int x) { return x < b; }) + 1);
	}
	return 0;
}


Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<ll> r(n);

    rep(i,n) cin>>r[i];

    vector<ll> r1,r2;
    bool large=true;
    for(int i=0; i<n-1; ++i){
		if(large && r[i]<r[i+1]){
			large=false;
			r1.push_back(r[i]);
		}
		else if(!large && r[i]>r[i+1]){
			large=true;
			r1.push_back(r[i]);
		}		
	} 
	//printf("large ? %d\n", large);
	if(r1.size()!=0){
		if(!large && r1[r1.size()-1]<r[n-1]) r1.push_back(r[n-1]);
		else if(large && r1[r1.size()-1]>r[n-1]) r1.push_back(r[n-1]);
	}

    //rep(i,r1.size()) cout<<r1[i]<<" ";
    //cout<<endl;

    ll ans=1000;
    ll kab=0;
    ll yen=1000;
    int x=0;
    if(r1.size()>0 && r1.size()%2==1) x=1;
    rep(i,r1.size()-x){
        if(i%2==0){
            kab=yen/r1[i];
            yen=yen-kab*r1[i];
        }
        else{
            yen+=kab*r1[i];
        }
    }

    ans=max(ans,yen);
	
	//x1 > x2 < x3 > x4 < ...の形
	large=false;
	for(int i=0; i<n-1; ++i){
		if(large && r[i]<r[i+1]){
			large=false;
			r2.push_back(r[i]);
		}
		else if(!large && r[i]>r[i+1]){
			large=true;
			r2.push_back(r[i]);
		}
	} 
	if(r2.size()!=0){
		if(!large && r2[r2.size()-1]<r[n-1]) r2.push_back(r[n-1]);
		else if(large && r2[r2.size()-1]>r[n-1]) r2.push_back(r[n-1]);
	}

    kab=0;
    yen=1000;

    x=0;
    if(r2.size()>0 && r2.size()%2==0) x=1;
    
    for(int i=1;i<r2.size()-x;i++){
        if(i%2==1){
            kab=yen/r2[i];
            yen=yen-kab*r2[i];
        }
        else{
            yen+=kab*r2[i];
        }
    }

    ans=max(ans,yen);

    cout<<ans<<endl;
}



Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
using namespace std;
 
int main() {
  int A,B;
  cin>>A;
  cin>>B;
/*   int A_min;
  A_min = ceil(A*12.5);
  for(A_min;A_min/10<(B+1);A_min++){
      if(A<(A_min/12.5)){
          cout<<"-1";
          exit(0);
      }
      if((A_min/10)==B){
          cout<<A_min;
          exit(0);
      }
  }
    cout<<"-1"; */

for(int i=0;true;i++){
    if(floor(i*0.08)==A && floor(i*0.1)==B){
        cout<<i;
        exit(0);
    }
    if(A<floor(i*0.08) || B<floor(i*0.1)==B){
        cout<<"-1";
        exit(0);
    }
}
  return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	vector<int>v(M);
	loop(N) {
		int k; cin >> k;
		rep(i, 0, k) {
			int a; cin >> a;
			a--;
			v[a]++;
		}
	}
	int ans = 0;
	rep(i, 0, M)ans += v[i] == N;
	cout << ans << endl;
	return 0;
}


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


using namespace std;
int main(){
    int n,x, ans = 0;
    cin >> n >> x;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = 0 ; i < n; i++){
        if(x - a[i] >= 0){
            x -= a[i];
            ans++;
        }
    }
    if(x && ans > 0 && ans == n)ans--;
    cout << ans;
}   


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

int main(){
	int n;
	int T, H, L;
	int t[114514];
	int h[114514];
	int f = -1;
	cin >>n>>T>>H>>L;
	for (int i = 0; i < n; i++){
		cin >> t[i] >> h[i];
	}
	int zan = 0;
	while (f==-1){
		for (int k = 0; k < n; k++){
			if (t[k] > 0){	//10???????????£???????????´???
				t[k]--;
				zan += 10;	//?????????????????\
				T++;		//?????????10???????????¬???????¢????
				if (T > L){ f = k; break; }//?????????????£??????????????????¢??±
				if (zan >= 90){
					zan = 0;
				}
			}
			else{		//100???
				if (h[k] <= 0){ f = k; break; }	//?????????????????¨????????¢??±
				h[k]--;
				zan += 100;
				H++;
				if (zan >= 90){	//?????????90????????????
					if (T > (zan - 90)/10){
						T -= (zan - 90) / 10;
						t[k] += (zan - 90) / 10;
						zan = 0;
					}
					else { f = k; break; }//????????????????????????
				}
			}
		}
	}
	cout <<f+1<<endl;
	return 0;
}

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

constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int MAX = 510000;

vector<long> fact(MAX), finv(MAX), inve(MAX);

void init() {
  fact.at(0) = fact.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inve.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fact.at(i) = fact.at(i - 1) * i % MOD;
    inve.at(i) = MOD - inve.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inve.at(i) % MOD;
  }
}

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact.at(n) * (finv.at(r) * finv.at(n - r) % MOD) % MOD;
}

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

long com2(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * mpow(y, MOD - 2) % MOD;
}

long inv(long a) {
  long b = MOD, u = 1, v = 0;
  while (b) {
    long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= MOD; 
  if (u < 0) u += MOD;
  return u;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  long ans = mpow(2, N);
  ans -= com2(N, 0);
  ans -= com2(N, A);
  ans -= com2(N, B);
  while (ans < 0) ans += MOD;
  cout << ans << "\n";
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>

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

using namespace std;
typedef long long ll;

string parse(string a) {
    if(a == "0") return a;

    bool flag = true;
    stringstream ss;
    rep(i,a.size()) {
        if(flag && a[i] == '0') continue;
        else {
            flag = false;
            ss << a[i];
        }
    }

    return ss.str();
}

string smax(string a,string b) {
    a = parse(a);
    b = parse(b);
    if(a.size() > b.size()) return a;
    if(b.size() > a.size()) return b;
    return max(a,b);
}

int main() {

    int h,w;
    while(cin >> w >> h) {
        if(w == 0 && h == 0) break;

        vector<string> v(h);
        vector<vector<string> > memo(h);

        rep(i,h) {
            cin >> v[i];
            memo[i].resize(w);
        }

        rep(i,h) {
            rep(j,w) {
                if('0' <= v[i][j] && v[i][j] <= '9') {
                    stringstream ss;
                    ss << v[i][j];

                    memo[i][j] = ss.str();
                }
            }
        }

        REP(i,0,h) {
            REP(j,0,w) {
                if('0' <= v[i][j] && v[i][j] <= '9') {
                    stringstream ss,ss2;

                    if(0 <= i-1) {
                        ss << memo[i-1][j];
                    }
                    if(0 <= j-1) {
                        ss2 << memo[i][j-1];
                    }

                    ss << memo[i][j];
                    ss2 << memo[i][j];

                    string res = ss.str();
                    string res2 = ss2.str();

                    memo[i][j] = smax(res,res2);
                }
            }
        }

        string ans = "";
        rep(i,h) {
            rep(j,w) {
                ans = smax(ans,memo[i][j]);
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1368
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
const double eps = 1.0e-13;
const double pi = 3.14159265358979;
int A,B,H,M;
int main(){
	cin >> A >> B >> H >> M;
	double theta;
	double Hrad = pi*( (60.0*H+M) /360.0 ) ;
	double Mrad = pi*(M/30.0);;
	if(Hrad>Mrad)theta = Hrad - Mrad; 
	else theta = Mrad-Hrad;
	//cout << theta << endl;
	//cout << cos(theta) << endl;
	printf("%.13f",sqrt(A*A+B*B-2.0*A*B*cos(theta)));

	return 0;
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

template<typename T>
struct CumulativeSum{
    int n;
    vector<T> dat;
    CumulativeSum(vector<T> v){
        n=v.size();
        dat.assign(n+1,0);
        rep(i,n) dat[i+1]=v[i];
        rep(i,n) dat[i+1]+=dat[i];
    };
    T query(int k){ //[0,k]
        if (k<0) return 0;
        return dat[min(k+1,(int)dat.size()-1)];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,T; cin >> N >> T;
    vector<int> t(T+1);
    rep(i,N){
        int l,r; cin >> l >> r;
        ++t[l],--t[r];
    }
    CumulativeSum<int> CS(t);
    int ans=0;
    rep(i,T+1) chmax(ans,CS.query(i));
    cout << ans << endl;
}


Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}





void solve(){
	ll n,k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];

	}
	ll ans=0;
	sort(v.begin(),v.end());
	for(ll i=0;i<k;i++){
		ans+=v[i];

	}
	cout<<ans<<endl;






return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
  //  cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

void solve(){
	string s;
	cin>>s;
	int mx=-1e8;
	int cnt=0;
	rep(i,sz(s)){
		if(s[i]=='A' || s[i]=='G' || s[i]=='C' || s[i]=='T'){
			cnt++;
			mx=max(mx,cnt);
		}
		else cnt=0;
	}
	cout<<(mx==-1e8?0:mx)<<endl;
}


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
	int n, m;
	cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,x) for(int i = 0; i < x; i++)
typedef long long ll;
const ll N = 1e9 + 7;
using namespace std;

ll dp[100005][2] = {0};
int main(){
    string l;cin >> l;
    int L = l.size();
    dp[0][0] = 1;
    int small = 1;//small = 1 なら未満確定
    rep(i,L){
        rep(small,2){
            if(l[i] == '0') {
                if(small == 1){
                    dp[i+1][small] += dp[i][small]*3 % N;
                }
                else{
                    dp[i+1][small] += dp[i][small] % N;                
                    }
            }
            else{
                if(small == 1){
                    dp[i+1][small] += dp[i][small]*3 % N;
                    dp[i+1][small] += dp[i][0] % N;
                }
                else{
                    dp[i+1][small] += dp[i][small]*2 % N;
                }
            }
        }
    }
    int ans = (dp[L][1] + dp[L][0]) % N;
    cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int d[n];
    for(int i=0;i<n;i++)
        cin >> d[i];
    sort(d,d+n,greater<>());
    int count=1;
    for(int i=0;i<n-1;i++){
        if(d[i] > d[i+1])
            count ++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256