akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define IOS ios::sync_with_stdio(false);
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时，答案应至多初始化为INT_MIN；求最小值时，答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
*/
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
const int N = 2e5 + 5;
int a[N][2];
int n;
ll max_Manhattan(int p[][2], int n, int k)
{
	ll ans = 0;
	for (int s = 0; s < (1 << k); ++s)
	{
		ll mx = -1e18, mn = 1e18;
		for (int i = 0; i < n; ++i)
		{
			ll tmp = 0;
			for (int j = 0; j < k; ++j)
				tmp += (s & (1 << j)) ? p[i][j] : -p[i][j];
			mx = max(mx, tmp), mn = min(mn, tmp);
		}
		ans = max(ans, mx - mn);
	}
	return ans;
}
int main() {
	n = read();
	for_int(i, 0, n - 1) a[i][0] = read(), a[i][1] = read();
	cout << max_Manhattan(a, n, 2) << endl;
	return 0;
}

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

// calculate |gcd|.
// if  ether num is 0, return 0
long long GCD(long long left, long long right) {
  if(left == 0 || right == 0) return 0;
  if(left < 0) left *= -1;
  if(right < 0) right *= -1;
  if(left < right) swap(left, right);
  long long nextnum, ansgcd = -1;
  while(ansgcd == -1) {
    nextnum = left % right;
    if(nextnum == 0) ansgcd = right;
    left = right;
    right = nextnum;
  }
  return ansgcd;
}

long long LCM(long long left, long long right) {
  return left / GCD(left, right) * right;
}

long long n;
long long t[1005] = {0}, a[1005] = {0};

long long solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> t[i] >> a[i];

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long now = 1, nowl = t[0], nowr = a[0];
  for(int i = 1; i < n; ++i) {
    now = max((nowl + t[i] - 1) / t[i],
              (nowr + a[i] - 1) / a[i]);
    nowl = now * t[i];
    nowr = now * a[i];
  }
  return nowl + nowr;
}

Measured memory_bytes: 256
import numpy as np

N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

cnt = 0
for i in range(2**N):
  cnt += np.prod([
    sum([int(bin(i)[2:].zfill(N)[s-1]) for s in S[j][1:]])%2 == P[j]
    for j in range(M)
  ])
print(cnt)

Measured memory_bytes: 27316
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e9
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}
 
int main()
{
    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;

    string ans = "";
    for(int i=0;i<s.size();i++)
    {
        ans += s[i];
        ans += t[i];
    }

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int arr[1000000];
int dp[1000000];

int f(int i,int n){

    if(i==n) return 0;
    //Memoization
    if(dp[i]!=-1) return dp[i];
    int cost = abs(arr[i]-arr[i+1]) + f(i+1,n);

    if(i+2<=n){

        cost = min( cost, (abs(arr[i]-arr[i+2]) + f(i+2,n)));

    }

    return dp[i]=cost;

}

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

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

    memset(dp,-1, sizeof(dp));

    cout<<f(1,n)<<"\n";


    return 0;
}


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

using namespace std;
typedef long long ll;

#define LOOP(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) LOOP(i, 0, n)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359

string reverse(string s) {
  string ret;
  for(int i=s.size()-1; i>=0; i--) {
    ret += s[i];
  }

  return ret;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    set<string> s;
    for(int j=1; j<str.size(); j++) {
      string left = str.substr(0, j), right = str.substr(j);
      //cout << left << " " << right << endl;
      s.insert(left+right);
      s.insert(left+reverse(right));
      s.insert(reverse(left)+right);
      s.insert(reverse(left)+reverse(right));
      s.insert(right+left);
      s.insert(reverse(right)+left);
      s.insert(right+reverse(left));
      s.insert(reverse(right)+reverse(left));
    }
    /*for(auto itr = s.begin(); itr != s.end(); ++itr) {
        cout << *itr << "\n";
    }*/
    ans.push_back(s.size());
  }

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

  return 0;
}

Measured memory_bytes: 3244
L,X=map(int,input().split())
b=[1];p=[1]
for i in range(L):
	b.append(b[-1]*2 + 3)
	p.append(p[-1]*2 + 1)
def f(L, X):
	if L==0 or X<0:
		return 0 + (X>0)
	elif X <= 1 + b[L-1]:
		return f(L-1, X-1)
	else:
		return p[L-1] + 1 + f(L-1, X-b[L-1]-2)
print(f(L, X))


