akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  int n;
  cin>>n;
  vector<double> v(n);
  double sum=0.0;
  rep(i,n) {
    cin >> v[i];
    sum+=v[i];
  }
  double x = (double)sum /n;
  double ans = 10000.0;
  int res;
  rep(i,n){
    if(ans > abs(x-v[i])){
      ans = abs(x-v[i]);
      res = i;
    }
  }
  cout<<res<<endl;
}


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

int main(){
   char s[99];
   scanf("%s",s);
   int n = strlen(s),i;
   int x = 1;
   if(n%2!=0){
      printf("No");
      return 0;
   }
   for(i = 0; i < n; i++){
      if((i+1)%2==1 && s[i]!='h'){
         x = 0;
         break;
      }else if((i+1)%2==0 && s[i]!= 'i'){
         x = 0;
         break;
      }
   }
   
   if(x == 0){
   printf("No");
   }else{
      printf("Yes");
   }
   return 0;
}


Measured memory_bytes: 128
//JSD
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define Mod 1000000007
#define ld long double 
#define ll long long 
using namespace std;
ll modular_exponentiation(ll a,ll b){	
	if(b==0){
		return 1;
	}
	if(b==1){
		return a%Mod;
	}
	ll x=modular_exponentiation(a,b/2);
	x=(x*x)%Mod;	
	if(b%2==1){
		x=(x*a)%Mod;
	}
	return x;
}
ll modular_divison(ll a,ll b){
    return (modular_exponentiation(b,Mod-2)*a)%Mod;	
}
int main(){	
	ll n;
	cin>>n;
	vector<pair<ll ,ll > >  v;
	
	ld d=0;
	for(int i=0;i<n;i++){
		ll p,q;
		cin>>p>>q;
		v.push_back({p,q});
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){			
			ld p=sqrt((v[i].first-v[j].first)*(v[i].first-v[j].first)+(v[i].second-v[j].second)*(v[i].second-v[j].second));
			d+=p;			
		}
	}	
	d*=2;
	d/=n;
	cout<<fixed<<setprecision(6)<<d<<"\n";	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const int INF = 1e9;
const int MOD = 1e9+7;

struct fl{
    string name;
    ll cost, p;
    double x;
    int a, b, c, d, e, f, s, m;
    bool operator < (const fl &r)const{
        if(abs(x - r.x) < 1e-8) return name < r.name;
        return x > r.x;
    }
};

fl input(){
    fl f;
    cin >> f.name >> f.p >> f.a >> f.b >> f.c >> f.d >> f.e >> f.f >> f.s >> f.m;
    f.cost = (ll)f.m * f.f * f.s;
    f.cost -= f.p;
    int t = f.a + f.b + f.c + (f.d + f.e) * f.m;
    f.x = (double)(f.cost) / t;
    return f;
}

int main(void){
    int n;
    while(cin >> n, n){
        vector<fl> fls(n);
        REP(i, n){
            fls[i] = input(); 
        }
        sort(ALL(fls));
        REP(i, n){
            cout << fls[i].name << endl;
        }
        cout << "#" << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<char, ll> c;
    ll ans = 1;
    for (int i = 0; i < n; ++i) {
        c[s[i]]++;
    }
    for (auto &&j : c) {
        (ans *= j.second+1) %= MOD;
    }
    (ans += MOD-1) %= MOD;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		Stack<Integer> s = new Stack<Integer>();
		while(sc.hasNext()){
			int car = sc.nextInt();
			if(car==0)System.out.println(s.pop());
			else s.push(car);
		}
	}
}

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

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

    if (N == 0)
    {
        cout << X << endl;
        exit(0);
    }

    vector<int> vec(N);
    for (int i = 0; i < N; i++)
    {
        cin >> vec[i];
    }

    int count = 0;

    while(1)
    {
        for (int i = 0; i < N; i++)
        {
            if (vec[i] == X - count)
            {
                break;
            }
            if (i == N-1)
            {
                cout << X - count << endl;
                exit(0);
            }
        }

        for (int i = 0; i < N; i++)
        {
            if (vec[i] == X + count)
            {
                break;
            }
            if (i == N-1)
            {
                cout << X + count << endl;
                exit(0);
            }
        }
        count ++;
    }
}

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

