akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
using namespace std;

int getnum()
{
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1; ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0'; ch = getchar();
	}
	return x * f;
}

const int N = 500010, M = 500010, INF = 1000000010;
int n, k;
int cnt;
int head[N];
struct edge
{
	int v, nxt;
}vec[M << 1];
int ind[N];
int A[N];
int P[N];
int minn[N << 2];
priority_queue<int, vector<int>, greater<int> >Q;
int tot;
int ans[N];

void addedge(int u, int v)
{
	vec[++cnt] = (edge){v, head[u]}; head[u] = cnt; ++ind[v];
}

void get_read()
{
	n = getnum(); k = getnum();
	for (int i = 1; i <= n; ++i) A[P[i] = getnum()] = i;
}

void TOPSORT()
{
	for (int i = 1; i <= n; ++i) if (!ind[i]) Q.push(i);
	while (!Q.empty()) {
		int u = Q.top(); Q.pop();
		ans[u] = ++tot;
		for (int i = head[u]; i; i = vec[i].nxt) {
			int v = vec[i].v;
			--ind[v];
			if (!ind[v]) Q.push(v);
		}
	}
}

#define lson (o << 1)
#define rson (o << 1 | 1)

int query(int o, int l, int r, int L, int R)
{
	if (L > R) return INF;
	if (L <= l && r <= R) return minn[o];
	int mid = (l + r) >> 1, ret = INF;
	if (L <= mid) ret = min(ret, query(lson, l, mid, L, R));
	if (R > mid) ret = min(ret, query(rson, mid + 1, r, L, R));
	return ret;
}

void modify(int o, int l, int r, int p, int w)
{
	if (l == r) {
		minn[o] = w; return;
	}
	int mid = (l + r) >> 1;
	if (p <= mid) modify(lson, l, mid, p, w);
	else modify(rson, mid + 1, r, p, w);
	minn[o] = min(minn[lson], minn[rson]);
}

void get_work()
{
	memset(minn, 63, sizeof(minn));
	for (int i = n; i >= 1; --i) {
		int t;
		t = query(1, 1, n, A[i] + 1, min(n, A[i] + k - 1));
		if (t < INF) addedge(A[i], A[t]);
		t = query(1, 1, n, max(1, A[i] - k + 1), A[i] - 1);
		if (t < INF) addedge(A[i], A[t]);
		modify(1, 1, n, A[i], i);
	}
	TOPSORT();
	for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
}

int main()
{
	get_read();
	
	get_work();
	
	return 0;
}

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

using namespace std;

int main(){
	int N, W;
	cin >> N >> W;
	
	long long * dp;
	dp = new long long [W + 1];
	memset(dp, 0, sizeof dp);
	long w, v;
	//para debuggear
	/*
	for(int i = 0; i <= W; i++) cout << i << "\t";
	cout << endl << endl;
	for(int i = 0; i < W + 1; i++) cout << dp[i] << "\t"; cout << endl;
	*/

	while(N--){
		cin >> w >> v;
		for(int weight = W - w; weight >= 0; weight--){
			dp[weight + w] = max(dp[weight + w], dp[weight] + v);
		}	
		//para debuggear
		//for(int i = 0; i < W + 1; i++) cout << dp[i] << "\t"; cout << endl;
	}
	long long ans = 0;
	for(int i = 0; i < W + 1; i++){
		ans = max(dp[i], ans);
	}
	cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	const Int MOD = 998244353;
	Int N;
	cin >> N;
	string s;
	cin >> s;

	vector<int> rx, gx, bx;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'R') { rx.push_back(i); }
		if (s[i] == 'G') { gx.push_back(i); }
		if (s[i] == 'B') { bx.push_back(i); }
	}

	vector<int> a(N), b(N), c(N);
	for (int i = 0; i < N; ++i) {
		a[i] = min({ rx[i], gx[i], bx[i] });
		c[i] = max({ rx[i], gx[i], bx[i] });
		b[i] = rx[i] + gx[i] + bx[i] - a[i] - c[i];
	}

	Int ans = 1;
	for (Int i = 0; i < N; ++i) {
		Int x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		Int y = lower_bound(b.begin(), b.end(), c[i]) - b.begin();
		(ans *= (x - i) * (y - i) % MOD) %= MOD;
	}
	while (N > 0) {
		(ans *= N--) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int apoint[3],bpoint[3];
string data[3];
int main(void)
{
  while(cin >> data[0] && data[0]!="0")
    {
      memset(apoint,0,sizeof(apoint));
      memset(bpoint,0,sizeof(bpoint));
      data[0]+='C';
      cin >> data[1];
      data[1]+='C';
      cin >> data[2];
      data[2]+='C';
      for(int i=0;i<3;i++)
	{
	  for(int j=0;j<int(data[i].size()-1);j++)
	    {
	      if(data[i][j+1]!='C')
		{
		  if(data[i][j+1]=='A')
		    {
		      apoint[i]++;
		    }
		  else bpoint[i]++;
		}
	      else
		{
		  if(i!=2)
		    {
		      if(data[i+1][0]=='A') apoint[i]++;
		      else bpoint[i]++;
		    }
		  else
		    {
		      if((apoint[i]+1-bpoint[i])>=2) apoint[i]++;
		      else bpoint[i]++;
		    }
		}
	    }
	}
      for(int i=0;i<3;i++)
	{
	  cout << apoint[i] << ' ' << bpoint[i] << endl;
	}
    }
  return 0;
}



Measured memory_bytes: 3156
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <utility>

using namespace std;

int main() {
  string str;

  cin >> str;

  if (str[0] == '?') {
    str[0] = 'D';
  }

  char prev = str[0];
  for (int i = 1; i < str.length(); i++) {
    if (str[i] == '?') {
      // 前の文字がPならPDを作れるのでDを入れる
      // そうでないならPを入れる
      if (prev == 'P') {
        str[i] = 'D';
      } else if (i + 1 < str.length() && str[i + 1] == 'D') {
        str[i] = 'P';
      } else {
        str[i] = 'D';
      }
    }

    prev = str[i];
  }

  cout << str << endl;

  return 0;
}

Measured memory_bytes: 3372
// https://atcoder.jp/contests/abc169/tasks/abc169_c
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;

int main() {
  dd A, B;
  cin >> A >> B;
  dd ans = A * B;
  cout << ll(ans) << endl;
}

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

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> hi(n);
    for(int i = 0; i < n; i++){
        cin >> hi.at(i);
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum = sum + hi.at(i);
    }
    if(sum < h){
        cout << "No";
    } else {
        cout << "Yes";
    }
}


