akhauriyash/Code-Regression huggingface dataset:
a, b = map(int, input().split())
x = sum([int(i) for i in str(a) * b])
y = sum([int(i) for i in str(b) * a])
if x < y:
    print(str(a) * b)
elif x > y:
    print(str(b) * a)
else:
    if a < b:
        print(str(a) * b)
    else:
        print(str(b) * a)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string n;
 cin >> n;
 if((n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3])) {
   cout <<"Yes" << endl;
 }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	print1(n*n*n);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-10
#define PB push_back
#define fi first
#define se second
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
class Data{
	public:
	int y;
	int x;
	int cnt;
	bool flg;
	Data(){}
	Data(int _y,int _x,int _cnt,bool _flg){
		y = _y;
		x = _x;
		cnt = _cnt;
		flg = _flg;
	}
	bool operator<(const Data &a)const{
		return cnt >= a.cnt;
	}
};
int main(){
	int w,h;
	while(scanf("%d%d",&w,&h),(w|h)){
		char stage[128][128];
		bool memo[128][128]={{0}};
		rep(i,h+2){
			rep(j,w+2){
				stage[i][j] = '.';
			}
		}
		rep(i,h){
			scanf("%s",stage[i+1]+1);
			stage[i+1][w+1] = '.';
			stage[i+1][w+2] = '\0';
		}
		h += 2;
		w += 2;
		int ans = -1;
		priority_queue < Data > Q;
		Q.push(Data(0,0,0,0));
		memo[0][0] = 1;
		while( !Q.empty() ){
			Data d = Q.top();Q.pop();
			if(stage[d.y][d.x] == '&'){
				ans = d.cnt;
				break;	
			}
			rep(i,4){
				int ny = d.y + dy[i];
				int nx = d.x + dx[i];
				if(ny < 0 || ny > h-1 || nx < 0 || nx > w-1 || memo[ny][nx]==1)continue;
				memo[ny][nx]=1;
				if(stage[ny][nx] == '#'){
					if(d.flg == 1)Q.push(Data(ny,nx,d.cnt,1));
					else Q.push(Data(ny,nx,d.cnt+1,1));
				}
				else Q.push(Data(ny,nx,d.cnt,0));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;

	cin >> N;
	rep(i,5000){
		if( i*(i+1) / 2 == N ) ans = i+1;
	}

	int cnt = 1;
	if(ans > 0){
		vector<pii> v[100005];
		rep(i, ans) reps(j, i+1, ans){
			v[i].emplace_back(j, cnt);
			v[j].emplace_back(i, cnt);
			cnt++;
		}

		cout << "Yes" << endl;
		cout << ans << endl;
		rep(i, ans){
			cout << v[i].size();
			for(auto t: v[i]) cout << " " << t.Y;
			cout << endl;
		}
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vl dp(N),sum(N);
  ll a = 0;
  if(A[0]>0) {
    dp[0] = A[0];
  } else {
    dp[0] = 1;
    a += 1-A[0];
  }
  sum[0] = dp[0];
  srep(i,1,N) {
    if(i%2==0) {
      if(sum[i-1]+A[i]>0) {
        sum[i] = sum[i-1]+A[i];
      } else {
        sum[i] = 1;
        a += 1 - (sum[i-1]+A[i]);
      }
    } else {
      if(sum[i-1]+A[i]<0) {
        sum[i] = sum[i-1]+A[i];
      } else {
        sum[i] = -1;
        a += 1 + (sum[i-1]+A[i]);
      }
    }
  }
  ll b = 0;
  if(A[0]<0) {
    dp[0] = A[0];
  } else {
    dp[0] = -1;
    b += 1 + A[0];
  }
  sum[0] = dp[0];
  srep(i,1,N) {
    if(i%2==1) {
      if(sum[i-1]+A[i]>0) {
        sum[i] = sum[i-1]+A[i];
      } else {
        sum[i] = 1;
        b += 1 - (sum[i-1]+A[i]);
      }
    } else {
      if(sum[i-1]+A[i]<0) {
        sum[i] = sum[i-1]+A[i];
      } else {
        sum[i] = -1;
        b += 1 + (sum[i-1]+A[i]);
      }
    }
  }
  cout << min(a,b) << endl;
  return 0;
}

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

int main(){
  string str;
  int ab[26] = {};
  int i;

  while(getline(cin, str)){
    for(i = 0; i < str.size();i++){
      if(str[i] >= 'a' && str[i] <= 'z') ab[str[i]-'a']++;
      else if(str[i] >= 'A' && str[i] <= 'Z') ab[str[i]-'A']++;
    }

  }
  for(i=0;i<26;i++){
    cout << (char)('a'+i) << " : " << ab[i] << endl;
  }
  return 0;
}




Measured memory_bytes: 3212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        string s = cin.next();
        string t = cin.next();

        for (int i = N; i >= 0; i--)
        {
            if (presuf(i, s, t))
            {
                Console.WriteLine(i + 2 * (N - i));
                break;
            }
        }
    }

    bool presuf(int n, string s, string t)
    {
        int len = s.Length;
        for (int i = 0; i < n; i++)
        {
            if (s[len - n + i] != t[i]) return false;
        }
        return true;

    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2648
dic = {}
N = int(input())
for _ in range(N):
    s = input()
    dic.setdefault(s, 0)
    dic[s] += 1
M = int(input())
for _ in range(M):
    s = input()
    try:
        dic[s] -= 1
    except:
        continue
m = 0
for k in dic:
    m = max(m, dic[k])
print(m)

Measured memory_bytes: 9072
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
#include <map>

const int MAXN = 1000 * (1000 - 1) / 2;
const int INF = MAXN + 1;

int a[1000][1000 - 1];
int in_degree[MAXN];
std::vector<int> graph[MAXN];
int f[MAXN];

struct Hash {
  int tot;
  std::map<std::pair<int, int>, int> hash;
  
  void Build(int n) {
    tot = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        hash[std::make_pair(i, j)] = tot++;
      }
    }
  }
  int Calc(int i, int j) {
    if (i > j) std::swap(i, j);
    return hash[std::make_pair(i, j)];
  }
};
Hash hash;

void build_graph(int n) {
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j < n - 1; ++j) {
      int p = hash.Calc(i, a[i][j - 1]);
      int v = hash.Calc(i, a[i][j]);
      graph[p].emplace_back(v);
      ++in_degree[v];
    }
  }  
}

