akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;

struct union_find_tree {
    vector<int> data;
    union_find_tree() = default;
    explicit union_find_tree(size_t n) : data(n, -1) {}
    bool is_root(int i) { return data[i] < 0; }
    int find_root(int i) { return is_root(i) ? i : (data[i] = find_root(data[i])); }
    int tree_size(int i) { return - data[find_root(i)]; }
    int unite_trees(int i, int j) {
        i = find_root(i); j = find_root(j);
        if (i != j) {
            if (tree_size(i) < tree_size(j)) swap(i,j);
            data[i] += data[j];
            data[j] = i;
        }
        return i;
    }
    bool is_same(int i, int j) { return find_root(i) == find_root(j); }
};

int main() {
    int n, k, l; cin >> n >> k >> l;
    union_find_tree uft1(n);
    REP (i, k) {
        int p, q; cin >> p >> q; -- p; -- q;
        uft1.unite_trees(p, q);
    }
    union_find_tree uft2(n);
    REP (i, l) {
        int r, s; cin >> r >> s; -- r; -- s;
        uft2.unite_trees(r, s);
    }
    map<pair<int, int>, int> cnt;
    REP (i, n) {
        cnt[make_pair(uft1.find_root(i), uft2.find_root(i))] += 1;
    }
    REP (i, n) {
        cout << cnt[make_pair(uft1.find_root(i), uft2.find_root(i))] << ' ';
    }
    cout << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++){
   
    if((i+1) % 2 != 0){
      cout << s[i];
    }
  }
  
  cout << endl;
}

Measured memory_bytes: 512
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int h = nextInt();
			if (h == 0) {
				break;
			}

			int[][] map = new int[h][5];
			for (int i = 0; i < map.length; i++) {
				for (int j = 0; j < map[i].length; j++) {
					map[i][j] = nextInt();
				}
			}

			int total = 0;
			while (true) {
				int score = 0;
				for (int i = 0; i < map.length; i++) {
					for (int j = 0; j < 3; j++) {
						if (map[i][j] == map[i][j + 1]
								&& map[i][j + 1] == map[i][j + 2]
								&& map[i][j] > 0) {
							int point = map[i][j];
							map[i][j] = 0;
							map[i][j + 1] = 0;
							map[i][j + 2] = 0;
							if (j + 3 < map[i].length && map[i][j + 3] == point) {
								map[i][j + 3] = 0;
								if (j + 4 < map[i].length
										&& map[i][j + 4] == point) {
									score += point * 5;
									map[i][j + 4] = 0;
								} else {
									score += point * 4;
								}
							} else {
								score += point * 3;
							}
						}
					}
				}
				if (score > 0) {
					total += score;
				} else {
					break;
				}

				for (int i = 0; i < 5; i++) {
					int[] column = new int[h];
					int k = 0;
					for (int j = h - 1; j >= 0; j--) {
						if (map[j][i] != 0) {
							column[k] = map[j][i];
							k++;
						}
					}
					for (int j = 0; j < column.length; j++) {
						map[h - j - 1][i] = column[j];
					}
				}
			}
			System.out.println(total);

		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

Measured memory_bytes: 24360
H,W=map(int,input().split())
if (H*W)%3==0:
  ret=0
