akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

bool solve() {
    int H, W;
    cin >> W >> H;
    if(!(H + W)) return false;

    VV<int> wall(H * W);

    auto make_idx = [&](int h, int w) { return h * W + w; };
    auto check_range = [&](int h, int w) {
        return 0 <= h && h < H &&
               0 <= w && w < W;
    };

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W - 1; j++) {
            int a;
            cin >> a;
            if(a == 1) {
                wall[make_idx(i, j)].push_back(make_idx(i, j + 1));
                wall[make_idx(i, j + 1)].push_back(make_idx(i, j));
            }
        }
        if(i == H - 1) break;
        for(int j = 0; j < W; j++) {
            int a;
            cin >> a;
            if(a == 1) {
                wall[make_idx(i, j)].push_back(make_idx(i + 1, j));
                wall[make_idx(i + 1, j)].push_back(make_idx(i, j));
            }
        }
    }
    
    VV<int> edges(H * W);

    int dh[] = { 1, 0, -1, 0 };
    int dw[] = { 0, 1, 0, -1 };

    for(int h = 0; h < H; h++) for(int w = 0; w < W; w++) {
        for(int i = 0; i < 4; i++) {
            int nh = h + dh[i], nw = w + dw[i];
            if(!check_range(nh, nw)) continue;
            int hw_idx = make_idx(h, w);
            int nhw_idx = make_idx(nh, nw);
            auto ite = find(wall[hw_idx].begin(), wall[hw_idx].end(), nhw_idx);
            if(ite == wall[hw_idx].end()) edges[hw_idx].push_back(nhw_idx);
        }
    }

    const int inf = 1e9;
    V<int> dist(H * W, inf);
    dist[0] = 0;
    queue<pair<int, int>> que;
    que.emplace(0, 0);
    while(que.size()) {
        int idx, d;
        tie(idx, d) = que.front();
        que.pop();
        if(dist[idx] < d) continue;
        int nd = d + 1;
        for(int nidx : edges[idx]) {
            if(dist[nidx] <= nd) continue;
            dist[nidx] = nd;
            que.emplace(nidx, nd);
        }
    }

    int ans = dist.back();
    if(ans == inf) ans = -1;
    ans++;
    cout << ans << endl;
    return true;
}

int main() {
    while(solve());
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <stack>

using namespace std;

int main(void) {
  int n, q, command, t, x;
  cin >> n >> q;
  stack<int> st[n];

  for(int i = 0; i < q; i++) {
    cin >> command >> t;
    switch(command) {
      case 0:
        cin >> x;
        st[t].push(x);
        break;
      case 1:
        if(!st[t].empty())
          cout << st[t].top() << endl;
        break;
      case 2:
        if(!st[t].empty())
          st[t].pop();
        break;
    }
  }
}


Measured memory_bytes: 4304
import java.util.*;
import static java.lang.System.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
      String s = sc.next();
      int sum = 0;
      
      for(int i=0; i<s.length(); i++){
        sum = sum + (s.charAt(i)-'0');
      }
    if(sum % 9 ==0){
      out.println("Yes");
}else{
      out.println("No");
    }
}
}

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

using namespace std;