void topo_sort(int n) {
  std::queue<int> que;
  for (int i = 0; i < hash.tot; ++i) {
    if (!in_degree[i]) {
      que.emplace(i);
      f[i] = 1;
    }
  }
  // printf("que_size = %d\n", (int)que.size());
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (const auto &v : graph[u]) {
      --in_degree[v];
      f[v] = std::max(f[v], f[u] + 1);
      if (!in_degree[v]) que.emplace(v);
    }
  }
}

int solve(int n) {
  int tot = 0;
  hash.Build(n);
  build_graph(n);
  for (int i = 0; i < hash.tot; ++i) f[i] = -1;
  topo_sort(n);

  int max = 0;
  for (int i = 0; i < hash.tot; ++i) {
    if (f[i] == -1) return -1;
    if (f[i] > max) max = f[i];
  }
  return max;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0, in; i < n; ++i) {
    for (int j = 0; j < n - 1; ++j) {
      scanf("%d", &in);
      a[i][j] = in - 1;
    }
  }
  printf("%d\n", solve(n));
  return 0;
}


Measured memory_bytes: 66560
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define iP pair<int,P>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

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

	ll A,B,C,X,Y;
	cin>>A>>B>>C>>X>>Y;
	ll sum=X*A+B*Y;
	chmin(sum,(X*C*2)+B*max(0ll,Y-X));
	chmin(sum,A*max(0ll,X-Y)+(Y*C*2));
	print(sum);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<Integer>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li);
        System.out.println(li.get(n/2)-li.get(n/2-1));
    }
}


Measured memory_bytes: 61948
#include <iostream>
#define MOD 1000000007ll
using namespace std;

int p[] = {2,3,5,7,11,13,15,17,23,29,31};
bool prime[1001];
int num[1001];

void calc(int n){
	for(int i = 0;i <= n;i++) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	for(int i = 4;i <= 1000;i += 2) prime[i] = false;
	for(int i = 3;i <= 33;i += 2){
		for(int j = 2 * i;j <= 1000;j += i) prime[j] = false;
	}
}

