akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin>>s;
    int zn =0;
    int an =0;
    for(int i = 0;i<s.size();i++){
        if (s[i] == 'Z'){
            zn = i;
        }
    }
    for(int i = s.size();i>=0;i--){
        if (s[i] == 'A'){
            an = i;
        }
    }
    cout<<zn-an+1<<endl;
}

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

int main(){
    ll n,a,b,c,d,e;
    scanf("%lld%lld%lld%lld%lld%lld", &n,&a,&b,&c,&d,&e);

    ll minN = min({a,b,c,d,e});

    cout << 5 + (n-1) / minN << endl; //((n-minN)+minN-1)/minN
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    int n;
    long long ans = 0;
    cin >> n;
    
    rep(i,n){
        if((i+1)%3!=0 && (i+1)%5!=0){
            ans += (i+1);
        }
    }

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

Measured memory_bytes: 3620
#include<stdio.h>

void bubbleSort(int*,int);
void swap(int* ,int*);

int main()
{
  int n,i;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  bubbleSort(a,n);

  return 0;
}

void swap(int *x ,int *y)
{
  int z;
  z=*x;
  *x=*y;
  *y=z;
}




void bubbleSort(int*a,int n)/*バブルソート*/
{
  int i,j,x,cnt=0;
  
  for(i=0; i<n-1; i++){
    for(j=n-1; j>=i+1; j--){
      if(a[j]<a[j-1])/*入替*/
	{
	  swap(&a[j],&a[j-1]);
	  cnt++;
        }
    }
  }
  for(i=0;i<n;i++){
    if(i==n-1)
      printf("%d",a[i]);
    else
    printf("%d ",a[i]);}
  printf("\n");
  printf("%d\n",cnt);
}



Measured memory_bytes: 2104
def rec(x, i)
  return if x.zero?
  if x % 10 == 3
    @str += " " + i.to_s
  else
    x /= 10
    rec(x, i)
  end
end

val = gets.to_i
i = 1
@str = ""

while i <= val
  x = i
  if x % 3 == 0
    @str += " " + i.to_s
  else
    rec(x, i)
  end
  i += 1
end

puts @str

Measured memory_bytes: 13944
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum Type{
	pre_no,
	pre_yes,
};

struct Info{
	int ENC_POWER,WILL_POWER;
};

int main(){

	int N,P;
	scanf("%d %d",&N,&P);


	int X[N],Y[N];
	for(int i = 0; i < N; i++){
		scanf("%d %d",&X[i],&Y[i]);
	}

	Info dp[N+1][N+1][2];

	for(int i = 0; i <= N; i++){
		for(int k = 0; k <= N; k++){
			dp[i][k][pre_no].ENC_POWER = -1;
			dp[i][k][pre_no].WILL_POWER = -1;

			dp[i][k][pre_yes].ENC_POWER = -1;
			dp[i][k][pre_yes].WILL_POWER = -1;
		}
	}

	dp[0][0][pre_no].ENC_POWER = P;
	int today_value;

	for(int day = 0; day <= N-1; day++){
		for(int num = 0; num <= day; num++){
			if(dp[day][num][pre_no].ENC_POWER != -1){
				if(X[day] >= Y[day]){
					dp[day+1][num+1][pre_no].ENC_POWER = max(dp[day+1][num+1][pre_no].ENC_POWER,dp[day][num][pre_no].ENC_POWER);
				}else{

					dp[day+1][num][pre_no].ENC_POWER = max(dp[day+1][num][pre_no].ENC_POWER,dp[day][num][pre_no].ENC_POWER);

					if(dp[day][num][pre_no].ENC_POWER >= Y[day]-X[day]){

						if(dp[day+1][num+1][pre_yes].ENC_POWER < dp[day][num][pre_no].ENC_POWER-(Y[day]-X[day])){

							dp[day+1][num+1][pre_yes].ENC_POWER = dp[day][num][pre_no].ENC_POWER-(Y[day]-X[day]);
							dp[day+1][num+1][pre_yes].WILL_POWER = X[day+1]-(Y[day]-X[day]);

						}else if(dp[day+1][num+1][pre_yes].ENC_POWER == dp[day][num][pre_no].ENC_POWER-(Y[day]-X[day])){
							if(dp[day+1][num+1][pre_yes].WILL_POWER < X[day+1]-(Y[day]-X[day])){
								dp[day+1][num+1][pre_yes].WILL_POWER = X[day+1]-(Y[day]-X[day]);
							}
						}
					}
				}
			}

			if(dp[day][num][pre_yes].ENC_POWER != -1){

				today_value = max(0,dp[day][num][pre_yes].WILL_POWER);

				if(today_value >= Y[day]){
					dp[day+1][num+1][pre_no].ENC_POWER = max(dp[day+1][num+1][pre_no].ENC_POWER,dp[day][num][pre_yes].ENC_POWER);
				}else{

					dp[day+1][num][pre_no].ENC_POWER = max(dp[day+1][num][pre_no].ENC_POWER,dp[day][num][pre_yes].ENC_POWER);

					if(dp[day][num][pre_yes].ENC_POWER >= Y[day]-today_value){

						if(dp[day+1][num+1][pre_yes].ENC_POWER < dp[day][num][pre_yes].ENC_POWER-(Y[day]-today_value)){

							dp[day+1][num+1][pre_yes].ENC_POWER = dp[day][num][pre_yes].ENC_POWER-(Y[day]-today_value);
							dp[day+1][num+1][pre_yes].WILL_POWER = X[day+1]-(Y[day]-today_value);

						}else if(dp[day+1][num+1][pre_yes].ENC_POWER == dp[day][num][pre_yes].ENC_POWER-(Y[day]-today_value)){

							if(dp[day+1][num+1][pre_yes].WILL_POWER < X[day+1]-(Y[day]-today_value)){
								dp[day+1][num+1][pre_yes].WILL_POWER = X[day+1]-(Y[day]-today_value);
							}
						}
					}
				}
			}
		}
	}

	int ans = 0;
	for(int num = 1; num <= N; num++){
		if(dp[N][num][pre_no].ENC_POWER != -1 || dp[N][num][pre_yes].ENC_POWER != -1)ans = num;
	}

	printf("%d\n",ans);

	return 0;
}

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

int main(){
    string n;
    cin >> n;
    int ans = 0;
    for(int i=n.size();i>=0;--i){
        int sum = 0;
        for(int j=n.size()-1;j>=0;--j){
            if(i == j)sum += (n[j] - '0' - 1);
            else if(i > j)sum += (n[j] - '0');
            else sum += 9;
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		if(b%a==0)System.out.println(a+b);
		else System.out.println(b-a);
	}

}


Measured memory_bytes: 21972
#include <cstdio>
#include <utility>
#include <numeric>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<vector<int>> v(in());
	for (int q = in(), i; q ; q--) {
		switch (in()) {
		case 0:
			i = in();;
			v[i].push_back(in());
			break;
		case 1:
			out(v[in()]);
			break;
		default:
			v[in()] = {};
		}
	}
}


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

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

    int min_cost[n];
    
    min_cost[0] = 0;
    min_cost[1] = abs(cost[0]-cost[1]);

    for(int i=2;i<n;i++){
        min_cost[i] = min(abs(cost[i]-cost[i-2])+min_cost[i-2],abs(cost[i]-cost[i-1])+min_cost[i-1]);
    }

    cout << min_cost[n-1] << endl;

    return 0;
}