else:
  ret=min(H,W)
  S=[0]*3
  for h in range(1,H):
    S=[(W//2)*h, (W-W//2)*h, W*(H-h)]
    ret=min(ret,max(S)-min(S))
  for w in range(1,W):
    S=[(H//2)*w, (H-H//2)*w, H*(W-w)]
    ret=min(ret,max(S)-min(S))
print(ret)    

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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 2e5 );
const int MOD  = int( 360 );
const int oo   = INT_MAX;

int x, y;

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "attack.in", "r", stdin );
    //freopen( "attack.out", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> x >> y ) {
    int ans = 0,dif = abs( abs(y)-abs(x) );
    if( x == y )
      ans = 0;
    else if( x == -y )
      ans = 1;
    else if( x < y ) {
      if( x < 0 ) {
        if( y <= 0 ) {
          ans = dif;
        }
        else {
          ans = 1+dif;
        }
      }
      else {
        ans = y-x;
      }
    }
    else {
      if( x < 0 ) {
        ans = 2+dif;
      }
      else if( x > 0 ) {
        if( y <= 0 ) {
          ans = 1 + dif;
        }
        else {
          ans = 2+dif;
        }
      }
      else {
        ans = abs(y)+1;
      }
    }

    cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

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

  if( (a == b) && (b == c)){
    cout << 1 << endl;
  } else if((a == b) || (b == c) || (c == a)){
    cout << 2 << endl;
  } else{
    cout << 3 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;



public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String num1 = sc.next();
        String num2 = sc.next();
        int N = Integer.parseInt(num1);
        int K = Integer.parseInt(num2);
        String str = sc.next();
        char c[] = str.toCharArray();
        
        c[K - 1] = (char) (c[K - 1] - ('A' - 'a'));
        
        for(char ch : c){
            System.out.print(ch);
        }
    }
}


Measured memory_bytes: 21204
H, W = map(int, input().split())
a = [input() for _ in range(H)]
for i in range(H):
  if a[i] != "." * W:
    s = ""
    for j in range(W):
      if [X[j] for X in a].count("#")>0:
        s += a[i][j]
    print(s)

Measured memory_bytes: 73536
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 53;const ll inf=1e18;
int n,x,d,fa[N],a[N],val[N];ll cost[N],qz[N][N*N*N],res;
Pii s[N];int len;
bool cmp(Pii a, Pii b){return 1LL*a.se*b.fi>1LL*b.se*a.fi;}
int main() {
	read(n);read(x);read(d);
	rep(i,1,n){
		read(a[i]);if(i>1)read(fa[i]);
		val[i]=1;cost[i]=a[i];
	}
	per(i,n,1)val[fa[i]]+=val[i],cost[fa[i]]+=cost[i];
	rep(i,1,n)if(cost[i]<=x)s[++len]=Pii(cost[i],val[i]);
	sort(s+1,s+len+1,cmp);
//	rep(i,1,len)cerr<<s[i].fi<<' '<<s[i].se<<endl;
	rep(i,0,len+1)rep(j,0,len*n*n)qz[i][j]=inf;
	qz[0][0]=0;
	rep(i,0,len-1)rep(j,0,len*n*n)if(qz[i][j]<=x)
		for(int k=0;k<=min(d,n)&&qz[i][j]+1LL*k*s[i+1].fi<=x;k++)
			umin(qz[i+1][j+k*s[i+1].se],qz[i][j]+1LL*k*s[i+1].fi);
	rep(i,0,len*n*n)if(qz[len][i]<=x){
		ll ans=i,lst=x-qz[len][i];
		rep(j,1,len){
			ll cnt=d-min(d,n);if(s[j].se==n)cnt=0x3f3f3f3f;
			int cur=min(cnt,lst/s[j].fi);
			ans+=1LL*cur*s[j].se;lst-=1LL*cur*s[j].fi;
		}
		umax(res,ans);
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 61440
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class SegmentTree {
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        n = 1;
        int s = v.size();
        while (n < s) n *= 2;
        node.resize(2 * n - 1, 0);
        for (int i = 0; i < s; i++) node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) node[i] = node[2 * i + 1] + node[2 * i + 2];
    }

    void add(int x, int val) {
        x += (n - 1);
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2 * x + 1] + node[2 * x + 2];
        }
    }

    int find(int a, int b, int k = 0, int l = 0, int r = -1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];

        int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n, 0);
    // vector<int> a(n);
    // REP(i, n) cin >> a[i];
    SegmentTree st(a);
    REP(i, q) {
        int c, a, b;
        cin >> c >> a >> b;
        if (c == 0) st.add(a - 1, b);
        else cout << st.find(a - 1, b) << endl;
    }
}



