akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n, m; cin >> n >> m;
	priority_queue<ll> pq;
	vl a(n); 
	rep(i, n) {
		cin >> a[i];
		pq.push(a[i]);
	}

	rep(i, m) {
		ll tmp = pq.top(); pq.pop();
		tmp >>= 1;
		pq.push(tmp);
	}

	ll ans = 0;
	rep(i, n) {
		ans += pq.top(); pq.pop();
	}

	cout << ans << endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x, y;
    int ans = 0;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        if((2 * i + 4 * (x - i)) == y){
            ans = 1;
            break;
        }
    }
    if(ans == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int N;
  int c=0;
  cin>>N;
  vector<long long>L(N);
  for(int i=0;i<N;i++){
  cin>>L[i];
    
  }
for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]){
if(L[i]+L[j]>L[k]&&L[k]+L[i]>L[j]&&L[j]+L[k]>L[i]){
c++;
}
        }
      }
    }
  }
  
  cout<<c<<endl;
}


Measured memory_bytes: 3628
INF = 10 ** 15
MOD = 10 ** 9 + 7 
from collections import deque

def main():
    N,K = map(int,input().split())
    number = [tuple(map(int,input().split())) for _ in range(N)]
    if K == 0:
        ans = 0
        for a,b in number:
            if a == 0:
                ans += b
        print(ans)
        return 

    msb = 30
    while (K>>msb)&1 == 0:
        msb -= 1

    ans = 0
    for i in range(msb + 1):
        x = K >> i
        if i > 0:
            x -= 1
        ret = 0
        for a,b in number:
            if (a>>i) | x == x:
                ret += b
        ans = max(ans,ret)      
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 16916
#include<iostream>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int h[N];
  for (int i=0; i<N; i++){
  cin>>h[i];}
  int sum=0;
  for (int i=0; i<N; i++){
    if (h[i]>=K) sum++;}
  cout<<sum<<endl;}
    
    

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}

/*!* [fenwick] *!*/
/*+* フェニック木
     長さNの配列の部分和と更新をO(log N)で行う *+*/
template <typename T, typename F = function<T(T, T)>>
struct Fenwick {
    int N;
    vector<T> array;
    const F f;
    const T id;
    Fenwick() {}
    Fenwick(int len, const F f, const T& id) : N(len), f(f), id(id) {
        array.assign(N, id);
    }
    inline int LSB(int x) { return x & (-x); }
    void update(int i, T val) {
        while(i < N) {
            array[i] = f(array[i], val);
            i += LSB(i + 1);
        }
    }
    // sum of the elements [0:i]
    T sum(int i) {
        i++;
        T s = id;
        while(i) {
            s = f(s, array[i - 1]);
            //   <--LSB-->
            i -= LSB(i);
        }
        return s;
    }
};

const int M = 26;

struct CharNum {
    int c[M];
};

