akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

double eps = 1e-8;

int main() {
    int n; cin >> n;
    for (int x = 1; x <= 50000; x++) {
        double v = x * 1.08;
        v = int(v+eps);
        if (v == n) {cout << x << endl; return 0;}
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
	long long n,a,b;
	cin >> n >> a >> b;
	
	long long count = n / (a+b);
	long long ans = count * a;
	
	long long res = n - (count*(a+b));
	if(res > a){
		ans += a;
	}
	else if(res < a){
		ans += res;
	}
	
	cout << ans << endl;
	
	
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}

int main(){
  //input
  int point[210];
  rep(i,210)point[i]=0;//なぜかこの作業を行わなかったら後ろのdp[209]などで巨大な数が発生してしまいエラったので入れた。
  int n,m;
  cin>>n;
  vector<string>s(n);
  rep(i,n)cin>>s[i];
  cin>>m;
  vector<string>t(m);
  rep(i,m)cin>>t[i];
  //prepare
  vector<string>stock(0);
  stock.push_back(s[0]);
  int ct=1;

  //蟻本を完全に無視した解答
  //データの数が非常に少ないのでこれで通ると確信
  //入力データで出てきた文字データを（ダブらないように）ストックに入れる
  //次にストックに入れた文字データの添字に対しpointの添字が対応するが、
  //ｓに出てきた文字データがあれば対応するpointの場所を１増加させ、tに出てきたら1減少させる。
  //最後にpointの中から最大のものを選ぶ。ただし、それが0を下回っていたら0を出力する。

  

  
  Rep(i,1,n){
    ct=1;
    rep(j,stock.size()){
      if(stock[j]==s[i])ct=0;
    }
    if(ct==1)stock.push_back(s[i]);
  }
  rep(i,m){
    ct=1;
    rep(j,stock.size()){
      if(stock[j]==t[i])ct=0;}
    if(ct==1)stock.push_back(t[i]);
  }
  sort(stock.begin(),stock.end());

  rep(i,n){
    rep(j,stock.size()){if(stock[j]==s[i]){point[j]++;break;}
    }}
  rep(i,m){
    rep(j,stock.size()){if(stock[j]==t[i]){point[j]--;break;}
    }}
  int maxpoint=0;//0になる可能性があることに注意
  rep(i,201){maxpoint=max(maxpoint,point[i]);}
  cout<<maxpoint<<endl;

  

    
  return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

constexpr static int MAXN = 2e5;

int n;
vector <int> adj[MAXN];
bool vis[MAXN];
unordered_map <int, int> parity[MAXN];

int calc(int u, int v) {
    if (parity[u].count(v))
        return parity[u][v];
    if (adj[v].size() == 1)
        return parity[u][v] = 1;

    int cnt = 0;
    for (int w : adj[v])
        if (w != u && calc(v, w) == 1)
            cnt++;

    if (cnt >= 2) {
        cout << "First" << endl;
        exit(0);
    }
    return parity[u][v] = (cnt == 0 ? 1 : 2);
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < n; i++) {
        int cnt = 0;
        for (int j : adj[i])
            if (calc(i, j) == 1)
                cnt++;
        if (cnt >= 2 || cnt == 0) {
            cout << "First" << endl;
            return 0;
        }
    }
    cout << "Second" << endl;
}


Measured memory_bytes: 29824
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
ll n, a[maxn], s[maxn], b[maxn];
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for (int i = 0;i <= n;++i)
		cin >> a[i];
	s[n] = b[n] = a[n];
	for (int i = n-1;i >= 0;--i) {
		s[i] = (s[i+1]+1) / 2 + a[i];
		b[i] = b[i+1] + a[i];
	}
//	return 0;
	if (s[0] > 1) return cout << -1 << '\n', 0;
	ll res = a[n];
	ll lst = 0, lf = 0;
	for (int i = 0;i < n;++i) {
		if (i == 0) {
			lst = 1, ++res;
			continue;
		}
		lst = min(lst * 2, b[i]);
		res += lst;

		lst -= a[i];
	//	cout << min(lst*2, b[i]) << '\n';
	}
	//cout << '\n';
	cout << res << '\n';





}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  string s;
  cin >> s;
  int64 now = 0;
  int64 state = 1;
  int64 res = 0;
  REP(i, s.size()) {
    if (s[i] == 'R') {
      now = (now + 1) %4;
      state |= 1 << now;
      if (now == 0 && state == 15) res++;
    }  else {
      now = (now + 3) % 4;
    }
    if (now == 0) {
      state = 1;
    }
  }
  cout << res << endl;
}


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