Measured memory_bytes: 4360
let rec digits r = function
  | 0 -> []
  | n -> n mod r :: digits r (n / r)
 
let () = Scanf.scanf "%d" @@ fun n ->
  Array.init (n + 1) (fun i ->
    List.fold_left ( + ) 0 (digits 6 i) + List.fold_left ( + ) 0 (digits 9 (n - i)))
  |> Array.fold_left min max_int
  |> Printf.printf "%d\n"

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    int n, a;
    scanf("%d", &n);
    int ma=0, mi=0x3f3f3f3f;
    for (int i = 0; i<n; i++) {
        scanf("%d", &a);
        ma = max(ma, a);
        mi = min(mi, a);
    }
    printf("%d\n", ma-mi);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<algorithm>

#define X first
#define Y second
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;

vector<pair<int,int> > x;
int main(void){
  ll n,k;
  ll a,b;
  cin >> n >> k;
  rep(i,n){
    cin >> a >> b;
    x.push_back(make_pair(a,b));
  }
  sort(all(x));
  ll ind = 0;
  rep(i, n){
    ind += x[i].Y;
    if( ind >= k){
      cout << x[i].X << endl;
      return 0;
    }
  }
  return 0;
}


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
   return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}


int main(){
  ll n,k;

  cin>>n>>k;

  ll last = n % k;

  ll ans = 0;

  if(k%2==0){
    if(last>=k/2) ans += (n /(k)+1) *(n /(k)+1) * (n /(k)+1);
    else   ans += (n /(k)) *(n /(k)) * (n /(k));
  }

  ans += (n /(k)) *(n /(k)) * (n /(k));
  cout << ans<<endl;
  
  
}


Measured memory_bytes: 256
#!/usr/bin/env python3

# input
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(n):
    p[i] -= 1

