akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
int digitsum(int n){
  int s=0;
  while(n>0){
    s+=n%10;
    n/=10;
  }
  return s;
}

int n;
int minsum;
int main(){
  cin>>n;
  minsum=10000;
  for(int i=1;i<n/2+1;i++){
    if(minsum>digitsum(i)+digitsum(n-i))minsum=digitsum(i)+digitsum(n-i);
  }
  cout<<minsum<<endl;
}

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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

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

int main() {
	int a, n, m;
	cin >> a >> n >> m;
	int ans = 0;
	for (int y = a+1;y < 72 + a;y++) {
		int y_h = a;
		int x = pow(y, n);
		if (x > m) continue;
		rep(i,0,9) {
			ll kari = pow(10, i);
			if (x >= kari)
				y_h += (x % (kari*10) - x % kari)/kari;
			else
				break;
		}
		if (y == y_h) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3384
#include <bits/stdc++.h>
#define ll long long int
#define N 100
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.141592653
#define cot cout.tie(0)
#define endl "\n"
using namespace std;
/**
        * @author :: Sawlani
        *
        */

 

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

        ll a[n+1];
        ll b[n+1]={0};
        f(i,1,n-1)  {cin >> a[i];b[a[i]]++;
        
       }


       f(i,1,n)  
       {
           cout << b[i] << endl;
       }



         
}

Measured memory_bytes: 6760
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=4110,Mod=1e9+7;
int main(){
	int n=gi(),ans=0;
	for(int i=1;i<=n;i++){
		int x=0,tmp=i;
		while(tmp){
			x++;tmp/=10;
		}
		if(x&1)ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<list>
using namespace std;
#define ll long long
#define mod 998244353
ll n,k,f[2000005],inv[2000005],ans;
ll ksm(ll x,ll y){
	ll anss=1,t=x;
	while(y){
		if(y&1) anss=anss*t%mod;
		t=t*t%mod;
		y>>=1;
	}
	return anss;
}
ll C(ll n,ll m){
	if(n<m||m<0) return 0;
	return f[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	scanf("%lld%lld",&n,&k);
	f[0]=1;
	for(ll i=1;i<=k;i++) f[i]=f[i-1]*i%mod;
	inv[k]=ksm(f[k],mod-2);
	for(ll i=k-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(ll r=n;r<=k;r++){
		ll b=k-r;
		if(r<b) continue;
		if(r>=b+n){
			ans=(ans+C(k,r))%mod;
		}
		else ans=(mod+ans+C(r+b-(r==b),r)-C(r+b-(r==b),2*r-n+1))%mod;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 11644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(3*a*a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  ll K;
  cin >> N >> K;
  ll A;
  vector<ll> B, C, D;
  ll z = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A == 0)
      z++;
    else if (A < 0) {
      B.push_back(A);
      D.push_back(-A);
    } else
      C.push_back(A);
  }
  ll nb = B.size();
  ll nc = C.size();
  ll f0 = nb * nc;
  ll f1 = f0 + z * (nb + nc) + (z * (z - 1)) / 2;
  if (K <= f0) {
    sort(B.begin(), B.end());
    sort(C.begin(), C.end(), greater<ll>());
    ll l = -1e18 - 1ll;
    ll r = 0;
    while (r - l > 1) {
      ll m = (l + r) / 2;
      ll sum = 0;
      int j = nb;
      for (int i = 0; i < nc && sum < K; i++) {
        j = upper_bound(B.begin(), B.begin() + j, m / C[i] - (m % C[i] ? 1 : 0))
            - B.begin();
//        while (j < nc && B[i] * C[j] <= m)
//          j++;
        if (j == 0)
          break;
//        cout << i << " " << j << " " << m << endl;
        sum += j;
      }
      //cout << sum << " " << m << "\n";
      if (sum < K)
        l = m;
      else
        r = m;
    }
    cout << r << "\n";
  } else if (K <= f1) {
    cout << "0\n";
  } else {
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());
    K -= f1;
    ll l = 0, r = 1e18 + 1ll;
    ll bt = nb * 2 - 3, ct = nc * 2 - 3;
    while (r - l > 1) {
      ll m = (l + r) / 2;
      ll sum = 0;
      for (ll i = nb - 2; i >= 0 && sum < K; i--) {
        ll j = upper_bound(D.begin() + i, D.end(), m / D[i]) - D.begin();
        if (j == nb) {
          sum += (bt - i) * i / 2 + nb - 1;
          break;
        }
        sum += max(0LL, j - i - 1);
      }
      for (ll i = nc - 2; i >= 0 && sum < K; i--) {
        ll j = upper_bound(C.begin() + i, C.end(), m / C[i]) - C.begin();
        if (j == nc) {
          sum += (ct - i) * i / 2 + nc - 1;
          break;
        }
        sum += max(0LL, j - i - 1);
      }
      // cout << sum << " " << m << "\n";
      if (sum < K)
        l = m;
      else
        r = m;
    }
    cout << r << "\n";
  }
  return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;

	while (n > 0)
	{
		n /= 10;

		count++;
	}
	return count;
}
int digit(int n)
{

	int ans = 0;
	while (n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin >> n;
	int m;
	cin >> m;
	int k;
	cin>>k;
	bool ans=false;
	rep(i,n+1){
		
		rep(j,m+1){
			int bl=0;
			bl=i*m+j*n-2*i*j;
			if(bl==k){
				//cout<<i<<" "<<j<<endl;
				ans=true;
			}
		}
	}
	if(ans){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


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

int main() {
    long N = 0;
    cin >> N;
    
    int count = 0;
    for (int i = N; i > 0; i--)
    {
        if (i<10 || (i<1000 && 100<=i) || (i<100000 && 10000<=i)) {
            /* code */
            count++;
        }
    }
    printf("%d ", count);
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x
using namespace std;
const ll N = 1e5+5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a,b,c,d; cin>>a>>b>>c>>d;
  cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}


Measured memory_bytes: 3648
n,a,b = map(int,input().split())
p = 10**9 + 7
def CC(n,k):
  X,Y = 1,1
  for i in range(n-k+1,n+1):
    X = X*i%p
  for j in range(1,k+1):
    Y = Y*j%p
  YY = pow(Y,p-2,p)
  return(X*YY%p)
A = CC(n,a)
B = CC(n,b)
ALL = pow(2,n,p)
ans = (ALL-1-A-B)%p
print(ans)

Measured memory_bytes: 9208
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int c = 1;
	ll x, y;
	cin >> x >> y;
	while(2*x <= y){
		c++;
		x *= 2;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main () {
  
  int x,y,n;
  
  scanf("%d%d",&x,&y);
  if(x < y){
    n = x;
    x = y;
    y = n;
  }
  while(y != 0) {
    n = x % y;
    x = y ;
    y = n ;
  }
  printf("%d\n",x);
  return 0;
}

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

int main() {
  ll n;
  cin >> n;
  string ans;
  while (n) {
    n--;
    ans += 'a'+n%26;
    n /= 26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using namespace std;

int N;
string S;
int accE[300010];


void makeAccE(){
	if(S[0] == 'E') accE[0] = 1;
	rep(i, 1, N)
		if(S[i] == 'E') accE[i] = accE[i-1] + 1;
		else accE[i] = accE[i-1];
}


int solve(){
	int ans = accE[N-1] - accE[0];
	rep(i, 1, N-1){
		int cnt = 0;
		if(S[i] == 'E') cnt = i - accE[i] + 1;
		else cnt = i - accE[i];
		cnt += accE[N-1] - accE[i];
		ans = min(ans, cnt);
	}
	int cnt = 0;
	if(S[N-1] == 'E') cnt = N-1 - accE[N-1] + 1;
	else cnt = N-1 - accE[N-1];
	ans = min(ans, cnt);
	return ans;
}


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

	makeAccE();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1796
use proconio::input;

fn main() {
    input! {
        s: i64
    };
    let v = 1_000_000_000;
    let x = (v - (s % v)) % v;
    let y = (s + x) / v;
    println!("{} {} {} {} {} {}", 0, 0, v, 1, x, y);
}


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

list_yakusuu = []

cnt = 0
for i in range(1,N+1):
  list_yakusuu = []
  if i % 2 == 0:
    continue
    
  for j in range(1,i+1):
    if i % j == 0:
      list_yakusuu.append(j)
  
  if len(list_yakusuu) == 8:
    cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define f first
#define s second
#define ll long long int
#define PI acos(-1.0)
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int a,b;
   cin>>a>>b;
   cout<<(a+b)%24;
   return 0;
}


Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


n = ip()                              #入力整数1つ
#n,m= (int(i) for i in input().split())      #入力整数横2つ
#w,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 1
for i in range(1,n+1):
    s*=i
    s%=(pow(10,9)+7)
print(s)

Measured memory_bytes: 13628
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[200200];
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    ll cut;
    cin >> n >> cut;
    for(i=1;i<=n;i++) cin >> arr[i];
    sort(arr+1, arr+n+1);
    ll low = 1;
    ll high = arr[n];
    ll chaeng = high;
    while(low <= high) {
        ll mid = (low + high) / 2;
        ll need = 0;
        for(i=1;i<=n;i++) {
            ll potong = (arr[i]-1)/mid;
            need += potong;
        }
        if(need <= cut) {
            chaeng = min(chaeng, mid);
            high = mid - 1;
        } else low = mid + 1;
    }
    cout << chaeng << endl;
    return 0;
}


Measured memory_bytes: 5160
// Last Change:   12/09/2018 00:38:02.
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <list>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int n, a[100];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i];
  }
  cout << ans<<endl;
}



Measured memory_bytes: 3092
using System;

class Program
{
    const int MOD = 1000000007;
    static long[,] c;

    static void Main(string[] args)
    {
        initc();
        var nk = Console.ReadLine().Split();
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]);

        for (int i = 1; i <= k; i++)
        {
            var red = 0L;
            red += f(n - k, i - 1); red %= MOD;
            red += f(n - k, i); red %= MOD;
            red += f(n - k, i); red %= MOD;
            red += f(n - k, i + 1); red %= MOD;

            var ans = f(k, i) * red; ans %= MOD;
            Console.WriteLine(ans);
        }
    }

    static void initc()
    {
        c = new long[4005, 4005];
        c[0, 0] = 1;
        for (int i = 0; i <= 4000; i++)
        {
            for (int j = 0; j <= i; j++)
            {
                c[i + 1, j] += c[i, j]; c[i + 1, j] %= MOD;
                c[i + 1, j + 1] += c[i, j]; c[i + 1, j + 1] %= MOD;
            }
        }
    }

    static long f(int n, int k)
    {
        if (n < k) return 0;
        if (n == 0 && k == 0) return 1;
        if (k < 1) return 0;
        return f2(n - k, k);
    }

    static long f2(int n, int k)
    {
        return comb(n + k - 1, k - 1);
    }

    static long comb(int x, int y)
    {
        return c[x, y];
    }
}


Measured memory_bytes: 136148
#include<bits/stdc++.h>
using Int = long long;
using namespace std;
constexpr Int mod = 1e9 + 7;
template <class T> T modpow(T a, T b) {
    if (b == 0) return T(1);
    if (b % 2 == 0) {
        T d = modpow(a, b / T(2));
        return (d * d) % mod;
    } else {
        return (a * modpow(a, b - 1) % mod );
    }
}
template<class T> T mod_nCr(T n, T r, T mod ) {
    T denom = 1;
    T numer = 1;
    for (T i = 1; i <= r; i++) numer = (numer * i) % mod;
    for (T i = n - r + 1; i <= n; i++) denom = (denom * i) % mod;
    return (denom * modpow(numer, mod - 2) % mod);
}
class modcomb {
public:
    Int maxn,MOD;
    vector<Int>fac,finv,inv;
    modcomb(Int _maxn,Int _mod) : maxn(_maxn),MOD(_mod),fac(_maxn),finv(_maxn),inv(_maxn){
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < maxn; 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;
        }
    };
    Int modComb(Int n,Int k){
        if (n < k) return 0LL;
        if (n < 0 || k < 0) return 0LL;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
};
int main(){
    Int N,K; cin >> N >> K;
    Int ans = 1;
    auto C = modcomb(2 * N,mod);
    for(Int zero = 1; zero <= min(N,K);zero++){
        Int res = C.modComb(N,zero);
        Int margin = N - zero;
        res *= C.modComb(N - margin + margin - 1, margin - 1);
        ans += res;
        ans %= mod;
    }
    cout << ans << endl;
    
}





Measured memory_bytes: 9728
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let x: usize = read();

    // 動的計画法
    let mut dp = vec![false; 100001];
    // X = 0はtrue
    dp[0] = true;
    // X = 100-104はtrue
    dp[100] = true;
    dp[101] = true;
    dp[102] = true;
    dp[103] = true;
    dp[104] = true;

    // iから100~105の値を引いた添字の真偽値をチェックし、1つでもtrueが存在すればその金額は有効である。
    for i in 105..dp.len() as usize
    {
        if dp[i - 105] || dp[i - 104] || dp[i - 103] || dp[i - 102] || dp[i - 101] || dp[i - 100] { dp[i] = true; }
    }

    // 結果を出力
    if dp[x] { println!("1"); } else { println!("0"); }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
const int MOD = 1046527;
string S[MOD];
int charToInt(char c){
    if(c == 'A') return 1;
    if(c == 'C') return 2;
    if(c == 'G') return 3;
    if(c == 'T') return 4;
    return 0;
}
int getKey(string s){
    int sum = 0, p = 1;
    for(int i=0;i<s.size();++i,p*=5) sum+=p*charToInt(s[i]);
    return sum;
}
int h1(int key){return key % MOD;}
int h2(int key){return 1 + (key % (MOD - 1));}
int find(string s){
    int key = getKey(s);
    for(int i=0;;++i){
        int h = (h1(key) + i * h2(key)) % MOD;
        if(S[h] == s) return 1;
        if(S[h].size() == 0) return 0;
    }
}
void insert(string s){
    int key = getKey(s);
    for(int i=0;;++i){
        int h = (h1(key) + i * h2(key)) % MOD;
        if(S[h] == s) return;
        if(S[h].size() == 0){
            S[h] = s;
            return;
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        string s, t;
        cin>>s>>t;
        if(s == "insert") insert(t);
        if(s == "find") cout<<(find(t)?"yes":"no")<<endl;
    }
}

Measured memory_bytes: 24308
"""
python3 a.py < input.txt
"""
import math
import itertools as it
import heapq

N=int(input())
S=input()

T=[S[0]]
U=[1]
for si in S[1:]:
    if T[-1] == si:
        U[-1] = U[-1]+1
    else:
        T.append(si)
        U.append(1)
M=len(T)

B=[U[i] if T[i] == "#" else 0 for i in range(M)]
sumB=[B[0]]
for b in B[1:]:
    sumB.append(sumB[-1]+b)

W=[U[i] if T[i] == "." else 0 for i in range(M)]
sumW=[W[-1]]
for w in reversed(W[:-1]):
    sumW.append(sumW[-1]+w)
sumW=list(reversed(sumW))

l=[sum(B), sum(W)]
for i in range(M):
    if T[i] == "#":
        l.append(sumB[max(0, i-1)] + sumW[min(i+1, M-1)])

#print(S)
#print(T)
#print("U   ",U)
#print("B   ",B)
#print("sumB",sumB)
#print("W   ",W)
#print("sumW",sumW)
#print("l   ",l)
print(min(l))

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

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int count[3] = {};
	for(int i=0; i<n; i++){
		int p;
		cin >> p;
		if(p <= a) count[0]++;
		else if(p <= b) count[1]++;
		else count[2]++;
	}
	cout << *min_element(count, count+3) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    set<str> s;
    for (int i = 0; i < n; i++)
    {
        str x;
        cin >> x;
        s.insert(x);
    }
    cout << sz(s) << endl;
    GAME_OVER;
}

Measured memory_bytes: 19212
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main()
    {	
      	ios_base::sync_with_stdio(false);
		cin.tie(NULL);
        double h,n,a;
        cin>>h>>n;
        while(n--)
        {
            cin>>a;
            h-=a;
        }
        if(h<=0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX],n;
int op1()
{
    int ans=0;
    int cnt=0,x=0,y=0;
    map<int,int>mp;
    set<int>s;
    vector<pair<int,int> >v;
    for(int i=0; i<n; i+=2)
    {
        mp[arr[i]]++;
        s.insert(arr[i]);
    }
    for(auto it:s)
        v.push_back({mp[it],it});
    sort(all(v));
    reverse(all(v));
    int X;
    ans=(n/2)-v[0].first;
    X=v[0].second;
    v.clear();
    s.clear();
    mp.clear();
    for(int i=1; i<n; i+=2)
    {
        mp[arr[i]]++;
        s.insert(arr[i]);
    }
    for(auto it:s)
        v.push_back({mp[it],it});
    sort(all(v));
    reverse(all(v));
    if(v[0].second==X)
    {
        if(v.size()==1)
            ans+=n/2;
        else
            ans+=(n/2)-v[1].first;
    }
    else
    {
        ans+=(n/2)-v[0].first;
    }
    return ans;
}
int op2()
{
    int ans=0;
    int cnt=0,x=0,y=0;
    map<int,int>mp;
    set<int>s;
    vector<pair<int,int> >v;
    for(int i=1; i<n; i+=2)
    {
        mp[arr[i]]++;
        s.insert(arr[i]);
    }
    for(auto it:s)
        v.push_back({mp[it],it});
    sort(all(v));
    reverse(all(v));
    int X;
    ans=(n/2)-v[0].first;
    X=v[0].second;
    v.clear();
    s.clear();
    mp.clear();
    for(int i=0; i<n; i+=2)
    {
        mp[arr[i]]++;
        s.insert(arr[i]);
    }
    for(auto it:s)
        v.push_back({mp[it],it});
    sort(all(v));
    reverse(all(v));
    if(v[0].second==X)
    {
        if(v.size()==1)
            ans+=n/2;
        else
            ans+=(n/2)-v[1].first;
    }
    else
    {
        ans+=(n/2)-v[0].first;
    }
    return ans;

}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }

    cout<<min(op1(),op2())<<endl;

    return 0;
}


Measured memory_bytes: 9080
#include<stdio.h>

int main(){
		int n,i,a[100000],ans=0;
		scanf("%d",&n);
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		int f[100000]={0},ff[50000],c=0;
		for(i=0;i<n;i++){
				if(a[i]==i+1)f[i]=1;
		}
		for(i=0;i<n;i++){
				int tmp=0;
				while(f[i]==1){
						tmp++;
						i++;
				}
				ff[c++]=tmp;
		}
		for(i=0;i<c;i++)ans+=(ff[i]+1)/2;
		printf("%d\n",ans);
		return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>

#include <vector>
#include <algorithm>
#include <unordered_set>
#include <climits>

using Set = std::unordered_set<uint32_t>;

void FindAndUpdate(int key, Set* o) {
  auto find = o->find(key);
  if (find == o->end()) {
    o->insert(key);
  }
}

int main() {
  uint32_t n = 0;
  scanf("%d", &n);

  uint32_t a = 0;
  uint32_t i = 0;
  Set o;
  uint32_t free = 0;
  while (std::cin >> a) {
    if (a >= 1 && a <= 399) {
      FindAndUpdate(1, &o);
    } else if (a >= 400 && a <= 799) {
      FindAndUpdate(2, &o);
    } else if (a >= 800 && a <= 1199) {
      FindAndUpdate(3, &o);
    } else if (a >= 1200 && a <= 1599) {
      FindAndUpdate(4, &o);
    } else if (a >= 1600 && a <= 1999) {
      FindAndUpdate(5, &o);
    } else if (a >= 2000 && a <= 2399) {
      FindAndUpdate(6, &o);
    } else if (a >= 2400 && a <= 2799) {
      FindAndUpdate(7, &o);
    } else if (a >= 2800 && a <= 3199) {
      FindAndUpdate(8, &o); 
    } else {
      free++;
    }

    i++;
    if (i >= n) {
      break;
    }
  }

  uint32_t max = uint32_t(o.size()) + free;
  uint32_t min = std::max(uint32_t(o.size()), uint32_t(1));

  std::cout << min << " " << max << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>

int main(void)
{
	unsigned long long n;
	unsigned long long a;
	unsigned long long b;

	scanf("%llu %llu %llu", &n, &a, &b);

	unsigned long long res;
	res = (n / (a + b)) * a;
	res += (n % (a + b) > a ? a : (n % (a + b)));
	printf("%llu", res);
	return (0);
}



Measured memory_bytes: 128
#include <stdio.h>

using namespace std;

int main(){
	int m,f,r;
	char grade;
	while(true){
		scanf("%d %d %d",&m,&f,&r);
		if(m == -1 && f == -1 && r == -1) break;
		if(m == -1 || f == -1){
			grade = 'F';
		}else if(m+f >= 80){
			grade = 'A';
		}else if(m+f >= 65){
			grade = 'B';
		}else if(m+f >= 50){
			grade = 'C';
		}else if(m+f >= 30){
			grade = (r >= 50)? 'C':'D';
		}else{
			grade = 'F';
		}
		printf("%c\n",grade);
	}
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n;
const int maxn = 2e5 + 5;
pi a[maxn];
int pre[maxn], suf[maxn];
int id[maxn], tot;

int dp[maxn];
int sum[maxn];
const int mod = 1e9 + 7;

void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i].fi >> a[i].se;
        id[++tot] = a[i].se;
    }
    sort(a + 1, a + 1 + n);
    sort(id + 1, id + 1 + n);
    for(int i = 1;i <= n;i++){
        a[i].se = lower_bound(id + 1, id + 1 + n, a[i].se) - id;
    }
    pre[0] = 0;
    for(int i = 1;i <= n;i++){
        pre[i] = max(pre[i - 1], a[i].se);
    }
    suf[n + 1] = n + 1;
    for(int i = n;i >= 1;i--){
        suf[i] = min(suf[i + 1], a[i].se);
    }
    dp[n + 1] = 1;
    sum[n + 1] = 1;
    int j = n + 1;
    for(int i = n;i >= 1;i--){
        while(j > i and suf[j] > pre[i] + 1){
            j--;
        }
        int delta = (sum[i + 1] - sum[j + 1] + mod) % mod;
        dp[i] = delta;
        sum[i] = sum[i + 1];
        add(sum[i], dp[i]);
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if(suf[i] == suf[1]){
            add(ans, dp[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int	main() {
	string S;
	cin >>S;
	int s=0;
	for (int i=1; i<S.size(); i++)
		if (S.at(i)!=S.at(i-1))
			s++;
	cout <<s <<endl;
	return 0;
};


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

signed main(){
	int N; string S; cin>>N>>S;
	map<char,set<int>> dic;
	for(char i='a';i<='z';i++){
		set<int> tmp;
		dic[i]=tmp;
	}
	for(int i=0;i<N;i++){
		dic[S[i]].insert(i);
	}
	int Q; cin>>Q;
	for(int i=0;i<Q;i++){
		int a; cin>>a;
		if(a==1){
			int i; char c; cin>>i>>c; i--;
			if(S[i]!=c){
				dic[S[i]].erase(i);
				dic[c].insert(i);
				S[i]=c;
			}
		}
		else if(a==2){
			int l,r; cin>>l>>r; l--; r--;
			int ans=0;
			for(char p='a';p<='z';p++){
				if(dic[p].size()==0)continue;
				int tmp=*dic[p].lower_bound(l);
				if(l<=tmp && tmp<=r && dic[p].lower_bound(l)!=dic[p].end())ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 24196
n = int(input())

p = list(map(int,input().split()))

ans = 0

for i in range(2,n):
    #i-1が二番目に小さい
    if p[i-2] > p[i-1] > p[i] or p[i] > p[i-1] > p[i-2]:
        ans += 1

print(ans)


Measured memory_bytes: 2940
N=int(input())
S=input()
alphabet = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
out=[]
for s in S:
    index = alphabet.index(s)
    new_index = (index+N)%len(alphabet)
    new_s = alphabet[new_index]
    out.append(new_s)
print(''.join(out))



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

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int n = 0;
	std::cin >> n;

	unsigned long long pro = 1;
	for (int i = n; i >= 1; i--) {
		pro *= i;
	}

	std::cout << pro << std::endl;

}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL H, W; cin >> H >> W;
		bool S[20][20] = {};
		rep(y, H) {
			rep(x, W) {
				char c; cin >> c;
				if (c == '.') S[x][y] = true;
			}
		}
		UL ans = 0;
		rep(sy, H) {
			rep(sx, W) {
				UL D[20][20];
				rep(y, H) rep(x, W) D[x][y] = (UL)-1;
				queue<pair<pair<UL, UL>, UL>> q;
				q.push({ {sy,sx}, 0 });
				while (q.size()) {
					auto p = q.front(); q.pop();
					UL x = p.first.first, y = p.first.second;
					if (x == (UL)-1 || y == (UL)-1) continue;
					if (x >= W || y >= H) continue;
					if (D[x][y] != (UL)-1) continue;
					if (!S[x][y]) continue;
					UL d = p.second;
					ans = max(ans, d);
					D[x][y] = d;
					q.push({ {x + 1,y}, d + 1 });
					q.push({ {x - 1,y}, d + 1 });
					q.push({ {x,y + 1}, d + 1 });
					q.push({ {x,y - 1}, d + 1 });
				}
			}
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
while True:
    N,Q=map(int,raw_input().split())
    if N==Q==0:break
    T=[0]*101
    for i in range(N):
        L=map(int,raw_input().split())
        for j in L[1:]:
            T[j]+=1
    m=max(T)
    print 0 if m<Q else T.index(m)

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

using namespace std;

int main(){
	int n;
	cin >> n;
	string ans = "";
	while(n != 0){
		int t;
		if(n % 2 == 0){
			t = 0;
		}else{
			t = 1;
		}
		if(t == 0){
			ans = "0" + ans;
		}else{
			ans = "1" + ans;
		}
		n = (n - t) / -2;
	}
	if(ans == "") ans = "0";
	cout << ans << endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    
    char a[201],b[201];
    int i,h,m;
    
    while(1){
        scanf("%s",a);
        if(strcmp(a,"-") == 0)break;
        strcpy(b, a);
        scanf("%d",&m);
        
        for(i=0; i<m; i++){
            scanf("%d",&h);
            strcpy(a, &b[h]);
            strncpy(&a[strlen(a)], b, h);
            strcpy(b, a);
        }
        printf("%s\n",a);
        
    }
    return 0;
}



Measured memory_bytes: 2040
// agc044_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int dx[8]={ 1, 0, -1, 0, -1, 1, -1, 1};
int dy[8]={ 0, 1, 0, -1, -1, -1, 1, 1};
bool bound_check(int i, int j, int N, int M) {return (0 <= i) && (i < N) && (0 <= j) && (j < M);}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N*N);
    REP(i, N*N) {cin >> A[i]; A[i]--;}

    vector<vector<int>> D(N, vector<int>(N, 0));
    REP(i, N) REP(j, N){
        D[i][j] = min(min(i, j), min(N-i-1, N-j-1));
    }

    vector<vector<bool>> occupied(N, vector<bool>(N, true));
    int ans = 0;
    REP(x, N*N){
        int xi = A[x] / N;
        int xj = A[x] % N;

        ans += D[xi][xj];
        occupied[xi][xj] = false;
        queue<P> q;
        q.emplace(xi, xj);
        while (not q.empty()){
            P p = q.front(); q.pop();
            int i = p.first;
            int j = p.second;
            REP(k, 4){
                int ni = i + dx[k];
                int nj = j + dy[k];
                if (not bound_check(ni, nj, N, N)) continue;
                if (D[i][j] + occupied[i][j] < D[ni][nj]){
                    D[ni][nj] = D[i][j] + occupied[i][j];
                    q.emplace(ni, nj);
                }
            }
        }
    }

    print(ans);


    return 0;
}


Measured memory_bytes: 5264
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
#define INF 99999999
typedef pair<int, int> P;
typedef pair<P, int> PP;
struct Edge
{
	int to;
	int cost;
};

void solve()
{
	int c, n, m, s, d;
	while(cin >> c >> n >> m >> s >> d, c || n || m || m || s)
	{
		vector<Edge> V[101];
		for(int i = 0; i < m; ++i)
		{
			int from, to, cost;
			cin >> from >> to >> cost;
			--from; --to;
			Edge e1 = {to, cost};
			Edge e2 = {from, cost};
			V[from].push_back(e1);
			V[to].push_back(e2);
		}
		vector< vector<int> > dist(n, vector<int>(c + 1));
		for(int i = 0; i < dist.size(); ++i)
		{
			for(int j = 0; j < dist[i].size(); ++j)
			{
				dist[i][j] = INF;
			}
		}
		priority_queue<PP, vector<PP>, greater<PP> > pq;
		--s;
		dist[s][0] = 0;
		pq.push(PP(P(0, s), 0));
		while(!pq.empty())
		{
			PP pp = pq.top();
			pq.pop();
			int v = pp.first.second;
			int ticket = pp.second;
			if(dist[v][ticket] < pp.first.first)
			{
				continue;
			}
			for(int i = 0; i < V[v].size(); ++i)
			{
				Edge e = V[v][i];
				if(dist[e.to][ticket] > pp.first.first + e.cost)
				{
					dist[e.to][ticket] = pp.first.first + e.cost;
					pq.push(PP(P(dist[e.to][ticket], e.to), ticket));
				}
				if(ticket < c && dist[e.to][ticket + 1] > pp.first.first + e.cost / 2)
				{
					dist[e.to][ticket + 1] = pp.first.first + e.cost / 2;
					pq.push(PP(P(dist[e.to][ticket + 1], e.to), ticket + 1));
				}
			}
		}
		int min_cost = INF;
		for(int i = 0; i <= c; ++i)
		{
			if(min_cost > dist[d - 1][i])
			{
				min_cost = dist[d - 1][i];
			}
		}
		cout << min_cost << endl;
	}
}

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

Measured memory_bytes: 1260
def resolve():
    a, b = map(int, input().split())
    input_data = [int(_) for _ in input().split()]
    input_data.sort(reverse=True)
    sum_data = sum(input_data)
    converge = sum_data * (1 / (4 * b))

    if(converge > input_data[b - 1]):
        print("No")
    else:
        print("Yes")
resolve()

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
n = int(input())
x = [[] for _ in range(200001)]
y = [[] for _ in range(200001)]
z = [[] for _ in range(800002)]
w = [[] for _ in range(800002)]
t = float("inf")
for _ in range(n):
  xi,yi,ui = map(str,input().split())
  xi = int(xi)
  yi = int(yi)
  if ui == "U":
    x[xi].append((yi,1))
    z[xi+yi].append((xi,-1))
    w[xi-yi+200001].append((xi,1))
  elif ui == "D":
    x[xi].append((yi,-1))
    z[xi+yi+400001].append((xi,1))
    w[xi-yi+600001].append((xi,-1))                       
  elif ui == "R":
    y[yi].append((xi,1))
    z[xi+yi].append((xi,1))
    w[xi-yi+600001].append((xi,1))  
  else:
    y[yi].append((xi,-1))
    z[xi+yi+400001].append((xi,-1))
    w[xi-yi+200001].append((xi,-1)) 
for xx in x:
  if len(xx) >= 2:
    xx.sort(key=lambda a:a[0])
    n = -1
    for i in range(len(xx)):
      if xx[i][1] == 1:
        n = xx[i][0]
      else:
        if n != -1:
          if (xx[i][0] - n)*5 < t:
            t = (xx[i][0] - n)*5
          n = -1 
for xx in y:
  if len(xx) >= 2:
    xx.sort(key=lambda a:a[0])
    n = -1
    for i in range(len(xx)):
      if xx[i][1] == 1:
        n = xx[i][0]
      else:
        if n != -1:
          if (xx[i][0] - n)*5 < t:
            t = (xx[i][0] - n)*5
          n = -1 
for xx in z:
  if len(xx) >= 2:
    xx.sort(key=lambda a:a[0])
    n = -1
    for i in range(len(xx)):
      if xx[i][1] == 1:
        n = xx[i][0]
      else:
        if n != -1:
          if (xx[i][0] - n)*10 < t:
            t = (xx[i][0] - n)*10
          n = -1 
for xx in w:
  if len(xx) >= 2:
    xx.sort(key=lambda a:a[0])
    n = -1
    for i in range(len(xx)):
      if xx[i][1] == 1:
        n = xx[i][0]
      else:
        if n != -1:
          if (xx[i][0] - n)*10 < t:
            t = (xx[i][0] - n)*10
          n = -1 
if t == float("inf"):
  print("SAFE")
else:
  print(t)

Measured memory_bytes: 214652
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
const int M = 1e5 + 10;
vector<int>vc[M];
int n;
int dfs1(int u , int pre , int pos) {
    int len = vc[u].size();
    if(u == n) return M;
    int sum = 1;
    for(int i = 0 ; i < len ; i++) {
        int v = vc[u][i];
        if(v == pre) continue;
        int gg = dfs1(v , u , pos);
        if(u == pos) {
            if(gg < M) sum += gg;
        }
        else sum += gg;
        //cout << u << ' ' << sum << endl;
    }
    return sum;
}
int pr[M];
void dfs(int u , int pre) {
    int len = vc[u].size();
    if(u == n) return ;
    for(int i = 0 ; i < len ; i++) {
        int v = vc[u][i];
        if(v == pre) continue;
        dfs(v , u);
        pr[v] = u;
    }
}
int main() {
    scanf("%d" , &n);
    for(int i = 1 ; i < n ; i++) {
        int u , v;
        scanf("%d%d" , &u , &v);
        vc[u].push_back(v);
        vc[v].push_back(u);
    }
    dfs(1 , -1);
    int count = 0;
    int pos = n;
    while(pr[pos] != 1) {
        count++;
        pos = pr[pos];
    }
    pos = n;
    int cnt = 0;
    while(pr[pos] != 1) {
        pos = pr[pos];
        if(cnt >= count / 2) break;
        cnt++;
    }
    //cout << pos << endl;
    int num1 , num2;
    if(pos == n) pos = 1;
    num1 = dfs1(pos , -1 , pos);
    num2 = n - num1;
    //cout << num1 << ' ' << num2 << endl;
    if(num1 <= num2) printf("Snuke\n");
    else printf("Fennec\n");
    return 0;
}

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

int main(){
   double a;   cin >>a;
   cout << fixed << setprecision(8);
   cout << a/3.0*a/3.0*a/3.0<< endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c - '0';}

// TODO: write
int main() { 
  int n,a,b;cin>>n>>a>>b;
  string s;cin>>s;
  int horeigner = 0;
  int now = 0;
  rep(i,n){
    if(s[i] == 'a'){
      if(now < a+b){
        print("Yes");
        now++;
        continue;
      }
    }else if(s[i] == 'b'){
      if(now < a+b && horeigner < b){
        print("Yes");
        now++;
        horeigner++;
        continue;
      }
    }
    print("No");
  }
  return 0;
}

Measured memory_bytes: 896
#!/usr/bin python3
# -*- coding: utf-8 -*-

H, W = map(int,input().split())

INF = -1
Gmap = [list(input()) for _ in range(H)]
Seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}
init_q =[]

from collections import deque

def bfs(sth, stw):
    black = 1
    white = 0
    next_q = deque([])
    next_q.append((sth, stw))
    while len(next_q)!=0:
        #キュー取り出し(先頭)
        h, w = next_q.popleft()
        Seen[h][w] = 0
        for d in direc:
            hs, ws = h + d[0], w + d[1]
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[h][w]=='#' and Gmap[hs][ws]=='.' and Seen[hs][ws]==INF:
                Seen[hs][ws]=0
                next_q.append((hs, ws))
                white +=1
            if Gmap[h][w]=='.' and Gmap[hs][ws]=='#' and Seen[hs][ws]==INF:
                Seen[hs][ws]=0
                next_q.append((hs, ws))
                black +=1
#        print(black,white)
    return black * white

def main():
    #複数
    ret = 0
    for sth in range(H):
        for stw in range(W):
            if Gmap[sth][stw]=='#' and Seen[sth][stw]==INF:
                x = bfs(sth, stw)
#                print(sth,stw ,x)
                ret += x
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 11992
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

int gcd(int a, int b){
    if (b == 0) {
        return a;
    }
    return gcd(b, a%b);
}

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

void solve(){
    int N, A, B;
    cin >> N >> A >> B;

    string S;
    cin >> S;

    int a = 0, b = 0;
    int pass = 0;
    for (int i = 0; i < (int)S.size(); i++) {
        if (S[i] == 'a') {
            if (pass < A + B) {
                pass++;
                a++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else if(S[i] == 'b'){
            if (pass < A + B && b+1 <= B) {
                pass++;
                b++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }
    
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 896