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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  int n,res = 0;
  cin >> n;
  vector<int> v(n);
  REP(i,n)cin >> v[i];
  if(v[n-1] == n)swap(v[n-2],v[n-1]),res++;
  REP(i,n-1){
    if(v[i] == i+1)swap(v[i],v[i+1]),res++;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

inline static int sp(char* str, unsigned short i){
    if(i>99){
        char c0 = i%10; i/=10;
        char c1 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c1+48;
        str[2] = c0+48;
        return 3;
    }else if(i>9){
        char c0 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c0+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

char a[1001];
char buffer[8*1024*1024];

int main(void){
    const int h=gl(), w=gl();
    int p = 0;
    int pos=0;
    {
        char haveCoin = 0;
        short old_y, old_x;
        for(int i=1; i<=h; i++){
            fgets_unlocked(a, 1001, stdin);
            if(i%2==1){
                for(int j=1; j<=w; j++){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= a[(j-1)*2]&1;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(int j=w; j>0; j--){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= a[(j-1)*2]&1;
                    old_y = i;
                    old_x = j;
                }
            }
        }
    }
    pl(pos); putchar_unlocked('\n');
    fwrite(buffer, p, 1, stdout);
    return 0;
}


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

int main() {
    int K, S;
    cin >> K >> S;

    int res = 0;
    for( int X = 0; X <= K; X++ ) {
        for( int Y = 0; Y <= K; Y++ ) {
            int Z = S - (X + Y);
            if (0 <= Z and Z <= K) {
                res++;
            }
        }
    }
    cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long

void lol(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif	
}

const int INF = 1e9 + 7; 

void solve(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(auto &x: a) cin >> x;
	vector<int> dp(n,INF);
	dp[n-1] = 0;
	for(int i=n-2; i>=0;i--){
		// cout << i << " "; 
		for(int j=i+1; j<=i+k; j++){
			if(j < n) dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
	}
	cout << dp[0];
}

int main(){
	FAST(); 
	// lol();
	int t; t = 1; while(t--) solve();
	return 0;
}


Measured memory_bytes: 1024
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    a = int(input())
    s = str(input().rstrip())
    if a >= 3200:
        print(s)
    else:
        print('red')
if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back 
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
str s;
int main(){
  cin>>s;
  int ss=s.size();
  int a=1,j=0;
  vi vec;
  rep(i,ss-1){
    if(s[i]!=s[i+1]){
      vec.pb(a);
      a=1;
    }
    else a++;
  }
  vec.pb(a);
  prin(vec.size()-1);
  
  return 0;
}


Measured memory_bytes: 1020
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long c = sc.nextLong();
		long[] x = new long[n];
		long[] v = new long[n];

		for (int i=0;i<n;i++) {
			x[i] = sc.nextLong();
			v[i] = sc.nextLong();
		}
		//right
		long answer1 = 0;
		long tmp = 0;
		for (int i=0;i<n;i++) {
			tmp += (v[i]-(i==0 ? x[i] : x[i]-x[i-1]));
			answer1 = Math.max(answer1, tmp);
		}
		tmp = 0;
		//left
		long answer2 = 0;
		for (int i=n-1;i>=0;i--) {
			tmp += (v[i]-(i==n-1? c-x[i] : x[i+1]-x[i]));
			answer2 = Math.max(answer2, tmp);
		}
		//right and then left
		long answer3 = 0;
		long[] tmpMax = new long[n];
		tmp = 0;
		for (int i=0;i<n;i++) {
			tmp += (v[i]-2*(i==0 ? x[i] : x[i]-x[i-1]));
			tmpMax[i] = i==0 ? tmp : Math.max(tmpMax[i-1], tmp);
		}
		tmp = 0;
		for (int i=n-1;i>=1;i--) {
			tmp += (v[i]-(i==n-1? c-x[i] : x[i+1]-x[i]));
			answer3 = Math.max(answer3, tmp+tmpMax[i-1]);
		}
		//left and then right
		long answer4 = 0;
		tmpMax = new long[n];
		tmp = 0;
		for (int i=n-1;i>=0;i--) {
			tmp += (v[i]-2*(i==n-1? c-x[i] : x[i+1]-x[i]));
			tmpMax[i] = i==(n-1) ? tmp : Math.max(tmpMax[i+1], tmp);
		}
		tmp = 0;
		for (int i=0;i<n-1;i++) {
			tmp += (v[i]-(i==0 ? x[i] : x[i]-x[i-1]));
			answer4 = Math.max(answer4, tmp+tmpMax[i+1]);
		}

		System.out.println(Math.max(Math.max(answer1, answer2), Math.max(answer3, answer4)));
	}

}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


const int MOD = 1e+9 + 7;

template <typename T>
T pow_mod( T n, T p, T m )
{
    if( p == 0 ) return 1;
    if( p%2 == 1 ) return pow_mod(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

int main()
{
    int N, K;
    cin >> N >> K;

    long long ans = 0;
    vector<long long> num_cases(K+1);
    // gcd が i になるものの個数を求める
    for(int i = K; i >= 1; --i){
        num_cases[i] = pow_mod<long long>(K/i, N, MOD);
        int j = 2;
        while(i*j <= K) num_cases[i] -= num_cases[i*j++];
        ans += (i * num_cases[i]) % MOD;
    }
    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>

#define G_MAX 100

int main(){
  int n;
  int i,j;
  int u,k,v;
  int G[G_MAX][G_MAX];
  for (i = 0 ; i < G_MAX ; i++) {
    for (j = 0 ; j < G_MAX ; j++) {
      G[i][j] = 0;
    }
  }
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    u=u-1;
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      v=v-1;
      G[u][v] = 1;
    }
  }
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      printf("%d%c",G[i][j],(j < n-1 ? ' ' : '\n'));
    }
  }
  return 0;
}



Measured memory_bytes: 2104
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()
ans = 0
#順序維持のbisect (二分探索を利用したライブラリ）
for i in range(N):
    count_a = bisect.bisect_left(A,B[i])
    count_c = N -bisect.bisect_right(C,B[i])
    ans += count_a*count_c
print(ans)

Measured memory_bytes: 23232
import sys
def main():
    n = int(input())
    lines = sys.stdin.readlines()
    outputs = [None] * n
    str_range = [str(i) for i in range(1, n+1)]
    for i in range(n):
        idx, idx_n, *idx_vertices = lines[i].rstrip().split()
        outputs[i] = ['1' if str_i in idx_vertices else '0' for str_i in str_range]

    [print(" ".join(outputs[i])) for i in range(n)]


main()


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

int main() {
    int k;
    cin >> k;
    int x = 7 % k;
    set<int> s;
    int i = 1;
    while(s.count(x) == 0) {
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10 + 7) % k;
        ++i;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 50464
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;

int main() {
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < a.size(); i--) {
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				break;
			}
			else if (a[i] < b[i]) {
				cout << "LESS" << endl;
				break;
			}
			else if (i == 0) {
				cout << "EQUAL" << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[][] x = new int[n][n];
			int[][] y = new int[n][n];
			int[][] loop = new int[n][n];
			
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					x[i][j] = sc.nextInt();
					y[i][j] = sc.nextInt();
				}
			}
			
			int cnt = 1;
			int p, q, r, u, v;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(loop[i][j]==0){
						p = i;
						q = j;
						while(true){

							if(loop[p][q]==cnt){
								cnt++;
								break;
							}else if(loop[p][q]==0){
								loop[p][q] = cnt;
								u = p;
								v = q;
								p = y[u][v];
								q = x[u][v];
							}else{
								r = loop[p][q];
								for(int a=0;a<n;a++){
									for(int b=0;b<n;b++){
										if(loop[a][b]==cnt) loop[a][b] = r;
									}
								}
								break;
							}
						}
					}
				}	
			}

			System.out.println(cnt-1);
		}	
	}	
}

