akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	w = sorted(v)
	c = 0
	for i in range(n):
		if v[i] != w[i]:
			c += 1
	if c == 0 or c == 2:
		print('YES')
	else:
		print('NO')

if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int n;

  cin >> n;
  string s;
  map<string, int> m;
  int ma = 0;
  for (int i = 0; i < n; i++){
    cin >> s;
    m[s]++;
    ma = max(ma, m[s]);
  }


  for( auto i = m.begin(); i != m.end() ; ++i ) {
    if (i->second == ma)
      cout << i->first << endl;
  }

  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXN = 5 + 1000;
const int MAXWS = 5 + 10000;

struct block {
    int w,s,v;
    friend istream& operator>>(istream& in, block& b) {
        in >> b.w >> b.s >> b.v;
        return in;
    }
} b[MAXN];

ll memo[MAXN][MAXWS];
int N;

ll dp(int i, int sum) {
    if(i < 0 || sum >= MAXWS) {
        return 0LL;
    }
    ll& ans = memo[i][sum];
    if(ans == -1) {
        ans = dp(i - 1, sum);
        if(sum <= b[i].s) {
            ans = max(ans, b[i].v + dp(i - 1, sum + b[i].w));
        }
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N;
    foi(i,0,N) {
        cin >> b[i];
    }
    memset(memo, -1, sizeof memo);
    sort(b, b + N, [](const block& p, const block& q)->bool{
         int rem = p.s - q.w;
         int rem2 = q.s - p.w;
         return rem > rem2;
         });
    cout << dp(N-1,0) << '\n';
    return 0;
}


Measured memory_bytes: 78848
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
 string s,t;
 cin>>s>>t;
 
 ll len=s.size();
 
 ll mn=INF;
 
 for(ll i=0;i<len;i++){
     if(i+(ll)t.size()-1<s.size()){
         ll cnt=0;
         
         for(ll j=i;j<i+(ll)t.size();j++){
             if(s[j]!=t[j-i])
             cnt++;
         }
         
         mn=min(mn,cnt);
     }
 }
 
 cout<<mn<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int count = 0;
        for(int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(Math.sqrt(((double)x*x + (double)y*y)) <= d) {
                count++;
            }
        }
        System.out.println(count);
        sc.close();
    }
}

Measured memory_bytes: 48660
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	int N,i,sum=0;
	cin >> N;
	int A[N+2];
	for(i=1;i<=N;i++){
		cin >> A[i];
	}
	A[0]=0;
	A[N+1]=0;
	for(i=0;i<=N;i++){
		sum+=abs(A[i+1]-A[i]);
	}
	for(i=1;i<=N;i++){
		cout <<(sum-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1])) <<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define iii tuple<int, int, int>
#define iiii tuple<int, int, int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define rep(i, a, b) for (auto i = a; i != b; i += 1 - 2 * (a > b))

using namespace std;

ll cal(vector<ll>& pos, vector<ll>& neg, ll zero, ll m) {
    if (m > 0) {
        ll res = 1LL * pos.size() * neg.size() +
                 zero * (pos.size() + neg.size()) + 1LL * (zero - 1) * zero / 2;
        for (int i = 0; i < pos.size(); ++i) {
            res += lower_bound(pos.begin() + i + 1, pos.end(),
                               (m - 1) / pos[i] + 1) -
                   pos.begin() - i - 1;
        }
        for (int i = 0; i < neg.size(); ++i) {
            res += lower_bound(neg.begin() + i + 1, neg.end(),
                               (m - 1) / neg[i] + 1) -
                   neg.begin() - i - 1;
        }
        return res;
    } else if (m == 0)
        return 1LL * pos.size() * neg.size();
    else {
        ll res = 0;
        for (int i = 0; i < pos.size(); ++i) {
            res += neg.size() -
                   (lower_bound(all(neg), (-m) / pos[i] + 1) - neg.begin());
        }
        return res;
    }
}

void solve() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> pos, neg, a;
    int zero = 0;
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        a.eb(x);
        if (x > 0)
            pos.eb(x);
        else if (x == 0)
            zero++;
        else
            neg.eb(-x);
    }

    sort(all(pos));
    sort(all(neg));
    ll l = -1e18, r = 1e18, resr;
    while (l <= r) {
        ll m = (l + r) >> 1;
        ll cnt = cal(pos, neg, zero, m);
        if (cnt < k) {
            l = m + 1;
            resr = m;
        } else {
            r = m - 1;
        }
    }
    cout << resr << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;

    while (t--) solve();
    return 0;
}

