akhauriyash/Code-Regression huggingface dataset:
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}
const int MX=3e5+100;
int n,arr[MX],cm[MX];
int Left,Right,add;
bool can(int x){
 for(int i=1,j=x;j<=n;++i,++j){
  if(cm[j]-cm[i-1]+add>=x){
  Left=i,Right=j;
   return true;}
 }
 return false;
}
bool checkP(int n){
 vector<int>vr;
 while(n!=0){
 int a=n%10;
  n/=10;
 vr.push_back(a);}
 if(vr[0]==vr[4]&&vr[1]==vr[3])
 return true;
 return false;
}
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

   int a=RD(),b=RD(),cont=0;
   for(int i=a;i<=b;++i)
   if(checkP(i))
   cont++;
   cout<<cont;
 }


Measured memory_bytes: 256
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
A = inpl()
A.sort(reverse=True)
L = list(map(lambda a: len(bin(a))-2,A))
L.append(0)
l = L[0]
P = []
D = []
for i in range(N+1):
    if L[i] == l:
        continue
    elif i > M:
        break
    else:
        d = l - L[i]
        l = L[i]
        r = M // i
        if d < r:
            P.append(i)
            D.append(d)
            M -= d*i
        else:
            P.append(i)
            D.append(r)
            M -= r*i
            break
E = [0]
for dd in D[::-1]:
    E.append(E[-1]+dd)
i = 0
for n in range(len(P)):
    while i < P[n]:
        A[i] >>= E[-n-1]
        i += 1
A.sort(reverse=True)
for m in range(min(M,N)):
    A[m] >>= 1

print(sum(A))

Measured memory_bytes: 63984
#include <stdio.h>
#include <stdlib.h>
 
void main() {
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  int ans = 0;
  for(int i = 0; i < N; i++) {
    int *ptr = (int *)malloc(sizeof(int *));
    scanf("%d ", ptr);
    int tmp = (K - (*ptr));
    int a = (tmp > 0 ? tmp : (-tmp))*2;
    int b = (*ptr)*2;
    ans += (a > b ? b : a);
  }
  printf("%d\n", ans);

  __asm__("mov $0x0,%rax");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    ll dp[100][2];
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;

    rep(d, 0, 50) {
        ll mask = 1ll << (50 - d - 1);
        int num = 0;
        rep(i, 0, N) if(A[i] & mask) num++;

        ll cost0 = mask * num;
        ll cost1 = mask * (N - num);

        if(dp[d][1] != -1) chmax(dp[d + 1][1], dp[d][1] + max(cost0, cost1));

        if(dp[d][0] != -1) {
            if(K & mask) chmax(dp[d + 1][1], dp[d][0] + cost0);
        }

        if(dp[d][0] != -1) {
            if(K & mask) chmax(dp[d + 1][0], dp[d][0] + cost1);
            else chmax(dp[d + 1][0], dp[d][0] + cost0);
        }
    }

    cout << max(dp[50][0], dp[50][1]) << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <assert.h>
#include <stdio.h>

#define SIZE_OF_ARRAY(D) (sizeof(D)/sizeof(D[0]))

using namespace std;

int maxElement(const int* array, size_t size)
{
    assert(array != NULL);
    assert(size >= 1);

    int max = array[0];
    for (size_t i = 1; i < size; ++i) {
        if (max < array[i]) {
            max = array[i];
        }
    }

    return max;
}

int main()
{
    int K, N;

    cin >> K >> N;

    int A[N], D[N+1];

    // 始点から各家への距離を配列Aへ格納
    for(int i=0; i<N; i++)
    {
        cin >> A[i];
    }
    
    D[0] = A[0];
    for(int i=1; i<N; i++)
    {
        D[i] = A[i] - A[i-1];
    }
    D[N] = A[0] + (K - A[N-1]);

    int sum = accumulate(D, D+SIZE_OF_ARRAY(D), 0);
    int max = maxElement(D, SIZE_OF_ARRAY(D));

    cout << K -max << endl;

    return 0;

}

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

const int mo=int(1e9+7);
struct node{int l,r,x,n;}a[305];
int n,m,f[305][305][305],h[305],ans;

bool check(int i,int j,int k)
{
	for (int x=h[i]; x; x=a[x].n)
		{
			if ((a[x].x==1)&&(a[x].l<=j))  return 0;
			if ((a[x].x==2)&&((a[x].l>j)||(a[x].l<=k)))  return 0;
			if ((a[x].x==3)&&(a[x].l>k))  return 0;
		}
	return 1;
}

void work()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<=m; i++)
		scanf("%d %d %d",&a[i].l,&a[i].r,&a[i].x),a[i].n=h[a[i].r],h[a[i].r]=i;
	f[0][0][0]=1;
	for (int i=0; i<n; i++)
		for (int j=0; j<=i; j++)
			for (int k=0; k<=j; k++)
				if ((f[i][j][k])&&(check(i,j,k)))
					{
						f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%mo;
						f[i+1][i][k]=(f[i+1][i][k]+f[i][j][k])%mo;
						f[i+1][i][j]=(f[i+1][i][j]+f[i][j][k])%mo;
					}
	for (int j=0; j<=n; j++)
		for (int k=0; k<=j; k++)
			if (check(n,j,k))
				ans=(ans+f[n][j][k])%mo;
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


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