Measured memory_bytes: 3064
// clang-format off
	#define BADSEED random_device{}()
	#include <bits/stdc++.h>
	using namespace std;
	using ll = long long;
	using uint = unsigned int;
	ostream &operator<<(ostream &os, int8_t c) { return os << short(c); }
	istream &operator>>(istream &is, int8_t &c) { short x; is >> x; c = x; return is; }
	#define TM_(...) template <class __VA_ARGS__>
	namespace narut {
	TM_(T) using TupSz = tuple_size<decay_t<T>>;
	TM_(T) constexpr auto spc(T const &t, int) -> decltype((cout << t), 'a') { return ' '; }
	constexpr auto spc(string const &s, int) { return '\n'; }
	TM_(T) constexpr auto spc(T const &t, char) { return '\n'; }
	struct IO {
		TM_(T) static auto out_(ostream &os, T const &t, int) -> decltype(void(os << t)) { os << t; }
		TM_(T, class OS) static auto out_(OS &os, T const &t, int) -> decltype(void(begin(t))) {
			auto it = begin(t), e = end(t);
			if (it != e) out_(os, *it++, 0);
			for (; it != e; out_(os, *it++, 0)) os << spc(*it, 0);
		}
		TM_(T, size_t... Is) static void out_tup(ostream &os, T const &t, index_sequence<Is...>) { (void)initializer_list<int>{0, ((Is == 0) ? 0 : ((os << ' '), 0), (os << get<Is>(t)), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) out_(ostream &os, T const &t, char) { out_tup(os, t, make_index_sequence<TupSz<T>::value>{}); }
		TM_(Sep, class F, class... Ts) static ostream &print(ostream &os, Sep sep, F const &f, Ts const &... ts) { return void(initializer_list<int>{(out_(os, f, 0), 0), (out_(os << sep, ts, 0), 0)...}), os; }
		TM_(T) static auto in_(istream &is, T &t, int) -> decltype(void(is >> t)) { is >> t; }
		TM_(T, class IS) static auto in_(IS &is, T &t, int) -> decltype(void(begin(t))) { for (auto &x : t) in_(is, x, 0); }
		TM_(T, size_t... Is) static void in_tup(istream &is, T &t, index_sequence<Is...>) { (void)initializer_list<int>{0, (in_(is, get<Is>(t), 0), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) in_(istream &is, T &t, char) { in_tup(is, t, make_index_sequence<TupSz<T>::value>{}); }
	};
	} // namespace narut
	#define Cout(...) narut::IO::print(cout, ' ', __VA_ARGS__) << '\n'
	#ifdef NARUT_LOCAL
	#define Debug(...) narut::IO::print(cerr << "\033[0;31m", ", ", __VA_ARGS__) << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] struct Cin { 
		template <class T> Cin const &operator>>(T &t) const { return narut::IO::in_(cin, t, 0), *this; }
		template <class T> operator T() const { T t; return *this >> t, t;  }	
	} Cin;
	TM_(T) auto operator%(T &t, size_t n) -> decltype(t.resize(n), t)& { return t.resize(n), t; }
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)

// clang-format on





auto Main() {
	int s, w;
	cin>>s>>w;
	if (w >= s) cout << "unsafe";
	else cout<<"safe";
	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, A;
	cin >> N >> M >> A;
	while (N != 0) {
		int cur = A;
		vector<tuple<int, int, int> > L;
		REP(i, M) {
			int H, P, Q;
			cin >> H >> P >> Q;
			L.push_back(make_tuple(H, P, Q));
		}
		so(L); rev(L);
		REP(i, M) {
			int P = get<1>(L[i]), Q = get<2>(L[i]);
			if (P == cur){
				cur = Q;
			}
			else if (Q == cur) {
				cur = P;
			}
		}
		cout << cur << endl;
		cin >> N >> M >> A;
	}
	return 0;
}



Measured memory_bytes: 3124
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    int A, B, T; cin >> A >> B >> T;
    int i = 2, tmp = A;
    int ans = 0;
    while (tmp <= T) {
        ans += B;
        tmp = A * i;
        i++;
    }
    cout << ans << endl;
    return 0;
}

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

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()

#define EPS 1e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;
int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	int count = 0, n;
	cin >> n;
	cin >> s;
	for(int i = 0; i <= n - 3; ++i) {
		if(s.substr(i, 3) == "ABC") ++count;
	}
	cout << count << '\n';
    return 0;
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define INF INT_MAX/3

#define fi first
#define se second

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

struct dice{
  int a[6];
};
void rot(int &a,int &b,int &c,int &d){
  int tmp=a; a=b; b=c; c=d; d=tmp;
}
void roll_f(dice &d){
  rot(d.a[0],d.a[3],d.a[2],d.a[1]);
}
void roll_b(dice &d){
  rot(d.a[0],d.a[1],d.a[2],d.a[3]);
}
void roll_l(dice &d){
  rot(d.a[3],d.a[5],d.a[1],d.a[4]);
}
void roll_r(dice &d){
  rot(d.a[3],d.a[4],d.a[1],d.a[5]);
}

typedef pair<P,int> pi;

int n;
map<P,int> nd[20];
ll dp[1<<15];

int main(int argc, char const *argv[]){
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,20)nd[i].clear();
    rep(i,1<<15){
      dp[i]=0;
    }
    rep(i,n){
      dice d;
      int sx,sy;
      string s;
      cin>>sx>>sy;
      cin>>d.a[4]>>d.a[5]>>d.a[0]>>d.a[2]>>d.a[1]>>d.a[3];
      cin>>s;
      nd[i][P(sx,sy)]=d.a[1];
      rep(j,s.length()){
        if(s[j]=='F'){
          roll_f(d);
          sy--;
        }
        if(s[j]=='B'){
          roll_b(d);
          sy++;
        }
        if(s[j]=='R'){
          roll_r(d);
          sx++;
        }
        if(s[j]=='L'){
          roll_l(d);
          sx--;
        }
        nd[i][P(sx,sy)]=d.a[1];
      }
    }
    rep(S,(1<<n)){
      map<P,bool> used;
      rep(i,n){
        if((S&(1<<i))==0)continue;
        for(auto it: nd[i]){
          used[it.fi]=true;
        }
      }
      rep(i,n){
        if((S&(1<<i))!=0)continue;
        ll add=0;
        for(auto it: nd[i]){
          if(used[it.fi])continue;
          add+=it.se;
        }
        int T=S|(1<<i);
        dp[T]=max(dp[T],dp[S]+add);
      }
    }
    cout<<dp[(1<<n)-1]<<endl;
  }
  return 0;
}

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