int main(){
  int n;
  string s = "APPROVED";
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  for(int i=0; i<n; i++){
    if(a.at(i)%2 == 0){
    	if(a.at(i)%3 != 0 && a.at(i)%5 !=0){
          s="DENIED";
        }
    }
  }
  cout << s << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	long long H,N,m,ans=0;
	cin>>H>>N;
	for(int i=1;i<=N;i++)	
	{
		cin>>m;	
		ans+=m;
	}
	if(ans>=H)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
	long long a,b,c,d,x,y;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	x = a * b;
	y = c * d;
	if(x > y)
		printf("%lld\n",x);
	else
		printf("%lld\n",y);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int n, a, b;
  ll ans = 0;
  cin >> n >> a >> b;
  REP(i, n+1){
    int tmp = digsum(i);
    if(a <= tmp && tmp <= b) ans += i;
  }
  cout << ans << endl;
}



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

int main(void)
{
  int n, d;
  scanf("%d %d", &n, &d);
  int x[n][d];
  for (int i = 0; i < n; i++){
    for (int j = 0; j < d; j++){
      scanf("%d", &x[i][j]);
    }
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++){
    for (int j = i + 1; j < n; j++){
      int sum = 0;
      double dist;
      for (int k = 0; k < d; k++){
        sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      dist = sqrt((double) sum);
      if (dist - (int) dist == 0) ans++;
    }
  }
  printf("%d\n", ans);
  
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	long long k;
	cin >> n >> k;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}

	long long tel = 1;
	long long next = a[0];
	vector<long long> f(n, -1);
	f[0] = 0;
	f[a[0]] = 1;
	while (1) {
		tel++;
		next = a[next];
		if (f[next] != -1) {
			break;
		} else {
			f[next] = tel;
		}
	}
	if (tel < k) {
		k -= f[next];
		k %= (tel - f[next]);
		k += f[next];
	}
	
	long long ans = 0;
	for (int i = 0; i < k; i++) {
		ans = a[ans];
	}
	cout << ans + 1 << endl;

	return 0;
}

Measured memory_bytes: 6432
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D

// g++ -std=c++11 file_name.cpp
// ./file_name.out
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((int) a.size())
typedef long long ll ;
const int MAXN = 5*1e5 + 10;
int main (){
    
    
    int N , M ;
    cin >> N >> M ;
    vector<ll> a(N + 1) ;
    for(int i = 1; i <=N ;i++)
        cin >> a[i] ;
    a[0] =0 ;
    sort(a.begin(),a.end());
    priority_queue<pair<ll,ll>> pq ;
    for(int i = 1 ; i <= M ;i++){
        ll B , C ;
        cin >> B >> C ;
        pq.push(mk(C , B)) ;
    }
    ll pre[N + 1] ;
    pre[0] = 0 ;
    for(int i = 1 ; i <= N ;i++)
        pre[i] = pre[i - 1] + a[i] ;
    
    int index = 0;
    ll sum =0 ;
    for(int i =0 ; i <= N ;i++)
        sum+=a[i] ;
    //cout<<sum<<endl;
    while(pq.empty() == false) {
        pair<ll,ll> p  = pq.top() ;
        pq.pop() ;
        vector<ll> :: iterator it = upper_bound(a.begin(),a.end(),p.F) ;
        int pos = int(it - a.begin()) ;
        if(pos <= index || pos == 1) continue ;
        else{
            //cout<<pos<<endl;
            pos-- ;
            ll len = pos - index + 1;
            
            if(len > p.S)
                pos = (int)(index + p.S) ;
            ll exp = pre[pos] - pre[index] ;
            //cout<<len<<" "<<exp<<" "<<p.F<<" "<<p.S<<endl;
            sum-=exp ;
            sum+=(pos - index)*1LL*p.F ;
            index = pos ;
        }
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
    return 0 ;
}


Measured memory_bytes: 3440
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <cstring>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/
ll N, L, Q;
vector<ll> X(100010);
ll Next[100010][20];
int main(){
  cin >> N;
  X.resize(N);

  rep(i, N) cin >> X[i];
  X.pb(INFL);
  cin >> L;
  rep(i, N){
    Next[i][0] = upper_bound(X.begin(), X.end(), X[i] + L) - X.begin() - 1;
  }

  for(ll j = 1; j < 20; j++){
    rep(i, N){
      Next[i][j] = Next[Next[i][j-1]][j-1];
    }
  }

  cin >> Q;
  rep(i, Q){
    ll a, b;
    cin >> a >> b;
    a--, b--;
    if(a > b) swap(a, b);
    ll ok = N, ng = 0;
    while(ok - ng > 1){
      ll mid = (ok + ng) / 2;
      ll now = a;
      rep(j, 20){
        if((mid >> j) & 1){
          now = Next[now][j];
        }
      }
      if(now >= b) ok = mid;
      else ng = mid;
    }
    cout << ok << endl;
  }
}


Measured memory_bytes: 17280
#include<bits/stdc++.h>
	
using namespace std;
string st;
int P;
int main()
{
	cin>>st;
	for(int i=0;i<st.length();i++)
	{
		if(st[i]==67)P=1;
		else if(P==1&&st[i]==70){P=2;break;}
	}
	if(P==2)cout<<"Yes\n";
	else cout<<"No\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
void sort(int *a,int n)
{
int k,i,j;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]<a[j])
{
k=a[i];
a[i]=a[j];
a[j]=k;
}
}
}
return ;
}
int main()
{
int a[10];
int i;
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}

