akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int n,m,a[200003],b,c;
string s;int cudi[209993];
vector<int>v[200003];
int fix[200003][2],fixx[200003];
int main(){std::ios::sync_with_stdio(false);
cin>>n>>m;
cin>>s;
for(int i=0;i<s.size();i++)
{
	a[i]=s[i]-'A';
}
for(int i=0;i<m;i++)
{
	cin>>b>>c;
	b--;
	c--;
	v[b].push_back(c);
	fix[b][a[c]]++;
	v[c].push_back(b);
	fix[c][a[b]]++;
}
c=0;
for(int i=0;i<n;i++)
{
	for(int j=0;j<2;j++)
	{
		if(fix[i][j]==0)
		{
			cudi[i]=1;
			fixx[c++]=i;
			break;
		}
	}
}
for(int I=0;I<c;I++)
{
	int i=fixx[I];
	for(int j=0;j<v[i].size();j++)
	{
		if(cudi[v[i][j]]==1)
			continue;
		fix[v[i][j]][a[i]]--;
		if(fix[v[i][j]][a[i]]==0)
		{
			cudi[v[i][j]]=1;
			fixx[c++]=v[i][j];
		}
	}
}
if(c==n)
{
	cout<<"No"<<endl;
}
else
{
	cout<<"Yes"<<endl;
}

}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 14288
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

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

    int l[N];
    for(int i = 0; i < N; i++) cin >> l[i];

    sort(l, l+N, greater<int>());

    int sum = 0;
    for(int i = 0; i < K; i++){
        sum += l[i];
    }

    cout << sum << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*三日目*/
