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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);

  while(true) {
  int n;
  cin >> n;
  if (n == 0) break;
  int a[n] = {};
  rep(i, n) {
    cin >> a[i];
  }

  sort(a, a + n);

  int minimum = INF;
  rep(i, n - 1) {
    minch(minimum, a[i + 1] - a[i]);
  }

  print(minimum);
}

  return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int M, D, d1, d10, m,ans=0;
    cin >> M >> D;
    for (int m = 1; m <= M; m++){
        for (int d = 1; d <= D; d++){
            d1 = d % 10;
            d10 = d / 10;
            if (d1 >= 2 && d10 >= 2 &&d1*d10==m)ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int T;
    cin >> T;
    for(int i = 0; i < T; i++){
        long A, B, C, D;
        cin >> A >> B >> C >> D;
        if(A < B || B > D){
            Yes(false);
            continue;
        }else if(A <= C){
            Yes(true);
            continue;
        }
        A %= B;
        Yes(A + (B - A - 1) / gcd(B, D) * gcd(B, D) <= C);
    }
}


Measured memory_bytes: 256
#include <stdio.h>
 
int walk(int index, int time, int w[101][101], int *d, int *f) {
    int *p;
 
    d[index] = ++time;
    for (p = w[index]; *p != 0; p++) {
        if (!d[*p]) {
            time = walk(*p, time, w, d, f);
        }
    }
    f[index] = ++time;
    return time;
}
 
int main(void) {
    int num, i, j, u, k, tm = 0;
    int d[101] = {0}, f[101] = {0};
    int w[101][101] = {{0}};
 
    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d %d", &u, &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &w[u][j]);
        }
    }
 
    for (i = 1; i <= num; i++) {
        if (!d[i]) {
            tm = walk(i, tm, w, d, f);
        }
    }
 
    for (i = 1; i <= num; i++) {
        printf("%d %d %d\n", i, d[i], f[i]);
    }
    return 0;
}

Measured memory_bytes: 648
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

int  dp[100005],a[100005];

void solve(){
	int  n,k;
	cin>>n>>k;
	for (int i=1;i<=n;i++)  cin>>a[i] ; 
	dp[1] = 0,dp[2] = abs(a[2]-a[1]); 
	for (int i=3;i<=n;i++){
	//	cout << i<< " = ";
		dp[i] = dp[i-1]+abs(a[i]-a[i-1]) ; 
		for (int j=i-2,ii=1;ii<k and j>0;j--,ii++){
		 	//cout <<j<<" ";
 			int  h= dp[j]+abs(a[i]-a[j]); 
 			// cout << h << " "; 
		 	dp[i] = min(dp[i],h) ; 
		}
		/*cout <<  endl ; 
		for (int j=1;j<=i;j++) cout << dp[j]<<" ";
		cout << endl ; */
	}
    cout <<  dp[n] << endl ;
}

signed main()
{
    solve();
    return 0;
}
/*
4 2
10 30 40 20

output: 30

10 4
40 10 20 70 80 10 20 70 80 60

output: 40

*/


Measured memory_bytes: 1792
MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)