#define ull unsigned long long 

int main(void){
    ull w, h;
    cin >> h >> w;
    ull ans = h*w;

    if(h==1 || w == 1){
        cout << 1;
        return 0;
    }

    if(ans&1)
        cout << (ans+1)/2;
    else
        cout << ans/2;

    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
long long modinv(long long a){
    long long b=MOD,u=1,v=0;
    while(b){
      long long t=a/b;
      a-=t*b;
      swap(a,b);
      u-=t*v;
      swap(u,v);
    }
    u%=MOD;
    if(u<0) u+=MOD;
    return u;
}
 
long long dev(long long a,long long b){
    return (a*modinv(b))%MOD;
}
 
long long comb(int x,int y){
  long long tmp=1;
    for(int i=0;i<y;i++){
        tmp=dev(tmp*(x-i)%MOD,i+1);
    }
  return tmp;
}
int main(){
    ll X,Y; cin>>X>>Y;
    if((X+Y)%3!=0) cout<<0;
    else if((X>2*Y)||(Y>X*2)) cout<<0;
    else{
        ll t=(X+Y)/3;
        ll B=(2*Y-X)/3;
        if((2*Y-X)%3!=0){
            cout<<0;
            return 0;
        }
        ll A=t-B;
        if(A<0){
            cout<<0;
            return 0;
        }
        cout<<comb(t,A);
    }
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int count = 0;
  string S;
  cin >> S;
  
  bool hasR = false;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'R') {
      count++;
      hasR = true;
    } else if (hasR) {
      break;
    }
  }
  cout << count << endl;
}

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

using namespace std;

typedef long long LL;
#define N 120000

const LL mod=998244353;
LL n,m,p,f[3][N],F[N],pw[N*18],sg[N];
bool vis[N];
vector<LL> g[N];

void upd(LL &x,LL y){x=(x+y)%mod;}

void solve(LL op){
	scanf("%lld",&m);
	for (LL i=1;i<=n;++i) g[i].clear();
	for (LL i=1;i<=m;++i){
		LL x,y; scanf("%lld%lld",&x,&y);
		if (x>y) swap(x,y);
		g[x].push_back(y);
	}
	for (LL i=n;i;--i){
		for (LL j:g[i]) vis[sg[j]]=1;
		for (sg[i]=0;vis[sg[i]];++sg[i]);
		upd(f[op][sg[i]],pw[i*18]);
		for (LL j:g[i]) vis[sg[j]]=0;
	}
}

int main(){
	scanf("%lld",&n);
	pw[0]=1; for (LL i=1;i<=n*18;++i) pw[i]=pw[i-1]*10%mod;
	solve(0); solve(1); solve(2);
	p=600;
	for (LL i=1;i<=2;++i){
		memset(F,0,sizeof F);
		for (LL j=0;j<=p;++j)
			for (LL k=0;k<=p;++k){
				upd(F[j^k],f[i][j]*f[i-1][k]);
			}
		for (LL j=0;j<=p;++j) f[i][j]=F[j];
	}
	printf("%lld\n",f[2][0]);
	
	return 0;
}
			

Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  	if(a%3==0 || b%3==0 || (a+b)%3==0)
    cout<<"Possible"<<endl;
  	else
    cout<<"Impossible"<<endl;
  
    
      
  return(0);
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
typedef long long ll;
const int N=105;
ll l,r;int nl[N],nr[N],f[N][2][2][2];
int dfs(int pos,int fl,int fr,int c){
	if(pos==-1)return c;if(~f[pos][fl][fr][c])return f[pos][fl][fr][c];
	int lx=(fl?nl[pos]:0),rx=(fr?nr[pos]:1),res=0;
	fp(y,0,rx)fp(x,lx,y){
		if(!c&&y==1){
			if(!x)continue;
			upd(res,dfs(pos-1,fl&&x==lx,fr&&y==rx,1));
		}else upd(res,dfs(pos-1,fl&&x==lx,fr&&y==rx,c));
	}
//	printf("%d %d %d %d %d\n",pos,fl,fr,c,res);
	return f[pos][fl][fr][c]=res;
}
int main(){
	memset(f,-1,sizeof(f));
	scanf("%lld%lld",&l,&r);
	fd(i,59,0)nl[i]=(l>>i&1);
	fd(i,59,0)nr[i]=(r>>i&1);
	printf("%d\n",dfs(59,1,1,0));
	return 0;
}

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