Measured memory_bytes: 640
from collections import deque

q = int(input())
querys = [list(map(int, input().split())) for _ in range(q)]

d = deque()

for query in querys:
    if query[0] == 0:
        if query[1] == 0:
            d.appendleft(query[2])
        else:
            d.append(query[2])

    if query[0] == 1:
        print(d[query[1]])

    if query[0] == 2:
        if query[1] == 0:
            d.popleft()
        else:
            d.pop()



Measured memory_bytes: 69480
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    int a, b;
    cin >> a >> b;
    if(!(b%a)){print(a+b);}
    else{print(b-a);}
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

chc = 1
while True:
	if chc == 1:
		c-=b
		chc = 2
	else:
		a-=d
		chc = 1
	if c<=0:
		print('Yes')
		break
	if a<=0:
		print('No')
		break

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

void SelectionSort(int a[], int n) {	
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {		
	    int iMin = i, s = i;; 		
	    for (int j = i + 1; j < n; j++) {		
	        if (a[j] < a[iMin]) {
	            iMin = j;	
	        }
	    }		
	    if (iMin != s) ans++;
    	int temp = a[i];		
        a[i] = a[iMin];		
	    a[iMin] = temp;		
	    
    }
    
    for (int i = 0; i < n; i++) {
        cout << a[i];
        if (i == n - 1) cout << endl;
        else cout << ' ';
    }
    cout << ans << endl;
}		

int main(void){
    int n; cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    SelectionSort(a, n);
}