Measured memory_bytes: 4468
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    string s;
    while(cin >> s){
        int ans1, ans2;
        ans1 = ans2 = 0;
        rep(i, s.size() - 2){
            if(s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I'){
                ans1++;
            }else if(s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I'){
                ans2++;
            }
        }
        cout << ans1 << endl << ans2 << endl;
    }
}

Measured memory_bytes: 1196
#include <iostream>

using namespace std;
long long dp[3010][3010][2] = {},a[3010],ans = 0;//i個取り除いて、左がa[j]のとき0が先手で先攻-後攻
int main(){
	int i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<n;i++){
		dp[n-1][i][0] = a[i];
		dp[n-1][i][1] = -a[i];
	}
	for(i=n-2;i>=0;i--){
		for(j=0;j<=i;j++){
			dp[i][j][0] = max(a[j] + dp[i+1][j+1][1],a[n+j-i-1] + dp[i+1][j][1]);
			dp[i][j][1] = min(-a[j] + dp[i+1][j+1][0],-a[n+j-i-1] + dp[i+1][j][0]);
		}
	}
	cout << dp[0][0][0] << endl;
}

Measured memory_bytes: 139776
import java.util.Scanner;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        boolean[][] bom = new boolean[H + 2][W + 2];
        for (int i = 0; i < H + 2; i++) {
            for (int j = 0; j < W + 2; j++) {
                bom[i][j] = false;
            }
        }
        for (int i = 0; i < H; i++) {
            String line = sc.next();
            for (int j = 0; j < W; j++) {
                if (line.charAt(j) == '#') {
                    bom[i + 1][j + 1] = true;
                } else {
                    bom[i + 1][j + 1] = false;
                }
            }
        }
        for (int i = 1; i < H + 1; i++) {
            for (int j = 1; j < W + 1; j++) {
                if (bom[i][j]) {
                    System.out.print('#');
                } else {
                    int nBoms = 0;
                    if (bom[i - 1][j - 1]) {
                        nBoms++;
                    }
                    if (bom[i - 1][j]) {
                        nBoms++;
                    }
                    if (bom[i - 1][j + 1]) {
                        nBoms++;
                    }
                    if (bom[i][j - 1]) {
                        nBoms++;
                    }
                    if (bom[i][j + 1]) {
                        nBoms++;
                    }
                    if (bom[i + 1][j - 1]) {
                        nBoms++;
                    }
                    if (bom[i + 1][j]) {
                        nBoms++;
                    }
                    if (bom[i + 1][j + 1]) {
                        nBoms++;
                    }
                    System.out.print(nBoms);
                }
            }
            System.out.println();
        }
    }
}


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

int main() {
    double a,b;cin>>a>>b;
    cout<<setprecision(10)<<a/b<<endl;
	return 0;
}

Measured memory_bytes: 3724
S = input()
S_inv = S[::-1]
if S == S_inv:
	print(0)
else:
	i = 0
	j = len(S) - 1
	cnt = 0
	while i <= j:
		if S[i] == S[j]:
			i += 1
			j -= 1
		else:
			if S[i] == 'x':
				i += 1
				cnt += 1
			elif S[j] == 'x':
				j -= 1
				cnt += 1
			else:
				cnt = -1
				break
	print(cnt)

Measured memory_bytes: 3316
#!/usr/bin/env python3

from sys import stdin, setrecursionlimit
from collections import deque


def main():
    input = stdin.buffer.readline
    n = int(input())
    d = list(map(int, input().split()))
    m = int(input())
    t = list(map(int, input().split()))
    if m > n:
        print('NO')
    else:
        d.sort()
        t.sort()
        dq = deque(d)
        tq = deque(t)
        while tq:
            ti = tq.popleft()
            di = dq.popleft()
            while di < ti:
                di = dq.popleft()
            if di > ti:
                print('NO')
                exit()
        print('YES')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 115572
n = gets.to_i
k = 26
ans = ""
length = 1
nn = n
while nn > k
    nn -= k
    k = k * 26
    length += 1
end
(length - 1).times do |j|
    n -= 26 ** (j + 1)
end
length.times do |i|
    index = n % 26
    index = 26 if index == 0
    ans += ('a'.ord + index - 1).chr
    n = (n - 1) / 26
    n += 1
end
puts ans.reverse


