akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int mod = (int) 1e9 + 7;

const int MAXN = 405000;

long long binpow(long long x, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res = (res * x) % mod;
      p--;
    } else {
      x = (x * x) % mod;
      p /= 2;
    }
  }
  return res % mod;
}

long long inv(long long x) {
  return binpow(x, mod - 2) % mod;
}

int n, k;
long long f[MAXN];
long long invf[MAXN];
long long ans;

long long cnk(long long n, long long k) {
  long long res = f[n];
  res = res * inv(f[k]) % mod;
  res = res * inv(f[n - k]) % mod;
  return res;
}

int main() { 

  cin >> n >> k;

  f[0] = 1; invf[0] = inv(1);
  for (int i = 1; i <= 2 * n; i++) {
    f[i] = f[i - 1] * i % mod;
    invf[i] = inv(f[i]);
  }

  for (int i = n; i >= max(1, n - k); i--) {
    long long cur = cnk(n, i);
    cur = cur * cnk(n - 1, i - 1) % mod;
    // cerr << i << " " << cur << endl;
    ans = (ans + cur) % mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int neg = 1;
	REP(i,n){
		int a;
		cin >> a;
		if(a%2==0)neg*=2;
	}
	ll ans = 1;
	REP(i,n){
		ans *= 3;
	}
	ans -= neg;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
[abc127] F - Absolute Minima
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int NONE = 1e9 + 1;
const int MAX_Q = 2e5;
const int MAX_BIT_IDX = MAX_Q;

template <typename T>
class BIT {
public:
    T b[MAX_BIT_IDX + 1];
    int n;
    void init(int num);
    T sum(int i);          // i : [0, n), returns sum of [0, i)
    void add(int i, T x);  // i : [0, n)
};

template <typename T>
void BIT<T>::init(int num) {
    n = num;
    for (int i = 0; i <= n; i++) {
        b[i] = 0;
    }
    return;
}

template <typename T>
T BIT<T>::sum(int i) {
    T s = 0;

    for (; i > 0; i -= i & -i) {
        s += b[i];
    }
    return s;
}

template <typename T>
void BIT<T>::add(int i, T x) {
    for (i += 1; i <= n; i += i & -i) {
        b[i] += x;
    }
    return;
}

int Q;
bool ty[MAX_Q];
int a[MAX_Q], b[MAX_Q];
BIT<ll> bit1, bit2;

void solve() {
    vector<int> ca(Q);
    for (int i = 0; i < Q; i++) {
        ca[i] = a[i];
    }
    sort(ca.begin(), ca.end());
    ca.erase(unique(ca.begin(), ca.end()), ca.end());
    for (int i = 0; i < Q; i++) {
        if (a[i] != NONE) {
            a[i] = lower_bound(ca.begin(), ca.end(), a[i]) - ca.begin();
        }
    }

    bit1.init(Q);
    bit2.init(Q);
    int cnt = 0;
    ll sb = 0;
    for (int i = 0; i < Q; i++) {
        if (ty[i]) {
            // answer
            int ng = -1;
            int ok = Q;
            while (ok - ng > 1) {
                int m = (ok + ng) / 2;
                if (bit1.sum(m + 1) >= (cnt + 1) / 2) {
                    ok = m;
                } else {
                    ng = m;
                }
            }

            int x = ca[ok];
            ll cnt_x = bit1.sum(ok) - (bit1.sum(Q) - bit1.sum(ok));
            ll sa = -bit2.sum(ok) + (bit2.sum(Q) - bit2.sum(ok));
            ll fx = sb + 1LL * x * cnt_x + sa;
            cout << x << " " << fx << endl;
        } else {
            // update
            cnt++;
            bit1.add(a[i], 1);
            bit2.add(a[i], ca[a[i]]);
            sb += b[i];
        }
    }
}

int main() {
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int tmp_ty;
        cin >> tmp_ty;
        ty[i] = (tmp_ty == 2);
        if (ty[i]) {
            a[i] = b[i] = NONE;
        } else {
            cin >> a[i] >> b[i];
        }
    }
    solve();

    return 0;
}


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

int lowwer(const void *a, const void *b)
{
	const int *x = a;
	const int *y = b;

	return (*y - *x);
}

int main(void)
{
	int card[5];
	int ma;
	int i;
	int sum;

	while (~scanf("%d,%d,%d,%d,%d", card, card + 1, card + 2, card + 3, card + 4)){
		int bucket[16];
		int sort_bucket[16];

		memset(bucket, 0, sizeof(bucket));
		for (i = 0; i < 5; i++) bucket[card[i]]++;
		memcpy(sort_bucket, bucket, sizeof(bucket));
		qsort(sort_bucket, 16, sizeof(int), lowwer);

		bucket[14] = bucket[1];
		ma = sum = 0;
		for (i = 1; i < 15; i++) if (ma < (sum = (bucket[i] > 0 ? 1 : 0) * (sum + 1))) ma = sum;


		if 		(sort_bucket[0] == 4) 					puts("four card");
		else if (sort_bucket[0] + sort_bucket[1] == 5) 	puts("full house");
		else if (ma == 5) 								puts("straight");
		else if (sort_bucket[0] == 3)					puts("three card");
		else if (sort_bucket[0] + sort_bucket[1] == 4)	puts("two pair");
		else if (sort_bucket[0] == 2)					puts("one pair");
		else 											puts("null");
	}

	return (0);
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int MOD=1000000007,INF=1001001001;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int h,w,a,b,res=0;

signed main(){
    cin>>h>>w>>a>>b;
    COMinit();
    rep(i,0,h-a){
        res+=COM(b-1+i,b-1)*COM(w-b-1+(h-1-i),w-b-1);
        res%=MOD;
    }
    
    
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 12284
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000000
int main() {
    int N, K;
    cin >> N >> K;
    int h[N];
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    long long int dp[N];
    for(int i = 0; i < N; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    dp[1] = abs(h[1]- h[0]);
    for(int i = 2; i < N; i++) {
        for(int j = 1; j <= K && 0 <= i-j; j++) {
            dp[i] = min(dp[i], dp[i-j]+abs(h[i] - h[i-j]));
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

int main()
{
	int parts[512], check, num, wk, tk, kt, kr;
	vector<int> a, b, c;

	while(cin >> wk >> tk >> kt)
	{
		if(wk == 0 && tk == 0 && kt == 0 ) break;

		cin.clear();

		num = wk + tk + kt;

		cin >> check;

		for(int i = 0; i < 300; i++)
		{
			parts[i] = 2;
		}

		for(int i = 0; i < check; i++)
		{
			cin >> wk >> tk >> kt >> kr;

			if(kr)
			{
				parts[wk-1] = parts[tk-1] = parts[kt-1] = 1;
			}
			else
			{
				a.push_back(wk-1);
				b.push_back(tk-1);
				c.push_back(kt-1);
			}
		}

		for(int i = 0; i < a.size(); i++)
		{
			if		( parts[a[i]] == 1 && parts[b[i]] == 1) parts[c[i]] = 0;
			else if	( parts[a[i]] == 1 && parts[c[i]] == 1) parts[b[i]] = 0;
			else if	( parts[b[i]] == 1 && parts[c[i]] == 1) parts[a[i]] = 0;
		}

		for(int i = 0; i < num; i++)
		{
			printf("%d\n",parts[i]);
			//cout << parts[i] << endl;
		}

		a.clear();
		b.clear();
		c.clear();
	}

}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
using namespace std;
using ll=long long ;
int main(){
  ll A,B;
  cin >> A >> B;
  for(ll i=0;i<1000000;i++){
  	ll eight=i*0.08;
    ll ten=i*0.10;
    if( eight == A && ten == B ){
    	cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}

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

struct State{
    int i,j;
    int dir;
    int p;
    int q;
    bool mir;
};
bool operator<(State lhs,State rhs){
    return make_tuple(lhs.i,lhs.j,lhs.dir,lhs.p,lhs.q,lhs.mir)<make_tuple(rhs.i,rhs.j,rhs.dir,rhs.p,rhs.q,rhs.mir);
}
using Field=vector<string>;
int di[]={0,-1,0,1};
int dj[]={1,0,-1,0};
int pd[]={3,2,1,0};
int qd[]={1,0,3,2};

int main(){
    int n,m,a;
    cin>>n>>m>>a;
    Field f(n);
    for(int i=0;i<n;i++){
        cin>>f[i];
    }    
    int inii=-1;
    int inij=-1;
    deque<State> que;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(f[i][j]=='S'){
                que.push_back({i,j,3,a,a,true});
                inii=i;
                inij=j;
            }
        }
    }
    auto isRange=[&](int i,int j){
        return 0<=i && i<n && 0<=j&& j<m && f[i][j]!='#';
    };
    
    set<State> used;
    while(!que.empty()){
        auto st=que.front(); que.pop_front();
        if(f[st.i][st.j]=='S' && st.dir==1) continue;
        if(used.count(st)) continue;
        used.insert(st);
        if(f[st.i][st.j]=='G'){
            cout<<a-st.p+a-st.q<<endl;
            return 0;
        }
        if(isRange(st.i+di[st.dir],st.j+dj[st.dir])){
            State to=st;
            to.i+=di[st.dir];
            to.j+=dj[st.dir];
            to.mir=false;
            que.push_front(to);
        }
        if(st.mir)  continue;
        if(st.p>0){
            State to=st;
            to.p--;
            to.dir=pd[to.dir];
            to.mir=true;
            que.push_back(to);
        }
        if(st.q>0){
            State to=st;
            to.q--;
            to.dir=qd[to.dir];
            to.mir=true;
            que.push_back(to);
        }
    }
    cout<<-1<<endl;
    return 0;
}


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >>n;
    vector<int> bricks(n);
    bool flag = false;
    rep(i,n) {
        cin >> bricks[i];
        if (bricks[i] == 1) flag = true;
    }

    if (!flag) {
        cout << -1 << endl;
        return 0;
    }

    int cnt = 1;
    int ans = 0;
    rep(i,n){
        if(bricks[i]==cnt) cnt ++;
        else ans++;
    }

    cout << ans <<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

VEC( int, 0, h, 0 );

int f( int l, int r )
{
    if( l >= r ) return 0;
    if( l == r - 1 ) return h[l];

    int ans = 0;
    int min = *min_element(h.begin() + l, h.begin() + r);
    ans += min;
    int ll = l;
    for(int i=l; i<r; ++i)
    {
        h[i]-=min;
        if( h[i] == 0 )
        {
            int a = f( ll, i );
            ans += a;
            ll = i + 1;
        }
    }
    ans += f( ll, r );
    return ans;
}

int main()
{
    int n;
    cin >> n;
    h.assign( n, 0 );
    REP(i,n) cin>>h[i];

    int ans = f( 0, n );
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
array = [int(x) for x in input().split()]

res = []
for item in array:
    res.append(item-1)
    res.append(item)
    res.append(item+1)

res_dict = sorted(dict(collections.Counter(res)).items(), key=lambda x:x[1])
print(res_dict[-1][1])


Measured memory_bytes: 30936
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<vector<int>> e;
int n;
map<int,int> color;
vector<int> par;
void rec(int now,int p){
	par[now] = p;
	if(now == n-1){
		return;
	}
	for(int v:e[now]){
		if(v != p){
			rec(v,now);
		}
	}
}

void paint(int now,int p){
	for(int v:e[now]){
		if(v != p && (color[v] == 0 || color[v] == color[now])){
			color[v] = color[now];
			paint(v,now);
		}
	}
}

int main(){
	cin >> n;
	e.resize(n);
	par.resize(n);
	for(int i = 0;i < n-1;i++){
		int a,b;
		cin >> a >> b;
		a--,b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	rec(0,-1);
	par[0] = 0;
	vector<int> path;
	int v = n-1;
	while(par[v] != v){
		path.push_back(v);
		v = par[v];
	}

	path.push_back(0);

	reverse(path.begin(),path.end());
	for(int i = 1;i <= path.size();i++){
		if(i <= (path.size()+1) / 2)color[path[i-1]] = 1;
		else color[path[i-1]] = -1;
	}

	paint(0,-1);
	paint(n-1,-1);
	
	int cnt_black = 0;
	int cnt_white = 0;
	for(auto p:color){
		if(p.second == 1)cnt_black++;
		else if(p.second == -1)cnt_white++;
	}

	if(cnt_black <= cnt_white)cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
}


Measured memory_bytes: 16632
#pragma GCC optimize (2)
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

signed main()
{
    int a=read(), b=read(), c=read(), ans=min(b+c, a+2*b+1);
    printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
        	string s;
        	cin>>s;
        	if(s.at(s.length()-1)=='2'||s.at(s.length()-1)=='4'||  s.at(s.length()-1)=='5'||  s.at(s.length()-1)=='7'||  s.at(s.length()-1)=='9'){
        		cout<<"hon";
        	}    
        	else if(s.at(s.length()-1)=='3')
        		cout<<"bon";
        	else
        		cout<<"pon";
       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;
const double PI=3.14159265359;





int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m,q;
    cin>>n>>m>>q;
    
    vector<vector<int>> v(n+1);
    
    while(m--){
        int l,r;
        cin>>l>>r;
        
        for(int i=1; i<=l; i++){
            v[i].push_back(r);
        }
    }
    
    for(int i=1; i<=n; i++){
        sort(v[i].begin(), v[i].end());
    }
    
    while(q--){
        int l,r;
        cin>>l>>r;
        
        auto it=upper_bound(v[l].begin(), v[l].end(), r);
        
        cout<<it-v[l].begin()<<endl;
    }
    
    
    
    
    
    
    
   
    return 0;
}

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

int main() {
	int n,m,s = 0;
	cin >> n;
	m = n;
	while (m) {
		s += m%10;
		m /= 10;
	}
	if (n%s) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

const long long INF = 1e18;

bool check(long long b, long long n, long long s) {
    long long res = 0;
    for(; n; n /= b){
		res += n % b;
	}
    return res == s;
}

void solve() {
    long long n, s;
    cin >> n >> s;

    for (long long b = 2; b * b <= n; b++) {
        if (check(b, n, s)) {
            cout << b;
            return;
        }
    }
    
    if (n < s) {
        cout << -1;
        return;
    }
    else if (n == s) {
        cout << n + 1;
        return;
    }
    long long ans = INF;
    long long nv = n - s;
    for (long long factor1 = 1; factor1 * factor1 <= nv; factor1++) {
        if (nv % factor1 != 0)
            continue;
        long long factor2 = nv / factor1;
        if (check(factor1 + 1, n, s))
            ans = min(ans, factor1 + 1);
        if (check(factor2 + 1, n, s))
            ans = min(ans, factor2 + 1);
    }
    if (ans == INF)
        cout << -1;
    else
        cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
#include <algorithm>
	#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
#include <map>
#include <cmath>

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


int main() {
	double L;
	cin >> L;
	double s = L / 3;
	cout <<setprecision(10)<< s*s*s;

	return 0;

}

Measured memory_bytes: 256
// Author            -  Ranadev Varma
// Codeforces Handle -  Ranadev_CaptainR
// Codechef Handle   -  ranadev
 
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("O2")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("unroll-loops")
 
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <iterator>
#include <iomanip>
#include <set>

using namespace std ;

#define MOD 1000000007LL
#define LOD 1000000006
#define pi 3.14159

#define lol1 ios::sync_with_stdio(false)
#define lol2 cin.tie(NULL);cout.tie(NULL)

#define FOR(i,a,b)  for(int i = a ; i < b ; i++)
#define RFOR(i,a,b) for(int i = a ; i > b ; i--)

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

int func(int n)
{
    int div=0;
    for(int i = 1 ; i*i<=n ; i++)
    {
        if(n%i==0)
        {
            if(i==n/i)
            {
                div++;
            }
            else
            {
                div+=2;
            }
        }
    }
    return div;
}

int main()
{
    lol1;
    lol2;
    int n,ans=0;
    cin >> n;
    for(int i = 1 ; i <= n ; i+=2)
    {
        if(func(i)==8)
        {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll X;

ll ltmp;
string stmp;
double dtmp;

/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/
map<ll,ll> count_map;

int main(){

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

    cin >> N;
    cin >> X;
    cin >> M;

    ll ai = X;
    ll ni = 0;
    while(ni<N){
        count_map[ai]++;
        ni++;
        
        ai = ai * ai;
        ai = (ai + M ) % M;
        if(ai==0){
            ni = N;
            break;
        }
        else if(count_map[ai]>0){
            map<ll,ll> roop_val;
            ll am = ai;
            ll roop_cnt = 0;
            while(roop_val[am] == 0){
                roop_val[am]++;
                roop_cnt++;
                am = am * am;
                am = (am + M) %M;
            }

            ll leftN = N - ni;
            ll roopi = leftN/roop_cnt;
            //cout << "roop " << roop_cnt << " " << roopi << endl;
            for(auto x : roop_val) {
                ll val = x.first;
                count_map[val] += count_map[val] * roopi;
            }
            ni += roopi * roop_cnt;
            break;
        }
    }
    while(ni<N){
        count_map[ai]++;
        ni++;
        
        ai = ai * ai;
        ai = (ai + M ) % M;
    }

    ll ans = 0;
    for(auto x : count_map) {
        ll val = x.first;
        ll num = x.second;
        //cout << val << " " << num << endl;
        ans += val * num;
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 9836
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
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 x,ll y){return y?gcd(y,x%y):x;}

vector<vector<int>> getRet(int n);
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  int N = input();

  for(auto iter:getRet(N)){
    string s;
    for(auto iter2:iter){
      char c = iter2 - 1 + 'a';
      cout << c;
    }
    cout << endl;
  }
 
  return 0;
}

vector<vector<int>> getRet(int n){
  if(n == 1){
    return {{1}};
  }
  vector<vector<int>> prev = getRet(n - 1);
  vector<vector<int>> ret;
  for(auto iter:prev){
    int max = *(std::max_element(iter.begin(), iter.end()))+1;
    for(int i=1;i<=max;i++){
      vector<int> r = iter;
      r.push_back(i);
      ret.push_back(r);
    }
  }
  return ret;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  double h, a;

  cin >> h >> a;

  int ans = ceil(h / a);

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


Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: a,b,x

    read*, a,b,x

    if (a <= x .and. x <= a+b) then
        print'(a)', 'YES'
    else
        print'(a)', 'NO'
    end if
end program main

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long n;
    while(scanf("%ld",&n)!=EOF)
    {
        int i;
        long long sum=1;
        for(i=1; i<=n; i++)
        {
            sum*=i%1000000007;
            sum%=1000000007;
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
import copy
def main():
    n = int(input())
    s = [list(map(int,list((input())))) for i in range(n)]
    k = []
    f = True
    for start in range(n):
        s_ = copy.deepcopy(s)
        group = [0]*n
        group[start] = 1
        v = [start]
        searched = set([start])
        mx_k = 2
        f = True
        while True:
            v_ = []
            for i in v:
                edge = s_[i]
                for j in range(n):
                    if edge[j] == 1:
                        if group[j] == 0:
                            v_.append(j)
                            group[j] = mx_k
                        elif not abs(group[j]-group[i])==1:
                            f = False
                            break
                searched = searched | set(v)
                if not f:
                    break
            if not f:
                break
            if len(searched) == n:
                k.append(mx_k-1)
                break
            v = copy.deepcopy(v_)
            mx_k += 1
    if k:
        print(max(k))
    else:
        print(-1)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 122336
St = Win = 1
Sc = Lose = 2
Pa = Draw = 3
NoWin = -1 

def getWinHand hand
  st = hand.include? St
  sc = hand.include? Sc
  pa = hand.include? Pa
  if (st && sc && pa) || (st && !sc && !pa) || (!st && sc && !pa) || (!st && !sc && pa)
    NoWin
  elsif st && pa
    Pa
  elsif st && sc
    St
  elsif sc && pa
    Sc
  end
end

def getResult hand, winHand
  if winHand == NoWin
    Draw
  elsif hand == winHand
    Win
  else
    Lose
  end
end

def showResult hand
  winHand = getWinHand hand
  hand.each do |h|
    p getResult(h, winHand)
  end
end


until (n = $stdin.gets.to_i) == 0
  hand = [n]
  4.times do
    hand << $stdin.gets.to_i
  end
  showResult(hand)
end

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; i++) cin >> D[i];
    sort(D.begin(), D.end());
    int n, p;
    n = p = 0;
    for (int x = 12; x >= 0; x--) {
        bool possible = true;
        n = p = 0;
        for (int i = 0; i < N; i++) {
            if (p + x > D[i] && n - x < -D[i])
                possible = false;
            else if (p + x > D[i])
                n = -D[i];
            else if (n - x < -D[i])
                p = D[i];
            else {
                if (p >= -n) p = D[i];
                if (p < -n) n = -D[i];
            }
        }
        possible &= (p <= 12 && n >= -12 && 24 + n - p >= x);
        if (possible) {
            cout << x << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
xlist = []
xcount = 0
t = ""
for i in range((len(s))):
    if s[i] == "x":
        xcount += 1
    else:
        xlist.append(xcount)
        xcount = 0
        t += s[i]
xlist.append(xcount)
if t != t[::-1]:
    print(-1)
else:
    ans = 0
    for i in range(len(xlist)//2):
        ans += abs(xlist[i]-xlist[-(i+1)])
    print(ans)

Measured memory_bytes: 4120
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()

#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF=1e18;
const ll inf=1e9;
const ld eps=1e-7;
const ld pi=acos(-1);
const int dx[4]={0,0 ,1,-1};
const int dy[4]={1,-1,0,0};
const int N=1e3+11;
const int M=1e6+11;
const int mod1=998244353;
const int mod2=1e9+7;

int main(){
  char a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  int ans=0;
  if(a==d)ans++;
  if(b==e)ans++;
  if(c==f)ans++;
  cout<<ans;
}


Measured memory_bytes: 256
package main

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

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	n := scanInt(sc)
	var limit uint64 = 1
	for i := 0; i < 18; i++ {
		limit *= 10
	}
	var exp float64 = 1e18
	var res uint64 = 1
	over := false
	for i := 0; i < n; i++ {
		c := scanUint(sc)
		if c == 0 {
			fmt.Println("0")
			return
		}
		exp /= float64(c)
		res *= c
		if res > limit || exp < 1 {
			over = true
			res = 1
		}
	}
	if over {
		fmt.Println("-1")
		return
	}
	fmt.Println(res)
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanUint(sc *bufio.Scanner) uint64 {
	sc.Scan()
	u, _ := strconv.ParseUint(sc.Text(), 10, 64)
	return u
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 5124
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class ELogs {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        ll n,k;
        cin>>n>>k;
        ll a[n];
        for (int i=0;i<n;i++)
            cin>>a[i];
        ll mid,hi=100000000000ll,lo=1ll,ans=*max_element(a,a+n);
        while (hi>=lo){
            mid=(hi+lo)>>1;
            ll cuts=0;
            for (int i=0;i<n;i++){
                cuts+=(a[i]-1)/mid;
            }
//            cout<<mid<<" "<<cuts<<endl;
            if (cuts<=k){
                hi=mid-1;
                ans=min(mid,ans);
            }
            else lo=mid+1;
        }
        cout<<ans;
	}
};


int main() {
	ELogs solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5172
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    string s;
    cin >> s;
    int l = s.length();
    int counta = 0;
    int countb = 0;
    for(int i = 0; i < l; i++){
        if(i%2 == 0){
            if(s[i] != 'L') counta++;
        }
        else if(i%2 != 0){
            if(s[i] != 'R') countb++;
        }
    }
    //cout << counta << " " << countb << " " << l << endl;
    if(counta + countb == l) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void){
    int a[3],i,max,min;
    max = 0;
    min = 100;
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    for(i=0;i<3;i++){
        if(max<a[i]){
            max = a[i];
        }if(min>a[i]){
            min = a[i];
        }
    }
    printf("%d",max-min);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  rep(i, S.size())
  {
    if (S.substr(i, 2) == "hi")
    {
      i++;
      continue;
    }
    else
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

int main() {
  ll H, W;
  cin >> H >> W;
  ll h, w;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
  }
  else {
    if (H % 2 == 1) {
      h = H / 2 + 1;  //Hが奇数の時の、奇数座標の個数
    }
    else {
      h = H / 2; //Hが偶数の時の、奇数座標の個数
    }
    if (W % 2 == 1) {
      w = W / 2 + 1;
    }
    else {
      w = W / 2;
    }
    ll ans = h*w + (H-h)*(W-w);
    cout << ans << endl;
  }
}
  

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

#define forn(i,n) for (int i = 0; i < int(n); i++)

const int N = 1e6 + 10;
int n, a[N];

int solve() {
    int ans = 0;
    for (int k = 0; k <= n; k++) {
        ans += ((k&(n-1)) == k) * a[k] % 2;
        ans %= 2;
    }
    return ans;
}

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

    bool one = 0;
    cin >> n; 
    string s; cin >> s;

    forn(i,n) {
        cin >> a[i];
        a[i] = s[i]-'0';
        one |= a[i] == 2;
    }

    int factor = one ? 1 : 2;
    forn(i,n) a[i] /= factor;

    cout << factor*solve() << endl;

    return 0;
}


Measured memory_bytes: 5276
#include <iostream>
#define MOD 1000000007
using namespace std;
 
int main() {
    int n,k;
    cin>>n>>k;
    int* a = new int[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long** dp = new long*[n+1];
    for(int i=0;i<=n;i++){
        dp[i] = new long[k+2];
        for(int j=0;j<k+2;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<=a[0];i++){
        dp[1][i]=1;
    }
    for(int i=2;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(j==0){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = (dp[i-1][j]%MOD + dp[i][j-1]%MOD)%MOD  ;
                if(j-a[i-1]-1>=0){
                    dp[i][j] = (MOD + dp[i][j]%MOD - dp[i-1][j-1-a[i-1]]%MOD)%MOD; 
                }
            }
        }
    }
    cout<<dp[n][k]<<'\n';
	return 0;
}

Measured memory_bytes: 79488
#include <stdio.h>

int main(void){
	int a;
	int b;
	int c;

	scanf("%d %d %d", &a, &b, &c);

	if (a<b && b<c){
	printf("%s\n","Yes");
}else{
	printf("%s\n","No");
}

	return 0;
}


Measured memory_bytes: 2040
K = int(input())
import copy

present = [1,2,3,4,5,6,7,8,9]
while K >= len(present):
    K -= len(present)
    next = []
    for i in range(len(present)):
        tmp = present[i]
        r = tmp % 10
        if r != 0:
            next.append(tmp * 10 + r -1)
        next.append(tmp * 10 + r)
        if r != 9:
            next.append(tmp * 10 + r +1)
    present = next

print(present[K-1])

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

using namespace std;

int main()
{
  while(1)
  {
    string n;
    cin >> n;
    if(n == "0")
    {
      exit(0);
    }
    long long int ans = 0;
    for(int i = 0;i < n.size();i++)
    {
      ans += n[i] - '0';
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3160
#include<iostream>

using namespace std;

int main(){
  double vel;
  while(cin >> vel){
	double t,y,n=1;
	t = vel/9.8;
	y = 4.9*t*t;
	while(y > 5*n-5)n++;
	cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 1276
#include <iostream>

using namespace std;
 
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == 1 && b == 1 && c == 0) || (a == 0 && b == 0 && c == 1)) {
        cout << "Open" << endl;
    } else {
        cout << "Close" << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>
int main(void){
    int X, Y, n;
    double d, a, x, y, k, S, key = 1;
    k = 3.141592653589 / 2;
    scanf("%d", &n);
    while ( key ) {
    x = 1.0;
    y = 0;
    while ( n - 1 ) {
        S = atan2(x, y);
        x += cos( 2 * k - S );
        y += sin( 2 * k - S );
        n--;
    }
    X = x; Y = y;
    printf("%.2lf\n%.2lf\n", x, y);
    scanf("%d", &n);
    if ( n == -1 ) key = 0;
    }
    return 0;
}

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

const int B = 32, N = 200000;
template <class T>
void read(T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}
template <class T>
void write(T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct op {
	int ty, i, j, k;
	void print() {
		putchar(ty ? '+' : '<'), putchar(' ');
		write(i), putchar(' ');
		write(j), putchar(' ');
		write(k), putchar('\n');
	}
} ;
vector<op> ans_list; 
int cnt = 5, one = 5, pw2[B], bit1[B], bit2[B], rev1[B], rev2[B], val[B][B];

void build(int ty, int i, int j, int k) {
	op tmp = {ty, i, j, k};
	ans_list.push_back(tmp);
}
void binary() {
	int now = ++cnt;
	for (int i = B - 1; i >= 0; i--) {
		build(1, now, pw2[i], ++cnt);
		build(0, 0, cnt, cnt + 1), cnt++;
		build(0, cnt, one, cnt + 1);
		bit1[i] = ++cnt;
		for (int j = 0; j < i; j++) build(1, cnt, cnt, cnt + 1), cnt++;
		build(1, now, cnt, cnt + 1);
		now = ++cnt;
	}
	now = ++cnt;
	for (int i = B - 1; i >= 0; i--) {
		build(1, now, pw2[i], ++cnt);
		build(0, 1, cnt, cnt + 1), cnt++;
		build(0, cnt, one, cnt + 1);
		bit2[i] = ++cnt;
		for (int j = 0; j < i; j++) build(1, cnt, cnt, cnt + 1), cnt++;
		build(1, now, cnt, cnt + 1);
		now = ++cnt;
	}
}

int main() {
	build(1, 0, 1, 3);
	build(0, 4, 3, 5);
	pw2[0] = one;
	for (int i = 1; i < B; i++) {
		build(1, pw2[i - 1], pw2[i - 1], ++cnt);
		pw2[i] = cnt;
	}
	binary();
	for (int i = 0; i < B; i++) build(0, bit1[i], one, ++cnt), rev1[i] = cnt;
	for (int i = 0; i < B; i++) build(0, bit2[i], one, ++cnt), rev2[i] = cnt;
	for (int i = 0; i < B; i++) {
		for (int j = 0; j < B; j++) {
			build(0, rev1[i], rev2[j], cnt + 1);
			build(0, rev2[j], rev1[i], cnt + 2);
			build(1, rev1[i], cnt + 3, cnt + 4);
			build(1, rev2[j], cnt + 4, cnt + 5);
			build(1, cnt + 1, cnt + 5, cnt + 6);
			build(1, cnt + 2, cnt + 6, cnt + 7);
			build(0, cnt + 7, one, cnt + 8);
			cnt += 8;
			for (int k = 0; k < i + j; k++) build(1, cnt, cnt, cnt + 1), cnt++;
			val[i][j] = cnt;
		}
	}
	cnt++;
	for (int i = 0; i < B; i++) {
		for (int j = 0; j < B; j++) {
			build(1, cnt, val[i][j], cnt + 1), cnt++;
		}
	}
	build(1, cnt, cnt + 1, 2);
	write(ans_list.size()), putchar('\n');
	for (int i = 0; i < ans_list.size(); i++) ans_list[i].print();
	return 0;
}



Measured memory_bytes: 4176
import sys
sys.setrecursionlimit(10 ** 6)
MOD = 10**9+7
 
def input():
    return sys.stdin.readline()[:-1]
 
def main():
    l = list(map(int, input().split()))
    if len(set(l)) == 2:
        print("Yes")
    else:
        print('No')
 
 
if __name__ == "__main__":
    main()

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

int main(void){
    int n = 0, k = 0; 
    int p[200001] = {0};
    double sum[200001] = {0};
    double ans = 0, tmp = 0, ans_sum = 0;

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

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

    for(int i = 0; i < n; i++){
        tmp = 0;
        for(int j = 1; j <= p[i]; j++){
            tmp = tmp + j;
//            printf("j = %d tmp = %lf\n", j, tmp);
        }
//            printf("tmp = %lf\n", tmp);

        sum[i] += tmp / p[i];
    }

    for(int i = 0; i < k; i++){
        ans += sum[i];
    }
    ans_sum = ans;
//    printf("ans_sum = %lf\n", ans_sum);
    for(int i = 1; i < n - k + 1; i++){
        ans_sum = ans_sum - sum[i - 1] + sum[i + k - 1];
        if(ans < ans_sum){
            ans = ans_sum;
        }
//        printf("ans_sum = %lf i-1 = %d i+k = %d\n", ans_sum, i-1, i+k);
    }

/*
    for(int i = 0; i < n - k + 1; i++){
        ans_sum = 0;
        for(int j = i; j < i + k; j++){
            ans_sum += sum[j];
        }
        if(ans < ans_sum){
            ans = ans_sum;
        }
    }
*/

/*
    for(int i = 0; i < n - k + 1; i++){
        double sum = 0, tmp = 0;
//        printf("i = %d\n", i);
        for(int j = i; j < i + k; j++){
            tmp = 0;
            for(int l = 1; l <= p[j]; l++){
                tmp += l;
            }
            sum += tmp / p[j];
//            printf("j = %d p[j] = %d \n", j, p[j]);
        }
//        printf("sum = %lf\n", sum);
        if(ans < sum){
            ans = sum;
        }
    }
*/
    printf("%lf\n", ans);
    return 0;

} 


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextDouble();
        double b = scan.nextDouble();
        double C = scan.nextDouble();
        double c = Math.sqrt((a *a) + (b * b) - (2 * a * b * Math.cos(C * Math.PI / 180)));
        double l = a + b + c;
        double s = l/2;
        double area = Math.sqrt(s* (s-a) *(s-b) *(s-c));
        double h = area * (2 / a);
        System.out.printf("%.8f\n", area);
        System.out.printf("%.8f\n", l);
        System.out.printf("%.8f\n", h);

    }
}


Measured memory_bytes: 28240
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define NL cerr << endl;
#define chmax(a, b) a=(((a)<(b))?(b):(a))
#define chmin(a, b) a=(((a)>(b))?(b):(a))
#define F first
#define S second
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const P<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T> ostream& operator << (ostream& s, const set<T>& st) {
   s << "{";
   for (auto i = st.begin(); i != st.end(); ++i) {
      s << *i;
      if (next(i) != st.end()) s << ", ";
   }
   s << "}";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

struct BIND { int s, t, v; };

signed main()
{
   int N; cin >> N;
   V<int> t(N), v(N);
   REP(i, N) {
      cin >> t[i]; t[i] *= 4;
   }
   REP(i, N) {
      cin >> v[i]; v[i] *= 4;
   }
   V<int> s(N+1);
   REP(i, N) {
      s[i+1] = s[i] + t[i];
   }

   V<BIND> bs;
   REP(i, N) {
      bs.PB((BIND){ s[i], s[i+1], v[i] });
   }
   bs.PB((BIND){ 0, 0, 0 });
   bs.PB((BIND){ s[N], s[N], 0 });

   int dist = 0;
   int prev_v = 0;
   for (int u = 2; u <= s[N]; u += 2) {
      int MIN = INF;
      REP(i, N+2) {
         BIND b = bs[i];
         if (u < b.s) {
            chmin(MIN, b.v + (b.s - u));
         } else if (u > b.t) {
            chmin(MIN, b.v + (u - b.t));
         } else {
            chmin(MIN, b.v);
         }
      }
      dist += prev_v + MIN;
      prev_v = MIN;
   }

   double ans = double(dist)/16;
   printf("%.9lf\n", ans);;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<string> s(N);
  vector<int> t(N);
  REP(i, N) cin >> s[i] >> t[i];
  string X;
  cin >> X;

  REP(i, N){
    if(X == s[i]){
      int ans = 0;
      FOR(j, i+1, N){
        ans += t[j];
      }
      cout << ans << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main () {
  string s;
  cin >> s;
  int count = 0;
  if (s[0] == '1') ++count;
  if (s[1] == '1') ++count;
  if (s[2] == '1') ++count;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256