Measured memory_bytes: 61008
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
    int n,h,w;
    int k=0;
    scanf("%d %d %d",&h,&w,&n);

    if(n<w || n<h){
      printf("1");
      return 0;
    }
  
if(w>h){

  k=n/w;
  if(n%(k*w)!=0){
    k+=1;
  }
}
  else{

    k=n/h;
  if(n%(k*h)!=0){
    k+=1;
  }
  }
  printf("%d",k);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#define hash_size 1000033
#define key_size_ub 14
char H[hash_size][key_size_ub];
int getChar(char c)
{
    if (c == 'A')
    {
        return 1;
    }
    else if (c == 'C')
    {
        return 2;
    }
    else if (c == 'G')
    {
        return 3;
    }
    else if (c == 'T')
    {
        return 4;
    }
    else
        return 0;
}

long long getKey(char str[])
{
    long long key = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++)
    {
        key += p * (getChar(str[i]));
        p *= 5;
    }
    return key;
}

int h_1(int key) { return key % hash_size; }
int h_2(int key) { return (key % (hash_size - 1)) + 1; }

int find(char str[])
{
    long long key_value, hash_value, i;
    for (i = 0;; i++)
    {
        key_value = getKey(str);
        hash_value = (h_1(key_value) + i * h_2(key_value)) % hash_size;
        if (strcmp(str, H[hash_value]) == 0) //すでにstrと同じ文字列が格納されている
        {
            return 1;
        }
        else if (strlen(H[hash_value]) == 0) //H[hash_value]が空
        {
            // strcpy(H[hash_value], str);
            return 0;
        }
    }
    return 0;
}