sort(a,10);

for(i=0;i<3;i++)
{
printf("%d\n",a[i]);
}
return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(int i=a; i<b; i++)
#define loopb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	lli n;
	cin>>n;
	loop(i, 1, 10){
		if(n%i == 0 && n/i < 10 && n/i > 0){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

    ll N = 0;
    cin >> N;
    vector<pair<ll, ll > > a;
    //map<ll >

    for(ll i = 0; i < N; i++){
        ll in = 0;
        cin >> in;
        a.push_back(make_pair(in, i));
    }

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

    vector<ll > ans(N);

    for(ll i = 0; i < N; i++){
        if(i < N / 2){
            //ans += a[N / 2 + 1];
            ans[a[i].second] = a[N / 2].first;
        }else{
            //ans += a[N / 2];
            ans[a[i].second] = a[N / 2 -1].first;
        }
    }

    //表示
    for(ll i = 0; i < N; i++){
        cout << ans[i] << endl;
    }

    //cout << ans << endl;



} 

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  vector<bool> hh(h,0), ww(w,0);
  rep(i,h) rep(j,w){
    cin >> a.at(i).at(j);
    if(a.at(i).at(j) == '#'){
      hh.at(i) = 1;
      ww.at(j) = 1;
    }    
  }
  rep(i,h){
    rep(j,w) if(hh.at(i) && ww.at(j)){
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int N, K, T, U, V, L;
  cin >> N >> K >> T >> U >> V >> L;
  int D[N];
  for(int i = 0; i < N; ++i)
    cin >> D[i];
  int t = 0, s = 0, r = 0, f = 0;
  for(int i = 0; i <= L; ++i){
    if(r > 0){
      ++f;
      --r;
    }
    if(t < N && D[t] == i){
      ++t;
      ++s;
    }
    if((r == 0 && s > 0) || s > K){
      r = T*V;
      --s;
    }
  }
  printf("%.10f\n",(double)f/V + (double)(L-f)/U);
  return 0;
}

Measured memory_bytes: 3228
s = input()
ans = 0
n = len(s)
prev = ""
now = 0
while now<n:
    if prev != s[now]:
        prev = s[now]
        now += 1
    else:
        if now != n-1:
            now += 2
            prev = ""
        else:
            break
    ans += 1
print(ans)

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(all(l));
    int sum = 0;
    rep(i,n-1){
        sum += l[i];
    }
    if(sum > l[n-1]) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dp[50][50][2502],n,a,ar[50] ;
int fun(int id , int ct , int sm)
{
    if(id==n)
    {
        if(ct && sm%ct==0 && sm/ct==a) return 1 ;
        return 0 ;
    }
    if(dp[id][ct][sm]!=-1) return dp[id][ct][sm] ;
    int x=fun(id+1,ct+1,sm+ar[id]) ;
    int y=fun(id+1,ct,sm) ;
    return dp[id][ct][sm]=(x+y) ;
}
int32_t main()
{
    memset(dp,-1,sizeof(dp)) ;
    cin>>n>>a ;
    for(int i = 0 ; i < n ; i++) cin>>ar[i] ;
    int ans=fun(0,0,0) ;
    cout<<ans<<endl ;
}


Measured memory_bytes: 52476
import math
sentinel = 1e9 + 1
counter = 0
def merge(a, left, mid, right):
    global counter
    L = a[left:mid] + [sentinel]
    R = a[mid:right] + [sentinel]
    i,j = 0,0
    for k in range(left, right):
        if(L[i] <= R[j]):
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1
    counter += right - left
def mergeSort(a, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(a, left, mid)
        mergeSort(a, mid, right)
        merge(a, left, mid, right)


n = int(input())
a = list(map(int, input().split()))
mergeSort(a, 0, n)
print(*a)
print(counter)



Measured memory_bytes: 65832
n = int( raw_input( ) )
dic = {}
output = []
for i in range( n ):
	cmd, word = raw_input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		try:
			dic[ word ]
			output.append( "yes" )
		except KeyError:
			output.append( "no" )

print( "\n".join( output ) )

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

int main(){
  int n;
  cin>>n;
  while(n--){
    int cnt=0;
    string m;
    cin>>m;
    for(;m.size()!=1;cnt++){
      //cout<<m.size()<<endl;
      int len=m.size();
      int temp=(m[len-1]-'0')+(m[len-2]-'0');
      if(temp/10) m[len-2]= temp/10+'0',m[len-1]=temp%10+'0';
      else m[len-2] = (temp+'0'),m = m.substr(0,len-1);
    }
    if(cnt%2==0) cout<<"Audrey wins."<<endl;
    else cout<<"Fabre wins."<<endl;

  }
  return 0;
}

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


using namespace std;
using ll = long long;
const int INF = 1000000009;
const ll LINF = 1e18;

int cal_digit(ll n) {
    int rtn = 0;
    while (n) {
        ++rtn;
        n /= 10;
    }
    return rtn;
}

int main() {
    ll n;
    cin >> n;
    int rtn = INF;
    for (ll a = 1; a * a <= n; ++a) {
        if (n % a == 0) {
            ll b = n / a;
            int t_dig = max(cal_digit(a), cal_digit(b));
            rtn = min(rtn, t_dig);
        }
    }
    cout << rtn << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;
 
int main(){
size_t n_count=0;
int H[3];  
    for(int i = 0; i < 3; i++)
    cin>>H[i];

  for(int i = 0; i < 3; i++){
    if(n_count <= count(H, H+(sizeof(H)), H[i]))
    n_count = count(H, H+(sizeof(H)), H[i]);    
  }

  if (2 == n_count){
  cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


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

int main() {
  int n;
  cin >> n;
  bool flug = false;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    if (s == "Y"){
	  flug = true;
    }
  }
  if (flug) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
inline void Rd(int &res){
	char c;res=0;
	while(c=getchar(),c<'0');
	do{
		res=(res<<1)+(res<<3)+(c^48);
	}while(c=getchar(),c>='0');
}
const int M=(int)2e5+5;
int n,A[M],B[M];
int main(){
	Rd(n);
	for(int i=1;i<=n;i++)Rd(A[i]);
	if(n&1){
		int L=n/2+1,R=n/2+1;
		B[L]=A[1];
		for(int i=2;i<=n;i++){
			if(i&1)B[--L]=A[i];
			else B[++R]=A[i];
		}
	}else{
		int L=n/2+1,R=n/2+1;
		B[L]=A[1];
		for(int i=2;i<=n;i++){
			if(i&1)B[++R]=A[i];
			else B[--L]=A[i];
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d%c",B[i]," \n"[i==n]);
	return 0;
}

Measured memory_bytes: 3712
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque
sys.setrecursionlimit(7*10**4)

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD =  998244353

# for _ in range(int(ri())):
s,w = Ri()
if w >= s :
    print("unsafe")
else:
    print("safe")


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

int busLine[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };
const int SIZE = sizeof(busLine) / sizeof(int);

int main()
{
	int n;
	while( cin >> n ){
		for( int i = 0; i < n; ++i ){
			int start, end;
			cin >> start >> end;

			int step = 0;
			int index = 0;
			int memo[ SIZE ];
			bool bFoundStart = false;
			while( 1 ){
				if( busLine[ index ] == start ){
					bFoundStart = true;
					step = 0;
					memo[ step ] = busLine[ index ];
					++index;
					continue;
				}
				++step;
				memo[ step ] = busLine[ index ];
				if( bFoundStart && busLine[ index ] == end ){
					break;
				}
				++index;
				index %= SIZE;
			}

			bool bFirst = true;
			for( int j = 0; j <= step; ++j ){
				if( bFirst ){
					bFirst = false;
				}else{
					cout << " ";
				}
				cout << memo[ j ];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  H,W=map(int,pin().split())
  ans=""
  for i in range(H):
    S=list(pin().split())
    for j in range(W):
      if S[j]=="snuke":
        ans=f"{chr(65+j)}{i+1}"
  print(ans)
  return 

main()

Measured memory_bytes: 9152
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int main()
{
  double x1,y1,x2,y2,x3,y3,xp,yp;
  while( cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
  double s;
  double a,b,c;
  a =sqrt(pow(x1-x2,2)+pow(y1-y2,2));
  c =sqrt(pow(x1-x3,2)+pow(y1-y3,2));
  b =sqrt(pow(x2-x3,2)+pow(y2-y3,2));
  s =(a+b+c)/2;
  double abcS =sqrt(s*(s-a)*(s-b)*(s-c));
  double ap,bp,cp;
  ap =sqrt(pow(x1-xp,2)+pow(y1-yp,2));
  bp =sqrt(pow(x2-xp,2)+pow(y2-yp,2));
  cp =sqrt(pow(x3-xp,2)+pow(y3-yp,2));
  s =(ap+bp+a)/2;
  double abpS =sqrt(s*(s-ap)*(s-bp)*(s-a));
  s =(bp+cp+b)/2;
  double bpcS =sqrt(s*(s-bp)*(s-cp)*(s-b));
  s =(ap+cp+c)/2;
  double apcS =sqrt(s*(s-ap)*(s-cp)*(s-c));
  double var =abcS-(abpS+bpcS+apcS);
  if((var<=0.001&&var>=-0.01))
     var=0.0;
  if(var==0.0)
    cout <<"YES"<<endl;
  else
    cout <<"NO"<<endl;
  
  }
  return 0;
}

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

#define ll long long 



int main() {
  int N;
  cin >> N;
  
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  
  int perm[N];
  for (int i = 1; i <= N; i++) {
    perm[i-1] = i;
  }
  
  int a, b;
  int count = 0;
  do {
    count++;
    bool condA = true, condB = true;
    // Pがpermに一致しているか
    for (int i = 0; i < N; i++) {
      if (P[i] != perm[i]) {
        condA = false;
        break;
      }
    }
    
    if (condA) a = count;
    
    // Qがpermに一致しているか
    for (int i = 0; i < N; i++) {
      if (Q[i] != perm[i]) {
        condB = false;
        break;
      }
    }
    
    if (condB) b = count;
    
    
  } while(next_permutation(perm, perm+N));
 


  cout << abs(b-a) << endl;
              
}



Measured memory_bytes: 3548
m, k = map(int, input().split())

if m == 0:
    if k == 0:
        ans = [0, 0]
    else:
        ans = []

elif m == 1:
    if k == 0:
        ans = [0, 0, 1, 1]
    else:
        ans = []

elif k < 2 ** m:
    li = list(range(2 ** m))
    li.remove(k)
    ans = li + [k] + li[::-1] + [k]

else:
    ans = []

if ans:
    print(*ans)
else:
    print(-1)


Measured memory_bytes: 16360
#include <iostream>

int a[100];

int main(){
    int n, m, sum = 0;
    std::cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
        sum += a[i];
    }
    int pop_count = 0;
    for (int i = 0; i < n; ++i) {
        if(a[i]*4*m>=sum)++pop_count;
    }
    std::cout << (pop_count>=m?"Yes":"No");
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N, M, Q = map(int, input().split())
    A = [[0] * (N + 1) for _ in range(N + 1)]
    for _ in range(M):
        L, R = map(int, input().split())
        A[L][R] += 1

    for i in range(N+1):
        for j in range(1,N+1):
            A[i][j] += A[i][j-1]

    for j in range(N+1):
        for i in range(1,N+1):
            A[i][j] += A[i-1][j]

    for _ in range(Q):
        p, q = map(int, input().split())
        ans = A[q][q] - A[q][p-1] - A[p-1][q] + A[p-1][p-1]
        print(ans) 


if __name__ == "__main__":
    main()

Measured memory_bytes: 54492
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
std::map<T, int> prime_factorize(T x) {
  std::map<T, int> primes;
  for (T factor = 2; factor * factor <= x; factor++) {
    if (x % factor == 0) {
      T count = 0;
      while (x % factor == 0) {
          count++;
          x /= factor;
      }
      primes[factor] = count;
    }
  }
  if (x != 1) primes[x] = 1;
  return primes;
}

int main() {
  int N; cin >> N;
  int cnt = 0;
  for (int i = 101; i <= N; i += 2) {
    auto m = prime_factorize(i);
    int c = 1;
    for (auto p : m) {
      c *= p.second + 1;
    }

    if (c == 8) {
      ++cnt;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for(int i = 0; i < X; ++i) {
        cin >> A[i];
    }
    for(int i = 0; i < Y; ++i) {
        cin >> B[i];
    }
    for(int i = 0; i < Z; ++i) {
        cin >> C[i];
    }
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> ret;
    for(int i = 0; i < X; ++i) {
        for(int j = 0; j < Y; ++j) {
            for(int k = 0; k < Z; ++k) {
                if(i*j*k<K)
                    ret.push_back(A[i]+B[j]+C[k]);
            }
        }
    }
    sort(ret.begin(), ret.end(), greater<ll>());
    for(int i = 0; i < K; ++i) {
        cout << ret[i] << endl;
    }
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int H,W;
    cin >> H >> W;
    vector<string> s(H);
    rep(i,H) cin >> s[i];

    rep(i,W+2) cout << '#';
    cout << endl;
    rep(i,H)
    {
        cout << '#' << s[i] << '#' << endl;
    }
    rep(i,W+2) cout << '#';
    cout << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,ans=1000000007;
  cin>>N;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(ll i=1;i<=1000;i++){
    ll a=0;
    for(ll j=0;j<N;j++){
      a+=(vec.at(j)-i)*(vec.at(j)-i);
    }
    ans=min(ans,a);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, k);
	int x = 0;
	inc1(i, k) {
		x = (10 * x + 7) % k;
		if(x == 0) { OUT(i); exit(0); }
	}
	OUT(-1);
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
using namespace std;

int a,b,c,d;

char p1='+';
char p2='-';

string t="=7";

int main(){
	string s;
	cin>>s;
	a=(int)(s[0]-'0');
	b=(int)(s[1]-'0');
	c=(int)(s[2]-'0');
	d=(int)(s[3]-'0');
	if(a+b+c+d==7){ 
		cout<<a<<p1<<b<<p1<<c<<p1<<d<<t<<endl;
		return 0;
	}
	if(a+b+c-d==7){
		cout<<a<<p1<<b<<p1<<c<<p2<<d<<t<<endl;
		return 0;
	}
	if(a+b-c-d==7){
		cout<<a<<p1<<b<<p2<<c<<p2<<d<<t<<endl;
		return 0;
	}
	if(a+b-c+d==7){
		cout<<a<<p1<<b<<p2<<c<<p1<<d<<t<<endl;
		return 0;
	}
	if(a-b+c+d==7){
		cout<<a<<p2<<b<<p1<<c<<p1<<d<<t<<endl;
		return 0;
	}
	if(a-b+c-d==7){
		cout<<a<<p2<<b<<p1<<c<<p2<<d<<t<<endl;
		return 0;
	}
	if(a-b-c-d==7){
		cout<<a<<p2<<b<<p2<<c<<p2<<d<<t<<endl;
		return 0;
	}
	if(a-b-c+d==7){
		cout<<a<<p2<<b<<p2<<c<<p1<<d<<t<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())

half = a * a * b / 2
if half > x:
    height = 2 * x / a / b
    print(90.0 - math.degrees(math.atan(height/b)))
else:
    rest = a * a * b - x
    width = rest / (a * a / 2)
    print(math.degrees(math.atan(width / a)))

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

x_min=0
y_min=0

for i in range(n):
        x,y,a=map(int,input().split())
        if a==1:
                x_min=max(x_min,x)

        elif a==2:
                w=min(w,x)

        elif a==3:
                y_min=max(y_min,y)

        elif a==4:
                h=min(h,y)


white=max(0,(w-x_min))*max(0,(h-y_min))

print(white)


Measured memory_bytes: 3060
from collections import deque
n,k = map(int,input().split())
r,s,p = map(int,input().split())
q = deque(input())
score = 0
memory = [0]*k
for i in range(n):
    a = q.popleft()
    if a == 'r': 
        if memory[i % k] != 'r':
            score += p 
            memory[i % k] = 'r'
        else:
            memory[i % k] = 0
    if a == 's': 
        if memory[i % k] != 's':
            score += r 
            memory[i % k] = 's'
        else:
            memory[i % k] = 0    
    if a == 'p': 
        if memory[i % k] != 'p':
            score += s 
            memory[i % k] = 'p'
        else:
            memory[i % k] = 0
print(score)

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


N,x = map(int, input().split())
An = list(map(int, input().split()))
ans = 0
for i in range(1,N):
  eat = max(An[i-1]+An[i]-x,0)
  ans += eat
  An[i] = max(An[i]-eat,0)

print(ans)

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
const ll mod = 1e9+7;

void sieve(size_t max, vector<bool> &isPrime){
    isPrime[0] = false; 
    isPrime[1] = false; 
    for (size_t i = 2; i*i <= max; ++i) 
        if(isPrime[i])
            for(size_t j=2; i*j <= max; ++j) 
                isPrime[i*j] = false; 
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<bool> isPrime(n+1, true);
	sieve(n, isPrime);
	vector<ll> cnt(n+1, 0);
	FOR(i, 2, n+1){
		if (isPrime[i]){
			FOR(j, i, n+1){
				ll c = 0;
				ll tmp = j;
				while(tmp%i==0){
					c++;
					tmp /= i;
				}
				cnt[i] += c;
			}
		}
	}
	ll ans = 1;
	FOR(i, 2, n+1){
		if (isPrime[i]){
			ans *= (cnt[i]+1);
			ans %= mod;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N, A[101010];

int main() {
    scanf("%d", &N);
    for (int j = 0; j < N; ++j) scanf("%d", A+j);

    int counts[3] = {0, 0, 0};
    for (int j = 0; j < N; ++j) {
        if (A[j] % 4 == 0) counts[2]++;
        else if (A[j] % 2 == 0) counts[1]++;
        else counts[0]++;
    }

    bool yesno;
    if (counts[1] > 0) {
        yesno = counts[0] <= counts[2];
    } else {
        yesno = counts[0]-1 <= counts[2];
    }

    cout << (yesno ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
using namespace std;

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  while(true)
    {
      int n,x;
      cin >> n >> x;

      if(n==0 && x==0)
	break;

      int count=0;
      for(int i=1; i<=n; i++){
	for(int j=i+1; j<=n; j++){
	  for(int k=j+1; k<=n; k++){
	    if(i+j+k==x)
	      count++;
	  }
	}
      }


      cout << count <<  endl;
    }

  }

Measured memory_bytes: 1160
# include <iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n%1000==0)
  {
    cout<<"0"<<endl;
  }
  else
  {
    int c=n/1000;
    cout<<((c+1)*1000)-n<<endl;
  }
  return 0;
}

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

int main() {
    string ticket;
    cin >> ticket;

    for (int tmp = 0; tmp < (1 << 3); tmp++) {
        bitset<3> op(tmp);
        int sum = ticket.at(0) - '0';

        for (int i = 0; i < 3; i++) {
            if (op.test(i)) {
                sum += ticket.at(i + 1) - '0';
            } else {
                sum -= ticket.at(i + 1) - '0';
            }
        }

        if (sum == 7) {
            cout << ticket.at(0);
            for (int i = 0; i < 3; i++) {
                if (op.test(i)) {
                    cout << "+";
                } else {
                    cout << "-";
                }
                cout << ticket.at(i + 1);
            }
            cout << "=7" << endl;

            return 0;
        }
    }
}

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

int a[200010], ans[200010];

void solve(){
    int n; cin >> n;
    for(int i = 2; i <= n; ++i) cin >> a[i];
    for(int i = 2; i <= n ; ++i) ans[a[i]]++;
    for(int i = 1 ; i <= n; ++i) cout << ans[i] << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 6724
mod = 998244353
k, n = list(map(int, input().split()))
C = [ [0 for i in range(n + k + 1)] for j in range(n + k + 1) ]
pw = [0 for i in range(n + k + 1)]

for i in range(0, n + k + 1) :
    C[i][0] = 1
    if i == 0 : pw[i] = 1
    else : pw[i] = (pw[i - 1] << 1) % mod
    for j in range(1, i + 1) :
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod

def calc(tot, seg) :
    if tot < 0 : return 0
    return C[tot + seg - 1][tot]

for i in range(2, k + k + 1) :
    ans = su = 0
    if i <= k : su = i - 1
    else : su = k + k - i + 1
    if i & 1 :
        for j in range(0, (su >> 1) + 1) :
            ans = ( ans + calc(n - j, k - su + j) * pw[j] % mod * C[su >> 1][j] ) % mod
    else :
        for j in range(0, (su >> 1) + 1) :
            ans = ( ans + calc(n - j - 1, k - su + j) * pw[j] % mod * C[su >> 1][j] ) % mod
            ans = ( ans + calc(n - j, k - su + j) * pw[j] % mod * C[su >> 1][j] ) % mod
    print(ans)

Measured memory_bytes: 169992
import sys
readline = sys.stdin.readline

def main():
    K, S = map(int, readline().rstrip().split())
    ans = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int k = 1;
    while (k * 2 <= n)
        k *= 2;
    cout << k;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 710
#define PB push_back
#define MP make_pair
#define X first
#define Y second

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

vi adj[SIZE];
int edge[SIZE][SIZE], vis[SIZE], col[SIZE];
int cnt[2];

bool dfs1(int v) {
    ++cnt[col[v]];
    for (auto t: adj[v]) {
        if (col[t] == -1) {
            col[t] = col[v] ^ 1;
            if (!dfs1(t)) return false;
        }
        if (col[t] != (col[v] ^ 1)) return false;
    }
    return true;
}

vector<pii> num;

bool bipartite(int n) {
    for (int i = 1 ; i <= n ; ++i) {
        cnt[0] = cnt[1] = 0;
        if (col[i] != -1) continue;
        col[i] = 0;
        if (!dfs1(i)) return false;
        num.PB(MP(cnt[0], cnt[1]));
    }
    return true;
}

int dp[SIZE][SIZE];

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

    for (int i = 0 ; i < m ; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        edge[u][v] = edge[v][u] = 1;
    }   
    for (int i = 1 ; i <= n ; ++i) {
        col[i] = -1;
        for (int j = 1 ; j <= n ; ++j) {
            if (edge[i][j] || j == i) continue;
            adj[i].PB(j);
        }
    }

    if (!bipartite(n)) {
        printf("-1\n");
        return 0;
    }

    int sz = num.size();
    dp[0][num[0].X] = dp[0][num[0].Y] = 1;
    for (int i = 1 ; i < sz ; ++i) {
        for (int j = 0 ; j <= n ; ++j) {
            if (j >= num[i].X && dp[i - 1][j - num[i].X]) dp[i][j] = 1;
            if (j >= num[i].Y && dp[i - 1][j - num[i].Y]) dp[i][j] = 1;
        }
    }

    for (int i = n / 2 ; i <= n ; ++i) {
        if (dp[sz - 1][i]) {
            int j = n - i;
            printf("%d\n", i * (i - 1) / 2 + j * (j - 1) / 2); 
            return 0;
        }
    }
    

}


Measured memory_bytes: 4992
N=int(input())
List = list(map(int, input().split()))
flg = True
if N ==1: print("Yes")
else:
  for i in range(1,N):
    if List[i]==List[i-1]:
      pass
    elif List[i]>List[i-1] or List[i]-1>=List[i-1]:
      List[i] = List[i]-1
    else:
      flg=False
      break
  if flg:
    print("Yes")
  else:
    print("No")

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

int main() {
  string s = "";
  bool b = 1;
  int n, m;
  cin >> n >> m;
  rep(i, n) s += 'a';
  vector<pair<int, int>> v(m);
  rep(i, m) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  rep(i, m){
    if(s[v[i].first-1] != 'a' && s[v[i].first-1] != '0' + v[i].second){
      s = "-1";
      b = 0;
      break;
    }
    else s[v[i].first-1] = '0' + v[i].second;
  }
  if(b){
    if(n != 1 && s[0] == '0') s = "-1";
    rep(i, n){
      if(i == 0 && n != 1 && s[i] == 'a') s[i] = '1';
      else if(s[i] == 'a') s[i] = '0';
    }
  }
  cout << s << endl;
  return 0;
}

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

int main() {
    char a,b;
    cin >> a >> b;
    if(a=='H'){
        if(b=='H'){
            cout << "H" << endl;
        }else{
            cout << "D" << endl;
        }
    }else{
        if(b=='H'){
            cout << "D" << endl; 
        }else{
            cout << "H" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256