# calc
ans = -int(1e18)
for si in range(n):
    x = si
    s = []
    opscore = 0 
    while True:
        x = p[x]
        opscore += c[x]
        s.append(c[x])
        if x == si: 
            break

    oplen = len(s)
    t = 0 
    for i in range(oplen):
        t += s[i]
        if i+1 > k:
            break
        now = t 
        if opscore > 0:
            e = (k-(i+1))//oplen
            now += opscore * e 
        ans = max(ans, now)

print(ans)


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

int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int ans = A*X+B*Y;
    for(int i=0;i<=X+Y;i++){
        int tmp = 2*C*i + max(0,X-i)*A + max(0,Y-i)*B;
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s == "Sunny")cout << "Cloudy" << endl;
  if(s == "Cloudy")cout << "Rainy" << endl;
  if(s == "Rainy")cout << "Sunny" << endl;
}

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

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

  int *A;
  A = new int[num];
  for (int i = 0; i < num; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < num - 1; i++) {
    cout << A[i] << " ";
  }
  cout << A[num - 1] << endl;

  for (int i = 1; i < num; i++) {
    int key = A[i];
    int j = i - 1;

    while (j >= 0 && A[j] > key) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = key;

    for (int i = 0; i < num - 1; i++) {
      cout << A[i] << " ";
    }
    cout << A[num - 1] << endl;
  }

  return 0;
}


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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<endl;
    }
    else if(a<k&&k<=a+b){
        cout<<a<<endl;
    }
    else{
        cout<<a-(k-(a+b))<<endl;
    }
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int n,sum=0,x;
    scanf("%d",&n);
    x=n;
    while(x!=0)
    {
        sum=sum+x%10;
        x=x/10;
    }
    if(n%sum==0)
        printf("Yes\n");
    else
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<numeric>
#include<cmath>

constexpr size_t f(size_t n){
    return n == 0 ? 1 : f(n - 1) * n;
}

int main(){
    
    size_t n;
    std::vector<std::pair<int, int>> xy;

    std::cin >> n;

    for(size_t i = 0; i < n; i++){
        int x, y;
        std::cin >> x >> y;
        xy.emplace_back(x, y);
    }

    std::vector<size_t> ar(n);
    std::iota(ar.begin(), ar.end(), 0);

    auto sum = 0.0;

    do{
        for(size_t i = 0; i < ar.size() - 1; i++){
            sum += std::sqrt(std::pow(xy[ar[i]].first - xy[ar[i + 1]].first, 2.0) + std::pow(xy[ar[i]].second - xy[ar[i + 1]].second, 2.0));
        }
    }while(std::next_permutation(ar.begin(), ar.end()));

    std::printf("%f\n", sum / f(n));
    
    return 0;
}


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

const int N = 1e3+100;

int A[N];
int main(){
  int a = 0 , b = 0 , c = 0 , d= 0;
  int n; cin >> n;
  string s;
  for(int i= 0;i < n ; ++i){
    cin >> s;
    if(s == "AC")++a;
    else if(s == "WA") ++b;
    else if(s == "TLE") ++c;
    else ++d;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;

  return 0;

}


Measured memory_bytes: 3616
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define Icin(s) ll (s);cin>>(s);
#define Scin(s) ll (s);cin>>(s);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
int main(){
    int n;cin>>n;
    V vec(n);
    rep(i,n)cin>>vec[i];
    ll res=0;
    res+=vec[0]/2;
    vec[0]-=res*2;
    rep3(i,1,n){
        if(vec[i-1]>vec[i]){
            res+=vec[i];
            vec[i-1]-=vec[i];
            vec[i]=0;
        }else{
            res+=vec[i-1];
            vec[i]-=vec[i-1];
            vec[i-1]=0;
            if(vec[i]>=2){
                res+=vec[i]/2;
                vec[i]-=(vec[i]/2)*2;
            }
        }
    }
    if(vec[n-1]>=2){
        res+=vec[n-1]/2;
        vec[n-1]-=(vec[n-1]/2)*2;
    }
    cout<<res<<endl;
}

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

const long long MOD = 998244353;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve(long long N, long long M, long long K){
    ll ans = 0;
    if(M == 1){
        if(K == N - 1){
            cout<<1<<endl;        
        }else{
            cout<<0<<endl;
        }
        return;
    }
    COMinit();
    for(int i = 0;i <= K;i++){
        ll A = COM(N - 1, i);
        ll remain = N - i - 1;
        ans += A * M % MOD * modpow(M - 1, N - i - 1, MOD);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 15756
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,sum;
char a[10];
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		if(i%3!=0&&i%5!=0)
			sum+=i;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main() {

    int n; cin >>n;
    vector<int> a(n); REP(i,n) cin >> a[i];

    vector<bool> flag(8, false);
    int count = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] <= 399) {
            flag[0] = true;
        } else if (a[i] <= 799) {
            flag[1] = true;
        } else if (a[i] <= 1199) {
            flag[2] = true;
        } else if (a[i] <= 1599) {
            flag[3] = true;
        } else if (a[i] <= 1999) {
            flag[4] = true;
        } else if (a[i] <= 2399) {
            flag[5] = true;
        } else if (a[i] <= 2799) {
            flag[6] = true;
        } else if (a[i] <= 3199) {
            flag[7] = true;
        } else {
            count++;
        } 
    }

    int col = 0;
    for (int i = 0; i < 8; i++) {
        if (flag[i]) {
            col++;
        } 
    }

    if (col > 0) {
        cout << col << " " << col + count << endl;
    } else {
        cout << 1 << " " << count << endl;
    } 
    
    return 0;
}