int insert(char str[])
{
    long long key_value, hash_value, i;
    for (i = 0;; i++)
    {
        key_value = getKey(str);
        hash_value = (h_1(key_value) + i * h_2(key_value)) % hash_size;
        if (strcmp(str, H[hash_value]) == 0) //すでにstrと同じ文字列が格納されている
        {
            return 1;
        }
        else if (strlen(H[hash_value]) == 0) //H[hash_value]が空
        {
            strcpy(H[hash_value], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int n;
    char str[key_size_ub], com[8];
    scanf("%d", &n);
    for (int i = 0; i < hash_size; i++)
    {
        H[i][0] = '\0'; //ハッシュの各要素の先頭をnullにしておく
    }
    for (int i = 0; i < n; i++)
    {
        scanf("%s %s", com, str);
        if (com[0] == 'i')
        {
            insert(str);
        }
        else if (com[0] == 'f')
        {
            if (find(str))
                printf("yes\n");
            else
                printf("no\n");
        }
    }
    return 0;
}


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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int number = 0;
    for (int i = 0; i < n; i++){
        if (sum%(4*m) == 0){
            if (a[i] >= sum/(4*m)) number++;
        }
        else {
            if (a[i] > sum/(4*m)) number++;
        }
    }
    if (number >= m) puts("Yes");
    else puts("No");
    return 0;
}

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

int main()
{
	int W,H,x,y;
	cin >> W >> H >> x >> y;
	double S = (double)W * (double)H / 2;
	if(x+x == W && y+y == H) cout << S << ' ' << 1 << endl;
	else cout << S << ' ' << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
bool d[15];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n=ri(),k=ri(),i,j,flag,tmp;
	for(i=1;i<=k;i++)	j=ri(),d[j]=1;
	while(1)
	{
		flag=1;
		for(tmp=n;tmp;tmp/=10)	if(d[tmp%10]){flag=0;break;}
		if(flag)	break;
		n++;
	}
	wi(n);
	return 0;
}
/*
1000 8
1 3 4 5 6 7 8 9

2000

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define fill(v, h) memset((v), h, sizeof(v))
using namespace std;
const int MOD = 1000000007;

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

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

int main(void)
{
    string s, t;
    cin >> s >> t;
    if(t.substr(0,sz(s))==s)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

long long gcd(long long x, long long y){
    if(y == 0)return x;
    // cout<<x<<endl;
    return gcd(y,x%y);
}

void solve(long long A, long long B){
    long long x = gcd(A, B);
    map<long long, long long> ma;
    long long p = 2;
    while(p*p<=x){
        while(x%p==0){
            x/=p;
            ma[p]+=1;
        }
        p++;
    }
    if(x!=1) ma[x]+=1;
    cout<<ma.size()+1<<endl;;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int N;
void dfs(string s, char m) {
	if(s.size() == N) {
		cout << s << endl;
		return;
	}
	rep(i,m-'a'+1) {
		char tm = m;
		if((char)('a'+i) == m)
			++tm;
		dfs(s+(char)('a'+i), tm);
	}
}

int main() {
	cin >> N;
	dfs("", 'a');
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

// <---------------------- > //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>k;
	vll a(n);
	for(ll i=0;i<n;i++) cin>>a[i];
		sort(all(a));
	ll mini = INF;
	ll i=0, j = k-1;
	while(j < n) {
		mini = min(mini, a[j] - a[i]);
		i++;
		j++;
	}
	cout<<mini;
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {

		MAIN();
	}
	return 0;
}


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int n,m,l,r,mid,ans;
int maxn[N<<2],a[N],f[N];

void change(int k,int l,int r,int pos,int v)
{
	if (l==pos && pos==r)
	{
		maxn[k]=v;
		return;
	}
	int mid=l+r>>1;
	if (pos<=mid) change(k<<1,l,mid,pos,v);
	else change(k<<1|1,mid+1,r,pos,v);
	maxn[k]=max(maxn[k<<1],maxn[k<<1|1]); 
}

int query(int k,int l,int r,int qx,int qy)
{
	if (qx<=l && r<=qy) return maxn[k];
	int mid=l+r>>1;
	int ans=0;
	if (qx<=mid) ans=max(ans,query(k<<1,l,mid,qx,qy));
	if (mid<qy) ans=max(ans,query(k<<1|1,mid+1,r,qx,qy));
	return ans;
}

inline bool jay(int mid)
{
	memset(maxn,0,sizeof(maxn));
	memset(f,0,sizeof(f));

//	if (maxn[1]>=mid) return true;
//	else return false;
}
	
int main(){
	scanf("%d%d",&n,&m);
	for (register int i=1; i<=n; ++i) scanf("%d",&a[i]);	
	f[1]=1;
	change(1,0,3e5,a[1],f[1]);	
	for (register int i=2; i<=n; ++i)
	{
		int now=query(1,0,3e5,max(a[i]-m,0),min(a[i]+m,300000));
		f[i]=max(1,now+1);
		now=query(1,0,3e5,a[i],a[i]);
		if (f[i]>now) change(1,0,3e5,a[i],f[i]);
	}
	for (register int i=1; i<=n; ++i) ans=max(ans,f[i]);
/*	l=0; r=3e5;
	while (l<=r)
	{
		mid=l+r>>1;
		if (jay(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}*/
	printf("%d\n",ans);
return 0;	
}

Measured memory_bytes: 10268
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;


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

	ll ans;
	cin >> ans;
	int pre = ans,cur;

	rep(i,n-2){
		cin >> cur;
		if(cur < pre)ans += cur;
		else ans += pre;
		//cout << ans << endl;
		pre = cur;
	}
	
	cout << ans+pre << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

#define INF (1<<29)

struct State {
  int to, cost;
  bool left;
  bool operator < (const State& s) const {
    return cost > s.cost;
  }
  State(int t, int c, bool l)
    : to(t), cost(c), left(l) {}
};

typedef pair<int, int> P;

vector<P> start, goal;
char t[61][31];
int G[61][31];
int W, H;

inline bool inF(int x, int y) {
  return 0<=x && x<W && 0<=y && y<H;
}

/*
  0 1   2   3 ...
  W W+1 W+2 ...
  ...
*/
inline int nidx(int x, int y) {
  return y*W+x;
}

inline int posx(int nidx) {
  return nidx % W;
}

inline int posy(int nidx) {
  return nidx / W;
}

inline bool isout(int i, int j) {
  if(i == -1 && j == 3) return true;
  if(i == +1 && j == 3) return true;
  if(i == -2 && j == 2) return true;
  if(i == +2 && j == 2) return true;
  if(i == -2 && j == 3) return true;
  if(i == +2 && j == 3) return true;
  return false;
}

int dijkstra() {
  
  int dist[61][31][2];
  fill(dist[0][0], dist[0][0]+61*31*2, INF);
  priority_queue<State> PQ;
  for(int I=0; I<start.size(); I++) {
    int sx = start[I].first, sy = start[I].second;
    dist[sy][sx][0] = dist[sy][sx][1] = 0;
    PQ.push(State(nidx(sx, sy), 0, false));
    PQ.push(State(nidx(sx, sy), 0, true));
  }
  while(!PQ.empty()) {
    const State st = PQ.top(); PQ.pop();
    const int x = posx(st.to), y = posy(st.to);
    int s = st.left ? -1 : +1;
    
    if(t[y][x] == 'T') return st.cost;
    
    for(int i=-2; i<=2; i++) {
      for(int j=1; j<=3; j++) {
        if(isout(i, j)) continue;
        int nx = x+s*j, ny = y+i;
        if(!inF(nx, ny)) continue;
        if(dist[ny][nx][!st.left] <= st.cost+G[ny][nx]) continue;
        dist[ny][nx][!st.left] = st.cost+G[ny][nx];
        PQ.push(State(nidx(nx, ny), dist[ny][nx][!st.left], !st.left));
      }
    }
  }
  
  return -1;
}

int main() {
  
  while(cin >> W >> H && (W|H)) {
    start.clear(); goal.clear();
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++) {
        cin >> t[i][j];
        if(t[i][j] == 'S') {
          start.push_back(P(j, i));
          G[i][j] = 0;
        }
        else if(t[i][j] == 'T') {
          goal.push_back(P(j, i));
          G[i][j] = 0;
        }
        else if(t[i][j] == 'X'){
          G[i][j] = INF;
        }
        else {
          G[i][j] = t[i][j]-'0';
        }
      }
    
    cout << dijkstra() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1232
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main() 
{
    //int t; cin >> t; while(t--) 
    {
        int n;
        cin >> n;
        
        int ans[n] = {};
      	for(int i = 0; i < n - 1; i++) {
          int x;
          cin >> x;
          ans[x - 1]++;
        }
      
      	for(int i = 0; i < n; i++)
          	cout << ans[i] << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 5140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int K = sc.nextInt();
            int X = sc.nextInt();

            if (K * 500 >= X) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define all(a) a.begin(), a.end()

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

	int n;cin >> n;
	vector <int> a(0);
	int dodo;
	for(int i = 0; i < n; i++) {
		if(i == 0) {cin >> dodo; a.pb(dodo); continue;}
		cin >> dodo;
		if(dodo == a[a.size() - 1]) {
			continue;
		}
		a.pb(dodo);
	}

	int count = 1;
	if(a.size() == 1) {cout << 1 << endl; return 0;}
	bool I;
	if(a[1] > a[0]) I = true;
	else I = false;


	for(int i = 2; i < a.size(); i++) {
		if(a[i] < a[i -1]) /*des*/ {
			if(I) {
				count++;
				if(a[i + 1] > a[i]) I = true;
				else I = false;
				i++;
			}
		} else {//ascend
			if(!I) {
				count++;
				if(a[i + 1] > a[i]) I = true;
				else I = false;
				i++;
			}
		}
	}


	cout << count << endl;


	return 0;
}

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    string s;
    int n;
    cin >> n;
    cin >> s;
    int cnt = 0;
    REP(i, s.size() - 2)
    {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n + 1), p;
    map<ll, ll> m;

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        m[i] = INF;
    }

    ll time = 0;
    ll city = 1;
    ll start, end;

    while (true)
    {
        if (m[city] == INF)
        {
            m[city] = time;
            p.push_back(city);
            city = a[city];
        }
        else
        {
            start = m[city];
            end = time;
            break;
        }

        time++;
    }

    if (start > k)
    {
        cout << p[k] << endl;
        return 0;
    }

    cout << p[(k - start) % (start - end) + start] << endl;
}

Measured memory_bytes: 19444
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
map<string,int>mp;
int n;
cin>>n;
while(n--)
{
    string a;
    cin>>a;
    mp[a]++;
}
vector<string>vv;
vector<int>aa;
for(auto x:mp)
{
    aa.push_back(x.second);
}
sort(aa.begin(),aa.end(),greater<int>());
int y=aa[0];
for(auto x:mp)
{
    if(x.second ==y)
    {
        vv.push_back(x.first);
    }
}
sort(vv.begin(),vv.end());
for(int i=0;i<vv.size();i++)cout<<vv[i]<<"\n";

return 0;
}



