akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60];
           signed main(){
        
           string s;
           	cin>>s;
           	
           	for(int i=0;i<s.length();i+=2) cout<<s[i];
           	cout<<endl;
           	
           	return 0;
           	
           	
           }
             

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

#define ll long long
#define print(r) cout << r << endl
#define prints(r) cout << r << " "
#define printline cout << endl

vector<ll> desc(2e5, 1);
vector<vector<ll>> tree(2e5);
vector<ll> visited(2e5, 0);

ll dfs(ll n)
{
    if (visited[n])
        return 0;
    visited[n] = 1;
    ll nc = 1;
    for (ll i = 0; i < (ll)tree[n].size(); i++)
        nc += dfs(tree[n][i]);
    return nc;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    for (ll i = 0; i < m; i++)
    {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    for (ll i = 0; i < 2e5; i++)
        desc[i] = max(desc[i], dfs(i));

    // for (ll i = 0; i < n; i++)
    // {
    //     prints(desc[i]);
    // }
    

    sort(desc.begin(), desc.end());
    ll ans = 0;
    for (ll i = 1; i < 2e5; i++)
    {
        ans += desc[i] - desc[i - 1];
    }
    print(ans+1);

    return 0;
}

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

int  main(){
int n;
int num=0;
cin >>n;
int i=0;
  while(true){
    if(i>=n ||i==10000)break;
    i=i+1000;
  }
 num=i-n;
cout <<num <<endl; 
return 0;
}

Measured memory_bytes: 3636
S = input()
count101 = 0
count010 = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "1":
            count010 += 1
        else:
            count101 += 1
    else:
        if S[i] == "0":
            count010 += 1
        else:
            count101 += 1
print(min(count010,count101))

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<string>
using namespace std;

int main(void) {
	long long int n, m;
	cin >> n >> m;
	long long int count = 0;

	vector<long long int> l(m);
	vector<long long int> r(m);
	vector<int> d(n+2,0);
	int i;
	for (i = 0; i < m; i++)
	{
		cin >> l[i] >> r[i];
	}

	for (i = 0; i < m; i++)
	{
		d[l[i]]++;
		d[r[i] + 1]--;
	}


	for (i = 1; i < n + 1; i++)
	{
		d[i] += d[i - 1];
	}

	for (i = 0; i < n + 1; i++)
	{
		if (d[i] >= m)
		{
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

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

int main(){
    string ans = "Yes";
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i = 0;i < n;i ++){
        int a;
        cin >> a;
        if(n%3 && a) ans = "No";
        mp[a] ++;
    }
    if((n%3)==0){
        int x;
        if(!(mp.size()==2 && mp[0]==n/3)){
            for(auto ite = mp.begin();ite != mp.end();++ite){
                if(ite->second!=n/3) ans = "No";
                if(ite==mp.begin()) x = ite->first;
                else x = x^ite->first;
            }
            if(x) ans = "No";
        }
        if(mp[0]==n) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3840
#include<stdio.h>

int main(void){
int N,K,c,i;
scanf("%d %d",&N,&K);
c=0;
i=1;
do{
 c++;
 if(c>=K){break;}
 i+=2;
}while(i<=N);
if(c>=K){printf("YES\n");}else{printf("NO\n");}
return 0;
}


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

#define N 200010
#define MAX 1000000000000000000

int main (void)
{
    int n, x, t;

    scanf("%d %d %d", &n, &x, &t);

    printf("%d", ((n+x-1)/x)*t);

    return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

const int mod=1e9+7;
vector<int> prime;
bool check[1000];
int cnt[200];
int main(){
	for(int i=2;i<1000;i++){
		if(check[i]==false){
			prime.push_back(i);
			for(int j=i*2;j<1000;j+=i)	check[j]=true;
		}
	}
	//1000以下のprimeの個数は168
	int n;	cin>>n;
	for(int i=n;i>1;i--){
		int k=i;
		for(int j=0;j<prime.size();j++){
			if(k==1)	break;
			while(k%prime[j]==0){
				cnt[j]++;
				k/=prime[j];
			}
		}
	}
	ll ret=1;
	for(int i=0;i<prime.size();i++)	ret=(ret*(cnt[i]+1))%mod;
	cout<<ret<<endl;
	return 0;
}


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

const int N = 101;
const int MAX = 1e5;

int n, sum;
int w[N], v[N];
int64_t dp[MAX + 1];

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

    std::cin >> n >> sum; 
    
    for (int i = 1; i <= n; i++) {
        std::cin >> w[i] >> v[i];
    }

    for (int i = 1; i <= n; i++) {
        for (int j = sum; j >= w[i]; j--) {
            dp[j] = std::max(dp[j], dp[j - w[i]] + v[i]);
        }
    }

    std::cout << dp[sum];

    return 0;
}



Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  double sum=0;
  for(int i=0;i<N;i++){
    double tmp;
    cin>>tmp;
    sum+=1/tmp;
  }
  cout<<fixed<<setprecision(10)<<1/sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    string s;
    cin >> s;
    int n = s.length();
    int apos, zpos;
    repeat(i, n) {
        if (s[i] == 'A') {
            apos = i;
            break;
        }
    }
    repeat(i, n) {
        if (s[n-i] == 'Z') {
            zpos = n-i;
            break;
        }
    }
    cout << zpos - apos + 1 << endl;
    return 0;
}

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

using namespace std;

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

  if(s == "AAA") cout << "No";
  else if(s[0]=='A' || s[1]=='A' || s[2]=='A') cout << "Yes";
  else cout << "No";
  cout << endl;
  
  return 0;
}


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

int main() {
    int n, y;
    cin >> n >> y;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int sum = 10000 * i + 5000 * j + 1000 * (n - i - j);
            if (y == sum && i + j <= n) {
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
  ll n;
  cin >> n;
  ll x = 100;
  ll ans = 0;
  while(x<n){
    x = x * 1.01;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdint>
#include <string>
#include <set>

int main()
{
	std::ios_base::sync_with_stdio(false);
	
	uint32_t N = 0, L = 0;
	std::cin >> N >> L;

	std::string temp;
	std::multiset<std::string> str_set;
	for(uint32_t i = 0; i < N; i++)
	{
		std::cin >> temp;
		str_set.insert(temp);
	}

	for(auto str : str_set) { std::cout << str; }
	std::cout << "\n";

	return 0;
}


Measured memory_bytes: 256
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  int sum = 0;
  rep(i, m) {
    int x; cin >> x;
    sum += x;
  }
  int ans = (sum > n ? -1 : n-sum);
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v) v.begin(),v.end()
#define endl            "\n"


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
  return (a >= b ? a : b);
}


lli minm(lli a, lli b)
{
  return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
  lli res = 1;

  x = x % p;
  if (x == 0)
    return 0;

  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;


    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

lli nCrmodp(lli n, lli r, lli p)
{
  if (r == 0)
    return 1;
  if (r == 1)
    return n;


  lli pro = 1, k = n;
  while (k > r)
  {
    pro *= k;
    pro %= p;
    --k;
  }

  k = 2;
  while (k <= (n - r))
  {
    pro *= power(k, (p - 2), p);
    pro %= p;
    ++k;
  }

  return pro;
}


string num_str(lli n, lli k)
{
  string str = "";
  lli x = n;
  while (x != 0)
  {
    string s = to_string(x % k);
    str = s + str;
    x /= k;
  }

  return str;
}

void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif*/
}

int main()
{
  c_p_c();

  int n;
  cin >> n;
  int arr[n], minH[n];

  for (int j = 0; j < n; ++j)
    cin >> arr[j];

  minH[n - 1] = 0;
  minH[n - 2] = abs(arr[n - 1] - arr[n - 2]);

  for (int j = (n - 3); j >= 0; --j)
  {
    int x, y;
    x = abs(arr[j] - arr[j + 1]) + minH[j + 1];
    y = abs(arr[j] - arr[j + 2]) + minH[j + 2];

    minH[j] = min(x, y);
  }

  cout << minH[0] << endl;
  return 0;
}

Measured memory_bytes: 4452
// https://atcoder.jp/contests/atc001/tasks/unionfind_a

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

bool visited[160010];

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll H,W;
    cin >> H >> W;
    UnionFind uf(H*W);

    char shapmap[H][W];

    FOR(i,0,H-1){
      string s; cin >> s;
      FOR(j,0,W-1){
        shapmap[i][j] = s[j];
      }
    }

    FOR(i,0,H-1){
      FOR(j,0,W-1){
        if(i==H-1){
          if(j!=W-1){
            if(shapmap[i][j]!=shapmap[i][j+1]) uf.merge(i*W+j, i*W+j+1);
          }
        } else if(j==W-1){
          if(shapmap[i][j]!=shapmap[i+1][j]) uf.merge(i*W+j, (i+1)*W+j);
        } else {
          if(shapmap[i][j]!=shapmap[i+1][j]) uf.merge(i*W+j, (i+1)*W+j);
          if(shapmap[i][j]!=shapmap[i][j+1]) uf.merge(i*W+j, i*W+j+1);
        }
      }
    }

    
    map<ll,ll> bombnum;

    FOR(i,0,H-1){
      FOR(j,0,W-1){
        if(shapmap[i][j]=='#') ++bombnum[uf.root(i*W+j)];
      }
    }
    ll ans = 0;
    FOR(i,0,H-1){
      FOR(j,0,W-1){
        if(!visited[uf.root(i*W+j)]){
          if(uf.size(i*W+j)>1){
            ans += bombnum[uf.root(i*W+j)] * (uf.size(i*W+j) - bombnum[uf.root(i*W+j)]);
          } 
          visited[uf.root(i*W+j)] = true;
        }
      }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 11392
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll a[maxn],b[maxn],c[maxn],d[maxn],pre[maxn],n,tot;

inline void add(int x,int val){for(int i=x;i<=maxn-4;i+=i&-i) c[i]+=val;}
inline ll q(int x){ll res=0; for(int i=x;i;i-=i&-i) res+=c[i]; return res;}

inline bool jud(ll x)
{
	ll tmp=0;
	for(int i=1;i<=n;i++) if(a[i]<x) b[i]=-1; else b[i]=1;
	for(int i=0;i<=maxn-4;i++) c[i]=0;
	for(int i=0;i<=n;i++) pre[i]=pre[i-1]+b[i],tmp+=q(pre[i]+1e5),add(pre[i]+1e5,1);
	if(tmp>=tot/2) return true; return false;
	
}

int main()
{
	n=read(); tot=n*(n+1)/2;
	for(int i=1;i<=n;i++) a[i]=read(),d[i]=a[i]; sort(d+1,d+n+1);
	int l=1,r=n,ans=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(jud(d[mid])) ans=d[mid],l=mid+1;
		else r=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int x[n];
  for(int i=0; i<n; i++) cin >> x[i];
  int ans=0;
  
  for(int i=0; i<n; i++){
    if(i==0) ans+=x[i];
    else{
      if(x[i]-x[i-1]>0) ans+=x[i]-x[i-1];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
S = [list(map(lambda x: int(x) if x != '.' else -1, input())) for i in range(H)]
dd = ((-1, 0), (-1, -1), (0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1))
que = []
D = [[0]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        v = S[i][j]
        if v == -1:
            continue
        x = sum(S[i+dy][j+dx] == -1 for dx, dy in dd)
        if v <= x:
            S[i][j] = 0
            que.append((i, j))
        else:
            S[i][j] -= x
ans = 0
while que:
    que2 = []
    for y, x in que:
        if S[y][x] == -1:
            continue
        S[y][x] = -1
        for dx, dy in dd:
            nx = x + dx; ny = y + dy
            if S[ny][nx] > 0:
                S[ny][nx] -= 1
                if not S[ny][nx]:
                    que2.append((ny, nx))
    que = que2
    ans += 1
print(ans)


Measured memory_bytes: 22340
#include<bits/stdc++.h>
using namespace std;
bool Is_same(vector<int> a, vector<int> b){
  bool rtn = true;
  for(int i = 0; i < a.size(); ++i){
    rtn = rtn && a[i] == b[i];
  }
  return rtn;
}

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  vector<int> q(N);
  vector<int> base(N);
  for(int i = 0; i < N; ++i) cin >> p[i];
  for(int i = 0; i < N; ++i) cin >> q[i];
  for(int i = 0; i < N; ++i) base[i] = i + 1; 
  int a, b;
  int index = 1;
  do {
    if(Is_same(p,base)) a = index; 
    if(Is_same(q,base)) b = index;
    ++index;
  } while(next_permutation(base.begin(), base.end()));
  cout << abs(a-b) << endl; 
}

Measured memory_bytes: 256
class WeightedUnionFindTree:
    """Disjoint-Set Data Structure with weight

    complexity:
        - init: O(n)
        - find, unite, same: O(alpha(n))
    """

    def __init__(self, n_nodes):
        self.par = [i for i in range(n_nodes)]  # parent
        self.rank = [0] * n_nodes  # depth of tree
        self.weights = [0] * n_nodes

    def find(self, x):
        if self.par[x] == x:
            return x
        root = self.find(self.par[x])
        self.weights[x] += self.weights[self.par[x]]
        self.par[x] = root
        return root

    def unite(self, x, y, weight=0):
        root_x, root_y = self.find(x), self.find(y)
        if root_x == root_y:
            return
        if self.rank[root_x] < self.rank[root_y]:
            self.par[root_x] = root_y
            self.weights[root_x] = weight - self.weights[x] + self.weights[y]
        else:
            self.par[root_y] = root_x
            self.weights[root_y] = -weight - self.weights[y] + self.weights[x]
            if self.rank[root_x] == self.rank[root_y]:
                self.rank[root_x] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weights[x] - self.weights[y]


N, M = map(int, input().split())
uft = WeightedUnionFindTree(N)

for _ in range(M):
    l, r, d = map(int, input().split())
    l, r = l-1, r-1
    if not uft.is_same(l, r):
        uft.unite(l, r, d)
    else:
        if uft.diff(l, r) != d:
            print("No")
            quit()
else:
    print("Yes")


Measured memory_bytes: 11524
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

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

int main(){
  int n,W;
    cin >> n >> W;
    vector<vector<int> > dp(n+1,vector<int> (W+1,0));
    vector<int> v(n),w(n);
    REP(i,n) cin >> v[i] >> w[i];

    REP(i,n){
        REP(j,W+1){
            if(j<w[i]) dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
        }
    }

    int max=0;
    REP(j,W+1){
        if(dp[n][j]>max) max=dp[n][j];
    }
    cout << max << endl;
  return 0;
}

Measured memory_bytes: 4956
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class T> int arrCountVal(int N, T A[], T val){
  int i;
  int res = 0;
  for(i=(0);i<(N);i++){
    if(A[i]==val){
      res++;
    }
  }
  return res;
}
int N;
char S[30];
char t[30];
int main(){
  N = rd(S);
  if(N==26){
    int i;
    for(i=(0);i<(26);i++){
      t[i] = S[i];
    }
    if(!next_permutation(S,S+26)){
      wt_L(-1);
      wt_L('\n');
      return 0;
    }
    for(i=(0);i<(26);i++){
      if(S[i]!=t[i]){
        S[i+1] = '\0';
        break;
      }
    }
  }
  else{
    int i;
    for(i=(0);i<(26);i++){
      if(arrCountVal(N,S,(char)('a'+i))==0){
        break;
      }
    }
    S[N++] = 'a' + i;
    S[N] = '\0';
  }
  wt_L(S);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// int N; char S[30], t[30];
// {
//   rd(S@N);
//   if(N==26){
//     rep(i,26) t[i] = S[i];
//     if(!next_permutation(S,S+26)) wt(-1), return 0;
//     rep(i,26) if(S[i]!=t[i]) S[i+1] = '\0', break;
//   } else {
//     rep(i,26) if(arrCountVal(N,S,(char)('a'+i))==0) break;
//     S[N++] = 'a' + i;
//     S[N] = '\0';
//   }
//   wt(S);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,i,a;
    set<int>st;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        st.insert(a);
    }
    if(st.size()==n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;

int main(){
	
	ll a,b,n;
	cin >> a >> b >> n;
	
	cout << a*min(b-1,n)/b << endl;
	
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    int n,k;
    cin >> n >> k;
    vint p(n);
    cin>>p;
    sort(p.begin(),p.end());
    ll ans = 0;
    REP(i, k) { ans += p[i]; }
    cout << ans << endl;
}

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

using namespace std;
// using namespace atcoder;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}

const int mod = 1000000007;
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
void printVec(std::vector<char> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}


int main() {
    ll a,b;
    cin >> a >> b;
    int k;
    cin >> k;
    rep(i,a,b+1) {
        if (i >=a && i <a +k) {
            cout << i <<endl;
            continue;
        }
        if (i >= b-k+1 && i < b+1) {
            cout << i <<endl;
            continue;
        }
    }
    // rep(i,a,a+k) {
    //     cout << i << endl;
    // }
    // rep(i,b-k+1,b+1) {
    //     cout << i << endl;
    // }
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {

            int n = s2i(Console.ReadLine());
            List<String> s = new List<string>();

            int c = 0;
            for (int i = 0; i < n; i++)
            {
                String ss = Console.ReadLine();
                    s.Add(ss);
            }

            RESULT((from x in s
                              select x).Distinct().Count());


        }
        static int GetIndex(IList<String> list, String value)
        {
            for (int index = 0; index < list.Count; index++)
            {
                if (list[index] == value)
                {
                    return index;
                }
            }
            return -1;
        }








        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static long s2l(String s)
        {
            return Convert.ToInt64(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 47936
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <vector>
#include <limits>

using namespace std;
using myui = uint64_t;
using myint = int64_t;

template<typename T>
T diff(const T& a, const T& b) {
    return a > b ? a - b : b - a;
}

myui impl(myui n, const vector<myui>& h, myui k, vector<myint>& costs) {
    if (costs[n-1] == -1) {
        myui min_cost = numeric_limits<myui>::max();
        for(myui i = 1; i <= k && i <= n - 1; i++) {
            const myui cost = static_cast<myui>(diff(h[n-1], h[n-i-1])) + impl(n-i, h, k, costs);
            if(cost < min_cost) min_cost = cost;
        }
        costs[n-1] = static_cast<myint>(min_cost);
    }
    return static_cast<myui>(costs[n-1]);
}

myui solve(myui n, const vector<myui>& h, myui k) {
    vector<myint> costs(n, -1);
    costs[0] = 0;
    return impl(n, h, k, costs);
}

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

    {
        myui n, k;
        cin >> n >> k;

        vector<myui> h(n, 0);
        for(myui i = 0; i < n; i++) {
            myui tmp;
            cin >> tmp;
            h[i] = tmp;
        }

        cout << solve(n, h, k) << endl;
    }

    return 0;
}


Measured memory_bytes: 11264
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N,M;
	cin >> N>>M;
	if (N >= M) {
		cout << 0 << endl;
		return;
	}

	vector<int> X(M);
	for (int i = 0; i < M; ++i) {
		cin >> X[i];
	}
	sort(X.begin(), X.end());
	vector<LL> sa(M - 1);
	for (int i = 0; i < M - 1; ++i) {
		sa[i] = X[i + 1] - X[i];
	}
	sort(sa.begin(), sa.end());
	reverse(sa.begin(), sa.end());
	LL add = 0;
	for (int i = 0; i < N - 1; ++i) {
		add += sa[i];
	}
	LL sum = X[M - 1] - X[0];
	LL ans = sum - add;
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>

int main(){
	char A[11],B[11],C[11];
	scanf("%s %s %s", &A,&B,&C);
	int lenA=strlen(A);
	int lenB=strlen(B);
	
	if(A[lenA-1]==B[0] && B[lenB-1] == C[0]){
		printf("YES");
	}
	else {
		printf("NO");
	}
	
	return 0;
}

Measured memory_bytes: 1716
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String pre = s.substring(0, 1);
		for(int i = 1; i < 4; i++) {
			if(s.substring(i, i + 1).equals(pre)) {
				System.out.println("Bad");
				return;
			} else {
				pre = s.substring(i, i + 1);
			}
		}
		System.out.println("Good");
	}
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Run(Console.In);
        }

        private static void Run(TextReader textReader)
        {
            // 奇数文字目がすべて R, U, D のいずれか。
            // 偶数文字目がすべて L, U, D のいずれか。

            var odd = new HashSet<char>();
            odd.UnionWith(new char[] { 'R', 'U', 'D' });
            var even = new HashSet<char>();
            even.UnionWith(new char[] { 'L', 'U', 'D' });

            var items = textReader.ReadLine().ToArray();

            for (int i = 0; i < items.Length; i++)
            {
                // odd
                if ((i + 1) % 2 == 1)
                {
                    if (odd.Contains(items[i]))
                    {
                        continue;
                    }
                }
                // even
                else
                {
                    if (even.Contains(items[i]))
                    {
                        continue;
                    }
                }

                Console.Out.WriteLine("No");
                return;
            }

            Console.Out.WriteLine("Yes");
            return;
        }
    }
}


Measured memory_bytes: 13280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,c,k; cin >> a >>  b >> c >> k;
    int res=min(a,k);
    k-=min(a,k);
    k-=min(b,k);
    res-=min(c,k);
    printf("%d\n",res);
}

Measured memory_bytes: 3772
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;
const int N_MAX=1e5*2+1;

signed main(){
  int n;
  cin>>n;
  vector<double> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  vector<vector<double> > dp(n+1,vector<double>(N_MAX,1e9));

  for(int i=1;i<N_MAX;i++){
    dp[0][i]=abs(a[0]-i)/a[0];
  }

  for(int i=1;i<n;i++){
    for(int j=1;j<N_MAX;j++){
      for(int k=j;k<N_MAX;k+=j){
        dp[i][k]=min(dp[i][k],max(dp[i-1][j],(abs(a[i]-k)/a[i])));
      }
    }
  }

  double ans=1e9;
  for(int i=1;i<N_MAX;i++){
    ans=min(ans,dp[n-1][i]);
  }
  cout<<fixed<<setprecision(20)<<ans<<endl;
}



Measured memory_bytes: 37284
#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(){
 ll n;
 cin >>n;
 
  string ans;
  while(n){
   n--;
   ans += 'a'+n%26;
   n/=26;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100+2;
int n,ans=0;
int a[maxn<<1];
int main(){
	scanf("%d",&n);
	n<<=1;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i+=2) ans+=a[i];
	printf("%d",ans);
	return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int N;
	cin >> N;

	Vi L(N);
	for (int i = 0; i < N; ++i) {
		cin >> L[i];
	}

	sort(L.begin(), L.end());

	int ans = 0;
	for (int i = 1; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			int b = L[i], c = L[j];

			int num = upper_bound(L.begin(), L.end(), c - b) - L.begin();

			ans += max(i - num, 0);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  double a, b;
  cin>>a>>b;
  map<int,int> x, y;
  for(double i = 0; i < 1500; ++i){
    if((int)(i * 0.08) == a && (int)(i * 0.1) == b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(k+1,0));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        ll tmpsum = 0;
        for(int j = 0; j <= k; j++){
            tmpsum += dp[i-1][j];
            tmpsum %= MOD;
            if(j-a[i-1]-1>=0){
                tmpsum += MOD;
                tmpsum -= dp[i-1][j-a[i-1]-1];
                tmpsum %= MOD;
            }
            dp[i][j] = tmpsum;
            dp[i][j] %= MOD;
        }
    }

    cout << dp[n][k]%MOD << endl;
    return 0;
}


Measured memory_bytes: 80256
import java.util.Scanner;
public class Main {

			public static void main(String[]args) {
			
				Scanner sc = new Scanner(System.in);
				int N = sc.nextInt();
				String A = sc.next();
				char achar[] =A.toCharArray();
				String B = sc.next();
				char bchar[] = B.toCharArray();
				String C = sc.next();
				char cchar[] = C.toCharArray();
				
				int counter = 0;
				for (int i = 0; i<N; i++) {
					if(achar[i] == bchar[i]&&bchar[i] ==cchar[i])  //3文字同じ
						continue;
					else if(achar[i] ==bchar[i]||achar[i] == cchar[i]||bchar[i] == cchar[i]) //2文字ごとおなじ
						counter++;
					else
						counter += 2;
				}
				
				System.out.println(counter);
			}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<string>> CARDS(2);
  //initialize
  for(int i=0;i<2;i++){
    int num;
    cin >> num;
    vector<string> vec(num);
    CARDS.at(i)=vec;
    
    for(int j=0;j<num;j++){
      string in;
      cin>>in;
      CARDS.at(i).at(j)=in;
    }
  }
  int maxStrategy=0;
  string maxCard="";//for debug
  for(int i=0;i<CARDS.at(0).size();i++){
    int howMany=0;
    string thisCard=CARDS.at(0).at(i);
    for(int j=0;j<CARDS.at(0).size();j++){
      if(CARDS.at(0).at(j)==thisCard){
        howMany++;
      }
    }
    for(int k=0;k<CARDS.at(1).size();k++){
      if(CARDS.at(1).at(k)==thisCard){
        howMany--;
      }
    }
    if(howMany>maxStrategy){
      maxStrategy=howMany;
      maxCard=thisCard;
    }
  }
  //cout << maxCard<<":"<<maxStrategy<<endl;
  cout << maxStrategy<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static Scanner in;

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

		int d = in.nextInt();
		int t = in.nextInt();
		int s = in.nextInt();
		
		int dist = s*t;
		
		System.out.println(dist>=d?"Yes":"No");
		
	}

}


Measured memory_bytes: 35620
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
using namespace std;
int main(){
    int n, W;
    cin >> n >> W;
    vector<long long> dp(W + 1, 0);
    // dp[i] is max total value we can fill with weight exactly i
    dp[0] = 0;
    for(int i = 0; i < n; i++){
    	long long wt, val;
    	cin >> wt >> val;
    	for(int wt_j = W; wt_j >= wt; wt_j--){
    		dp[wt_j] = max(dp[wt_j], dp[wt_j - wt] + val);
    	}
    }
    long long ans = 0;
    for(int w = 0; w <= W; w++){
    	ans = max(ans, dp[w]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nm = br.readLine().split(" ");
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);
        boolean[] covered = new boolean[n+1];
        Interval[] abs = new Interval[m];
        
        for (int i = 0; i < m; i++) {
            String[] s = br.readLine().split(" ");
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);
            Interval intr = new Interval(a, b);
            abs[i] = intr;
        }
        
        Arrays.sort(abs, new IntervalComparator());
        
        int count = 0;
        for (Interval ab : abs) {
            if (!covered[ab.a]) {
                count++;
                for (int i = 0; i < ab.b; i++) {
                    covered[i] = true;
                }
            }
        }
        
        System.out.println(count);
    }
}

class Interval {
    int a;
    int b;
    public Interval(int a, int b) {
        this.a = a;
        this.b = b;
    }
}

class IntervalComparator implements Comparator<Interval>{
	public int compare(Interval intr1, Interval intr2) {
		return intr1.b - intr2.b;
	}
}


Measured memory_bytes: 47840
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <tuple>
#include <utility>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)

ll ans = 0;

void calc(string s, ll value)
{
    ll sz = s.size();
    if (sz == 1) {
        ans += value + stoll(s);
        return;
    }
    ll ret = 0;
    // 切断しない場合
    ans += value + stoll(s);

    // i 文字を左側にする
    for2(i, 1, sz) {
        calc(s.substr(i), value + stoll(s.substr(0,i)));
    }
}

void solve()
{
    string S;
    cin >> S;
    calc(S, 0);
    cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException{
		String str = new BufferedReader(new InputStreamReader(System.in)).readLine();
		int[] input = Arrays.stream(str.split(" ")).mapToInt(Integer::parseInt).toArray();
		System.out.println((int)((input[1]+input[1]/100)* Math.pow(100, input[0])));
	}

}

Measured memory_bytes: 28500
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d;
  string s,ss,sss;
  long long ans = 0;
  string anss = "";
  
  cin >> s >> ss >> sss;

  if(s[s.size()-1] == ss[0] && ss[ss.size()-1] == sss[0]) anss = "YES";
  else anss = "NO";
  
  cout << anss << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextIntArray(N);

        System.out.println(solve());
    }

    static int solve() {
        int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += A[i];
        }
        double avg = (double)sum / N;
        double[] D = new double[N];
        for (int i = 0; i < N; i++) {
            D[i] = Math.abs(avg-A[i]);
        }
        double min = Double.MAX_VALUE;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if( D[i] < min ) {
                ans = i;
                min = D[i];
            }
        }
        return ans;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

bool solve( int a, int n )
{
    int sum = 0;
    for( int i = a; sum < n; i++ )
        sum += i;
    if( sum == n )
        return true;
    else
        return false;
}

int main()
{
    int n;

    while( cin >> n )
    {
        if( !n )
            break;

        int sum = 0;

        for( int i = 1; i < n; i++ )
            sum += solve( i, n );

        cout << sum << endl;
    }

    return 0;
}


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

#define jk(i,j,k) for (int i = (j); i <= (k); i++)
#define kj(i,j,k) for (int i = (j); i >= (k); i--)
#define int long long
#define lb long double
#define ul unsigned long long
#define mp std::make_pair
#define pb push_back
#define pr(a,b) printf(a, b)
#define sc(a,b) scanf(a, &b)
#define x first
#define y second
#define al(x) (x).begin(), (x).end()
#define me(a) memset((a), 0, sizeof(a))

inline int rd() { int data = 0, w = 1; char ch = 0; while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar(); (ch == '-') && ( w = -1, ch = getchar() ); while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); } return data * w; }
inline void P (int v) { if (v < 0) { putchar('-'); v = -v; } if (v > 9) P(v / 10); putchar(v % 10 + '0'); }

// 1 2 3 4 5 6 7 8

signed main () {
    int a = rd();
    if (a & 1) { P(0); return 0; }
    int d = a >> 1ll, r = 0;
    while (d) { r += d / 5; d /= 5; }
    P(r);
    return 0;
}

Measured memory_bytes: 256