Measured memory_bytes: 256
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

def comb(n,r,mod=10**9+7):
    a=1
    b=1
    r = min(r,n-r)
    for i in range(r):
        a = a*(n-i)%mod
        b = b*(i+1)%mod
    return a*pow(b,mod-2,mod)%mod

n,a,b = map(int,input().split())
p = 10**9 +7
print((pow(2,n,p)-1-comb(n,a,p)-comb(n,b,p))%p)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K;
bool used[10], visited[int(1e5+5)];
vector <int> ans;

int Solve(int num){
  if (num >= N){
    ans.push_back(num);
    return 0;
  }

  visited[num] = true;
  for (int i = 0; i < 10; i++){
    if (used[i]) continue;
    if (visited[num * 10 + i]) continue;
    Solve(num * 10 + i);
  }

  return 0;
}

int main(){
  cin >> N >> K;
  for (int i = 0; i < K; i++){
    int D; cin >> D;
    used[D] = true;
  }
  Solve(0);

  sort(ans.begin(), ans.end());
  cout << ans[0] << endl;

  return 0;
}


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

cnt = 0
def dfs(s):
    global cnt
    if '3' in s and '5' in s and '7' in s and int(s) <= N:
        cnt += 1
    if len(s) >= 10:
        return cnt
    dfs(s + '3')
    dfs(s + '5')
    dfs(s + '7')
    return cnt

print(dfs(''))

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