int main(){
    long long N, K, ans;
    cin >> N >> K;
    if(N - (N/K)*K > abs(N - (N/K+1)*K)) ans = abs(N - (N/K+1)*K);
    else ans = N - (N/K)*K;
    cout << ans << endl;
    return 0;
}

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

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 1000000;
	int len = s.size()-t.size();
	for(int i=0; i<=len; i++) {
		int cnt = 0;
		for(int j=0; j<t.size(); j++) {
			if(s[i+j] != t[j]) {
				cnt++;
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


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

  if(s.size() == 1){
    cout<<0<<endl;
    return 0;
  }

  LL bcount=0;
  LL ans=0;
  for(int i=0; i<s.size(); ++i ){
    if(s[i]=='B') ++bcount;
    else ans += bcount;
  }

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


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, input().split())
A = list(map(int, input().split()))

S = sum(A)
m = S / (4 * M)
cnt = 0
for a in A:
    if a < m:
        continue
    cnt += 1

if cnt >= M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import java.util.Scanner;

 public class Main{
	 public static void main(String[] args){
		 Scanner s = new Scanner(System.in);
		 while(s.hasNextDouble()){
			 double a= s.nextDouble();
			 double b= s.nextDouble();
			 double c= s.nextDouble();
			 double d= s.nextDouble();
			 double e= s.nextDouble();
			 double f= s.nextDouble();
			 double x=(c*e-b*f)/(a*e-b*d);
			 double y=(c*d-a*f)/(b*d-a*e);
			 if(x == 0)x = 0;
			 if(y == 0)y = 0;
			 System.out.printf("%.3f %.3f\n",x,y);
		 }
		 }
	 } 

Measured memory_bytes: 20564
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i, j;
	int donatsu[101] = {};
	int cake[101] = {};
	int N;
	int ans=0;
	int count = 0;
	cin >> N;

	for (i = 0; i < 100; ++i) {
		donatsu[i] = 7;
		cake[i] = 4;
	}

	for (i = 0; i < 100; ++i) {
		for (j = 0; j < 100; ++j) {
			ans = i*donatsu[i] + j*cake[j];
			if (ans == N) {
				++count;
			}
		}
	}

	if (count == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}



}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int main(void) {
  long fact[11];
  fact[0] = 1;
  REP(i, 1, 11) fact[i] = fact[i - 1] * i;

  for(int N; cin >> N, N > 0;) {
    string S[12];
    int a[256];

    REP(i, 0, 256) a[i] = 0;
    REP(i, 0, N) {
      cin >> S[i];
      REP(j, 0, S[i].length()) a[S[i][j]] = 1;
    }

    int p = 0;
    REP(i, 0, 256) {
      if(a[i] == 1) a[i] = p++;
      else a[i] = -1;
    }

    int v[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    long cnt = 0;
    int k, s, t, u;
    while(next_permutation(v, v + 10)) {
      k = 0;
      REP(i, 0, N - 1) k += v[a[S[i][S[i].length() - 1]]];
      k -= v[a[S[N - 1][S[N - 1].length() - 1]]];
      if(k % 10 != 0) goto CONTINUE;
      s = 0;
      REP(i, 0, N - 1) {
        if(S[i].length() > 1 && v[a[S[i][0]]] == 0) goto CONTINUE;
        t = 0;
        REP(j, 0, S[i].length()) t = t * 10 + v[a[S[i][j]]];
        s += t;
      }
      if(S[N - 1].length() > 1 && v[a[S[N - 1][0]]] == 0) goto CONTINUE;
      u = 0;
      REP(i, 0, S[N - 1].length()) u = u * 10 + v[a[S[N - 1][i]]];
      if(s == u) cnt++;
CONTINUE: continue;
    }

    cout << (p <= 10 ? cnt / fact[10 - p] : cnt) << endl;
  }
}

Measured memory_bytes: 3096
MOD = 10**9+7
def pow(a, b):
    res = 1
    while b:
        if b & 1: res = res * a % MOD
        a = a**2 % MOD
        b >>= 1
    return res

n, a, b = list(map(int, input().split()))

ans = pow(2, n)-1

for X in [a, b]:
    x = 1
    y = 1
    for i in range(X):
        x = x * (n-i) % MOD
        y = y * (i+1) % MOD

    t = x * pow(y, MOD-2) % MOD
    ans -= t

while ans < 0: ans += MOD
print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

//   String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
    String[] s=sc.nextLine().split("");
//     String[] e=sc.nextLine().split(" ");

//int n=Integer.parseInt(nyuA);

//int A=Integer.parseInt(s[0]);
//int B=Integer.parseInt(s[1]);

for(int i=0;i<s.length;i++){
if(i%2==0)System.out.print(s[i]);

}

System.out.println();

//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);


	}
}

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

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