int main() {
    int N; cin>>N;
    string S; cin>>S;

    bool isOk=true;
    if (N % 2 == 0) {
        for (int i=0;i<N/2;i++) {
            if (S[i] != S[i+N/2]) {
                isOk = false;
                break;
            }
        }
    } else {
        isOk = false;
    }

    cout << (isOk?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 256
import Data.List

main = do
  [x, n] <- map read . words <$> getLine
  if n == 0 then do
    print x
  else do
    p <- map read . words <$> getLine
    let ps = sortBy (cmp x) $ [0..101] \\ p
    print $ head ps

cmp x a b
  | abs (a-x) > abs (b-x) = GT
  | abs (a-x) < abs (b-x) = LT
  | a > b = GT
  | a < b = LT
  | otherwise = EQ



Measured memory_bytes: 4420
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define RFOR(i,a,b) for (ll i = (a) ; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int n, ans=0, pre=0;
	cin >> n;
	VI h(n);
	rep(i, n) cin >> h[i];

	FOR(i, 1, n-1){
		if(h[i] <= h[i-1]) pre++;
		else pre = 0;
		ans = max(ans, pre);
	}

	cout << ans << endl;

}

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

  return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,a=-1,b=-1;
    cin >> N;
    string A,P,Q;
    char p,q;
    for(int i=1; i<=N; i++){
        A.push_back('0'+i);
        cin >> p;
        P.push_back(p);
    }
    for(int i=0; i<N; i++){
        cin >> q;
        Q.push_back(q);
    }
    if(A.compare(P)==0){
        a=0;
    }
    if(A.compare(Q)==0){
        b=0;
    }
    int i=1;
    while(a<0 || b<0){
        next_permutation(A.begin(),A.end());
        if(A.compare(P)==0){
            a=i;
        }
        if(A.compare(Q)==0){
            b=i;
        }
        i++;
    }
    cout << (a<b?b-a:a-b);
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<long double, long double>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

inline long double leng2(double x1, double y1, double x2, double y2) {return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

P ue(P x, P y) {
    P n;
    n.first = (x.first + y.first)/2;
    n.second = (x.second + y.second)/2;
    long double le = leng2(x.first, x.second, y.first, y.second);
    n.first += (x.second - y.second)/6*sqrt(3.0);
    n.second += (y.first - x.first)/6*sqrt(3.0);
    return n;
}

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

    function<vector<P>(int, P, P)> dfs = [&](int i, P x, P y ) {
        if(!i) {
            vector<P> vec;
            vec.push_back(x);
            vec.push_back(y);
            return vec;
        }
        --i;
        P i1, i2;
        i1.first = (x.first*2 + y.first)/3;
        i1.second = (x.second*2 + y.second)/3;
        i2.first = (x.first + y.first*2)/3;
        i2.second = (x.second + y.second*2)/3;

        

        vector<P> vec(1, x), vec1 = dfs(i, x, i1), vec2 = dfs(i, i2, y), vec3 = dfs(i, i1, ue(x, y)), vec4 = dfs(i, ue(x, y), i2);
        rep(j, vec1.size()-1) {
            vec.push_back(vec1[j+1]);
        }
        rep(j, vec1.size()-1) {
            vec.push_back(vec3[j+1]);
        }
        rep(j, vec1.size()-1) {
            vec.push_back(vec4[j+1]);
        }
        rep(j, vec1.size()-1) {
            vec.push_back(vec2[j+1]);
        }
        return vec;
    };

    P x = make_pair(0, 0), y = make_pair(100, 0);
    vector<P> vv = dfs(n, x, y);

    cout << fixed << setprecision(10);
    rep(i, vv.size()) {
        cout << vv[i].first << ' ' << vv[i].second << endl;
    }
}


Measured memory_bytes: 3420
let rec s ?(l = []) n =
  if n = 0 then l else s ~l:(read_int () :: l) (n-1)

let () =
  while true do
    let n = read_int () in
    if n == 0 then exit 0
    else
      let l = List.fast_sort compare (s n) in
      let min = List.hd l in
      let max = List.nth l (n-1) in
      let sum = List.fold_left (+) 0 l in
      let ave = (sum-min-max) / (n-2) in
      print_int ave; print_newline ()
  done

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

int main() {
    string s;
    cin >> s;
    map<char, int> counter;
    for(char c : s){
        counter[c]++;
    }
    if((bool(counter['N']) == bool(counter['S'])) && (bool(counter['W']) == bool(counter['E']))){
        puts("Yes");
    } else
        puts("No");
}

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

int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[n],i,a,b;

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

    for(i=k+1;i<=n;i++)
    {
        a=arr[i];
        b=arr[i-k];
        if(a>b)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
int main(){
	int w, h;
	int n;
	int x, y, a;
	bool field[100][100];
	for(int i = 0; i < 100; i++){
		for(int j = 0; j < 100; j++){
			field[i][j] = false;
		}
	}
	scanf("%d %d", &w, &h);
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d %d %d", &x, &y, &a);
		if(a == 1){
			for(int j = 0; j < x; j++){
				for(int k = 0; k < h; k++){
					field[j][k] = true;
				}
			}
		}else if(a == 2){
			for(int j = x; j < w; j++){
				for(int k = 0; k < h; k++){
					field[j][k] = true;
				}
			}
		}else if(a == 3){
			for(int j = 0; j < w; j++){
				for(int k = 0; k < y; k++){
					field[j][k] = true;
				}
			}
		}else if(a == 4){
			for(int j = 0; j < w; j++){
				for(int k = y; k < h; k++){
					field[j][k] = true;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < w; i++){
		for(int j = 0; j < h; j++){
			if(field[i][j] == false) ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() { cin >> N >> M; }

map<int, int> factorize(int n) {
  map<int, int> ret;
  int nn = n;
  for (int i = 2; i * i <= n; ++i) {
    while (nn % i == 0) {
      ret[i]++;
      nn /= i;
    }
  }
  if (nn != 1) ret[nn]++;
  return ret;
}
void solve() {
  map<int, int> m1 = factorize(N);
  map<int, int> m2 = factorize(M);
  int ans = 1;
  for (auto x : m1) {
    if (x.second >= 1) {
      if (m2[x.first] >= 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans (n);
    int count = 0;
    for(int rl=0; rl<2; rl++){
        for(int i=0; i<n; i++){
            if(s.at(i) == 'R') count++;
            else{
                ans.at(i) += count/2;
                ans.at(i-1) += (count+1)/2;
                count = 0;
            }
        }
        reverse(s.begin(),s.end());
        reverse(ans.begin(),ans.end());
        for(int i=0; i<n; i++){
            if(s.at(i) == 'L') s.at(i) = 'R';
            else s.at(i) = 'L';
        }
    }
    for(int a : ans){
        cout << a << endl;
    }
}

Measured memory_bytes: 1024
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
   //ll k,n,i;

    int main()
    {
          
          
          
    ll n;
    cin>>n;
    ll z=n*(n+1)/2;
    o(z)
    



    re
}

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

int main(void){
    int x;
    cin>>x;
    if(x>=30) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < s.length()-1; i++)
	{
		if(s[i] != s[i+1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
	string s;
	cin>>s;
	string sr=s,l,lr,r,rr;
	reverse(s.begin(),s.end());
	l=s.substr(0,s.size()/2);
	r=s.substr(s.size(),s.size()/2);
	lr=l,rr=r;
	reverse(l.begin(),l.end());
	reverse(r.begin(),r.end());
	if(s==sr&&l==lr&&r==rr)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int V[100005];
int N;
int solve(int st,int dr)
{
    if(st>dr)return 0;
    if(st==dr)return V[st]==st;
    int op=0;
    if(V[st]==st)
    {
        swap(V[st],V[st+1]);op++;
    }
    if(V[dr]==dr)
    {
        swap(V[dr],V[dr-1]);op++;
    }
    return op+solve(st+1,dr-1);
}
int main()
{
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        cin>>V[i];
    }
    cout<<solve(1,N);
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  unsigned long long int n,i,a[1000000]={0},x,sum=0,y;
   scanf("%llu %llu\n",&n,&x);
   
   for(i=0;i<n;i++)
   {
      scanf("%llu",&a[i]);
      sum+=a[i];
    
   }
   if(a[0]>x){
       a[0]=x;
   }
 for(i=0;i<n-1;i++)
 {
     y=a[i]+a[i+1];
     if(y>x)
     {
         a[i+1]=x-a[i];
     }
 }
 for(i=0;i<n;i++)
 {
     sum-=a[i];
 }
 printf("%llu",sum);
    return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <bits/stdc++.h>
#define loop(i,N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int

using namespace std ;

int main()
{
    int n;
    cin >> n;
    string s=to_string(n);
    int k=0;
    loop(i,s.size()){
        k+=s[i]-'0';
    }
    cout<<(n%k==0?"Yes":"No")<<endl;
    return 0;
}



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

using namespace std;

typedef long long int ll;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  
  ll d = min(a, b);
  ll e = min(max(a, b), c);
  
  cout << (d*e)/2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main(){
	string s ;
	cin >> s ;
	int r = 1 ;
	int p = 0 ;
	int win = 0;
	if(s[0]=='p')
	 win--;
	for(int i =1 ; i < s.size() ; i++){
	     if( r > p){
	     	if(s[i] == 'g')
	     	    {
	     	    	p++;
	     	    	win++;
				 }
	     	 else {
	     	 	  p++;
			  }
		 }
		 else if(r==p){
		     r++;
			 if(s[i]=='p')
			  win--;		 	  
		 }
		
	}
	cout << win << endl;
}


Measured memory_bytes: 3728
#include <stdio.h>

unsigned long long str[100001];

int main()
{
    unsigned long long n, sum=1, a, i, flag=1, tmp=1;
    scanf("%llu", &n);
    for (i=0; i<n; i++) {
        scanf("%llu", &str[i]);
        if (str[i]==0) flag=0;
    }
    if (flag) {
        for (i=0; i<n; i++) {
            if (str[i]>(1000000000000000000)/sum) {
                tmp=0;
                break;
            }
            sum=sum*str[i];
        }
        if (tmp) printf("%llu\n", sum);
        else puts("-1");
    }
    else puts("0");
    return 0;
}


Measured memory_bytes: 2504
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int[] arr = r.ria();
		int sum = (arr[0]-arr[2])/(arr[1]+arr[2]);
		print(sum);		
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

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

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

void mult(ll a[matmax][matmax], ll b[matmax][matmax], ll c[matmax][matmax], int m, int n, int p)
{
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= p; j++)
		{
			c[i][j] = 0;
			for (int k = 1; k <= n; k++)
			{
				c[i][j] += (a[i][k]*b[k][j])%mod;
				c[i][j] %= mod;
			}
		}
	}
}

void mat_pow(ll a[matmax][matmax], ll c[matmax][matmax], int n, ll p)
{
	if (p == 0)
	{
		for (int i = 1; i <= n; i++)
			c[i][i] = 1;
	}
	else if (p == 1)
	{
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= n; j++)
				c[i][j] = a[i][j];
		}
	}
	else
	{
		ll d[matmax][matmax];
		mat_pow(a, d, n, p/2);
		if (p % 2)
		{
			ll e[matmax][matmax];
			mult(d, d, e, n, n, n);
			mult(e, a, c, n, n, n);
		}
		else
		{
			mult(d, d, c, n, n, n);
		}
	}
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

ll n, d;

int main()
{
	fastio;		
	cin>>d>>n;
	ll smallest;
	if (d == 0)
	{
		smallest = n;
		if (n == 100)
			smallest = 101;
	}
	else if (d == 1)
	{
		smallest = 100;
		smallest *= n;
		if (n == 100)
			smallest = 101*100;
	}
	else
	{
		smallest = 10000;
		smallest *= n;
		if (n == 100)
			smallest = 101*10000;
	}


	cout<<smallest<<endl;

	return 0;
}


Measured memory_bytes: 256
import fractions

N,M=map(int,input().split())
g=fractions.gcd(N,M)

a=N//g;b=M//g

S=input();T=input()

f=True
for k in range(g):
    if S[k*a]!=T[k*b]:
        f=False
        break

print(a*b*g if f else -1)

Measured memory_bytes: 65260
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  sort(all(A));
  vector<ll> sum(n+1);
  rep(i, n) sum[i+1] = sum[i] + A[i];
  rrep(i, n) {
    if(i == n-1) continue;
    int j = upper_bound(all(A), sum[i+1]*2) - begin(A);
    if(j == i+1) {
      cout << n-i-1 << endk;
      return 0;
    }
  }
  cout << n << endk;
  return 0;
}


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

using namespace std;

static const int MAX = 200000;

int main() {
    long int R[MAX], n;

    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> R[i];

    long int maxv = -1'000'000'000;
    long int minv = R[0];

    for ( long int i = 1; i < n; i++ ) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 4624
#include <bits/stdc++.h>
//#include <iostream>
//#include <string>
//#include <sstream>
//#include <vector>
//#include <algorithm>
//#include <map>
//#include <set>
//#include <math.h>
//#include <unordered_map>
//#include <queue>
//#include <stack>
//#include <iomanip>

using namespace std;

#define PI 3.141592653589793238462643383279502884
#define Max 100005
#define ll long long
#define mod 2
#define EPS 1E-9

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a,b;
	cin >> a >> b;
	cout << (a+b)%24 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

main()
{
    string s1,s2;
    cin>>s1>>s2;
    ll x=s2.size();
    ll cnt,ans=0,l;
    for(ll i=0;i+x-1<s1.size();i++)
    {
        cnt=0;
        l=0;
        for(ll j=i;j<i+x and j<s1.size() ;j++)
        {
            if(s1[j]==s2[l]) cnt++;

            l+=1;
        }
        ans=max(ans,cnt);
    }
    cout<<x-ans<<endl;
}



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

void shuffle(char *cards, int h) //sのh文字目までをs1,sのh文字目以降をs2コピーし、順番を入れ替えて連結
{
    // char s1[201] = {0};
    // strncpy(s1, cards, h);
    char s2[201] = {0};
    int len = strlen(cards);
    strcpy(s2, (cards + h));
    strncpy((s2 + (len - h)), cards, h);
    //strcat(s2, s1);
    strcpy(cards, s2);
}

int main(void)
{
    while (1)
    {
        char cards[201];
        scanf("%s", cards);
        if (cards[0] == '-')
        {
            break;
        }
        int m;
        scanf("%d", &m);
        for (int i = 0; i < m; i++)
        {
            int h;
            scanf("%d", &h);
            shuffle(cards, h);
        }
        printf("%s\n", cards);
    }

    return 0;
}



Measured memory_bytes: 2044
#include<iostream>
#include<string>
//#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N,center;
	cin >> N;
	center = N / 2;
	vector<LLI>vec(N);
	for (int i = 0; i < N;i++) {
		LLI a;
		cin >> a;
		vec[i] = a;
	}
	auto vecs = vec;
	sort(vecs.begin(), vecs.end());
	LLI MED = vecs[center];
	for (int i = 0; i < N;i++) {
		if (MED > vec[i]) {
			cout << vecs[center] << endl;
		}
		else if (MED < vec[i]) {
			cout << vecs[center - 1] << endl;
		}
		else {
			cout << vecs[center - 1] << endl;
		}
	}
}

Measured memory_bytes: 5376
#include <string>
#include <string.h>
#include <iostream>
#include <queue>
#include <math.h>
#include <stdio.h>
using namespace std;
const int mod = 100000000;
int dp[20200];
int main()
{
	int a,b,c,x;
	int ans= 0;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x){
					ans++;
				}
			}
		}
	}
	printf("%d\n",ans);


	return 0;
}


Measured memory_bytes: 256
#include "iostream"

using namespace std;

int main() {

	int n, q;
	int s[100000], t[50000];

	int a = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> t[i];
	}

	int head, mid, tail;


	for (int i = 0; i < q; i++) {
		head = 0;
		tail = n;
		mid = (head + tail) / 2;
		while (tail != head) {
			if (s[mid] > t[i]) {
				tail = mid;
			}
			else if (s[mid] < t[i]) {
				head = mid + 1;
			}
			else {
				a++;
				break;
			}
			mid = (head + tail) / 2;
		}
	}

	cout << a << endl;

	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int flag = 1;
  rep(i,s.size()) {
    if (s.at(i) != t.at(i)) flag = 0;
  }
  if (flag == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int i, N, K, x, count=0, ans=0;
  
  cin >> x;
  
  if(x==0) cout << 1;
  else cout << 0;
}
  



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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n, b);
    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]))

print(ans * 2 * math.factorial(n-1) / math.factorial(n))


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

int main(){
  int a,b,c=0;
  scanf("%d%d",&a,&b);
  for (int i = 1; i < a; i++) {
    for (int j = 1; j < 31; j++) {
      if (i==j) {
        c++;
      }
    }
  }
  if (a<=b) c++;
  printf("%d\n",c);
}


Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/maxflow>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;
namespace ac = atcoder;

int main() {
    int n,m; cin >> n >> m;
    vector<string> da(n);
    auto in_table = [&](int x, int y){return 0 <= x && x < n && 0 <= y && y < m;};
    rip(i,n,0) cin >> da[i];
    ac::mf_graph<int> g(n*m+2);
    rip(i,n,0) rip(j,m,0) {
        if(da[i][j] == '#') continue;
        int now = i*m+j+1;
        if((i^j)&1) {
            g.add_edge(0, now, 1);
            if(in_table(i,j+1)) g.add_edge(now, now+1, 1);
            if(in_table(i+1, j)) g.add_edge(now, now+m, 1);
        }
        else {
            g.add_edge(now, n*m+1, 1);
            if(in_table(i,j+1)) g.add_edge(now+1, now, 1);
            if(in_table(i+1, j)) g.add_edge(now+m, now, 1);

        }
    }

    cout << g.flow(0, n*m+1) << '\n';
    auto e = g.edges();
    auto ans = da;
    rip(i,e.size(),0) {
        if(e[i].from != 0 && e[i].to != n*m+1 && e[i].flow == 1) {
            int a = e[i].from-1, b = e[i].to-1;
            if(a > b) swap(a, b);
            if(b-a == m) {
                ans[a/m][a%m] = 'v';
                ans[b/m][b%m] = '^';
            }
            else {
                ans[a/m][a%m] = '>';
                ans[b/m][b%m] = '<';
            }
        }
    }
    rip(i,n,0) cout << ans[i] << '\n';
}

Measured memory_bytes: 5496
import java.util.Scanner;
import java.util.HashSet;

class Main{
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int preCounter = 0;
    int counter = 0;

    for(int i = 1; i < N; i++) {
      String mae = S.substring(0, i);
      String ato = S.substring(i, N);
      mae = removeDup(mae);
      ato = removeDup(ato);
      


      preCounter = 0;


      for(int n = 0; n < mae.length(); n++) {

        char maemoji = mae.charAt(n);

        for(int t = 0; t < ato.length(); t++) {
          char atomoji = ato.charAt(t);
          if (maemoji == atomoji) {
            preCounter++;
          }
        }
      }
      if(counter < preCounter) {
        counter = preCounter;
      }
    }
    System.out.println(counter);
    return;
  }

  private static String removeDup(String str){
    String result = new String("");

    for (int i = 0; i < str.length(); i++) {
        if (!result.contains("" + str.charAt(i))) {
            result += "" + str.charAt(i);
        }
    }

    return result;
  }
}


Measured memory_bytes: 24020
/*
   ~~~~~~~~~~~~~~~~~~~
   \  |\/| | |\ | |  /
   /  |  | | |/ |_|  \
   ~~~~~~~~~~~~~~~~~~~
*/
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#define pf push_front
#define lb lower_bound
#define up upper_bound
#define mp make_pair
#define sp setprecision
#define ll long long
using namespace std;
int main()
{	
	 ll s[6],i;
	 cin>>s[0]>>s[1]>>s[2]>>s[3]>>s[4];
	 for(i=0;i<5;i++){
	 	if(s[i]==0) {cout<<i+1<<endl;break;}
	 }
	return 0;
}

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

int main(void){
	int i,j,a[2025],n;
	ll ans=0,sum=0,mx,tmp;
	bitset<4444444> dp;
	cin >> n;
	for(i=0; i<n; i++){
		cin >> a[i];
		sum += a[i];
	}
	dp[0] = 1;
	for(i=0; i<n; i++){
		dp |= (dp<<a[i]);
	}
	ans = (sum+1)/2;
	while(dp[ans]==0){
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1920
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")

#pragma GCC target("popcnt,abm,mmx,tune=native")

#include <bits/stdc++.h>

#define ll long long

#define fi first

#define se second

#define pb push_back

#define sqr(x) (ll)(x)*(x)

#define inf LLONG_MAX

#define $ ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

#define mod 1000000007

#define Mod 998244353

#define MOD 1234567891

#define pi acos(-1)

using namespace std;

ll n, i, j;

main()
{$
    cin >> n;

    for (i=1; i<=9; i++) for (j=1; j<=9; j++) if (i*j==n) return cout << "Yes", 0;

    cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            auto iter = lower_bound(L.begin(), L.end(), L[j] - L[i] + 1);
            int k = iter - L.begin();
            // cout << L[i] << " " << L[j] << " " << L[j] - L[i] << "\n";
            // cout << i - k<< "\n";
            ans += max(0ll, (ll)i - k);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath> 
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=19260817;
int s[MOD];
bool pr[MOD];
int main()
{
	memset(pr,true,sizeof(pr));
	int n;
	int l,r;
	cin>>n;
	for(int i=2;i<=1e6;i++)
	{
		if(!pr[i])continue;
		for(int j=i*2;j<=1e6;j+=i)
		{
			pr[j]&=0;
		}
	}
	pr[1]=false;
	pr[0]=false;
	/*
	for(int i=1;i<=1e6;i++)
	{
		if(pr[i])cout<<i<<" ";
	}
	*/
	for(int i=1;i<=1e6;i++)
	{
		if(pr[i]&&pr[(i+1)/2])s[i]=s[i-1]+1;
		else s[i]=s[i-1];
	}
	//for(int i=1;i<=10;i++)cout<<i<<":"<<s[i]<<endl;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		cout<<s[r]-s[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, arr[100000], dp[100000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    dp[0] = 0, dp[1] = abs(arr[0] - arr[1]);
    for (int i = 2; i < n; i++)
        dp[i] = min(dp[i - 2] + abs(arr[i] - arr[i - 2]), dp[i - 1] + abs(arr[i] - arr[i - 1]));
    cout << dp[n - 1] << '\n';

    return 0;
}


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

ll solve(int i, ll left, ll sum) {
  return s[i] == '\0'
    ? left+sum
    : solve(i+1, left*10 + (s[i]-'0'), sum) + solve(i+1, s[i]-'0', sum + left);
}

int main() {
  cin >> s;
  cout << solve(1, s[0]-'0', 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int f=1000000000,ss=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++) {
		if(s[i]=='A')
			f=min(f,i);
		if(s[i]=='Z')
			ss=max(ss,i);
	}
	cout<<max(0,ss-f+1);
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int n, X, w[110], res;
long long S;
int main() {
	int i;
	scanf("%d%d", &n,&X);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		S += w[i];
	}
	sort(w + 1, w + n + 1);
	if (S == X) {
		printf("%d\n", n);
		return 0;
	}
	S = 0;
	for (i = 1; i < n; i++) {
		S += w[i];
		if (S <= X) res = i;
	}
	printf("%d\n", res);
}

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


int main() {
  int y,m,d; char c1,c2; 
  cin >> y >> c1 >> m >> c2 >> d;
  if (m <= 4) cout << "Heisei";
  else cout << "TBD";
  cout << endl;

}
  


Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder s = new StringBuilder(br.readLine());
    String t = br.readLine();
    
    for(int i = 0; i < s.length(); i++) {
      char c = s.charAt(0);
      s.deleteCharAt(0);
      s.append(c);
      
      if(t.equals(s.toString())) {
        System.out.println("Yes");
        return;
      }
    }
    
    System.out.println("No");
  }
}


Measured memory_bytes: 22996
N = int(input())
P = list(map(int, input().split()))

lst = []
ans = 0
for e,p in enumerate(P,1):
    if e == p:
        ans += 1

        if e < N:
            P[e] = 0
print(ans)
exit(0)

st = False
ans = 0
for a,b,c in zip(lst[::2], lst[1::2] + [-1], lst[2::2] + [-1, -1]):
    print(a,b,c)
    if b == -1:
        if st:
            break
        ans += 1
        break

    if c == -1:
        if not st and a +1 == b:
            ans += 1
        elif st :
            ans += 1
        else:
            ans += 2
        break

    if not st and a+1 == b:
        ans += 1
        continue
    if not st and b+1 == c:
        st = True
        ans += 1
    if st and b+1 == c:
        ans += 1

    st = False
    ans += 2
print(ans)




Measured memory_bytes: 52716
def gcd(c, d):
    if c < d:
        return gcd(d, c)
    
    while d != 0:
        s = c % d
        c = d
        d = s
        
    return c
    
def lcm(c, d):
    return c * d // gcd(c, d)

A, B, C, D = map(int, input().split())


c = B // C - A // C if A % C == 0 else B // C - (A // C + 1)
d = B // D - A // D if A % D == 0 else B // D - (A // D + 1)

LCM = lcm(C, D)

LCM = B // LCM - A // LCM if A % LCM == 0 else B // LCM - (A // LCM + 1)

c += 1
d += 1
LCM += 1

#print(c, d, LCM)

print(B - A + 1 - c - d + LCM)

Measured memory_bytes: 3064
def show(nums):
    for i in range(len(nums)):
        if i != len(nums)-1:
            print(nums[i],end=' ')
        else:
            print(nums[i])

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

for i in range(N):
    minj = i
    for j in range(i,N):
        if A[j] < A[minj]:
            minj = j
    tmp = A[i]
    A[i] = A[minj]
    A[minj] = tmp
    if i != minj:
        count += 1

show(A)
print(count)



Measured memory_bytes: 5608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program {
    static void Main(string[] args) {
        List<string> input = Console.ReadLine().Split(' ').ToList();

        StringBuilder s = new StringBuilder();
        s.Append(input[1]);
        s.Append(input[0]);
        Console.WriteLine(s);
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    double a;
    cin >> a;
    printf("%.10f %.10f\n", pi*a*a, 2*pi*a);
    return 0;
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;


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


  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if (e - a <= k) pr("Yay!");
  else pr(":(");

  return 0;
}


Measured memory_bytes: 256
def factorial_mod(n, mod):
  a = 1
  for i in range(1, n + 1):
    a *= i
    a %= mod
  return a

def comb_mod(n, k, mod):
  if k > n or k < 0:
    return 0
  fact_n = factorial_mod(n, mod)
  fact_k = factorial_mod(k, mod)
  fact_n_k = factorial_mod(n - k, mod)
  return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod

n,k=map(int,input().split())
MOD=10**9+7
for i in range(1,k+1):
  print((comb_mod(n-k+1,i,MOD)*comb_mod(k-1,i-1,MOD))%MOD)


Measured memory_bytes: 3316
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll n;cin>>n;
	vi a(n);
	ll cnt=0;
	rep(i,0,n)
	{
		ll x;cin>>x;
		if(!(i&1) && (x&1))cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int a=read(),b=read();
	a*=b;
	if (a&1) printf("Yes\n");
	else printf("No\n"); 
	return 0;
}

Measured memory_bytes: 256