int main() {
    int n, m;
    cin >> n >> m;
    int a[50], b[50];
    int c[50], d[50];
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];
    
    rep(i, n) {
        int mv = INT_MAX;
        int mi = -1;
        int dd;
        
        rep(ii, m) {
            dd = abs(a[i] - c[ii]) + abs(b[i] - d[ii]);
            
            if (mv > dd) {
                mv = dd;
                mi = ii;
            }
        }
        
        cout << (mi + 1) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define MOD 1000000007
using namespace std;

 ll pow(ll b){
    ll ans = 1; 
    for(int i = 1;i <= b; i++)
      ans = ((ans%MOD) * (2%MOD))%MOD;
    return ans;
 }
 
int main(){
 int n;
 cin >> n;
 ll a[n];
 int freq[100009];
 
 for(int i = 0; i < 100008; i++) freq[i]  = 0;
 
 for(int i = 0; i < n; i++){
      cin >> a[i]; 
      freq[a[i]]++;
 }
 bool res = 1;
 if(n&1){
  if(freq[0] > 1) res = 0;
  else{
   for(int i = 0 ; i < n ; i++){
	   if((freq[a[i]] != 2 && a[i] != 0) || a[i]%2 != 0){
	      res = 0;
	      break;                	   
	   }
 	 } 
   }
   res == 0? cout << "0" : cout << pow(n/2);    
 }
 else{
	 if(freq[1] != 2) res = 0;
	 else{
	  for(int i = 0 ; i < n ; i++){
	    if(freq[a[i]] != 2 || a[i]%2 == 0){
	      res = 0;
	      break;                	   
	   }
 	 } 
   }
   res == 0? cout << "0" : cout << pow(n/2); 	 
 }
 return 0;	
}


Measured memory_bytes: 4696
target = input()
now_height = []
now_area = [0]
answer = []
continued = 0
depth = 0
depth_list = []
for t in target:
    # print(now_height,depth_list,now_area,answer,continued)
    if t == '\\':
        now_height.append(continued)
        depth_list.append(depth)
        now_area.append(0)
        depth -= 1
    elif t == '_':
        pass
    elif t == '/' and len(now_height) > 0:
        depth += 1
        started = now_height.pop()
        temp_area = continued - started
        # print(depth_list[-1],depth)
        now_area[-1] += temp_area
        if depth > depth_list[-1]:
            while depth > depth_list[-1]:
                temp = now_area.pop()
                now_area[-1] += temp
                depth_list.pop()
        if len(now_height) == 0 or depth == depth_list[0]:
            answer.append(sum(now_area))
            now_area = [0]
            depth_list = []
    continued += 1
now_area = list(filter(lambda x:x != 0,now_area))
answer.extend(now_area)
print(sum(answer))
print(len(answer),*answer)

Measured memory_bytes: 9488
loop do
  n, s = gets.chomp.split(" ").map(&:to_i)
  exit if [n, s] == [0, 0]
  cnt = 0
  if s > 45
    puts 0
    next
  else
    [*0..9].combination(n).to_a.each do |i|
      cnt += 1 if i.inject(&:+) == s
    end
  end
  puts cnt
end

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll T[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, C, K;
    cin >> N >> C >> K;
    REP(i, N) {
        cin >> T[i];
    }
    sort(T, T + N);
    ll ans = 1;
    ll index = 0;
    REP(i, N) {
        if (T[index] + K < T[i] || i - index >= C) {
            ans++;
            index = i;
        }
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
vector<ll> v[200005];
void dfs(ll a, vector<bool> &visit, ll &ans){
    visit[a]=true;
    ans++;
    for(auto x : v[a]){
        if(visit[x]==false)
            dfs(x,visit,ans);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    ll maxi = 0;
    vector<bool> visit(n+1,false);
    for(int i=0;i<n;i++){
        if(visit[i]==false){
            ll ans = 0;
            dfs(i,visit,ans);
            maxi=max(maxi,ans);
        }
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 23944
#include<stdio.h>
int main(){
    int n,a[100];
    int i,b[20][10]={0};
    char c[100];
    scanf("%d",&n);
    for (i=0;i<n;i++){
        scanf("%*c%c %d",&c[i],&a[i]);
        if (c[i]=='S'){
            b[a[i]][1]=1;
        }else if(c[i]=='H'){
            b[a[i]][2]=1;
        }else if(c[i]=='C'){
            b[a[i]][3]=1;
        }else if(c[i]=='D'){
            b[a[i]][4]=1;
        }
    }
     
    for(i=1;i<=13;i++){
        if(b[i][1]==0){
            printf("S %d\n",i);
        }
    }
    for(i=1;i<=13;i++){
        if(b[i][2]==0){
            printf("H %d\n",i);
        }
    }
    for(i=1;i<=13;i++){
        if(b[i][3]==0){
            printf("C %d\n",i);
        }
    }
    for(i=1;i<=13;i++){
        if(b[i][4]==0){
            printf("D %d\n",i);
        }
    }    
     
    return 0;
}  


Measured memory_bytes: 2100
#include <cstdio>
#include <algorithm>
using namespace std;

int N,T;
const int MAX_N = 100010;
int a[MAX_N], M;
int pmin[MAX_N], pmax[MAX_N];

int main(){
    scanf("%d%d",&N,&T);
    for(int i=1;i<=N;i++){
        scanf("%d",&a[i]);
    }

    pmin[0] = 1e9;
    for(int i=1;i<=N;i++){
        pmin[i] = min(pmin[i-1], a[i]);
    }
    for(int i=N;i>=1;i--){
        pmax[i] = max(pmax[i+1], a[i]);
    }

    for(int i=1;i<N;i++){
        M = max(M, pmax[i+1]-pmin[i]);
    }

    int ans = 0;
    for(int i=1,j=2;i<=N;i=j++){
        while(pmax[j] >= a[i]+M)j++;
        int lo=0, hi=0;
        for(int k=i;k<j;k++){
            if(a[k]==a[i])lo++;
            if(a[k]==a[i]+M)hi++;
        }
        ans += min(lo, hi);
    }
    printf("%d\n",ans);
    return 0;
}


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

const int M = 998244353;
int A, B, C, D;

int main () {
    while (scanf("%d %d %d %d", &A, &B, &C, &D) == 4) {
        vector<vector<int>> dp(C + 1, vector<int>(D + 1, 0));
        dp[A][B] = 1;
        for (int i = A + 1; i <= C; i++) dp[i][B] = 1ll * dp[i - 1][B] * B % M;
        for (int j = B + 1; j <= D; j++) dp[A][j] = 1ll * dp[A][j - 1] * A % M;

        for (int i = A + 1; i <= C; i++)
            for (int j = B + 1; j <= D; j++) {
                //dp[i][j] = ((dp[i - 1][j] + dp[i][j - 1]) % M + 1ll * dp[i - 1][j - 1] * (i - 1)  * (j - 1) % M) % M;
                dp[i][j] = ((1ll * dp[i - 1][j] * j % M + 1ll * dp[i][j - 1] * i % M) % M - 1ll * dp[i - 1][j - 1] * (i - 1)  * (j - 1) % M + M) % M;
            }

        //for (int i = 0; i <= C; i++) {
        //    for (int j = 0; j <= D; j++)
        //        cerr << dp[i][j] << " ";
        //    cerr << "\n";
        //}

        printf("%d\n", dp[C][D]);
    }
}



Measured memory_bytes: 38532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll N,W;
	cin>>N>>W;
	ll dp[N][W+5];
	memset(dp,0,sizeof(dp));
	ll w[N],v[N];
	for(ll i=0;i<N;i++)
	{
		cin>>w[i]>>v[i];
		dp[i][w[i]]=v[i];
	}
	ll ans=v[0];
	for(ll i=1;i<N;i++)
	{
		for(ll j=0;j<=W;j++)
		{
			dp[i][j]=max(dp[i-1][j],dp[i][j]);
			if (j>=w[i])
				dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+v[i]);

			ans=max(ans,dp[i][j]);
		}

	}
	cout<<ans;
}

Measured memory_bytes: 78336
#include <stdio.h>

int main(void)
{
  int i = 0,a = 0,b = 0; 
  char S[100001];
  scanf("%s",S);
  for(i = 0;i < 100001;i++) {
    if(S[i] != '0' && S[i] != '1') break;
    if(i % 2 == 0) {
      if(S[i] != '0') a++;
      else if(S[i] != '1') b++;
    } else {
      if(S[i] != '1') a++;
      else if(S[i] != '0') b++;
    }  
  }
  if(a >= b) printf("%d",b);
  else printf("%d",a);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)

void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
} 

int main(){
   Fast_IO();
   char a;
   cin>>a;
   if(a-97<0) cout<<"A";
   else cout<<"a";
}






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



int main() {
  int K, N;
  cin >> K >> N;
  int A[N];
  rep(i,N)cin >> A[i];
  int D[N];
  rep(i,N-1){
    D[i] = A[i+1] - A[i];
  }
  D[N-1] = (K - A[N-1]) + A[0];
  int l = 0;
  rep(i,N) l = max(l,D[i]);
  int ans = K - l;
  cout << ans << endl;


	return 0;
}


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

int main(int argc, char const * argv[])
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    int countac = 0, counttle = 0, countwa = 0, countre = 0;
    for (int i = 1; i < n + 1; i++)
    {
        string s;
        cin >> s;

        if (s == "AC")
            countac++;
        if (s == "TLE")
            counttle++;
        if (s == "WA")
            countwa++;
        if (s == "RE")
            countre++;
    }
    cout << "AC x " << countac << endl;
    cout << "WA x " << countwa << endl;
    cout << "TLE x " << counttle << endl;
    cout << "RE x " << countre << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N, M;
  cin >> N >> M;
  int k;
  int tp;
  vector<vector<int>> s(M, vector<int>(0));
  for (int i = 0; i < M; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> tp;
      s[i].push_back(tp - 1);
    }
  }
  debug(s);
  vector<int> p(M);
  cin >> p;

  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bool break_flag = 0;
    bitset<10> bs(tmp);
    for (int i = 0; i < M; i++) {
      int cnt = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (bs.test(s[i][j])) cnt++;
      }
      if (cnt % 2 != p[i]) {
        break_flag = 1;
        break;
      }
    }
    if (break_flag)
      continue;
    else
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
#define ll long long
#define MOD 1000000007

long long mypow(long long k, long long n) {
	long long temp = 1;
 
	k = k % MOD;
	while (n) {
		if (n % 2) temp = temp * k % MOD;
		k = k * k % MOD;
		n = n / 2;
	}
	return temp % MOD;
}

ll f(int n) {
  if(n==0) return 1;
  ll x = f(n/2);
  x *= x;
  if(n%2==1)x*=2;
  return x;
}

long long combi(long long n, long long r) {
	long long x = 1, y = 1, y_inv;
	long long min;
 
	if (n - r > r) min = r;
	else min = n - r;
	for (long long i = 0; i < min; i++) {
		x = x * (n - i) % MOD;
		y = y * (i + 1) % MOD;
	}
	y_inv = mypow(y, MOD - 2);
	return x * y_inv % MOD;
}

int main(){
  ll n, a, b, i;
  scanf("%lld%lld%lld",&n, &a, &b);
  ll ans = (mypow(2,n)-1-combi(n,a));
  if (ans < 0)ans = (ans + MOD);
  ans = (ans-combi(n,b));
  if (ans < 0)ans = (ans + MOD);
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 128
while 1:
  n = input()
  if n==0: break
  a = 1e9
  b = 1e9
  for _ in [0]*n:
    i,h,w = map(int, raw_input().split())
    tmp = abs(w/(h/100.0)**2-22)
    if a>=tmp: a,b = tmp,i
  print b

Measured memory_bytes: 4252
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
int used[55];
int main(){
  vector<pair<int,int> > d;
  int n; cin >>n;
  std::vector<int> x(n),y(n);
  cinf(n,x,y);
  std::vector<pair<int,int> > v;
  for(int i=0;i<n;i++){
    v.push_back(make_pair(x[i],y[i]));
  }
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      d.push_back(make_pair(v[j].first-v[i].first,v[j].second-v[i].second));
    }
  }
  int ans=0;
  for(int i=0;i<d.size();i++){
    int n=d[i].first; int m=d[i].second;
    int cnt=0;
    for(int j=0;j<d.size();j++){
      if(d[j].first==n&&d[j].second==m)cnt++;
    }
    ans=max(cnt,ans);
  }
  cout << n-ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> A(a), B(b);
	rep(i, a) cin >> A[i];
	rep(i, b) cin >> B[i];
	int ans = 10000000;
	rep(i, m) {
		int x, y, c;
		cin >> x >> y >> c;
		int ansi = A[x - 1] + B[y - 1] - c;
		ans = min(ans, ansi);
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	ans = min(ans, A[0] + B[0]);
	cout << ans << endl;
}

Measured memory_bytes: 1024
A, V = map(int, input().split())                                               
B, W = map(int, input().split())                                               
T = int(input())

if A < B:
    A_res = A + V * T
    B_res = B + W * T

    if A_res >= B_res:
        print("YES")
    else:
        print("NO")

else:
    A_res = A - V * T
    B_res = B - W * T

    if A_res <= B_res:
        print("YES")
    else:
        print("NO")

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N, K;
    cin >> N >> K;
    vec d(K);
    vec A(N, 0);
    REP(i,0,K) {
        cin >> d[i];
        REP(j,0,d[i]) {
            ll a;
            cin >> a;
            --a;
            ++A[a];
        }
    }

    ll cnt = 0;
    REP(i,0,N) {
        if(A[i] == 0) ++cnt;
    }
    _PR(cnt);




    return 0;
}