using namespace std;

int main(){
	int a;
	char b[110] , c[110];
	cin>>a;
	for(int i = 0 ; i < a ; i++) cin>>b[i];
	for(int i = 0 ; i < a ; i++) cin>>c[i];
	for(int i = 0 ; i < a ; i++) cout<<b[i]<<c[i];
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

minabs = 10 ** 10
resi = 0

for i, h in enumerate(H):
    res = abs(A - (T-h*0.006))
    if minabs > res:
        resi = i
        minabs = min(minabs, res)

print(resi+1)


Measured memory_bytes: 3064
from collections import defaultdict
N, M = map(int, input().split())
dict = defaultdict(int)
for _ in range(N):
    line = list(map(int, input().split()))
    K = line[0]
    A = line[1:]
    for a in A:
        dict[a] += 1
ans = 0
for k, v in dict.items():
    if v == N:
        ans += 1
print(ans)


Measured memory_bytes: 65496
x, y = map(int, input().split())
if x == y or x % y == 0:
  print(-1)
else:
  now = x
  k = 1
  M = pow(10, 18)
  while now <= M:
    now = k * now
    if now % y != 0:
      break
    k += 1
  print(now)

Measured memory_bytes: 3060
s = input()

ans = 0
p = "0"
q = ""
for i in range(len(s)):
    if p == "0":
        ans += 1
        p = s[i]
        continue

    q += s[i]
    if q == p:
        continue
    else:
        ans += 1
        p = q
        q = ""
        
print(ans)
        
    
        
        

                                        




    




        


    







        



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

int main(){
	int to_win[30];
	int n,k;
	double ans=0;
	double i_win_par=1;

	for(int i=0;i<30;i++){
		to_win[i]=0;
	}

	cin >> n >> k;

	for(int i=1;i<=n;i++){
		int how_times=0;
		int point=i;
		while(true){
			if(point>=k){
				break;
			}
			how_times++;
			point*=2;
		}
		to_win[how_times]++; 
	}
/*
	for(int i=0;i<30;i++){
		cout << to_win[i] << endl;
	}
*/

	for(int i=0;i<30;i++){

		ans+=i_win_par*to_win[i];
		i_win_par/=2;
	}

	ans/=n;


	cout << setprecision(15) << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,t;
  cin >> a >> b >> t;
  cout << (2*t+1)/(2*a)*b << endl;  
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    print("ABC{}".format(N))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<i64> a;

int main(){
  cin >> N;
  a.resize(N);
  rep(i,0,N - 1) cin >> a[i];
  if(a[0] != 0){
    cout<< -1 << endl;
    return 0;
  }
  i64 now = 0;
  i64 ans = 0;
  for(int i = N - 1;i > 0;i--){
    if(a[i] - now == 0){
    }
    else if(a[i] - now > 0){
      ans += a[i];
      now = a[i];
    }
    else{
      cout << -1 << endl;
      return 0;
    }
    now = max(0LL,now - 1);
  }
  if(now == 0){
    cout << ans << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);

		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);

		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());

	return 0;
}


Measured memory_bytes: 2748
#include<iostream>

int main(void)
{
    int data[10000];
    int i;
    i = 0;
    while(std::cin >> data[i]){
        if(data[i] == 0)
            break;
        i++;
    }
    i = 0;
    while(data[i] != 0){
        std::cout << "Case " << i+1 << ": " << data[i] << std::endl;
        i++;
    }
}


Measured memory_bytes: 3052
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll h,w;
    cin>>h>>w;
    vector<string> a(h);
    for(int i=0;i<h;i++){
        cin>>a[i];
    }
    vector<vector<ll>> ans(h,vector<ll>(w,0));
    for(int i=0;i<h;i++){
        ans[i][0]=1;//blue
        ans[i][w-1]=2;//red
    }
    for(int i=0;i<h;i++){
        for(int t=1;t+1<w;t++){
            ans[i][t]=(i&1?1:2);
        }
    }
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            if(a[i][t]=='#'){ans[i][t]=3;}
        }
    }
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            cout<<(ans[i][t]&1?'#':'.');
        }
        cout<<endl;
    }
    cout<<endl;
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            cout<<(ans[i][t]&2?'#':'.');
        }
        cout<<endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 2944
