akhauriyash/Code-Regression huggingface dataset:
// D.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <deque>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using pari=pair<lolo, lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORIT(it,v) for (auto it=v.begin(); it!=v.end(); ++it)
#define FORANGE(it, v) for (auto it : v)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()
template <class T>
void chmax(T& ans, const T& b)
{
	if (ans < b) {
		ans = b;
	}
}


int main()
{
	lolo N, K;
	cin >> N >> K;
	deque<lolo> V(N);
	FOR(i, N) cin >> V[i];
	lolo ans = 0;

	FOR(A, K + 1) {
		FOR(B, K + 1 - A) {
			auto MODOSU = K - A - B;
			priority_queue<lolo, vector<lolo>, greater<lolo>> Q;
			if (A + B >= N) {
				FORANGE(it, V) {
					Q.push(it);
				}
			}
			else {
				FOR(i, A) {
					Q.push(V[i]);
				}
				lolo i = N - 1;
				lolo cnt = B;
				while (cnt-- > 0) {
					Q.push(V[i]);
					i -= 1;
				}
			}

			lolo cnt = MODOSU;
			while (cnt-- > 0 and (!Q.empty() and Q.top() < 0)) {
				Q.pop();
			}
			lolo score = 0;
			lolo S = Q.size();
			FOR(i, S) {
				score +=  Q.top(); Q.pop();
			}
			chmax(ans, score);

		}
	}
	cout << ans << endl;
	
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s; cin >>s;
	int sum=0;
	for (int i=0;i<sz(s);i++) {
		sum+=s[i]-'0';
	}
	if(sum%9==0) {
		cout <<"Yes";
	}
	else cout <<"No";
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, a, b, ans = 0;
    cin >> n >> a >> b;
    if(n == 1){
        if(a == b) ans = 1; 
    }else if(a <= b){
        ans = (n - 2) * (b - a) + 1;
    }
    cout << ans << endl;
}

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

int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long n = 0;
    cin >> n;
    long long sum = n * (n + 1)/2;
    for(int i = 1; i <= n; i++) {
        if(i % 3 == 0 || i % 5 == 0) {
            sum -= i;
            
        }
    }
    cout << sum << endl;


    return 0;
}

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

const int MAXN = 3010;

string s,t;
int dp[MAXN][MAXN],N,M;
stack<char> resposta;


//create the dp table
int solve(int a,int b){

	if(a < 0 || b < 0) return 0;

	if(dp[a][b] != -1) return dp[a][b];

	if(s[a] == t[b]) return dp[a][b] = 1 + solve(a-1,b-1);

	return dp[a][b] = max(solve(a-1,b),solve(a,b-1));

}


//printing the lcs
void build(int a,int b){

	if(a < 0 || b < 0) return;

	if(s[a] == t[b]){
		resposta.push(s[a]);
		build(a-1,b-1);
		return;
	}

	if(solve(a-1,b) > solve(a,b-1)) build(a-1,b);
	else build(a,b-1);

}

int main(){

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

	cin >> s;
	cin >> t;

	N = (int)s.size();
	M = (int)t.size();

	build(N-1,M-1);

	while(!resposta.empty()){
		cout << resposta.top();
		resposta.pop();
	}
	cout << endl;

	return 0;

}


Measured memory_bytes: 39280
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N+2,0);
    for (int i = 0; i < N; i++) {
        cin >> A[i+1];
    }
    int t = 0;
    REP(i, N+1){
        t += abs(A[i+1] - A[i]);
    }
    Rep(i, 1, N+1){
        pr(t+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])));
    }
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)
		cout<<"Possible"<<endl;
	else
		cout<<"Impossible"<<endl;
	return 0;
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    string s, t;
    cin >> s >> t;
    c(t + s);
    ed;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;
           
int n, res, a[216000];
set<int> nums;
int main(){
	cin >> n;
	for(int i = 0;i < n;i++)cin >> a[i];
	for(int i = 0;i < n;i++){
		nums.insert(a[i]);
		while(*nums.rbegin() > a[i]){
			res++;
			nums.erase(*nums.rbegin());
		}
	}
	cout << res + nums.size() << endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int arr[n];
    int x;
    for (int i=0;i<n;++i){
        cin>>arr[i];
        if (i==0){
            x=arr[i];
        }
        else{
            x^=arr[i];
        }
    }
    for (int i=0;i<n;++i){
        int ans = x^arr[i];
        cout<<ans<<" ";
    }
    
}

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