/*



*/

Measured memory_bytes: 3600
#include<stdio.h>

int main(void){

    int M,N,i,A[101],hyou_sum = 0,boder,ans = 0;

    scanf("%d %d",&N,&M);
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
        hyou_sum += A[i];
    }

    for(i = 0;i < N;i++){
        if(A[i]*4*M >= hyou_sum) ans++;
    }

    (ans >= M) ? printf("Yes\n") : printf("No\n");
    return 0;
}


Measured memory_bytes: 128
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e6 + 345;
const ll MOD = 998244353;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	fre("");
	ACCELERATE;

	string s;
	cin >> s;

	int n = sz(s);
	vector<int> a(n + 2, 0), b(n + 2, 0);
	for (int i = 0; i < n; i++) {
		if (s[i] == '<') a[i+1] = a[i] + 1;
		else a[i+1] = 0;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>') b[i] = b[i+1] + 1;
		else b[i] = 0;
	}

	ll ans = 0;
	for (int i = 0; i <= n + 1; i++) ans += max(a[i], b[i]);

	cout << ans;
	return 0;
}
/*
 
*/


Measured memory_bytes: 4764
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String N;
        N = sc.next();
        int K;
        K = sc.nextInt();

        final Solver solver = new Solver();
        solver.solve(N, K);
    }
}