int main() {
    const CharNum zeros = {0};
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    auto add = [&zeros](CharNum x, CharNum y) -> CharNum {
        CharNum retval = zeros;
        for(int i = 0; i < M; i++) retval.c[i] = x.c[i] + y.c[i];
        return retval;
    };
    Fenwick<CharNum, decltype(add)> fenwick(N, add, zeros);
    for(int i = 0; i < S.size(); i++) {
        char c = S[i];
        CharNum x = zeros;
        x.c[c - 'a'] = 1;
        fenwick.update(i, x);
    }
    for (int q = 0; q < Q; q++) {
        int mode, i, l, r;
        char c;
        cin >> mode;
        if (mode == 1) {
            cin >> i >> c;
            i--;
            if(S[i] == c) continue;
            CharNum x = zeros;
            x.c[S[i] - 'a'] = -1;
            fenwick.update(i, x);
            x = zeros;
            x.c[c - 'a'] = 1;
            fenwick.update(i, x);
            S[i] = c;
        } else if (mode == 2) {
            cin >> l >> r;
            l--;
            r--;
            CharNum L, R;
            L = l ? fenwick.sum(l - 1) : zeros;
            R = fenwick.sum(r);
            int ans = 0;
            for(int i = 0; i < M; i++) {
                ans += R.c[i] - L.c[i] > 0 ? 1 : 0;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 51716
N, M, K = map(int, input().split())
table = [-1]*N
def union(x, y):
    global table
    x, y = find(x), find(y)
    if x==y:
        return False
    else:
        if table[x]>table[y]:
            x, y = y, x
        table[x] += table[y]
        table[y] = x
        return True
def find(x):
    if table[x]<0:
        return x
    else:
        table[x] = find(table[x])
        return table[x]
def rank(x):
    return table[find(x)]
friend = [[] for _ in range(N)]
block = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)
    union(a-1, b-1)

for _ in range(K):
    c, d = map(int, input().split())
    block[c-1].append(d-1)
    block[d-1].append(c-1)

ans = [""]*N
for i in range(N):
    tmp = abs(rank(i)) - len(friend[i]) - 1
    cnt = 0
    for b in block[i]:
        if find(i)==find(b):
            cnt += 1
    ans[i] = str(tmp - cnt)
print(" ".join(ans))

Measured memory_bytes: 108420
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

template <typename T>
void ri(T& x);

const int MAXN = 1e5+4;

char s[MAXN];
int ans = 1; 

int main() {
    #ifdef DEBUG
        freopen("in", "r", stdin);
        // freopen("out", "w", stdout);
    #endif
    
    int len;
    scanf("%d%s", &len, s);
    for (int i=1; i<len; ++i) {
        if (s[i] != s[i-1]) ++ans;
    }

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

    return 0;
}





template <typename T>
void ri(T& x) {
    char c;
    bool minus = false;
    while ((c=getchar())<'0' || '9'<c)
        if (c == '-') minus = true;
    x = c-'0';
    while ('0'<=(c=getchar()) && c<='9')
        x = 10*x - '0' + c;
    if (minus) x = -x;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int N, T, A;
    int min_index = -1;
    double min_value = 100000;
    
    cin >> N;
    cin >> T >> A;
    
    for(int i = 0; i < N; i++){
        int temp;
        cin >> temp;
        if(abs(A - (T - 0.006 * temp)) < min_value){
            min_value = abs(A - (T - 0.006 * temp));
            min_index = i + 1;
        }
    }
        
    cout << min_index << endl;
    
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

int n, s;
int ans = 0;

void dfs(int pos, int sum,int count) {
	if (count == n&&sum == s) {
		ans++;
		return;
	}
	if (pos == 10 || count == n) {
		return;
	}

	dfs(pos + 1, sum + pos,count+1);
	dfs(pos + 1, sum,count);
}

int main() {
	while (cin >> n >> s&&(n != 0 || s != 0)) {
		ans = 0;
		dfs(0, 0, 0);
		cout << ans << endl;
	}
}

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

int main(void)
{
	int n;
	cin >> n;
	int min = 1000000, max = -1000000;
	long long sum = 0;
	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		sum += x;
		if (x < min) {
			min = x;
		}
		if (x > max) {
			max = x;
		}
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
main(){
  bitset<7> a[10];
  string num2[10]={"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
  for(int i=0;i<10;i++){
    a[i]=bitset<7>(num2[i]);
  }
  while(1){
    long long n,num;
    cin>>n;
    if(n==-1) break;
    bitset<7> now(0);
    for(int i=0;i<n;i++){
      cin>>num;
      bitset<7> out=now^a[num];
      cout<<(now^a[num])<<endl;
      now=a[num];
    }
  }
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;

int n, m;
vector<int> hv[200005];
struct edge
{
	int to, cap, rev;
}E[800005];
vector<int> G[200005];

void add_edge(int u, int v, int c)
{
	E[m].to = v;
	E[m].cap = c;
	E[m].rev = m ^ 1;
	G[u].push_back(m ++);
	E[m].to = u;
	E[m].cap = 0;
	E[m].rev = m ^ 1;
	G[v].push_back(m ++);
}

int dis[200005], cur[200005];
bool bfs()
{
	rep1(i, 2 * n) dis[i] = -1;
	queue<int> que;
	que.push(0);
	dis[0] = 0;
	while(!que.empty()) {
		int v = que.front();
		que.pop();
		rep(i, G[v].size()) {
			int ce = G[v][i];
			if(E[ce].cap > 0 && dis[E[ce].to] == -1) {
				que.push(E[ce].to);
				dis[E[ce].to] = dis[v] + 1;
			}
		}
	}
	if(dis[2 * n] == -1) return false;
	rep(i, 2 * n + 1) cur[i] = 0;
	return true;
}

int dfs(int v, int maxf)
{
	if(v == 2 * n) return maxf;
	if(maxf == 0) return 0;
	int ret = 0;
	for(; cur[v] < G[v].size(); cur[v] ++) {
		int ce = G[v][cur[v]];
		if(dis[E[ce].to] == dis[v] + 1 && E[ce].cap > 0) {
			int cf = dfs(E[ce].to, min(maxf - ret, E[ce].cap));
			E[ce].cap -= cf;
			E[E[ce].rev].cap += cf;
			ret += cf;
			if(ret == maxf) break;
		}
	}
	return ret;
}

int lp[200005], par[200005];

int dinic()
{
	int ret = 0;
	while(bfs()) ret += dfs(0, INF);
	return ret;
}

int main()
{
	scanf("%d", &n);
	rep1(i, n - 1) {
		int cs;
		scanf("%d", &cs);
		hv[i].resize(cs);
		rep(j, cs) {
			scanf("%d", &hv[i][j]);
			add_edge(hv[i][j], i + n, 1);
		}
		add_edge(i + n, n * 2, 1);
	}
	rep1(i, n) add_edge(0, i, 1);
	if(dinic() != n - 1) {
		printf("-1\n");
		return 0;
	}
	rep1(i, n) if(dis[i] == -1) {
		printf("-1\n");
		return 0;
	}
	
	rep1(i, 2 * n - 1) rep(j, G[i].size()) {
		int ce = G[i][j];
		if(E[ce].cap == 0 && dis[E[ce].to] == dis[i] - 1) {
			par[i] = E[ce].to;
			break;
		}
	}
	
	rep1(i, n) if(par[i] != 0) lp[par[i] - n] = i;
	rep1(i, n - 1) printf("%d %d\n", par[i + n], lp[i]);
	return 0;
}

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

int main() {
    int A, B, K;
    scanf ("%d %d", &A, &B);

    if ((A%2==0 && B%2==0) || (A%2!=0 && B%2!=0))
        printf ("%d\n", (A+B)/2);
    else
        printf ("IMPOSSIBLE\n");

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    while(cin >> n && n){
        ll cnt[26] = {};
        bool istie = true;

        rep(i,n){
            char s,c;
            vector<ll> v(26);
            cin >> s;
            cnt[s - 'A']++;
            rep(j,26)v[j] = cnt[j];
            sort(ALL(v));
            reverse(ALL(v));
            rep(j,26){
                if(v[0] == cnt[j])c = (char)('A' + j);
            }
            if(v[0] - v[1] > n - i - 1){
                if(!istie)continue;
                cout << c << " " << i+1 << endl;
                istie = false;
                // break;
            }
        }
        // cout << "!" << istie << endl;
        if(istie)cout << "TIE" << endl;
    }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;

int main()
{
    ll n,i,j,s=0,p=0,q;
    cin>>n;vector<ll> v(100000,0);
     set<string> st;
    while(n--)
    {
        string ss;cin>>ss;
        
        ll sum=0;
        
       
        st.insert(ss);
    }
    
    cout<<st.size();
}

Measured memory_bytes: 19448
#include<stdio.h>
int main(void){
int w,h;
for(;;){
scanf("%d %d",&w,&h);
if(w==0&&h==0)break;
else{
for(int i=0;i<w;i++){
for(int j=0;j<h;j++){
printf("#");
}
printf("\n");
}
printf("\n");
}
}
return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    
    vector<int> B(n);
    for (int i = 0; i < n; i++) {
        cin >> B.at(i);
    }

    vector<int> C(n);
    for (int i = 0; i < n; i++) {
        cin >> C.at(i);
    }
    sort(C.begin(), C.end());

    int64_t sum = 0;
    for (int j = 0; j < n; j++) {
        int b = B.at(j);
        auto itrA = lower_bound(A.begin(), A.end(), b);
        int i = distance(A.begin(), itrA);
        auto itrC = lower_bound(C.begin(), C.end(), b + 1);
        int k = distance(itrC, C.end());
        sum += (int64_t)i * k;
    }

    cout << sum << endl;
}

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

int main(){
long int n,d; cin>>n>>d;
int count = 0;
while(n--){
long int a,b; cin>>a>>b;
long int ans = a*a + b*b;
if(d*d >= ans) count++;
}
cout<<count;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<set>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		
		
		int dp[111][111]={0};
		rep(i,111)rep(j,111)dp[i][j]=1000000000;
		
		
		int m=0;
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			dp[a][b]=min(c,dp[a][b]);
			dp[b][a]=min(c,dp[a][b]);
			
			m=max(m,max(a,b));
		}
		m++;
		rep(i,111)dp[i][i]=0;
		
		
		rep(k,111){
			rep(i,111){
				rep(j,111){
					dp[i][j] = min(dp[i][k]+dp[k][j],dp[i][j]);
				}
			}
		}
		
		
		int ans=1000000000;
		int minp=-1;
		rep(i,111){
			int sum=0;
			rep(j,111){
				if(dp[i][j]==1000000000)continue;
				sum+=dp[i][j];
			}
			if(sum==0)continue;
			
			if(ans>sum){
				minp=i;
				ans = sum;
			}
		}
		printf("%d %d\n",minp,ans);
	}
}

Measured memory_bytes: 0
h,w = map(int, input().split( ))
#縦3
ans1 = h*((w+2)//3-(w//3))
#横3
ans2 = w*((h+2)//3-(h//3))

#T型
mn = min((h//3)*w, (h-h//3)*(w//2), (h-h//3)*((w+1)//2))
mx = max((h//3)*w, (h-h//3)*(w//2), (h-h//3)*((w+1)//2))
ans3 = mx-mn

#T型
mn = min(((h+2)//3)*w, (h-(h+2)//3)*(w//2), (h-(h+2)//3)*((w+1)//2))
mx = max(((h+2)//3)*w, (h-(h+2)//3)*(w//2), (h-(h+2)//3)*((w+1)//2))
ans4 = mx-mn

#横T
h,w=w,h
mn = min((h//3)*w, (h-h//3)*(w//2), (h-h//3)*((w+1)//2))
mx = max((h//3)*w, (h-h//3)*(w//2), (h-h//3)*((w+1)//2))
ans5 = mx-mn
mn = min(((h+2)//3)*w, (h-(h+2)//3)*(w//2), (h-(h+2)//3)*((w+1)//2))
mx = max(((h+2)//3)*w, (h-(h+2)//3)*(w//2), (h-(h+2)//3)*((w+1)//2))
ans6 = mx-mn



print(min(ans1,ans2,ans3,ans4,ans5,ans6))


Measured memory_bytes: 38256
#include <bits/stdc++.h>   
using namespace std;
#define N 3005   
#define REP(i, n) for(int i=0; i<n; i++)
/*
string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}
*/

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

string str;

int main(){
    cin >> str;
    reverse(str.begin(),str.end());
    REP(i,4) reverse(divide[i].begin(),divide[i].end());
    
    
    int can=1;
    int cou=0;
    for(int i=0;i<(int)str.size();){
        cou=0;
        for(int j=0;j<4;j++){
            if(str.substr(i,divide[j].size())==divide[j]){
                i+=divide[j].size();
            }else{
                cou++;
            }
        }
        if(cou>=4){
            can=0;
            break;
        }
    }

    if(can==1){
        printf("YES");
    }else{
        printf("NO");   
    }
}





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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

signed main() {
  IOS;
  int N, ans;
  cin >> N;
  cout << 180*(N-2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 200005
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f

using namespace std;

int n, a[maxn], x;

signed main(){
	scanf("%lld%lld", &n, &x);
	a[0] = 0;
	for (int i = 1; i <= n; i++) scanf("%lld", a + i), a[i] += a[i - 1];
	
	int ans = INF, sum;
	for (int k = 1; k <= n; k++){
		sum = x * n + x * k; int t = 3;
		for (int i = n; i >= 1; i -= k){
			sum += (a[i] - a[max(0ll, i - k)]) * max(5ll, t), t += 2;
			if (sum >= ans) break;
		}
		ans = min(ans, sum);
	} printf("%lld\n", ans);
	
	return 0;
} 

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

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

	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (abs(a - b) <= (v - w) * t) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    bool edge[10][10] = {};
    int N, M;
    cin >> N >> M;

    rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        edge[A][B] = edge[B][A] = true;
    }

    vector<int> vs(N);
    iota(ALL(vs), 0);

    int ans = 0;
    do {
        bool ok = true;
        rep(i, N-1) ok &= edge[vs[i]][vs[i+1]];
        ans += ok;
    } while (next_permutation(vs.begin()+1, vs.end()));
    cout << ans << endl;
}



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

int main(){
  int n,m;
  bitset<10> bb;
  cin >> n >> m;
  vector<bitset<10>> sw(m);
  vector<int> p(m);
  for(int i=0;i<m;i++){
    int k; cin >> k;
    for(int ii=0;ii<k;ii++){
      int a; cin >> a; sw.at(i).set(a-1);
    }
  }
  for(int i=0;i<m;i++) cin >> p.at(i);
  
  int cnt = 0;
  for(int i=0;i<(1<<n);i++){
    bb = i; bool can = true;
    for(int j=0;j<m;j++){
      int tmpcnt = 0;
      for(int k=0;k<n;k++) if(sw.at(j).test(k) && bb.test(k)) tmpcnt++;
      if(tmpcnt%2 != p.at(j)) can = false;
    }
    if(can) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
-- Your code here!
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
 
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,a,b] <- getIntList
    
    print $ min (n*a) b

Measured memory_bytes: 380
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    const double PI=3.14159265358979323846;
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double a_x, a_y, b_x, b_y;
    a_x = a * cos(30 * (h + m / 60) * PI / 180);
    a_y = a * sin(30 * (h + m / 60) * PI / 180);
    b_x = b * cos(6 * m * PI / 180);
    b_y = b * sin(6 * m * PI / 180);
    cout << fixed << setprecision(15) << sqrt(pow((a_x - b_x), 2.0) + pow((a_y - b_y), 2.0));
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    string s; cin >> s;
    sort(s.begin(), s.end());
    cout << (s[0] == s[1] && s[2] == s[3] && s[0] != s[2] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

int get(vector <int> &v, int d) {
   int ans = 0;
   for(auto &e: v) {
      ans += (e - d) * (e - d);
   }
   return ans;
}

void solve() {
   int n;
   cin >> n;
   vector <int> v(n);
   for(int i = 0; i < n; i++) {
      cin >> v[i];
   }
   int sum = accumulate(v.begin(), v.end(), 0);
   double avg = sum / n;
   int nearest = (int) avg;

   int ans = INT_MAX;
   for(int i = nearest; i <= nearest + 1; i++) {
      ans = min(ans, get(v, i));
   }
   cout << ans << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


Measured memory_bytes: 3588
//
//  main.cpp
//  ABC081A_placingmarbles
//
//  Created by 岡本 朋大 on 2019/05/29.
//  Copyright © 2019年 岡本　朋大. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int a = 0;
    for(int i = 0;i <3;i++){
        if(s[i] == '1') a++;
    }
    cout << a << endl;
}


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

int main(){
    string s;
    cin >> s;
    
    int c_01 = 0;
    int c_10 = 0;

    int n = s.length();
    for (int i = 0; i < n; i++) {
        //cout << s[i];
        
        if ((i % 2) == 0) {
            if (s[i] == '0') ++c_10;
            else ++c_01;
        } else {
            if (s[i] == '1')  ++c_10;
            else ++c_01;
        }
    }
    cout << min(c_10, c_01) << endl;
    return 0;
}


Measured memory_bytes: 512
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
xys = [None]*n
for i in range(n):
    x,y = map(int, input().split())
    xys[i] = (x,y)

def sub(p,q):
    seen = [False]*n
    ans = 0
    for start in range(n):
        if seen[start]:
            continue
        ans += 1
        qq = [start]
        seen[start] = True
        while qq:
            u = qq.pop()
            for i,(x,y) in enumerate(xys):
                if seen[i]:
                    continue
#                 print(xys[u][1], y, p, q)
                if (xys[u][0]-x, xys[u][1]-y) == (p,q) or (xys[u][0]-x, xys[u][1]-y) == (-p,-q):
                    qq.append(i)
                    seen[i] = True
    return ans
ans = 10**10
for i in range(n):
    for j in range(n):
        p = xys[i][0]-xys[j][0]
        q = xys[i][1]-xys[j][1]
        val = sub(p,q)
        ans = min(ans, val)
print(ans)

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

int p[101];
int x, n;

//bool search(int a[], int key,int n) {
//    if()
//}
int main()
{

  


    cin >> x >> n;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        p[a] = 1;
    }
    bool ok = true;
    int sa = 0;
    int ans;
    while (ok) {

        int m1 = x - sa;
        int m2 = x + sa;

        if (p[m1] == 0) {
            ans = m1;
            break;
        }
        if (p[m2] == 0) {
            ans = m2;
            break;
        }


        sa++;
    }
    cout << ans << endl;

    return 0;
}




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

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

int main()
{
  string cls;
  int a, b;

  REP(i, 9){
    cin >> cls >> a >> b;
    cout << cls << " " << a + b << " " << a * 200 + b * 300 << endl;
  }
}

Measured memory_bytes: 1200
/*
    Oh, let the bullets fly, oh, let them rain
    My life, my love, my drive, it came from
                    ~Pain~
*/

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int mx=1e5+10;
int ar[mx],n,dp[mx];

void solve()
{
    cin>>n;

    for(int i=1;i<=n;i++) cin>>ar[i];

    for(int i=2;i<=n;i++)
    {
        if(i==2) dp[i]=abs(ar[i]-ar[i-1]);
        else dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]), dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<dp[n]<<endl;
}

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

    int t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4396
n, k = map(int, input().split())
P = list(map(int, input().split()))

total = sum(P[:k])
tmp = total
start = 0
for i in range(0, n - k):
    tmp = tmp - P[i] + P[i + k]
    if total < tmp:
        total = tmp
        start = i + 1

ret = 0
for i in range(start, start + k):
    ret += (P[i] + 1) / 2

print(ret)


Measured memory_bytes: 24804
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int x, y, z, K;
    cin >> x >> y >> z >> K;

    ll A[x], B[y], C[z];
    for (int i = 0; i < x; i++) cin >> A[i];
    for (int i = 0; i < y; i++) cin >> B[i];
    for (int i = 0; i < z; i++) cin >> C[i];

    sort(A, A+x, greater<ll>());
    sort(B, B+y, greater<ll>());
    sort(C, C+z, greater<ll>());

    priority_queue <ll, vector <ll>, greater<ll> > q;
    for (ll a : A) {
        for (ll b : B) {
            for (ll c : C) {
                ll sm = a + b + c;
                
                if (q.size() < K) {
                    q.push(sm);
                } else {
                    if (sm <= q.top()) {
                        break;
                    } else {
                        q.pop();
                        q.push(sm);
                    }
                }
            }
        }
    }

    int i = K-1;
    vector <ll> ans(K);
    while (q.size()) {
        ans[i--] = q.top();
        q.pop();
    }

    for (ll ret : ans) cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 2e5+5, OO = 0x3f3f3f3f;
//int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Directio
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class BIrohaLovesStringsABCEdition {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n, l; in >> n >> l;
        vector<string> v(n);
        for (string& s: v) in >> s;
        sort(v.begin(), v.end());
        string ans = "";
        for (string s: v) {
            ans += s;
        }
        out << ans << el;
	}
};


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


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

bool hantei(int x){
	for(int i=1;i<=x;i++){
    	if(i*i==x){
        	return 1;
        }
    }
  return 0;
}

int main() {
  int a,b,c,d,sum,ans;
  string s;
  cin>>a>>b;
  ans=0;
  vector<vector<int>> vec(a,vector<int>(b));
  
  for(int i=0;i<a;i++){
  	for(int j=0;j<b;j++){
    	cin>>vec.at(i).at(j);
    }
  }
  
  for(int i=0;i<a-1;i++){
  	for(int j=i+1;j<a;j++){
    	sum=0;
      	for(int k=0;k<b;k++){
        	c = vec.at(i).at(k) - vec.at(j).at(k);
          	sum += c*c; 
        }
      	if(hantei(sum))ans++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

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

int main(){

    while(true){
        int N, M;
        cin >> N >> M;
        if(N == 0){
            break;
        }
        vector<int> s(M);
        vector<vector<int>> c(M);

        vector<int> maxScore(N, 0);
        vector<int> minScore(N, 0);

        for(int i = 0; i < M; i++){
            cin >> s[i];
            int k;
            cin >> k;
            int temp;
            if(k == 1){
                cin >> temp;
                temp--;
                minScore[temp] += s[i];
                maxScore[temp] += s[i];
            }
            else{
                for(int j = 0; j < k; j++){
                    cin >> temp;
                    temp--;
                    maxScore[temp] += s[i];
                }
            }
        }

        vector<pair<int, int>> maxPair(N);
        vector<pair<int, int>> minPair(N);
        for(int i = 0; i < N; i++){
            maxPair[i] = make_pair(maxScore[i], i);
        }
        for(int i = 0; i < N; i++){
            minPair[i] = make_pair(minScore[i], i);
        }

        sort(maxPair.begin(), maxPair.end(), greater<pair<int, int>>());
        sort(minPair.begin(), minPair.end());

        int ans = 0;
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j++){
                auto big = maxPair[i];
                auto small = minPair[j];
                if(big.second == small.second){
                    continue;
                }
                ans = max(ans, big.first - small.first);
            }
        }

        cout << ans + 1 << endl;
    }


    return 0;
}


Measured memory_bytes: 3220
N, W = map(int, input().split())
objects = [tuple(map(int, input().split())) for i in range(N)]

dp = {(0, j):0 for j in range(W + 1)}

for i in range(N):
    for j in range(W + 1):
        if j < objects[i][1]:
            dp[(i + 1, j)] = dp[(i, j)]
        else:
            dp[(i + 1, j)] = max(dp[i, j], dp[i + 1, (j - objects[i][1])] + objects[i][0])

print(dp[(N, W)])



Measured memory_bytes: 144220
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
int n,m,k,ans;
int main(){
	n=read();
	REP(i,1,n){
		m=read(),k=read();
		while(1){
			if(m%k==0){
				ans^=(m/k);
				break;
			}
			m-=max(1,(m-(m/k)*k)/(m/k+1))*(m/k+1);
		}
	}
	puts(ans?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, init) for (int i = init, len = (n); i < len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())
#define int long long
#define float long double
using namespace std;

template <class Key, class Value>
pair<Key, Value> findMaxValuePair(unordered_map<Key, Value> const &x) {
  return *max_element(
      x.begin(), x.end(),
      [](const pair<Key, Value> &p1, const pair<Key, Value> &p2) { return p1.second < p2.second; });
}

string padStart(int target, int len, char padString) {
  ostringstream ss;
  ss << setfill(padString) << right << setw(len) << target << flush;
  return ss.str();
}

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

  string N;

  cin >> N;

  int total = 0;
  rep(i, len(N), 0) total += (int)(N.at(i) - '0');

  cout << (total % 9 == 0 ? "Yes" : "No") << endl;

  return 0;
}


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

long n,x,y,ans,check,num=1e10;

int main(){
    scanf("%ld",&n);
    while(n--){
        scanf("%ld%ld",&x,&y);
        ans += x;
        if(x != y)  check = 1;
        if(x > y && num > y) num = y;
    }
    printf("%ld",check ? ans-num : 0);
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

int n, A[1010][1010], B[1010][1010];

void compute() {
  vector<int> pos(n,0);
  memset(B,-1,sizeof B);
  int rem = n * ( n - 1 );
  while( rem > 0 ) {
    bool found = false;
    rep(i,n) {
      if( pos[i] >= n-1 ) continue;
      int dst = A[i][pos[i]];
      if( pos[dst] < n-1 && i == A[dst][pos[dst]] ) {
	found = true;
	int a = ( (pos[ i ]-1>=0) ? B[i][pos[i]-1]     : 0 );
	int b = ( (pos[dst]-1>=0) ? B[dst][pos[dst]-1] : 0 );
	int c = max(a,b)+1;
	B[i][pos[i]] = c;
	B[dst][pos[dst]] = c;
	++pos[i];
	++pos[dst];
	rem -= 2;
	break;
      }
    }
    if( !found ) { puts("-1"); return ; }
  }
  /*
  rep(i,n) {
    rep(j,n-1) {
      cout << B[i][j] << " ";
    } puts("");
  }
  */
  int maxi = 0;
  rep(i,n) rep(j,n-1) maxi = max(maxi,B[i][j]);
  cout << maxi << endl;
}


int main() {
  cin >> n;
  rep(i,n) rep(j,n-1) {
    cin >> A[i][j];
    --A[i][j];
    B[i][j] = 0;
  }
  compute();
  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int degit;
  while(cin>>a>>b){
    stringstream ss; ss<<a+b;
    string temp=ss.str();
    degit=temp.size();
    printf("%d\n",degit);
  }
  return 0;
}

Measured memory_bytes: 3240
import static java.lang.Math.*;

import java.util.Scanner;

public class Main{

	double EPS = 1e-10;

	double det(double[][] A){
		int n = A.length;
		double res = 1;
		for(int i=0;i<n;i++){
			int pivot = i;
			for(int j=i+1;j<n;j++)if(abs(A[j][i])>abs(A[pivot][i]))pivot = j;
			swap(A, pivot, i);
			res *= A[i][i] * (i!=pivot?-1:1);
			if(abs(A[i][i])<EPS)break;
			for(int j=i+1;j<n;j++)for(int k=n-1;k>=i;k--)A[j][k]-=A[i][k]*A[j][i]/A[i][i];
		}
		return res;
	}
	//swap row a and row b
	void swap(double[][] A, int a, int b){
		int n = A[a].length;
		for(int i=0;i<n;i++){
			double t = A[a][i];
			A[a][i] = A[b][i];
			A[b][i] = t;
		}
	}
	
	int[] l;
	boolean tri(int a, int b, int c){
		int m = max(l[a], max(l[b], l[c]));
		return m < l[a]+l[b]+l[c]-m;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			l = new int[n];
			for(int i=0;i<n;i++)l[i]=sc.nextInt();
			double max = 0;
			for(int a=0;a<n;a++){
				for(int b=0;b<n;b++){
					if(a==b)continue;
					for(int c=0;c<n;c++){
						if(a==c||b==c)continue;
						for(int p=0;p<n;p++){
							if(a==p||b==p||c==p||!tri(a, b, p))continue;
							for(int q=0;q<n;q++){
								if(a==q||b==q||c==q||p==q||!tri(a, c, q))continue;
								for(int r=0;r<n;r++){
									if(a==r||b==r||c==r||p==r||q==r||!tri(b, c, r)||!tri(p, q, r))continue;
									double[][] A = {{0, l[p]*l[p], l[q]*l[q], l[a]*l[a], 1},
											{l[p]*l[p], 0, l[r]*l[r], l[b]*l[b], 1},
											{l[q]*l[q], l[r]*l[r], 0, l[c]*l[c], 1},
											{l[a]*l[a], l[b]*l[b], l[c]*l[c], 0, 1},
											{1, 1, 1, 1, 0}
									};
									double D = det(A);
									if(D<EPS)continue;
									max = Math.max(max, D/288);
								}
							}
						}
					}
				}
			}
			System.out.printf("%.8f\n", Math.sqrt(max));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main( void )
{
	ll A,B;
	cin >> A >> B;
	int x1,x2,y1,y2,sum = 0;
	
	while ( A <= B )
	{
		/*
		//1
		x1 = A % 10;
		//5
		x2 = A / 10000;
		//2
		y1 = A % 10000 / 1000;
		//4
		y2 = A % 100 / 10;
		*/
		if ( A % 10 != 0 && A % 10 == A / 10000 && A % 10000 / 1000 == A % 100 / 10 )
		{
			sum++;
		}
		
		A++;
	}
	
	cout << sum << endl;
}

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

typedef long long int lli;
#define pb push_back
#define gcd __gcd
#define MOD 1000000007
#define mod2 998244353
#define forz(i,n) for(long long int i=0;i<n;i++)

double mod(double a){
    if(a<0) return -1*a;
    return a;
}

bool prime[100000000+1];

void SieveOfEratosthenes() 
{ 
    lli n=100000000;
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
}

bool aa(string a,string b){
    for(int i=0;i<7;i++){
        if(a[i]=='?') continue;
        else if(a[i]==b[i]) continue;
        else return 0;
    }
    return 1;
}

bool bb(string t2){
    map<string,lli> solve;
    map<string,lli>::iterator itr;
    for(int i=0;i<t2.size()-6;i++){
        solve[t2.substr(i,7)]++;
    }
    string s="abacaba";
    if(solve[s]==1) return 1;
    return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t=1,u,j;
    
    
    //cin>>t;
    ///SieveOfEratosthenes();
    for(u=1;u<=t;u++){
        lli m,n, i,j,a,b,c,k,p=0,q=0,p1=0,p2=0,p3=0,ans=0,l,r,index=-1;
        cin>>a>>b>>c;
        cin>>n;
        while(b<=a){
            b=b*2;
            n--;
        }
        while(c<=b){
            c=c*2;
            n--;
        }

        if(n<0) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        System.out.println(a <= c && c <= b ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
package main

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

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,10000)}
  n,l := input.NextInts()
  root := NewNode(0)
  for i:=0;i<n;i++ {
    s := input.NextLine()
    node := root
    for j:=0;j<len(s);j++ {
      if s[j:j+1] == "0" {
        node = node.Left()
      } else {
        node = node.Right()
      }
    }
  }
  pile := []int64{}
  var dfs func(*Node)
  dfs = func(node *Node) {
    not := true
    if node.left != nil {
      if node.right == nil { pile = append(pile,l-node.depth);not = false }
      dfs(node.left)
    }
    if node.right != nil {
      if node.left == nil && not { pile = append(pile,l-node.depth) }
      dfs(node.right)
    }
  }
  dfs(root)
  p := make([]int64,61)
  p[0] = 1
  for i:=1;i<61;i++ { p[i] = 2*p[i-1] }
  xor := int64(0)
  for i:=0;i<len(pile);i++ {
    grundy := 0
    ub := 61
    for ub-grundy > 1 {
      m := (ub+grundy)/2
      if pile[i]%p[m] == 0 {
        grundy = m
      } else {
        ub = m
      }
    }
    xor ^= p[grundy]
  }
  if xor == 0 {
    fmt.Println("Bob")
  } else {
    fmt.Println("Alice")
  }
}

type Node struct {
  depth int64
  left,right *Node
}
func NewNode(d int64) *Node { return &Node{d,nil,nil} }
func(n *Node) Left() *Node {
  if n.left == nil { n.left = NewNode(n.depth+1) }
  return n.left
}
func(n *Node) Right() *Node {
  if n.right == nil { n.right = NewNode(n.depth+1) }
  return n.right
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int64) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.ParseInt(s[1],10,64)
  return x,y
}
func(i *Input) NextIntArray() []int {
  s := strings.Fields(i.NextLine())
  a := make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 35328
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int num[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        System.out.println(num[n - 1]);
    }
}

Measured memory_bytes: 35560
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >>N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> A(N);
    iota(A.begin(),A.end(),1);
    REP(i,N) cin >> P.at(i);
    REP(i,N) cin >> Q.at(i);


    int p = 1;
    int q = 1;
    int k = 1;
    do{
        bool isp = true;
        bool isq = true;
        REP(i,N){
            if(A[i] != P[i]) isp = false;
            if(A[i] != Q[i]) isq = false;
        }
        if(isp) p = k;
        if(isq) q = k;
        k++;
    }while(next_permutation(A.begin(),A.end()));
    cout << abs(p-q) << endl;
    return 0;
}

Measured memory_bytes: 3584
x1, y1, x2, y2 = gets.chomp.split(" ").map(&:to_i);
x3 = x2 + y1 - y2
y3 = y2 + x2 - x1
x4 = x3 + y2 - y3
y4 = y3 + x3 - x2

puts "#{x3} #{y3} #{x4} #{y4}"

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

void solve () {
	int n;
	cin >> n;

	const int N = (int)1e6;
	int a[N + 1];
	memset(a, 0, sizeof(a));
	int it;
	for (int i = 0; i < n; i++) {
		cin >> it;
		a[it]++;
	}
	int bad[N + 1];
	memset(bad, 0, sizeof(bad));
	for (int i = 1; i <= N; i++) {
		if (a[i]) {
			for (int j = i + i; j <= N; j += i){
				if (a[j]) bad[j] = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (a[i] > 1) continue;
		if (a[i] && !bad[i]) ans++;
	}
	cout << ans << endl;
}

int main () {
	/*int t;
	cin >> t;
	while (t--) {
		solve();
	}*/
	
	solve();

	return 0;
}


Measured memory_bytes: 11380
#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 = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

int main() {
	string s, t;
	cin >> s >> t;

	t = t.substr(0, t.size() - 1);
	string ans = "Yes";
	if (s != t) ans = "No";
	cout << ans << endl;
	return 0;
} 

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int a,b;
	cin >> a >> b;
	if(a+b>9) cout << "error" << endl;
	else cout << a+b << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <string>

#define rep(i, n) for(int i=0;i<n;i++)
#define IOS() ios_base::sync_with_stdio(false)

using namespace std;
int n;
char a[103];

int input() {

    scanf("%d", &n);

    scanf("%s", a);

}

void process() {

    int r_co = 0, b_co = 0;

    rep(i, n){

        if(a[i] == 'R') {
            r_co++;
        }
        if(a[i] == 'B'){
            b_co++;
        }
    }

    if(r_co > b_co){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

int main() {

    //IOS();

    input();
    process();

    return 0;
}

Measured memory_bytes: 256