int main(void){
  int i,j,d,min;
  long l,r;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  l=atol(p);
  p=strtok(NULL," \n");
  r=atol(p);
  
  if(r-l>=2019){
    printf("0\n");
    return 0;
  }
  
  for(i=l,min=1000000;i<r;i++){
    for(j=i+1;j<r+1;j++){
      d=((j%2019)*(i%2019))%2019;
      if(min>d){
        min=d;
      }
    }
  }
  
  printf("%d\n",min);
  
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double EPS=(1e-10);

int main()
{
	int n;
	double x[4],y[4];

	cin>>n;

	for(int i=0;i<n;i++){
		for(int j=0;j<4;j++) cin>>x[j]>>y[j];
		
		if( abs((y[1]-y[0])*(x[3]-x[2])-(y[3]-y[2])*(x[1]-x[0]))<EPS  ) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

	return 0;
}

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

void Main() {
    // input
    u_int64_t N;
    cin >> N;

    // translate
    u_int64_t ans = 0;
    for (u_int64_t i = 1; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
            ans += i;
        }
    }


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
A = int(input())
B = int(input())
C = int(input())
X = int(input())
if ((A+B+C<1) or (A<0 or A>50) or (B<0 or B>50) or (C<0 or C>50) or (X<50 or X > 20000 or X%50!=0)):
    print("条件を満たしてください")
count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            Y = i*500 + j*100 + k*50
            if (X==Y):
                count = count+1

print (count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, a, b;
  cin >> n >> a >> b;

  ll times = n / (a + b);

  ll blue = times * a;

  ll rem = n % (a + b);

  blue += min(rem, a);
  cout << blue << en;
  return 0;
}


Measured memory_bytes: 256
u, s, e, w, n, d = list(map(int, input().split()))
insts = input()
for inst in insts:
    if inst == 'N':
        u, s, n, d = s, d, u, n
    elif inst == 'E':
        u, e, w, d = w, u, d, e
    elif inst == 'S':
        u, s, n, d = n, u, d, s
    elif inst == 'W':
        u, e, w, d = e, d, u, w
print(u)

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

int main(){
    string str;
    cin >> str;
    int ans = 1e5;
    for(int i=0; i<26; i++){
        char c = 'a' + i;
        int l1 = 0, l2 = 0;
        for(int j=0; j<str.length(); j++){
            if(str[j] == c){
                l1 = max(l1,l2);
                l2 = 0;
            }else{
                l2++;
            }
        }
        l1 = max(l1,l2);
        ans = min(ans,l1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

#define int long long

int N, C[300000] ={};
vector<int> v;
vector<int> sum;

int idx[300001];

signed main(){
	cin >> N;
	rep(i, N){
		int A;
		cin >> A;
		A--;
		C[A]++;
	}
	rep(i, N)
		if(C[i] != 0) v.pb(C[i]);
	sort(all(v));
	reverse(all(v));
	rep(i, v.size()){
		if(i > 0) sum.pb(sum.back()+v[i]);
		else sum.pb(v[i]);
	}
	int tmp = 0;
	for(int i=N; i>=0; i--){
		while(tmp < v.size() && v[tmp] > i) tmp++;
		idx[i] = tmp;
	}

	rep(i, N){
		if(v.size() <= i) cout << 0 << endl;
		else{
			int mainSum = sum[i];
			int subSum = N - sum[i];

			int ok = 0;
			int ng = N+1;
			while(ng-ok > 1){
				int m = (ok+ng)/2;
				int j = idx[m];
				if(j >= i+1){
					ok = m;
					continue;
				}
				int s = sum[i] - (j > 0 ? sum[j-1] : 0);
				int k = i+1-j;
				if(s+subSum >= m*k) ok = m;
				else ng = m;
				//cout << m << " " << j << " " << s << " " << k << endl;
			}
			cout << ok << endl;
		}
	}

}

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

int main() {
    int n,i,arr[10000],min=1000000,max=-1000000;
    long sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
        
        if(arr[i]>max){
            max=arr[i];
        }
        if(arr[i]<min){
            min=arr[i];
        }
        
        
        sum+=arr[i];
        
    }
    printf("%d %d %ld\n",min,max,sum);
    
    return 0;
}


Measured memory_bytes: 2140
N,K=map(int,input().split())
a=[0]*N
for i in range(N):
  a[i]=int(input())
a=sorted(a)
minh=a[-1]
for i in range(N-K+1):
  minh=min(minh,a[i+K-1]-a[i])
print(minh)


Measured memory_bytes: 8240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//import org.junit.Test;

public class Main {
//	@Test
//	public void testName() throws Exception {
//		main(null);
//	}
	public static void main(String[] args) throws IOException {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line = br.readLine();
			new Main().solution(Integer.parseInt(line));
        }
    }
	
	private void solution(int inputNum){
		int ans = inputNum * inputNum * inputNum;
		System.out.println(ans);
	}

}

Measured memory_bytes: 24296
#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 a, b;
    cin >> a >> b;
    cout << max(a,b)+max(max(a,b)-1,min(a,b)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ERedScarf solver = new ERedScarf();
        solver.solve(1, in, out);
        out.close();
    }

    static class ERedScarf {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int acc = 0;
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                acc ^= a[i];
            }

            for (int i = 0; i < n; i++) {
                out.print(acc ^ a[i]);
                out.print(" ");
            }
            out.println();

        }

    }
}