class Solver {
    public void solve(String N, int K) {
        final int L = N.length();
        final long[][][] dp = new long[L + 1][2][K + 1];

        // dp[i][j][k]:
        //  i 桁まで決定
        //  N 未満フラグ (0: 未満未確定, 1: 未満確定)
        //  0 でない桁が k 個
        dp[0][0][0] = 1;
        for (int i = 0; i < L; i++) {
            final int D = N.charAt(i) - '0';

            for (int j = 0; j < 2; j++) {

                for (int k = 0; k < K + 1; k++) {

                    for (int d = 0; d <= (j == 1 ? 9 : D); d++) {
                        if (d != 0 && k == K) continue;

                        boolean smaller = j == 1 || d < D;
                        int s = smaller ? 1 : 0;
                        int l = k + (d == 0 ? 0 : 1);
                        dp[i + 1][s][l] += dp[i][j][k];
                    }
                }
            }
        }

        System.out.println(dp[L][0][K] + dp[L][1][K]);
    }
}



Measured memory_bytes: 22608
#include <iostream>
#include <sstream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const double PI = 3.14159265358979323846264338327950;
const LL MOD = 1000000007;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#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)

int main(void)
{
	int N;
	cin >> N;
	PrintLn((N * (N + 1) / 2));
	return 0;
}


Measured memory_bytes: 256
h,n=map(int,input().split())

ab=[]
dp=[10**9]*(10**5)

maxA=0
for _ in range(n):
    a,b=map(int,input().split())
    dp[a]=min(dp[a],b)
    maxA=max(maxA,a)
