akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N, x[100001], L, Next[100001], Used[100001][2], Q, a, b;
vector<int>v[100001];


int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> x[i];
	}
	cin >> L;
	int r = 1;
	for (int i = 1; i <= N; i++) {
		while (x[i] + L >= x[r] && r <= N) {
			r++;
		}
		Next[i] = r - 1;
	}
	for (int i = 1;; i = Next[i]) {
		Used[i][0] = 1;
		Used[i][1] = v[1].size();
		v[1].push_back(i);
		if (i == N)break;
	}
	for (int i = 2; i <= N; i++) {
		if (Used[i][0])continue;
		for (int j = i;; j = Next[j]) {
			if (Used[j][0]) {
				v[i].push_back(j);
				break;
			}
			Used[j][0] = i;
			Used[j][1] = v[i].size();
			v[i].push_back(j);
		}
	}
	cin >> Q;
	while (Q--) {
		cin >> a >> b;
		if (a > b)swap(a, b);
		int ans = 0;
		while (a != b) {
			if (v[Used[a][0]].back() < b) {
				ans += v[Used[a][0]].size() - Used[a][1] - 1;
				a = v[Used[a][0]].back();
			}
			else {
				ans += lower_bound(v[Used[a][0]].begin(), v[Used[a][0]].end(), b) - v[Used[a][0]].begin() - Used[a][1];
				break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 7424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            if(a == b + c || b == a+c||c == a+b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n;
  cin >> n;
  cout << (n+1) * n / 2 << endl;

}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,p[22],cnt;
void solve(){
    cin>>n;
    rep(i,1,n+1) cin>>p[i];
    rep(i,2,n){
        vi v;
        v.pb(p[i-1]);
        v.pb(p[i]);
        v.pb(p[i+1]);
        sort(all(v));
        if(v[1]==p[i]) cnt++;
    }
    cout<<cnt<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int n,x;

inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<='0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}

int main(){
	n = read(),x = read();
	int* arr = new int[n];
	for(int i = 0;i < n;++i){
		arr[i] = read();
	}
	
	sort(arr,arr+n);
	
	int ans = 0;
	int i = 0;
	for(i = 0;i < n;++i){
		if(arr[i] <= x){
			x -= arr[i];
			ans++;
		}else{
			break;
		}
	}
	if(i == n && x)cout << n-1;
	else
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
a = []

data = 2019

if r - l + 1 >= 2019:
    print(0)
    exit()

else:
    for i in range(l, r + 1):
        for j in range(i+1, r + 1):
            data = min(data, i * j % 2019)

print(data)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0; i<(int)(n); i++)
ll int n,m;
ll int x[1001],y[1001],z[1001];
int main(){
    int n;
    int ans = 0;
    cin >> n;
    REP(i,n){
    	int a;
    	cin >> a;
    	while(1){
    		if(a%2==1) break;
    		a/=2;
    		ans++;
    	}
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
x.sort()

xmin = x[0]
xmax = x[-1]
ans = 10**9
for i in range(xmin, xmax+1):
    d = 0
    for j in x:
        d += (j - i)**2
    ans = min(ans, d)
print(ans)

Measured memory_bytes: 9112
#include <iostream>

using namespace std;

int main()
{
  int N;
  int count;
  cin >> N;

  for (int i = 1; ;i++) {
    count = 0;
    for (int j = 1; j <= i/2; j++) {
      if (!(i % j)) count++;
    }
    if (count == N - 1) {
      cout << i << endl;
      break;
    }
  }
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);


void merge(long long a1[],long long len_a1,long long a2[],long long len_a2,long long a[]){
    long long i = 0,j = 0;
    while(i<len_a1 || j<len_a2){
        if(j>=len_a2 || (i<len_a1 && a1[i]<a2[j])){
            a[i+j] = a1[i];
            i++;
        }else{
            a[i+j] = a2[j];
            j++;
        }
    }
}
void mergeSort(long long a[],long long len_a){
    if(len_a > 1){
        long long m = len_a/2;
        long long n = len_a - m;
        long long a1[m];
        long long a2[n];
        for(long long i = 0;i < m;i++) a1[i] = a[i];
        for(long long i = 0;i < n;i++) a2[i] = a[m+i];
        mergeSort(a1,m);
        mergeSort(a2,n);
        merge(a1,m,a2,n,a);
    }
}
 
//////////////////////////////////////////

int X,Y,Z,K;

int main(){
    scanf("%d%d%d%d",&X,&Y,&Z,&K);
    long long A[X],B[Y],C[Z];
    for(int i = 0;i < X;i++){
        scanf("%lld",&A[i]);
    }
    for(int i = 0;i < Y;i++){
        scanf("%lld",&B[i]);
    }
    for(int i = 0;i < Z;i++){
        scanf("%lld",&C[i]);
    }

    long long oishi[X*Y];
    for(int i = 0;i < X;i++){
        for(int j = 0;j < Y;j++){
            oishi[i*Y + j] = A[i] + B[j];   
        }
    }
    mergeSort(oishi,X*Y);
    long long os[X*Y];
    for(int i = 0;i < X*Y;i++){
        os[i] = oishi[X*Y-i-1];
        //printf("%lld\n",os[i]);
    }

    int R = min(K,X*Y);

    long long L[R*Z];
    for(int i = 0;i < R;i++){
        for(int j = 0;j < Z;j++){
            L[i*Z + j] = os[i] + C[j];
        }
    }
    mergeSort(L,R*Z);
    long long l[R*Z];
    for(int i = 0;i < R*Z;i++){
        l[i] = L[R*Z-i-1];
    }
    for(int i = 0;i < K;i++){
        printf("%lld\n",l[i]);
    }
    
    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


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

int main(void)
{
    int A, B, C, D;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;

    int sum = 0;
    if(A > B)
        sum += B;
    if(A <= B)
        sum += A;
    if(C > D)
        sum += D;
    if(C <= D)
        sum += C;

    cout << sum << endl;      
   return 0;
}


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

int k, s, c;
int main() {
    int i, j, x;
    cin >> k >> s;
    for(i=0; i<=k; i++) for(j=0; j<=k; j++) {
        x = s - i - j;
        if(x >= 0 && x <= k) c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

n, m = map(int, input().split())
ab = [0] * m
for i in range(m):
    a, b = map(int, input().split())
    ab[i] = (a, b)

ans = 0
pattern = list(itertools.permutations(list(range(2, n+1))))
for i in pattern:
    li = list(i)
    li.insert(0, 1)
    pattern_check = True
    for j in range(0, n-1):
        path_check = False
        for k in range(m):
            if len({li[j], li[j+1]} & set(ab[k])) == 2:
                path_check = True
                break
        if not path_check:
            pattern_check = False
            break
    if pattern_check:
        #print(li)
        ans += 1
print(ans)

Measured memory_bytes: 3572
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;;
using ll = long long;
int A[3][3], flag[3][3] = {};
int main() {

	rep(i, 3) rep(j, 3) cin >> A[i][j];

	int N;
	cin >> N;

	int x;

	rep(ni, N) {
		cin >> x;
		rep(i, 3) rep(j, 3) if (A[i][j] == x) { flag[i][j] = 1; }
	}
	bool ans = false;

	rep(i, 3) {
		int cnt = 0;
		rep(j, 3) cnt += flag[i][j];
		if (cnt == 3) { ans = true; }
	}
	rep(i, 3) {
		int cnt = 0;
		rep(j, 3) cnt += flag[j][i];
		if (cnt == 3) { ans = true; }
	}
	int cnt = 0;
	rep(i, 3) {
		cnt += flag[i][i];
		if (cnt == 3) { ans = true; }
	}
	 cnt = 0;
	rep(i, 3) {
		cnt += flag[i][2-i];
		if (cnt == 3) { ans = true; }
	}
	puts(ans ? "Yes" : "No");
	return 0;
}

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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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


int main() {
    INIT();
    int n,tmp = 0,result = 0,countRed = 0;

    cin >> n;
    vector<char> c(n);
    stack<int> st;
    for(int i = 0; i < n; i++) {
        cin >> c[i];
        if(c[i] == 'R') {
            st.push(i);
            countRed++;
        }
    }
    for(int i = 0; i < n; i++) {
        if(c[i] == 'W') {
            if(!st.empty() && st.top() > i) {
                tmp++;
                c[st.top()] = 'W';
                st.pop();
                c[i] = 'R';
            }
        }
    }
    cout << tmp;
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b;
    cin >> a >> b;
    int n = stoi(a + b);
    bool f = false;
    for(int i = 1; i * i <= n; i++){
        if(i * i == n) f = true;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;
const int N = 100010;
int _w;

int n, a[N];
map<int,int> cnt;

int main() {
	_w = scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		_w = scanf( "%d", a+i );
	for( int i = 1; i <= n; ++i )
		++cnt[a[i]];
	if( cnt.size() == 1 && cnt.begin()->first == 0 ) {
		puts("Yes");
	} else {
		if( n % 3 == 0 ) {
			if( cnt.size() == 3 ) {
				auto it = cnt.begin();
				int x = it->first;
				int xc = it->second;
				++it;
				int y = it->first;
				int yc = it->second;
				++it;
				int z = it->first;
				int zc = it->second;
				if( (x ^ y ^ z) == 0 && xc == yc && xc == zc ) {
					puts("Yes");
				} else {
					puts("No");
				}
			} else if( cnt.size() == 2 ) {
				auto it = cnt.begin();
				int x = it->first;
				int xc = it->second;
				++it;
				int y = it->first;
				int yc = it->second;
				if( x == 0 && yc == xc + xc ) {
					puts("Yes");
				} else {
					puts("No");
				}
			} else {
				puts("No");
			}
		} else {
			puts("No");
		}
	}
	return 0;
}


Measured memory_bytes: 7564
A = [0]*3
for i in range(3):
    A[i] = list(map(int,input().split()))
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))
             
for k in range(3):
    for j in range(3):
        if A[k][j] in B:
             A[k][j] = 0
answer = 'No'
for i in range(3):
    if sum(A[i])==0:
        answer = 'Yes'
        break
    count = 0
    for j in range(3):
        count += A[j][i]
    if count == 0:
        answer = 'Yes'
if A[0][0]+A[1][1]+A[2][2]==0:
    answer = 'Yes'
if A[0][2]+A[1][1]+A[2][0]==0:
    answer = 'Yes'
print(answer)

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

main(){
  int N;
  cin >> N;
  for(int ii=N;ii<1000;ii++){
    //    cout << N/100 << " " << (N/10)%10 << " " << N%10 << endl;
    if(ii/100==(ii/10)%10 && ii/100==ii%10){
      cout << ii << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
use std::io::Read;

fn partition_point<Pred>(s: &[i32], pred: Pred) -> usize
where
    Pred: Fn(i32) -> bool,
{
    let mut left = 0;
    let mut right = s.len();
    while right - left > 0 {
        let mid = (left + right) / 2;
        if pred(s[mid]) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    right
}

fn solve(_n: usize, a: &mut [i32], b: &mut [i32], c: &mut [i32]) -> usize {
    a.sort();
    b.sort();
    c.sort();
    b.iter()
        .map(|&x| partition_point(a, |y| y < x) * (c.len() - partition_point(c, |y| y <= x)))
        .sum::<usize>()
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut a = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect::<Vec<_>>();
    let mut b = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect::<Vec<_>>();
    let mut c = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect::<Vec<_>>();
    let r = solve(n, &mut a, &mut b, &mut c);
    println!("{}", r);
}


Measured memory_bytes: 6528
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;
map<ll,int> M;
int main()
{
	int n;scanf("%d",&n);
	ll x,s=0,ans=0;
	for(;n--;)
	{
		scanf("%lld",&x);
		s+=x;
		ans+=M[s];
		M[s]++;
	}
	printf("%lld\n",ans+M[0]);
	return 0;
}

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

using namespace std;

int main(void){
    int n; cin >> n;
    int S[n];
    for(int i = 0; i < n; i++) cin >> S[i];
    int q; cin >> q;
    int T[q];
    for(int i = 0; i < q; i++) cin >> T[i];

    int sum = 0;
    for(int i = 0; i < q; i++){
        if(*lower_bound(S, S+n, T[i]) == T[i]){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
    int N;
    int P[200000];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> P[i];

    int min = N + 1;
    int count = 0;
    for (int i = 0; i < N; ++i) {
        if (P[i] < min) {
            count++;
            min = P[i];
        }
    }
    cout << count;
    return 0;
}


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

string dp[10100];
 
void chmax( string &s, string t){ //string としての比較に注意
  if( s == "-"){ s = t;}
  else if( t.size() > s.size()){ s = t;} 
  else if( t.size() == s.size()){ //サイズが同じな時は数字として比較できる
    s = max(s,t);}
  
  return;
}

int match[] = {0,2,5,5,4,5,6,3,7,6};
              
int main(){
  int N,M; cin >> N >> M;
  vector<char> A(M); for(int i = 0; i < M; i++){ cin >> A[i];}
  
  for(int i = 0; i < 10100; i++){ dp[i] = "-";} // "-"は不可能
  
  dp[0] = "";
  
  for(int i = 0; i < 10010; i++){
    for(int j = 0; j < M; j++){
      if(dp[i] == "-"){ continue;}
      
      chmax( dp[i+match[A[j]-'0']], dp[i] + A[j]); }}
                
  cout << dp[N] << endl; return 0;}


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

int main(void)
{
    long N, k;
    cin >> N >> k;
    vector<long long> a(N, 0);
    
    for(long i=0; i<N; i++)
    {
        cin >> a[i];
    }
    
    for(long i=0; i<N-k; i++)
    {
        if(a[i] < a[i+k])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=2e5+20;
vector<ll> v;
ll n,k,dp[2500];
ll powmod(ll x,ll n)
{
	ll s=1;
	while(n)
	{
		if(n&1)
			s=(s*x)%mod;
		n>>=1;
		x=(x*x)%mod;
	}
	return s;
}
void init()
{
	v.clear();
	for(ll i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			v.push_back(i);
			if(i*i!=n)
				v.push_back(n/i);
		}
	}
	sort(v.begin(),v.end());
}
int main()
{
	while(cin>>n>>k)
	{
		init();
		ll ans=0;
		for(int x=0;x<v.size();x++)
		{
			dp[x]=powmod(k,(v[x]+1)/2);
			for(int y=0;y<x;y++)
			{
				if(v[x]%v[y]==0)
					dp[x]=(dp[x]-dp[y]+mod)%mod;	
			}	
			if(v[x]%2)
				ans=(ans+(dp[x]*v[x])%mod)%mod;
			else
				ans=(ans+(dp[x]*v[x]/2)%mod)%mod;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
p = [1]*51
t = [1]*51
def f(n,x):
    if n==0:
        return 1
    if x==1:
        return 0
    if x==t[n]:
        return p[n]
    if x==p[n]:
        return p[n-1]+1
    if x<p[n]:
        return f(n-1,x-1)
    return p[n-1]+f(n-1,x-p[n])+1

for i in range(1,51):
    p[i] = p[i-1]*2+1
    t[i] = t[i-1]*2+3
n,x = map(int,input().split())    
print(f(n,x))

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main(){
	int n;
	scanf("%d", &n);
	string s;
	cin >> s;
	bool dp[n + 1][11][11][11];
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= 10; j++){
			for (int k = 0; k <= 10; k++){
				for (int l = 0; l <= 10; l++){
					dp[i][j][k][l] = false;
				}
			}
		}
	}
	for (int i = 0; i <= n; i++){
		dp[i][10][10][10] = true;
	}
	for (int i = 1; i <= n; i++){
		for (int j = 0; j <= 10; j++){
			for (int k = 0; k <= 10; k++){
				for (int l = 0; l <= 10; l++){
					if (dp[i - 1][j][k][l]){
						dp[i][j][k][l] = true;
						if (j == 10){
							dp[i][k][l][s[i - 1] - '0'] = true;
						}
					}
				}
			}
		}
	}
	int count = 0;
	for (int j = 0; j < 10; j++){
		for (int k = 0; k < 10; k++){
			for (int l = 0; l < 10; l++){
				if (dp[n][j][k][l]){
					count++;
				}
			}
		}
	}
	printf("%d\n", count);
}

Measured memory_bytes: 39296
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int N,M;
int digit = 1;
int digitnum = 10;
int ans;
int main(){
  int N;
  cin >> N; 
  for(int i = 1; i <= N; i++){
    if(i % digitnum == 0){
      digitnum*=10;
      digit++;
    } 
    if(digit%2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
}


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

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

const int mo=924844033;
const int maxn=2003;

int f[maxn][maxn][2],fac[maxn],res[maxn],g[maxn],n,K,tot,tmp[maxn];
bool canr[maxn],canl[maxn];

void add(int &a,int b){
	a+=b;if(a>=mo)a-=mo;
}

int mul(int x,int y){
	return (1ll*x*y)%mo;
}

int main(){
	scanf("%d%d",&n,&K);
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=mul(fac[i-1],i);
	}
	res[0]=1;
	for(int r=0;r<2*K&&r<n;++r){
		int m=0;
		for(int i=r;i<n;i+=2*K){
			canl[m]=(i>=K);
			canr[m++]=(i<n-K);
		}
		for(int i=0;i<=m;++i)
			for(int j=0;j<=m;++j)
				f[i][j][0]=f[i][j][1]=0;
		f[0][0][0]=1;
		for(int i=0;i<m;++i){
			for(int j=0;j<=i;++j){
				for(int t=0;t<2;++t){
					int p=f[i][j][t];
					if(!p)continue;
					add(f[i+1][j][0],p);
					if(canl[i]&&t==0)
						add(f[i+1][j+1][0],p);
					if(canr[i])
						add(f[i+1][j+1][1],p);
				}
			}
		}
		for(int j=0;j<=m;++j)
			g[j]=(f[m][j][0]+f[m][j][1])%mo;
		for(int i=0;i<=tot+m;++i)tmp[i]=0;
		for(int i=tot;i>=0;--i)
			for(int j=0;j<=m;++j)
				add(tmp[i+j],mul(res[i],g[j]));
		tot+=m;
		for(int i=0;i<=tot;++i)res[i]=tmp[i];
	}
//	printf("%d\n",tot);
	int ans=0;
	for(int i=0;i<=tot;++i){
//		printf("%d %d\n",res[i],fac[i]);
		int v=mul(res[i],fac[n-i]);
		add(ans,i%2?mo-v:v);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 16128
#include "bits/stdc++.h"
using ll = long long;
using namespace std;
int main(){
ll N,M;
cin>>N>>M;
vector<ll> L(M);
vector<ll> R(M);
ll min=1,max=N;
ll tmp=0;
for(ll i=0;i<M;i++){
   cin>>tmp;
   if(tmp>min)
   min = tmp;
   cin>>tmp;
   if(tmp<max)
   max = tmp;
}
if(min>max)
printf("%d\n",0);
else
printf("%d\n",int(max-min+1));
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k, a;
  in(n);
  k = n / 11;
  a = n % 11;
  k = k * 2;
  if(0 < a && a < 7)
    k++;
  else if(6 < a)
    k = k + 2;
  out(k);
  memi;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int sum_digit(int i)
{
    int rev,s=0;
    while(i>0){
        rev =i%10;
        s=s+rev;
        i=i/10;
        }
    return s;
}
int main()
{
    int N,A,B,i,sum=0,j,p;
    scanf("%d %d %d",&N,&A,&B);
    for(i=1;i<=N;i++){
        p=sum_digit(i);
        if(p>=A && p<=B){
            sum= sum + i;
        }


    }
    printf("%d",sum);




    return 0;
}

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

using namespace std;

void solve(){
    int n,m;
    cin>>n>>m;
    vector <int> a(m);
    for(int i=0;i<m;i++)
        cin>>a[i];
    int sum=0;
    for(int x:a)
        sum+=x;
    if(sum<=n)
        cout<<n-sum;
    else
        cout<<-1;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3696
n, m = map(int, input().split())

a = []
for i in range(0,n):
    row = []
    row[:] = map(int,input().split())
    a.append(row)
    #print(a)

b = []
for i in range(0,m):
    b.append(int(input()))
    #print(b)

c = []
for i in range(0,n):
    ci = 0
    for j in range(0,m):
        ci += a[i][j]*b[j]
    c.append(ci)
    print(ci)



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

using namespace std;

#define fo(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define lli long long int
#define all(c) c.begin(),c.end()
#define lower(c) tolower(c)
#define upper(c) toupper(c)
#define max(c) *max_element(c.begin(),c.end())
#define min(c) *min_element(c.begin(),c.end())
#define len(c) c.size()
const int MOD = 1000000007;
const int MX = 2e5 + 5;
const int INF = 1e9 + 10;
const lli LINF = 1e18;

void solve() {
	string s,t;
	cin >> s >> t;
	long long c=0;
	//sort(all(s));
	//sort(all(t));
	fo(i,len(s))
		if(s[i]!=t[i])c++;
	cout << c;

}


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


    return 0;
}






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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
  

    int n;int k;cin>>n>>k;
    ll ans = k;
    k--;
    fore(i,0,n-1){
        ans*=k;

    }cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	long long A = 1, B=0, ans = 1, N;
	cin >> N;
	for (long i = 2; i <= sqrt(N); i++) {
		if (N % i == 0) {
			A = i;
		}
	}
	B = N / A;
	for (int i = 0; i < 11; i++) {
		B /= 10;
		if (B > 0)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

if n % 2 == 0:
    b = [0] * n
    for i in range(n):
        if i // 2 == 0:
            b[i] = a[i]
        else:
            if i % 2 == 0:
                b[i] = b[i - 2] + a[i]
            else:
                b[i] = max(b[i - 3], b[i - 2]) + a[i]
    print(max(b[-1], b[-2]))
else:
    b = []
    for i in range(2):
        temp = [0] * n
        b.append(temp)
    for i in range(n):
        if i // 2 == 0:
            b[0][i] = a[i]
        else:
            if i % 2 == 1:
                b[0][i] = max(b[0][i - 3], b[0][i - 2]) + a[i]
            else:
                b[0][i] = b[0][i - 2] + a[i]
                if i == 2:
                    b[1][i] = b[1][i - 2] + a[i]
                else:
                    b[1][i] = max(b[0][i - 4], b[0][i - 3], b[1][i - 2]) + a[i]
    print(max(b[1][-1], b[0][-2], b[0][-3]))

Measured memory_bytes: 105100
//自分用テンプレート・ライブラリ

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S; cin >> S;
  ll N = S.length(); 
  vector<ll> s(N); FOR(i,N){ s[i] = (S[i]-'0'); }
  
  //main
  ll ans = 0;
  
  if(N==101){
    for(int i=N-1; i>0; i--){
      if(s[i] >= 6){ 
        s[i-1]++; 
        ans += 10-s[i]+1; 
      }else{
        ans += s[i];
      }
    }
    
    ans += s[0]; 
    
    cout << ans << endl; return 0;
    
  }else{
    for(int i=N-1; i>0; i--){
      if(s[i] == 10){//s[i]=0~9。高々10。
        s[i-1]++;
      }else if(6 <= s[i] && s[i] <= 9){ 
        s[i-1]++; 
        ans += 10-s[i]; 
      }else if(s[i] == 5){
        if(s[i-1]>=5){
          s[i-1]++;
          ans += 10-s[i];
        }else{
          ans += s[i]; 
        }
      }else{
        ans += s[i];
      }
    }
    
    if(s[0] == 10){//s[i]=0~9。高々10。
      ans ++;
    }else if(6 <= s[0] && s[0] <= 9){ 
      ans += 10-s[0]+1; 
    }else{
      ans += s[0];
    }
    
    cout << ans << endl; return 0;
  }
  
  // output
  //cout << N << endl;

  return 0;
}

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

vl fac, finv, inv;

void com_init(const int MAX) {
  fac.resize(MAX);  fac[0] = fac[1] = 1;
  finv.resize(MAX); finv[0] = finv[1] = 1;
  inv.resize(MAX);  inv[1] = 1;
  for (int i=2; i<MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}

ll combination(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main() {
  int h, w, a, b; cin >> h >> w >> a >> b;
  com_init(h+w);
  ll ans = 0;
  rep(i,w-b) {
    int down = h-a-1, right = b+i;
    int down2 = a-1, right2 = w-b-1-i;
    (ans += combination(down + right, down) * combination(down2 + right2, down2) ) %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;



void mymain(){
    int n;
    cin >> n;
    set<int>s;
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
            s.insert(i*j);
    if(s.count(n)!=0)
        cout << "Yes" <<endl;
    else
        cout << "No" << endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
///cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}


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

bool is_prime[104730];

void eratos(int N) {
  is_prime[0] = false, is_prime[1] = false;
  for (int i = 2; i * i <= N; ++i) {
    if (is_prime[i]) {
      for (int j = i * i; j <= N; j += i) {
        is_prime[j] = false;
      }
    }
  }
}

int main() {
  for (int i = 0; i <= 104729; ++i) {
    is_prime[i] = true;
  }
  eratos(104729);
  vector<int> p;
  for (int i = 0; i <= 104729; ++i) {
    if (is_prime[i]) {
      p.push_back(i);
    }
  }

  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      return 0;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      ans += p[i];
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3340
x, y, a, b, c = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i).max(x)
qs = gets.split.map(&:to_i).max(y)
rs = gets.split.map(&:to_i).sort!

pqs = [*ps, *qs].sort!
ans = pqs.inject(:+)

[pqs.count, rs.count].min.times do |i|
  ans += rs[-1 - i] - pqs[i] if rs[-1 - i] >= pqs[i]
end
puts ans


Measured memory_bytes: 27280
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;

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

  cin >> s;

  if(s[0] == 'A'){
    cout << 'T' << endl;
  }else if(s[0] == 'T'){
    cout << 'A' << endl;
  }else if(s[0] == 'C'){
    cout << 'G' << endl;
  }else{
    cout << 'C' << endl;
  }
  return 0;
}



Measured memory_bytes: 256
while True:
    n = int(input())
    ans = 0
    if n == 0:
        break
    count = n
    for i in range(1, n):
        a = 0
        for j in range (i, n):
            a += j
            if a == n:
                ans += 1
                break
            if a > n:
                break
#    for i in range(2, n):
#        a = int(n / i)
#        print("a=", a)
#        b = a
#        for j in range(0,i-1):
#            a += 1
#            b += a
#        print("b=", b)
#        if a == b:
#            ans += 1
    print(ans)

Measured memory_bytes: 6720
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
  string s;
  cin >> s;
  int tmp=0;
  int tmp2=0;
  int sousa;
  bool r=true;
  bool temp;
  vector<int> v(s.size(),0);
  REP(i,s.size()){
    if(s[i]=='R'){
      if(r==false){
        r=true;
        if(temp==true){
          v[sousa]=tmp;
          v[sousa+1]=tmp2+1;
        }
        else{
          v[sousa]=tmp2;
          v[sousa+1]=tmp+1;
        }
        tmp=0;
        tmp2=0;
        if(i%2==0){
          tmp++;
        }
        else{
          tmp2++;
        }
      }
      else{
        if(i%2==0){
          tmp++;
        }
        else{
          tmp2++;
        }
      }
    }
    else{
      if(r==true){
        if(i%2==1){
          temp=true;
        }
        else{
          temp=false;
        }
        sousa=i-1;
        r=false;
      }
      else{
        if(i%2==0){
          tmp++;
        }
        else{
          tmp2++;
        }
      }
    }
  }
  if(r==false){
    r=true;
    if(temp==true){
      v[sousa]=tmp;
      v[sousa+1]=tmp2+1;
    }
    else{
      v[sousa]=tmp2;
      v[sousa+1]=tmp+1;
    }
  }
  REP(i,s.size()){
    cout << v[i];
    if(i==s.size()-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}

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

int main()
{
  string O, E;
  cin >> O >> E;
  for(int i=0; i<O.length(); ++i) {
    cout << O[i];
    if(i<E.length()) {
      cout << E[i];
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

int main(){
	int x,y;
	cin>>x>>y;
	if(x%y==0){
		cout<<-1<<endl;
	}else{
		cout<<x<<endl;
	}
}





Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

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

using namespace std;


int main() {
    string s;
    cin >> s;
    for(int i = 0;i < s.length() - 8;i++)
    {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 201;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

struct LB{
   ll x[65];
   void init(){
      memset(x,0,sizeof x);
   }
   void insert(ll v){
      nfr(i,63,0){
         if((v >> i)&1){
            if(!x[i]){
               x[i] = v; return ;
            } else v ^= x[i];
         }
      }
   }
   bool query(ll v){
      nfr(i,63,0){
         if((v >> i)&1){
            if(x[i])v ^= x[i];
            else return false;
         }
      }
      return true;
   }
}l;

int n,m;
ll a[N];
char s[N];
void solve(){
   scanf("%d",&n);
   fr(i,1,n)scanf("%lld",a+i);
   scanf("%s",s+1);
   l.init();

   bool flag = true;
   nfr(i,n,1){
      if(s[i] == '0')l.insert(a[i]);
      else flag &= l.query(a[i]);
   }
   printf("%d\n",flag^1);
}

int t;
int main(){
   scanf("%d",&t);
   while(t--)solve();
   return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

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

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

	string t=s;
	reverse(all(s));

	int ans=0;
	for (int i = 0; i < s.size(); i++){
		if(s[i]!=t[i])ans++;
	}

	cout<<ans/2<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
 
const ll mod = 1E9 + 7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N; cin >> N;
	vector<ll> a(N);
	int i;
	for(i = 0; i < N; i++) cin>>a[i];
	ll ans = 0, sum = 0;
	for(i = 0; i < N; i++) sum = sum + a[i];
	sum = sum % mod;
	ll sum2 = (sum * sum)%mod;
	ll sum3 = 0;
	for(i = 0; i < N; i++)
		sum3 = (sum3 + a[i]*a[i])%mod;
	ans = (((sum2 - sum3 + mod)%mod)*500000004)%mod;
	cout<<ans;
}


Measured memory_bytes: 4748
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  string s; cin >> s;
  map<char, int> mp;
  for(auto &x: s) {
    mp[x]++;
  }
  if(mp.size() != 2) {
    cout << "No\n";
    return;
  }
  for(auto &x: mp) {
    if(x.second != 2) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}


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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;

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

    if(s[2]==s[3] && s[4]==s[5]){
        puts("Yes");
    }else{
        puts("No");
    }
}

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

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

		int[] sides = new int[3];

		for (int i = 0; i < sides.length; i++) {
			sides[i] = sc.nextInt();
		}

		Arrays.sort(sides);

		System.out.println(sides[0] * sides[1] / 2);

		sc.close();
	}
}



Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<string>
long pow(long a, long n) {
	long ret = 1;
	for (; n > 0; n >>= 1, a = a * a) {
		if (n % 2 == 1)ret = ret * a;
	}
	return ret;
}


unsigned long long func(std::string S)
{
	unsigned long long ans = 0;
	int keta = S.size();
	int num[9] = { 0,0,0,0,0,0,0,0,0 };
	for (unsigned int i = 0; i < (1<<keta-1) ; ++i)
	{
		std::vector<int> Plus;
		for (int j = 0; j < keta; ++j)
		{
			if ( i & (1 << j))
			{

				Plus.push_back(1);
				
			}
			else
			{
				Plus.push_back(0);
			}
		}
		unsigned long long sum = 0;
		unsigned long long sum_temp = 0;
		for (int k = 0; k < keta; ++k)
		{
			sum_temp *= 10;
			sum_temp += S[k] - '0';
			if (Plus[k] == 1)
			{
				sum += sum_temp;

				sum_temp = 0;
			}
		}
		sum += sum_temp;

		ans += sum;
	}
	

	return ans;

	
}


int main()
{
	std::string S;
	std::cin >> S;

	
	std::cout << func(S) ;
	return 0;
}



Measured memory_bytes: 764
n, m, q = map(int, input().split())
queries = [tuple(map(int, input().split())) for _ in range(q)]
ans = 0

def calc_score(p):
    score = 0
    for a, b, c, d in queries:
        if p[b-1] - p[a-1] == c:
            score += d
    return score

def f(p):
    if len(p) == n:
        global ans
        ans = max(ans, calc_score(p))
        return
    l = p[-1] if len(p) else 1
    for x in range(l, m+1):
        p.append(x)
        f(p)
        p.pop()

f([])

print(ans)


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

int main(){
	int a,b,n;
	while(cin >> a >> b >> n){
		if(a >= b) a %= b;
		int sum = 0;
		for(int i = 0;i < n;i++){
			sum += a * 10 / b;
			a = a * 10 - (int)(a * 10 / b) * b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF
#define mp make_pair
#define pb

#define fi first
#define se second


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;
int s[30*2+10][30*2+10];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int main(){
	int t=0;
	while(1){
		t++;
		rep(y,70){
			rep(x,70){
				s[y][x]=-1;
			}
		}
		int w,h;
		cin >> w >> h;
		// cout << w << " " << h << endl;
	
		if(w==0) break;
		rep(y,h*2+1){
			rep(x,w*2+1){
				if(y==0||x==0||y==h*2||x==w*2){
					s[y][x] = -1;
				}else if(x%2==0 && y%2==0){
					s[y][x] = -1;
				}else if((x+y)%2==0){
					s[y][x] = 0;
				}else{
					cin >> s[y][x];
					if(s[y][x]==1) s[y][x]=-1;
				}
			}
		}
		// if(t==62){
		// 	cout << w << " " << h << endl;
		// 	rep(y,60){
		// 		rep(x,60){
		// 	 		printf("%c ",(s[y][x]==-1)? '#':' ');
		//  		}
		//  		cout << endl;
		// 	 }
		// 	 cout << endl;
		// }
		// rep(y,60){
		// 	rep(x,60){
		// 		printf("%c ",(s[y][x]==-1)? '#':' ');
		// 	}
		// 	cout << endl;
		// }
		// cout << endl;

		queue<pii> que;
		que.push(mp(1,1));

		queue<int> dist;
		dist.push(1);
		s[que.front().se][que.front().fi] = dist.front();
		while(!que.empty()){
			if(que.front().se == h*2-1 &&que.front().fi == w*2-1){
				break;
			}
			// cout << "@" << endl;
			rep(i,4){
				int nx = que.front().fi + dx[i];
				int ny = que.front().se + dy[i];
				if( nx>=0 && ny>=0 &&
					nx<w*2+1  && ny<h*2+1  &&
					s[ny][nx]==0){
					que.push(mp(nx,ny));
					s[ny][nx] = dist.front();
					dist.push(dist.front()+1);
				}
			}
			que.pop();
			dist.pop();
			// if(t==62){
			// 	rep(y,60){
			// 		rep(x,60){
			// 			printf("%2d ",s[y][x]);
			// 		}
			// 		cout << endl;
			// 	}
			// 	cout << endl;
			// }
		}
		// rep(y,60){
		// 	rep(x,60){
		// 		printf("%2d ",s[y][x]);
		// 	}
		// 	cout << endl;
		// }
		// cout << endl;
		if(s[h*2-1][w*2-1]==0){
			cout << 0 << endl;
		}else{
			cout << s[h*2-1][w*2-1]/2+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
//一括include
using namespace std;
int main()
{
    int n;
    int count = 0;
    int i = 0;
    cin >> n;
    int a[210] = {};
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    while (true)
    {
        if (a[i] % 2 == 0)
        {
            a[i] = a[i] / 2;
            i++;
        }
        else
            break;
        if (i == n)
        {
            count++;
            i = 0;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll m,N,dp[100001],h[100002],K;
  cin >> N >> K;
  h[0] = 0;
  REP(i,N)cin >> h[i+1];
  dp[1] = 0;
  dp[2] = abs(h[2] -h[1]);
  for(int i=3;i<=N;i++){
    m = INF_INT;
    for(int j=1;j<=K;j++)
      if(i-j >= 1){
        m = min(m,dp[i-j]+abs(h[i-j]-h[i]));
      }else
        break;
    dp[i] = m;
  }
  cout << dp[N] << endl;
  return 0;
}



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

using lint = long long;

int main() {
    lint L;
    int N;
    std::cin >> L >> N;

    std::vector<lint> A(N);
    for (auto& a : A) std::cin >> a;

    std::vector<lint> presum(N + 1, 0);
    for (int i = 0; i < N; ++i) presum[i + 1] = presum[i] + A[i];

    // Aを左右反転させたもの
    auto B = A;
    std::reverse(B.begin(), B.end());
    for (auto& b : B) b = L - b;

    std::vector<lint> sufsum(N + 1, 0);
    for (int i = 0; i < N; ++i) sufsum[i + 1] = sufsum[i] + B[i];

    lint ans = 0;

    // 右に移動して終わるケース
    for (int r = 1; r <= N; ++r) {
        // r個の区間に右から入る
        int l = N - r;
        int step = std::min(l, r);  // 「階段」の段数

        lint left = (sufsum[l] - sufsum[l - step]) * 2;
        lint right = (presum[r] - presum[r - step]) * 2 - A[r - 1];
        if (r > l) right += (presum[r - step] - presum[r - step - 1]) * 2;
        // 右側の階段が1段増える

        ans = std::max(ans, left + right);
    }

    // 左から終わるケース
    // さっきのを全体を左右反転させてやるだけ
    std::swap(presum, sufsum);
    for (int r = 1; r <= N; ++r) {
        int l = N - r;
        int step = std::min(l, r);

        lint left = (sufsum[l] - sufsum[l - step]) * 2;
        lint right = (presum[r] - presum[r - step]) * 2 - B[r - 1];
        if (r > l) right += (presum[r - step] - presum[r - step - 1]) * 2;

        ans = std::max(ans, left + right);
    }

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


Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
using namespace std;
const int  maxn=100;
char s[maxn];

int main()
{

    while(scanf("%s",s)!=EOF)
    {
        char aa[maxn];
        stack<char> ss;
        int len=strlen(s);
        int index=0;
        int cnt=0;
        for(int i=0;i<len;i++)
         {


             if(s[i]=='B'&&!ss.empty())
              ss.pop();
              if(s[i]=='1'||s[i]=='0')
              {
                 ss.push(s[i]);
              }

         }
         int in=0;
         while(!ss.empty())
         {

             aa[in++]=ss.top();
             ss.pop();
         }
          for(int i=in-1;i>=0;i--)
          printf("%c",aa[i]);
          printf("\n");


    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{   int n,m,x;
    cin>>n>>m>>x;
    int toll[m+2];
    toll[0]=0;
    toll[m+1]=n;
    int i;
    for(i=1;i<m+1;i++)
    {
        cin>>toll[i];
    }
    for(i=0;i<m+1;i++)
    {
        if((x>toll[i])&&(x<toll[i+1]))
            break;
    }
    int forward=i;
    int backward=m-i;
    if(forward>backward)
        cout<<backward<<" ";
    else
        cout<<forward;
    
    return 0;
}

Measured memory_bytes: 256