akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

const int INF = 1001001001;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, int>> X(n);
  rep(i, n) cin >> X[i].first >> X[i].second;
  sort(X.begin(), X.end());
  BIT<ll> bitree(n+1);
  ll ans = 0;
  int i = 0;
  while (i < n) {
    ll t = X[i].first + 2 * d;
    int idx = upper_bound(X.begin(), X.end(), make_pair(t, INF)) - X.begin();
    int num = (X[i].second-bitree.sum(i)+a-1) / a;
    ans += num;
    ll damage = num * a;
    bitree.add(i, damage);
    bitree.add(idx, -damage);
    while (i<n && bitree.sum(i) >= X[i].second) ++i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8020
a = Array.new(9)
x = 0
for i in 0...3 do
    str = gets.split
    for j in 0...3 do
        y = x*3 + j
        a[y] = str[j].to_i
    end
    x += 1
end

N = gets.chomp.to_i
b = Array.new(N)
for i in 0...N do
    b[i] = gets.chomp.to_i
end

c = Array.new(3){Array.new(3,0)}

for i in 0...N do
    for j in 0...9 do
        if a[j] == b[i]
            c[j/3][j%3] += 1
        end
    end
end

answer = 0
for i in 0...3 do
    answer += c[0][i] * c[1][i] * c[2][i]
    answer += c[i][0] * c[i][1] * c[i][2]
end
answer += c[0][0] * c[1][1] * c[2][2]
answer += c[0][2] * c[1][1] * c[2][0]

if answer > 0
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
n = int(input())
Ps = [int(n) for n in input().split()]
score=0
for ind in range(len(Ps)-2):
    p1 = Ps[ind]
    p2 = Ps[ind+1]
    p3 = Ps[ind+2]
    l = [p1,p2,p3]
    if max(l)!=p2 and min(l)!=p2:
       score+=1
print(score)


Measured memory_bytes: 2940
import math
 
def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return factors
	

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		g, y, x = egcd(b % a, a)
		return (g, x - (b // a) * y, y)
		
def modinv(a, m):
	g, x, y = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m
		
def factorial(n):
	num = 1
	while n >= 1:
		num = (num * n) % 1000000007
		n = n - 1
	return num
	   
a = input().split()
a = [int(i) for i in a]
 
num = dict()
for i in prime_factors(a[1]):
	if i not in num:
		num[i] = 1
	else:
		num[i] += 1
		
ans = 1
for j in num.values():
	ans *= factorial(j + a[0] - 1)
	ans %= (10**9 + 7)
	inv = modinv((factorial(a[0] - 1)* factorial(j)), 1000000007)
	ans *= inv
	ans %= (10**9 + 7)
	
print(ans)

Measured memory_bytes: 38896
N, Y =map(int, input().split(' '))

for a in range(N+1):
    for b in range(N+1):
        c = N - a - b
        if c < 0:
            break
        total = a*10000 + b*5000 + c*1000
        if(total==Y):
            print(str(a)+' '+str(b)+' '+str(c))
            exit()

print('-1 -1 -1')


Measured memory_bytes: 3060
N=int(input())
S=input()
S3=[]
for i in range(len(S)):
  S3.append(S[i])
  if S3.count("(") < S3.count(")") :
    S3 =["("] + S3
  if i == len(S) - 1:
    for j in range(S3.count("(") - S3.count(")")):
      S3.append(")")
      
print("".join(S3))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C;
  cin>>A>>B>>C;
  int baf;
  if(A<B){
  	baf=A;
    A=B;
    B=baf;
  }
  if(B<C){
  	baf=B;
    B=C;
    C=baf;
  }
  if(A<B){
  	baf=A;
    A=B;
    B=baf;
  }
  cout<<A*10+B+C<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N, K; cin >> N >> K;
    vector<int> A(N), B(N), C(N);
    int t = K;
    for (int i = 0; i < N; i += 2) A[i] = t++;
    for (int i = 1; i < N; i += 2) A[i] = t++;
    for (int i = 1; i < N; i += 2) B[i] = t++;
    for (int i = 0; i < N; i += 2) B[i] = t++;
    for (int i = 0; i < N; i += 1) C[i] = t++;
    for (int i = 0; i < N; i++) {
        if (A[i] + B[i] > C[i]) {
            cout << "-1\n";
            return 0;
        }
    }
    for (int i = 0; i < N; i++) {
        cout << A[i] << ' ' << B[i] << ' ' << C[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 3456
public class Main {

    /**
     * ????????????????????????
     *
     * @param args
     */
    public static void main(String[] args) {
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                System.out.println(i + "x" + j + "=" + i * j);
            }
        }
    }
}

Measured memory_bytes: 24256
def step(cheese):
    global x, y, a, d
    gone = set()
    q = [(x, y)]
    steps = 1
    while True:
        nq = []
        for i in q:
            for j in range(4):
                xy = (i[0] + d[j][0], i[1] + d[j][1])
                if a[xy[1]][xy[0]] == cheese:
                    x, y = xy
                    return steps
                elif xy not in gone and a[xy[1]][xy[0]] != "X":
                    gone.add(xy)
                    nq.append(xy)
        q = nq
        steps += 1

h, w, n = map(int, input().split())
d = ((1, 0), (-1, 0), (0, 1), (0, -1))
a = ["X" * (w + 2)]
for _ in range(h):
    a.append("X" + input() + "X")
a.append("X" * (w + 2))
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j] == "S":
            x, y = j, i
            
steps = 0
for i in range(1, n + 1):        
    steps += step(str(i))
print(steps)


Measured memory_bytes: 86900
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <cctype>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef string::const_iterator State;

string str;
int val[6];
bool flag=false;

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}

void term(State &begin){
	int v=number(begin);
	if(v==0)v=1;
	bool used=false;
	while(1){
		if(*begin=='x'){
			begin++;
			if(*begin=='^'){
				begin++;
				int p=number(begin);
				val[p]=v;
				if(flag)val[p]*=-1;
			}else{
				val[1]=v;
				if(flag)val[1]*=-1;
			}
			flag=false;
			used=true;
		}else if(*begin=='+'){
			begin++;
			if(!used){
				val[0]=v;
				if(flag)val[0]*=-1;
				flag=false;
			}
			term(begin);
			break;
		}else if(*begin=='-'){
			begin++;
			if(!used){
				val[0]=v;
				if(flag)val[0]*=-1;
				flag=false;
			}
			flag=true;
			term(begin);
			break;
		}else{
			if(!used){
				val[0]=v;
				if(flag)val[0]*=-1;
			}
			break;
		}
	}
	
}

bool check(int v){
	ll sum=val[0];
	ll p=v;
	for(int i=1;i<=5;i++){
		sum+=(ll)val[i]*p;
		p=(ll)p*v;
	}
	return (sum==0);
}

int main(void){
	cin >> str;
	State begin=str.begin();
	term(begin);
	for(int i=2000;i>=-2000;i--){
		if(check(i)){
			if(i>=0)cout << "(x-" << i << ")";
			else cout << "(x+" << -i << ")";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<algorithm>

typedef long long ll;

struct SegmentTree{
	int x;
	std::vector<ll> data;

	SegmentTree(int n){
		x = 1;
		while(x < n){
			x *= 2;
		}
		data = std::vector<ll>(x*2-1);
	}

	void update(int i, ll value){
		i += x - 1;
		data[i] = value;
		while(i > 0){
			i = (i-1) / 2;
			data[i] = std::max(data[i*2+1], data[i*2+2]);
		}
	}

	ll _query(int a, int b, int i, int l, int r){
		if(r <= a || b <= l) return 0;
		if(a <= l && r <= b) return data[i];
		ll v1 = _query(a, b, i*2+1, l, (l+r)/2);
		ll v2 = _query(a, b, i*2+2, (l+r)/2, r);
		return std::max(v1, v2);
	}
	ll query(int a, int b){
		return _query(a, b, 0, 0, x);
	}
};

int main(){
	int n;
	std::cin >> n;
	std::vector<int> h(n);
	std::vector<ll> a(n);
	for(int i=0; i<n; i++){
		std::cin >> h[i];
	}
	for(int i=0; i<n; i++){
		std::cin >> a[i];
	}

	SegmentTree seg(n+1);
	for(int i=0; i<n; i++){
		seg.update(h[i], seg.query(0, h[i]) + a[i]);
	}
	std::cout << seg.query(0, n+1) << std::endl;
	return 0;

}

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

int main(void) {
    string S;
    cin >> S;
    if (S == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int x, a, b;
    cin >> x >> a >> b;

    int ax = abs(a - x);
    int bx = abs(b - x);

    if(ax < bx){
        p("A");
    }else{
        p("B");
    }
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e4+23;

int a[N], b[N];
long long totA = 0, totB = 0;

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a+i);
  for (int i = 0; i < n; ++i) scanf("%d", b+i);
  for (int i = 0; i < n; ++i) {
    if (a[i] > b[i]) {
      totB += a[i]-b[i];
    } else {
      if (a[i]%2 != b[i]%2) {
	++b[i];
	++totB;
      }
      totA += (b[i]-a[i])/2;
    }
    //printf("%d %d\n", totA, totB);
  }
  if (totA >= totB)  puts("Yes");
  else puts("No");
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int a, b, c;
	cin >> a >> b >> c;
	long long k;
	cin >> k;
	cout << (k % 2 ? b - a : a - b) << endl;
	return 0;	
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int r = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		for (; a % 2 == 0; a /= 2)
			r++;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 0
    right = 0
    s = 0

    for left in range(N):
        while right < N and s & (s ^ A[right]) == s:
            s ^= A[right]
            right += 1

        ans += right - left

        if left == right:
            right += 1
        else:
            s ^= A[left]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 32196
#include<iostream>
using namespace std; 
int main(){
    static const int NUM = 3;
    static int count = 0;

    char s[NUM], t[NUM];
    
    for(int i=0;i<NUM;i++){
        cin >> s[i];
    }
    for(int i=0;i<NUM;i++){
        cin >> t[i];
    }
    for(int i=0; i<NUM; i++){
        if(s[i] == t[i]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int c[3][3], flag = 1;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            scanf("%d", &c[i][j]);
        }
    }

    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 2; j++){
            if((c[i][j] - c[i][j + 1]) != (c[i + 1][j] - c[i + 1][j + 1])){
                    flag = 0;
            }
        }
    }

    if(flag){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n; ll a[100005],th[100005][2];
bool notprime[100005];
map<P,int>M;
map<P,P>PAIR;
int main(){
	cin>>n;// n=100000;
	int ans = 0;int cube = 0; //srand((unsigned)time(NULL));
	th[0][0]=th[0][1]=1LL;
	for(int i=1;i<100005;i++){
		th[i][0]=th[i-1][0]*5LL%mod;
		th[i][1]=th[i-1][1]*7LL%mod;
	}
	for(int i=2;i<100005;i++){
		if(notprime[i]) continue;
		for(int j=2;j*i<100005;j++){
			notprime[i*j]=1;
		}
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		//vector<P>vec;
		ll hashas[2]={};
		ll hashas2[2]={};
		for(int j=2;j<=3000;j++){
			if(a[i]%j==0){
				int cnt=0;
				while(a[i]%j==0){
					a[i]/=j;cnt++;
				}
				if(cnt%3!=0){
					hashas[0] += th[j][0] * (cnt%3) % mod; hashas[0]%=mod;
					hashas[1] += th[j][1] * (cnt%3) % mod; hashas[1]%=mod;
					hashas2[0] += th[j][0] * (3-cnt%3) % mod; hashas2[0]%=mod;
					hashas2[1] += th[j][1] * (3-cnt%3) % mod; hashas2[1]%=mod;
				}
			}
		}
	//	if(i==6)cout<<a[i]<<endl;
		if(a[i]!=1){
			ll lb=0,ub=1000000LL;
			while(ub-lb>1){
				ll mid = (lb+ub)/2;
				if(mid*mid >= a[i]) ub=mid;
				else lb=mid;
			}
			if(ub*ub==a[i]){
				hashas[0] += th[ub][0] * (2) % mod; hashas[0]%=mod;
				hashas[1] += th[ub][1] * (2) % mod; hashas[1]%=mod;
				hashas2[0] += th[ub][0] * (1) % mod; hashas2[0]%=mod;
				hashas2[1] += th[ub][1] * (1) % mod; hashas2[1]%=mod;
			}
			else{
				if(a[i]<100005 && !notprime[a[i]]){
					hashas[0] += th[a[i]][0] * (1) % mod; hashas[0]%=mod;
					hashas[1] += th[a[i]][1] * (1) % mod; hashas[1]%=mod;
					hashas2[0] += th[a[i]][0] * (2) % mod; hashas2[0]%=mod;
					hashas2[1] += th[a[i]][1] * (2) % mod; hashas2[1]%=mod;
				}
				else{
					ans+=2; goto fail;
				}
			}
		}
		if(hashas[0]||hashas[1]){
			M[mp(hashas[0],hashas[1])]++;
			PAIR[mp(hashas[0],hashas[1])]=mp(hashas2[0],hashas2[1]);
		}
		else ans+=!cube*2,cube=1; fail:;
	}//cout<<ans<<endl;
	for(map<P,int>::iterator it=M.begin();it!=M.end();++it){
		const P &v = it->fi;
	//	for(int i=0;i<v.size();i++)cout<<v[i].fi<<" " <<v[i].sc<<endl;
		const P &vv = PAIR[v];
		if(M.find(vv) == M.end()) ans+=(it->sc)*2;
		else ans+=max(M[vv],(it->sc));
	}
	cout<<ans/2<<endl;
}

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

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

long long int gcd(long long int c,long long int d)
{
    if(d==0) return c;
    else return gcd(d,c%d);
}

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
//////////////////////////////////////////////////

int n,m,cell_tim[210][210],sx,sy,ex,ey;
char ch[210][210];

int chk(int x,int y)
{
    if(x<1 || x>n)return 0;
    if(y<1 || y>m)return 0;
    if(ch[x][y]=='#')return 0;
    return 1;
}
void bfs(int xx,int yy)
{
    queue< int >q;
    q.push( xx );
    q.push( yy );
    q.push(  0 );
    cell_tim[xx][yy]=0;
    while(!q.empty())
    {
        int x=q.front();    q.pop();
        int y=q.front();    q.pop();
        int ti=q.front();   q.pop();
        for(int i=0;i<4;i++)
        {
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(chk(nx,ny)==1 && cell_tim[nx][ny]>ti+1)
            {
                cell_tim[nx][ny]=ti+1;
                q.push( nx );
                q.push( ny );
                q.push( ti+1 );
            }
        }
    }
    return ;
}

int dfs1(int xx,int yy)
{
    queue< int >q;
    q.push( xx );
    q.push( yy );
    q.push(  0 );
    cell_tim[xx][yy]=0;
    while(!q.empty())
    {
        int x=q.front();    q.pop();
        int y=q.front();    q.pop();
        int ti=q.front();   q.pop();
        if(x==ex && y==ey) return 1;
        for(int i=0;i<4;i++)
        {
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(chk(nx,ny)==1 && cell_tim[nx][ny]>ti+1)
            {
                cell_tim[nx][ny]=ti+1;
                q.push( nx );
                q.push( ny );
                q.push( ti+1 );
            }
        }
    }
    return 0;
}

int main()
{
    S2(n,m);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            scanf(" %c",&ch[i][j]);
            if(ch[i][j]=='@'){sx=i;sy=j;}
            if(ch[i][j]=='%'){ex=i;ey=j;}
        }
    }

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)cell_tim[i][j]=1000000000;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(ch[i][j]=='$')
            {
                bfs(i,j);
            }
        }
    }
    int ans=dfs1(sx,sy);
    if(ans==1)printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 3284
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(; sc.hasNext();){
			char[] cs=sc.nextLine().toCharArray();
			for(;;){
				for(int i=0; i<cs.length; i++){
					if(Character.isLowerCase(cs[i])){
						if(cs[i]=='z')
							cs[i]='a';
						else
							cs[i]++;
					}
				}
				String s=new String(cs);
				if(s.indexOf("the")!=-1||s.indexOf("this")!=-1
						||s.indexOf("that")!=-1)
					break;
			}
			println(new String(cs));
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
table = [[[0]*10 for i in range (3)] for k in range (4)]

N = int(input())

for _ in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add

for i in range(4):
    if i != 0:
        print("#"*20)

    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()



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

using namespace std;

const int N = 3e3 + 2;

int n;
double dp[N][N], ans, a[N];

int main(){
      cin >> n;

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

      dp[0][0] = 1;

      for(int i = 1; i <= n; i ++){
            dp[i][0] = dp[i - 1][0] * (1 - a[i]);
            for(int j = 1; j <= i; j ++){
                  dp[i][j] = dp[i - 1][j - 1] * a[i] + dp[i - 1][j] * (1 - a[i]);
            }
      }

      for(int i = n / 2 + 1; i <= n; i ++)
            ans += dp[n][i];

      cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


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

intl modinv(intl a, intl p){
  if (a==0){
    cout << "/0 at modinv"<<endl;
    exit(0);
  }
  if (a < 0){
    cout << "/- at modinv" <<endl;
    exit(0);
  }
  if (a==1){return 1;}
  if (a > p){return modinv(a%p, p);}

  return p - ( modinv(p%a,p) * (p/a) ) % p;
}

intl modcomb(intl n, intl k, intl p){
  if (k > n || k < 0 || n < 0){
    cout << "error at modcomb"<<endl;
    exit(0);
  }
  if (2*k > n){ k = n-k;}
  if (k ==0){return 1;}
  intl c=1;
  for (intl i = 0; i < k; i++){
    c =( c * ( (n-i) % p ) % p ) * modinv(i+1,p) % p;
  }
  return c;
}

int main(){
  intl N;
  cin >>N;
  intl N3 = N / 3;
  intl N5 = N /5;
  intl N15 = N /15;
  cout << N * (N+1) /2 - N3 * (N3 + 1) * 3 / 2 - N5 * (N5 + 1) * 5 / 2 + N15 * (N15 + 1) * 15 / 2;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	r := 100.0
	for i := 0; i < n; i++ {
		r = math.Ceil(1.05 * r)
	}

	fmt.Println(int(r * 1000))
}



Measured memory_bytes: 1140
n = int(input())
w = list(map(int,input().split()))
A = w[0]
a = 1
B = 0
b = 1
for i in range(n-1):
    if A >= B:
        B += w[-b]
        b += 1
    else:
        A += w[a]
        a += 1
print(abs(A-B))

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

int main()
{
  int n, d, x;
  cin >> n >> d >> x;
  int a[n];
  rep(i,n) cin >> a[i];
  int ans = x;
  rep(i,n){
    if(d % a[i]) ans++;
    ans += d /a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
a, b, k =  map(int, input().split())
turn_a = 1
for i in range(k):
  if turn_a == 1:
    if a % 2 == 1:
      b = b + (a-1)/2
      a = (a-1)/2
    else:
      b = b + a/2
      a = a/2
    turn_a = 0
  else:
    if b % 2 == 1:
      a = a + (b-1)/2
      b = (b-1)/2      
    else:
      a = a + b/2
      b = b/2 
    turn_a = 1
print(int(a), int(b))

Measured memory_bytes: 3316
import numpy as np
import string

alphabets = "abcdefghijklmnopqrstuvwxyz"

h, w = map(int, input().split(" "))

txt = np.zeros(26, dtype = int)

for i in range(h):
    a = input()
    for j in a:
        txt[alphabets.index(j)] += 1

one = 0
if(h % 2 != 0 and w % 2 != 0):
    one += 1

all = h * w - one

flag = 1
if(one == 1):
    flag = 0
    for i in range(26):
        if(txt[i] % 2 != 0):
            txt[i] -= 1
            flag = 1
            break
num = int(h / 2) * int(w / 2)

while(flag == 1 and all > 0 and num > 0):
    flag = 0
    for i in range(26):
        if(txt[i] > 3):
            txt[i] -= 4
            all -= 4
            flag = 1
            break
    num -= 1

for i in range(26):
     if(txt[i] % 2 != 0):
         flag = 0
         break



if(flag == 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int n,m;
  ll ans = 0LL;
  cin >> n >> m;
  map<int,int> mp;
  for (int i = 1; i <= n; i++){
    mp[i%m]++;
  }
  ans += (ll)mp[0]*mp[0]*mp[0];
  if (m%2 == 0){
    ans+= (ll)mp[m/2]*mp[m/2]*mp[m/2];
  }
  cout << ans << endl;

  


  return 0; 
}



Measured memory_bytes: 4992
import sys
from collections import deque
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    A = string_to_int(inputs[0])
    odds = []

    for a in A:
        if a % 2 == 0:
            odds.append(a)
    count = 0
    for o in odds:
        while o % 2 != 1:
            o /= 2
            count += 1

    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 4836
#include<stdio.h>
int main()
{
   int  am[9], pm[9], i;
   char m[9];

   for(i=0; i<9; i++){
     scanf("%s%d%d", m, &am[i], &pm[i]);
     printf("%s %d %d\n",m, am[i]+pm[i], 200*am[i]+300*pm[i]);
   }

   /*for(i=0; i<9; i++){
     printf("%d%c %d %d\n",n[i], m[i], am[i]+pm[i], 200*am[i]+300*pm[i]);
     
   }
   */
   
     return 0;

 }

Measured memory_bytes: 596
N=int(input())

S=input()

R=[]
G=[]
B=[]

for i in range(len(S)):
    if S[i]=='R':
        R.append(i)
    elif S[i]=='G':
        G.append(i)
    else:
        B.append(i)

ex=0
for i in range(1,len(S)-1):
    for j in range(i+1,len(S)):
        if 2*j-i<=len(S):
            if S[i-1]!=S[j-1] and S[j-1]!=S[2*j-i-1] and S[i-1]!=S[2*j-i-1]:
                ex+=1

print((len(R)*len(G)*len(B))-ex)

Measured memory_bytes: 68284
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e6 +9;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9+7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;

ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll val[N];
ll adj[N][2];
ll ans = 0;
multiset<ll> l,r;
map<ll,bool> cnbf;
map<ll,int> ct;
void dfs(ll v){
     if(adj[v][0]!=-1){
          l.insert(val[v]);
          dfs(adj[v][0]);
          auto e = l.find(val[v]);
          l.erase(e);
     }
     if(adj[v][1]!=-1){
          r.insert(val[v]);
          dfs(adj[v][1]);
          auto e = r.find(val[v]);
          r.erase(e);
     }
     ll ul = inf;
     ll ll = 0;
     if(l.size() ){
          ul = *l.begin();
         
     }
     if(r.size()){
          ll = *r.rbegin();
          // cout<<ll<<'\n';
     }
          // cout<<v<<" "<<ul<<" "<<ll<<'\n';

     if(val[v]>=ll && val[v]<=ul){
          cnbf[val[v]] = 1;
     }


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

     ll q = 1;
     // cin>>q;
     while(q--){
          ll n;cin>>n;
          ll ac[n][3];
          for(int i = 0;i<n;i++){

               cin>>ac[i][0]>>ac[i][1]>>ac[i][2];
          }
          for(int i = 1;i<n;i++){
               ac[i][0] = max(ac[i-1][1],ac[i-1][2])+ac[i][0];
               ac[i][1] = max(ac[i-1][0],ac[i-1][2])+ac[i][1];
               ac[i][2] = max(ac[i-1][1],ac[i-1][0])+ac[i][2];
          }
          cout<<max(max(ac[n-1][0],ac[n-1][1]),ac[n-1][2])<<'\n';

     }
}         

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

using namespace std;

using ll = long long;

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

    int cnt = 0;
    int size = s.size();
    for (int i = 0; i < size / 2; i++) {
        if (s[i] != s[size - 1 - i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
using namespace std;


int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	if(a==b&&c==d)cout<<"yes"<<endl;
	else if(a==c&&b==d)cout<<"yes"<<endl;
	else if(a==d&&b==c)cout<<"yes"<<endl;
	else cout<<"no"<<endl;


	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int n,m;
  cin >> n >> m;
  int h[n];
  for(int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int a[m],b[m];
  int vc[n];
  for(int i = 0; i < n; i++) {
    vc[i] = 1;
  }
  //vector<int> vc(n,1);
  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if(h[a[i]] < h[b[i]]) {
      vc[a[i]] = 0;
    }else if(h[a[i]] > h[b[i]]) {
      vc[b[i]] = 0;
    }else {
      vc[a[i]] = 0;
      vc[b[i]] = 0;
    }
  }
  int count = 0;
  for(int i = 0; i < n; i++) {
    if(vc[i] == 1) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 5180
#include <iostream>

using namespace std;

int main()
{
    long unsigned int n;
    cin >> n;
    long long unsigned int a[n];
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    long int divby4=0, divby2=0;
    for (int i=0;i<n;i++)
    {
        if(a[i]%4==0)
        {
            divby4++;
        }
        else if(a[i]%2==0)
        {
            divby2++;
        }
    }
    if (divby4>=n/2)
    {
         cout << "Yes";
         return 0;
    }
    if (2*divby4+divby2==n)
    {
        cout << "Yes";
         return 0;
    }
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int w,a,b;
  cin>>w>>a>>b;
  if(a<b){
    if(b<=a+w)cout<<0<<endl;
    else cout<<b-a-w<<endl;
  }else{
    if(a<=b+w)cout<<0<<endl;
    else cout<<a-b-w<<endl;
  }
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    h=parseMap(split(readline()))
    ans=0
    cnt=0
    for i in 1:n-1
        if h[i]>=h[i+1]
            cnt+=1
        else
            ans=max(cnt,ans)
            cnt=0
        end
    end
    println(max(ans,cnt))
end
main()

Measured memory_bytes: 119032
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
      ll a,n; cin >> n;
      vector <string> vec(n);
      for (int i=0;i<n;i++){
          cin >> vec.at(i);
      }
      for(int i=0;i<n-1;i++){
          for(int j=i+1;j<n;j++){
              if(vec.at(i)==vec.at(j)){
                  cout << "No" << endl;
                  return 0;
              }
          }
      }
      for(int i=0;i<n-1;i++){
          char a,b;
          a=(vec.at(i)).at(vec.at(i).size()-1);
          b=(vec.at(i+1)).at(0);
          if(a!=b){
              cout << "No" << endl;
              return 0;
          }
      }

      cout << "Yes" << endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    vector<int> p;
    rep(i, (int)s1.size()){
        if(s1[i] == s2[i]) p.push_back(1);
        else {
            p.push_back(2);
            i++;
        }
    }

    const int mod = 1000000007;
    ll ans = 0;
    if(p[0] == 1) ans = 3;
    else ans = 6;
    for(int i = 1; i < (int)p.size(); i++){
        if(p[i - 1] == 1) ans *= 2;
        else if(p[i] == 2) ans *= 3;
        ans %= mod;
    }
    cout << ans << endl;
}

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

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int k, x;
    cin >> k >> x;
    int min_n = max(-1000000, x-k+1);
    int max_n = min( 1000000, x+k-1);
    for(int i = min_n; i < max_n; i++){
        cout << i << " ";
    }
    cout << max_n << " " << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
int i,j,n,P[10001];int main(){for(i=2;i*i<10001;i++)for(j=i*2;j<10001;j+=i)P[j]=1;for(;std::cin>>n,n;printf("%d %d\n",i-2,i))for(i=n&1?n:n-1;i>4&&(P[i]||P[i-2]);i-=2);return 0;}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#define INF 0
int dp[17][17];
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	int i,j,k,notx,noty;
	int h,w,ss;
	while(1) {
		cin>>w>>h;
		if(h==0&&w==0) break;
		for(i=1;i<=h;i++) 
			for(j=1;j<=w;j++) dp[i][j]=INF;
		cin>>ss;
		for(i=1;i<=ss;i++) {
			cin>>notx>>noty;
			dp[noty][notx]=-1;
		}
		dp[1][1]=1;
		for(i=1;i<=h;i++) {
			for(j=1;j<=w;j++) {
				if(dp[i][j]!=-1 && dp[i][j]!=INF ) {
					if(dp[i+1][j]!=-1) 
						if(i+1<=h) dp[i+1][j]+=dp[i][j];
					if(dp[i][j+1]!=-1)
						if(j+1<=w) dp[i][j+1]+=dp[i][j];
				}
			}
		}
		cout<<dp[h][w]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner input = new Scanner(System.in);
        String line = input.nextLine();
        int N = Integer.parseInt(line);
        String[] array = line.split("");

        int Snum = 0;
        int arrayLength = array.length;

        for(int i = 0; i < arrayLength; i++){
        	Snum += Integer.parseInt(array[i]);
        }

        if(N % Snum == 0){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}

}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }


int main(){
    int n;
    set<int> se;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        se.insert(x);
    }
    if(se.size()!=n) cout<<"NO"<<endl;
    else cout<<"YES"<<endl; 
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int main(void){
    int k,x;
    cin>>k>>x;
    vector<int>ans;
    int num=0;
    int y=x;
    while(num<k-1){
        y--;
        ans.push_back(y);
        num++;
    }
    num=0;
    y=x;
    while(num<k-1){
        y++;
        ans.push_back(y);
        num++;
    }
    ans.push_back(x);
    sort(ans.begin(),ans.end());
    for(int i=0;i<(int)ans.size();i++){
        if(i==(int)ans.size()-1)cout<<ans[i]<<endl;
        else cout<<ans[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0061().doIt();
	}
	
	class AOJ0061{
		void doIt(){
			ArrayList<Data> list = new ArrayList<Data>();
			while(in.hasNext()){
				String[] a = in.next().split(",");
				if(a[0].equals("0")&&a[1].equals("0"))break;
				list.add(new Data(Integer.parseInt(a[0]),Integer.parseInt(a[1])));
			}
			Collections.sort(list);
//			for(int i=0;i<list.size();i++)System.out.println(list.get(i).id+" "+list.get(i).ans);
			while(in.hasNext()){
				int num = in.nextInt();
				int result = 1;
				for(int i=1;i<list.size();i++){
					if(list.get(i-1).ans>list.get(i).ans)result++;
					if(list.get(i).id==num)break;
				}
				if(list.get(0).id==num)result = 1;
				System.out.println(result);
			}
		}
		class Data implements Comparable<Data>{
			int ans,id;
			public Data(int id,int ans) {
				this.id = id;
				this.ans = ans;
			}
			public int compareTo(Data o) {
				if(this.ans>o.ans)return -1;
				else if(this.ans<o.ans)return 1;
				return 0;
			}
		}
	}
	
}

Measured memory_bytes: 15372
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String S =sc.next();
      
      char[] a =S.toCharArray();
      
     for(int i=0; i<S.length(); i++){
     if(i%2==0){
     if(a[i]=='L'){
     System.out.println("No");
       return;
     }
     }
       if(i%2!=0){
       if(a[i]=='R'){
       System.out.println("No");
         return;
       }
       }
     }
      System.out.println("Yes");
    }
}

Measured memory_bytes: 20948
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
  ll N,A[107],B=0;
  cin >> N;
  rep(i,N-1){
    cin >> A[i];
  }
  rep(i,N){
    if(i==0){
      B+=A[0];
    }
    else if(i==N-1){
      B+=A[N-2];
    }
    else{
      B+=min(A[i-1],A[i]);
    }
  }
  cout <<  B  << endl;
}

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

int N;
const int MAX_N = 2.0e5 + 10;
ll A[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    bool possible = true;
    
    if (A[0] != 0) possible = false;
    for (int i = 1; i < N; i++) {
        if (A[i-1] < A[i] && A[i-1] + 1 != A[i]) {
            possible = false;
            break;
        }
    }

    if (possible) {
        ll ans = 0;
        for (int i = N-1; i >= 1; i--) {
            if (A[i-1] + 1 == A[i]) {
                ans++;
            }
            else {
                ans += A[i];
            }
        }
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string S;
    cin >> S;
    int N = S.size();

    ll ans    = 0;
    ll nowsum = S[0] - '0';

    rep(i, 1 << (N - 1)) {
        rep(j, N - 1) {
            if (i & (1 << j)) {
                // +が来た場合、ここまでの計算を一度確定させて、
                // 次の桁から始める
                ans += nowsum;
                nowsum = S[j+1] - '0';
            } else {
                // +が来ない場合、繰り上げ
                nowsum *= 10;
                nowsum += (S[j+1] - '0');
            }
        }
        ans+=nowsum;
        nowsum = S[0] - '0';
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
main = do
    n <- readLn :: IO Int
    hs <- map read . words <$> getLine :: IO [Int]
    print $ solve 0 hs

solve :: Int -> [Int] -> Int
solve n hs = case 0 `elem` hs of
    True -> foldl solve n $ split 0 hs
    False -> 1 + solve n (map (\x -> x-1) hs)

split  :: Eq a => a -> [a] -> [[a]]
split p xs =  case dropWhile (\x -> x==p) xs of
                      [] -> []
                      xs' -> w : split p xs''
                            where (w, xs'') = break (\x -> x==p) xs'

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

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

ll powermod(ll x,ll ex,ll md){ll ans=1ll;while(ex>0){if(ex&1ll) ans=(ans*x)%md; ex>>=1ll;x=(x*x)%md;}return ans;}
inline ll gcd(ll a,ll b) {if(b==0)return a;a%=b;return gcd(b,a);}
inline ll max(ll a,ll b) {return((a>b)?a:b);}
inline ll min(ll a,ll b) {return((a>b)?b:a);}


int main(){
        IOS;
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll x,y,z,w;
        x=a*c;
        y=a*d;
        z=b*c;
        w=b*d;
        ll ans=LLONG_MIN;
        ans=max(ans , x);
        ans=max(ans , y);
        ans=max(ans , z);
        ans=max(ans , w);
        cout<<ans<<"\n";
}


Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

int main () {
	int n,m;
	scanf("%d%d",&n,&m);
	vector<int> odd;
	deque<int> even;
	int x;
	for (int i=0;i<m;i++) {
		scanf("%d",&x);
		if (m==1) {
			if (x==1) {
				printf("1\n1\n1\n");
				return 0;
			}
			printf("%d\n2\n%d %d\n",x,x-1,1);
			return 0;
		}
		if (x%2) odd.push_back(x);
		else even.push_back(x);
	}
	if (odd.size()>2) {
		printf("Impossible\n");
		return 0;
	}
	if (odd.size()>0) {
		even.push_front(odd[0]);
	}
	if (odd.size()>1) {
		even.push_back(odd[1]);
	}
	for (auto it:even) {
		printf("%d ",it);
	}
	even.front()--;
	even.back()++;
	if (even.front()==0) even.pop_front();
	printf("\n%d\n",even.size());
	for (auto it:even) {
		printf("%d ",it);
	}
	printf("\n");
	return 0;
}


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

int main(){
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%.6lf\n", sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}


Measured memory_bytes: 2032
#include<iostream>
using namespace std;
int a[20001], b[20001], p[20001], q[20001], n;
int main() {
	cin >> n; for (int i = 1; i <= n; i++)cin >> p[i];
	for (int i = 1; i <= n; i++) { q[p[i]] = i; }
	for (int i = 1; i <= n; i++)a[i] = i * 30000;
	for (int i = 1; i <= n; i++)b[i] = (n + 1 - i) * 30000 + q[i];
	for (int i = 1; i <= n; i++) { if (i >= 2)cout << ' '; cout << a[i]; }cout << endl;
	for (int i = 1; i <= n; i++) { if (i >= 2)cout << ' '; cout << b[i]; }cout << endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i;i<j;i++)
#define print(t) cout<<t<<endl
typedef long long ll;
typedef string str;


int main(){
	str s;
	int n,k;
	cin >> n >> k >> s;
	s[k-1]+=32;
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

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

	if (a < b && a < c)
	{
		printf("%d ", a);
		if (b < c) printf("%d %d\n", b, c);
		else printf("%d %d\n", c, b);
	}
	else if (a < b || a < c)
	{
		if (b < c) printf("%d %d %d\n", b, a, c);
		else printf("%d %d %d\n", c, a, b);
	}
	else
	{
		if (b < c) printf("%d %d ", b, c);
		else printf("%d %d ", c, b);
		printf("%d\n", a);
	}

	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		int sqrt = (int) Math.floor(Math.sqrt(n));
		int min_Keta = String.valueOf(n).length();

		for (int i = 2; i <= sqrt ; i++){
			if (n % i == 0){
				min_Keta = Math.min(min_Keta, Math.max(String.valueOf(i).length(),String.valueOf(n / i).length()));
			}
		}

		System.out.println(min_Keta);
	}

}


Measured memory_bytes: 22868
# ビンゴは8通りあるためすべてをチェック
# a多次元配列でビンゴカードを表す
a = [list(map(int, input().split())) for _ in range(3)]
d = [[0] * 3 for _ in range(3)]
n = int(input())
# カードにbリストの数があれば、その数を１に変換
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                d[j][k] = 1
# 縦3通り、横3通り、斜め2通りについてチェック
for i in range(3):
    if sum(d[i]) == 3:
        print('Yes')
        exit(0)
for i in range(3):
    res = 0
    for j in range(3):
        res += d[j][i]
    if res == 3:
        print('Yes')
        exit(0)
res = 0
for i in range(3):
    res += d[i][i]
if res == 3:
    print('Yes')
    exit(0)
res = 0
for i in range(3):
    res += d[i][2 - i]
if res == 3:
    print('Yes')
    exit(0)
print('No')

Measured memory_bytes: 3064
#include <cstdio>

int N,M,Q;
int fld[2007][2007];
int parent[2007][2007];
int sum[2007][2007];
int vx[5]={1,0,-1,0};
int vy[5]={0,1,0,-1};
void dfs(int nx,int ny,int frvec) {
	parent[nx][ny]=frvec;
	for(int i=0;i<4;i++) {
		if(frvec!=i) {
			if(fld[nx+vx[i]][ny+vy[i]]) {
				dfs(nx+vx[i],ny+vy[i],(i+2)%4);
			}
		}
	}
}
char str[2009];
int main() {
	scanf("%d%d%d",&N,&M,&Q);
	for(int i=1;i<=N;i++) {
		scanf("%s",str);
		for(int j=1;j<=M;j++) {
			fld[i][j]=(int)(str[j-1]-'0');
			parent[i][j]=-1;
		}
	}
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=M;j++) {
			if(fld[i][j]==1&&parent[i][j]<0) {
				dfs(i,j,4);
				sum[i][j]=1+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			} else {
				sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			}
		}
	}
	for(int i=0;i<Q;i++) {
		int xa,xb,ya,yb;
		scanf("%d%d%d%d",&xa,&ya,&xb,&yb);
		int sol=sum[xb][yb]-sum[xb][ya-1]-sum[xa-1][yb]+sum[xa-1][ya-1];
		for(int j=xa;j<=xb;j++) {
			if(parent[j][ya]==3) sol++;
			if(parent[j][yb]==1) sol++;
		}
		for(int j=ya;j<=yb;j++) {
			if(parent[xa][j]==2) sol++;
			if(parent[xb][j]==0) sol++;
		}
		printf("%d\n",sol);
	}
	return 0;
}


Measured memory_bytes: 49408
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <iterator>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main() {
	fast();
	int a,b;
  cin>>a>>b;
  cout<<a*b<<nl;
}


Measured memory_bytes: 3612
//最大に注目
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cassert>
using namespace std;

int k, t;
int a[100];

signed main() {
	int i;
	
	cin >> k >> t;
	for (i = 0; i < t; i++) {
		cin >> a[i];
	}
	
	int maxi = 0;
	for (i = 0; i < t; i++) {
		maxi = max(a[i], maxi);
	}
	
	if (k % 2 == 1) {
		if (maxi * 2 - 1 <= k) {
			cout << 0 << endl;
		}
		else {
			cout << (maxi - (k + 1) / 2) * 2 << endl;
		}
	}
	else {
		if (maxi * 2 <= k) {
			cout << 0 << endl;
		}
		else {
			cout << (maxi - k / 2) * 2 - 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#define INT long long int
#define MOD 1000000007
#define oo 978654321
#define OO 9999999987654321ll
using namespace std;
INT a, b, c, d, T, O, H, Q, n, ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>a>>b>>c>>d>>n;
    T = min(d, min(2*c, min(4*b, 8*a)));
    O = min(c, min(2*b, 4*a));
    H = min(b, 2*a);
    Q = a;
    ans = (n/2)*T;
    n%=2;
    ans += n*O;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int X,Y;
    cin >> X >> Y;
    if(Y%2==0){
          int y = (Y/2)-X;
         int x = X-y;
         if(2*x+4*y == Y){
              if(x>=0 && y>=0){
               cout << "Yes";     
              }else{
                   cout<<"No";
              }
         }
         else{
              cout << "No";
         }      
    }else{
         cout << "No";
    }
    
}

Measured memory_bytes: 3592