const int N = 2e5 + 5, M = 4e5 + 5;

int ne, head[N], nxt[M], to[M], vis[N];

void initGraph(int n){ // reset graph
    memset(head, -1, n * sizeof(head[0]));
    ne = 0;
}
void addEdge(int f, int t){
    to[ne] = t;
    nxt[ne] = head[f];
    head[f] = ne++;
}

int c = 0;
void dfs(int u){
    vis[u] = 1;
    c++;
    for(int k = head[u]; ~k; k = nxt[k]){
        int v = to[k];
        if(!vis[v]) dfs(v);
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m, mx = 0; cin >> n >> m;
    initGraph(n);
    while(m--){
        int u, v; cin >> u >> v;
        u--, v--;
        addEdge(u, v);
        addEdge(v, u);
    }
    for(int i = 0; i < n; i++){
        if(!vis[i]){
            c = 0;
            dfs(i);
            mx = max(mx, c);
        }
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 17668
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final int counter = scanner.nextInt();
		final int diff = scanner.nextInt();
		final int[] trees = new int[counter];

		for (int i = 0; i < counter; i++) {
			trees[i] = scanner.nextInt();
		}

		Arrays.sort(trees);

		final int[] diffs = new int[counter - diff + 1];
		for (int i = 0; i < counter - diff + 1; i++) {
			diffs[i] = trees[i + diff - 1] - trees[i];
		}

		System.out.println(min(diffs));
	}

	public static int min(int[] array) {
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] < min) {
				min = array[i];
			}
		}
		return min;
	}

}

Measured memory_bytes: 49448
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long X = nx[1];
        //ちゅーごくじょーよてーり
        //オーダーによってSの終端が決定する
        //まず影響するのは降順のみなことは自明に分かって、
        //で、「次」を選ぶことができる順番は
        //「確率」「期待値」
        //aを取り除いた場合、その後に適用できるのはそれ以前全て。

        List<int> s = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToList();
        ModInt[] dp = new ModInt[X + 1];
        dp[X] = 1;
        ModInt remain = s.Count - 1;
        foreach (var mod in s)
        {
            ModInt[] newDP = new ModInt[X + 1];

            for (int i = 0; i < dp.Length; i++)
            {
                newDP[i % mod] += dp[i];
                newDP[i] += dp[i] * remain;
            }
            remain--;
            dp = newDP;
        }
        ModInt res = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            res += dp[i] * i;
        }
        Console.WriteLine(res);
    }
}


struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ModInt(long data) { Data = data; Eval(); }

    private long Eval() => (Data %= MOD) < 0 ? Data += MOD : Data;
    public static implicit operator long(ModInt modInt) => modInt.Data;
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, ModInt b)
    {
        long res = a.Data + b.Data;
        return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt(a.Data * b.Data);
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);

    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 29920
#include<stdio.h>
int main(){
 
int a,b;
scanf("%d %d\n",&a,&b);
if (a < b) {
    printf("a < b\n");
} else if (a > b) {
    printf("a > b\n");
} else {
    printf("a == b\n");
}
 
return 0;
}



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


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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
struct AB{
    long long int a;
    int b;
}ab[100000];
bool comp(AB x, AB y){
    return x.a<y.a;
}
int main(){
    long long int sum=0;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>ab[i].a>>ab[i].b;
    }
    sort(ab,ab+n,comp);
    for(int i=0;i<n;i++){
        if(ab[i].b>=m){
            sum+=m*ab[i].a;
            m=0;
        }
        else{
            sum+=ab[i].a*ab[i].b;
            m-=ab[i].b;
        }
        if(m==0){
            cout<<sum<<endl;
            return 0;
        }
    }
}


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