Measured memory_bytes: 60256
import java.util.*;

public class Main {
	public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if(a%2==0){
          System.out.println("Even");
          return;
        }
        int b = sc.nextInt();
        if(b%2==0){
          System.out.println("Even");
          return;
        }
        System.out.println("Odd");
    }
}

Measured memory_bytes: 21716
N=int(input())
A=list(map(int,input().split()))

for i in range(1,N+1):
  A[i-1]-=i
A.sort()
#print(A,(N-N%2)//2)
m=A[(N-N%2)//2]
#print(m)

A=list(map(lambda x: abs(x-m),A))
print(sum(A))

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

int N;
 //<(????§???????????????????(0~), ????????????????????????), ???>
pair< pair<int, int>, int > disk[20005];

int main() {
  while(1){
    cin>>N;
    if(N==0) break;
    REP(i,0,20005) disk[i] = make_pair(make_pair(INF,INF), INF);
    disk[0] = make_pair(make_pair(0,1000000001), -1);  //-1:empty
    REP(i,0,N){
      string com, inp1, inp2;
      int num, len, ind;
      cin>>com;
      if(com=="W"){ /*?????????*/
        cin>>inp1>>inp2;
        num = stoi(inp1);
        len = stoi(inp2);
        REP(k,0,20005){
          if(len==0) break;
          if(disk[k].S == -1){
            int tl = disk[k].F.S-disk[k].F.F+1;
            if(len >= tl){
              disk[k].S = num;
              len -= tl;
            }else{
              //??°????´???????
              int tmp = disk[k].F.F;
              disk[k].F.F = disk[k].F.F+len;
              RREP(l,k+1,20005){
                disk[l] = disk[l-1];
              }
              disk[k] = make_pair(make_pair(tmp, tmp+len-1), num);
              len = 0;
            }
          }
        }
      }else if(com=="D"){ /*??????*/
        cin>>inp1;
        num = stoi(inp1);
        REP(k,0,20005){
          if(disk[k].S==num) disk[k].S = -1;
        }
      }else{ /*????????????*/
        cin>>inp1;
        ind = stoi(inp1);
        REP(k,0,20005){
          if(disk[k].F.F <= ind && ind <= disk[k].F.S){
            cout<<disk[k].S<<endl;
            break;
          }
        }
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3360
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int N, M;
vector<vector<int> > G;

vector<bool> seen;
bool rec(int v, int p, int s, int t) {
    if (v == s && p != -1) return true; // Ò»ÖÜ»Ø¤Ã¤Æ¤­¤Æ s ¤Ë‘ø¤Ã¤ÆÀ´¤¿¤é OK
    if (v != s) seen[v] = true;
    for (auto nv :  G[v]) {
        if (nv == p || nv == t || seen[nv]) continue;
        if (rec(nv, v, s, t)) return true;
    }
    return false;
}
        
bool solve() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    map<int,int> degs;
    for (int v = 0; v < N; ++v) {
		degs[(int)G[v].size()]++;
		if (G[v].size() > 6) degs[6]++;
		if (G[v].size() & 1) return false;
	}

//    for (auto it : degs) if (it.first % 2 != 0) return false;
    if (degs[6] > 0) return true;
    if (degs[4] > 2) return true;
    if (degs[4] <= 1) return false;

    vector<int> four;
    for (int v = 0; v < N; ++v) if (G[v].size() == 4) four.push_back(v);
    int s = four[0], t = four[1];
    seen.assign(N, 0);
    return rec(s, -1, s, t);
}

int main() {
    if (solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#include <boost/functional/hash.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define debug 0
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define urep(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define drep(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) urep(i,0,(n) - 1)
#define rep1(i,n) urep(i,1,(n))
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define era erase
#define emp emplace
#define emf emplace_front
#define emb emplace_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define odd(x) ((x) & 1)
#define even(x) (!odd(x))

using namespace std;

typedef boost::multiprecision::cpp_int mlint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef map<int,int> mpii;
typedef unordered_map<int,int> umpii;

const int dir[8][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const ll inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const ll mod = 1e9 + 7;
const db eps = 1e-9;

template <class T, class U> T qceil(T x, U y) { return x > 0 ? (x - 1) / y + 1 : x / y; }
template <class T, class U> bool parity(T x, U y) { return odd(x) ^ even(y); }
template <class T, class U> bool chmax(T &m, U x) { if(m < x) { m = x; return 1; } return 0; }
template <class T, class U> bool chmin(T &m, U x) { if(m > x) { m = x; return 1; } return 0; }
template <class T> bool cmprs(T &v) {
    T tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return v.size() > tmp.size();
}

int N,a[100010];
int X,Y,K;

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

    cin>>N;
    rep(i,N) cin>>a[i];
    sort(a,a+N);
    if(a[N-1]-a[0] > 1) esc("No");
    K = a[N-1];
    X=a+N-l_bnd(a,a+N,a[N-1]);
    Y=N-X;
    if(!Y && K == N - 1) esc("Yes");
    if(Y >= K) esc("No");
    if((K - Y) * 2 > X) esc("No");
    esc("Yes");
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
	int a, b;
	char op;

	for (int i = 0;; i++){

		cin >> a >> op >> b;

		switch (op){
		case '+':
			cout << a + b << endl;
			break;

		case '-':
			cout << a - b << endl;
			break;

		case '*':
			cout << a * b << endl;
			break;

		case '/':
			cout << a / b << endl;
			break;

		}
		if (op == '?')
			break;
	}

	return 0;
}

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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int k;
    string s;
    cin >> k >> s;
    forn(i, s.length()) {
        s[i] = char((s[i] - 'A' + k)%26  + 'A');
    }
    cout << s << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int maxn=2e3+2;
const int maxm=4e6+2;
const int mod=1e9+7;
int n,m;
int fac[maxm],inv[maxm],fv[maxm];
void init(){
	fac[0]=fac[1]=inv[1]=fv[0]=fv[1]=1;
	for (int i=2;i<=maxm;i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		inv[i]=1LL*inv[mod%i]*(mod-mod/i)%mod;
		fv[i]=1LL*fv[i-1]*inv[i]%mod;
	}
}
int Com(int x,int y){return 1LL*fac[x]*fv[y]%mod*fv[x-y]%mod;}
int dp[maxn];
void DP(){
	dp[0]=1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=i;j++)
			dp[j]=(dp[j]+1LL*dp[j-1]%mod*(n-j+1)%mod*Com(n*m-i-(j-1)*(m-1)-1,m-2)%mod)%mod;
}
int main(){
	init();
	scanf("%d%d",&n,&m);
	if (m==1){
		printf("1");
		return 0;
	}
	DP();
	printf("%d",dp[n]);
	return 0;
}

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

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll ;
typedef long double ldb ;
 
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl "\n"
 
#define all( x ) x.begin(),x.end()
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );

int main( ) {
	timesaver ;
	int k, a, b;
	cin >> k >> a >> b;
	if(a % k == 0)
		cout << "OK";
	else {
		int temp = a / k;
		if (k * (temp + 1) <= b)
			cout << "OK";
		else 
			cout << "NG";
	}

	return 0;
}

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
x = [int(i) for i in input().split()] # 配列で数字

ans = float('inf')
for i in range(101):
    t = 0
    for j in range(n):
        t += (x[j] - i) ** 2
    ans = min(ans, t)
print(ans)

Measured memory_bytes: 38664
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()
left=0
right=10**100

for i in range(m):
    x,y=mii()
    left=max(left,x)
    right=min(right,y)

ans=right-left+1
if ans<=0:
    print(0)
else:
    print(ans)
    

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

namespace ConsoleApp11
{
    class Class29
    {
        static void Main()
        {
            string S = Console.ReadLine();
            int i = 0;
            long countA = 0;
            long countB = 0;
            long R = 0;
            while (true)
            {
                while (S[i] == '<')
                {
                    countA ++;
                    i++;
                    if (i >= S.Length) break;
                }
                if (i >= S.Length) break;
                while (S[i] == '>')
                {
                    countB ++;
                    i++;
                    if (i >= S.Length) break;
                }
                if (i >= S.Length) break;
                R += Culc(countA - 1) + Culc(countB - 1) + Math.Max(countA, countB);
                countA = 0;countB = 0;
            }
            R += Culc(countA - 1) + Culc(countB - 1) + Math.Max(countA, countB);
            Console.WriteLine(R);
        }
        static long Culc(long n)
        {
            return n > 0 ? n * (n + 1) / 2 : 0;
        }
    }
}


Measured memory_bytes: 12896
#include <iostream>
using namespace std;
typedef long long ll;

int main(void){
  ll a,b,c;
  cin >> a >> b >> c;
 ll d = c - a - b;
 if(d > 0 && d * d > 4 * a * b){
 cout << "Yes" << endl;
 } else {
 cout << "No" << endl;
 }

 return 0;
}

Measured memory_bytes: 384
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $k);
$cnt = 0;
for ($i = min($a, $b); $i >= 1; $i--) {
    if ($a % $i === 0 && $b % $i === 0) {
        $cnt++;
        if ($cnt === $k) {
            $ans = $i;
            break;
        }
    }
}
echo $ans . PHP_EOL;

Measured memory_bytes: 4604
use proconio::input;

fn main() {
        input!{
                n: i64,
                k: i64,
        }

        let mut snuke = (0..n).map(|_| 0).collect::<Vec::<i64>>();

        for _ in 0..k {
                input!{
                        d: i64,
                        a: [usize; d]
                }
                for j in a {
                        snuke[j - 1] += 1;
                }
        }

        let ans = snuke.iter().filter(|&&s| s == 0).count();

        println!("{}", ans);
}

Measured memory_bytes: 2140
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    int A,B;
    string S;

    cin >> A >> B >> S;

    bool flag=true;

    REP(i,S.length()){
        if(i==A){
            if(S[i]=='-'){
                flag = flag&&true;
            }else{
                flag = false;
            }
        }else{
            if(S[i]=='-'){
                flag = false;
            }else{
                flag = flag&&true;
            }
        }
    }

    if(flag){
        cout << "Yes";
    }else{
        cout << "No";
    }

 }

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

int main(void){
    int n = 0;
    char s[101];
    int x = 0, max = 0;

    scanf("%d%s", &n, s);

    for(int i = 0; i < n; i++){
        if(s[i] == 'I'){
            x++;
        }else if(s[i] == 'D'){
            x--;
        }
        if(x > max){
            max = x;
        }
    }

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

    return 0;

} 


Measured memory_bytes: 256
class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        #using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        if mod > max_fact:
            fi = [pow(f[-1], mod - 2, mod)]
            for idx in range(max_fact, 0, -1):
                fi += [fi[-1] * idx % mod]
            fi = fi[::-1]
        else:
            fi = [pow(n, mod - 2, mod) for n in f]
        self.mod = mod
        self.f = f
        self.fi = fi

    def factorial(self, n):
        return self.f[n]

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = 2 * 10 ** 6
mod = 10**9 + 7
fact_instance = Factorial(max_fact, mod)
comb = fact_instance.combination
perm = fact_instance.permutation
combrep = fact_instance.homogeneous_product

H, W, A, B = [int(_) for _ in input().split()]
ans = comb(H + W - 2, H - 1)
for x in range(H - A, H):
    ans -= comb(x + B - 1, B - 1) * comb(H - 2 - x + W - B, W - B - 1)
    ans %= mod
print(ans)


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

int main() {
  long long n, d;
  cin >> n >> d;
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    if (d * d >= ((x * x) + (y * y))) {
      ans++;
    }
  }
  
  cout << ans;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int x,y;

	cin>>x>>y;

	cout<<x+y/2<<endl;


	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main()
{
    int n,ans=0;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    for(int i=2;i<n;i++){
        if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C'){
            ans++;
        }
    }
    printf("%d",ans);
}


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

using namespace std;

int main() {
  int n, l;
  cin >> n >> l;

  vector<int> tastes(n);
  int tasteSum = 0;
  for (int i = 0; i < n; ++i) {
    tastes[i] = l + i;
    tasteSum += tastes[i];
  }

  int mi = 1e9;
  int ans;
  for (int i = 0; i < n; ++i) {
    int tmp = tasteSum - tastes[i];
    int diff = abs(tmp - tasteSum);
    if (diff < mi) {
      mi = diff;
      ans = tmp;
    }
  }

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



Measured memory_bytes: 256
/* B - Crane and Turtle */

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

int main(){
  int X, Y;
  cin >> X >> Y;
  for(int i = 0; i <= X; i++){
    if(2 * i + 4 * (X - i) == Y){
      cout << "Yes" << endl;
      break;
    }
    if(i == X){
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{

	string s;
	cin>>s;
	ll count = 0;
	for(ll i=0;i<s.length();i++)
	{
		count+=s[i]-'0';
	}
	if(count%9)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	
}

Measured memory_bytes: 3696
h,w=map(int,input().split())
s=[]
s.append("#"*(w+2))
for i in range(h):
  s.append("#"+input()+"#")
s.append("#"*(w+2))
r=[[0]*(w+2) for i in range(h+2)]
l=[[0]*(w+2) for i in range(h+2)]
d=[[0]*(w+2) for i in range(h+2)]
u=[[0]*(w+2) for i in range(h+2)]

for i in range(1,h+1):
  for j in range(w+1,0,-1):
    if s[i][j]=="#":
      r[i][j]=0
    else:
      r[i][j]+=r[i][j+1]+1
# print(r)
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j]=="#":
      l[i][j]=0
    else:
      l[i][j]+=l[i][j-1]+1
# print(l)
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j]=="#":
      u[i][j]=0
    else:
      u[i][j]+=u[i-1][j]+1
# print(u)
for i in range(h+1,0,-1):
  for j in range(1,w+1):
    if s[i][j]=="#":
      d[i][j]=0
    else:
      d[i][j]+=d[i+1][j]+1
# print(d)
ans=0
for i in range(1,h+1):
  for j in range(1,w+1):
    ans=max(r[i][j]+l[i][j]+u[i][j]+d[i][j]-3,ans)
print(ans)

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

typedef long long LL;
int n,x[1005],bit[1005];
vector<int> ans;

void work(int kind){
        int pl,pr;
        for(int i=1;i<=n;i++){
            if (x[i]>=0 && i%2!=kind){
                pl=i;
                break;
            }
            else ans.push_back(1);
        }
        for(int i=n;i>=1;i--){
            if (x[i]>=0 && i%2!=kind){
                pr=i;
                break;
            }
            else ans.push_back(i-pl+1);
        }
        int ls=pl,ind=1;
        for(int i=pl+2;i<=pr;i+=2){
            if (x[i]<0) continue;
            for(int j=1;j<=(i-ls-1)/2;j++){
                ans.push_back(ind*2+1);
            }
            ind++;
            ls=i;
        }
        for(int i=1;i<ind;i++) ans.push_back(2);
        int num=ans.size();
        printf("%d\n",num);
        for(int i=0;i<ans.size();i++) printf("%d\n",ans[i]);
}

int main(){
    scanf("%d",&n);
    LL a,b; a=b=0;
    int tag=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&x[i]);
        if (x[i]>=0){
            tag=1;
            if (i%2==1) a+=x[i];
            else b+=x[i];
        }
    }
    if (tag==0){
        x[0]=-1000000009; int p=0;
        for(int i=1;i<=n;i++){
            if (x[i]>x[p]) p=i;
        }
        printf("%d\n%d\n",x[p],n-1);
        for(int i=1;i<p;i++) printf("1\n");
        for(int i=n;i>p;i--) printf("%d\n",i-p+1);
        return 0;
    }
    if (a>b){
        printf("%lld\n",a);
        work(0);    
    }
    else{
        printf("%lld\n",b);
        work(1);    
    }
    return 0;
}

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

using namespace std;

int N, M;
vector<int> G[8];

int dfs(int v, int vis)
{
    if (vis == (1 << N) - 1) {
        return 1;
    }
    
    int res = 0;
    for (int next : G[v]) {
        if (vis >> next & 1) continue;
        res += dfs(next, vis | (1 << next));
    }
    return res;
}

int main()
{
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a -= 1; b -= 1;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    cout << dfs(0, (1 << 0)) << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=[input() for _ in range(n)]
sdic={}
march=['M', 'A', 'R', 'C', 'H']
ans=0
for i in range(n):
  if s[i][0] in march:
    if s[i][0] in sdic:
      sdic[s[i][0]]+=1
    else:
      sdic[s[i][0]]=1
lis=[_ for _ in sdic.values()]
for j in range(len(lis)-2):
  for k in range(j+1,len(lis)-1):
    for l in range(k+1,len(lis)):
      ans+=lis[j]*lis[k]*lis[l]
print(ans)

Measured memory_bytes: 83216
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    ll k;
    cin>>s>>k;
    for(ll i=0;i<k;i++){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            break;
        }
        if(i==k-1){
            cout<<1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define H ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
using namespace std;
const ll  mod = 3e7;

string bin(int x){
    string s = "00000";
    int i = 4;
    while (x){
        s[i--] = (x % 2) + '0';
        x /= 2;
    }
    return s;
}

string s, str;
int f[1000006], arr[1000006];
int getNxt(int len, char c){
    while (len && s[len] != c){
        len = f[len - 1];
    }
    if (s[len] == c)
        len++;
    return len;
}

void computeF(){
    f[0] = 0;
    for (int i = 1; i < s.size(); i++){
        f[i] = getNxt(f[i - 1], s[i]);
    }
}

void KMP(){
    computeF();
    int k = 0, ans = 0;
    for (int i = 0; i < str.size(); i++){
        k = getNxt(k, str[i]);
        arr[k]++;
    }

}

int main()
{
    H
    ll n, k;
    cin >> n >> k;
    ll x, ans = 0;
    for (int i = 0; i < n; i++){
        cin >> x;
    }
    for (int i = 0; i < n - 1; i += k - 1) ans++;
    cout << ans;
    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}


 
void solve()
{
    int n,m,t,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    int a,b,c;
    cin>>a>>b>>c>>k;
    if(b<=a)
    {
        while(k--)
        {
            b*=2;
            if(b>a) break;
        }
    }
    if(b<=a)
    {
        cout<<"No";
        return;
    }
    if(c<=b)
    {
        while(k--)
        {
            c*=2;
            if(c>b) break;
        }
    }
    if(c<=b)
    {
        cout<<"No";
        return;
    }
    cout<<"Yes";
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        // if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3648
import math
# a=int(input())
b=int(input())
# c=[]
# for i in b:
#     c.append(i)
#e = list(map(int,input().split()))
#f = list(map(int,input().split()))
j = [input() for _ in range(3)]
a1=[i for i in j[0]]
a2=[i for i in j[1]]
a3=[i for i in j[2]]

count=0

for i in range(b):
    if a1[i]==a2[i]==a3[i]:
        count+=0
    elif a1[i]==a2[i] or a1[i]==a3[i] or a2[i]==a3[i]:
        count+=1
    else:
        count+=2

print(count)

Measured memory_bytes: 9136