Measured memory_bytes: 14376
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int f[22][1<<21],n,K;
char s[1<<21];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>K;
	for(int i=0,now=1;i<=n;i++,now<<=1){
		cin>>s;
		for(int j=0;j<1<<i;j++)
			f[i][j+now]=s[j]=='1';
	}
	for(int i=n;i;i--){
		for(int j=0;j<1<<n+1;j++){
			int k1=-1,k2=-1;
			for(int p=i-1;~p;p--)
				if(j>>p&1){k1=p;break;}
			for(int p=i-1;~p;p--)
				if(~j>>p&1){k2=p;break;}
			int tmp=f[i][j];
			f[0][j>>i]+=tmp;
			if(~k1){
				int now1=j&(1<<k1)-1,now2=(j>>i-1)|1;
				f[k1][now1|now2<<k1]+=tmp;
			}
			if(~k2){
				int now1=j&(1<<k2)-1,now2=(j>>i)<<1;
				f[k2][now1|now2<<k2]+=tmp;
			}
		}
	}
	int ans=1;
	for(int j=(1<<n+1)-1;j;j--){
		if(f[0][j]>=K){
			int now=n+1;
			while(~ans>>now&1&&~j>>now&1) now--;
			if(j>>now&1&&~ans>>now&1) ans=j;
			if(j>>now&1&&ans>>now&1&&ans>j) ans=j;
		}
	}
	int x=ans,now=n+1;
	while(~x>>now&1) now--;
	for(int i=now-1;~i;i--)
		cout<<(x>>i&1);
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 173440
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	rep(i, (n / 2)+1) {
		rep(j, (n / 7)+1) {
			if (4 * i + 7 * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
   int n,m; cin>>n>>m;
   vector<int> ac(n),wa(n);
   rep(i,m){
      int p;
      string s;
      cin>>p>>s;
      --p;
      if(ac[p]) continue;
      if(s=="AC") ac[p]=1;
      else wa[p]++;
   }
   int a=0,w=0;
   rep(i,n){
      a+=ac[i];
      if(ac[i]) w+=wa[i];
   }
   cout<<a<<" "<<w<<endl;
   return 0;
}


Measured memory_bytes: 1024
while True:
    (H, W) = [int(x) for x in input().split()]
    if H == W == 0:
        break
  
    for hc in range(H):
        if hc == 0 or hc == H -1:
            print('#' * W)
        else:
            print('#' + '.' * (W -2) + '#')
    print()

Measured memory_bytes: 7684
n,m=map(int, input().split())
lmax=0
rmin=1000000
for i in range(m):
  l,r=map(int, input().split())
  lmax=max(l, lmax)
  rmin=min(r, rmin)

if rmin-lmax>=0:
  print(rmin-lmax+1)
else:
  print(0)

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

int64_t dp[1000010][2];
int main() {
	string s; cin >> s;
	int n = s.size();
	dp[n][1] = 1e18;
	for(int i = n - 1; i >= 0; --i) {
		int num = s[i] - '0';
		dp[i][0] = min(dp[i + 1][0] + num, dp[i + 1][1] + (num + 1));
		dp[i][1] = min(dp[i + 1][0] + (10 - num), dp[i + 1][1] + (10 - (num + 1)));
	}
	cout << min(dp[0][0], dp[0][1] + 1) << '\n';
	return 0;
}

Measured memory_bytes: 17028
#include <iostream>

int main() {
    int H, W;
    while (true) {
        std::cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i + j) % 2 ==0) {
                    std::cout << '#';
                } else {
                    std::cout << '.';
                }
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, cnt;

signed main() {
    cin >> n;
    while (n) {
        if (0 < n && n < 10) cnt++;
        else if (100 <= n && n < 1000) cnt++;
        else if (10000 <= n && n < 100000) cnt++;
        n--;
    }
    cout << cnt << endl;
}

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

int main() {
  int n, m, q;
  cin >> n >> m >> q;

  int dp[n][n] = {}; // 位置を記録
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    dp[l - 1][r - 1]++;
  }

  // 俗に言う2次元累積和
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n - 1; j++)
      dp[i][j + 1] += dp[i][j];

  for (int i = n - 1; i >= 1; i--)
    for (int j = n - 1; j >= 0; j--)
      dp[i - 1][j] += dp[i][j];

  // クエリに答える
  for (int query = 0; query < q; query++) {
    int s, t;
    cin >> s >> t;
    cout << dp[s - 1][t - 1] << endl;
  }
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
main(){
  int N,x;
  cin>>N>>x;
  vector<int>a(N);
  for(auto&x:a)cin>>x;
  int n_actions=0;
  for(int i=0;i<a.size()-1;++i){
    int sum=a[i]+a[i+1];
    if(sum>x){
      int sub=sum-x;
      int sub_right=min(a[i+1],sub);
      a[i+1]-=sub_right;
      int sub_left=sub-sub_right;
      a[i]-=sub_left;
      n_actions+=sub;
    }
  }
  cout<<n_actions<<endl;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
Connect = [0] * M
for i in range(M):
    k, *Connect[i] = map(int,input().split())
P = list(map(int,input().split()))
Switch = [0] * N
ans = 0
for i in range(1<<N):
    for j in range(N):
        bit = i>>j & 1
        Switch[j] = bit
    flag = True
    for l in range(M):
        count = 0
        for c in Connect[l]:
            if Switch[c-1]:
                count+=1
        if not P[l] == count % 2:
            flag = False
    if flag:
        ans += 1

print(ans)







Measured memory_bytes: 9148
#include<stdio.h>

int main(){
	int N;
	int R;
	int A;
	scanf("%d %d",&N,&R);//%dと%dの間に,を入れる場合二つの数値の間に,をいれるのを忘れないようにしよう。
	//printf("%d %d\n",N,R);わかりやすくするつもりが余計な出力
    if(N<10){
    A=R+100*(10-N);
    }else{
    	A=R;
    }
    printf("%d\n",A);
    return 0;
}

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

typedef long long ll;

int n; ll a[200010], ans;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%lld", &a[i]), a[i] += a[i - 1];
	ans = abs(a[n] - 2ll * a[1]);
	for(int i = 2; i < n; ++i)
		ans = min(ans, abs(a[n] - 2ll * a[i]));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
from itertools import combinations as comb
def get_ans(m, n):
    ans = sum(1 for nums in comb(range(1, min(m+1,n-2)), 2) if ((n-sum(nums)>0) and (n-sum(nums) > max(nums)) and (n-sum(nums)<=m)))
    return ans
      
while True:
    m, n = (int(x) for x in input().split())
    if m==0 and n==0:
        quit()
    ans = get_ans(m, n)
    print(ans)


Measured memory_bytes: 5644
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,d;
  cin>>n>>d;
  ll ans=0;
  vector<vector<ll> >v(n,vector<ll>(d,0));
  for(ll i=0;i<n;i++){
    for(ll j=0;j<d;j++){
      cin>>v[i][j];
    }
  }
  for(ll i=0;i<n-1;i++){
    for(ll j=i+1;j<n;j++){
      ll tmp=0;
      for(ll k=0;k<d;k++){
        tmp+=abs(v[i][k]-v[j][k])*abs(v[i][k]-v[j][k]);
      }
      if((ll)sqrt(tmp)*(ll)sqrt(tmp)==tmp)ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int a,b,c;
  scanf("%lld %lld %lld\n",&a,&b,&c);
  if(c-a-b<0){
    printf("No\n");
    return 0;
  }
  long long int d=a*a+b*b+c*c+2*a*b-2*a*c-2*b*c;
  if(d>4*a*b){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256
import heapq

n, m = map(int,input().split())
a = [-1 * int(i) for i in input().split()]
heapq.heapify(a)

for i in range(m):
    hangaku = (heapq.heappop(a) * -1) // 2 * -1
    heapq.heappush(a, hangaku)    

print(-1*sum(a))

Measured memory_bytes: 72216
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=2000010;

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x;}
    if(n%2==0){
        return power((x*x)%M,n/2);
    }
    if(n%2==1){
        return (power((x*x)%M,n/2)*x)%M;
    }
}

ll fac[N];

ll ncr(ll n,ll r)
{
    ll num=fac[n];
    ll denum=(fac[r]*fac[n-r])%M;
    ll ans=(num*power(denum,M-2))%M;
    return ans;
}

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

    fac[0]=1;
    for(ll i=1;i<N;++i){
        fac[i]=(i*fac[i-1])%M;
    }

    ll n;
    cin>>n;
    string ans="";
    while(n>0){
        ll l=n%26;
        if(l==0){
            ans+="z";
            n/=26;
            --n;
        }
        else{
            ans+=char('a'+l-1);
            n/=26;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;


    return (0);
}


Measured memory_bytes: 19276
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 0 1 0 0
1 0 0 0 0
0 0 0 1 0
0 0 0 1 0

output:
6
"""

import sys


class Rectangle(object):
    __slots__ = ('pos', 'height')

    def __init__(self, pos=float('inf'), height=-1):
        """
        init a Rectangle
        """
        self.pos = pos
        self.height = height


def gen_rec_info(_carpet_info):
    dp = [[float('inf')] * W for _ in range(H)]

    for i in range(H):
        for j in range(W):
            if int(_carpet_info[i][j]):
                dp[i][j] = 0
            else:
                dp[i][j] = dp[i - 1][j] + 1 if i else 1

    return dp


def get_largest_area(_hi_info):
    hi_max_area = 0
    rec_stack = []
    _hi_info.append(0)

    for i, v in enumerate(_hi_info):
        rect = Rectangle(pos=i, height=int(v))
        if not rec_stack:
            rec_stack.append(rect)
        else:
            last_height = rec_stack[-1].height
            if last_height < rect.height:
                rec_stack.append(rect)
            elif last_height > rect.height:
                target = i
                while rec_stack and rec_stack[-1].height >= rect.height:
                    pre = rec_stack.pop()
                    area = pre.height * (i - pre.pos)
                    hi_max_area = max(hi_max_area, area)
                    target = pre.pos
                rect.pos = target
                rec_stack.append(rect)

    return hi_max_area


def solve(_rec_info):
    overall_max_area = 0
    for hi_info in _rec_info:
        overall_max_area = max(overall_max_area, get_largest_area(hi_info))

    return overall_max_area


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    H, W = map(int, _input[0].split())
    carpet_info = list(map(lambda x: x.split(), _input[1:]))

    rec_info = gen_rec_info(carpet_info)
    # print(rec_info)
    ans = solve(rec_info)
    print(ans)

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m, x; cin>>n>>m>>x;
    vector<int> a(m, 0);
    for(int i=0; i<m; i++) cin>>a[i];

    int ans=1e9, sum=0;
    for(int i=0; i<m; i++){
        if(a[i]<x) sum++;
    }
    ans=min(ans, sum);
    sum=0;
    for(int i=0; i<m; i++){
        if(x<a[i]) sum++;
    }
    ans=min(ans, sum);
    cout << ans << endl;
}

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

int main(){
  int n;cin>>n;
  vector<int>p(n);
  int ans=0;
  for(int i=0;i<n;++i) cin>>p[i];
  sort(p.begin(),p.end());

  int size = p.size()/2 - 1;
  // cout<<p[size] << " " << p[size+1]<<endl;
  cout<<p[size+1] - p[size]<<endl;
  return 0;
}

Measured memory_bytes: 768
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            long Gcd(long x, long y) => y == 0 ? x : Gcd(y, x % y);
            var (N, X) = Slice2<long>();
            var xi = Sarray();
            var gcd = 0L;
            foreach (var x in xi)
                gcd = Gcd(gcd, Abs(X - x));
            WriteLine(gcd);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 38220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))

const ll mod = 1e9 + 7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll a , ll b){ a = a%mod; if(b == 0) return 1LL;if(b&1)  return (a*1LL*expo(a , b - 1))%mod;ll t = expo(a , b/2);return (t*1LL*t)%mod;}
ll inv(ll x){return expo(x,mod-2);}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

const int M = 2e5 + 5;


int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

int a , b;
cin >> a >> b;
string str;
cin >> str;

if(str.size() != a + b +1){
cout<<"No";
return 0;
}

for(int i = 0 ; i < a ; i++){
if(str[i] - '0' >= 0 && str[i] - '0' <= 9){
}
else{
cout<<"No";
return 0;
}
}
for(int i = a + 1 ; i < a + b + 1 ; i++){
if(str[i] - '0' >= 0 && str[i] - '0' <= 9){
}
else{
cout<<"No";
return 0;
}
}

if(str[a] != '-'){
cout<<"No";
return 0;
}
cout<<"Yes";















}














Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
ll f[2][2];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int a = 0; a < 2; a++) {
        for (int b = 0; b < 2; b++) {
            f[a][b] = -1e18;
        }
    }
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        for (int a = -1; a <= 1; a += 2) {
            for (int b = -1; b <= 1; b += 2) {
                f[(a + 1) / 2][(b + 1) / 2] = max(f[(a + 1) / 2][(b + 1) / 2], (ll)x * a + y * b);
            }
        }
    }
    ll best = -1e18;
    for (int a = 0; a < 2; a++) {
        for (int b = 0; b < 2; b++) {
            best = max(best, f[a][b] + f[a ^ 1][b ^ 1]);
        }
    }
    cout << best;
    return 0;
}

Measured memory_bytes: 3624
var
n,m,i,t:longint;
begin
read(n,m);
t:=trunc(sqrt(m));
for i:=1 to t do
if m mod i=0 then
if i>=n then
begin
writeln(m div i);
halt;
end;
for i:=t-1 downto 1 do
if m mod i=0 then
if m div i>=n then
begin
writeln(i);
halt;
end;
end.

Measured memory_bytes: 128
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"bac
" => r"Yes",

r"bab
" => r"No",

r"abc
" => r"Yes",

r"aaa
" => r"No"
}

use std::cmp;
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: String
    }

    let vec: Vec<char> = s.chars().collect();
    let mut hs = HashSet::new();

    for i in 0..vec.len() {
        hs.insert(vec[i]);
    }

    if hs.len() == 3 {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 4352
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

import random #入力整数列Aの生成に使用

A, P = [ int(x) for x in input().split() ]

print (math.floor((A * 3 + P) / 2))


Measured memory_bytes: 24732
from math import gcd
n = int(input())
a = list(map(int, input().split()))
u = 0
for i in a:
    u = gcd(u, i)
if u != 1:
    print('not coprime')
    exit()
vis = [False] * (10 ** 6 + 1)
for i in a:
    vis[i] = True
cnt = [0] * (10 ** 6 + 1)
for i in range(1, 10 ** 6 + 1):
    for j in range(1, 10 ** 6 + 1):
        if i * j > 10 ** 6:
            break
        if vis[i * j]:
            cnt[i] += 1
if max(cnt[2:]) <= 1:
    print('pairwise coprime')
else:
    print('setwise coprime')

Measured memory_bytes: 198012
n = int(input())
li_p = list()

li_p = list(map(int, input().split()))
answer = 0
for i in range(1, n - 1):
    li_w = li_p[i - 1:i + 2]
    if sorted(li_w).index(li_p[i]) == 1:
        answer += 1

print(answer)


Measured memory_bytes: 3060
/*
ID:greenty2
LANG:C++
TASK:
*/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int n,m;
char maps[105][105];
int book[105][105]; 
int dx []= {1,-1, 0,0};
int dy []= {0, 0,-1,1};
void dg(int x,int y,char ch)
{
	book[x][y]=1;
//	cout<<x<<" "<<y<<endl;
	for(int i=0;i<4;i++)
	{
		int xx= x+dx[i];
		int yy= y+dy[i];
		if(xx>0&&xx<=n&&yy>0&&yy<=m&&book[xx][yy]==0&&maps[xx][yy] == ch)
		{
			dg(xx,yy,ch);
		}
	}
	return ;
}
int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		if(m==0&&n==0)
		return 0;
		memset(book,0,sizeof(book));
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				scanf(" %c",&maps[i][j]);
			}
		}
		int tot = 0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if(book[i][j]==0)
				{
					dg(i,j,maps[i][j]);
					tot++;
				}
			}
		}
		printf("%d\n",tot);
	}	
} 

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  rep(i, n) {
    int t = a[i];
    while (t % 2 == 0) {
      t /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3692
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[3];
int main(){
	cin>>a[1]>>a[2];
	sort(a+1,a+2+1);
	if(a[1]==1&&a[2]==1){
		cout<<1;
		return 0;
	}
	if(a[1]==0){
		cout<<0;
		return 0;
	}
	if(a[1]==1){
		cout<<a[2]-2;
		return 0;
	}
	if(a[1]==2||a[2]==2){
		cout<<0;
		return 0;
	}
	cout<<(a[1]-2)*(a[2]-2);
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
town=[0]*n
info=[1]
now=1
while town[now-1]==0:
    town[now-1]+=1
    now=a[now-1]
    info.append(now)
loop_list=list(info[info.index(now):-1])
loop_len=len(loop_list)
before_loop_list=list(info[:info.index(now)])
#print(town)
#print(info)
if k<len(before_loop_list):
    print(before_loop_list[k])
else:
    print(loop_list[((k-len(before_loop_list))%loop_len)])

Measured memory_bytes: 32328
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
  cout << fixed << setprecision(10);
  long double a,b,x;cin>>a>>b>>x;x/=a;
  if(b*a/2 < x){
    x=(long double)(b*a/2)-(long double)(x-b*a/2);
    long double y = (x*2)/(long double)(a);
    cout << (long double) atan2l(y,a)*180/M_PI << endl;
  }else{
    long double y = (long double)(2*x)/(long double)(b);
    cout << (long double) atan2l(b,y)*180/M_PI << endl;
  }
}

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

int main(){

    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i=1;i<=N;i++)
        cin >> A[i];

    vector<long long> B(N+1);
    B[N] = A[N];
    for(int i=N-1;i>=2;i--)
        B[i] = (B[i+1] + A[i]) % 1000000007;

    long long res = 0;
    for(int i=1;i<=N-1;i++){
        res += A[i] * B[i+1];
        res %= 1000000007;
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define N 4
using namespace std;
int m[N][N];
int p[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};

bool legal(int r1, int c1){
	return (r1>=0 && r1<N && c1>=0 && c1<N);
}
int cost(){
	int ans = 0, x;
	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++){
			if(!m[i][j]) continue;
			x = m[i][j] - 1;
			ans += abs(x/N-i) + abs(x%N-j);
		}
	return ans;
}
bool dfs(int limit, int back, int now, int r, int c){
	int predict = cost();
	int r1, c1;
	if(predict == 0) return 1;
	if(predict+now > limit) return 0;
	for(int i=0; i<4; i++){
		r1 = p[i][0] + r;
		c1 = p[i][1] + c;
		if(!legal(r1, c1)) continue;
		if(abs(back-i) == 2) continue;
		swap(m[r][c], m[r1][c1]);
		if(dfs(limit, i, now+1, r1, c1)) return 1;
		swap(m[r][c], m[r1][c1]);
	}
	return 0;
}
int main()
{	
	int r, c;
	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++){
			cin >> m[i][j];
			if(m[i][j] == 0) r = i, c = j;
		}
	for(int limit=0; ; limit++){
		if( dfs(limit, 99, 0, r, c) ){
			cout << limit <<endl;
			break;
		}
	}
	return 0;
}



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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

int a[55], b[55], c[55], d[55];
int x[15];
int n, m, q;

int dfs(int p) {
  int res = 0;
  
  if (p==n+1) {
    /*
    rep(i, 1, n+1) {
      printf("%d", x[i]);
    }
    printf("\n");
    */
    rep (i, 0, q) if (x[b[i]] - x[a[i]] == c[i]) res += d[i];
    return res;
  }
  
  for (int i=x[p-1]; i<=m; i++) {
    x[p] = i;
    res = max(res, dfs(p+1));
  }
  return res;

}

int main(void) {
  cin >> n >> m >> q;
  rep(i, 0, q) {
    scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
  }
  
  x[1] = 1;
  int ans = dfs(2);
    
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 3772
#include <iostream>
#include <algorithm>

#define int long long
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

using namespace std;

int H, W;
int c[10][10];
int A[201][201];

signed main()
{
    cin >> H >> W;
    REP(i, 10) REP(j, 10) cin >> c[i][j];

    REP(k, 10) REP(i, 10) REP(j, 10)
    {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }

    int ans;
    REP(i, H) REP(j, W)
    {
        int a;
        cin >> a;
        if (a == -1) continue;
        ans += c[a][1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = (int) 1e5+5;

void ngk(){
    int n;
    cin >> n;
    if (n % 2 == 0){
        cout << n * (n-1) / 2 - n/2 << '\n';
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if (i + j != n+1)
                    cout << i << ' ' << j << endl;
            }
        }
    }
    else{
        cout << n * (n-1) / 2 - n/2 << '\n';
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if (i + j != n)
                    cout << i << ' ' << j << endl;
            }
        }
    }
} 

/*
    Verifying the algorithm
    Array limits;
    Corner cases;
*/

int main(){
    #ifdef NGKCP
        freopen("input.txt","r",stdin);
    #endif
    iostream::sync_with_stdio(0);
    ngk();
}

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

using namespace std;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS

    ll x, y;
    cin >> x >> y;

    if (x == 1 && y == 1) {
        cout << 1000000;
        return 0;
    }

    ll ans = 0;
    if (x <= 3) {
        ans += (4 - x) * 100000;
    }
    if (y <= 3) {
        ans += (4 - y) * 100000;
    }
    cout << ans;


    return 0;
}

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

public class Main {

    static int N;
    static int X;
    static int[] A;

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

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

    static int solve() {
        Arrays.sort(A);

        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if( X >= A[i] ) {
                X -= A[i];
                cnt++;

            } else {
                return cnt;
            }
        }

        if( X > 0 ) {
            return N - 1;
        } else {
            return N;
        }
    }

    @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: 21332
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<i64,i64>;

i64 toi64(string t){
    i64 res = 0;
    i64 digit = 1;
    for(int i = t.size() - 1; i >= 0; i--){
        res += (t[i] - '0') * digit;
        digit *= 10;
    }
    return res;
}

int main(){
    string S;
    cin >> S;
    i64 ans = 0;

    for(int bit = 0; bit < (1 << (S.size() - 1)); bit++){
        int b = bit, last = 0;
        b |= (1 << (S.size() - 1));
        for(int i = 0; i < S.size(); i++){
            if(b & (1 << i)) {
                int now = i + 1;
                string t = S.substr(last, now-last);
                last = now;
                ans += toi64(t);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
public class test{
    public static void Main(){
        // Your code here!
        var stArrayData = System.Console.ReadLine().Split(' ');
      	var a = int.Parse(stArrayData[0]);
        var b = int.Parse(stArrayData[1]);
      if(a*b%2==0)
        System.Console.WriteLine("Even");
      else
      	System.Console.WriteLine("Odd");
    }
}

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

bool is_product_overflow(ull a, ull b) {
	ull prod = a * b;
	return (prod / b != a);
}

void Main()
{
	ll a, b, c, d;
	std::cin >> a >> b >> c >> d;

	ll ac = a * c;
	ll bc = b * c;
	ll ad = a * d;
	ll bd = b * d;
	cout << max(max(ac, bc), max(ad, bd));
	return;	
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n,c;
    std::cin >> n>>c;
    vvector(d,ll,c,c,0ll);
    reprep(i,j,c,c)std::cin >> d[i][j];
    vvector(co,ll,3,c,0ll);
 //   std::cout << "nurupo" << std::endl;
    reprep(i,j,n,n){
        int dum;
        std::cin >> dum;
        co[(i+j)%3][dum-1]++;
        
    }
    ll ans=INF64;
    reprep(i,j,c,c)rep(k,c){
        ll dum=0ll;
        if(i==j||i==k||k==j)continue;
        rep(ii,c){
            dum+=co[0][ii]*d[ii][i];
            dum+=co[1][ii]*d[ii][j];
            dum+=co[2][ii]*d[ii][k];
            
        }
       // std::cout <<i<<j<<k<< dum << std::endl;
        ans=min(dum,ans);
    }
    std::cout << ans << std::endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

template <typename T>
T powi(T a, ll n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= a; 
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <ll mod>
class ModInt {
private:
    ll num;
public:
    ModInt() {};
    ModInt(ll n) { num = n % mod; }
    ModInt inv() const { return powi(*this, mod-2); }
    explicit operator ll() const { return num; }

    ModInt& operator+=(const ModInt& a) {
        num += a.num; 
        if (num >= mod) num -= mod; 
        return *this;
    }
    ModInt& operator-=(const ModInt& a) {
        if (num < a.num) num += mod;
        num -= a.num;
        return *this;
    }
    ModInt& operator*=(const ModInt& a) {
        num = num * a.num % mod;
        return *this;
    }
    ModInt& operator/=(const ModInt& a) { return *this *= a.inv(); }
    friend ModInt operator+(const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
    friend ModInt operator-(const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
    friend ModInt operator*(const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
    friend ModInt operator/(const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }

    friend ostream& operator<<(ostream& os, const ModInt& a) { return os << a.num; }
    friend istream& operator>>(istream& is, ModInt& a) {
        ll tmp;
        is >> tmp;
        a.num = tmp % mod;
        return is;
    }
};
using mint = ModInt<1000000007>;

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

    vector<bool> fir(2 * n, false);

    int cur = 0;
    for (int i = 0; i < 2*n; ++i) {
        int t = cur + (s[i] == 'W' ? 0 : 1);
        if (t % 2 == 1) {
            fir[i] = true;
            ++cur;
        } else {
            cur--;
            if (cur < 0) {
                cout << 0 << endl;
                return 0;
            }
        }
    }
    if (cur != 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<array<int, 2>> cumu(2*n+1);
    cumu[0][0] = 0;
    cumu[0][1] = 0;
    for (int i = 0; i < 2*n; ++i) {
        cumu[i+1][0] = cumu[i][0];
        cumu[i+1][1] = cumu[i][1];

        cumu[i+1][fir[i]]++;
    }

    mint ans = 1;
    for (int i = 2; i <= n; ++i) {
        ans *= i;
    }
    for (int i = 0; i < 2*n; ++i) {
        if (fir[i] == false) {
            int t = cumu[i+1][1] - cumu[i+1][0] + 1;
            ans *= t;
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 2180