int main(){
	int n;
	cin >> n;
	calc(n);
	for(int i = 0;i <= 1000;i++){
		if(!prime[i]) continue;
		int nn = n;
		while(nn){
			nn /= i;
			num[i] += nn;
		}
	}
	long long int res = 1;
	for(int i = 0;i <= 1000;i++){
		//cout << num[i] << endl;
		if(num[i]) res = res * (long long int)(num[i] + 1) % MOD;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	let total = 700
	if (input[0] === 'o') total += 100
	if (input[1] === 'o') total += 100
	if (input[2] === 'o') total += 100
	console.log(total)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

#define ll long long
using namespace std;

const int MAX = 1e5;

int main()
{
	ll n, a, b, arr[MAX], ans = 0;
	cin >> n >> a >> b;
	
	for (int i=0; i<n; ++i) {
		cin >> arr[i];
	}
	
	for (int i=0; i<n-1; ++i) {
		ans += min ((arr[i+1] - arr[i]) * a, b);
	}
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

int fd(int n) {
	int res = 0;
	while(n != 0) {
		res += (n % 10);
		n /= 10;
	}
	return res;
}

void solve() {
	int N; cin >> N;
	int res = inf;
	rep(a, 1, N) {
		int b = N - a;
		MIN(res, fd(a) + fd(b));
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
def main():
    S = input()
    K = int(input())
    ans = 0
    L = len(S)
    s = set([i for i in S])
    if len(s) == 1:
        print((L*K)//2)
        exit()
    cnt = 1
    for i in range(L):
        if i < L-1 and S[i] == S[i+1]:
            cnt += 1
        else:
            ans += cnt//2
            cnt = 1
    ans *= K
    if S[0] == S[-1]:
        t = S[0]
        i = 0
        a = 0
        b = 0
        while i < L and S[i] == t:
            a += 1
            i += 1

        i = L-1
        while i >= 0 and S[i] == t:
            b += 1
            i -= 1

        tmp = a//2+b//2-(a+b)//2
        tmp *= (K-1)
        ans -= tmp
    print(ans)
if __name__ == "__main__":
    main()


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

int main(){
  int N;
  cin>>N;
  int a;
  bool b=false;
  
  for(int i=0;i<N;i++){
    cin>>a;
    if(a%2==0){
    if(a%3!=0&&a%5!=0){b=true;}
    }
  }
  if(b){cout<<"DENIED"<<endl;}
  else{cout<<"APPROVED"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int Count = 0;
    int NowCount = 0;
    for(int i = 1; i <= N; i++){
        NowCount = 0;
        if(i%2 == 1){
            for(int j = 1; j <= N; j++){
                if(i % j == 0){
                    NowCount++;
                }
            }
            if(NowCount == 8) Count++;
        }
    }
    cout << Count << endl;
}

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

def search_common_divisor(x,y):
    if x<y:
        x,y=y,x
    while y!=0:
        x,y=y,x%y
    return x

def search_list_common_divisor(*numbers):
    c=[numbers[0][i] for i in range(n)]
    b=[search_common_divisor(c[0],c[1])]
    for i in c:
        b.append(search_common_divisor(b[-1],i))
    return b[-1]

print(search_list_common_divisor(a))


Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <stdio.h>
using namespace std;
 
int main()
{
    unsigned long long int n;
    cin >> n;
    std::string s;
    cin >> s;
    int cnt = std::count(s.begin(), s.end(), 'R');
    if(cnt == 0){
        cout << 0 << endl;
        return 0;
    }
    //cout << cnt << endl;
    
    int cnt2 = 0;
    int size = s.length();
    std::vector<int> vindex;
    for(int i=0; i<size; i++){
        if(s[i] == 'R'){
            vindex.push_back(i);
            if(i+1 > cnt) cnt2++;
        }
    }
    //cout << cnt2 << endl;
    //cout << vindex[vindex.size()-1]+1 << endl;
    if(cnt == vindex[vindex.size()-1]+1){
        cout << 0 << endl;
    }else{
        cout << cnt2 << endl;
    }
    
    
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t x,y; cin>>x>>y;
	int ans=1;
	while(x<=y)++ans,x*=2;
	cout<<ans-1<<"\n"s;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		char c[] = str.toCharArray();
		c[3] = '8';
		
		System.out.println(c);
	}
}

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

long long gcd(long long a, long long b) {
	long long old_a, old_b;
	while (b != 0) {
		old_a = a;
		a = b;
		old_b = b;
		b = old_a % b;
	}
	return old_b;
}
long long x[100010];
int main() {
	long long n, X; cin >> n >> X;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		x[i] = abs(x[i] - X);
	}
	long long d;
	if (n > 1) {
		d = gcd(x[0], x[1]);
		for (int i = 2; i < n; i++) {
			d = gcd(d, x[i]);
		}
	}
	else {
		cout << x[0] << endl;
		return 0;
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define MAX_HEAP 600000

int heap_size;
/* 木の移動 */
int parent(int);
int left(int);
int right(int);

void maxHeapfy(int *, int);
void buildMaxHeap(int *);

int main(void) {
	int i, n;
	int ary[MAX_HEAP];

	scanf("%d", &n);
	heap_size = n;
	for (i = 1; i <= n; i++) {
		scanf("%d", &ary[i]);
	}
	buildMaxHeap(ary);

	for (i = 1; i <= n; i++) {
		printf(" %d", ary[i]);
	}
	putchar('\n');

	return 0;
}

int parent(int i) {
	return i/2;
}
int left(int i) {
	return 2*i;
}
int right(int i) {
	return 2*i + 1;
}

void maxHeapify(int *A, int i) {
	int l = left(i);
	int r = right(i);
	int largest;

	if (l <= heap_size && A[l] > A[i]) {
		largest = l;
	} else {
		largest = i;
	}
	if (r <= heap_size && A[r] > A[largest]) {
		largest = r;
	}

	if (largest != i) {
		/* A[i]とA[largest]の値を交換 */
		int tmp = A[largest];
		A[largest] = A[i];
		A[i] = tmp;

		maxHeapify(A, largest);
	}
}

void buildMaxHeap(int *A) {
	int i;
	for (i = heap_size/2; i >= 1; i--) {
		maxHeapify(A, i);
	}
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=100005;
int T[N*3],t[N];
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
	int n=0,x,y,a,b,c,i;ll s=0ll;
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	if(a<=x)while(a--)scanf("%d",&T[++n]);
	else{
		REP(i,0,a)scanf("%d",&t[i]);
		sort(t,t+a);
		REP(i,a-x,a)T[++n]=t[i];
	}
	if(b<=y)while(b--)scanf("%d",&T[++n]);
	else{
		REP(i,0,b)scanf("%d",&t[i]);
		sort(t,t+b);
		REP(i,b-y,b)T[++n]=t[i];
	}
	while(c--)scanf("%d",&T[++n]);
	sort(T+1,T+n+1);
	rep(i,max(0,n-(x+y))+1,n)s+=T[i];
	printf("%lld",s);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/combine.hpp>

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

template<typename... T>
auto zip (T&&... containers) -> boost::iterator_range<
    boost::zip_iterator<decltype (boost::make_tuple (begin (containers)...))>> {
    auto zip_begin =
        boost::make_zip_iterator (boost::make_tuple (begin (containers)...));
    auto zip_end =
        boost::make_zip_iterator (boost::make_tuple (end (containers)...));
    return boost::make_iterator_range (zip_begin, zip_end);
}

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (auto v : zip (S, T)) {
        char s, t;
        boost::tie (s, t) = v;
        if (s == t)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3552
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;
int main()
{
	
	long long n, m;
	scanf("%lld %lld", &n, &m);
	if (n * 2 >= m)
		printf("%lld\n", m / 2);
	else
	{
		long long b = m - n * 2;
		printf("%lld\n", n + b / 4);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <list>
#include <map>

using namespace std;
#define lf double
#define ll long long int
#define map unordered_map
#define f(i, n) for (ll i = 0; i < n; i++)

int main()
{
    ios::ios_base::sync_with_stdio(0);
    // ll tc;
    // cin >> tc;
    ll n;
    cin >> n;
    ll x = 0, m = 0, s = 0;
    f(i, n)
    {
        cin >> x;
        if (x > m)
            m = x;
        s += x;
    }
    cout << (m < s - m ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

string s;
int k;
signed main() {
	cin >> s >> k;
	rep(i, k) {
		if (s[i] != '1') {
			cout << s[i] << endl; return 0;
		}
	}
	cout << s[k - 1] << endl;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

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

    int a = 1;
    int b = n-1;
    int min_sum_digits = 100000000;
    while(a <= b) {
        int tmp_sum_digits = sum_digits(a) + sum_digits(b);
        if(min_sum_digits > tmp_sum_digits) {
            min_sum_digits = tmp_sum_digits;
        }
        a++;
        b--;
    }

    cout << min_sum_digits << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    string num_str = to_string(num);
    for(int i=0; i<num_str.size(); i++) {
        rtn += num_str[i] - '0';
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256
S = input()
T = input()

def match(k):
    flag = True
    for i in range(len(T)):
        if S[i+k] != T[i] and S[i+k]!="?":
            flag = False
            break
    return flag

flag = False
for k in reversed(range(len(S)-len(T)+1)):
    # print(k)
    if match(k):
        S = S[:k] + T + S[k+len(T):]
        flag = True
        break
    
if flag:
    ans = S.replace("?","a")

if not flag:
    ans = "UNRESTORABLE"

print(ans)
    

Measured memory_bytes: 3064
# ABC165a


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    k = int(input())
    a, b = map(int, input().split())
    if k == 1:
        print('OK')
        exit(0)
    for i in range(b // k + 2):
        if a <= i * k <= b:
            print('OK')
            exit(0)
    print('NG')


if __name__ == '__main__':
    main()


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

int main() {
	vector<int> a(4);
	int ans;
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	if (a[0] >= a[3] || a[2] >= a[1])ans = 0;
	else {
		sort(a.begin(), a.end());
		ans = a[2] - a[1];
	}
	cout << ans << endl;
}

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

using namespace std;

const int maxn = 100010;

int val[maxn], n, m;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int a, b; scanf("%d%d", &a, &b);
		val[a] ^= 1; val[b] ^= 1;
	}
	int ok = 1;
	for (int i = 1; i <= n; i++) if (val[i]) ok = 0;
	if (ok) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,a[55],ans;
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++) 
        cin>>a[i];
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            if(a[i]<a[j]) swap(a[i],a[j]); 
    for(int i=0;i<k;i++) ans+=a[i]; 
    cout<<ans<<endl; 
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

template <typename T>
class CumulativeSum2D {
    vector <vector <T>> sum;
    public:
    CumulativeSum2D (int h, int w) : sum(vector <vector <T>> (h + 1, vector <int> (w + 1))) {}

    T& operator()(int x, int y) {
        return sum[x][y];
    }

    void add(int x, int y, int num) {
        x++;
        y++;
        sum[x][y] += num;
    }

    void build() {
        for (int i = 1; i < sum.size(); i++) {
            for (int j = 1; j < sum[i].size(); j++) {
                sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
            }
        }
    }

    T operator()(int sx, int sy, int gx, int gy) {
        return (sum[gx][gy] - sum[sx][gy] - sum[gx][sy] + sum[sx][sy]);
    }
};

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector <vector <char>> s(h, vector <char> (w));

    CumulativeSum2D <int> J(h, w), O(h, w), I(h, w);

    rep (i, h) rep (j, w) {
        cin >> s[i][j];
        if (s[i][j] == 'J') J.add(i, j, 1);
        if (s[i][j] == 'O') O.add(i, j, 1);
        if (s[i][j] == 'I') I.add(i, j, 1);
    }

    J.build();
    O.build();
    I.build();

    rep (i, k) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        cout << J(a, b, c, d) << " " << O(a, b, c, d) << " " << I(a, b, c, d) << endl;
    }

    return 0;
}



Measured memory_bytes: 15500
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll,ll> mp;
    for(ll i = 2;i*i<=n;++i){
        if(n%i==0){
            while(n%i==0){
                mp[i]++;
                n /= i;
            }
        }
    }
    if(n>1){
        mp[n]++;
    }
    ll ans = 0;
    for(auto p : mp){
        ll x = p.se;
        if(x==0) continue; 
        //cout << p.fi << " " << x << endl;
        ll ok = 1;
        ll ng = 100;
        while(abs(ok-ng)>1){
            ll mid = (ok+ng)/2;
            if(x>=mid*(mid+1)/2){
                ok = mid;
            }else{
                ng = mid;
            }
        }
        ans += ok;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<long long>
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e18+1;
const ll N = 2e5;

string s;
int x, y, n;
vector<int> vx, vy;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> s >> x >> y;
    n = sz(s); vy.pb(0);
    int cf=0, ct=0;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='F') cf++;
        else
        {
            if(ct%2==0) vx.pb(cf);
            else vy.pb(cf);
            cf=0;
            ct++;
        }
    }
    if(cf)
    {
        if(ct%2==0) vx.pb(cf);
        else vy.pb(cf);
    }
    int sx = sz(vx), sy = sz(vy);
    bool dp1[18000][sx+1] = { 0 }, dp2[18000][sy+1] = { 0 };
    dp1[vx[0]+8500][0] = 1; dp2[8500][0] = 1;
    for(int i=1; i<sx; i++)
    {
        for(int j=-8000; j<=8000; j++)
        {
            if(dp1[j+8500][i-1])
            {
                dp1[j+8500+vx[i]][i] = 1;
                dp1[j+8500-vx[i]][i] = 1;
            }
        }
    }
    if(!dp1[x+8500][sx-1])
    {
        cout << "No";
        return 0;
    }
    for(int i=1; i<sy; i++)
    {
        for(int j=-8000; j<=8000; j++)
        {
            if(dp2[j+8500][i-1])
            {
                dp2[j+8500+vy[i]][i] = 1;
                dp2[j+8500-vy[i]][i] = 1;
            }
        }
    }
    if(!dp2[y+8500][sy-1])
    {
        cout << "No";
        return 0;
    }
    cout << "Yes";
}


Measured memory_bytes: 20864
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
#define maxn 100000
int n,color[maxn];
vector<int> G[maxn];
void dfs(int g,int c){
    stack<int> s;
    s.push(g);
    color[g] = c;
    while(!s.empty()){
        int u = s.top();s.pop();
        for(int i=0;i<G[u].size();i++){
            int v = G[u][i];
            if(!color[v]){
                s.push(v);
                color[v] = c;
            }
        }
    }
}
int main(){
    int m,a,b,q;
    scanf("%d%d",&n,&m);
    while(m--){
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int j=1;
    for(int i=0;i<n;i++)
        if(!color[i])
            dfs(i,j++);
    scanf("%d",&q);
    while(q--){
        scanf("%d%d",&a,&b);
        if(color[a]==color[b])
            printf("yes\n");
        else
            printf("no\n");
    }
}


Measured memory_bytes: 8968
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Crested Ibis vs Monster
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 10000;
const int MAX_N = 1000;
const int MAX_A = 10000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N];
int dp[MAX_H + MAX_A + 1];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }
inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int h, n;
  scanf("%d%d", &h, &n);

  int maxa = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", as + i, bs + i);
    setmax(maxa, as[i]);
  }

  fill(dp, dp + h + maxa + 1, INF);
  dp[0] = 0;

  for (int i = 0; i < h; i++)
    if (dp[i] < INF)
      for (int j = 0; j < n; j++)
	setmin(dp[i + as[j]], dp[i] + bs[j]);

  int mind = INF;
  for (int i = h; i <= h + maxa; i++) setmin(mind, dp[i]);

  printf("%d\n", mind);
  return 0;
}


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

int main(){
    int a, b, sum = 0;
    cin >> a >> b;
    rep(i, 2){
        if(a>b){
            sum += a;
            a--;
        } else {
            sum += b;
            b--;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
    int n_tmp = N;
    int keta = 0;
    while (n_tmp) {
        n_tmp /= 10;
        ++keta;
    }
    int res = 0;
    for (int i = keta - 1; i > 0; --i) {
        if (i % 2 == 0) continue;
        res += pow(10, i) - pow(10, i - 1);
    }
    if (keta % 2 != 0) {
        res += N - pow(10, keta - 1) + 1;
    }
    cout << res << endl;
}

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


Measured memory_bytes: 256
import math

n = int(input())

def f(a,b):
    return len(str(a)) if len(str(a)) > len(str(b)) else len(str(b))

min = 10

for i in range(1,int(math.sqrt(n))+1):
    if n%i==0 and min > f(i,n//i):
        min = f(i,n//i)

if n<10:
    min=1

print(min)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
double power( double a, int n )
{
  double r;
  int abs_n;

  r = 1; abs_n = n < 0 ? -n : n;
  while ( abs_n > 0 ) {
    if ( abs_n % 2 == 1 ) { r *= a; }
    a *= a;
    abs_n /= 2;
  }

  return n >= 0 ? r : 1/r;
}

double nthroot( double a, int n )
{
  double x, y;

  if ( a <= 0 || n < 0 ) { return 0; }
  if ( n == 0 ) { return 1; }

  /* a > 0 かつ n > 0 の場合 */
  y = (a > 1) ? a : 1;
  do {
    x = y;
    y = ((n-1)*x + a/power(x, n-1)) / n;
  } while ( y < x );

  return y;
}

int is_power( int a )
{
  int i; 

  if ( a == 1 ) { return 1; }

  for ( i = 2; i <= floor(log2(a)); i++ ) {
    if ( power(floor(nthroot(a, i)), i) == a ) { 
      return 1;
    }
  }

  return 0;
}

int main(){
    int X;
    cin >> X;
    while(X > 0){
        if(is_power(X)){
            cout << X << endl;
            break;
        }else{
            X -= 1;
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;




namespace ConsoleApplication1 {

    

    class ClassMain {


        public static int A = 0;
        public static int B = 0;
        public static int C = 0;

        public static int nextRand(int num) {
            return (A * num + B) % C;
        }


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = ints[0];
                //int n = int.Parse(line);                
                if (n == 0) { break; }
                A = ints[1];
                B = ints[2];
                C = ints[3];
                int x = ints[4];

                int[] ys = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int ythReel = 0;
                int fCnt = 0;
                while(true){
                    if(x==ys[ythReel]){
                        ythReel++;
                    }
                    if (ythReel == n) { break; }
                    if (fCnt > 10000) { break; }
                    fCnt++;
                    x = nextRand(x);

                }
                if (fCnt > 10000) { Console.WriteLine(-1); }
                else {
                    Console.WriteLine(fCnt);
                }
                    
              //Console.WriteLine();
                    
                



            }
        }
    }
}

Measured memory_bytes: 6208
#include <bits/stdc++.h>
#define M 4010
#define PLL pair <ll, ll>
#define x first
#define y second

using namespace std;

typedef long long ll;

int n;

char ch[100010];

int Head[M], Next[M], Go[M], Sz[M], Dep[M], Cnt = 0;

ll ans = 0;

PLL F[M];

void addedge(int a, int b) {
	Go[++Cnt] = b;
	Next[Cnt] = Head[a];
	Head[a] = Cnt;
}

void DFS1(int x, int f, int dep) {
	Dep[x] = dep;
	Sz[x] = ch[x] - '0';
	for(int T = Head[x]; T; T = Next[T]) if(Go[T] != f) {
		DFS1(Go[T], x, dep + 1);
		F[Go[T]].x += Sz[Go[T]];
		F[Go[T]].y += Sz[Go[T]];
		Sz[x] += Sz[Go[T]];
	}
	ll sum = 0, mx = 0, tot = 0, res = 0, ans = 0, mxv;
	for(int T = Head[x]; T; T = Next[T]) if(Go[T] != f) {
		if(F[Go[T]].x > mx) mx = F[Go[T]].x, mxv = Go[T];
		res += F[Go[T]].y - F[Go[T]].x;
		sum += F[Go[T]].x;
		tot += F[Go[T]].y;
	}
	if(mx * 2 <= sum) {
		F[x] = PLL(tot & 1, tot);
	} else {
		res -= F[mxv].y - F[mxv].x;
		ll tmp = 2 * mx - sum;
		if(tmp <= res) F[x] = PLL(tot & 1, tot); else F[x] = PLL(tmp - res, tot);
	}
}

int main() {
	scanf("%d", &n);
	scanf("%s", ch + 1);
	for(int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		addedge(a, b);
		addedge(b, a);
	}
	ll ans = 1e18;
	for(int i = 1; i <= n; i++) {
		memset(F, 0, sizeof F);
		DFS1(i, -1, 0);
		if(F[i].x == 0) {
			ll tot = 0;
			for(int j = 1; j <= n; j++) if(ch[j] == '1') tot += Dep[j];
			assert(tot % 2 == 0);
			ans = min(ans, tot / 2);
		}
	}
	printf("%lld\n", (ans == 1e18 ? -1 : ans));
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
constexpr int MOD = 998244353;

int main() {
	int n, s;
	scanf("%d %d", &n, &s);
	vector<int> a(n);
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

	vector<vector<int>> dp(3, vector<int>(s + 1));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		vector<vector<int>> next(3, vector<int>(s + 1));
		for (int j = 0; j <= s; ++j) {
			(next[0][j] += dp[0][j]) %= MOD;
			(next[1][j] += (dp[0][j] + dp[1][j]) % MOD) %= MOD;
			(next[2][j] += ((dp[0][j] + dp[1][j]) % MOD + dp[2][j]) % MOD) %= MOD;
			if (j + a[i] <= s) {
				(next[1][j + a[i]] += (dp[0][j] + dp[1][j]) % MOD) %= MOD;
				(next[2][j + a[i]] += (dp[0][j] + dp[1][j]) % MOD) %= MOD;
			}
		}
		dp = next;
	}
	printf("%d", dp[2][s]);
	return 0;
}

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

int main(void) {
  int n; cin >> n;
  vector<string> s(n);
  for (auto && vec : s) { 
    cin >> vec;
  }
  
  int a=0,b=0,c=0,d=0,e=0;
  for(int i=0;i<n;i++) {
    if(s.at(i).front() == 'B' && s.at(i).back() =='A') {
      c++;
    } else if (s.at(i).front() == 'B' && s.at(i).back() !='A') {
      b++;
    } else if (s[i].front() != 'B' && s[i].back() =='A') {
      a++;
    }
    for(int j=0;j<s[i].length()-2;j++) {
    	if(s[i].substr(j,2) == "AB") {
      		e++;
        }
    }
  }
  if (a==0 && b==0 && c>0) {
    d= c-1 + e;
  } else {
    d= min(a+c,b+c)+e;
  }
  cout << d << endl;
  return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  string s;
  cin >> s;
  s.at(5) = s.at(13) = ' ';
  cout << s << endl;
}


Measured memory_bytes: 3624
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

typedef long long LL;

int main() {
	LL a, b, c, k;
	cin >> a >> b >> c >> k;
	LL ans = min(a, k);
	k -= ans;
	k -= min(b, k);
	ans -= min(c, k);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main()
{
    string S;
    int K;
    cin >> K >> S;
    int size = S.size();
    if(size<=K){
        cout << S << endl;
        return 0;
    }else
    {
        for (int i = 0; i < K; i++)
            cout << S[i];

        cout << "..." << endl;
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll N;
string s;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	ll ans=0,x,y,z;
	x=y=z=0;
	REP(i,N){
		cin>>s;
		REP(i,s.size()-1){
			if(s[i]=='A' && s[i+1]=='B'){
				ans++;
			}
		}
		if(s.front()=='B' && s.back()=='A'){
			z++;
		}else if(s.front()=='B'){
			y++;
		}else if(s.back()=='A'){
			x++;
		}
	}
	if(x==0 && y==0){
		ans+=max(z-1,0ll);
	}else{
		ans+=min(x+z,y+z);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n), mb(n);
    rep(i, n) cin >> a.at(i);
    rep(i, n) cin >> b.at(i);
    rep(i, n) cin >> c.at(i);
    rep(i, n) mb.at(i) = -b.at(i);

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll answer = 0;
    for (int bi = 0; bi < n; bi++)
    {
        ll ai_max = lower_bound(a.begin(), a.end(), b.at(bi)) - a.begin();
        ll ci_min = c.end() - upper_bound(c.begin(), c.end(), b.at(bi));
        answer += ai_max * ci_min;
    }

    cout << answer << endl;
}

Measured memory_bytes: 1792