//少数も使いたい割り算はしない方がいい(三日目）
	ll n, a, b; cin >> n>> a>> b;
	ll syo = n / (a + b);
	ll amari = n % (a + b);
	ll sum = syo * a;
	if (amari <= a)
		sum += amari;
	else
		sum += a;
	cout << sum;
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define EPS 0.000000001 //1e-9
#define pii pair<int,int>
using namespace std;
int32_t main()
{
    IOS;
    int ans=-1000000000+7;
    string s,t;
    cin>>s>>t;
    int l=s.length(),k=t.length();
    for(int i=0;i<=l-k;i++)
    {
        int mx=0;
        string str=s.substr(i,k);
        for(int j=0;j<k;j++)
        {
            if(str[j]==t[j])
                mx++;
        }
        ans=max(mx,ans);
    }
    cout << k-ans << endl;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int dp[81][81][28000];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int A[80][80], B[80][80], C[80][80];
    rep(i, H) rep(j, W) {
        cin >> A[i][j];
    }
    rep(i, H) rep(j, W) {
        cin >> B[i][j];
        C[i][j] = abs(A[i][j] - B[i][j]);
    }
    dp[0][0][13000 + C[0][0]] = 1;
    dp[0][0][13000 - C[0][0]] = 1;
    rep(i, H) {
        rep(j, W) {
            REP(k, -12900, 12900){
                if (j + 1 < W) {
                    dp[i][j + 1][k + 13000 + C[i][j + 1]] |= dp[i][j][k + 13000];
                    dp[i][j + 1][k + 13000 - C[i][j + 1]] |= dp[i][j][k + 13000];
                }
                if (i + 1 < H){
                    dp[i + 1][j][k + 13000 + C[i + 1][j]] |= dp[i][j][k + 13000];
                    dp[i + 1][j][k + 13000 - C[i + 1][j]] |= dp[i][j][k + 13000];
                }
            }
        }
    }
    int ans = INF;
    REP(k, -13000, 13000) {
        if(dp[H - 1][W - 1][13000 + k]) ans = min(ans, abs(k));
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 710784
#include <stdio.h>

int p[100000],l[100000],r[100000],d[100000],h[100000];

void depth(int x,int dep){
  d[x]=dep;
  if(r[x]!= -1)depth(r[x],dep+1);
  if(l[x]!= -1)depth(l[x],dep+1);
}

int height(int x){
  int h1=0,h2=0;

  if(l[x]!=-1)h1=height(l[x])+1;
  if(r[x]!=-1)h2=height(r[x])+1;

  if(h1>h2){
    h[x]=h1;
    return h1;
  }
  else{
    h[x]=h2;
    return h2;
  }
}

int main(){
  int i,j,n,t,t1,t2,t3,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    p[i]=-1;
    l[i]=-1;
    r[i]=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&t1,&t2,&t3);
    l[t1]=t2;
    r[t1]=t3;
    if(t2!=-1)p[t2]=t1;
    if(t3!=-1)p[t3]=t1;
  }

  /*for(i=0;i<n;i++){
    printf("%d\n",p[i]);
    }*/

  for(i=0;i<n;i++){
    if(p[i]==-1){
      root=i;
      break;
    }
  }
  //printf("ttt\n");

  depth(root,0);
  //printf("ttt2\n");
  height(root);
  //printf("ttt3\n");

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,p[i]);


    //sibling
    printf("sibling = ");
    if(p[i]==-1)printf("-1, ");
    else {
      t1=p[i];
      if(l[t1]==i)printf("%d, ",r[t1]);
      else printf("%d, ",l[t1]);
    }

    //degree
    t1=0;
    if(l[i]!=-1)t1++;
    if(r[i]!=-1)t1++;
    printf("degree = %d, ",t1);

    
    printf("depth = %d, ",d[i]);

    //height
    printf("height = %d, ",h[i]);

    
    if(p[i]==-1)printf("root");
    else if(l[i]==-1 && r[i]==-1)printf("leaf");
    else printf("internal node");
    /*t=l[i];
    for(j=0;t != -10;t=r[t]){
      if(j!=0){
	printf(", ");
      }
      j=1;
      printf("%d",t);
    }
    */
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    string t;
    cin>>t;
    int x=0,y=0;
    REP(i,n){
        if(t[i]=='a'){
            if(x+y<a+b){
                x++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(t[i]=='b'){
            if(x+y<a+b&&y<b){
                y++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0 ; i < int(N);i++)
using namespace std ;
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    
    int n ;
    cin >> n ;
    vector<int> a(n);
   	rep(i,n) {
   		cin >> a[i];
   	}
   	int h =0 ;
   	ll ans = 0 ;
   	rep(i,n){
   		h = max(h,a[i]);
   		// cout << h << endl;
   		ans += h-a[i];
   		// cout << ans << endl;
   	}
   	cout << ans << endl;
	return 0 ;
}


Measured memory_bytes: 3948
num = [1]
for i in range(1, 50):
  num.append(2 * num[i - 1] + 3)
def count_p(level, x):
  if x == 0:
    return 0
  if level == 1:
    if x == 5:
      return 3
    else:
      return x - 1
  if x < num[level - 1] + 1:
    return count_p(level - 1, x - 1)
  if x == num[level - 1] + 1:
    return 2 ** level - 1
  if x >= num[level - 1] * 2 + 2:
    return 2 ** (level + 1) - 1
  if x >= num[level - 1] + 2:
    return 2 ** level + count_p(level - 1, x - num[level - 1] - 2)


N, X = map(int, input().split())
print(count_p(N, X))

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

int main(){
  int a, b, c, n;
  int x, y;
  cin >> a >> b >> c >> n;
  
  x = max( a, max( b, c ) );
  y = x;
  
  for ( int i = 0; i < n; i++ ){
    x *= 2;
  }
  
  cout << a + b + c + x - y << endl;
}

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

int main(){

  int n,  left, right;
  long ans=0;
  scanf("%d", &n );
  int a[n+1], b[n];
  rep (i,n+1) scanf("%d", &a[i]);
  rep (i,n) scanf("%d", &b[i]);

  rep(i,n){
    left=fmin(a[i],b[i]);
    a[i]-=left;
    b[i]-=left;
    ans+=left;
    right=fmin(a[i+1],b[i]);
    a[i+1]-=right;
    ans+=right;
  }
  printf("%ld\n", ans);
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(ll X) {
	if (!X) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
int A[100000];
ll B[100001];
int C[100001];
int MA[100001], MI[100001];
int saidai, k = 1;
ll kotae[100001];

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


	int N = getint();
	int k3 = 0;
	rep(i, N) {
		int a = getint();
		if (a > saidai) {
			MA[k] = a;
			MI[k] = i;
			B[k] += a - saidai;
			C[k++]++;
			saidai = a;
		}
		else A[k3++] = a;
	}
	pakuri_sort(k3, A);
	int k2 = 1;
	rep(i, k3) {
		while (MA[k2] < A[i]) k2++;
		B[k2] += A[i] - MA[k2 - 1];
		C[k2]++;
	}

	ll cnt = 0;
	for (int i = k - 1; i >= 1; i--) {
		kotae[MI[i]] = B[i] + (MA[i] - MA[i - 1]) * cnt;
		cnt += C[i];
	}

	rep(i, N) putint(kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n, a, b; cin >> n >> a >> b;
  vector<int> p(n);
  int cnt1 = 0;
  int cnt2 = 0;
  int cnt3 = 0;
  rep(i, n) {
    int p; cin >> p;
    if (p <= a) {
      cnt1++;
    } else if (p <= b) {
      cnt2++;
    } else {
      cnt3++;
    }
  }
  int ans = min(cnt1, cnt2);
  ans = min(ans, cnt3);


  cout << ans << endl;

}

Measured memory_bytes: 256
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  4/ 7 20:31:14 2018
 * Ended  Time*  : 六  4/ 7 22:11:25 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

LL a, b, sum;

bool check(LL mid){
	if(mid * mid <= sum) return true;
	return false;
}

int main()
{
	int T;
	scanf("%d", &T);
	while(T--){
		scanf("%lld %lld", &a, &b);
		sum = a * b;
		sum--;
		LL res = 0;
		LL l = 1LL, r = 1 << 30, mid, ans = 1LL;
		while(l <= r){
			mid = (l + r) >> 1;
			if(check(mid)) l = mid + 1, ans = mid;
			else r = mid - 1;
		}
		if(ans * (ans + 1LL) <= sum){
			if(ans >= min(a, b)) res = 2LL * ans - 1;
			else res = 2LL * ans;
		}
		if(ans * (ans + 1LL) > sum){
			if(ans >= min(a, b)) res = 2LL * ans - 2;
			else res = 2LL * ans - 1;
		}
		printf("%lld\n", res);
	}
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<algorithm>
#define INF (1 << 30)
using namespace std;

int main(){
  int n, m, tmp;
  while(1){
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0)return 0;
    int dp[3][10][100];
    memset(dp, 0, sizeof(dp));
    vector< pair<int, int> >stones[n];
    for(int i = 0;i < n;i++){
      int k, l, m;
      scanf("%d", &k);
      for(int j = 0;j < k;j++){
	scanf("%d %d", &l, &m);
	stones[i].push_back(make_pair(l, m));
      }
    }
    for(int i = 0;i < n;i++){
      int ind = i%3, prev = (i - 1) % 3, prepre = (i - 2) % 3;

      for(int j = 0;j < stones[i].size();j++)
	for(int k = 0;k <= m;k++)
	  dp[ind][j][k] = INF;

      for(int j = 0;j < stones[i].size();j++){
	if(i == 0)dp[ind][j][m] = 0;
	else if(i == 1 && m - 1 >= 0)dp[ind][j][m - 1] = 0;
      }
      for(int j = 0;j < stones[i].size();j++){
	for(int k = 0;k <= m;k++){
	  for(int l = 0;i > 0 && l < stones[i - 1].size();l++){
	    dp[ind][j][k] = min(dp[ind][j][k],
				dp[prev][l][k] + abs(stones[i - 1][l].first - stones[i][j].first) * (stones[i - 1][l].second + stones[i][j].second));
	  }
	  for(int l = 0;i > 1 && k < m && l < stones[i - 2].size();l++){
	    dp[ind][j][k] = min(dp[ind][j][k],
				dp[prepre][l][k + 1] + abs(stones[i - 2][l].first - stones[i][j].first) * (stones[i - 2][l].second + stones[i][j].second));
	  }
	}
      }
    }
    int res = INF;
    for(int i = 0;i < stones[n - 1].size();i++){
      for(int j = 0;j <= m;j++){
	res = min(res, dp[(n - 1) % 3][i][j]);
      }
    }
    for(int i = 0;i < stones[n - 2].size();i++){
      for(int j = 1;j <= m;j++){
	res = min(res, dp[(n - 2) % 3][i][j]);
      }
    }
    printf("%d\n", res);
  }
}

Measured memory_bytes: 1076
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
if s.isupper():
    print("A")
else:
    print("a")

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

int main()
{
  int64_t N, K, x, y, ans = (1LL << 62);
  cin >> N >> K;
  vector<pair<int64_t, int64_t>> xy(N);
  for (int i = 0; i < N; i++)
  {
    cin >> x >> y;
    xy.at(i) = make_pair(x, y);
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      int64_t xmin = xy[i].first, xmax = xy[j].first;
      if (xmin >= xmax)
        continue;
      for (int k = 0; k < N; k++)
      {
        for (int l = 0; l < N; l++)
        {
          int64_t ymin = xy[k].second, ymax = xy[l].second;
          if (ymin >= ymax)
            continue;
          int64_t cnt = 0;
          for (auto p : xy)
          {
            tie(x, y) = p;
            if (x >= xmin && x <= xmax && y >= ymin && y <= ymax)
              cnt++;
            if (cnt >= K)
              ans = min(ans, (xmax - xmin) * (ymax - ymin));
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <array>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n) {int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
//is(string &s) {int c;for(;;){c=gcu();if(c=='\n'||c==' ')return true;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int main() {
	int n;
	array<bool, 31> v = {true};
	while(scan(n))
		v[n] = true;

	for (auto &b: v)
		if (!b)
			out(&b - &v[0], '\n');
}


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

typedef struct {
  int pos;
  int val;
} Val;

int main()
{
  int i, j, k, n, m, q, v, lb, ub;
  char buf[32];
  fscanf(stdin, "%d\n", &n);
  Val *a = (Val*)malloc(sizeof(Val)*n);
  int alen=0;

  char *line=NULL;
  size_t linecap = 0;
  getline(&line, &linecap, stdin);
  a[alen].pos = 0;
  a[alen++].val = atoi(line);
  line = index(line+1, ' ');
  for (i=1; i<n; i++) {
    v = atoi(line);
    if (a[alen-1].val<v) {
      a[alen].pos = i;
      a[alen++].val = v;
    }
    line = index(line+1, ' ');
  }
  
  int begin, end, mid;
  fscanf(stdin, "%d\n", &q);
  for (i=0; i<q; i++) {
    fgets(buf, 32, stdin);
    k = atoi(buf);
    begin=0;
    end=alen-1;
    int undecided_lb=1;
    while (begin<=end) {
      mid=(begin+end)/2;
      if (a[mid].val==k) {
	lb =  a[mid].pos;
	undecided_lb=0;
      }
      if (a[mid].val>k) {
        end = mid - 1;
      } else begin = mid + 1;
    }
    if (begin>=alen) {
      if (undecided_lb) lb = n;
      ub = n;
    } else {
      if (undecided_lb) lb = a[begin].pos;
      ub = a[begin].pos;
    }
    int b=lb;
    int k;
    if (b==0) {
      putc_unlocked('0', stdout);
    } else {
      if (b<0) {
	putc_unlocked('-', stdout);
	b=-b;
      }
      for (j=1; j*10<=b; j*=10);
      k=j;
      for (;j>0; j/=10) {
	putc_unlocked('0'+b/j, stdout);
	b %= j;
      }
    }
    putc_unlocked(' ', stdout);
    if (lb==ub) {
      if (ub==0) {
	putc_unlocked('0', stdout);
      } else {
	if (ub<0) {
	  putc_unlocked('-', stdout);
	  ub=-ub;
	}
	j=k;
	for (;j>0; j/=10) {
	  putc_unlocked('0'+ub/j, stdout);
	  ub %= j;
	}
      }
    } else {
      if (ub==0) {
	putc_unlocked('0', stdout);
      } else {
	if (ub<0) {
	  putc_unlocked('-', stdout);
	  ub=-ub;
	}
	for (j=1; j*10<=ub; j*=10);
	for (;j>0; j/=10) {
	  putc_unlocked('0'+ub/j, stdout);
	  ub %= j;
	}
      }
    }
    putc_unlocked('\n', stdout);
  }
  
  return 0;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif






ll n, a, b;
ll ab, n0, n1;

// maskの0のビットにpattern0を、1のビットにpattern1を当てはめる
ll g( ll pattern0, ll pattern1, ll mask ){
	ll result = 0;
	for ( ll m = 1 << (n-1); m; m >>= 1 ){
		if ( mask & m ){
			result = (result<<1)|(pattern1&1);
			pattern1 >>= 1;
		}
		else{
			result = (result<<1)|(pattern0&1);
			pattern0 >>= 1;
		}
	}
	return result;
}

void test(ll x){
	static ll last_x = 0;
	ll ct = 0;
	rep(k,n){
		cout << ((x&(1<<(n-k-1))) ? "1": "0");
	}
	cout << "  ";
	rep(k,n){
		cout << (((x^last_x)&(1<<(n-k-1))) ? ct++,"1": "0");
	}
	last_x = x;
	cout << " " << ct << endl;
}

void f0(ll data, ll rev){
	rep(i,1<<n0){
		ll x = rev ? (1<<n0)-i-1 : i;
		ll val = a^g( x^(x>>1), data, ab );
		//test(val);
		cout << val << " ";
	}
}

void f1( ll data, ll nx, int rev, int is_last ){
	if ( nx == 0 ){
		f0( data, rev );
		return;
	}
	
	nx -= 2;
	data <<= 2;
	if ( rev ){
		if ( is_last ){
			f1(data|2,nx,0,0);
			f1(data|0,nx,1,0);
			f1(data|1,nx,0,0);
			f1(data|3,nx,1,1);
		}
		else {
			f1(data|2,nx,0,0);
			f1(data|3,nx,1,0);
			f1(data|1,nx,0,0);
			f1(data|0,nx,1,0);
		}
	}
	else {
		f1(data|0,nx,0,0);
		f1(data|1,nx,1,0);
		f1(data|3,nx,0,0);
		f1(data|2,nx,1,0);
	}
}

void f1a( ll nx ){
	f1(0,nx-1,0,0);
	f1(1,nx-1,1,1);
}





int main(){
	cin >> n >> a >> b;
	
	ab = a^b;
	n1 = __builtin_popcount(ab);
	n0 = n - n1;
	
	if ( n1 % 2 == 0 ){
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
		f1a( n1 );
		cout << endl;
	}
	
	
	return 0;
}




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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/05/27  Problem: ARC 015 C / Link: http://arc015.contest.atcoder.jp/tasks/arc015_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll H, W, Q;
ll v[2005][2005];
ll ex[2005][2005];
ll ey[2005][2005];
ll ans = 0LL;

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

	cin >> H >> W >> Q;
	string s[2000];
	FOR(i, 0, H)cin >> s[i];
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			int c = 0;
			if (s[i][j] == '1')c = 1;
			v[i + 1][j + 1] = c;
		}
	}

	FOR(i, 0, H)FOR(j, 0, W)v[i + 1][j + 1] += v[i + 1][j];

	FOR(i, 0, H)FOR(j, 0, W)v[i + 1][j + 1] += v[i][j + 1];


	FOR(i, 0, H)FOR(j, 0, W - 1) {
		if (s[i][j] == '1'&&s[i][j + 1] == '1')ex[i + 1][j + 1] = 1;
	}
	FOR(i, 0, H)FOR(j, 0, W - 1) {
		ex[i + 1][j + 1] += ex[i + 1][j];
	}
	FOR(i, 0, H)FOR(j, 0, W - 1) {
		ex[i + 1][j + 1] += ex[i][j + 1];
	}


	FOR(i, 0, H - 1)FOR(j, 0, W) {
		if (s[i][j] == '1'&&s[i + 1][j] == '1')ey[i + 1][j + 1] = 1;
	}
	FOR(i, 0, H - 1)FOR(j, 0, W) {
		ey[i + 1][j + 1] += ey[i + 1][j];
	}
	FOR(i, 0, H - 1)FOR(j, 0, W) {
		ey[i + 1][j + 1] += ey[i][j + 1];
	}

	FOR(i, 0, Q) {
		int ax, ay, bx, by;
		cin >> ax >> ay >> bx >> by; ax--; ay--;
		int vv = v[bx][by] + v[ax][ay] - v[ax][by] - v[bx][ay];
		int exx = ex[bx][by - 1] + ex[ax][ay] - ex[ax][by - 1] - ex[bx][ay];
		int eyy = ey[bx - 1][by] + ey[ax][ay] - ey[ax][by] - ey[bx - 1][ay];
		ans = vv - exx - eyy;
		cout << ans << endl;

	}

	return 0;
}


Measured memory_bytes: 100224
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll d, c[26], s[365][26], t[365], ans = 0, m, x, y, v, old[2],cnt=0;
  ll ra[100000];
  for (int i = 0; i < 100000; i++) {
    ra[i] = (floor(30 / (log(i % 100000 + 20) / log(20)))) - 3;
  }
  set<ll> se[26];
  srand(time(NULL));
  cin >> d;
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    se[i].insert(0);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < d; i++) {
    x = -10000000000000;
    y = -1;
    for (int j = 0; j < 26; j++) {
      if (x < s[i][j] + (i + 1 - *se[j].rbegin()) * c[j] * (d - i)) {
        y = j;
        x = s[i][j] + (i + 1 - *se[j].rbegin()) * c[j] * (d - i);
      }
    }
    t[i] = y;
    se[t[i]].insert(i + 1);
    ans += s[i][t[i]];
    for (int j = 0; j < 26; j++) {
      ans -= (i + 1 - *se[j].rbegin()) * c[j];
    }
  }
  for (int i = 0; i < 26; i++) {
    se[i].insert(d + 1);
  }
  for (int i = 0; i < 4000000; i++) {
    y = ra[rand() % 100000];
    x = rand() % (d - y) + 1;
    y += x;
    v = 0LL;
    v += s[x - 1][t[y - 1]] - s[x - 1][t[x - 1]] + s[y - 1][t[x - 1]] -
         s[y - 1][t[y - 1]];
    set<ll>::iterator it = se[t[x - 1]].find(x);
    it--;
    ll z = *se[t[x - 1]].upper_bound(x);
    v -= c[t[x - 1]] * (z - x) * (x - *it);
    se[t[x - 1]].erase(x);
    it = se[t[y - 1]].find(y);
    it--;
    z = *se[t[y - 1]].upper_bound(y);
    v -= c[t[y - 1]] * (z - y) * (y - *it);
    se[t[y - 1]].erase(y);
    it = se[t[y - 1]].lower_bound(x);
    it--;
    v += c[t[y - 1]] * (*se[t[y - 1]].lower_bound(x) - x) * (x - *it);
    it = se[t[x - 1]].lower_bound(y);
    it--;
    v += c[t[x - 1]] * (*se[t[x - 1]].lower_bound(y) - y) * (y - *it);
    if (v > 0LL) {
      ans += v;
      se[t[x - 1]].insert(y);
      se[t[y - 1]].insert(x);
      ll temp = t[x - 1];
      t[x - 1] = t[y - 1];
      t[y - 1] = temp;cnt++;
    } else {
      se[t[x - 1]].insert(x);
      se[t[y - 1]].insert(y);
    }
  }
  for (int i = 0; i < d; i++) {
    cout << t[i] + 1 << endl;
  }
}

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

using namespace std;

int main(){
    char s[111];
    scanf("%s", s);
    int len = strlen(s);
    int ans = INT_MAX;
    for (int i = 0; i < len - 2; i++){
        int cur = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') * 1;
        cur -= 753;
        if (cur < 0)
            cur *= -1;
        ans = min(ans, cur);
    }
    printf("%d\n", ans);
    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi a(N); REP(i, N) cin >> a[i];

    int ans = 0;
    REP(i, N) ans += a[i]-1;
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

const double eps = 1e-10;

class Vector
{
public:
  double x;
  double y;

  Vector(){}
  Vector( double x, double y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const double k ) { return Vector( x * k, y * k ); }
  Vector operator / ( const double k ) { return Vector( x / k, y / k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double abs() { return sqrt( norm() ); }
  double norm() { return x * x + y * y; }

  static double dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static double cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }
};

class Intersection
{
public:
  Vector p0, p1, p2, p3;
  Intersection(){}
  Intersection( Vector p0, Vector p1, Vector p2, Vector p3 ) : p0(p0), p1(p1), p2(p2), p3(p3) {}
  int solve();
};

int Intersection::solve()
{
  Vector p10 = p1 - p0;
  Vector p20 = p2 - p0;
  Vector p30 = p3 - p0;
  Vector p32 = p3 - p2;
  Vector p02 = p0 - p2;
  Vector p12 = p1 - p2;
  
  double c0 = Vector::cross( p10, p20 );
  double c1 = Vector::cross( p10, p30 );
  double c2 = Vector::cross( p32, p02 );
  double c3 = Vector::cross( p32, p12 );
  
  if ( c0 == 0 && c1 == 0 && c2 == 0 && c3 == 0 )
    {
      Vector p01 = p0 - p1;
      Vector p21 = p2 - p1;
      Vector p31 = p3 - p1;

      if ( Vector::dot( p10, p20) < 0 && Vector::dot( p10, p30 ) < 0 )
        cout << "0" << endl;
      else if ( Vector::dot( p01, p21 ) < 0 && Vector::dot( p01, p31 ) < 0 )
        cout << "0" << endl;
      else
        cout << "1" << endl;
    }
  else if ( c0 * c1 <= 0 && c2 * c3 <= 0 )
    cout << "1" << endl;
  else
    cout << "0" << endl;
  
  return 0;
}

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

  for ( auto i = 0; i < q; ++i )
    {
      double x0, y0, x1, y1, x2, y2, x3, y3;
      cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
      Intersection s( Vector(x0, y0), Vector(x1, y1), Vector(x2, y2), Vector(x3, y3) );
      s.solve();
    }

  return 0;
}

Measured memory_bytes: 1224
function Main(input) {

    input = input.split(" ");

    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var c = parseInt(input[2], 10);

    var d = Math.floor(b / a)

    console.log(Math.min(d, c))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next()), b = Integer.parseInt(sc.next());
		if(a <= b){
			for(int i = 0; i < b; i++){
				System.out.print(a);
			}
		} else {
			for(int i = 0; i < a; i++){
				System.out.print(b);
			}
		}
		System.out.println();
	}
}


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

using namespace std;

int main() {
    string s; cin >> s;
    int len = s.size();
    int able = 1;
    for (int i = 0; i < len; i++) {
        if (i%2 == 0) {
            if (s[i] == 'L') {
                able = 0;
                break;
            }
        }
        else {
            if (s[i] == 'R') {
                able = 0;
                break;
            }
        }
    }
    if (able) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>

int h1, h2;
int k1, k2;
int a, b, c, d;

int main(void)
{
	int p1, p2;
	
	scanf( "%d %d %d %d %d %d %d %d", &h1, &h2, &k1, &k2, &a, &b, &c, &d );
	
	p1 = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
	p2 = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;
	
	if ( p1 > p2 ) printf( "hiroshi\n" );
	else if ( p1 < p2 ) printf( "kenjiro\n" );
	else printf( "even\n" );
	
	return 0;
}

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

#define ll long long

using namespace std;

ll a[100010],b[100010];

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

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

    ll count = 0;

    for(int i=1;i<n;i++)
    {
        ll temp = a[i] + a[i-1];

        if(temp <= x)
            continue;
        else
        {
            temp -= x;
            count += temp;
            a[i] = max((ll)0,a[i]-temp);
        }
    }

    /*ll count1 = 0;

    for(int i=n-2;i>=0;i--)
    {
        ll temp = b[i] + b[i+1];

        if(temp <= x)
            continue;
        else
        {
            temp -= x;
            count1 += temp;
            b[i] = min((ll)0,b[i]-temp);
        }
    }

    cout << min(count,count1) << endl;*/

    cout << count << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

ll n, sum = 0;
vector<ll> v;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    v.assign(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
        sum ^= v[i];
    }
    for(int i = 0; i < n; ++i){
        cout << (sum ^ v[i]) << " ";
    }
    return 0;
}

Measured memory_bytes: 4688
#include <stdio.h>
int main()
{
        int  n, k, x, y,total=0;
        scanf("%d%d%d%d",&n,&k,&x,&y);
        total = k*x + (n-k)*y;
        if(n <= k)
                printf("%d",n*x);
        else
                printf("%d",total);
        return 0;
}                          

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof a)
#define cp(a,x) memcpy(a,x,sizeof a)
using namespace std;
typedef long long LL;
const int N=1e5+3;
int a[N]; char s[N];
LL p[N],f[N];
int main(){
    int n,i,j; scanf("%d",&n);
    for(i=1;i<=n;++i){
        scanf("%d",&a[i]);
        if(i<n)scanf("\n%c",&s[i+1]);
    }
    for(i=n;i;--i) p[i]=p[i+1]+a[i];
    j=n+1;
    for(i=n;i>1;--i){
        if(s[i]=='+')continue;
        f[i]=max( f[j]+p[i+1]-p[j],p[j]-(p[i+1]-p[j]) )-a[i];
        j=i;
    }
    printf("%lld\n",f[j]+p[1]-p[j]);
    return 0;
}

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

int main() {
	long long n;
	cin >> n;
	string ans;
	while (n > 0) {
		n--;
		char x = n % 26 + 'a';
		n /= 26;
		ans.push_back(x);
	}

	for (int i = ans.size()-1; i >= 0; i--) {
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n,k=map(int,input().split())
    A=list(map(lambda x:int(x)-1,input().split()))
    S=[0]*(n+1)
    for i in range(n):
        S[i+1]=S[i]+A[i]
        S[i+1]%=k

    C=defaultdict(int)
    ans=0
    for i in range(n+1):
        ans+=C[S[i]]
        C[S[i]]+=1
        if(i-k+1>=0): C[S[i-k+1]]-=1
    print(ans)
resolve()

Measured memory_bytes: 105704
N = int(input())
a_list = list(map(int, input().split()))

b = [0 for i in range(N)]

for i in range(N)[::-1]:
    s = N // (i+1)
    a = a_list[i]
    if s > 1:
        m_a = sum([b[(i+1)*k-1] for k in range(2, s+1)]) % 2
        a = a ^ m_a
    b[i] = a
print(sum(b))

res = ""
for i in range(len(b)):
    if b[i] > 0:
        res += str(i+1) + " "
if len(res) > 0:
    print(res)


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

int main(){
  int n;
  cin >> n;
  ll a[n+1] = {};
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a+n);
  ll max = a[n-1], idx = -1;
  for(int i = 0; i < n-1; i++){
    if(abs(max - a[i]) > idx) idx = a[i];
  }
  cout << max << " " << idx << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	string s;
	cin >> s;

	string t;
	cin >> t;

	int same = 0;
	for (int i = 1; i <= N; i++)
	{
		bool check = true;
		for (int j = s.size() - i; j < s.size(); j++)
		{
			if (s[j] != t[j - (s.size() - i)])
			{
				check = false;
				break;
			}
		}

		if (check)
		{
			same = i;
		}
	}

	cout << 2 * N - same;

	return 0;
}

Measured memory_bytes: 256
/*
 * @Author: hesorchen
 * @Date: 2020-07-03 17:05:01
 * @LastEditTime: 2020-08-02 20:09:59
 * @Description: https://hesorchen.github.io/
 */
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define PI acos(-1)
#define PB push_back
#define ll long long
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pll pair<ll, ll>
#define lowbit(abcd) (abcd & (-abcd))
#define max(a, b) ((a > b) ? (a) : (b))
#define min(a, b) ((a < b) ? (a) : (b))

#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define FRE                              \
    {                                    \
        freopen("in.txt", "r", stdin);   \
        freopen("out.txt", "w", stdout); \
    }

inline ll read()
{
    ll x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    return x * f;
}
//head==============================================================================

int main()
{
    ll n;
    cin >> n;
    if (n >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

/*
 
 */

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;



int main(){
  string s;
  cin>>s;
  ll ans=0;
  ll n=1;
  ll a[10]={0};
  rep(i,s.size()-1){
    n*=2;
  }
  a[0]=n;
  repn(i,s.size()-1){
    rep(j,s.size()){
      ans+=(s[i]-48)*a[j];
    }
    a[s.size()-i]=10*(a[s.size()-1-i])/2;
    a[s.size()-1-i]/=2;
  }
  cout<<ans<<endl;
  

  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>cnt(m,0);
  for(int i=0;i<n;i++){
    int k[n];
    cin>>k[i];
    for(int j=0;j<k[i];j++){
      int a;
      cin>>a;
      a--;
      cnt[a]++;
    }
  }
  int ans=0;
  rep(i,m)
  if(cnt[i]==n)ans++;
  cout<<ans<<endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

ll f(ll b, ll n) {
    if (n < b) return n;
    return f(b, n/b) + n%b;
}

vector<int> V[100010];

int main(){
    ll n, s;
    cin >> n >> s;
    if (s == n) {
        cout << n + 1 << endl;
        return 0;
    }
    ll sq = sqrt(n);
    for (auto i = 2; i < sq+10; i++) {
        if (f(i, n) == s) {
            cout << i << endl;
            return 0;
        }
    }
    ll ans = 1000000000000;
    for (ll p = 1; p < sq+10; p++) {
        ll q = s - p;
        ll b = (n - q)/p;
        if (0 <= q && q < b && p < b && f(b, n) == s) {
            ans = min(b, ans);
        }
    }
    if (ans == 1000000000000) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

}

Measured memory_bytes: 2560
while true do
  array = gets.chomp.split(" ")
  num1 = array[0].to_i
  num2 = array[2].to_i
  num = 0
  case array[1]
  when "+"
    num = num1 + num2
  when "-"
    num = num1 - num2
  when "*"
    num = num1 * num2
  when "/"
    num = num1 / num2
  when "?"
    break
  else
  end
  puts num
end

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

using namespace std;

#define MAX 35
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
 
int H, W, T;
vector<piii> vec;
 
bool check(int s)
{
    int now = s;
    for (int i = 0; i < (int)vec.size(); i++) {
	if (vec[i].second.first == now) {
	    now = vec[i].second.second;
	} else if (vec[i].second.second == now) {
	    now = vec[i].second.first;
	}
    }
    return now == T;
}
 
int main()
{
    int S;
    bool G[MAX][MAX][MAX];
    char in;
   
    while (cin >> W, W) {
	memset(G, false, sizeof(G));
	vec.clear();
	cin >> S >> T >> H; S--; T--;
	for (int i = 0; i < H; i++) {
	    for (int j = 0; j < W-1; j++) {
		cin >> in;
		if (in == '1') {
		    if (j > 0) {
			G[i][j-1][j] = true;
		    }
		    G[i][j][j+1] = G[i][j+1][j+2] = true;
		    vec.push_back(piii(i,pii(j, j+1)));
		}
	    }
	}
	sort(vec.begin(), vec.end());
	if (check(S)) {
	    cout << 0 << endl;
	} else {
	    bool found = false;
	    for (int i = 0; i < H; i++) {
		for (int j = 0; j < W-1; j++) {
		    if (G[i][j][j+1]) continue;
		    vector<piii> tmp = vec;
		    vec.push_back(piii(i, pii(j, j+1)));
		    sort(vec.begin(), vec.end());
		    if (check(S)) {
			cout << i+1 << " " << j+1 << endl;
			found = true;
			goto end;
		    }
		    vec = tmp;
		}
	    }
	end:;
	    if (!found) {
		cout << 1 << endl;
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<62;
const double eps = 1e-4;
const double PI=3.1415926535897932;

vector<int> adj[100009];

int dfs(int x,int p){//returns bitmask of visible positions
	bool hasc=0;
	int visible=0;
	int doubleup=0;
	for(int i:adj[x]){
		if(i==p)continue;
		hasc=1;
		int dfsv=dfs(i,x);
		doubleup|=(visible&dfsv);
		visible|=dfsv;
	}
	if(!hasc)return 1;
	int m2=0;
	for(int i=19;i>=0;i--){
		if(doubleup&(1<<i)){m2=i+1;break;}
	}
	int v=0;
	REPP(i,m2,20){
		if(!(visible&(1<<i))){v=i;break;}
	}
	visible|=(1<<v);
	REP(i,v){
		if(visible&(1<<i))
		visible^=(1<<i);
	}
	return visible;
}

int main(){
	DRI(n);
	REP(i,n-1){
		DRII(a,b);a--;b--;
		adj[a].PB(b);adj[b].PB(a);
	}
	int vv=dfs(0,-1);
	//printf("%d ",vv);
	for(int i=20;i>=0;i--){
		if(vv&(1<<i)){printf("%d",i);return 0;}
	}
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	long long ans=0;
	cin>>n;
	for(long long i=1;i<=n;i++)
		if(i%3!=0&&i%5!=0)
			ans+=i;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3608
MOD = 10**9 + 7
MOD_t_MAX = 10**5+10

fac  = [None] * MOD_t_MAX
finv = [None] * MOD_t_MAX
inv  = [None] * MOD_t_MAX
def MOD_COM_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MOD_t_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
def MOD_COM(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
def main():
    n = int(input())
    a = list(map(int, input().split()))
    p = [-1]*(n+1)
    l, r = -1, -1
    for i, v in enumerate(a):
        if p[v] == -1:
            p[v] = i
        else:
            l = p[v]
            r = i
            break
    MOD_COM_init()
    for i in range(1, n+2):
        if i == 1:
            print(n)
        else:
            tmp = MOD_COM(n+1, i)
            tmp -= MOD_COM(l+(n+1-r-1), i-1)
            while tmp < 0:
                tmp += MOD
            print(tmp)

if __name__ == "__main__":
    main()

Measured memory_bytes: 24420
#include <iostream>

using namespace std;

int main(){
    int n, D[100][2];
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> D[i][0] >> D[i][1];
    }
        
    bool exit = false;
    int cnt_zoro = 0;
    for(int i = 0; i < n; i++) {
        if(D[i][0] == D[i][1]) {
            cnt_zoro++;
        } else {
            cnt_zoro = 0;
        }
        if(3 <= cnt_zoro) {
            exit = true;
        }
    }

    if(exit) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    int al[26] = {};
    for(int i = 0; i < s.size(); ++i) {
        ++al[s[i] - 'a'];
    }

    for(int i = 0; i < 26; ++i) {
        if(al[i] == 0) {
            cout << char(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}



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

using namespace std;

template <class T> T abs(T x) { return x < 0 ? -x : x; }

const int inf = 1e9;
const int N = 200010;

pair <int, int> a[N];
int f[N];

int main() {
  int xa, ya, xb, yb;
  scanf("%d %d %d %d", &xa, &ya, &xb, &yb);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &a[i].first, &a[i].second);
  }
  sort(a, a + n);
  if (xa > xb) {
    swap(xa, xb);
    swap(ya, yb);
  }
  vector <int> z;
  for (int i = 0; i < n; ++i) {
    int x = a[i].first;
    int y = a[i].second;
    if (x >= xa && x <= xb) {
      if (ya <= yb) {
        if (y >= ya && y <= yb) {
          z.push_back(y - ya);
        }
      } else {
        if (y >= yb && y <= ya) {
          z.push_back(ya - y);
        }
      }
    }
  }
  int sz = (int)z.size();
  for (int i = 1; i <= sz; ++i) {
    f[i] = inf;
  }
  for (int i = 0; i < sz; ++i) {
    int l = 0, r = sz;
    while (r - l > 1) {
      int s = (l + r) / 2;
      if (f[s] > z[i]) {
        r = s;
      } else {
        l = s;
      }
    }
    f[r] = z[i];
  }
  int cnt = 0;
  for (int i = 1; i <= sz; ++i) {
    if (f[i] != inf) {
      ++cnt;
    }
  }
  double v = 5 * acos(-1);
  double add = v * cnt;
  if (cnt == min(xb - xa, abs(ya - yb)) + 1) {
    add += v;
  }
  int sub = 20 * cnt;
  printf("%.15f\n", 100LL * ((xb - xa) + abs(ya - yb)) - sub + add);
}

Measured memory_bytes: 3444