Measured memory_bytes: 3108
#include <iostream>
using namespace std;
int main() {
    string set;
    while (cin >> set) {
        if (set == "0") break;
        int a = 0, b = 0;
        for (int i=1; i<set.length(); i++) {
            if (set[i] == 'A') a++;
            if (set[i] == 'B') b++;
        }
        if (a > b) a++;
        else if (a < b) b++;
        cout << a << " " << b << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
  
char str[15];
char a[10000000];
  
int find(void);
void insert(void);
int getChar(char);
int getkey(void);
 
int find(){
  int key = getkey();
      
  if(a[key]) return 1;
  else return 0;
}
 
int getkey(){
  int sum=0, p=1,i;
  for(i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
void insert(){
  a[getkey()] = 1;
}
 
int getChar(char c){
  if(c == 'A')return 1;
  else if(c == 'C')return 2;
  else if(c == 'G')return 3;
  else if(c == 'T')return 4;
}
 
int main(){
  int i,j,n;
  char b[7];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s %s",b,str);
    if(b[0]=='i'){
      insert();
    }
    else if(b[0]=='f'){
      if(find())printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 9376
#include <iostream>
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  string s1, s2;
  cin >> s1 >> s2;
  int i = 0;
  int pre = -1;
  ll ans = 1;
  while(i < N) {
    if(s1[i] == s2[i]) {
      switch(pre) {
      case -1:
        ans = (ans * 3) % MOD;
        break;
      case 0: // 縦
        ans = (ans * 2) % MOD;
        break;
      case 1: // 横
        ans = (ans * 1) % MOD;
        break;
      default:
        break;
      }
      i += 1;
      pre = 0;
    } else {
      switch(pre) {
      case -1:
        ans = (ans * 6) % MOD;
        break;
      case 0:
        ans = (ans * 2) % MOD;
        break;
      case 1:
        ans = (ans * 3) % MOD;
      default:
        break;
      }
      i += 2;
      pre = 1;
    }
  }
  cout << (ans % MOD) << endl;
  return 0;
}

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

int main() {
  int h, w;
  char a[100][100];
  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) cin >> a[i][j];
  }
  bool rows[100] = {}, columns[100] = {};
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (a[i][j] == '#') rows[i] = true;
    }
  }
  for (int j = 0; j < w; ++j) {
    for (int i = 0; i < h; ++i) {
      if (a[i][j] == '#') columns[j] = true;
    }
  }
  for (int i = 0; i < h; ++i) {
    if (!rows[i]) continue;
    for (int j = 0; j < w; ++j) {
      if (columns[j]) cout << a[i][j];
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;

int main( void )
{

 /*   #ifndef ONLINE_JUDGE
        freopen( "input.txt" , "r" , stdin ) ;
        freopen( "output.txt" , "w" , stdout ) ;
    #endif // ONLINE_JUDGE  

*/

    ios_base::sync_with_stdio( false ) ;

    cin.tie( NULL ) ;

    cout.tie( NULL ) ;


    //cout << -9%-2 << endl ;


    ///*

    int n ;

    cin >> n ;

    if( n == 0 )  cout << 0 << endl ;

    else  {

        vector<int> v ;

        while( n )  {

            v.push_back( abs( n % -2 ) ) ;

            n = (n-abs(n%-2)) /-2 ;

        }

        for( auto i = v.rbegin() ; i != v.rend() ; i++ )  {

            cout << *i ;

        }

    }           //   */

    return 0 ;

}


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

int main()
{
	int n;
	while (scanf("%d", &n), n){
		bitset<100> s[100];
		for (int i = 0; i < n; i++){
			int m;
			scanf("%d", &m);
			for (int j = 0; j < m; j++){
				int p;
				scanf("%d", &p);
				s[i].set(--p);
			}
		}
		
		bitset<100> t;
		int k;
		scanf("%d", &k);
		for (int i = 0; i < k; i++){
			int l;
			scanf("%d", &l);
			t.set(--l);
		}
		
		int res = -1;
		for (int i = 0; i < n; i++){
			bitset<100> tmp = s[i] &= t;
			if (tmp == t){
				if (res == -1) res = i + 1;
				else {
					res = -1;
					break;
				}
			}
		}
		
		printf("%d\n", res);
	}
	
	return 0;
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC96
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var a = int.Parse(s[0]);
            var b = int.Parse(s[1]);
            if (a > b)
            { 
                Console.WriteLine(a-1);
            }else
            Console.WriteLine(a);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> a(N),b(N),c(N,1);
	//c[i] == 0 だったらその場所の数値は固定
	int m = 0;
	bool ng = 0;
	for(int i=0;i<N;i++)cin >> a[i];
	for(int i=0;i<N;i++)cin >> b[i];
	for(int i=0;i<N;i++){
		if(m<a[i]){
			c[i] = 0;
			m = a[i];
			if(i!=0 && m>b[i])ng = 1;
		}else if(m>a[i]){
			ng = 1;
		}
	}
	int am = m;
	m = 0;
	for(int i=N-1;i>=0;i--){
		if(m<b[i]){
			c[i] = 0;
			m = b[i];
			if(i!= N-1 && m>a[i])ng = 1;
		}else if(m>b[i]){
			ng = 1;
		}
	}
	int bm = m;
	if(ng || am!=bm)cout << 0 << endl;
	else {
		ll ans = 1;
		for(int i=0;i<N;i++){
			if(c[i]!=0){
				ans *= min(a[i],b[i]);
				ans %= mod;
			}
		}
		cout << ans << endl;
	}
}

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

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

    int sz;
    cin >> sz;
    vector<int> xs(sz, 0);
    for (auto &x : xs) cin >> x;

    ll ans = 0;
    ll s = 0;

    for (int i = sz - 2; i >= 0; --i) {
        s += xs[i + 1];
        s %= M;

        ans += xs[i] * s;
        ans %= M;
    }

    cout << ans << '\n';

    return 0;
}


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

int main() {
  
  string a;
  cin >> a;
 
  a[5] = ' ';
  a[13] = ' ';
  
  cout << a << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
 
int main(){
    int m[1000],n=0,M=0,N=0,w,I,J,j;
    string r[1000],s;
    while(cin>>s){
        w=0;
        if(s.size()>M){M=s.size();I=n;}
        for(int i=0;i<n;i++)if(s==r[i]){m[i]++;w=1;j=i;break;}
        if(w==0){r[n]=s;m[n]=1;j=n;n++;}
        if(m[j]>N){N=m[j];J=j;}
    }
    cout<<r[J]<<" "<<r[I]<<endl;
}

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

int main(){
  int n; ll m;
  cin >> n >> m;
  ll a[n], sum[n+1];
  sum[0] = 0;
  rep(i,n)cin >> a[i];  
  sort(a,a+n);
  rep(i,n) sum[i+1] = sum[i] + a[i]; 
  ll l = 0, r = INF, u;
  while(r-l>1) {
    ll mid = (l+r)/2;
    u = 0;
    rep(i,n) {
      ll b = mid - a[i];
      ll p = a + n - lower_bound(a,a+n,b);
      u += p;
    }
    if(u < m) r = mid;
    else l = mid;
  }
  ll ans = 0, c = 0;
  rep(i,n) {
    ll b = r - a[i];
    ll p = lower_bound(a,a+n,b) - a;
    ans += sum[n] - sum[p] + a[i]*(n-p);
    c += n-p;
  }
  ll d = m-c;
  int pos = n-1;
  while(d > 0) {
    ll b = l - a[pos];
    ll p = upper_bound(a,a+n,b) - lower_bound(a,a+n,b);
    ans += l*min(d,p);
    d -= p;
    pos--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
ll n,k,h[200005];
int main()
{
    cin>>n>>k;
	rep(i,1,n)cin>>h[i];
	sort(h+1,h+n+1);
	ll ans=0;
	int lim=max(0ll,n-k);
	rep(i,1,lim)ans+=h[i];
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9)+1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        rep0(i, N) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    long long s;
    cin>>s;
    int v = 1000000000;
    ll x=(v-s%v)%v;
    ll y=(s+x)/v;
    printf("0 0 1000000000 1 %lld %lld",x,y);
    return 0;
}


Measured memory_bytes: 256
S = input()
ans = 1
tmp = S[0]
flg = False
for i in range(1,len(S)):
    if flg:
        tmp += S[i]
        ans += 1
        flg = False
        continue
    if S[i] != tmp:
        tmp = S[i]
        ans += 1
    else:
        flg = True
print(ans)

Measured memory_bytes: 41308
from sys import stdin
input = stdin.readline

N = int(input())
L = list(map(int, input().split()))

cnt = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                continue

            if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[i] + L[k] > L[j]:
                cnt += 1

print(cnt)


Measured memory_bytes: 9200
from math import pi,cos,sqrt
a,b,h,m =map(int,input().split())

L =30*h +0.5*m
M =6*m
angle =max(L,M)-min(L,M)
if angle >180:
    angle =360-angle
A=cos(angle*pi/180)

# print(A)
ans =sqrt(a*a+b*b -2*a*b*A)
print(ans)

Measured memory_bytes: 9524
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] d = new int[N];
        int i = 0;
        while(i < N){
            d[i] = sc.nextInt();
            i++;
        }
        int[] flag = new int[100];
        for(int j = 0; j < N; j++){
            flag[d[j] - 1]++;
        }
        int count = 0;
        for(int f: flag){
            if(f > 0){
                count++;
            }
        }
        System.out.println(count);
    }
}


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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  ans += min(a, b);
  ans += min(max(a, b), c);
  ans += max(max(a, b), c) * 10;
  cout << ans << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/aising2019/tasks/aising2019_e
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int N;
LL A[5123];
vector<int> g[5123];
vector<int> t[5123];
LL allB[5123][5123];
LL dp[5123][5123];
LL tmp[5123];
int sub[5123];
void dfs(int v,int p){
    sub[v]=1;
    for(int u:g[v]){
        if(u==p)continue;
        t[v].push_back(u);
        dfs(u,v);
        sub[v]+=sub[u];
    }
}
void solve(int v){
    for(int u:t[v]){
        solve(u);
    }
    int x=1;
    if(A[v]>0){
        allB[v][0]=1;
    }
    else{
        allB[v][0]=0;
    }
    dp[v][0]=A[v];
    for(int u:t[v]){
        const int nx=x+sub[u];
        for(int i:range(nx+1)){
            tmp[i]=0;
        }
        for(int i:range(x))for(int j:range(sub[u]+1)){
            tmp[i+j]|=(allB[v][i]&allB[u][j]);
        }
        for(int i:range(nx+1)){
            allB[v][i]=tmp[i];
            tmp[i]=1e18;
        }
        for(int i:range(x))for(int j:range(sub[u]+1)){
            chmin(tmp[i+j],dp[v][i]+dp[u][j]);
        }
        for(int i:range(nx+1)){
            dp[v][i]=tmp[i];
        }
        x=nx;
    }
    for(int i:range(x)){
        if(allB[v][i]||dp[v][i]<0){
            chmin(dp[v][i+1],0ll);
            allB[v][i+1]=1;
        }
    }
}
int main(){
    cin>>N;
    for(int i:range(N)){
        cin>>A[i+1];
    }
    for(int i:range(N-1)){
        int u,v;
        cin>>u>>v;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    dfs(1,1);
    solve(1);
    int ret=N-1;
    for(int i:range(N+1)){
        if(allB[1][i])chmin(ret,i);
        if(dp[1][i]<0)chmin(ret,i);
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 401664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007



signed main() {
	int n;
	int t, a;
	int h[1002];

	cin >> n;
	cin >> t >> a;
	rep(i, n) {
		cin >> h[i];
	}
	double m = abs(a - (t - h[0] * 0.006));
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (m > abs(a - (t - h[i] * 0.006))) {
			ans = i + 1;
			m = abs(a - (t - h[i] * 0.006));
		}
	}

	cout << ans << endl;


	END;
}


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

int main()
{
    int N;
    cin >> N;
    int Ai;
    double res = 0;
    for(int i=0;i<N;i++){
        cin >> Ai;
        res += 1./Ai;
    }
    cout<<1./res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <string.h>

using namespace std;

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

int board[44][44];
int h, w;

int DFS(int x, int y, int n){
	int ret = 0;
	while(board[x][y] != 0){
		x++;
		if(x > w){
			y++;
			x = 1;
			if(y > h)return 1;
		}
	}
	//たて向き
	if(board[x][y+1]==0){
		int check = 0;
		if(board[x][y-1] != board[x+1][y-1])check++;
		if(board[x+1][y-1] != board[x+1][y])check++;
		if(check != 2){
			board[x][y] = n;
			board[x][y+1] = n;
			ret += DFS(x,y,n+1);
			board[x][y] = 0;
			board[x][y+1] = 0;
		}
	}
	//よこ向き
	if(board[x+1][y]==0){
		int check = 0;
		if(board[x+1][y-1] != board[x+2][y-1])check++;
		if(board[x+2][y] != board[x+2][y-1])check++;
		if(check != 2){
			board[x][y] = n;
			board[x+1][y] = n;
			ret += DFS(x,y,n+1);
			board[x][y] = 0;
			board[x+1][y] = 0;
		}
	}
	return ret;
}

int main(){
	while(1){
		memset(board, 0, sizeof(board));
		cin >> h>> w;
		if(h==0)break;
		REP(i,w+2){
			board[i][0] = 1000;
			board[i][h+1] = 1000;
		}
		REP(i,h+2){
			board[0][i] = 1000;
			board[w+1][i] = 1000;
		}
		if(h==0)return 0;
		cout << DFS(1, 1, 1) << endl;
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    // 入力
    int n,m,s[11],c[11],count[11][3]={},ans=0;
    cin >> n >> m;
    rep(i,m){
        cin >> s[i] >> c[i];
        if(count[s[i]][0] == 0){
            count[s[i]][0]++;
            count[s[i]][1] = c[i];
        }else if(count[s[i]][0] == 1 && count[s[i]][1] != c[i]){
            cout << "-1" << endl;
            return 0;
        }
    }
    
    if(n == 3){
        if(count[1][1] == 0){
            if(count[1][0] == 0){
                count[1][1] = 1;
            }else{
                cout << "-1" << endl;
                return 0;
            }
        }
        ans = count[1][1]*100 + count[2][1]*10 + count[3][1];
    }else if(n == 2){
        if(count[1][1] == 0){
            if(count[1][0] == 0){
                count[1][1] = 1;
            }else{
                cout << "-1" << endl;
                return 0;
            }
        }
        ans = count[1][1]*10 + count[2][1];
    }else if(n == 1){
        ans = count[1][1];
    }
    
    cout << ans << endl;
} 


Measured memory_bytes: 256
n,m= gets.chop.split.map(&:to_i)

a = []
b = []
ans1 = []

n.times do |i|
  as = gets.chop.split.map(&:to_i)
  a << as
end

m.times do |j|
  bs = gets.to_i
  b << bs
end

n.times do |i|
  m.times do |j|
    cs = a[i][j] * b[j]
    ans1 << cs
  end
end

ans2 = ans1.each_slice(m).to_a
ans3 =[]
n.times do |i|
  ds = ans2[i].inject(:+)
  ans3 << ds
end

puts ans3

Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define llint long long
#define pii pair<int, int>
#define UNVISITED -1


template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}
 
template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif


int main() {
    string s; cin >> s;
    if(s.back() != 's') s += "s";
    else s += "es";
    cout << s << endl;
}

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

int main()
{
	string s,t;
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0;i<s.size();i++)
	{
		if(s[i]==t[i])cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        long L = scanner.nextInt();
        long R = scanner.nextInt();
        long ans = 0;
        long min = 2018;
        long i;
        long j;
        for (i = L; i < R; i++) {
            for (j = i + 1; j <= R; j++) {
                ans = (i * j) % 2019;
                if (min > ans) min = ans;
                if(min == 0) break;
            }
            if(min == 0) break;
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 22996
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 400010;
const int MAXM = 30*30*16*16+10;
const int MAXK = 19;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
//const int MOD = 1000000007;
//const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

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


#define rep(i,a,b) for (int i = (a), I = (b); i <= I; ++ i)

void solve()
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = 1; i <= n; ++ i)
	{
		int x;
		cin >> x;
		ans += x >= k;
	}
	cout << ans << endl;
}

int main()
{
	
	int T;
	T = 1;
	//scanf("%d", &T);
	while (T --)
	solve();
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(char a){
  putchar_unlocked(a);
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int M;
int C;
int B[20];
int A[20];
int main(){
  int KL2GvlyY, i, res=0, val;
  rd(N);
  rd(M);
  rd(C);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<M;Lj4PdHRW++){
      rd(B[Lj4PdHRW]);
    }
  }
  for(KL2GvlyY=0;KL2GvlyY<N;KL2GvlyY++){
    {
      int Q5VJL1cS;
      for(Q5VJL1cS=0;Q5VJL1cS<M;Q5VJL1cS++){
        rd(A[Q5VJL1cS]);
      }
    }
    val = C;
    {
      int e98WHCEY;
      for(e98WHCEY=0;e98WHCEY<(M-1) + 1;e98WHCEY++){
        val += A[e98WHCEY] * B[e98WHCEY];
      }
    }
    if(val > 0){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190227-1 [beta]

// --- original code ---
// int N, M, C;
// int B[20], A[20];
// {
//   int i, val, res = 0;
//   rd(N,M,C,B(M));
//   rep(N){
//     rd(A(M));
//     val = C;
//     val += A[0..M-1] * B[0..];
//     if(val > 0) res++;
//   }
//   wt(res);
// }


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

const int maxn = 100 * 1000 * 2 + 20;
vector <int> gr[maxn];
int num[maxn];

void dfs(int v, int u) {
	for (int i: gr[v])
		if (i != u) {
			num[i] += num[v];
			dfs(i, v);
		}
}

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		gr[a].push_back(b);
		gr[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		num[a] += b;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++)
		cout << num[i] << " ";
	return 0;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

void solve() {
	int n, m;
	cin >> n >> m;
	cout << max( 0, n-m+1 ) << '\n';
}

int main() {
	precal();
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int black[200001];
int white[200001];
int blackAc[200001];
int whiteAc[200001];
int main() {
    int N;
    char S[200001];
    cin >> N;
    cin >> S;

    int left = 0;
    for (int i=0; i<N; i++) {
        if (S[i] == '.') continue;
        else {
            left = i;
            break;
        }
    }
    for (int i=left; i<N; i++) {
        if (S[i] == '.') black[i]++;
    }
    for (int i=N-1; i>=0; i--) {
        if (S[i] == '#') white[i]++;
    }

    int k = 0;
    for (int i=0; i<N-1; i++) {
        k += white[i];
        whiteAc[i+1] = k;
    }
    k = 0;
    for (int i=N-1; i>=1; i--) {
        k += black[i];
        blackAc[i-1] = k;
    }

    int minLoss = -1;
    for (int i=0; i<N; i++) {
        if (minLoss == -1 || minLoss > whiteAc[i] + blackAc[i]) {
            minLoss = whiteAc[i] + blackAc[i];
        }
    }


    cout << minLoss << endl;

    return 0;
}



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

int main(){
  char str;
  cin >> str;
  
  if(str=='a')
    cout << "vowel" << endl;
  else if(str=='e')
    cout << "vowel" << endl;
  else if(str=='i')
    cout << "vowel" << endl;
  else if(str=='u')
    cout << "vowel" << endl;
  else if(str=='o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,M = [int(x) for x in input().split()]
uf = UnionFind(N)
for _ in range(M):
    x,y,z = [int(x) for x in input().split()]
    uf.union(x-1,y-1)
ans = 0
print(uf.group_count())


Measured memory_bytes: 69720
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i, st, end) for (int i = st; i < end; ++i)
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    map<int, int, greater<int>> mp;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a; //mp.first
        mp[a]++; //++ is mp.second
    }
    int ans = 0;
    for (auto x : mp) {
        if (x.second >= 4) {
            if (ans == 0) {
                cout << (ll)x.first * x.first << endl;
                return 0;
            } else {
                cout << (ll)ans * x.first << endl;
                return 0;
            }
        }
        if (x.second >= 2) {
            if (ans == 0) {
                ans = x.first;
            } else {
                cout << (ll)ans * x.first << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var X = sc.ReadInt();
        var Xs = sc.ReadIntArray(N);
        var ans = Math.Abs(Xs[0] - X);
        for (int i = 1; i < N; i++)
        {
            var d = Math.Abs(Xs[i] - X);
            ans = (int)Gcd(ans, d);
        }
        Console.WriteLine(ans);
    }
    static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 28500
function Main(input) {
	input = input.split("\n");
	tmp = input[0].split(" ");
	var nums = Number(tmp[0])
    var picks = Number(tmp[1])
    var required = 1/(4*picks)
    var ans = 'Yes'
	var list = input[1].split(' ')
    list.sort((a,b) => Number(b) - Number(a))
  	var sum = list.reduce((a, b) => Number(a) + Number(b))
    if(list[picks-1]/sum < required) return console.log('No')
  	console.log('Yes')
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

char f[100][100]={};
char fruit;
int H, W;


void CHECK(int h, int w);

int main(void){
    int count;
    
    while(1){
        count=0;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cin >> f[i][j];
            }
        }
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(f[i][j] != 'E'){
                    count++;
                    fruit=f[i][j];
                    CHECK(i,j);
                }
            }
        }
        cout << count << endl;
    }
}


void CHECK(int h, int w){
    f[h][w]='E';
    if(h-1>=0 && f[h-1][w]==fruit){
        f[h-1][w]='E';
        CHECK(h-1, w);
    }
    if(h+1<H && f[h+1][w]==fruit){
        f[h+1][w]='E';
        CHECK(h+1, w);
    }
    if(w-1>=0 && f[h][w-1]==fruit){
        f[h][w-1]='E';
        CHECK(h, w-1);
    }
    if(w+1<W && f[h][w+1]==fruit){
        f[h][w+1]='E';
        CHECK(h, w+1);
    }
}



Measured memory_bytes: 3784
import random

class Dice:
    def __init__(self, hoge):
        self.num = hoge
        self.face = {'U': 0, 'W': 3, 'E': 2, 'N': 4, 'S': 1, 'B': 5} 
    
    def move(self, direct):
        previouse = {k: v for k, v in self.face.items()}
        if direct == 'E':
            self.face['U'] = previouse['W']
            self.face['W'] = previouse['B']
            self.face['E'] = previouse['U']
            self.face['B'] = previouse['E']
        elif direct == 'W':
            self.face['U'] = previouse['E']
            self.face['W'] = previouse['U']
            self.face['E'] = previouse['B']
            self.face['B'] = previouse['W']
        elif direct == 'N':
            self.face['U'] = previouse['S']
            self.face['N'] = previouse['U']
            self.face['S'] = previouse['B']
            self.face['B'] = previouse['N']
        elif direct == 'S':
            self.face['U'] = previouse['N']
            self.face['N'] = previouse['B']
            self.face['S'] = previouse['U']
            self.face['B'] = previouse['S']
    
    def get_num(self, place):
        return self.num[self.face[place]]
    
    def getFace(self):
        for k, v in sorted(self.face.items()):
            yield self.num[v]
    
        
if __name__ == '__main__':
    dice1 = Dice([int(x) for x in input().split()])
    dice2 = Dice([int(x) for x in input().split()])
    d = ['E', 'W', 'N', 'S']
    for k in range(1000):
        c = 0
        rand_num = random.randint(0, 3)
        dice2.move(d[rand_num])
        
        for v1, v2 in zip(dice1.getFace(), dice2.getFace()):
            if v1 == v2:
                c += 1
        if c == 6:
            print ('Yes')
            break
        if k == 999:
            print ('No')


Measured memory_bytes: 8200
#include <iostream>
#include <algorithm>
#include <sstream>
using namespace std;
int memo[1000001];
string tostr(int x){
  stringstream ss;
  ss << x;
  string s;
  ss >> s;
  return s;
}
int toint(string s){
  int x;
  stringstream ss;
  ss << s;
  ss >> x;
  return x;
}

int solve(int n){
  if(n<10) return 0;
  if(memo[n]) return memo[n];
  string s = tostr(n);
  int nxt = -1;
  for(int i=1;i<=s.length()-1;++i){
    string a = s.substr(0,i);
    string b = s.substr(i,s.length()-i);
    nxt = max(nxt,toint(a)*toint(b));
  }
  return memo[n]=solve(nxt)+1;
}
int main(){
  int q;
  cin >> q;
  while(q--){
    int n;
    cin >> n;
    cout << solve(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 3048
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *CSP-S 2019 RP++                                          *
 ***********************************************************/
//#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
	char *pp = (char*)malloc(size) + size;  \
	__asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<fstream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
	ll x=0,f=1;char c;
	for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
	for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
	return x*f;
}
template<typename T>
inline void write(T a){
	if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
	while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
#define int ll
int n,k,q,x,c[mn],sum;
signed main(){
#ifdef LOCAL_LIGEN
	// freopen("0.in","r",stdin);
	// freopen("0.out","w",stdout);
	double be=clock();
#endif
	n=read(),k=read(),q=read();
	FOR(i,1,q)x=read(),--c[1],++c[x],--c[x+1];
	FOR(i,1,n){
		sum+=c[i];
		if(sum+k<=0)puts("No");else puts("Yes");
	}
#ifdef LOCAL_LIGEN
	double en=clock();
	printf("Time: %.0lfms\n",en-be);
	fclose(stdin);fclose(stdout);
#endif
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL Maxn = 1000000 + 100;
LL N, M;
LL Ans[Maxn];
struct node
{
	LL id, val;
}A[Maxn];
int main()
{
#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	scanf("%lld%lld", &N, &M);
	LL k = 0ll;
	for (LL i = 1ll; i <= N; ++i)
	{
		scanf("%lld", &A[i].val), A[i].id = i;
		if (A[i].val > A[k].val) k = i;
	}
	LL Cnt = N, sum = 0ll;
	while (Cnt > 1ll)
	{
		LL fl = 0ll;
		if (k <= Cnt / 2)
		{
			k = 0ll;
			for (LL i = 1ll; i < Cnt; ++i)
			{
				if (A[i].val + A[i + 1ll].val >= M)
				{
					Ans[++sum] = A[i + 1].id - 1;
					fl = 1ll;
					A[i + 1ll].val += A[i].val;
					A[i].val = 0ll;
					//A[i + 1ll].id = A[i].id;
				}
			}
		}
		else 
		{
			k = 0ll;
			for (LL i = Cnt; i > 1ll; --i)
			{
				if (A[i].val + A[i - 1ll].val >= M)
				{
					Ans[++sum] = A[i - 1].id;
					fl = 1ll;
					A[i - 1ll].val += A[i].val;
					A[i].val = 0ll;
					//A[i - 1ll].id = A[i].id;
					//A[i + 1ll].id = A[i].id;
				}
			}
		}
		if (!fl)
		{
			cout<<"Impossible"<<endl;
			return 0;
		}
		LL tmp = Cnt;
		Cnt = 0ll;
		for (LL i = 1ll; i <= tmp; ++i)
			if (A[i].val) A[++Cnt].val = A[i].val, A[Cnt].id = A[i].id;
		for (LL i = 1ll; i <= Cnt; ++i)
			if (A[i].val > A[k].val) k = i;
	}
	cout<<"Possible"<<endl;
	for (LL i = sum; i >= 1ll; --i)
		cout<<Ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[maxn];
set<int>ss;
int main()
{
    int s,n=2;
    scanf("%d",&s);
    a[1]=s;
    ss.insert(s);
    while(1){
        if(a[n-1]&1){
            a[n]=3*a[n-1]+1;
        }
        else{
            a[n]=a[n-1]/2;
        }
        if(ss.count(a[n])){
            printf("%d\n",n);
            return 0;
        }
        ss.insert(a[n]);
        n++;
    }

}


Measured memory_bytes: 256