int main(){

	int n;
	cin >> n;
	vector<char> s(n);

	//リーダーよりEにいる人の中でEを向いている人数
	//向きを変える人数
	int e = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> s[i];
		if(s[i] == 'E') e++;	
	}

	//リーダーよりWにいる人の中でWを向いている人数
	//向きを変える人数
	int w = 0;

	int ans= 3*100010;
	for(int i = 0; i < n; i++)
	{	
		if(s[i] == 'E') e--;
		ans = min(ans, e+w);
		if(s[i] == 'W') w++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >>d;
  if(abs(a-c)<=d){
    cout << "Yes"<< endl;
  }else if(abs(a-b)<=d && abs(b-c)<=d && abs(a-c)>d){
    cout << "Yes" << endl;
  }else{
    cout <<"No" << endl;
  }
  }


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

int main()
{
	int w, h, n;
	cin >> w >> h >> n;
	int top, right, bottom, left;
	top = h;
	right = w;
	bottom = left = 0;
	for(auto i = 0; i < n; ++i){
		int x, y, a;
		cin >> x >> y >> a;
		switch(a){
			case 1:
				left = max(left, x);
				break;
			case 2:
				right = min(right, x);
				break;
			case 3:
				bottom = max(bottom, y);
				break;
			case 4:
				top = min(top, y);
				break;
		}
	}
	cout << max(0, top - bottom) * max(0, right - left) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(T a){
	cout << a << '\n';
}
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll a,b,c;
int main(){
	g(a); g(b); g(c);
	if(a+b > c){
		puts("No");
	}
	else{
		ll L = 4ll*a*b;
		ll R = c-a-b; R*=R;
		if(L < R) puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n[10001] = {0};
    int m[10001] = {0};
    int i, j;
    
    while(1) {
        scanf("%d %d", &n[i], &m[i]);
        if(n[i] == 0 && m[i] == 0) break;
        i++;
    }
    
    for(j = 0; j < i; j++) {
        if(n[j] < m[j]) {
            printf("%d %d\n", n[j], m[j]);
        } else {
            printf("%d %d\n", m[j], n[j]);
        }
    }
    return 0;
}


Measured memory_bytes: 1996
#include<stdio.h>
int main(){
  long int n,a,b,h[100000],m=0,i,t,u=1,x;
  scanf("%ld%ld%ld",&n,&a,&b);
  for(i=0;i<n;i++){scanf("%ld",&h[i]);m=m<h[i]?h[i]:m;}
  t=m/b/2;
  while(1){
    x=0;for(i=0;i<n;i++)if(t*b<h[i])x+=(h[i]-t*b+a-b-1)/(a-b);
    if(x<=t){
      x=0;for(i=0;i<n;i++)if((t-1)*b<h[i])x+=(h[i]-(t-1)*b+a-b-1)/(a-b);
      if(x>t-1){printf("%ld",t);return 0;}
      u=u*2>m/b?m/b:u*2;t-=m/b/u;
    }
    else {u=u*2>m/b?m/b:u*2;t+=m/b/u;}
  }
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a[114514];
int main(){
	ll n,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++)cin>>a[i];
	ll num=-1;
	for(int i=1;i<n;i++){
		if(a[i]+a[i+1]>=l){
			num=i;
			break;
		}
	}
	if(num==-1)cout<<"Impossible\n";
	else{
		cout<<"Possible\n";
		for(int i=1;i<num;i++)cout<<i<<endl;
		for(int i=n-1;i>num;i--)cout<<i<<endl;
		cout<<num<<endl;
	}
	return 0;
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 200*1000+10, mod = 998244353;
ll p[maxn], n, m, ans, k, f[maxn], rf[maxn];

ll power(int a, int b, int m)
{
    if (b == 0)
        return 1;
    ll c = power(a, b / 2, m);
    if (b & 1)
        return (((c * c) % m) * a) % m;
    return (c * c) % m;
}

ll C(int a, int b)
{
    if (a < b || a < 0)
        return 0;
    return (((f[a] * rf[b]) % mod) * rf[a - b]) % mod;
}

int main()
{
    cin >> n >> m >> k;
    f[0] = rf[0] = 1;
    for (int i = 1; i < maxn; i++)
    {
        f[i] = (f[i - 1] * i) % mod;
        rf[i] = power(f[i], mod - 2, mod);
    }
    p[0] = 1;
    for (int i = 1; i < maxn; i++)
        p[i] = (p[i - 1] * (m - 1)) % mod;
    for (int i = 1; i <= k + 1; i++)
    {
        ans += (((C(n - 1, i - 1) * m) % mod) * p[n - i]) % mod;
        ans %= mod;
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 8332
N, M = map(int, input().split())
# N:スイッチの数、M：電球の数
s = [[] for _ in range(M)]
for i in range(M):
    temp = list(map(int, input().split()))
    s[i] = temp[1:]
p = list(map(int, input().split()))
ans = 0

# bit全探索
for i in range(2 ** N):
    on = [0 for _ in range(M)]
    for j in range(N): 
        if (i >> j) & 1:
            for k in range(M):
                if j+1 in s[k]:
                    on[k] += 1
    tf = []
    for on_n, p_n in zip(on, p):
        if on_n % 2 == p_n:
            tf.append(True)
        else:
            tf.append(False)
    if all(flg for flg in tf):
        ans += 1

print(ans)


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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18L+9
#define inf 1e9L+9
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()

const int mod=1e9L+7; 

void solve(){
  int n; cin>>n; 
  vector<int> h(n); 
  for(int i=0;i<n;i++) cin>>h[i]; 
  int ans=0; 
  int cur=0; 
  for(int i=0;i<n-1;i++){
    if(h[i+1]<=h[i]) cur++; 
    else {
      cur=0; 
    }
    ans=max(ans,cur); 
  }
  cout<<ans<<endl; 
}

int main()
{
	fast_io;
	clock_t beg=clock(); 
	solve(); 
	clock_t end=clock(); 
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
	return 0;
}

Measured memory_bytes: 640
#define M 1000000
#define sf scanf
#define pf printf

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,x,y;
    vector<int> a,b;
    cin>>n;
    int diff;
    for(int i = 0; i<n; i++)
    {
        cin>>x>>y;

        a.push_back(x);
        b.push_back(y);
    }

   long long cnt = 0;

    for(int i = n-1;i>=0;i--)
    {

        if((a[i]+cnt) % b[i] != 0)
        {

                 cnt += b[i] - (cnt + a[i]) % b[i];

        }
        else continue;

    }


    cout<<cnt<<endl;

return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int n;
  cin >>n;
  vector<int> p(n);
  rep(i,n) cin >> p.at(i);
  sort(p.begin(),p.end());
  int ans = p.at(n/2) - p.at(n/2 - 1);
  cout <<ans << endl;
}

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

const int maxn=1e5+10;
int flag[maxn],vis[maxn];

bool solve(int n)
{
    if(n==1)
        return false;
    for(int i=2; i<sqrt(n+0.5); i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

void table()
{
    memset(flag,0,sizeof(flag));
    memset(vis,0,sizeof(vis));
    for(int i=1; i<maxn; i++)
    {
        if(i%2)
        {
            if(solve(i)&&solve((i+1)/2))
            {
                vis[i]=1;
            }
        }
        flag[i]=flag[i-1];
        if(vis[i]==1)
        {
            flag[i]++;
        }
    }
}

int main()
{
    table();
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        int ans=flag[r]-flag[l];
        if(vis[l]==1)
            ans++;
        printf("%d\n",ans);
    }
    return 0;
}




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

int cntExch;

void bubbleSort(int A[], int n){
  for(int i = 0; i < n; i++){
    for(int j = n - 1; j > i; j--){
      if(A[j] < A[j-1]){
        swap(A[j], A[j-1]);
        cntExch++;
      }
    }
  }
}

int main(void){
  int n, A[100];

  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];

  bubbleSort(A, n);

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

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

constexpr int match_num[] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
    int N, M;
    cin >> N >> M;

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

    vector<int> dp(N+1, 0);
    for(int i = 1; i <= N; ++i){
        for(int j = 0; j < M; ++j){
            if(i-match_num[A[j]] >= 0){
                dp[i] = max(dp[i], dp[i-match_num[A[j]]]+1);
            }
        }

        if(dp[i] == 0){
            dp[i] = -1;
        }
    }

    sort(begin(A), end(A), greater<int>());

    string ans = "";
    while(N > 0){
        for(int i = 0; i < M; ++i){
            if(N-match_num[A[i]] >= 0 && dp[N-match_num[A[i]]] == dp[N]-1){
                ans += to_string(A[i]);
                N -= match_num[A[i]];
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
//#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

const int SZ = 1005,SZ0 = 256005;

int n,a[SZ],dp[SZ0];
bool bas[SZ];bool vis[SZ];
int sl,B[SZ],sum[SZ];

template<typename Type>inline void read(Type &xx){
    Type f = 1;char ch;xx = 0;
    for(ch = getchar();ch < '0' || ch > '9';ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9';ch = getchar()) xx = xx * 10 + ch - '0';
    xx *= f;
}

int DP(){
    for(int i = 1;i <= sl;i++) sum[i] = sum[i - 1] + B[i];
    dp[0] = 0;
    for(int i = 1;i <= sl;i++){
        int mn = B[i];
        for(int j = sum[i] / mn * mn;j >= (mn << 1);j -= mn)
            dp[j] = max(dp[j],dp[j - mn] + 1);
        dp[mn] = max(dp[mn],1);
    }
    int ans = 0;
    for(int i = 1;i <= sum[sl];i <<= 1) ans = max(ans,dp[i]);
    memset(dp,0x8f,sizeof dp);
    return ans;
}

bool is_least(int idx){
    if(vis[a[idx]]) return false;
    vis[a[idx]] = true;
    for(int j = 1;j <= n;++j)
        if(a[idx] % a[j] == 0 && bas[a[idx] / a[j]] && a[idx] > a[j])
            return false;
    return true;
}

int main(int argc, char** argv) {
    for(int i = 1;i < SZ;i <<= 1) bas[i] = true;
    while(scanf("%d",&n) != EOF && n){
        memset(dp,0x8f,sizeof dp);memset(vis,0,sizeof vis);
        for(int i = 1;i <= n;i++) read(a[i]);
        int ans = 0;
        for(int i = 1;i <= n;++i){
            if(!is_least(i)) continue;
            sl = 0;
            for(int j = 1;j <= n;++j)
                if(a[j] % a[i] == 0 && bas[a[j] / a[i]])
                    B[++sl] = a[j] / a[i];
            ans = max(ans,DP());
        }
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 4228
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    n,m=MI()
    dist=[[inf]*n for _ in range(n)]
    abc=[]
    for _ in range(m):
        a,b,c=MI()
        a,b=a-1,b-1
        abc.append((a,b,c))
        dist[a][b]=dist[b][a]=c
    for i in range(n):dist[i][i]=0
    for j in range(n):
        for i in range(n):
            for k in range(n):
                dist[i][k]=dist[k][i]=min(dist[i][k],dist[i][j]+dist[j][k])
    ans=0
    for a,b,c in abc:
        if dist[a][b]<c:ans+=1
    print(ans)

main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

const int d[4] = {0,2,6,19};

int main(){
    string s;
    cin >> s;
    bool ok = false;
    int ans = 0;
    int tmp = 0;
    rep(i,s.size()){
        rep(j,4){
            if(s[i]=='A'+d[j]){
                ok = true;
            }
        }
        if(ok){
            tmp++;
            ans = max(ans,tmp);
        }else{
            tmp = 0;
        }
        ok = false;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		if (x < a)
			System.out.println(0);
		else if (x >= a)
			System.out.println(10);
	}
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string t;
    for (int i = 0; i < n; ++i) t.push_back(i % 2 == 0 ? '1' : '0');
    int ans = 0;
    for (int j = 0; j < n; ++j) if (s[j] != t[j]) ans++;
    string u;
    for (int i = 0; i < n; ++i) u.push_back(i % 2 == 0 ? '0' : '1');
    int cnt = 0;
    for (int k = 0; k < n; ++k) if (s[k] != u[k]) cnt++;
    cout << min(ans, cnt) << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    int n;
    ll ans=0;
    string s;
    cin>>n>>s;
    int cnt[3]={0};
    rep(i,0,n){
        if(s[i]=='R'){
            ++cnt[0];
            ans+=1ll*cnt[1]*cnt[2];
            rep(j,i/2,i){
                int la=2*j-i;
                if(la>=0){
                    if(s[j]!=s[i]&&s[j]!=s[la]&&s[la]!=s[i])--ans;
                }
            }
        }
        else if(s[i]=='G'){
            ++cnt[1];
            ans+=1ll*cnt[0]*cnt[2];
            rep(j,i/2,i){
                int la=2*j-i;
                if(la>=0){
                    if(s[j]!=s[i]&&s[j]!=s[la]&&s[la]!=s[i])--ans;
                }
            }
        }
        else{
            ++cnt[2];
            ans+=1ll*cnt[1]*cnt[0];
            rep(j,i/2,i){
                int la=2*j-i;
                if(la>=0){
                    if(s[j]!=s[i]&&s[j]!=s[la]&&s[la]!=s[i])--ans;
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    multiset< string > st;
    int n;
    cin >> n;
    for( int i = 0; i < n; ++i ) {
        string s;
        cin >> s;
        sort( all( s ) );
        st.insert( s );

    }

    auto it = st.begin();
    string bef;
    bef = *it;
    ++it;
    LL cnt = 1, res = 0;
    for( ; it != st.end(); ++it) {
        if( bef != *(it) ) {
            res += ( cnt * ( cnt - 1) ) / 2;
            cnt = 1;
            bef = *it;

        } else {
            ++cnt;

        }
    }
    
    cout << res + ( ( cnt * ( cnt - 1 ) ) / 2 ) << endl;
    return 0;
}



Measured memory_bytes: 9600
# ABC 092 C
N = int(input())
s = [str(input()) for i in range(N)]
M = int(input())
t = [str(input()) for i in range(M)]
ans = 0

for i in range(N):
    ans = max(s.count(s[i])-t.count(s[i]), ans)

print(ans)


Measured memory_bytes: 3064
n, y = map(int, input().split())

y //= 1000

for a in range(0, n + 1):
    if a * 10 > y:
        break
    for b in range(0, n + 1):
        x = a * 10 + b * 5
        if x > y:
            break
        c = n - a - b
        if y == x + c:
            print(f"{a} {b} {c}")
            exit(0)
print("-1 -1 -1")

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

typedef long long ll;
typedef double d;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<=b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)
#define be(a) a.begin(),a.end()
#define sz(x) x.size();
#define nl cout<<"\n";
#define sp cout<<" ";
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define nlng long long n; cin>>n;
#define nint int n; cin>>n;
#define br break;
#define cn continue;
#define vec vector < int >
#define vecll vector < long long >
#define op() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    op();
   string s,s1,s2;int c,d;

   cin>>s;
   s1[0]=s[5];
   s1[1]=s[6];
   c=stoi(s1);
  s2[0]=s[8];
   s2[1]=s[9];
 d=stoi(s2);


 if(c<=4)
 {
    cout<<"Heisei";
    nl
 }
 else
 {
   cout<<"TBD";
 }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define PI 3.141592653589793
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
const ll MOD=1e9+7;

ll powmod(ll x,ll y){
	ll pow=1;

	for(ll i=0;i<y;i++){
		pow*=x;
		pow%=MOD;
	}

	return pow;
}


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

	ll N;
	ll ans=0;

	cin >> N;

	if(N==1)
		ans=0;
	if(N==2)
		ans=2;
	else
		ans=powmod(10,N)-powmod(9,N)-powmod(9,N)+powmod(8,N);

	ans%=MOD;
	ans=(ans+MOD)%MOD;
	
	cout << ans << endl;

	return 0;
}



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

using namespace std;

const int mod = 1e9 + 7;

long long paint(vector<vector<int>> &graph, int k){
  int n = (int)graph.size();
  vector<bool> painted(n, false);
  stack<int> s;
  
  long long color = k;
  painted[0] = true;
  long long t = k - 1;
  for(int child : graph[0]){
    painted[child] = true;
    s.push(child);
    color *= t;
    color %= mod;
    t--;
  }
  
  while(!s.empty()){
    int node = s.top();
    s.pop();
    t = k - 2;
    for(int child : graph[node]){
      if(painted[child]) continue;
      painted[child] = true;
      s.push(child);
      color *= t;
      color %= mod;
      t--;
    }
  }
  
  return color;
}

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<vector<int>> graph(N);
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  
  cout << paint(graph, K) << endl;
  
  return 0;
}

Measured memory_bytes: 6520
#include <cstdio>

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

void dfs(int x,int y) {
	map[x][y]=0;
	for(int i=0;i<4;i++) {
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx&&nx<12&&0<=ny&&ny<12&&map[nx][ny]) {
			dfs(nx,ny);
		}
	}
}

int main() {
	while(1) {
		for(int i=0;i<12;i++) {
			for(int j=0;j<12;j++) {
				map[i][j]=getchar()-'0';
			}
			getchar();
		}
		int count=0;
		for(int i=0;i<12;i++) {
			for(int j=0;j<12;j++) {
				if(map[i][j]) {
					dfs(i,j);
					count++;
				}
			}
		}
		printf("%d\n",count);
		if(getchar()==EOF) break;
	}
}

Measured memory_bytes: 932
#include <stdio.h>
signed main(){
  int N,M,i,j,count=0;
  double sum=0;
  scanf("%d %d",&N,&M);
  int A[100];
  for(i=0;i<N;i++){
    scanf("%d",A+i);
    sum+=A[i];
  }
  sum=sum/(4*M);
  for(i=0;i<N;i++){
    if(A[i]>=sum){
      count++;
    }
  }
  if(count>=M){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return(0);
}

Measured memory_bytes: 1648
#include<iostream>
//#include<bits/stdc++.h>
#include<cstdio>
#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#include<cstring>
//#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
const double eps=1e-6;
int a[maxn];
int main()
{
    //cout<<(double) 10/110<<endl;
    int a,b,c,d,e,f,c1=-1,c2=-1;
     int maxq=0,maxh=0;
     cin>>a>>b>>c>>d>>e>>f;
     //cout<<f/100/a<<endl;
     /*cout<<f/100/b<<endl;
     cout<<f*e/100/c<<endl;
     cout<<f*e/100/d<<endl;*/
      rep(i,0,f/100/a+1)
        rep(j,0,f/100/b+1)
          rep(k,0,f*e/100/c+1)
           rep(z,0,f*e/100/d+1)
           {
               int fr=(k*c+z*d),bac=(i*100*a+j*100*b);
               //double bi=(double)(k*c+z*d)/(i*100*a+j*100*b);
               int ss=fr+bac;
               if(fr*100<=e*bac&&fr*maxh>=bac*maxq&&ss<=f)
                 c1=ss,c2=k*c+z*d,maxq=fr,maxh=bac;
           }
 // cout<<maxs<<endl;
          cout<<c1<<" "<<c2<<endl;



}


Measured memory_bytes: 3616
//動的計画法

#include <cstdio>
#include <algorithm>
using namespace std;

int N,W;
int w[1001];
int v[1001];

int main(){
    scanf("%d %d",&N,&W);

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

    int dp[N + 1][W + 1];
    for(int i = 0; i < W + 1; i++){
        dp[0][i] = 0;
    }

    for(int i = 1;i <= N;i++){
        for(int j = 0;j <= W;j++){
            if(j - w[i - 1] < 0){
                dp[i][j] = dp[i - 1][j];
            }else{
                dp[i][j] = max(dp[i - 1][j],dp[i][j - w[i - 1]] + v[i - 1]);
            }
        }
    }

    printf("%d\n",dp[N][W]);

    return 0;
}


Measured memory_bytes: 6692
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
int n;
cin>>n;
vector<int> a(n);
for(int i=0; i<n; i++){
cin>>a[i];
}
vector<int> b(n);
for(int i=0; i<n; i++){
b[a[i]-1]=i+1;
}
for(int i=0; i<n; i++){
cout<<b[i]<<endl;
}
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  vector<string>lis={"dream","dreamer","erase","eraser"};
  int l=s.length();
  vector<vector<int>>edge(l);
  rep(i,l){
    rep(j,4){
      int ll=lis[j].length();
      int f=1;
      if(i+ll>l)continue;
      rep(k,ll){
        if(s[i+k]!=lis[j][k])f=0;
      }
      if(f){edge[i].push_back(i+ll);}
    }
  }
  vector<int>used(l+1);
  function<bool(int)>dfs=[&](int now){
    if(now==l)return true;
    used[now]=1;
    bool res=0;
    for(auto nn:edge[now]){
      if(used[nn])continue;
      res|=dfs(nn);
    }
    return res;
  };
  if(dfs(0))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;




  return 0;

}


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

int main() {
    ll n;
    cin >> n;
    
    ll ans = 0;
    if (n % 2 == 0) {
        ll syo = 10;
        while(n / syo != 0) {
            ans += n / syo;
            syo *= 5;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $ss);
$s = str_split($ss);
$len = count($s);
if ($len % 2 == 1) {
    echo 'No';
    return;
}
$list = [];
foreach ($s as $v) {
    if (!isset($list[$v])) {
        $list[$v] = 1;
    } else {
        $list[$v]++;
    }
}
foreach ($list as $v) {
    if ($v % 2 == 1) {
        echo 'No';
        return;
    }
}
echo 'Yes';


Measured memory_bytes: 3828
s = input()
l = len(s)
a = [0 for i in range(l)]
cur = 0
for i, ele in enumerate(s[::-1]):
  a[i] = cur
  if ele =="W":
    cur += 1

ans = 0
for i in range(l):
  if s[i]=="B":
    ans += a[l-i-1]
print(ans)

Measured memory_bytes: 11368
#include <iostream>

int main() {
  int A, B, C;
  std::cin >> A >> B >> C;

  bool ans;

  if (A == B) {
    if (A != C) {
      ans = true;
    } else {
      ans = false;
    }
  } else if (B == C) {
    if (A != C) {
      ans = true;
    } else {
      ans = false;
    }
  } else if (A == C) {
    if (B != C) {
      ans = true;
    } else {
      ans = false;
    }
  } else {
    ans = false;
  }

  std::cout << (ans ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<int> A(100001, 0);
vector<P> B;

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%d", &A[i]);
    sort(A.begin(), A.begin() + N);
    
    int num = -1;
    for(int i = 0; i < N; ++i){
        if(num != A[i]){
            num = A[i];
            B.push_back(make_pair(num, 1));
        }
        else ++B.back().second;
    }
    
    int ans = 0;
    for(int i = 0; i < B.size(); ++i){
        int sum = B[i].second;
        for(int j = i + 1; j < B.size(); ++j){
            if(B[i].first + 2 >= B[j].first) sum += B[j].second;
            else break;
        }
        ans = max(ans, sum);
    }
    printf("%d\n", ans);
    
    return 0;
}


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

int main()
{
    int n,a[100],k=0,i,flag,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        flag=0;
        for(j=i;j>=0;j--)
        {
         if(a[i]<a[j])
            flag=1;
        }
        if(flag==0)
            k++;
    }
    printf("%d",k);
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}

const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e5 + 9;

signed main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //std::cout.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    if (b * c >= a)
        cout << "Yes" << endl;
    else

        cout << "No" << endl;
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>
void read(T &res)
{
    res = 0;
    char c = getchar();
    T f = 1;
    while(c < '0' || c > '9')
    {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9')
    {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x)
{
    if(x < 0)
    {
        putchar('-');
        x = -x;
    }
    if(x >= 10)
    {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int main()
{
    ll s[3000];
    ll l,n,m;
    read(l);
    read(n);
    read(m);
    s[0]=n;
    for(int i=1;i<=l;i++){
       read(s[i]);
    }
    ll ans1;
    ll ans2=abs(s[l]-m);
    if(l!=1)
    ans2=max(abs(s[l]-s[l-1]),ans2);
    out(ans2);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		  int n = sc.nextInt();
		  int d = sc.nextInt();
		  int ans = 0;
		  for(int i=0;i<n;i++) {
			  double a = sc.nextInt();
			  double b = sc.nextInt();
			  if(Math.sqrt(a*a+b*b)<=d) {
				  ans++;
			  }
		  }
		  System.out.println(ans);
	}

}

Measured memory_bytes: 59528
# M-SOLUTIONS プロコンオープン 2020: B – Magic 2
A, B, C = [int(i) for i in input().split()]
K = int(input())

is_success = 'No'

for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k <= K and A * 2 ** i < B * 2 ** j < C * 2 ** k:
                is_success = 'Yes'

print(is_success)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,X,Y;
  cin >>N>>M>>X>>Y;
  int ma = X;
  int mi = Y;
  for(int i=0;i<N;i++){
    int a_i;
    cin >>a_i;
    ma = max(ma,a_i);
  }
  for(int i=0;i<M;i++){
    int b_i;
    cin >>b_i;
    mi = min(mi,b_i);
  }
  if(ma<mi) cout <<"No War" << endl;
  else cout << "War" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;L D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){return i?B[i]+M(i-(i&-i)):0;}L S(L x,L i){for(x=G(x)-M(i+1)+M(i++);i<1<<17;B[i]+=x,i+=i&-i);}L W(){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}main(){for(cin>>n>>k;++p<n;path[a][b]=path[b][a]=c)cin>>a>>b>>c;for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;for(cin>>a;cin>>s>>a>>b;*s&2?W():A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33508
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int pointer=0;
    int ans=0;
    for(int i=0;i<=n-3;i++){
        string temp=s.substr(i,3);
        if(temp=="ABC")ans++;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
import statistics

N = int(input())
A_suc = [int(a) for a in input().split()]
B_suc = [i + 1 for i in range(len(A_suc))]
C_suc = [i - j for i, j in zip(A_suc, B_suc)]
median = int(statistics.median(C_suc))
D_suc = [abs(i - median) for i in C_suc]
print(sum(D_suc))

Measured memory_bytes: 37548
#泊数
N = int(input())
#K+1泊以降
K = int(input())
#N泊に対する1泊当たりの料金
X = int(input())
#K+1泊に対する１泊当たりの料金
Y = int(input())
#宿泊費の合計
if(N<K):
    hotel_sum=N*X
else:
    hotel_sum=K*X+(N-K)*Y
print(hotel_sum)


Measured memory_bytes: 2940
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N; cin >> N;
    VI H(N);
    REP(i,N){
        cin >> H[i];
    }
    bool yn = true;
    for(int i=N-1; i>0; i--){
        if(H[i-1] > H[i]){
            H[i-1]--;
            if(H[i-1] > H[i]){
                yn = false;
                break;
            }
        }
    }
    // bool yn = true;
    // FOR(i,0,N-2){ //iマス目の右に。。。
    //     FOR(j,1,N-i){ //iマス目のj個右
    //         if( (H[i]-2) >= H[i+j]){
    //             yn = false;
    //             break;
    //         }
    //     }
    //     if(!yn) break;
    // }
    // for(int i=0,j=1; (i+j)<=N; i++){
    //     while((H[i]-2) < H[i+j]){
    //         j++;
    //     }
    //     if(j!=(N-i)){
    //         yn = false;
    //         break;
    //     }
    // }
    if(yn){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
  priority_queue<pair<int, int> > PQ;
  int color[MAX];
  int d[MAX];
  for ( int i = 0; i < n; i++ ) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0,0));
  color[0] = GRAY;

  while ( !PQ.empty()) {
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;

    color[u] = BLACK;

    if ( d[u] < f.first * (-1)) continue;

    for ( int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].first;
      if ( color[v] == BLACK ) continue;
      if ( d[v] > d[u] + adj[u][j].second) {
	d[v] = d[u] + adj[u][j].second;
	PQ.push(make_pair(d[v] * (-1), v));
	color[v] = GRAY;
      }
    }
  }

  for ( int i = 0; i < n; i++) {
    cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
  }
}

int main() {
  int k, u, v, c;

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    for ( int j = 0; j < k; j++) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  
  vector<long double> p(n);
  rep(i, 0, n) {
    long double P;
    cin >> P;
    p[i] = (P+1)/2;
  }
  
  vector<long double> wa(n+1);
  wa[0] = 0;
  rep(i, 1, n+1) {
    wa[i] += wa[i-1];
    wa[i] += p[i-1];
  }
  
  long double maxi = -1;
  rep(i, k, n+1)
    maxi = max(maxi, wa[i]-wa[i-k]);
  
  cout << fixed << setprecision(15) << maxi << "\n";

}

Measured memory_bytes: 6528
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math


NN = 202020
MOD = 10**9+7
# MOD = 998244353
INF = float("inf")

n, m = map(int, input().split())
H = list(map(int, input().split()))
Edge = [list(map(int, input().split())) for i in range(m)]

graph = [[] for _ in range(n)]
for e in Edge:
    graph[e[0]-1].append(e[1]-1)
    graph[e[1]-1].append(e[0]-1)

count = 0
for i in range(n):
    for adj in graph[i]:
        if H[adj] >= H[i]:
            break
    else:
        count += 1

print(count)


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

 ll n ,x;
 cin >> n >> x;
 ll ara[n+10];
 for(ll i=0; i<n; i++)
 {
     cin >> ara[i];
 }
 ll sum = 0;
 for(int i=1; i<n; i++)
 {
     if(ara[i]+ara[i-1]>x)
     {
        ll todel = (ara[i] + ara[i-1])-x;
        sum += todel;
         if(ara[i]>=todel)
            {
                //sum += ara[i] - todel;
                ara[i] -= todel;

            }
         else
         {
             //s//um += ara[i];
             //ara[i] = 0 ;
             //sum += ara[i-1] - (todel - ara[i]);

             ara[i-1] = ara[i-1] - (todel - ara[i]);
             ara[i] = 0;
         }

     }

 }
 cout << sum << endl;



  }


Measured memory_bytes: 4364