Measured memory_bytes: 4576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 200005;

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

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

vlli g[MAXN];
lli ans[MAXN], vis[MAXN];

void dfs(lli node) {
    if (vis[node]) return;
    vis[node] = 1;
    for (int i = 0; i < g[node].size(); i++) {
        if (!vis[g[node][i]]) {
            ans[g[node][i]] += ans[node];
            dfs(g[node][i]);
        }
    }
}

void solve() {
    lli n, q;
    cin >> n >> q;
    for (int i = 1; i <= n - 1; ++i) {
        lli u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 1; i <= q; ++i) {
        lli p, x;
        cin >> p >> x;
        ans[p] += x;
    }

    dfs(1);

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << ' ';
    }
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 25856
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>

// template {{{
using namespace std;

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))

using int64 = long long;

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

bool in_field(int W, int H, int x, int y) {
  return (0 <= x && x < W) && (0 <= y && y < H);
}

// pair
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
// vector
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << "\t";
  }
  return s;
}

// }}}

// url: https://atcoder.jp/contests/abc124/tasks/abc124_c

string S;

int main() {
  cin >> S;

  int ans = 0;

  int tmp;
  tmp = 0;
  rep(i, S.length()) {
    if (i % 2 == 0 && S[i] == '0') {
      tmp++;
    }
    if (i % 2 == 1 && S[i] == '1') {
      tmp++;
    }
  }
  ans = tmp;

  tmp = 0;
  rep(i, S.length()) {
    if (i % 2 == 0 && S[i] == '1') {
      tmp++;
    }
    if (i % 2 == 1 && S[i] == '0') {
      tmp++;
    }
  }
  ans = min(ans, tmp);

  cout << ans << endl;

  return 0;
}

// vim: foldmethod=marker


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std; 
int main(){
	ll x,y,z,K;
	scanf("%lld %lld %lld %lld",&x,&y,&z,&K);
	vector<ll>a,b,c;
	ll temp;
	for(int i=0; i<x; i++){
		scanf("%lld",&temp);
		a.push_back(temp);
	}
	for(int i=0; i<y; i++){
		scanf("%lld",&temp);
		b.push_back(temp);
	}
	for(int i=0; i<z; i++){
		scanf("%lld",&temp);
		c.push_back(temp);
	}
	sort(a.begin(),a.end(),greater<ll>());
	sort(b.begin(),b.end(),greater<ll>());
	sort(c.begin(),c.end(),greater<ll>());
	priority_queue<ll> pq;
	
	for(int i=0; i<x ; i++){
		for(int j=0; j<y ; j++){
			for(int k=0; k<z ; k++){
				if((i+1)*(j+1)*(k+1)>K)
					break ;
				else
					pq.push(a[i]+b[j]+c[k]);
			}
		}
	}

	while(K-- && !pq.empty()){
		printf("%lld\n",pq.top());
		pq.pop();
	}
		
	return 0;
}
/*
2 2 2 8
4 6
1 5
3 8
*/


Measured memory_bytes: 1412
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0)
    {
        if( ret.find(2) != ret.end() ) {
            ret[2]++;
        }
        else
        {
            ret[2] = 1;
        }
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            if( ret.find(i) != ret.end() ) {
            ret[i]++;
        }
        else
        {
            ret[i] = 1;
        }
            n = n / i;
        }
    }
    if (n > 2)
        {
            if( ret.find(n) != ret.end() ) {
            ret[n]++;
        }
        else
        {
            ret[n] = 1;
        }
        }
    return ret;
}

void print_map(map<char, int> mp){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first           // キーを表示
                        << ", val = " << itr->second << "\n";    // 値を表示
    }
}

