akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

char c[100][100];
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int h, w;

void dfs(int x, int y, char fruit)
{
	c[x][y] = '.';
	
	for(int i = 0; i != 4; ++i){
		int nx = x + dx[i],
			ny = y + dy[i];
		
		if(0 <= nx && nx < h && 0 <= ny && ny < w && c[nx][ny] == fruit)
			dfs(nx, ny, fruit);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(1){
		cin >> h >> w;
		if(h == 0 && w == 0)
			break;
		
		for(int i = 0; i != h; ++i){
			for(int j = 0; j != w; ++j){
				cin >> c[i][j];
			}
		}
		
		int res = 0;
		for(int i = 0; i != h; ++i){
			for(int j = 0; j != w; ++j){
				if(c[i][j] != '.'){
					dfs(i, j, c[i][j]);
					res++;
				}
			}
		}
		
		cout << res << endl;
	}
	return 0;
}

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

import sys

w = sys.stdin.readline().strip().lower()

num_w = 0

while True:
    s_lst = sys.stdin.readline().split()
    if s_lst[0] == 'END_OF_TEXT':
        break
    for str_x in s_lst:
        str_x = str_x.lower()
        if str_x == w:
            num_w += 1

print(num_w)



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

int main()
{
  ll n,k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(n) cin >> v[i];
  
  if(n<=k)
  {
    cout << 0 << endl;
    return 0;
  }

  sort(v.begin(),v.end(),greater<ll>());
  ll tmp = 0;
  for (ll i = k; i < n; i++)
  {
    tmp += v[i];
  }
  
  cout << tmp << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int ans = 0;
  string S;
  cin >> S;
  
  if(S.at(0) == '1'){
    ans++;
  }
  if(S.at(1) == '1'){
    ans++;
  
  }
  if(S.at(2) == '1'){
    ans++;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;


struct fish{
    int man;
    int point;
};


bool comp(const fish f1, const fish f2){
    if(f1.point<f2.point){
        return 0;
    }else if(f1.point>f2.point){
        return 1;
    }else{
        if(f1.man<f2.man){
            return 1;
        }else if(f1.man>f2.man){
            return 0;
        }else{
            return 0;
        }
    }
}

int main(){
    int n;
    while(cin>>n){
        fish f[20];
        for(int i=0; i<n; i++){
            cin>>f[i].man>>f[i].point;
        }
        
        sort(f, f+n, comp);
        
        
        
        cout<<f[0].man<<" "<<f[0].point<<endl;
        
        
       
    }
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef pair<int, int> P_i;
typedef pair<double,double> P_d;
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;int ans=0;
#define answer cout << ans << endl;
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;

using P=pair<int,int>;

signed main() {
  int N;
  cin >> N;
  vector<vector<P>> xy(N);
  rep(i,N){
    int A;
    cin >> A;
    rep(j,A){
      int x,y;
      cin >> x >> y;
      x--;
      xy[i].push_back(P(x,y));
    }
  }
  bool flag=false;
  int tmp=0,ans=-1;
  rep(bits,(1 << N)){
    flag=false;
    tmp=0;
    bitset<16> bit(bits);
    for (int i = 0; i < N; ++i) {
      if (bit[i]==0) continue;
      for(auto p : xy[i]){
        if(bit[p.first]==p.second);
        else{
          flag=true;
          break;
        }
      }
      if(flag){
        break;
      }
      else tmp++;
    }
    if(flag) continue;
    chmax(ans,tmp);
  }
  answer
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);


	
	int n,k; cin >> n >> k;
	double vd[n];
	rep(i,0,n-1){
		int a; cin >> a;
		if(i==0)vd[i] = (double)(a+1)/2.0;
		else vd[i] = vd[i-1] + (double)(a+1)/2.0;
		//cout << vd[i] << endl;
	}
	double best = vd[k-1];
	for(int i=k;i<n;i++){
		best=max(best,vd[i]-vd[i-k]);
		//cout<<best<<"\n";
	}
	printf("%.12f",best);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
ifstream in("in.txt");
int main(){
    ll a, b, c;
    cin>>a>>b>>c;
    ll r=(c-a-b)*(c-a-b)-4*a*b;
    if(r>0 && c-a-b>=0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) //aからbまで繰り替えす
#define vec vector<int>a(n)
#define soot(a) sort(a.begin(),a.end())
/*int n;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];*/
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	a -= 1;
	b -= a;
	REP(0, 2 * a) {
		printf("%d ", b + i);
	}

	return 0;
}

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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

vector< vector<double> > d;
double res;
int n, m;
vi used;

void dfs(int cn, int rest, double sum);

int main(void){
    for(; cin >> n >> m; printf("%.10f\n", res)){
        vector<double> l(n), a(n), b(n);
        rep(i, n) cin >> l[i] >> a[i] >> b[i];

        d = vector< vector<double> >(n, vector<double>(n));
        used = vi(n);

        rep(i, n) rep(j, n){
            d[i][j] = pow(l[i] - l[j], 2.) + pow(a[i] - a[j], 2.) + pow(b[i] - b[j], 2.);
        }

        res = 0.;
        dfs(0, m, 0.);
    }

	return 0;
}

void dfs(int cn, int rest, double sum){
    if(rest == 0){
        res = max(res, sum);
        return;
    }

    range(i, cn, n){
        double s = 0.;
        rep(j, i){
            s += used[j] * d[i][j];
        }

        used[i] = 1;
        dfs(i + 1, rest - 1, sum + s);
        used[i] = 0;
    }
}

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

int main() {
  int W;
  int a;
  int b;
  cin >> W >> a >> b;

  int c = max(b, a);
  int d = min(a+W, b+W);

  if(c - d < 0) {
    cout << 0 << endl;
  } else {
    cout << c - d << endl;
  }
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int a[4];
	FOR(i, 0, 4)
		cin >> a[i];
	sort(a, a + 4);
	cout << (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9 ? "YES" : "NO");
	return 0;
}

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

int main(){
	
	int h,tmp,filled,combo;
	int last_score, score;
	int a[10][5];
	
	while(1){
		score = 0;
		last_score = -1;
		scanf(" %d", &h);
		if(h == 0){
			break;
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<5;j++){
				scanf(" %d", (a[i]+j));
			}
		}
		
		
		while(last_score != score){	//while2 begin
			last_score = score;

			//erasing and scoring
			for(int i=0;i<h;i++){
				combo = 0;
				for(int j=1;j<5;j++){
					if(a[i][j] == a[i][j-1]){
						combo ++;
					}else{
						if(combo >= 2){
							for(int k=combo;k>=0;k--){
								score += a[i][j-1-k];
								a[i][j-1-k] = 0;
							}
						}
						combo = 0;
					}
				}
				//not DRY...
				if(combo >= 2){
					for(int k=combo;k>=0;k--){
						score += a[i][4-k];
						a[i][4-k] = 0;
					}
				}
			}
			
			//dropping
			for(int j=0;j<5;j++){
				filled = 0;
				for(int i=h-1;i>=0;i--){
					if(a[i][j] != 0){
						tmp = a[i][j];
						a[i][j] = 0;
						a[h-1 - filled][j] = tmp;

						filled ++;
					}
				}
			}
		//debug
/*		printf("score:%d\n",score);
		for(int i=0;i<h;i++){
			for(int j=0;j<5;j++){
				printf("%d ",a[i][j]);
			}
			printf("\n");
		}
*/			
		}		//while2 end	
		printf("%d\n",score);
	}
	
	return 0;
}

Measured memory_bytes: 1028
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////




int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n],b[n];
    rep(i,0,n-1)cin>>a[i]>>b[i];
    ll ans=0;
    rep(i,0,n-1){
        
        if((a[i]&k)==a[i])ans+=b[i];
    }
    ll N=32;
    for(ll i=0;i<=N;i++){
        if(((k>>i)&1)==0)continue;
        ll c=0;
        
        rep(j,0,n-1){
            bool f=true;
            rep(t,i,N){
                if(((k>>t)&1)==0||t==i){
                    if((a[j]>>t)&1)f=false;
                }
            }
            if(f)c+=b[j];
        }
        chmax(ans,c);
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main()
{
	int w, h, n;
	cin >> w >> h >> n;
	int wmax = w;
	int wmin = 0;
	int hmax = h;
	int hmin = 0;
	for (int i = 0; i < n; ++i) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) {
			wmin = max(wmin, x);
		}
		else if (a == 2) {
			wmax = min(wmax, x);
		}
		else if (a == 3) {
			hmin = max(hmin, y);
		}
		else {
			hmax = min(hmax, y);
		}
	}
	if (wmin < wmax && hmin < hmax) {
		cout << (wmax - wmin) * (hmax - hmin) << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

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

int main() {
	int N;
	int max = 0;
	cin >> N;
	int A1[N] = {};
	int A2[N] = {};
	for (int i = 0; i < N; i++) {
		cin >> A1[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> A2[i];
	}
	for (int i = 0; i < N; i++) {
		int A1_sum = 0;
		int A2_sum = 0;
		for (int j = 0; j <= i; j++) {
			A1_sum += A1[j];
		}
		for (int j = i; j < N; j++) {
			A2_sum += A2[j];
		}
		if (max < A1_sum + A2_sum) {
			max = A1_sum + A2_sum;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);
        int index = -1;
        long sum = a[0];
        for (int i = 0; i < n - 1; i++) {
            if (sum * 2 < a[i + 1]) {
                index = i;
            }
            sum += a[i + 1];
        }
        int ans = n - index - 1;
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int N=2e5+5;
int n,m,a[N],b[N],tree[4*N],tree2[4*N],lazy[4*N];
ll ans;
void initseg(int nd,int l,int r)
{
    if(l==r){ tree[nd]=b[l]; tree2[nd]=l; return; }
    int m=(l+r)/2;
    initseg(nd*2,l,m);
    initseg(nd*2+1,m+1,r);
    tree[nd]=tree[nd*2];
    tree2[nd]=l;
}
void pushdown(int nd,int l,int r)
{
    if(l!=r){
        lazy[nd*2]+=lazy[nd];
        lazy[nd*2+1]+=lazy[nd];
    }
    tree[nd]+=lazy[nd];
    lazy[nd]=0;
}
P query(int nd,int l,int r,int s,int e)
{
    if(r<s||e<l) return P(2e9,0);
    pushdown(nd,l,r);
    if(s<=l&&r<=e) return P(tree[nd],tree2[nd]);
    int m=(l+r)/2;
    return min(query(nd*2,l,m,s,e),query(nd*2+1,m+1,r,s,e));
}
void update(int nd,int l,int r,int s,int e)
{
    if(r<s||e<l) return;
    pushdown(nd,l,r);
    if(s<=l&&r<=e){
        lazy[nd]++;
        pushdown(nd,l,r);
        return;
    }
    int m=(l+r)/2;
    update(nd*2,l,m,s,e);
    update(nd*2+1,m+1,r,s,e);
    tree[nd]=min(tree[nd*2],tree[nd*2+1]);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){ cin>>a[i]; b[i]=a[i]; }
    sort(b+1,b+1+n);
    m=unique(b+1,b+1+n)-b-1;
    initseg(1,1,m);
    for(int i=1;i<=n;i++){
        int plc=lower_bound(b+1,b+1+m,a[i])-b;
        P tp=query(1,1,m,plc,m);
        ans+=(ll)tp.first-a[i];
        if(tp.second==1) continue;
        update(1,1,m,1,tp.second-1);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11264
#include <iostream>

int main() {
    //k is a 500 yen coin
    //x is a total yen amount
    int k, x;

    std::cin >> k >> x;
    if( (k*500) >= x) {
        std::cout << "Yes";
    }
    else {
        std::cout << "No";
    }

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n, ma, mb; cin>>n>>ma>>mb;
  int ans = INF;
  int dp[410][410];
  rep(i, 410) rep(j, 410) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i, n) {
    int a, b, c; cin>>a>>b>>c;
    RREP(j, 410-a, 0) RREP(k, 410-b, 0) {
      if (dp[j][k] != INF) {
        dp[j+a][k+b] = min(dp[j+a][k+b], dp[j][k]+c);
        if ((j+a)*mb == (k+b)*ma) ans = min(ans, dp[j+a][k+b]);
      }
    }
  }
  if (ans == INF) print(-1);
  else print(ans);

  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin >>a>>b>>c>>d>>e>>k;
  if(max({a,b,c,d,e})-min({a,b,c,d,e})>k){
   cout<<":(";
  }else{
   cout<<"Yay!";
  }

 return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

h = ri()
res = 0
count = 0
while h:
    h //= 2
    res += 2**count
    count += 1
print(res)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
  ll n, m, k; cin >> n >> m >> k;
  vector<ll> A(n),B(m), SA(n+1), SB(m+1); 
  rep(i, n) {cin >> A[i]; SA[i+1] = SA[i]+A[i];}
  rep(i, m) {cin >> B[i]; SB[i+1] = SB[i]+B[i];}

  ll res = 0;
  rep(cnt_a, n+1){
    ll num = k - SA[cnt_a];
    if(num<0)break;
    ll cnt_b = upper_bound(all(SB), num) - SB.begin();
    if(cnt_b)cnt_b--;
    chmax(res, cnt_a + cnt_b);
  }

  cout << res << ln;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//typedef pair<int,int> P;
struct P{int x,y;};
const ll INF=9e18;
char fld[50][50];
int dx[4]={0,-1,0,1};
int dy[4]={-1,0,1,0};
int W,H;
int rec(int x,int y){
      int clr=0;
      bool used[50][50];
      memset(used,false,sizeof(used));
      queue<P> Q;
      Q.push((P){x,y});
      while(!Q.empty()){
            P p=Q.front();Q.pop();
            if(used[p.x][p.y])continue;
            if(p.x<0||p.x>=W||p.y<0||p.y>=H)continue;
            used[p.x][p.y]=true;
            if(fld[p.x][p.y]=='B'){clr|=2;continue;}
            if(fld[p.x][p.y]=='W'){clr|=1;continue;}
            REP(i,4){
                  int nx=p.x+dx[i],ny=p.y+dy[i];
                  if(p.x<0||p.x>=W||p.y<0||p.y>=H)continue;
                  Q.push((P){nx,ny});
            }
      }
      if(clr==1)return 0;
      else if(clr==2)return 1;
      else return -1;
}
int main(){
      while(cin>>W>>H&&(W||H)){
            int ans[2];
            memset(ans,0,sizeof(ans));
            REP(i,H)REP(j,W)cin>>fld[j][i];
            REP(i,H){
                  REP(j,W){
                        if(fld[j][i]=='.'){
                              int f=rec(j,i);
                              if(f==-1)continue;
                              ans[f]++;
                        }
                  }
            }
            cout<<ans[1]<<" "<<ans[0]<<endl;
      }
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>

int n;
int o, e;
int main() {
    std::cin >> n;

    for(int i = 0; i < n; ++i) {
        int tmp;
        std::cin >> tmp;

        if(tmp % 2 != 0) {
            ++o;
        }
    }

    if(o % 2 == 0) {
        std::cout << "YES" << std::endl;
    }else {
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() { 
    ll N, K, x, ans=0;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> x;
        ans += min({abs(K-x), x});
    }
    cout << ans*2 << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

start = 0
x_sum = 0
all = 0

def find(start):
    global all
    all = 1
    if N == 1:
        print(1)
        exit()
    i = start
    x_sum = A[start]
    while 1:
        i += 1
        if x_sum & A[i] == 0:
            x_sum += A[i]
            all += i + 1- start
            if i == N-1:
                break
        else:
            x_sum -= A[start]
            start += 1
            i -= 1

find(0)
print(all)

Measured memory_bytes: 23560
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define int long

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

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

//----------------------------------
//----------------------------------

template<typename STL> inline void print_STL(STL c, string ab = ""){
	cout << ab << c[0];
	for(int i = 1; i < c.size(); ++i) cout << ' ' << c[i]; }

template<typename STL> inline void import_STL(STL& c, int n){
	typename STL::value_type tmp;
	for(int i = 0; i < n; ++i){	cin >> tmp; c.push_back(tmp);} }

istream& operator>>(istream& os, pair<double,double>& x)
{
	double tmp;
	os >> tmp;
	x.first = tmp;
	os >> tmp;
	x.second = tmp;
	return os;
}

ostream& operator<<(ostream& os, pair<double,double>& x)
{
	return os << x.first << ' ' << x.second;
}

pair<double, double> operator-(pair<double,double> a, pair<double,double> b)
{
	return {a.first - b.first, a.second - b.second};
}
pair<double, double> operator+(pair<double,double> a, pair<double,double> b)
{
	return {a.first + b.first, a.second + b.second};
}

double operator*(pair<double, double> a, pair<double,double> b)
{
	return a.first * b.first + a.second * b.second;
}
double sq(double a)
{
	return a * a;
}

double round4(double x)
{
	x *= 1000;
	if(x > 0)
		x = (int)(x + 0.50);
	else
		x = (int)(x - 0.50);
	return x / 1000.;
}

signed main()
{
	pair<double,double> a, b, c;
	int n;
	cin >>n;
	for(int i = 0; i < n; ++i)
	{
		cin >> a >> b >> c;
		pair<double, double> va = b-c, vb = c-a;
		/* cout << va <<' ' << vb << '\n'; */
		/* auto m = b + c, n = c + a; */
		/* m = {m.first / 2, m.second/2}; */
		/* n = {n.first / 2, n.second/2}; */
		double norm = va.first * vb.second - va.second * vb.first;
		/* double cx = va * m , cy = vb * n ; */
		double cx = sq(b.first) + sq(b.second) - sq(c.first) - sq(c.second);
		double cy = sq(c.first) + sq(c.second) - sq(a.first) - sq(a.second);
		double sx = cx * vb.second - cy * va.second;
		double sy = va.first * cy - cx * vb.first;
		sx /= norm * 2;
		sy /= norm * 2;

		double r = sqrt(sq(c.first - sx)+ sq(c.second - sy));
		sx = round4(sx);
		sy = round4(sy);
		r = round4(r);
		printf("%.3lf %.3lf %.3lf\n", sx, sy, r);
	}
}

Measured memory_bytes: 3188
#include <cstdio>
int main()
{
	int n,sum = 0; scanf("%d",&n);
	int m = n;
	while(m) {
		sum += m%10;
		m /= 10;
	}
	if((n % sum)) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n, p;
int dp[50][2];

signed main(){
	scanf("%ld %ld", &n, &p);
	int a1;
	scanf("%ld", &a1);
	if(a1%2 == 1){
		dp[0][0] = 1;
		dp[0][1] = 1;
	}else{
		dp[0][0] = 2;
		dp[0][1] = 0;
	}
	for(int i = 1; i < n; i++){
		int a;
		scanf("%ld", &a);
		if(a%2 == 1){
			dp[i][0] = dp[i-1][0] + dp[i-1][1];
			dp[i][1] = dp[i][0];
		}else{
			for(int j = 0; j < 2; j++){
				dp[i][j] = 2 * dp[i-1][j];
			}
		}
	}
	printf("%ld\n", dp[n-1][p]);
	return 0;
}


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

using namespace std;

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

    int ret = 1;
    char buf = s[0];
    for (size_t i = 1; i < n; ++i) {
        if (buf != s[i]) {
            ret++;
            buf = s[i];
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

const ll MAX_N=2e5+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(all(A)),reverse(all(A));
    ll ans=0,pw1=1,pw2;
    rep(i,2*N-2) pw1=pw1*2%MOD;
    pw2=pw1*2%MOD;
    rep(i,N) ans=(ans+(pw2+pw1*i%MOD)%MOD*A[i]%MOD)%MOD;
    cout << ans << endl;
}

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


typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;


#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;


#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it!= m.end(); it++)

const int MOD = 1e9 + 7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 +5;
const char nl = '\n';


int main(){

  string s, t; cin >> s >> t;
  for(int i = 0; i < s.size(); i++){
    if(s == t){
      cout << "Yes" << nl;
      return 0;
    }
    s = s[s.size()-1] + s;
    s.pop_back();
  }
  cout << "No" << nl;



  return 0;
}



















Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b;
  cin>>a;
  cin>>b;
  int a1= a+b;
  int a2=a-b;
  int a3=a*b;
  cout<<max({a1,a2,a3})<<endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
int main(){
  string s,t;
  cin >> s >> t;
  int a=0;
  rep(i, s.size()){
    if(s[i]!=t[i]){
      a++;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 3900
#include <iostream>
#include <vector>

using namespace std;

int main(){
	for(int N, M, P; cin >> N >> M >> P, N; ){
		int bet = 0;
		vector<int> l;
		for(int i = 0; i < N; i++){
			int X; cin >> X;
			l.push_back(X);	
			bet += X;
		}	
		if(l[M - 1]){cout << (bet * (100 - P) / l[M - 1]) << endl;}
		else{cout << 0 << endl;}
	}
	return 0;
}

Measured memory_bytes: 1216
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF 1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second
#define setprecision(d) cout << fixed << setprecision(d);

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

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

signed main(){
	ll n,memo = 0;
	cin >> n;
	ll a[n];
	rep(i,0,n){
		cin >> a[i];

		memo = memo^a[i];
	}

	if(memo == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
set<char>set;
map<char,ll>rensou;
bool flag=true;
for(int i=0;i<s.size();i++){
    set.insert(s.at(i));
    rensou[s.at(i)]++;
    if(rensou[s.at(i)]>2){
        flag=false;
    }
}
if(set.size()==2&&flag){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}









Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n,m;
ll ans;
int wide[1500001],hight[1500001];
int w[1505],h[1505];

void enumerate_hight(){
  int sum;
  for(int i=0;i<n;i++){
    sum=0;
    for(int j=i;j<n;j++){
      sum+=h[j];
      //cout<<"h: "<<sum<<endl;
      hight[sum]++;
    }
  }
}

void enumerate_wide(){
  int sum;
  for(int i=0;i<m;i++){
    sum=0;
    for(int j=i;j<m;j++){
      sum+=w[j];
      //cout<<"w: "<<sum<<endl;
      wide[sum]++;
    }
  }
}

void solve(){
  ans=0;
  for(int i=0;i<n;i++)cin>>h[i];
  enumerate_hight();
  for(int i=0;i<m;i++)cin>>w[i];
  enumerate_wide();
  //rep(i,100)cout<<i<<":  "<<wide[i]<<" "<<hight[i]<<endl;
  rep(i,1500001){ans+=wide[i]*hight[i];wide[i]=hight[i]=0;}
  cout<<ans<<endl;
}

int main(){
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    solve();
  }
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >>d;
    if (abs(c-a)<=d || (abs(b-a)<=d && abs(c-b)<=d) ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.io.*;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double pi = Math.PI;
		double area = r*r*pi;
		double length = 2*r*pi;
		System.out.printf("%f %f",area,length);
	}
}

Measured memory_bytes: 28164
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

vector<int> num;
int n, k, d, m, ans = 1<<30;
bool flag = false;

void DFS(int payment){
    if(payment >= n){
        ans = min(ans, payment);
        return;
    }
    if(flag && payment == 0) return;
    flag = true;
    for (int i = 0; i < m; i++) DFS(payment*10 + num[i]);
    return;
}

int main(){
    cin >> n >> k;
    m = 10 - k;
    bool flag[10];
    for (int i = 0; i < 10; i++) flag[i] = true;
    for (int i = 0; i < k; i++) {
        cin >> d;
        flag[d] = false;
    }
    for (int i = 0; i < 10; i++) if(flag[i]) num.push_back(i);
    DFS(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,K;
  cin >> N >> K;
  vi V(N);
  rep(i,N) {
    cin >> V[i];
  }
  int ans = 0;
  for(int i = 0; i <= K;i++) {
    for(int j = 0;i+j <= K;j++) {
      if(i+j > N) continue;
      int now = 0;
      PQ(int) q;
      rep(a,i) {
        now += V[a];
        q.push(V[a]);
      }
      rep(b,j) {
        now += V[N-b-1];
        q.push(V[N-b-1]);
      }
      for(int d = 0;i+j+d < K;d++) {
        if(!q.empty()) {
          int x = q.top();
          if(x > 0) break;
          now -= x;
          q.pop();
        }
      }
      ans = max(ans,now);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int in;
	vb b(11,false);
	rep(i,4){
		cin>>in;b[in]=true;
	}
	YN(b[1]&&b[4]&&b[7]&&b[9]);
}

 

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

type Num struct {
	C int
	T int
}

func main() {
	s := IOInitialize()
	s.Buffer([]byte{}, math.MaxInt64)
	N := Int(s)
	T := Int(s)
	nums := scanNums(s, N)
	minCost := 10000
	for _, num := range nums {
		if num.C < minCost && num.T <= T {
			minCost = num.C
		}
	}
	if minCost == 10000 {
		fmt.Println("TLE")
	} else {
		fmt.Println(minCost)
	}
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []Num) {
	for i := 0; i < len; i++ {
		c := Int(s)
		t := Int(s)
		nums = append(nums, Num{C: c, T: t})
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


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

int main() {
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  int ans = 0;
  
  for(int i = 0; i < M;i++){
    cin >> B.at(i);
  }
  
  vector<int> A(M);
  int D = C;
  for(int j = 0; j < N; j++){
  for(int i = 0; i < M;i++){
    cin >> A.at(i);
    D += A.at(i) * B.at(i);
  }
    if(D > 0){
      ans ++;
    }
    D = C;
    
  for(int i = 0; i < M;i++){
    A.at(i) = 0;
  }
    
  }
  cout << ans << endl;
  
}
  

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((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())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

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

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string s;
    cin >> s;
    int k;
    cin >> k;

    int t = 0;
    while (k > 0) {
        if (t == s.length() - 1) {
            k %= 26;
            s[t] = (char) ((s[t] + k - 'a') % 26 + 'a');
            break;
        }
        if (s[t]!='a' && 'z' - s[t] + 1 <= k) {
            k -= 'z' - s[t] + 1;
            s[t] = 'a';
        }
        t++;
    }

    cout << s << ENDL;

    return 0;
}

Measured memory_bytes: 720
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
using namespace std;
#define MOD 1000000007
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


// ローリングハッシュ
// 二分探索で LCP を求める機能つき
struct RollingHash {
	static const int base1 = 1007, base2 = 2009;
	static const int mod1 = 1000000007, mod2 = 1000000009;
	vector<long long> hash1, hash2, power1, power2;

	// construct
	RollingHash(const string& S) {
		int n = (int)S.size();
		hash1.assign(n + 1, 0);
		hash2.assign(n + 1, 0);
		power1.assign(n + 1, 1);
		power2.assign(n + 1, 1);
		for (int i = 0; i < n; ++i) {
			hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
			hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
			power1[i + 1] = (power1[i] * base1) % mod1;
			power2[i + 1] = (power2[i] * base2) % mod2;
		}
	}
	RollingHash(const Array& a) {
		int n = (int)a.size();
		hash1.assign(n + 1, 0);
		hash2.assign(n + 1, 0);
		power1.assign(n + 1, 1);
		power2.assign(n + 1, 1);
		for (int i = 0; i < n; ++i) {
			hash1[i + 1] = (hash1[i] * base1 + a[i]) % mod1;
			hash2[i + 1] = (hash2[i] * base2 + a[i]) % mod2;
			power1[i + 1] = (power1[i] * base1) % mod1;
			power2[i + 1] = (power2[i] * base2) % mod2;
		}
	}

	// get hash of S[left:right]
	inline pair<long long, long long> get(int l, int r) const {
		long long res1 = hash1[r] - hash1[l] * power1[r - l] % mod1;
		if (res1 < 0) res1 += mod1;
		long long res2 = hash2[r] - hash2[l] * power2[r - l] % mod2;
		if (res2 < 0) res2 += mod2;
		return { res1, res2 };
	}

	// get lcp of S[a:] and T[b:]
	inline int getLCP(int a, int b) const {
		int len = min((int)hash1.size() - a, (int)hash1.size() - b);
		int low = 0, high = len;
		while (high - low > 1) {
			int mid = (low + high) >> 1;
			if (get(a, a + mid) != get(b, b + mid)) high = mid;
			else low = mid;
		}
		return low;
	}
};


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

	ll n;
	cin >> n;
	Array a(n), b(n);
	REP(i, n)cin >> a[i];
	REP(i, n)cin >> b[i];
	Array aa(n), bb(n);
	REP(i, n)aa[i] = (a[i] ^ a[(i + 1) % n]);
	REP(i, n)bb[i] = (b[i] ^ b[(i + 1) % n]);
	RollingHash rh_a(aa), rh_b(bb);
	REP(i, n) {
		P ha1 = rh_a.get(i, n);
		P ha2 = rh_a.get(0, i);
		P hb1 = rh_b.get(0, n - i);
		P hb2 = rh_b.get(n - i, n);
		if (ha1 == hb1 && ha2 == hb2) cout << i << ' ' <<( a[i] ^ b[0] )<< endl;
	}


	return 0;
}


Measured memory_bytes: 22272
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// M-SOL_2020_D
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A[] = new int[N];

		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}

		Long Yen = (long) 1000;
		Long Kabu = (long) 0;

		for(int i=0; i<N-1; i++) {
			if(A[i] < A[i+1]) {
				if(A[i] <= Yen) {
					Kabu = Yen / A[i];
					Yen -= Kabu * A[i];
				}
			}
			if(A[i] > A[i+1]) {
				Yen += Kabu * A[i];
				Kabu = (long) 0;
			}
		}

		// 最終日
		Yen += Kabu * A[N-1];
		Kabu = (long) 0;

		System.out.println(Yen);

		// Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


Measured memory_bytes: 35696