int main() {
    int n;
    cin >> n;
    while(n--) {
        int l = 0, r = 0;
        bool ok = true;
        for(int i=0; i<10; ++i) {
            int x;
            cin >> x;
            if(l < x && r < x) {
                if(l < r) {
                    r = x;
                } else {
                    l = x;
                }
            } else if(l < x) {
                l = x;
            } else if(r < x) {
                r = x;
            } else {
                ok = false;
            }
        }
        if(ok) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


Measured memory_bytes: 3100
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int h,w; cin >> h >> w;
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    vector<vector<int> > ans(h,vector<int> (w));
    int now = 0;

    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            int jd;
            if(i % 2 == 0) jd = j;
            else jd = w - 1 - j;

            ans.at(i).at(jd) = now;
            a.at(now) --;
            if(a.at(now) == 0) now ++;
        }
    }

    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cout << ans.at(i).at(j) + 1 << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  
  vector<char> vec_s(s.size());
  for (int i = 0; i < s.size(); i++) {
    vec_s.at(i) = s.at(i);
  }
  
  vector<char> vec_t(t.size());
  for (int j = 0; j < t.size(); j++) {
    vec_t.at(j) = t.at(j);
  }
  
  sort(vec_s.begin(), vec_s.end());
  
  sort(vec_t.begin(), vec_t.end());
  reverse(vec_t.begin(), vec_t.end());
  
  bool a = true;
  for (int k = 0; k < min(s.size(), t.size()); k++) {
    if (vec_s.at(k) < vec_t.at(k)) {
      cout << "Yes" << endl;
      a = false;
      break;
    }
    else if (vec_s.at(k) > vec_t.at(k)) {
      cout << "No" << endl;
      a = false;
      break;
    }
  }
  
  if (a == true && s.size() < t.size()) {
    cout << "Yes" << endl;
  }
  if (a == true && s.size() >= t.size()) {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {

        var line = Console.ReadLine().Split(' ');
        var r = int.Parse(line[0]);
        var c = int.Parse(line[1]);
        int[,] table = new int[r + 1, c + 1];

        for (var iRow = 0; iRow < r; iRow++)
        {
            line = Console.ReadLine().Split(' ');
            var sum_iRow = 0;
            for (var iCol = 0; iCol < c; iCol++)
            {
                sum_iRow+= table[iRow, iCol] = int.Parse(line[iCol]);
            }
            table[iRow, c] = sum_iRow;
        }

        for (var iCol = 0; iCol <= c ; iCol++)
        {
            var sum_iCol = 0;
            for (var iRow = 0; iRow < r; iRow++) sum_iCol += table[iRow, iCol];
            table[r, iCol] = sum_iCol;
        }

        for (var iRow = 0; iRow <= r; iRow++)
        {
            for (var iCol = 0; iCol <= c ; iCol++)
            {
                if (iCol != c) Console.Write(table[iRow, iCol] + " ");
                else Console.WriteLine(table[iRow, iCol]);
            }
     
        }
    }
}



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