n = int(input())
ans, cnt = 1, 0
for i in range(1, n+1):
    j = i
    t_cnt = 0
    if i%2 == 0:
        # print(i)
        while i%2 == 0:
            i = i//2
            t_cnt += 1
            # print(i, t_cnt)
        if t_cnt >= cnt:
            ans = j
            cnt = t_cnt

print(ans)

Measured memory_bytes: 9084
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2="CODEFESTIVAL2016";
	cin>>s1;
	int ans=0;
	for(int i=0;i<s1.length();i++)
	if(s1[i]!=s2[i]) ans++;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;


int main(){
    int n; cin >> n;
    int step, x, y;
    for(int i = 0; i < n; i++){
        cin >> step >> x >> y;
        if((abs(x) + abs(y) > step) || ((abs(x) + abs(y)) % 2 == 0 && step % 2 != 0) || ((abs(x) + abs(y)) % 2 == 1 && step % 2 != 1)){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	vector<int>p;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		p.push_back(t);
	}
	int r=0;
	for(int i=1;i<=N-2;i++)
	{
		if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i+1]<p[i]&&p[i]<p[i-1]))r++;
	}
	cout<<r<<endl;

}

Measured memory_bytes: 3560
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,m,x,y,ans;
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m){
		scanf("%d%d",&x,&y);
		ans^=x^y;
	}
	if (!ans) printf("YES\n");else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int n; string s;
	int a=0,b=0;
	cin>>n>>s;
	rep(i,n){
		if(s[i] == 'R') a++; else b++;
	}
	if(a > b) puts("Yes");
	else puts("No");
}

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

const int MAX = 105;

int main() {
  int n;
  int p[MAX];
  int m[MAX][MAX];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i-1] >> p[i];
  }

  for (int i = 0; i <= n; i++) {
    m[i][i] = 0;
  }

  for (int i = 2; i <=n; i++) {
    for (int j = 1; j <= n - i + 1; j++) {
      int k = j + i - 1;
      m[j][k] = (1 << 21);
      for (int l = j; l < k; l++) {
        long long tmp = m[j][l] + m[l+1][k] + p[j-1] * p[l] * p[k];
        m[j][k] = m[j][k] > tmp ? tmp : m[j][k];
      }
    }
  }
  cout << m[1][n] << endl;
  return 0;
}



Measured memory_bytes: 3128
n, m = gets.chomp.split(' ').map(&:to_i)

connect_arr = []
m.times do |i|
  a = gets.chomp.split(' ').map(&:to_i)
  connect_arr[i] = a[1..a.size]
end
p_arr = gets.chomp.split(' ').map(&:to_i)

sum = 0
(2 ** n).times do |i|
  success = true
  switch_arr = format("%0#{n}d", i.to_s(2).to_i).split('').map(&:to_i)
  connect_arr.each_with_index do |arr, i|
    s = 0
    arr.each do |num|
      s += switch_arr[num-1]
    end
    if s % 2 != p_arr[i]
      success = false
      break
    end
  end
  sum += 1 if success
end
puts sum


Measured memory_bytes: 3964
#include <iostream>
#include <vector>