#print(dp)
#dp[a]は、相手にaダメージを与えるときの、消耗する自分の最小HP
result=10**9
for i in range(1,h+maxA):
    #print(i,"##########")
    for k in range(1,i//2+2):
        dp[i]=min(dp[i],dp[k]+dp[i-k])
    if i>=h:
        result=min(result,dp[i])
    #print(dp)
print(result)



    
    



Measured memory_bytes: 42716
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 2e5 + 10;
vector<pair<ll,ll>> options[2][N];

int n;

void add(vector<pair<ll,ll>> opt[], int n, ll x, ll y) {
    if (x == 0 || y == 0) return;
    if (x > y) swap(x,y);
    opt[n].eb(x,y);
}

void compute(const vi &a, vector<pair<ll,ll>> opt[]) {
    int j = 0;
    ll x = 0, y = 0;
    forn(i,n) {
        y += a[i];
        while (j < i && x + a[j] < y - a[j]) {
            x += a[j];
            y -= a[j];
            j++;
        }
        add(opt, i+1, x, y);
        add(opt, i+1, x+a[j], y-a[j]);
    }
}

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

    cin >> n;
    vi a(n);
    forn(i,n) cin >> a[i];
    compute(a,options[0]);
    reverse(all(a));
    compute(a,options[1]);

//    for (int i = 1; i <= n; i++) {
//        cerr << i << ": \n";
//        for (auto xy : options[0][i])
//            cerr << xy.first << ' ' << xy.second << endl;
//    }

    ll ans = 1e18;
    for (int l = 2; l <= n-2; l++) {
        for (auto xy1 : options[0][l]) for (auto xy2 : options[1][n-l]) {
            ll x1, y1; tie(x1,y1) = xy1;
            ll x2, y2; tie(x2,y2) = xy2;
            auto s = max(y1,y2) - min(x1,x2);
            ans = min(ans, s);
        }
    }
    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 32244
using System;

namespace ALDS1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int counter = 0;
            int[] numbers = new int[n];
            string[] str = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                numbers[i] = int.Parse(str[i]);

            for (int j = 0; j < n - 1; j++)
            {
                for (int i = n - 1; j < i; i--)
                {
                    if (numbers[i] < numbers[i - 1])
                    {
                        int a = numbers[i];
                        numbers[i] = numbers[i - 1];
                        numbers[i - 1] = a;
                        counter++;
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (i == n - 1)
                {
                    Console.WriteLine("{0}", numbers[i]);
                    break;
                }
                Console.Write("{0} ", numbers[i]);
            }
            Console.WriteLine(counter);
        }   
    }
}



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

using namespace std;

long long L, R;
vector<bool> l, r;
const long long mod = 1000000007;

vector<vector<vector<vector<long long>>>> memo(60,
  vector<vector<vector<long long>>>(2,
  vector<vector<long long>>(2, 
  vector<long long>(2, -1))));

long long f(int pos, bool flagX, bool flagY, bool flagZ) {
  if (pos == -1) return 1;
  if (memo.at(pos).at(flagX).at(flagY).at(flagZ) != -1)
    return memo.at(pos).at(flagX).at(flagY).at(flagZ);

  long long ret = 0;

  if (flagX || !l.at(pos)) {
    if (r.at(pos))
      ret += f(pos - 1, flagX, 1, flagZ);
    else
      ret += f(pos - 1, flagX, flagY, flagZ);
  }

  if ((flagX || !l.at(pos)) && (flagY || r.at(pos)) && flagZ) {
    ret += f(pos - 1, flagX, flagY, flagZ);
  }

  if (flagY || r.at(pos)) {
    if (l.at(pos))
      ret += f(pos - 1, flagX, flagY, 1);
    else
      ret += f(pos - 1, 1, flagY, 1);
  }
  ret %= mod;
  memo.at(pos).at(flagX).at(flagY).at(flagZ) = ret;
  return ret;
}



int main() {
  cin >> L >> R;
  for (int i = 59; i >= 0; --i) {
    if (L & ((long long)1 << i))
      l.push_back(1);
    else
      l.push_back(0);
    
    if (R & ((long long)1 << i))
      r.push_back(1);
    else
      r.push_back(0);
  }
  reverse(l.begin(), l.end());
  reverse(r.begin(), r.end());

  long long ans = f(59, 0, 0, 0);
  cout << ans << endl;

  return 0;
}




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

long long calc(int b, vector<int> a){
    long long sum = 0;
    for(int i = 0; i < a.size(); ++i){
        sum += abs(a[i] - b);
    }
    return sum;
}
int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        a[i] -= i+1;
    }
    int b;
    sort(a.begin(),a.end());
    if(n%2 == 0) b = a[n/2 -1];
    else b = a[n/2];
    cout << calc(b,a) << endl;
    return 0;
}
//Saw the solution video

Measured memory_bytes: 4832