if n%2 == 0:
    valid = True
    for i in range(n):
        if i%2 == 0: v = i+1
        else: v = i
        if a[i] != v:
            valid = False
            print(0)
            break
    if valid:
        print(2**(n//2)%MOD)

else:
    valid = True
    for i in range(n):
        if i%2 != 0: v = i+1
        else: v = i
        if a[i] != v:
            valid = False
            print(0)
            break
    if valid:
        print(2**(n//2)%MOD)

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

int main()
{
char s[101];

scanf("%s",s);
int t=0;
int n = strlen(s);

for(int i=0;i<n;i++)
{
	if(i%2==0)
	{
	if(s[i]=='R'||s[i]=='U'||s[i]=='D')
	t++;
	}
	else
	{
	if(s[i]=='L'||s[i]=='U'||s[i]=='D')
	t++;
	}	
}
if(t==n)
printf("Yes\n");
else
printf("No\n");


return 0;
}


Measured memory_bytes: 128
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
MAXN = 2005

dp0 = [[-1] * MAXN for _ in range(MAXN)]
dp1 = [[-1] * MAXN for _ in range(MAXN)]

def dfs(i,j,p,z,w,a,n):
    if p == 0:
        if dp0[i][j] != -1:
            return dp0[i][j]
        if i == n:
            if j == 0:
                return abs(w - a[-1])
            return abs(a[j -1] - a[-1])
        ans = 0
        for k in range(i,n):
            ans = max(ans,dfs(k + 1,k,1,z,w,a,n))
        if i == 1:
            ans = max(ans,abs(a[-1] - w))
        else:
            ans = max(ans,abs(a[-1]- a[i - 1]))
        dp0[i][j] = ans
        return ans
    elif p == 1:
        if dp1[i][j] != -1:
            return dp1[i][j]
        if i == n:
            if j == 0:
                return abs(z - a[-1])
            return abs(a[j - 1] - a[-1])
        ans = INF
        for k in range(i,n):
            ans = min(ans,dfs(k + 1,k,0,z,w,a,n))
        if i == 1:
            ans = min(ans,abs(a[-1] - z))
        else:
            ans = min(ans,abs(a[-1] - a[i - 1]))
        dp1[i][j] = ans
        return ans

def main():
    n,z,w = map(int,input().split())
    a = list(map(int,input().split()))

    ans = dfs(1,0,0,z,w,a,n)
    print(ans)

if __name__=='__main__':
    main()

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

using std::string;


int main()
{
	using std::cin;
	cin.sync_with_stdio(false);
	cin.tie(nullptr);
	string s, t;
	std::getline(cin, s);
	std::getline(cin, t);
	const int ui = s.size() - t.size() + 1;
	int min_count = t.size();;
	for (int i = 0; i < ui; i++)
	{
		int count = 0;
		for (int j = 0; j < t.size(); j++)
		{
			if (s[i + j] != t[j])
			{
				count++;
			}
		}
		if (count < min_count)
		{
			min_count = count;
		}
	}
	std::cout << min_count;
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
using namespace std;
 
int main() {
	int D, N; cin >> D >> N;
 
	int S = 1; for (int i = 0; i < D; i++) S *= 100;
	if (N <= 99) {
		cout << S * N << endl;
	}
	else {
		cout << S * 101 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

template <typename T> class PXSum {
  vector<T> data; public: PXSum() : data(1) { }
  template <typename F> void push(F val) { data.push_back(val + data.back()); }
  size_t size() const { return data.size()-1; }
  // val[i]
  T value(int i) const { return data[i+1] - data[i]; }
  // sum[l, r)
  T query(int l, int r) const { return (l == r) ? T(0) : (data[r] - data[l]); }
};

const int N = 403;
ll dp[N][N];
int a[N], n;
PXSum<ll> px;

ll solve(int l, int r) {
  if (l+1 == r) return 0;
  if (dp[l][r] == LINF) {
    for (int s = l+1; s < r; ++s) {
      dp[l][r] = min(dp[l][r], solve(l, s) + solve(s, r));
    }
    dp[l][r] += px.query(l, r);
  }
  return dp[l][r];
}

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  cin >> n;
  memset(dp, INF, sizeof dp);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    px.push(a[i]);
  }
  cout << solve(0, n) << nl;

  return 0;
}



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

struct UnionFind {
  vector<int> par;
  UnionFind(int n = 0): par(n, -1) {}
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -par[root(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n + 1);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    uf.unite(a, b);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, uf.size(i));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3976
#include <stdio.h>

int main(){
  int a,b;
  int card[] = {0, 13, 1, 2, 3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 , 11 , 12};
  scanf("%d%d",&a, &b);

  // printf("%d %d\n", card[a], card[b]);
  if(card[a] == card[b]) printf("Draw");
  if(card[a] > card[b]) printf("Alice");
  if(card[a] < card[b]) printf("Bob");

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>

#define Rep(i, n) for (int i = 1; i <= n; i ++)

using namespace std;

const int N = 410, N0 = 1e7 + 10;

int d0[N], d[N], cd;

bool isnotprime[N0];
int prime[N0], cnt;
void get_prime()
{
	isnotprime[1] = true;
	for (int i = 2; i <= 1e7 + 5; i ++){
		if (!isnotprime[i]) prime[++ cnt] = i;
		for (int j = 1; j <= cnt && i * prime[j] <= 1e7 + 5; j ++) {
			isnotprime[i * prime[j]] = true;
			if (!(i % prime[j])) break;
		}
	}
}

bool g[N][N], vis[N];
int lnk[N];

bool dfs(int x)
{
	if (vis[x]) return 0;
	vis[x] = true;
	Rep(i, cd) if (g[x][i]){
		if (lnk[i] == -1 || dfs(lnk[i])) {
			lnk[i] = x;
			return true;
		}
	}
	return false;
}

int main()
{
	int n;
	scanf("%d", &n);
	Rep(i, n) scanf("%d", &d0[i]);
	d0[0] = -1;
	Rep(i, n) {
		if (d0[i - 1] != d0[i] - 1) d[++ cd] = d0[i];
		if (d0[i + 1] != d0[i] + 1) d[++ cd] = d0[i] + 1;
	}
	
	get_prime();
	Rep(i, cd) if (d[i] & 1)
		Rep(j, cd) if (!(d[j] & 1))
			if (!isnotprime[(int)abs(d[j] - d[i])]) g[i][j] = true;
	
	int c0 = 0, c1 = 0, cc = 0;
	Rep(i, cd) lnk[i] = -1;
	Rep(i, cd) {
		if (d[i] & 1) {
			Rep(j, cd) vis[j] = false;
			if (dfs(i)) cc ++;
			c1 ++;
		}
		else c0 ++;
	}
	int ans = cc;
	c0 -= cc, c1 -= cc;
	ans += (c0 / 2) * 2, c0 %= 2;
	ans += (c1 / 2) * 2, c1 %= 2;
	if (c0 && c1) ans += 3;
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
int n,cnt;
vector<int>a;

int main(){
	cin>>n;
	a.resize(n);
	for(int i=0;i<n;i++)cin>>a[i];
	
	sort(a.begin(),a.end());
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int p=lower_bound(a.begin(),a.end(),a[i]+a[j])-a.begin();
			cnt+=p-(j+1);
		}
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,i,j,count=0;
    cin>>a;
    ll t=100;
    while(a>t)
    {
        t+=t/100;
        count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
cout << fixed << setprecision(10);
    in x,y,z,k;
        cin>>x>>y>>z>>k;
    vector<in> a(x),b(y),c(z);
        rep(i,x) cin>>a[i];
        rep(i,y) cin>>b[i];
        rep(i,z) cin>>c[i];
    sort(all(a));reverse(all(a));
    sort(all(b));reverse(all(b));
    sort(all(c));reverse(all(c));
    using T=tuple<in,int,int,int>;
    set<T> que;
    using T3=tuple<int,int,int>;
    set<T3> used;
    que.emplace(a[0]+b[0]+c[0],0,0,0);
    in g1;
    int g2,g3,g4;
    rep(i,k){
        T ans=*rbegin(que);
        tie(g1,g2,g3,g4)=ans;
        cout<<g1<<endl;
        que.erase(ans);
        used.emplace(g2,g3,g4);
        if(g2+1<x && !used.count(T3(g2+1,g3,g4))) que.emplace(a[g2+1]+b[g3]+c[g4], g2+1,g3,g4);
        if(g3+1<y && !used.count(T3(g2,g3+1,g4))) que.emplace(a[g2]+b[g3+1]+c[g4], g2,g3+1,g4);
        if(g4+1<z && !used.count(T3(g2,g3,g4+1))) que.emplace(a[g2]+b[g3]+c[g4+1], g2,g3,g4+1);
    }
}/*
./problem.exe
*/

Measured memory_bytes: 4092
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int Q = Integer.parseInt(br.readLine().trim());
        int[][] lr = new int[Q][2];
        Boolean[] isPrime = new Boolean[100001];
        List<Integer> isPrimeList = new ArrayList<>();
        for (int i = 0; i < lr.length; i++) {
            lr[i] = inputval();
        }
        for (int i = 0; i < isPrime.length; i++) {
            isPrime[i] = true;
        }
        int x;
        for (int i = 2; i < (int) Math.sqrt(isPrime.length); i++) {
            x = 2;
            while (i * x < isPrime.length) {
                isPrime[i * x] = false;
                x++;
            }
        }
        isPrime[0] = false;
        isPrime[1] = false;
        /*
        for (int i = 0; i < isPrime.length; i++) {
            if (isPrime[i] == true) {
                isPrimeList.add(i);
            }
        }*/

        int[] isLike2017 = new int[100001];
        int count = 0;
        for (int i = 0; i < isLike2017.length; i++) {
            isLike2017[i] = 0;
        }
        for (int i = 0; i < isLike2017.length; i++) {
            if (isPrime[i] && isPrime[(i+1)/2]){
                count++;
            }
            isLike2017[i] = count;

        }


        for (int i = 0; i < lr.length; i++) {
            System.out.println(isLike2017[lr[i][1]] - isLike2017[lr[i][0]-1]);
        }
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 59068
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  string s;
  cin>>s;
  ll K;
  cin>>K;
  ll N=s.size();
  if(N==1){
    cout<<K/2<<endl;
    return 0;
  }
  ll cnt1=0;
  bool jd=false,jd2=false;
  for(int i=0;i+1<N;i++){
    if(s[i]==s[i+1]){
      if(i+2==N){jd=true;}
      cnt1++;
      i++;
    }
  }
  ll cnt2=0;
  for(int i=1;i+1<N;i++){
    if(s[i]==s[i+1]){
      if(i+2==N){jd2=true;}
      cnt2++;
      i++;
    }
  }
  if(s[N-1]!=s[0]){
    cout<<cnt1*K<<endl;
  }
  else if(jd){
    cout<<cnt1*K<<endl;
  }
  else if(jd2){
    cout<<cnt1*((K+1)/2)+cnt2*(K/2)+(K/2)<<endl;
  }
  else{
    cout<<cnt1+cnt2*(K-1)+(K-1)<<endl;
  }

  return 0;
}


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

int main(){
  ll n,ans=0;
  cin >> n;
  vector<pair<ll, ll> > p;
  for(ll i=2; (i*i)<=n; i++){
    ll count = 0;
    if(n%i==0){
      while(n%i == 0){
        n /= i;
        count++;
      }
      p.push_back(pair(i,count));
    }
  }
  if(n > 1){
    p.push_back(pair(n,1));
  }
  
  for(auto& i: p){
    ll j=1;
    while(i.second >= j){
      i.second -= j;
      ans++;
      j++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
const int N = 25, M = 50010;
const int INF = 0x3f3f3f3f;
int W, n;
int w[N];
int dp[N][M];//从0到i-1组成j的最少硬币数量
int main(){
    scanf("%d %d", &W, &n);
    for(int i = 0; i < n; i++) scanf("%d", &w[i]);
    for(int j = 0; j <= W; j++) dp[0][j] = INF;
    for(int i = 0; i < n; i++) dp[i][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= W; j++){
            if(w[i] > j){
                dp[i+1][j] = dp[i][j];
            }
            else{
                dp[i+1][j] = min(dp[i][j], dp[i+1][j-w[i]] + 1);
            }
        }
    }
//    for(int i = 0; i < n; i++){
//        for(int j = 0; j <= W; j++){
//            dp[i][j] == INF ? printf("INF   ") : printf("%d   ", dp[i][j]);
//            //printf("%s   ", dp[i][j] == INF ? INF : dp[i][j]);
//        }
//        printf("\n");
//    }
    printf("%d\n", dp[n][W]);
    return 0;
}


Measured memory_bytes: 7320
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

long long gcd(long long a, long long b){
  long long maxval = std::max(a,b);
  long long minval = std::min(a,b);
  if (minval==0){
    return a;
  } else {
    return gcd(minval, maxval%minval);
  }
}

int main(){
  long long A, B, C, D;
  scanf("%lld",&A);
  scanf("%lld",&B);
  scanf("%lld",&C);
  scanf("%lld",&D);
  long long gcdval = gcd(C,D);
  long long kobaisu = C/gcdval*D;
  long long c1 = (A-1)/C;
  long long d1 = (A-1)/D;
  long long e1 = (A-1)/kobaisu;
  long long c2 = B/C;
  long long d2 = B/D;
  long long e2 = B/kobaisu;
  long long ans = B-(A-1)-((c2-c1)+(d2-d1)-(e2-e1));
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
n, f = map(int, input().split())
d = []

for _ in range(n):
    i = input().split()
    d.append([i[0], int(i[1])])

t = 0
while len(d):
    if d[0][1] > f:
        t += f
        d[0][1] -= f
        d.append(d.pop(0))
    else:
        t += d[0][1]
        a = d.pop(0)
        print(a[0], t)


Measured memory_bytes: 13012
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){

  int a,b;
  cin>>a>>b;
  cout<<(a-1)*(b-1);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


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

typedef long long ll;

#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define rep1(i, n) for(ll i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    ll ans = 0;
    
    for (int i = N-1; i >= 0; i--) {
        ans += (B[i] - (A[i]+ans) % B[i]) %B[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
n = int(input())
s = [[] for _ in range(n)]

for i in range(n):
    s[i] = input()
comb = [[0]*2 for i in range(2)]
    
al = 0
be = 0
ans = 0
for i in range(n):
    m = len(s[i])
    for j in range(m-1):
        if s[i][j] == "A" and s[i][j+1] == "B":
            ans += 1
    if s[i][0] == "B" and s[i][-1] == "A":
        comb[1][1] += 1
    elif s[i][0] == "B" and s[i][-1] != "A":
        comb[0][1] += 1
    elif s[i][0] != "B" and s[i][-1] == "A":
        comb[1][0] += 1
    else:
        comb[0][0] += 1
        
if comb[0][1] == 0 and comb[1][0] == 0:
    ans += max(0,comb[1][1] - 1)
elif comb[0][1] != 0 and comb[1][0] == 0:
    ans += comb[1][1]
elif comb[0][1] == 0 and comb[1][0] != 0:
    ans += comb[1][1]
else:
    ans += (comb[1][1] + 1 + min(comb[1][0]-1,comb[0][1]-1))
    
print(ans)

Measured memory_bytes: 46424
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    vector<long> l2 {q*8, h*4, s*2, d};
    vector<long> l1 {q*4, h*2, s};
    sort(l2.begin(), l2.end());
    sort(l1.begin(), l1.end());
    long ll2 = n/2*l2[0], ll1 = n%2*l1[0];
    cout << ll2 + ll1 << endl;
    return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){
    vector<pair<T,T>> out(input.size()-1);
    rep(i,input.size()-1){
        out[i].first =input[i  ];
        out[i].second=input[i+1];
    }
    return(out);
}
vector<char> String_to_vector_char(const string& input){
    vector<char> out(input.size());
    rep(i,input.size()){
        out[i]=input[i];
    }
    return out;
}
inline bool operator<(const pii &lhs,const pii &rhs){
    return(lhs.first<rhs.first);
}

int n,m;
bitset<12> e;
map<int,vector<int>> s;
vector<int> p;
void input(){
    cin>>n>>m;
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int sm;
            cin>>sm;
            s[i].push_back(sm-1);
        }
    }
    p.resize(m);
    rep(i,m){
        cin>>p[i];
    }   
}
void src(){
    vector<int> dk(m,0);
    int count=0;
    rep(i,1<<n){
        e = i;
        rep(j,m){
            for(auto k:s[j]){
                if(e[k]==1)
                    dk[j]++;
            }
        }
        for_each(dk.begin(),dk.end(),[](auto &x){x=x%2;});
        if(dk==p) count++;
        for_each(dk.begin(),dk.end(),[](auto &x){x=0;});
    }
    cout<<count;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using namespace std;

const int N = 1e3 + 7;
const int mod = 1e9 + 7;

long long a[N][N], dp[N][N];

int main() {
	int n, m;
	cin >> n >> m;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < m; j++ ) {
			char c;
			cin >> c;
			a[i][j] = (c == '.');
		}
	}
	dp[0][0] = 1;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < m; j++ ) {
			if ( a[i][j] ) {
				if ( a[i + 1][j] ) {
					dp[i + 1][j] += dp[i][j];
					dp[i + 1][j] %= mod;
				}
				if ( a[i][j + 1] ) {
					dp[i][j + 1] += dp[i][j];
					dp[i][j + 1] %= mod;
				}  
			}
		}
	}
	cout << dp[n - 1][m - 1];
}

Measured memory_bytes: 16000
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])

        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if x != y:
            self.__size[x] += self.__size[y]
            self.__size[y] = self.__size[x]
            self.__table[x] = y
            

    def size(self, x):
        return self.__size[self.__root(x)]

@mt
def slv(N, M, AB):
    uf = UnionFind()

    ans = [N*(N-1)//2]
    for a, b in reversed(AB):
        if uf.same(a, b):
            ans.append(ans[-1])
        else:
            s1, s2 = uf.size(a), uf.size(b)
            uf.union(a, b)
            ans.append(ans[-1] - s1*s2)
            
    ans.pop()
    
    for a in reversed(ans):
        print(a)
            

    # return ans


def main():
    # N = read_int()
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    slv(N, M, AB)



if __name__ == '__main__':
    main()


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    while(true){
        int N;
        std::cin >> N;
        if(!N){break;}

        int l = 0, r = 0, nx = 1, res = 0;
        for(int i=0;i<N;++i){
            string S;
            std::cin >> S;

            if(S == "lu"){
                l = 1;
            }else if(S == "ld"){
                l = 0;
            }else if(S == "ru"){
                r = 1;
            }else{
                r = 0;
            }

            if(l == r && l == nx){
                ++res;
                nx = !nx;
            }
        }

        std::cout << res << std::endl;
    }
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
	using namespace std;
	#define ll long long
	#define vv vector<ll>
	#define pp pair<ll,ll>
	#define ff first
	#define ss second
	#define vp vector<pp>
	#define ld long double
	#define pb push_back
	#define mp make_pair
	const ll mod=7+1e9;
	ll power(ll a,ll n)
	{
		ll ans=1;
		a=a%mod;
		while(n>0)
		{
			if(n&1)
			{
				ans=(ans*a)%mod;
			}
			n=n>>1;
			a=(a*a)%mod;
		}
		return ans;
	}
	
	bool comp(pair<ll,ll> const &a,pair<ll,ll> const &b)
	{
		return a.first > b.first;
	}
	int main() 
	{
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    ll n,m;
	    cin>>n>>m;
	    ll a[n];
	    for(ll i=0;i<n;i++)
	    {
	    	cin>>a[i];
		}
		sort(a,a+n);
		vector<pair<ll,ll> > d;
		for(ll i=0;i<m;i++)
		{
			ll x,y;
			cin>>x>>y;
			d.pb(mp(y,x));
		}
		sort(d.begin(),d.end(),comp);
		ll j=0;
		ll ans=0;
		for(ll i=0;i<m;i++)
		{
			while(d[i].ss--)
			{
				if(a[j]<=d[i].ff)
				{
				ans+=d[i].ff;
			    }
			    else
			    {
			    	break;
				}
				j++;
				if(j>=n)
				{
					break;
				}
			}
			if(j>=n)
			{
				break;
			}
		}
		for(ll h=j;h<n;h++)
		{
			ans=ans+a[h];
		}
		cout<<ans;
	return 0;
	}

Measured memory_bytes: 3188
using System;

namespace B別解
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var d = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var dSum = 0;
            foreach (int i in d) dSum += i;

            var result = 0;
            foreach (int i in d) result += i * (dSum - i);
            Console.WriteLine(result/2);
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return (x * modpow(x * x % mod, n / 2) % mod + mod) % mod;
	return (modpow(x * x % mod, n / 2) + mod) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
template <typename T>
void greater_sort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}

int n;
P p[2 * 114514];
int cnt = 0;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p + n);
	rep(i, n) {
		cnt += p[i].second;
		if (p[i].first < cnt) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
pair<string,int> d[101];int r[101],p[101][101],q,t=0;
int main(){string a;while(cin>>a>>q){bool news=true;for(int i=0;i<t;i++){if(d[i].first==a){p[i][r[i]]=q;r[i]++;news=false;}}if(news){d[t].first=a;d[t].second=t;r[t]=1;p[t][0]=q;t++;}}sort(d,d+t);for(int i=0;i<t;i++)sort(p[i],p[i]+r[i]);for(int i=0;i<t;i++){int y=d[i].second;cout<<d[i].first<<endl<<p[y][0];for(int j=1;j<r[y];j++)cout<<" "<<p[y][j];cout<<endl;}return 0;}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
int n,t;
int main()
{
	cin>>n>>t;
	int ans=100000;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(b<=t){
			ans=min(ans,a);
		}
	}
	if(ans==100000)cout<<"TLE";
	else cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
	int main(){

	
	int A, B, C;
	scanf("%d %d %d",&A,&B,&C);
	
	if(A==B && B==C ||A!=B && B!=C && A!=C)
	{
		printf("No");
	}
	else
	{
		printf("Yes");
	}
	
	return 0;	
}

Measured memory_bytes: 1736
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
#define pi 3.14159265359f

// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//                                                              member.emplace(2)とかも同じ
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);

// UINT32_MAX
// 4294967295 ≒ 4 * 1e9 


/*

*/
// ABC 163 C
// https://atcoder.jp/contests/abc163/tasks/abc163_c
int main()
{
	uint32_t n;
	cin >> n;

	vector<uint32_t> v(n + 1);

	uint32_t temp;
	for (uint32_t i = 0; i < n-1; i++) {
		cin >> temp;
		v[temp]++;
	}
	for (uint32_t i = 1; i < n+1; i++) {
		printf("%d\n", v[i]);
	}

	return 0;
}


Measured memory_bytes: 4088
#include<stdio.h>
#define MD (1000000007)
int f[1010];
int main(){
	int n,ans=1;
	scanf("%d",&n);
	for (int i=2;i<=n;i++){
		if (!f[i]){
			int s=0;
			for (int k=n/i;k>0;k/=i){
				s+=k;
			}
			ans=1ll*ans*(s+1)%MD;
			for (int j=i*i;j<=n;j+=i){
				f[j]=1;
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

n = int(input())
  
print(l[n-1])


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int digits  = String.valueOf(N).length();
        int count = 0;
        for (int i = 1; i<=digits; i++){
            if (i%2!=0){
                if(i==digits){
                    count = count + N-(int)Math.pow(10,digits-1)+1;
                }else {
                    count = count + (int) Math.pow(10, i - 1) * 9;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22868
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int flag=0;
    while(n--){
        int a;
        cin>>a;
        if(a%2!=0) continue;
        if(a%3!=0&&a%5!=0){
            flag=1;
            break;
        }
    }
    if(!flag) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}


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 n, k;
  cin >> n >> k;
  int d=0;
  while (n >= 1) {
    d ++;
    n /= k;
  }
  cout << d;
}


Measured memory_bytes: 256
let main = (standardInput) => {
    let lengthList = standardInput.split(' ');
    let varticalLength = Number.parseInt(lengthList[0]);
    let horizonLength = Number.parseInt(lengthList[1]);

    console.log(`${varticalLength * horizonLength} ${2 * (varticalLength + horizonLength)}`);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 15100
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int d;

	cin>>d;

	if(d==22){
		cout<<"Christmas Eve Eve Eve"<<endl;
	} else if(d==23){
		cout<<"Christmas Eve Eve"<<endl;
	} else if(d==24){
		cout<<"Christmas Eve"<<endl;
	} else{
		cout<<"Christmas"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	for(int i=n;;i++){
    	string s = to_string(i);
      	set<char> se;se.insert({s[0],s[1],s[2]});
      	if(se.size()==1){cout<<i;return 0;}
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<int> g[101010];
int room[101010];

void bfs() {
    fill(room, room + 101010, -1);
    room[0] = 0;
    queue<int> que;
    que.push(0);
    while (que.size()) {
        int v = que.front(); que.pop();
        for (auto u : g[v]) {
            if (room[u] != -1) continue;
            que.push(u);
            room[u] = v;
        }
    }
    return;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bfs();
    bool flag = true;
    for (int i = 0; i < n; i++) {
        if (room[i] == -1) {
            flag = false;
            break;
        }
    }
    if (!flag) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << room[i] + 1 << endl;
    }
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        a: u32,
        b: u32,
    }

    println!("{}", a * b);
}


Measured memory_bytes: 2108
package main

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

func main() {
	In := ReadLineInt()
	Sheeps, Wolfs := In[0], In[1]

	if Sheeps <= Wolfs {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}
}

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

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

func abs(i int) int {
	if i >= 0 {
		return i
	}
	return i * -1
}

func Contains(s []string, t string) bool {
	for _, v := range s {
		if v == t {
			return true
		}
	}
	return false
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,par[200010],siz[200010],ans;
map<int,int>mx,my;
void init(int n){
	rep(i,n){
		par[i]=i;
		siz[i]=0;
	}
}
int find(int x){
	if(par[x]==x)return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(siz[x]<siz[y]){
		par[x]=y;
		siz[y]+=siz[x];
	}
	else{
		par[y]=x;
		siz[x]+=siz[y];
	}
}
signed main(){
	cin>>n;
	init(200010);
	rep(i,n){
		int x,y;
		cin>>x>>y;
		unite(x,y+100000);
	}
	for(int i=1;i<=100000;i++)mx[find(i)]++;
	for(int i=100001;i<=200000;i++)my[find(i)]++;
	for(int i=1;i<=100000;i++)ans+=mx[i]*my[i];
	ans-=n;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 23168