int main()
{
    std::string s, t;
    std::cin >> s;
    std::cin >> t;

    int s_len = int(s.length());
    int t_len = int(t.length());

    std::vector<std::vector<int>> alphabet_locations(26);

    for (int i = 0; i < s_len; i++) {
        alphabet_locations[s[i] - 'a'].push_back(i);
    }
    for (int i = 0; i < s_len; i++) {
        alphabet_locations[s[i] - 'a'].push_back(i + s_len);
    }

    long long ans = 0;
    int pointer = 0;
    for (int i = 0; i < t_len; i++) {
        int id = t[i] - 'a';
        if (!int(alphabet_locations[id].size())) {
            std::cout << -1 << std::endl;
            return 0;
        }

        pointer = *lower_bound(alphabet_locations[id].begin(), alphabet_locations[id].end(), pointer) + 1;

        if (pointer >= s_len) {
            pointer -= s_len;
            ans += s_len;
        }
    }

    ans += pointer;
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1724
#include<iostream>
using namespace std;
int main()
{
  int x,y,g1,g2;
  cin >> x >> y;
  if(x==4||x==6||x==9||x==11)
    g1=2;
  else if(x==2)
    g1=3;
  else
    g1=1;
  if(y==4||y==6||y==9||y==11)
    g2=2;
  else if(y==2)
    g2=3;
  else
    g2=1;
  if(g1==g2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
t = gets.chomp
max = 0;
t.size.times do |i|
	temp = t[i..-1].match(/[ATCG]+/).to_s.size
	max = temp if temp > max
end
t.size.times do |i|
	temp = t[0..-(i+1)].match(/[ATCG]+/).to_s.size
	max = temp if temp > max
end

puts max

Measured memory_bytes: 1788
//code by 27.
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
int main()
{
	string st;
	cin>>st;
	int g=0;
	int l=0,r=st.size()-1;
	while(l<=r)
	{
		if(st[r]==st[l])
		{
			r--;
			l++;
			continue;
		}
		else
		{
			if(st[r]=='x')
			{
				r--;
				g++;
				continue;
			}
			else if(st[l]=='x')
			{
				l++;
				g++;
				continue;
			}
			else if(st[l]!=st[r]&&st[l]!='x'&&st[r]!='x')
			{
				cout<<-1;
				return 0;
			}
		}
	}
	cout<<g;
	return 0;
}

Measured memory_bytes: 512
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main{
	static Map<Long,Long> map= new TreeMap<>();
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long n=sc.nextLong();
	  primeEnum(n);
	  long res=0;
	  for (long key : map.keySet()){
		  	int i=1;
		  	while(map.get(key)>i*(i+1)/2) {
		  		i++;
		  		if(map.get(key)<i*(i+1)/2) {
		  			i--;
		  			break;
		  		}
		  	}
		  	//System.out.println(map.get(key)+" "+i);
	    	res+=i;
	    }
	  System.out.println(res);
	  //System.out.println(map.toString());
  }
	public static Map<Long,Long> primeEnum(long n) {
		for(long i=2;i<=Math.sqrt(n);i++) {
			if(n%i!=0)continue;
			long e=0;
			while(n%i==0) {
				e++;
				n/=i;
			}
			if(map.containsKey(i)) {
				map.put(i, e+map.get(i));
			}else {
				map.put(i, e);
			}
		}
		if(n!=1) {
			if(map.containsKey(n)) {
				map.put(n, 1+map.get(n));
			}else {
				map.put(n, 1L);
			}
		}
		return map;
	}
	public static long GCD(long min,long max) {
		if(max%min==0)return min;
		else return GCD(max%min,min);
	}
}



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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string ch;
    string ch1;
    cin>>ch>>ch1;
    int s,t;
    s=ch.size();
    t=ch1.size();
    int track[s+1][t+1];
    for(int i=0;i<t+1;i++)
        track[0][i]=0;
    for(int i=0;i<s+1;i++)
        track[i][0]=0;
    for(int i=1;i<s+1;i++)
    {
        for(int j=1;j<t+1;j++)
        {
            if (ch[i-1]==ch1[j-1])
                track[i][j]=1+track[i-1][j-1];
            else
            {
                if (track[i-1][j]>track[i][j-1])
                    track[i][j]=track[i-1][j];
                else
                    track[i][j]=track[i][j-1];
            }
        }
    }
    int i=s;
    int j=t;
    string res="";
    while((j>=1)and(i>=1))
        {
        if (track[i][j]>max(track[i-1][j],track[i][j-1]))
            {
                res=ch[i-1]+res;
                i--;
                j--;
            }
        else
            {
            if (track[i-1][j]>track[i][j-1])
                    i--;
            else
                    j--;
            }

        }
    cout<<res;

    return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 200005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int tc=1;

void solve(int kk)
{

   ll a,b,c, sub;

   cin >> a >> b;

   c = a%b;
   sub = abs(c-b);

   cout << min(sub,c) << "\n";


}

int main()
{
   fast;
   int kk=0;
//   cin >> tc;
   while(++kk<=tc) solve(kk);

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
const int MAX = 50;
int n, m, a[MAX], b[MAX], ans;
bool graph[MAX][MAX], visited[MAX];

void dfs(int v) {
    visited[v] = true;
    rep(i, n) {
        if (!graph[v][i]) continue;
        if (visited[i]) continue;
        dfs(i);
    }
}

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    rep(i, m) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        rep(i, n) visited[i] = false; // init

        dfs(0);

        rep(i, n) {
            if (!visited[i]) {
                ans++;
                break;
            }
        }
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}

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

const int MAX_N = 200 * 1000, MAX_Q = 200 * 1000;
vector<int> adjLis[MAX_N + 1];
int counter[MAX_N + 1];

void dfs(int preVer, int v) {
    int u;
    for (int i = 0; i < adjLis[v].size(); i++) {
        u = adjLis[v][i];
        if (u != preVer) {
            counter[u] += counter[v];
            dfs(v, u);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, Q, a[MAX_N], b[MAX_N], p[MAX_Q], x[MAX_Q];
    cin >> N >> Q;
    for (int i = 0; i < N - 1; i++) {
        cin >> a[i] >> b[i];
        adjLis[a[i]].push_back(b[i]);
        adjLis[b[i]].push_back(a[i]);
    }
    for (int j = 0; j < Q; j++) {
        cin >> p[j] >> x[j];
        counter[p[j]] += x[j];
    }
    dfs(0, 1);
    for (int i = 1; i < N; i++)
        cout << counter[i] << " ";
    cout << counter[N] << '\n';
    return 0;
}


Measured memory_bytes: 29696
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);



int main() 
{
  ll N; cin>>N;
  vector<int> f(N+1,0);
  for(int x=1;x<=100;x++)
  {
    for(int y=1;y<=100;y++)
    {
      for(int z=1;z<=100;z++)
      {
        int n=x*x+y*y+z*z+x*y+y*z+z*x;
        if(n<=N) f.at(n)++;
      }
    }
  }
  rep(i,N)
  {
    cout<<f.at(i+1)<<endl;
  }  
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=2000005;
const int MOD=1000000007;

int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6,jc[N],ny[N];
struct data{int x,y,c;}a[4],b[4];

int C(int x1,int y1,int x2,int y2)
{
    return (LL)jc[x2-x1+y2-y1]*ny[x2-x1]%MOD*ny[y2-y1]%MOD;
}

int solve(data a,data b)
{
    int x1=a.x,y1=a.y,x2=b.x,y2=b.y,ans=0;
    for (int i=x3;i<=x4;i++) (ans+=(LL)C(x1,y1,i,y3-1)*C(i,y3,x2,y2)%MOD*(-i-y3)%MOD)%=MOD;
    for (int i=y3;i<=y4;i++) (ans+=(LL)C(x1,y1,x3-1,i)*C(x3,i,x2,y2)%MOD*(-i-x3)%MOD)%=MOD;
    for (int i=x3;i<=x4;i++) (ans+=(LL)C(i,y4+1,x2,y2)*C(x1,y1,i,y4)%MOD*(i+y4+1)%MOD)%=MOD;
    for (int i=y3;i<=y4;i++) (ans+=(LL)C(x4+1,i,x2,y2)*C(x1,y1,x4,i)%MOD*(i+x4+1)%MOD)%=MOD;
    return ans;
}

int main()
{
    scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6);
    scanf("%d%d%d%d%d%d",&y1,&y2,&y3,&y4,&y5,&y6);
    jc[0]=jc[1]=ny[0]=ny[1]=1;
    for (int i=2;i<=x6+y6;i++) jc[i]=(LL)jc[i-1]*i%MOD,ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
    for (int i=2;i<=x6+y6;i++) ny[i]=(LL)ny[i-1]*ny[i]%MOD;
    a[0]=(data){x2,y2,1};a[1]=(data){x2,y1-1,-1};a[2]=(data){x1-1,y2,-1};a[3]=(data){x1-1,y1-1,1};
    b[0]=(data){x6+1,y6+1,1};b[1]=(data){x6+1,y5,-1};b[2]=(data){x5,y6+1,-1};b[3]=(data){x5,y5,1};
    int ans=0;
    for (int i=0;i<4;i++)
        for (int j=0;j<4;j++)
            (ans+=a[i].c*b[j].c*solve(a[i],b[j]))%=MOD;
    printf("%d",(ans+MOD)%MOD);
    return 0;
}

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

template<typename OperatorMonoid>
struct DualSegmentTree{
    typedef function<OperatorMonoid(OperatorMonoid,OperatorMonoid)> H;
    int n,hi;
    H h;
    OperatorMonoid id1;
    vector<OperatorMonoid> laz;
    DualSegmentTree(int n_,H h,OperatorMonoid id1):h(h),id1(id1){init(n_);}
    void init(int n_){
        n=1,hi=0;
        while(n<n_) n<<=1,++hi;
        laz.assign(n<<1,id1);
    }
    inline void propagate(int k){
        if (laz[k]==id1) return;
        laz[k<<1|0]=h(laz[k<<1|0],laz[k]);
        laz[k<<1|1]=h(laz[k<<1|1],laz[k]);
        laz[k]=id1;
    }
    inline void thrust(int k){
        for (int i=hi;i;--i) propagate(k>>i);
    }
    void update(int a,int b,OperatorMonoid x){
        if (a>=b) return;
        thrust(a+=n),thrust(b+=n-1);
        for (int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if (l&1) laz[l]=h(laz[l],x),++l;
            if (r&1) --r,laz[r]=h(laz[r],x);
        }
    }
    void set_val(int k,OperatorMonoid x){
        thrust(k+=n);
        laz[k]=x;
    }
    OperatorMonoid operator[](int k){
        thrust(k+=n);
        return laz[k];
    }
};

// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_D

void DSL_2_D(){
    int n,q; cin >> n >> q;
    auto h=[](int a,int b){return b;};
    DualSegmentTree<int> seg(n,h,INT_MAX);
    for (;q--;){
        int c,s,t,x,i; cin >> c;
        if (!c){
            cin >> s >> t >> x;
            seg.update(s,t+1,x);
        } else {
            cin >> i;
            cout << seg[i] << '\n';
        }
    }
}

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


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

using namespace std;

int main(){
  string str1="CODEFESTIVAL2016";
  string str2;
  cin >> str2;
  int count=0;
  for(int i=0;i<str2.size();i++){
    if(str1[i]!=str2[i]){
      count++;
    }
  }
  cout <<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define mod 1000000007
#define MOD 99824435300000000
inline ll mul(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll c=a*b;
  c=(c+MOD)%MOD;
  return c;
}
inline ll add(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll ans=(a+b);
  ans=(ans+MOD)%MOD;
  return ans;
}

ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=mul(ans,a);
    }
    a=mul(a,a);
    b=b/2;
  }
  return ans;
}
inline ll max(ll a,ll b){return a>b?a:b;}
inline ll min(ll a,ll b){return a<b?a:b;}
ll find(std::vector<std::vector<ll> > &v,int ind,int w,ll a[][2],int n){
  if(w<0)return -MOD;
  if(ind==n)return 0;
  if(v[ind][w]!=-1)return v[ind][w];
  ll xx=find(v,ind+1,w,a,n);
  ll yy=a[ind][1]+find(v,ind+1,w-a[ind][0],a,n);
  return v[ind][w]=max(xx,yy);
}
int main()
{
  ll n,w; cin>>n>>w;
  ll a[n][2];
  for(int i=0;i<n;++i)cin>>a[i][0]>>a[i][1];
  vector<vector<ll> > res(n+1,vector<ll>(w+1,-1));
  ll ans=find(res,0,w,a,n);
  cout<<ans;
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=2e5+5;

lli A[MAX];
unordered_map<lli, int> M;

int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    int N; si(N);
    for(int i=0; i<N; i++) {
        sll(A[i]); M[A[i]]++;
    }

    sort(A, A+N);

    int ans = 0;
    for(int i = N-1; i >= 0; i--) {
        lli base = 1;
        while(base <= A[i])
            base <<= 1;
        int ret = M[base-A[i]];
        if(base == 2*A[i] && ret >= 2) {
            ans++; M[A[i]] -= 2;
        }
        else if(base != 2*A[i] && ret > 0 && M[A[i]]>0) {
            ans++; M[A[i]]--; M[base-A[i]]--;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 18420
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(ll &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int n;
int a[DMAX],b[DMAX];
int st[DMAX];
ll la,lb;
ll pos=1;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	for(int i=1;i<=n;i++){
		st[i]=i;
	}
	do{
		bool flag1=1,flag2=1;
		for(int i=1;i<=n;i++){
			if(a[i]!=st[i]){
				flag1=0;
			}
		}
		for(int i=1;i<=n;i++){
			if(b[i]!=st[i]){
				flag2=0;
			}
		}
		if(flag1==1){
			la=pos;
		}
		if(flag2==1){
			lb=pos;
		}
		pos++;
	}while(next_permutation(st+1,st+n+1));
	cout<<abs(la-lb)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
  int n,k;
  cin >> n >> k;
  long long a = n / k;
  if(k % 2 == 1)
    cout << a * a * a << endl;
  else
{
    long long b = n / (k / 2);
  	long long c = b - a;
    cout << a * a * a + c * c * c << endl;
  }
 
  return 0;
}

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

int main() {
  int a;
  cin >>a;
  int c[1000],d[1000];
  for(int i=0;i<a;i++){
    cin >> c[i]>>d[i];
  }
 int e;
  e =0;
    
  for(int i=0;i<a;i++){
   
    e += (d[i]-c[i]+1);
  }
  
  
  cout << e << endl;
    
  
}


Measured memory_bytes: 256
n = int(input())
max1 = 0
max2 = 0
index = 0
for i in range(n):
    a = int(input())
    new_max = max(a, max1)
    if (a == new_max and max2 <= max1) or (a == new_max and max2 <= max1 and a == max1):
        max2 = max1
        index = i
    elif (a != new_max and max2 <= a) or (a != new_max and max2 <= a and a == max1):
        max2 = a
    max1 = new_max

for i in range(n):
    if i != index:
        print(max1)
    else:
        print(max2)


Measured memory_bytes: 55768
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct UnionFind {
    vector<int> rank, parent, size;

    // +1 for 1-indexed nodes
    UnionFind(int n) : rank(n + 1, 0), parent(n + 1), size(n + 1, 1) {
        iota(parent.begin(), parent.end(), 0); // parent is itself
    }
    int root(int x) {
        if (x != parent[x]) {
            parent[x] = root(parent[x]);
        }
        return parent[x];
    }
    bool isSame(int x, int y) { return root(x) == root(y); }
    bool unite(int x, int y) { return link(root(x), root(y)); }
    bool link(int x, int y) {
        if (x == y)
            return false;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        } else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
        return true;
    }
    int getSize(int x) { return size[root(x)]; }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<vector<int>> fr(n), bl(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        fr[a].emplace_back(b);
        fr[b].emplace_back(a);
        uf.unite(a, b);
    }
    vector<int> ret(n, 0);
    for (int i = 0; i < n; ++i) {
        ret[i] = uf.getSize(i) - 1 - fr[i].size();
    }
    for (int i = 0; i < k; ++i) {
        int c, d;
        cin >> c >> d;
        c--, d--;
        if (uf.isSame(c, d)) {
            ret[c]--;
            ret[d]--;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (i != 0)
            cout << " ";
        cout << ret[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
  int a, b;

  cin >> a >> b;

  if(a==b){
    cout << "Draw" << endl;
  }  
  else if(a==1){
    cout << "Alice" << endl;
  }
  else if(b==1){
    cout << "Bob" << endl;
  }  
  else if(a > b){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1016
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;


int main() {
    long x,y,xx,yy;
    scanf ("%ld %ld",&x,&y);
    xx=x;
    yy=y;
    while(y!=0){
      xx=x;
      yy=y;
      if(y==0){
        
      }
      else{
        y=xx%yy;
        x=yy;
      }
    }
    printf("%ld\n",x);

}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, mx, a[100005][3], dp[100005][3];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
                }
            }
        }
    }

    for (int i = 0; i < 3; i++)
        mx = max(mx, dp[n-1][i]);

    cout << mx << '\n';
 
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#define NMAX 3
int main(){
    using namespace std;
    vector<int> v;
    int tmp;
    for(int i=0;i<NMAX;i++){
        cin>>tmp;
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size()-1;i++){
        cout<<v[i]<<" ";
    }
    cout<<v[v.size()-1]<<endl;
    

}


Measured memory_bytes: 3104
#include <stdio.h>
#include <math.h>
#include <string.h>

int gcd(int a,int b){
    if(a<b){
        int now=a;
        a=b;
        b=a;
    }

    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }

    return b;
}


int main(void){
  int x;
  scanf("%d",&x);
  
  printf("%d\n",360/gcd(360,x));

  return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>

int main(void){
  int a,b,c,count;
  for(;;){
    if(scanf("%d %d",&a,&b)==EOF) break;
    count=0;
    c=a+b;
    for(;;){
      c=c/10;
      count++;
      if(c==0) break;
    }
    printf("%d\n",count);
  }
  return 0;
}


Measured memory_bytes: 1836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <sstream>
#include <functional>

#define rep(i,n) for(long long i=0;i<n;i++)
using namespace std;



int main() {

	int n,k;
	cin >> n>>k;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	vector<int> ss(n + 1);
	vector<int> sum(n - k + 1);

	ss[0] = 0;
	for (int i = 1; i < n + 1; i++)
	{
		ss[i] = ss[i - 1] + p[i - 1];
	}



	rep(i, n - k + 1)
	{
		sum[i] = 0;
		sum[i] = ss[i + k] - ss[i];
	}

	int max = sum[0];
	int index;
	rep(i, n - k + 1)
	{
		if (sum[i] > max)
		{
			max = sum[i];
			index = i;
		}
	}
	
	double ans = 0;
	for(int i=index;i<index+k;i++)
	{
		if (p[i] % 2 == 0)
		{
			ans +=  (1.0 + double(p[i])) / 2.0;
		}
		else
		{
			double x = 1.0 + double(p[i]);
			ans += (x*(x/2-1)+x/2) / double(p[i]);
		}
		
	}


	
	printf("%lf", ans);

	return 0;
}




Measured memory_bytes: 2560
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int N = s.length();
        sc.close();

        int idx = 0;
        int min = 100;
        while(idx < 26){
            char c = (char)('a' + idx);
            if(include(s, c)){
                int cnt = 0;
                String now = s;
                while(!(check(now, c))){
                    String str = "";
                    for(int i = 0; i < now.length()-1; i++){
                        if(now.charAt(i) == c || now.charAt(i+1) == c){
                            str += c;
                        } else {
                            str += now.charAt(i);
                        }
                    }
                    cnt++;
                    now = str;
                    //System.out.println(now);
                }
                min = Math.min(min, cnt);
            } 
            idx++;
        }
        System.out.println(min);
    }

    static boolean include(String s, char c){
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == c)
                return true;
        }
        return false;
    }

    static boolean check(String s, char c){
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) != c)
                return false;
        }
        return true;
    }
}