// Returns nCr % p
ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N, M;
    cin >> N >> M;
    ll count = 0;
    vector<long> vec1(M);
    rep(i, M) {
        cin >> vec1.at(i);
    }
    sort(vec1.begin(), vec1.end());
    vector<long> vec2(M - 1);
    rep(i, M-1)
    {
        vec2.at(i) = vec1.at(i + 1) - vec1.at(i);
    }
    sort(vec2.begin(), vec2.end());
    ll sum = 0;
    rep(i, M - 1 - (N - 1))
    {
        sum += vec2.at(i);
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
long long gcd(long long a, long long b) {
  if (b == 0) return a;

  return gcd(b, a % b);
}

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

int N, M;
string S, T;

int main() {
  cin >> N >> M;
  cin >> S >> T;

  ll L = lcm(N, M);
  ll g = gcd(N, M);

  ll ng = N / g;
  ll mg = M / g;

  for (int i = 0; i < g; ++i) {
    if (S[ng * i] != T[mg * i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << L << endl;
}


Measured memory_bytes: 512
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
c=collections.Counter(a)
if len(c)<k:
    print(ans)
    exit()
l=c.most_common()
for i in range(1,-k+len(c)+1):
    ans+=l[-i][1]
print(ans)


Measured memory_bytes: 44600
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  vector<ll> p;
  cin >> N;
  rep(i,N){
    ll inp;cin >> inp;
    p.pb(inp);
  }

  ll ans = 0;
  rep(i,N-1){
    if(p[i]==i+1){
      swap(p[i],p[i+1]);
      ans++;
    }
  }
  if(p[p.size()-1]==p.size()) ans++;

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


Measured memory_bytes: 1400
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> s;
    cout << (s=="ABC"?"ARC":"ABC") << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n; char map[600][600];
int a[600], b[600];
bool flag = 0;
signed main() {
	cin >> n;
	for1(i, n)for1(j, n) {
		cin >> map[i][j];
		if (map[i][j] == '#') { a[i]++; b[j]++; flag = 1; }
	}
	if (!flag) { cout << "-1\n"; return 0; }
	int ans = n * 2, m = 0;
	for1(p, n) if (b[p] == n)m++;
	for1(p, n) {
		ans = min(ans, n - a[p] + 1 + n - m);
		if (b[p])ans = min(ans, n - a[p] + n - m);
	}
	cout << ans << endl;
}

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

int main(){
  int s;
  vector<int> tmp(10000);
  cin >> s;
  tmp.at(0)=s;
  for(int i=1;i<10000;i++){
    if(tmp.at(i-1)%2==0){
      tmp.at(i)=tmp.at(i-1)/2;
    }else{
      tmp.at(i)=3*tmp.at(i-1)+1;
    }
    for(int j=0;j<i;j++){
      if(tmp.at(i)==tmp.at(j)){
        cout << i+1 << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string mp[1111];
int h,w;
int num[1111][1111];
int vx[4]={1,0,-1,0};
int vy[4]={0,-1,0,1};
bool check(int x,int y){
  return x>=0&&x<h&&y>=0&&y<w&&num[x][y]==(1e9);
}
int main(){
  cin>>h>>w;
  for(int i=0;i<1111;i++)for(int j=0;j<1111;j++)num[i][j]=1e9;
  queue<pair<pair<int,int>,int>>que;
  for(int i=0;i<h;i++){
    cin>>mp[i];
    for(int j=0;j<w;j++){
      	if(mp[i][j]=='#'){
          num[i][j]=0;
          que.push(make_pair(make_pair(i,j),0));
        }
    }
  }
  while(!que.empty()){
    pair<int,int>now=que.front().first;
    int cnt=que.front().second;
    que.pop();
    for(int i=0;i<4;i++){
      int x=vx[i]+now.first,y=vy[i]+now.second;
      if(check(x,y)){
        num[x][y]=cnt+1;
        que.push(make_pair(make_pair(x,y),cnt+1));
      }
    }
  }
  int ans=0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      ans=max(ans,num[i][j]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 18320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    ll a,b;
    cin >> a >> b;
    cout << a/__gcd(a,b)*b << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    string a,b,c;
    cin>>a>>b>>c;
    
    string i,j,k;
    i=toupper(a[0]);
    j=toupper(b[0]);
    k=toupper(c[0]);
    
    cout<<i+j+k<<endl;
    
    
    return 0;
}






Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int>a,b,c;
    int t;
    
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        a.push_back(t);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        b.push_back(t);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        c.push_back(t);
    }
    
    
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    vector<int>::iterator itr1,itr2;
    long long int sum = 0;
    for(int i=0;i<n;i++){
        itr1 = lower_bound(a.begin(),a.end(),b[i]);
        itr2 = lower_bound(c.begin(),c.end(),b[i]+1);
        sum += distance(a.begin(),itr1)*distance(itr2,c.end());
    }
    cout << sum << endl; 
    return 0;
}

Measured memory_bytes: 1784
def solve():
  while True:
    n, m = map(int, input().split())
    if not n:
      break
    smap = [int(input()) for _ in range(n)]
    ind = 0
    cnt = 0
    flag = True
    for _ in range(m):
      ind += int(input())
      if flag:
        cnt += 1
        if ind >= n - 1:
          print(cnt)
          flag = False
        else:
          ind += smap[ind]
          if ind >= n:
            print(cnt)
            flag = False
  
solve()


Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    int n,c;
    cin>>n>>c;
    //imos法する。する前にチャンネル一個一個まとめる
    vector<vector<pair<int,int>>> v(c);
    rep(i,n){
        int st,en,ch;
        cin>>st>>en>>ch;
        ch--;
        v[ch].push_back(make_pair(st,en));
    }
    int imos[100100]={};
    rep(i,c){
        sort(ALL(v[i]));
        rep(j,v[i].size()){
            //v[i][j].firstとv[i][j-1].secondが一緒の時
            //v[i][j-1].secondの退店とv[i][j]の入店を取り消す
            imos[v[i][j].first]++;
            imos[v[i][j].second+1]--;
            if(j!=0&&(v[i][j].first==v[i][j-1].second)){
                imos[v[i][j].first]--;
                imos[v[i][j-1].second+1]++;
            }
        }
    }
    //simulate
    int ans=1;
    for(int i=1;i<100099;i++){
        imos[i]+=imos[i-1];
    }
    for(int i=0;i<100099;i++){
        ans=max(imos[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int a, b, c, x, res = 0, i, j, k, total;
  cin >> a >> b >> c >> x;
  for(i = 0; i <= a; i++){
    for(j = 0;j <= b; j++){
      for(k = 0; k <= c; k++){
        total = 500 * i + 100 * j + 50 * k;
        if(total == x) res++;
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	int x,a,b,bedaA=0,bedaB=0;
	scanf("%d %d %d", &x, &a, &b);
	 if (x>=a && x>=b){
	 	bedaA=x-a;
	 	bedaB=x-b;
	 }
	 else if(x>=a && x<=b){
	 	bedaA=x-a;
	 	bedaB=b-x;
	 }
	 else if(x<=a && x>=b){
	 	bedaA=a-x;
	 	bedaB=x-b;
	 }
	 else if(x<=a && x<=b){
	 	bedaA=a-x;
	 	bedaB=b-x;
	 }
	if(bedaA>bedaB){
		printf("B");
	}
	else{
		printf("A");
	}
	
	
	return 0;
}

Measured memory_bytes: 1620
K, N = map(int, input().split())
lis = list(map(int, input().split()))
dis=[]
lis.append(lis[0])
for i in range(N):
  if lis[i+1] > lis[i]:
    dis.append(lis[i+1]-lis[i])
  else:
    dis.append((K - lis[i]) + lis[i+1])
print(sum(dis)-max(dis))

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

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;

	string flag = "Yes";
	// right, upper, left, under
	if (w < (x + r) || h < (y + r) || 0 > (x - r) || 0 > (y - r)) {
		flag = "No";
	}
	cout << flag << "\n";
	return 0;
}

Measured memory_bytes: 1184
c = str(input())
max_count = 0
count = 0

for i in c:
	if i == 'A':
		count += 1
	elif i == 'T':
		count += 1
	elif i == 'C':
		count += 1
	elif i == 'G':
		count += 1
	else:
		if count > max_count:
			max_count = count
		count = 0

if count > max_count:
			max_count = count

print(max_count)


Measured memory_bytes: 38384
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    vector<vector<ll> > v(26) ; 
    string s , t ;
    cin >> s >> t ;
    ll n = (ll) s.size() ; 
    ll m = (ll) t.size() ; 
    for(ll i=0;i<n;i++){
    	v[s[i]-'a'].push_back(i) ; 
    }
    for(ll i=0;i<26;i++){
    	sort(v[i].begin(),v[i].end()) ; 
    }
    debug() << imie(v) ; 
    ll ans = 0 ; 
    ll cur = -1 ; 
    for(ll i=0;i<m;i++){
    	ll c = t[i] - 'a';
    	ll index = upper_bound(v[c].begin(),v[c].end(),cur) - v[c].begin() ; 
    	ll sz = v[c].size() ; 
    	debug() << imie(c) imie(index) imie(sz) ; 
    	if ( index == sz ){
    		ans += n - (cur+1) ; 
    		cur = -1 ;
    		index = upper_bound(v[c].begin(),v[c].end(),cur) - v[c].begin() ; 
    		if ( index == sz ){
    			return cout << -1 << endl , 0 ; 
    		}
    		ans += v[c][index]+1 ;
    		cur = v[c][index] ; 
    		continue ;
    	}

    	ans += v[c][index] - cur ;
    	cur = v[c][index] ;
    }
    cout << ans << endl;
    return 0 ;
}


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

vector<ll> lun;

void dfs(ll num)
{
  if (num > 3234566667) return;

  lun.emplace_back(num);

  ll d = num % 10;
  if (d > 0) dfs(num * 10 + d-1);
  dfs(num * 10 + d);
  if (d < 9) dfs(num * 10 + d+1);
}

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

  int n;
  cin >> n;

  for (int i = 1; i <= 9; ++i) dfs(i);
  sort(lun.begin(), lun.end());

  cout << lun[n-1] << '\n';

  return (0);
}


Measured memory_bytes: 4268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public void Run()
        {
            int ret = 0;
            N = Input.ReadInt();
            for (int n = 1; n <= N; n++)
            {
                int c = 0;
                for (int i = 1; i <= n; i++)
                    if (n % i == 0)
                        c++;
                if (c == 8 && n % 2 == 1) ret++;
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

const ll INF = 9223372036854775807;
const int inf = 2147483647;

/*********************************************/
/*
 考察
 前処理１
 (xi,yi)がw<=>(xi+k,yi)がb
 (xi,yi)がw<=>(xi  ,yi-2k)がw
 を用いて、
 2k*2k内に全て黒の状態で移動する
 前処理２
 ２次元累積和を作る
 矩形内の黒の数をO(1)で返せるようにする
 計算
 任意のチェック柄は、2k*2k内の任意の点を角にとる
 →全部で、０(N+K^2)
*/
/*********************************************/

int n,k;
ll x[100010];
ll y[100010];
char c[100010];
int a[2010][2010]={0};
int s[2010][2010]={0};

int rect(int x1,int y1,int x2,int y2){
    int rtn;
    rtn = s[y2][x2]-s[y1][x2]-s[y2][x1]+s[y1][x1];
    return rtn;
}
int check(int j,int i){
    int rtn=0;
    rtn += rect(0,0,j,i);
    rtn += rect(j,i,j+k,i+k);
    rtn += rect(0,i+k,j,2*k);
    rtn += rect(j+k,0,2*k,i);
    rtn += rect(j+k,i+k,2*k,2*k);
    return rtn;
}

int main() {
    cin >> n >> k;
    REP(i,n){
        cin >> x[i] >> y[i] >> c[i];
    }
    REP(i,n){
        if(c[i]=='B'){
            x[i] = x[i]%(2*k);
            y[i] = y[i]%(2*k);
            a[y[i]][x[i]]++;
        }else{
            x[i] += k;
            x[i] = x[i]%(2*k);
            y[i] = y[i]%(2*k);
            a[y[i]][x[i]]++;
        }
    }
    REP(i,2*k){
        REP(j,2*k){
            s[i+1][j+1] = s[i+1][j]+s[i][j+1]-s[i][j]+a[i][j];
        }
    }
    int res=0;
    REP(i,k){
        REP(j,k){
            res = max(res,check(i,j));
            res = max(res,n-check(i,j));
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 33408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define _USE_MATH_DEFINES
#include <cmath>

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

using namespace std;
typedef long long ll;

int main() {
   int A, B;
   int c, d, e;
   int ans;

   cin >> A >> B;
   c = A + B;
   d = A - B;
   e = A * B;
   ans = max(c, d);
   ans = max(ans, e);
   cout << ans << endl;
   return(0);
}


Measured memory_bytes: 256
import sys

def solve():
  while(1):
    n = int(raw_input())
    if n == 0:
      break
    score_a, score_b = 0, 0
    while(n > 0):
      a, b = map(int, raw_input().split())
      if a > b:
        score_a += a + b
      elif b > a:
        score_b += a + b
      else:
        score_a += a
        score_b += b
      n -= 1
    print score_a, score_b

if __name__ == '__main__':
  solve()

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<en;
    else cout<<"ABC"<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3644
using System;
using System.Linq;

namespace ConsoleApplication1
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var n = line[0];
			var m = line[1];

			var counter = new int[m];
			for (var i = 0; i < n; i++)
			{
				line = Console.ReadLine().Split().Select(int.Parse).ToArray();
				var upper = line.Length;
				for (var j = 1; j < upper; j++) { counter[line[j] - 1]++; }
			}

			Console.WriteLine(counter.Count(c => c == n));
		}
	}
}

Measured memory_bytes: 13396
dame=['AAGC', 'AACG', 'AGAC', 'AGAC', 'AGGC',
      'AGGC', 'AGTC', 'ATGC', 'GAGC', 'GGAC',
      'CAGC', 'CACG', 'CGAC', 'TAGC', 'TACG', 'TGAC']
memo={"TTT":1}

n=int(input())
for i in range(n):
    nmemo={}
    for c in ["A","G","C","T"]:
        for mk,mv in memo.items():
            nk=mk+c
            if nk not in dame:
                nk=nk[1:]
                if nk in nmemo:
                    nmemo[nk]+=mv
                else:
                    nmemo[nk]=mv
    memo=nmemo
print(sum(memo.values())%(10**9+7))

Measured memory_bytes: 3064
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2020-05-02 20:50:01
 * @LastEditTime: 2020-05-02 20:52:34
 * @FilePath: \VSC\C++\Practice\AC abc165 B.cpp
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long

int x;
signed main(){
    scanf("%lld",&x);
    
    int st=100;
    register int i;

    for(i=1;;++i){
        st+=st/100;
        if(st>=x){printf("%lld\n",i);return 0;}
    }
}

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

using namespace std;

#define lli long long 
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000000007

int main(){
        double n,m,x;
        cin >> n >> m >> x;
        if(n*n*m/2<=x)printf("%7lf",atan((m-x/n/n)*2/n)/M_PI*180);
        else printf("%7lf",atan(m/(2*x/m/n))/M_PI*180);
}


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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

typedef long long ll;

const ll MOD = 1e9 + 7;

class C {
public:
    void solve(std::istream& in, std::ostream& out) {
        string S;
        in >> S;
        ll sum = 0;
        rep(i,0,1LL << (S.size()-1)) {
            vector<int> oneIndices;
            rep(j,1,S.size()) {
                if (i & (1LL << (S.size()-j-1))) oneIndices.emplace_back(j);
            }
            int prevIndex = 0;
            for (const auto & index : oneIndices) {
                sum += stoll(S.substr(prevIndex,index-prevIndex));
                prevIndex = index;
            }
            sum += stoll(S.substr(prevIndex,S.size()-prevIndex));
        }
        out << sum << endl;
    }
};


signed main() {
    C solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n,k;
	scanf("%d %d", &n, &k);
	int more = 1;
	while (more < k && n > 0){
		more *= 2;
		n--;
	}
	for(int i = 0; i < n; i++){
		more += k;
	}
	printf("%d\n", more);
	return 0;
}


Measured memory_bytes: 1700
#include <iostream>
#include <string>
#include <cctype>

int main()
{
    std::string line;
    getline(std::cin, line);

    for (auto i = 0; i < line.size(); i++) {
        if ('a' <= line.at(i) && line.at(i) <= 'z') {
            line.at(i) = toupper(line.at(i));
        }
    }

    std::cout << line << std::endl;

    return 0;
}

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

int n;
ll p = 1e9 + 7,a[MAXN],sum[MAXN],ans = 0;

int main(){
	
	cin>>n;
	for(int i = 1 ; i <= n ; i++)cin>>a[i];
	for(int i = n ; i >= 1 ; i--)sum[i] = (sum[i + 1] + a[i]) % p;
	for(int i = 1 ; i <= n ; i++){
		ans = (ans + a[i] * sum[i + 1]) % p;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6756
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using namespace std;


int N;
int a[10010];


int solve(){
	int cnt = 0;
	rep(i, 0, N){
		while(a[i]%2 == 0) a[i] /= 2, cnt++;
	}
	return cnt;
}


int main(){
	cin >> N;
	rep(i, 0, N) cin >> a[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
def f(res):
    ans = 0
    # print(res)
    for i in range(n - 1):
        ans += abs(res[i] - res[i + 1])
    return ans
n = int(input())
l = sorted([int(input()) for _ in range(n)])
r = [[l[i], l[n - 1 - i]] for i in range(n//2)]
if n & 1:
    r += [[l[n//2]]]

res1, res2 = [], []

for p in r:
    res1 += p[::-1]
for p in r:
    res2 += p
res1 = [res1[-1]] + res1[:-1]
res2 = [res2[-1]] + res2[:-1]
ans = max(f(res1), f(res2))

print(ans)

Measured memory_bytes: 15428
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int w = scan.nextInt();

        while (w > -1) {
            int a = 1150;
            int b = 4280;
            
            if (w > 30) {
                a += 160 * (w - 30);
                w = 30;
            }
            
            if (w > 20) {
                a += 140 * (w - 20);
                w = 20;
            }
            
            if (w > 10) {
                a += 125 * (w - 10);
                w = 10;
            }
            
            System.out.println(b - a);
             w = scan.nextInt();
        }
    }
}



Measured memory_bytes: 26272
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define MAX_N 100010
bool x[MAX_N];
ll num[MAX_N];

ll fibl[MAX_N]={0};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

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

int main(){
    string a[3]={"Sunny","Cloudy","Rainy"};
    string x;
    cin >> x;
    if (x==a[0]){
        cout << a[1] << endl;
    }else if (x==a[1]){
        cout << a[2] << endl;
    }else{
        cout << a[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)
	x, max := 0, 0
	for i := 0; i < n; i++ {
		if s[i] == 'I' {
			x++
			if x > max {
				max = x
			}
		} else {
			x--
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  ll N,K,ans=0;
  cin>>N>>K;
  
  while(N>0){
    N/=K;
    ans++;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256