Measured memory_bytes: 27636
S = input()

ans = [0] * (len(S) + 1)
for i in range(len(S)):
    if S[i] == '<':
        ans[i + 1] = ans[i] + 1

for i in range(len(S)-1, -1, -1):
    if S[i] == '>':
        ans[i] = max(ans[i + 1] + 1, ans[i])
print(sum(ans))


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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

char to_lower(char c){
    ll diff = 'A' - 'a';
    return c - diff;
}

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

    // input
    ll N, K;
    cin >> N >> K;

    string s;
    cin >> s;

    s[K-1] = to_lower(s[K-1]);
    p(s);
        
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
	import java.util.Scanner;
	
	class Main {
		public static void main(String args[]) {
			Scanner sc = new Scanner(System.in);
			
			long a = sc.nextLong();
			long b = sc.nextLong();
			long x = sc.nextLong();
			
			long cnt = 0;
			if (a % x == 0) cnt++;
			cnt += (b / x) - (a / x);
			System.out.println(cnt);
		}
	}

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

int N;
ll A;
int main(){
  cin>>N;

  int odd=0,even=0;
  for(int i=0;i<N;i++){
    cin>>A;
    if(A%2==0)even++;
    else odd++;
  }

  bool flag=false;

  int res=0;
  if(odd%2==1){
    res++;
  }
  even+=(odd/2);

  if(even%2==0){

  }else{
    res++;
  }

  if(res==1 ||res == 0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      _s: [String; n]
   }
   let s: Vec<_> = _s.iter().map(|x| x.as_bytes()).collect();
   let mut march = vec![0usize; 5];
   for &s in s.iter() {
      match s[0] {
         b'M' => march[0] += 1,
         b'A' => march[1] += 1,
         b'R' => march[2] += 1,
         b'C' => march[3] += 1,
         b'H' => march[4] += 1,
         _ => (),
      }
   }
   let mut ans = 0;
   for i in 0..5 {
      for j in i+1..5 {
         for k in j+1..5 {
            ans += march[i]*march[j]*march[k];
         }
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 10492
n = int(input())
count = 0

def divisor(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

for odd in [i for i in range(1, n + 1, 2)]:
    # print('odd: {} divs: {}'.format(odd, divisor(odd)))
    if len(divisor(odd)) == 8:
        count += 1
print(count)

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

using namespace std;

int N, A, B, C, l[10], ans = 1e9;

void calc(int i, int a, int b, int c, int merge)
{
    if (i == N) {
        if (a != 0 && b != 0 && c != 0)
            ans = min(ans, abs(A-a) + abs(B-b) + abs(C-c) + merge - 30);
        return;
    }
    calc(i+1, a, b, c, merge);
    calc(i+1, a+l[i], b, c, merge+10);
    calc(i+1, a, b+l[i], c, merge+10);
    calc(i+1, a, b, c+l[i], merge+10);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; ++i) cin >> l[i];
    calc(0, 0, 0, 0, 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?')break;
        if(op == '+')printf("%d\n", a + b);
        else if(op == '-')printf("%d\n", a - b);
        else if(op == '*')printf("%d\n", a * b);
        else if(op == '/')printf("%d\n", a / b);
    }
    
}



Measured memory_bytes: 1968
let () =
    let main () =
        let s       = read_line () in
        let l = String.length s in
        let rec loop i =
            if i = l then true else
                match i mod 2, s.[i] with
                | 0, 'L' -> false
                | 1, 'R' -> false
                | _ -> loop (i + 1)
        in
        print_endline (if loop 0 then "Yes" else "No")
    in
    main ()

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int x[200000];
int main(){
	int n,a;cin>>n>>a;
	vector<int>x;
	rep(i,n){
		int X;cin>>X;
		x.push_back(X);
	}
	x.push_back(a);
	sort(x.begin(),x.end());
	x.erase(unique(x.begin(),x.end()),x.end());
	int g=x[1]-x[0];
	rep(i,x.size()-1){
		g=__gcd(g,x[i+1]-x[i]);
	}
	cout<<g<<endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long ea=0,bb=0,ch=0,ans=0,n,i,j;
	string s;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>s;
		for(j=0;j<s.size()-1;j++)
			if(s[j]=='A'&&s[j+1]=='B')
				ans++;
		if(s[0]=='B')
			bb++;
		if(s[s.size()-1]=='A')
			ea++;
		if(s[0]=='B'&&s[s.size()-1]=='A')
			ch++;
	}
	if(ch==bb&&ch==ea&&ch>0)
		cout<<ans+bb-1<<endl;
	else
		cout<<ans+min(bb,ea)<<endl;
	return 0;
}

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

int a[101]={0};

int main(){
	int n, x;
	cin >> n;  //4
	
	for (int i=1; i<=n; i++){
		cin >> x;
		a[x]=1;
	}
	
	int s=0;
	for(int i=1; i<=100; i++){
		if (a[i]==1) s++;
	}
	
	cout << s;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.algorithm, std.array, std.range;
import std.bigint, std.math;
 
auto solve(string s_)
{
    immutable N = s_.to!int();
    auto AS = new long[N];
    foreach(ref v;AS) v=readln.chomp().to!long();
    immutable M=AS.reduce!max();
    immutable M2=sqrt(M.to!real()).to!long()+1;
    immutable M3=cbrt(M.to!real()).to!long()+1;
    auto pbs = new bool[M2];
    long[] ps;
    size_t q=M2;
    foreach(i;2..M2) if(!pbs[i])
    {
        if(q==M2 && i>=M3) q=ps.length;
        ps~=i;
        for(auto j=i*2; j<M2; j+=i) pbs[j]=true;
    }
    if(q==M2) q=ps.length;
    auto RS = new long[N];
    int[long] b;
    foreach(k;0..N)
    {
        BigInt r=1;
        long a=1,v=AS[k];
        foreach(p;ps[0..q])
        {
            int c=0;
            while(v%p==0) v/=p, ++c;
            c%=3;
            if(c!=0)
            {
                foreach(_;0..c) a*=p;
                foreach(_;0..3-c) r*=p;
            }
        }
        if(v>1)
        {
            a*=v;
            long lo=0, hi=ps.length-1;
            void rev()
            {
                while(lo<=hi)
                {
                    auto m=(lo+hi)/2;
                    immutable p=ps[m], pp=p*p;
                    if(pp==v){ r*=p; return; }
                    if(pp<v) lo=m+1;
                    else     hi=m-1;
                }
                r*=v;
                r*=v;
            }
            rev();
        }
        AS[k]=a;
        immutable t=r>M? -1: r.toLong();
        RS[k]=t;
        if(a !in b) b[a]=1;
        else ++b[a];
        if(t !in b) b[t]=0;
    }
    if(1 in b) b[1]=1;
    bool[long] u;
    int m=0;
    foreach(k;0..N)
    {
        immutable a=AS[k];
        if(a in u) continue;
        immutable r=RS[k];
        m+=max(b[a],b[r]);
        u[a]=true,u[r]=true;
    }
    return m;
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 22780
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    int n = 0, m = 10e9 + 1;
    for (int i = 0; i < N; ++i) {
         int a = 0; cin >> a;
         n = max(n, a), m = min(m, a);
    }
    printf("%d\n", n - m);
}


Measured memory_bytes: 3704
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function 素因数分解(n)
  res=Tuple[]
  for a=2:isqrt(n)
    if n%a!=0; continue; end
    ex=0
    while n%a==0
      ex+=1
      n/=a
    end
    push!(res,(a,ex))
  end
  if n!=1; push!(res,(Int(n),1)); end
  return res
end
function main()
  ans=0
  for i=素因数分解(pI(readline()))
    now=i[2]
    j=1
    while j<=now
      ans+=1
      now-=j
      j+=1
    end
  end
  println(ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 164256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll N; cin >> N;
    int ans = 0;
    FOR(i, 2, 1000010) {
        int cur = 0;
        while (N % i == 0) {
            cur++;
            N /= i;
        }
        FOR(j, 1, 10000) {
            if (cur < j) break;
            ans++; cur -= j;
        }
    }
    if (N > 1) ans++;
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	s += s;

	string t;
	cin >> t;
	rep(i, s.size()) {
		if (s.size() <= i + t.size()) break;
		//cout << i + t.size() << endl;
		if (s.substr(i, t.size()) == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;
int main() {
  llong h;
  cin >> h;
  llong ans = 0;
  llong num = 1;
  while (h > 0) {
    ans += num;
    num *= 2;
    h /= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        //

        if (k > (n - 1) * (n - 2) / 2 ) {
            System.out.println(-1);
            return;
        }
        int b = (n - 1) * (n - 2) / 2 - k;
        System.out.println(n - 1 + b);
        for (int i = 1 ; i < n ; i++) {
            System.out.println(1 + " " +( i + 1));
        }
        int count = 0;
        for (int i = 1 ; i < n ; i++) {
            for (int j = 1 ; j < n ; j++) {
                if (i < j && count < b) {
                    System.out.println(i + 1 + " " + (j + 1));
                    count++;
                }
            }
        }



    }

}


Measured memory_bytes: 24892
#include<bits/stdc++.h>
#define int long long
using namespace std;
int two(int x)
{
	int sum=0;
	while(1){
		if(x%2==0)sum++;
		else break;
		x/=2;
	}
	return sum;
}
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int ans=0;
	int n,x;
	cin>>n;
	while(n--){
		cin>>x;
		ans+=two(x);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	s := scanText()

	w := []string{"SUN","MON","TUE","WED","THU","FRI","SAT"}

	var ans int

	for i := 0; i < 7; i++ {
		if s == w[i] {
			ans = 7-i
          	break
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  int mx = 0;
  rep(i, n) {
    if(s[i] == 'I') ans++;
    else ans--;
    mx = max(ans, mx);
  }
  cout << mx << endk;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2010,p=924844033;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int power(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=mul(x,x))
		if (y&1) ans=mul(ans,x);
	return ans;
}
int n,k,dp[N][N][4];
//dp[i][j][S]表示在前i个数中,k=1时,有j个位置不合法,最后i和i+1的状态为S的方案数
//这里只考虑不合法的位置赋值情况
int cnt[N][N],m,a[N];
int jc[N],calc[2][N],*x=calc[0],*y=calc[1];
int main()
{
	scanf("%d%d",&n,&k);
	dp[0][0][1]=1;
	for (int i=0;i<n;i++)
	for (int j=0;j<=i;j++)
	for (int S=0;S<4;S++){
		int v=dp[i][j][S];
		if (!(S&1)) dp[i+1][j+1][S>>1]=inc(dp[i+1][j+1][S>>1],v);//a[i+1]=i
		dp[i+1][j+1][S>>1|2]=inc(dp[i+1][j+1][S>>1|2],v);//a[i+1]=i+2
		dp[i+1][j][S>>1]=inc(dp[i+1][j][S>>1],v);//随便取
	}
	for (int i=0;i<=n;i++)
	for (int j=0;j<=i;j++)
		cnt[i][j]=inc(dp[i][j][0],dp[i][j][1]);
	for (int i=0;i<n%k;i++) a[++m]=n/k+1;
	for (;m<k;a[++m]=n/k);
	x[0]=1;
	for (int i=1;i<=m;i++){
		int now=a[i];
		for (int j=0;j<=n;j++) y[j]=0;
		for (int j=0;j<=n;j++)
		for (int k=0;k<=now&&k<=j;k++)
			y[j]=inc(y[j],mul(x[j-k],cnt[now][k]));
		swap(x,y);
	}
	jc[0]=1;
	for (int i=1;i<=n;i++) jc[i]=mul(jc[i-1],i);
	int ans=0;
	for (int i=0;i<=n;i++)
		if (i&1) ans=dec(ans,mul(x[i],jc[n-i]));
			else ans=inc(ans,mul(x[i],jc[n-i]));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 78080
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define MAX 1e9+7
#define MIN -1e9-7
#define int long long
#define endl "\n"
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define s(n) scanf("%d",&n)
#define mem memset(a, 0, sizeof(a))
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<string> vs;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
		  freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
    #endif
   
   int n;
   cin>>n;
   int loop=1e8+1;
   int check=0;
   bool flag=false;
   for(int i=1;i<loop;i++)
   {
     check+=7;
     if(check%n==0)
     {
         cout<<i;
         flag=true;
         break;
     }
     check*=10;
     check%=n;

// if(check==0)
// {
//     cout<<i;
//     flag=true;
//     break;
// }
   }
   if(!flag)
   {
       cout<<-1<<endl;
   }
return 0;
}


Measured memory_bytes: 3656