int main() {
	int k;
	vector<int> a(5);
	rep(i, 5) cin >> a[i];
	cin >> k;

	if (a[4] - a[0] > k) cout << ":(" << endl;
	else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MIN(x,y) ((x) < (y) ? (x) : (y))

int main(void) {
	int n, x, i, j, p, q, c;
	for(;;) {
		scanf("%d %d", &n, &x);
		if ((n == 0) && (x == 0)) {
			break;
		}
		c = 0;
		for (i = n; i>0; i--) {
			p = x - i; 
			for (j = MIN(p,i-1); j>1; j--) {
				q = p - j;
				if ((q>0)&(q<j)) {
					c++;
				} else if (q>=j) {
					break;
				}
			}
		}
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 600
import java.lang.Math;
import java.util.Scanner;
import java.util.Arrays;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt() + 2;     // N[0] と N[-1] == 0
        long C = sc.nextLong();
        long costs[] = new long[N];   // x_i
        int values[] = new int[N];    // v_i
        for (int i = 1; i < N - 1; i++) {
            costs[i] = sc.nextLong();
            values[i] = sc.nextInt();
        }
        costs[N-1] = C;
        sc.close();

        long cw_values_accum[] = new long[N];
        long ccw_values_accum[] = new long[N];
        for (int i = 1; i < N; i++) {
            cw_values_accum[i] = cw_values_accum[i-1] + values[i];
            ccw_values_accum[i] = ccw_values_accum[i-1] + values[(N-1)-i];
        }
        // System.out.println(Arrays.toString(cw_values_accum));
        // System.out.println(Arrays.toString(ccw_values_accum));

        long cw_score_max1[] = new long[N];
        long cw_score_max2[] = new long[N];
        for (int i = 1; i < N; i++) {
            cw_score_max1[i] = Math.max(cw_score_max1[i-1], cw_values_accum[i] - costs[i]);
            cw_score_max2[i] = Math.max(cw_score_max2[i-1], cw_values_accum[i] - costs[i]*2);
        }
        // System.out.println(Arrays.toString(cw_score_max1));
        // System.out.println(Arrays.toString(cw_score_max2));

        long score_max = 0;
        for (int i = 0; i < N-1; i++) {
            long ccw_first = ccw_values_accum[i] - (C - costs[(N-1)-i])*2 + cw_score_max1[(N-1)-i-1];
            long cw_first  = ccw_values_accum[i] - (C - costs[(N-1)-i])   + cw_score_max2[(N-1)-i-1];
            if (cw_first >= score_max) { score_max = cw_first; }
            if (ccw_first >= score_max) { score_max = ccw_first; }
        }

        System.out.println(score_max);
    }
}


Measured memory_bytes: 85660
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

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

  if (a >= k) {
    a -= k;
  }
  else {
    b = b - (k - a);
    if (b < 0) b = 0;
    a = 0;
  }

  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
# editorialを参考にした
N = int(input())
ans = 0

def count(s):
    global ans
    if int(s) > N:
        return 0
    elif s.count("3") > 0 and s.count("5") > 0 and s.count("7") > 0:
        ans += 1

    for j in "357":
        count(s+j)


count("0")
print(ans)


Measured memory_bytes: 3060
n=int(input())
words=[]
def siritori(word):
    global words
    if words==[]:
        words.append(word)
        return True
    if (word not in words) and words[-1][-1]==word[0]:
        words.append(word)
        return True
    return False

ans=0
for i in range(n):
    if not siritori(input()):
        ans+=1
if ans==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
H,N=map(int,input().split())
AB=[]
for i in range(N):
    AB.append(list(map(int,input().split())))
maxA=max(AB)[0]
#dp[i] 敵に合計iダメージを与えるのに必要な最小魔力量
dp=[float("inf")]*(H+maxA)
dp[0]=0
for i in range(H):
    for fire,cost in AB:
        dp[i+fire]=min(dp[i+fire],dp[i]+cost)

ans=min(dp[H:])
print(ans)







Measured memory_bytes: 43356
#include<stdio.h>
#include<algorithm>
#include<vector>
#define fst first
#define snd second

using namespace std;

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

const int MN = 1e5 + 1;
const int MM = 1e5 + 1;

int N, M;
vector<int> E[MN];
int outdegree[MN], visited[MN];

void connect(int a, int b) {
    outdegree[a] ^= 1;
    printf("%d %d\n", a+1, b+1);
}

void dfs(int n, int prev) {
    visited[n] = 1;
    for(int t: E[n]) {
        if (visited[t]) {
            if (t != prev && visited[t] == 1) {
                connect(n, t);
            }
        }
        else {
            dfs(t, n);
        }
    }
    if (prev != -1) {
        if (outdegree[n] == 1) {
            connect(n, prev);
        }
        else {
            connect(prev, n);
        }
    }
    visited[n] = 2;
}

int main() {
    scanf("%d%d", &N, &M);
    if (M&1) {
        return !puts("-1");
    }
    
    for(int i = 0; i < M; i++) {
        int a, b;
        scanf("%d%d", &a, &b); a--, b--;
        E[a].push_back(b), E[b].push_back(a);
    }
    dfs(0, -1);
    return 0;
}

Measured memory_bytes: 13824
#include <iostream>
#include <string>

using namespace std;

bool check(const string& S, string::size_type s)
{
    if (s == S.size()) return true;
    const string str[] = {"dream", "dreamer", "erase", "eraser"};
    for (int i = 0; i < sizeof(str)/sizeof(str[0]); ++i) {
        const auto n = S.find(str[i], s);                                                if (n == s) {                                                                        bool r = check(S, s + str[i].size());
            if (r) return r;                                                             }
    }                                                                                return false;
}
int main()
{
    string S;
    cin >> S;
    cout << (check(S, 0) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	string S;
	cin >> S;
	for(int i = 0; i < S.size(); i++){
		cout << 'x';
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3636
chomp(my $num = <>);

chomp(my $input_text = <>);
my @text = split / /, $input_text;


my $j=1;

while(){
    my $i =0;
    while($i <= $#text){
        if($text[$i] % (2**$j) != 0 ){
            $j--;
            print $j;
            exit(0);
        }
        $i++;
    }
    $j++;
}

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

using namespace std;

#define FOR(i,l,r) for (int i=(l); i<(r); ++i)
#define sz(x) (int)(x).size()
#define dbg(x) cout << (#x) << ' ' << (x) << endl
#define memfill(x, a) memset((x), (a), sizeof(x))
#define all(x) (x).begin(), (x).end()

typedef string str;
typedef long long int64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const int64 LLINF = 1LL << 60LL;

/*-------- END OF TEMPLATE --------*/

int n, m, a;

int main() {
    scanf("%i%i",&n,&m);
    int sum = 0;
    for (int i = 0; i < m; i++) {
        scanf("%i",&a);
        sum += a;
    }
    if (sum > n) printf("%i\n",-1);
    else printf("%i\n",n-sum);
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

vector<PI> edges[100100];

li res[100100];

inline void dfs(li now, li prev, li prev_color) {
    li now_color = 1;
    for (auto && next : edges[now]) {
        if (next.F == prev)continue;
        if (now_color == prev_color) {
            now_color++;
        }
        res[next.S] = now_color;
        dfs(next.F, now, now_color);
        now_color++;
    }
}

int main() {
    li n;
    cin >> n;
    rep(i, n - 1) {
        li a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].pb({b, i});
        edges[b].pb({a, i});
    }

    li max_degree = 0;
    rin{
        max_degree = max(max_degree, sz(edges[i]));
    }

    dfs(0, -1, -1);

    cout << max_degree << endl;
    rep(i, n - 1) {
        cout << res[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 8704
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;

    std::cin >> N;

    if (N%2 == 1) N++;

    std::cout << (N/2) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define MAX 100000
using namespace std;

int A[MAX];
int partition(int p, int r);


int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    int criterion = partition(0, n-1);
    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == criterion) {
            printf("[%d]", A[i]);
        }
        else printf("%d",  A[i]);
    }
    printf("\n");
}


int partition(int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    
    return i + 1;
}



Measured memory_bytes: 3004
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        
    def find_root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find_root(self.par[x])
        return self.par[x]
    
    def union(self, x, y):
        x_root = self.find_root(x)
        y_root = self.find_root(y)
        if x_root != y_root:
            if self.rank[x_root] < self.rank[y_root]:
                x_root, y_root = y_root, x_root
            if self.rank[x_root] == self.rank[y_root]:
                self.rank[x_root] += 1
            self.par[y_root] = x_root
            
    def is_same(self, x, y):
        x_root = self.find_root(x)
        y_root = self.find_root(y)
        return x_root == y_root
        
N, M = map(int, input().split())
X = [ list(map(int, input().split())) for _ in range(M)]

uf = UnionFind(N)
for x in X:
    uf.union(x[0]-1, x[1]-1)
    
roots = [ uf.find_root(i) for i in range(N)]
print(len(set(roots)))

Measured memory_bytes: 42340
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12

li dp(vector<vector<li>> &mem, int pos, li current, li sum, li &ans, string &s) {
  if (pos == s.size()) {
    sum += current;
    ans += sum;
    return 0;
  }
  current = current * 10 + s[pos] - '0';
  dp(mem, pos + 1, 0, sum + current, ans, s);
  dp(mem, pos + 1, current, sum, ans, s);
  return 0;
}

void _main(int tc) {
  string s;
  cin >> s;
  vector<vector<li>> mem(s.size() + 1, vector<li>(2, -1));
  li ans = 0;
  dp(mem, 0, 0, 0, ans, s);
  cout << (ans >> 1) << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;


int main(){
    ll X, Y;
    cin >> X >> Y;
    ll sum = 0;
    ll point = X;
    while(point <= Y){
        point *= 2;
        sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

s = arr_data[0][0]
t = arr_data[1][0]


#print(s,t)


arr1=[]
arr2=[]

for v in s:
    
    arr1.append(v)
    
arr1_sort=sorted(arr1)

for v in t:
    
    arr2.append(v)
    
arr2_sort=sorted(arr2,reverse=True)


str1="".join(arr1_sort)
str2="".join(arr2_sort)

#print(str1,str2)

if(str1<str2):
    
    print("Yes")
    
else:
    
    print("No")


Measured memory_bytes: 3188
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	k := iScan()
	ans := 1
	for i := 0; i < smaller(len(s), k); i++ {
		if string(s[i]) != "1" {
			ans = stringToInt(string(s[i]))
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
#include<iostream>

using namespace std;

int main(){
  int ax,bx;
  double a,b;
  cin >> a >> b;
  bool can=false;
  int ans=-1;
  for(int i=13;i<=1000;i++){
    ax=i*0.08;
    bx=i*0.1;
    if((int)bx==b && (int)ax==a){
      can=true;
      ans=i;
      break;
    }
  }
  if(can) cout << ans << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w;
    cin >> h >> w;
    char s[100][100];
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    for(int i=0;i<w+2;i++){
        cout << "#" ;
    }
    cout << endl;
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j==0){
                cout << "#";
            }
            cout << s[i][j];
            if(j==w-1){
                cout << "#" << endl;;
            }
            
        }
    }
     for(int i=0;i<w+2;i++){
        cout << "#" ;
    }
    cout << endl;
    
    return 0;
    
}


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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  
  for (int i=0; i<h; i++)
    cin >> s.at(i);
  
  for (int i=0; i<h; i++) {
    for (int j=0; j<2; j++) {
      cout << s.at(i) << endl;
    }
  }
}

Measured memory_bytes: 256
X,K,D = map(int,input().split())
X = abs(X)
ans = 0

if X>=D and D*K<=X:
  ans = X - D*K
if X>=D and D*K>X:
  K=K-int(X/D)
  X=X%D
  if K%2==0:
    ans=X
  else:
    ans = abs(X-D)
if X<D:
  if K%2==0:
    ans = X
  else:
    ans = abs(X-D)

print(ans)  

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

// 素因数分解 O(√n)以下
// (素因数,個数)
template<typename T>
vector<pair<T, int>> prime_factorization(T n) {
    vector<pair<T, int>> res;
    for (T i = 2; i*i <= n; i++) {
        int cnt = 0;
        while (n % i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt > 0) res.push_back({i,cnt});
    }
    if (n > 1) res.push_back({n,1});
    return res;
}

constexpr int MOD = 1e9 + 7;

template<long long mod>
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((mod + x) % mod) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= mod;
        }
        this->x = z;
    }
    mint& operator+=(const mint &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint &a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint& operator/=(const mint &a) {
        long long n = mod - 2;
        mint<mod> u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};

//pow
template<typename T, typename U>
T pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}

// comb (前計算O(NlogMOD) クエリO(1))
vector<mint<MOD>> FACT, IFACT;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    int MAX_N = 1000000;
    FACT.resize(MAX_N + 1);
    IFACT.resize(MAX_N + 1);
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i = 1; i <= MAX_N; i++) {
        FACT[i] = FACT[i - 1] * i;
        IFACT[i] = pow(FACT[i], MOD - 2);
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        auto p = prime_factorization(a[i]);
        for (auto q : p) {
            mp[q.first] = max(mp[q.first], q.second);
        }
    }
    mint<MOD> ans = 0;
    for (int i = 0; i < n; i++) {
        ans += IFACT[a[i]] * FACT[a[i] - 1];
    }
    for (auto p : mp) {
        ans *= pow(mint<MOD>(p.first), p.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16384