Measured memory_bytes: 38356
x, n = map(int, input().split())
ps = set(map(int, input().split()))

i = 0
while True:
    if (x - i) not in ps:
        print(x - i)
        exit(0)
    if (x + i) not in ps:
        print(x + i)
        exit(0)
    i += 1

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<tuple<int, int, int>> ai;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    ai.emplace_back(abs(t), t, i);
  }
  sort(ai.begin(), ai.end());
  reverse(ai.begin(), ai.end());
  int l = -1, r = n;
  for (auto const& e : ai) {
    int a, i; tie(ignore, a, i) = e;
    if (l < i && i < r) {
      if (a > 0) r = i;
      else l = i;
    }
  }
  vector<pair<int, int>> ret;
  for (int i = l - 1; i >= 0; i--) {
    for (int t = 0; t < 2; t++) {
      ret.emplace_back(i + 1, i);
    }
  }
  for (int i = r; i < n - 1; i++) {
    for (int t = 0; t < 2; t++) {
      ret.emplace_back(i, i + 1);
    }
  }
  cout << ret.size() << endl;
  for (auto const& p : ret) {
    cout << p.first + 1 << " " << p.second + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front

using namespace std;

int main(){
	int n;
	deque<int> dq;
	cin >> n;
	for(int i=0; i<n; i++){
		int a; cin >> a;
		if(i%2) dq.pb(a);
		else dq.pf(a);
	}
	if(n%2 == 0) reverse(dq.begin(),dq.end());
	for(int i:dq) cout << i << " ";
}


Measured memory_bytes: 3580
#include <cstdio>
#include <set>

using namespace std;

int a[200000];
int p[200000];

int main() {
    int n, k, ans = 1, c = 0, i;
    set <int> s;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) scanf("%d", &p[i]);
    
    a[0] = 1;
    for (i = 1; i < n; i++) {
        if (p[i] > p[i - 1]) {
            a[i] = a[i - 1] + 1;
        } else {
            a[i] = 1;
        }
    }
    
    if (a[k - 1] == k) c = 1;
    
    for (i = 0; i < k; i++) s.insert(p[i]);
    
    for (i = k; i < n; i++) {
        s.insert(p[i]);
        
        if (a[i] >= k) {
            if (c == 0) ans++;
            c = 1;
        } else if (*s.begin() != p[i - k] || *s.rbegin() != p[i]) {
            ans++;
        }
        
        s.erase(p[i - k]);
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 11264
#include<stdio.h>
int main()
{
    int n,i;
   long long  s;
    scanf("%d",&n);

        s=1;
        for(i=2;i<=n;i++)
        {
            s*=i;
            s=s%1000000007;
        }
        printf("%lld\n",s);

    return 0;
}


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

int main(){
	ll h;
	cin>>h;
	deque<ll> monster;
	ll two=1;
  	ll ans=0;
	while(h>0){
      h/=2;
      ans+=two;
      two*=2;
	}
	cout << ans << endl;
}

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

ll N;

void solve() {
	cin >> N;
	vector<int> vec;
	while(N != 0) {
		if((4 + N % 4) % 4 == 0) {
			vec.pb(0); vec.pb(0);
		}
		else if((4 + N % 4) % 4 == 1) {
			vec.pb(1); vec.pb(0);
			N -= 1;
		}
		else if((4 + N % 4) % 4 == 2) {
			vec.pb(0); vec.pb(1);
			N += 2;
		}
		else if((4 + N % 4) % 4 == 3) {
			vec.pb(1); vec.pb(1);
			N += 1;
		}
		N /= 4;
	}
	reverse(all(vec));
	bool found = false;
	string str;
	rep(i, 0, sz(vec)) {
		if(vec[i] == 1) found = true;
		if(found) str += char(vec[i] + '0');
	}
	if(sz(str) == 0) cout << 0 << "\n";
	else cout << str << "\n";
}

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



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
	ll n, k;
	cin >> n >> k;
	map<ll, ll> m;
	for (int i = 0; i < n; i++){
		ll a, b;
		cin >> a >> b;
		m[a] += b;
	}
	for (auto x : m){
		if (k <= x.second){
			cout << x.first << endl;
			break;
		}
		k -= x.second;
	}
		
}


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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  int ans = 0;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    while (a % 2 == 0) a /= 2, ans++;
  }

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

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		int[] H = new int[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			H[i] = Integer.parseInt(tokens[i]);
		}
		in.close();

		int count = 1;
		int max = H[0];
		for (int i = 1; i < N; ++i) {
			if (max <= H[i]) {
				++count;
			}
			max = Math.max(max, H[i]);
		}
		System.out.println(count);
	}

}


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

using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    S.erase(std::unique(S.begin(), S.end()), S.end());
    cout << S.size();
}


Measured memory_bytes: 9520
import collections

H, W = map(int, input().split())
S = [int(input()) for _ in range(H)]
sa = 1000000000000
c = collections.Counter(S)
B = c.most_common()
if B[0][1] >= W:
  print("0")

else:
  A = sorted(S, reverse=True)
  for i in range(len(A)-W+1):
    if sa > A[i]-A[i+W-1]:
      sa = A[i]-A[i+W-1]
  
    if sa == 1:
      break

  print(sa)



Measured memory_bytes: 21756