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

/* Note that the second condition for lexicographical ordering is
 * irrelevant because all candidate strings are concatenated from
 * the same strings, meaning that they all have the same length.
 * 
 * Also note that lexicographical ordering is just "dictionary ordering." */

int main()
{
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; ++i) cin >> S[i];
	sort(S.begin(), S.end());
	string ans = "";
	for (int i = 0; i < N; ++i) ans += S[i];
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int crr[5000]={0};
int main()
{
	long long n,m;
	cin>>n>>m;
	if(n*2>=m)
	{
		cout<<m/2;
		return 0;
	}
	else
	{
		cout<<n+(m-2*n)/4;
	}
 } 

Measured memory_bytes: 256
n = int(input())
a = [i for i in input().split()]
a2 = a.copy()
for i in range(n):
    for j in reversed(range(i+1, n)):
        if a[j][1] < a[j-1][1]:
            a[j], a[j-1] = a[j-1], a[j]
for s in range(n):
    minj = s 
    for t in range(s+1, n):
        if a2[t][1] < a2[minj][1]:
            minj = t
    if a2[s] != a2[minj]:
        a2[s], a2[minj] = a2[minj], a2[s]
print(*a)
print("Stable")
print(*a2)
if a == a2:
    print("Stable")
else:
    print("Not stable")


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

using namespace std;

class Dice{
public:
    int f[6];

    void roll_z(){roll(1,2,4,3);}
    void roll_y(){roll(0,2,5,3);}
    void roll_x(){roll(0,1,5,4);}

    void roll(int a,int b,int c,int d){
        int t = f[a]; f[a] = f[b]; f[b] = f[c]; f[c] = f[d]; f[d] = t;
    }
    void move(char command){
        if(command == 'N') roll_x();
        if(command == 'S') for(int i=0;i<3;i++) roll_x();
        if(command == 'W') roll_y();
        if(command == 'E') for(int i=0;i<3;i++) roll_y();
    }

};

int main(){
    Dice dice;
    for(int i=0;i<6;i++) cin >> dice.f[i];
    string commands;
    cin >> commands;
    for(int i=0;i<commands.size();i++) dice.move(commands[i]);
    cout << dice.f[0] << endl;
    return 0;
}



Measured memory_bytes: 3216
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	int a[100010];
	int cnt[100010]={};
	for(int i=0; i<n; i++){
		cin>>a[i]; a[i]--;
		cnt[a[i]]++;
	}
	if(n==2){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0; i<n; i++){
		if(cnt[i]==n-1){
			cout<<i+1<<" ";
			bool used[100010]={};
			for(int j=0; j<n; j++){
				if(i!=j && a[i]!=j){
					cout<<j+1<<" ";
					used[i]=used[j]=1;
					break;
				}
			}
			for(int j=0; j<n; j++){
				if(!used[j]) cout<<j+1<<" ";
			}
			cout<<endl;
			return 0;
		}
	}
	vector<int> ans;
	int x=0;
	set<int> st;
	bool used[100010]={};
	used[0]=1;
	for(int i=1; i<n; i++) st.insert(i);
	for(int i=0; i<n-1; i++){
		if(cnt[a[x]]==n-1-i){
			int pr=ans.back();
			if(i==n-2){
				ans.pop_back();
				if(!ans.empty()){
					int z=ans.back();
					if(a[z]==min(x, a[x])){
						ans.push_back(max(x, a[x]));
						ans.push_back(pr);
						ans.push_back(min(x, a[x]));
						break;
					}
				}
				ans.push_back(min(x, a[x]));
				ans.push_back(pr);
				ans.push_back(max(x, a[x]));
				break;
			}
			ans.push_back(a[x]);
			st.insert(x);
			st.erase(a[x]);
			int y;
			if(*st.begin()==a[a[x]]){
				auto itr=st.begin();
				itr++;y=*itr;
				ans.push_back(y);
			}else{
				y=*st.begin();
				ans.push_back(y);
			}
			st.erase(y);
			for(auto z:st) ans.push_back(z);
			break;
		}else{
			int y;
			if(*st.begin()==a[x]){
				auto itr=st.begin(); itr++;
				y=*itr;
			}else{
				y=*st.begin();
			}
			st.erase(y);
			if(!used[a[x]]) cnt[a[x]]--;
			cnt[x]=0;
			used[x]=1;
			ans.push_back(x);
			x=y;
		}
	}
	if(ans.size()==n-1) ans.push_back(x);
	for(auto z:ans) cout<<z+1<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 6940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        x = new double[n];
        y = new double[n];
        int[] permutation = new int[n];
        for(int i=0; i<n; i++) {
            x[i] = in.nextDouble();
            y[i] = in.nextDouble();
            permutation[i] = i;
        }
        calc(permutation, n);
//        System.out.println(sum);
//        System.out.println(c);
        System.out.println(sum / c);
    }
    private static double[] x = null;
    private static double[] y = null;
    private static double sum = 0.0d;
    private static int c = 0;
    private static void calc(int[] permutation, int m) {
        if(m == 1) {
            for(int i=1; i<permutation.length; i++) {
                double x2 = Math.pow(x[permutation[i-1]] - x[permutation[i]], 2);
                double y2 = Math.pow(y[permutation[i-1]] - y[permutation[i]], 2);
                sum += Math.sqrt(x2 + y2);
            }
            c++;
        }
        else {
            for(int i=0; i<m-1; i++) {
                calc(permutation, m-1);
                if(m%2 == 0) {
                    swap(permutation, i, m-1);
                }
                else {
                    swap(permutation, 0, m-1);
                }
            }
            calc(permutation, m-1);
        }
    }
    private static void swap(int[] permutation, int i, int j) {
        int t = permutation[i];
        permutation[i] = permutation[j];
        permutation[j] = t;
    }
}


Measured memory_bytes: 27748
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
flag = 0


a.each do |i|
  if i % 2 == 0
    if i % 3 == 0 or i % 5 == 0
      next
    else
      flag = 1
    end
  end
end

if flag == 1
  puts 'DENIED'
else
  puts 'APPROVED'
end

Measured memory_bytes: 1788
$<.map{|i|a=i.chop.split(?,).map(&:to_i).sort;b=a.uniq.map{|j|a.count(j)}.sort.reverse;s=b.size;puts b[0]>3?"four card":b[0]>2?s>2?"three card":"full house":b[0]>1?s>3?"one pair":"two pair":a[4]-a[0]<5||a[1]>9?:straight: :null}

Measured memory_bytes: 8608
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

typedef long long int ll;

int main () {
    string s; cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
     
    return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;

signed main() {
    string S;
    cin >> S;

    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            ++cnt;
        } else {
            cnt = 0;
        }
        
        ans = max(cnt, ans);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

S = []
H = []
C = []
D = []

matome = []
all_number = list(range(1, 14))

for _ in range(n):
    g, num = map(str, input().split())
    if g == "H":
        H.append(int(num))
    elif g == "S":
        S.append(int(num))
    elif g == "D":
        D.append(int(num))
    else:
        C.append(int(num))
        
matome = [S, H, C, D]

resultS = list(filter(lambda x: x not in S,all_number ))
resultH = list(filter(lambda x: x not in H,all_number ))
resultC = list(filter(lambda x: x not in C,all_number ))
resultD = list(filter(lambda x: x not in D,all_number ))

if resultS:
    for i in resultS:
        print("S", i)
if resultH:
    for i in resultH:
        print("H", i)
if resultC:
    for i in resultC:
        print("C", i)
if resultD:
    for i in resultD:
        print("D", i)




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

#define MOD 1000000007
#define si(x) scanf("%d",&x);
#define sii(x,y) scanf("%d%d",&x,&y);
#define siii(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define pi(x) printf("%d",x);
#define pii(x,y) printf("%d%d",x,y);
#define piii(x,y,z) printf("%d%d%d",x,y,z); 
#define sl(x) scanf("%lld",&x);
#define sll(x,y) scanf("%lld%lld",&x,&y);
#define slll(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);
#define pl(x) printf("%lld",x);
#define pll(x,y) printf("%lld%lld",x,y);
#define plll(x,y,z) printf("%lld%lld%lld",x,y,z);  

#define ll long long
#define mp make_pair
#define pb push_back
#define pp pop_back
#define nl printf("\n");
#define sf scanf
#define pf printf
#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define tci int t;scanf("%d",&t);while(t--)
int main()
{
    int n,k,a=0;
    sii(n,k)
    int x[n],i,j;
    for(i=0;i<n;i++)
    {
        si(x[i])
        if((x[i]-0)<=(k-x[i]))
            a=a+(2*x[i]);
        else
            a=a+(2*(k-x[i]));
    }
    pi(a)
  return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long mo=1000000007;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long N,ret=1;
	string s;
	cin >> N >> s;
	map<char,long long> m;
	for (auto& i:s) m[i]++;
	for (auto& i:m){
		ret *= (i.second+1)%mo;
		ret %= mo;
	}
	if (ret == mo) cout << 0;
	else cout << (ret%mo)-1;
	return 0;
}

Measured memory_bytes: 512
A=[[int(i) for i in input().split(" ")]for k in range(3)]
N=int(input())
for i in range(N):
    b=int(input())
    for x,y in [(x,y) for x in range(3) for y in range(3) if A[x][y]==b]:
        A[x][y]=0

M=1
for k in range(3):
    M*=sum(A[i][k] for i in range(3))
    M*=sum(A[k][i] for i in range(3))
M*=sum(A[i][i] for i in range(3))
M*=sum(A[i][2-i] for i in range(3))
if M==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
H = int(input())
W = int(input())
N = int(input())
HW =H*W
ans =H+W
for h in range(0,H+1):
    for w in range(0,W+1):
        cntB = HW - (H-h)*(W-w)
        if cntB>=N:
            ans = min(ans, h+w)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
ll power(ll a,ll b)
{
    if(b<0)
        return 1;
    if(b==0)
        return 1;
    ll x=power(a,b/2);
    x*=x;
    x%=mod;
    if(b%2)
        x*=a;
    x%=mod;
    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi c(n);
    for(ll i=0;i<n;i++)
        cin>>c[i];
    sort(c.begin(),c.end());
    ll ans=0;
    for(ll j=0;j<n;j++)
    {
        ll x=power(4,j);
        x*=power(2,n-j);
        x%=mod;
        x*=c[j];
        x%=mod;

        ll y=(n-j)*power(2,n-j-1);
        y%=mod;
        y-=((n-j-1)*power(2,n-j-2))%mod;
        y+=mod;
        y%=mod;
        x*=y;
        x%=mod;
        ans+=x;
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>

int main(void) {
	int N;
	std::cin >> N;
	int result = 0;
	int result2 = 0;
	std::array<std::array<int, 2>, 101>arr;
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= N; j++) {
			std::cin >> arr[j - 1][i - 1];
		}
	}

	for (int loop = 0; loop < N; loop++) {
		result = 0;
		for (int i = 0; i < N; i++) {
			if (loop >= i) {
				result += arr[i][0];
			}
		}
		for (int i = 0; i < N; i++) {
			if (loop <= i) {
				result += arr[i][1];
			}
		}
		if (result2 < result) {
			result2 = result;
		}
	}
	std::cout << result2 << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    vector<ll> vc;
    for (int i = 0; i < 9; i++)
    {
        vc.push_back(i + 1);
    }
    // for (int i = 0; i < vc.size(); i++)
    //     cout << "vc" << i << " " << vc[i] << endl;

    cin >> k;
    if (k <= 9)
    {
        cout << k << endl;
        return 0;
    }
    ll memo = 0;
    for (int i = 10; i <= k; i++)
    {
        int flag = 0;
        // cout << "memo:" << i - memo - 10 << endl;
        if (vc[i - memo - 10] % 10 - 1 >= 0)
        {
            vc.push_back(vc[i - memo - 10] * 10 + vc[i - memo - 10] % 10 - 1);
            flag++;
        }
        if (vc[i - memo - 10] % 10 + 1 < 10)
        {
            vc.push_back(vc[i - memo - 10] * 10 + vc[i - memo - 10] % 10 + 1);
            flag++;
        }

        vc.push_back(vc[i - memo - 10] * 10 + vc[i - memo - 10] % 10);
    }
    sort(vc.begin(), vc.end());

    // for (int i = 0; i < vc.size(); i++)
    //     cout << "vc" << i << " " << vc[i] << endl;
    cout << vc[k-1] << endl;
}

Measured memory_bytes: 6128
#include <bits/stdc++.h>
#define int long long
int dp[31][1000000];
using namespace std;

signed main(){
  int N,M;
  cin>>N>>M;
  std::vector<int> v(1000000,0);
  for(int i=2;i*i<=M;i++){
    if(M%i==0){
      M/=i;
      v[i]++;
      i=1;
    }
  }
  int k=100000;
  if(M>1)v[min(M,k)]++;
  for(int i=0;i<31;i++)for(int j=0;j<1000000;j++)dp[i][j]=0;
  sort(v.rbegin(),v.rend());
  //for(int i=0;i<20;i++)cout<<v[i]<<endl;
  int mmm;
  for(mmm=0;v[mmm];mmm++){}
  int ans=1;
  const int INF=1e9+7;
  for(int i=1;i<31;i++)dp[i][1]=1;
  for(int j=1;j<1000000;j++)dp[1][j]=j;
  for(int j=2;j<1000000;j++){
    for(int i=2;i<31;i++){
      dp[i][j]=dp[i-1][j]+dp[i][j-1];
      dp[i][j]%=INF;
    }
  }

  for(int i=0;i<mmm;i++){ans*=dp[v[i]][N];ans%=INF;}
  cout<<ans<<endl;
}


Measured memory_bytes: 250240
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> ar(h);
  int res = 0;
  for(auto &x: ar) cin >> x;
  for(int mask1 = 0; mask1 < (1 << h); ++mask1) {
    for(int mask2 = 0; mask2 < (1 << w); ++mask2) {
      int here = 0;
      for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
          if((mask1 & (1 << i)) || (mask2 & (1 << j))) continue;
          if(ar[i][j] == '#') here++;
        }
      }
      res += int(here == k);
    }
  }
  cout << res << '\n';
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3644
#include<cstdio>
#include<queue>
const int MaxN=200010;
int N;
struct edge{int to;edge*next;}E[MaxN*2],*ne=E,*fir[MaxN];
void link(int u,int v){*ne=(edge){v,fir[u]};fir[u]=ne++;}
int up[MaxN],f[MaxN][20][2],A1[MaxN],A2[MaxN];
int max(int a,int b){return a>b?a:b;}
void dfs(int i,int fa=0){
	if(i>1){
		f[i][0][0]=fa;
		f[i][0][1]=i;
		for(int j=1;j<20;j++){
			int t=f[i][j-1][0];
			f[i][j][0]=f[t][j-1][0];
			f[i][j][1]=max(f[i][j-1][1],f[t][j-1][1]);
		}
		//printf("i=%d up[%d]=%d\n",i,fa,up[fa]);
		if(i<up[fa]){
			int x=fa,y=i;
			for(int j=20;j--;){
				if(max(y,f[x][j][1])<up[f[x][j][0]]){
					y=max(y,f[x][j][1]);
					x=f[x][j][0];
				}
			}
			A1[x]++;
			//A2[f[x][0][0]]++;A2[i]--;
			//printf("i=%d x=%d\n",i,x);
		}
		else A1[i]++;
	}
	for(edge*e=fir[i];e;e=e->next)if(e->to!=fa){
		up[e->to]=max(up[i],i);
		dfs(e->to,i);
	}
}
void calc(int i,int fa=0){
	for(edge*e=fir[i];e;e=e->next)if(e->to!=fa){
		A1[e->to]+=A1[i];
		calc(e->to,i);
		A2[i]+=A2[e->to];
	}
}
int main(){
	scanf("%d",&N);
	for(int i=1,u,v;i<N;i++)scanf("%d%d",&u,&v),link(u,v),link(v,u);
	dfs(1);
	calc(1);
	for(int i=2;i<=N;i++)printf("%d%c",A1[i]+A2[i]," \n"[i==N]);
}

Measured memory_bytes: 52352
#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;

bool check(int A[3][3]){
	vi a;
	rep(i,3){
		int t = 0;
		rep(j,3){
			t += A[i][j];
		}
		a.pb(t);
	}

	rep(i,3){
		int t = 0;
		rep(j,3){
			t += A[j][i];
		}
		a.pb(t);
	}

	a.pb(A[0][0] + A[1][1] + A[2][2]);
	a.pb(A[2][0] + A[1][1] + A[0][2]);

	int f = a[0];
	reps(i,1,a.size()){
		if(a[i] != f){
			return false;
		}
	}
	return true;
}

int main(){
	int A[3][3];
	int a[3];
	rep(i,3){
		cin >> a[i];
	}

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

	for(int i = 0; i < 2000; ++i){
		for(int j = 0; j < 2000; ++j){
			if(i - j  == a[2]-a[1]){
				int s = i;
				int t = j;

				int p = a[0]-a[1]+t;

				int B[3][3];

				rep(y,3){
					rep(x,3){
						B[y][x] = A[y][x];
					}
				}

				B[0][2] = s;
				B[2][1] = p;
				B[2][2] = t;

				int sum = B[0][0] + B[1][1] + B[2][2];

				B[2][0] = sum - p - t;

				B[1][0] = sum - B[0][0] - B[2][0];
				B[1][2] = sum - B[0][2] - B[2][2];

				if(check(B)){
					rep(y,3){
						rep(x,3){
							printf("%d%c",B[y][x],x==2?'\n':' ');
						}
					}
				}

			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 1000000
vector<ll> p;
void prime(){
  vector<bool> pp(MAX+1,true);
  pp.at(0)=false,pp.at(1)=false;
  for(ll i=2;i<=MAX;i++){
    if(pp.at(i)){
      p.push_back(i);
      for(ll j=1;i*j<=MAX;j++){
        pp.at(i*j)=false;
      }
    }
  }
}

int main(){
  ll A,B;
  cin>>A>>B;
  prime();
  while(A%B!=0){
    ll tmp=A%B;
    A=B;
    B=tmp;
  }
  int n=p.size();
  vector<int> count(n);
  int k=0;
  int ans=1;
  while(B>1){
    if(B%p.at(k)==0){
      count.at(k)=1;
      B/=p.at(k);
    }else{
      k++;
    }
    if(k==n){
      ans++;
      break;
    }
  }
  for(int i=0;i<n;i++){
    ans+=count.at(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int,int>
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation 
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll &x, ll &y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;

int main()
{
    stat();
    int a,b;cin>>a>>b;string s;
    ll ans=0;
    for(int i=a;i<=b;++i){
	    s=to_string(i);
if(s[0]==s[4]&&s[1]==s[3]){ans++;}

    }cout<<ans<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat() {
#ifdef local
    rep(i, 2) {std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) { num = num * (n - i + 1) / i; }
    return num;
}

template <typename T> T fact(T num){
if(num==1){return 1;}
return num*fact(num-1);
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 
signed main(){
  int a,b,c,e=1000000000000,d=0;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>c;
    d=max(c,d);
    cin>>c;
    e=min(c,e);
  }
  cout<<max<long long>(0,e-d+1)<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 



int main() {
	int ans = -1;
	int N; cin >> N;
	string S; cin >> S;

	int b[N+2] = {};//i以下に存在する黒石の数
	int w[N+2] = {};//i以上に存在する白石の数
	int a = 0;
	for (int i = 0; i < N; i++)
	{
		if(S[i] == '#'){a++;}
		b[i]=a;
	}
	a = 0;
	for (int i = N-1; 0 <= i; i--)
	{
		if(S[i] == '.'){a++;}
		w[i] = a;
	}

	for (int i = 0; i < N; i++)
	{
		int n_ans = b[i] + w[i+1];
		if(ans == -1 or n_ans < ans){ans = n_ans;}
	}
	ans = min(abs(b[N-1]-N),ans);//全てを黒で塗るケース
	ans = min(abs(w[0]-N),ans);//全てを白で塗るケース
	

	cout << ans << endl;
	}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int S;
    int index;
    ull ans = 0;
    cin >> S;
    for(int i=1;i<S;i++){
        if(S/i<3){
            index = i-1;
            break;
        }
    }
    int St = S;
    for(int i=0;i<index;i++){
        St -= 3*(i+1);
        ans += Combination(St+i,i);
        //cout << ans << endl;
        ans %= mod;
        St = S;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
  string s;
  int sum, flg;

  cin >> s;
  sum = 0; flg = 1;
  for (int i=0; i<s.size(); i++){
    sum += s[i]-'0';
    if (i!=0) flg &= s[i]=='9';
  }
  if (flg) cout << sum << endl;
  else cout << ((s[0]-'0'-1)+9*(s.size()-1)) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)

int main(){
    string s;
    cin>>s;
    int l = s.length();
    int m = l;
    ll ans = 0;
    for(int i=l-1;i>=0;i--){
        if(s[i]=='B'){
            ans+= (m-(i+1));
            m--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdbool.h>

int main() {
	int n;
	scanf("%d", &n);
	int a[200000]={};
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int breakCou=0;
	int numCou=1;
	bool enable=false;
	for (int i = 0; i < n; i++) {
		if (a[i]==numCou) {
			numCou++;
			enable=true;
		}else{
			breakCou++;
		}
	}
	if(!enable){
		printf("-1\n");
	}else{
		printf("%d\n", breakCou);
	}
	return 0;
}


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

#define fi first
#define se second
#define sz(v) (int)((v).size())
#define pb push_back

typedef long long ll;

const ll MAX = (long long)1e18;

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

	int n; cin >> n;
	ll res=1;
	for (int i = 0; i < n; i++) {
		ll ai; cin >> ai;
		if (ai==0){
			res=0;
			break;
		}
		else if(ai>MAX/res)
			res=-1;
		else res *= ai;
	}
	cout << res << "\n";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


void solve(){
	int a, b, x;
	cin>>a>>b>>x;
	if(x>= a && x <= a+b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <string.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;


int dp[2000000][2];
string s;

int solve(int pos, int carry) {
	if (pos == s.size()) {
		return carry;
	}
	int &ret = dp[pos][carry];
	if (~ret)return ret;
	int val = s[pos] - '0' + carry;
	ret = 1e9;
	if (val < 10) {
		ret = min(ret, solve(pos + 1, 0) + val);
	}
	ret = min(ret, solve(pos + 1, 1) + 10 - val);
	return ret;
}


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	reverse(s.begin(), s.end());
	memset(dp, -1, sizeof(dp));
	cout << solve(0, 0);
	
}



Measured memory_bytes: 63900
// Aizu 2833: Displayed tweets
// 2017.11.25 bal4u@uu
// 2018.1.9

#include <stdio.h>
#include <string.h>

int a[100001], k[100001];
char f[100001];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int N, K, i, re, v, ans;

	N = in(), K = in();
	memset(k, 0x33, sizeof(int)*(N+1));
	for (i = 1; i <= N; i++) a[i] = in();

	ans = 0;
	for (i = N; i > 0; i--) {
		re = a[i];
		if (re) {
			if (!f[i]) v = 0, ans++;
			else if ((v = k[i]) < K) ans++;
			v++;
			if (v < K && k[re] > v) k[re] = v;
			f[re] = 1;
		} else ans++;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2724
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int count = 0;
		
	    int valLen = String.valueOf( a ).length();    //桁数
	    
	    for(int i = valLen; i > 0; i--){
	        
	        if(i % 2 == 1){
	            
	            if(i == valLen)
	            {
	                count += a % Math.pow(10, i-1) + 1;
	                count +=  ( (a / (int)Math.pow(10, i-1) ) - 1) * (int)Math.pow(10, i-1);
    	        }
    	        else if(i == 1)
    	        {
    	            count += 9;
    	        }
    	        else
    	        {
    	            count += 9*(int)Math.pow(10, i-1);
    	        }
	                
	        }
	        
	    }
	    
        System.out.println(count);
	}
}

Measured memory_bytes: 22740
gets.to_i.times do
  xa, ya, ra, xb, yb, rb = gets.chomp.split.map &:to_f
  d = Math.sqrt((xa-xb)**2+(yb-ya)**2)
  puts ( d+rb < ra ) ? 2
       : ( d+ra < rb ) ? -2
       : ( d <= ra+rb ) ? 1
       : 0
end

Measured memory_bytes: 6140
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    if(s.substr(0, n/2) == s.substr(n/2))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

class Point {
public:
	int x, y;
	Point(int x, int y) {
		this->x = x;
		this->y = y;
	}
};

signed main() {
	int N, M;
	cin >> N >> M;

	vector<Point> mans, checks;

	rep(i, N) {
		int a, b;
		cin >> a >> b;
		mans.push_back(Point(a, b));
	}

	rep(i, M) {
		int a, b;
		cin >> a >> b;
		checks.push_back(Point(a, b));
	}

	rep(i, N) {
		int minArg = -1;
		int minDist = LLONG_MAX;
		rep(j, M) {
			int dist = abs(mans[i].x - checks[j].x) + abs(mans[i].y - checks[j].y);
			if (dist < minDist) {
				minDist = dist;
				minArg = j;
			}
		}

		minArg++;

		cout << minArg << endl;
	}

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int a = tmp[0], b = tmp[1], c = tmp[2];
	WriteLine(a+b>=c?"Yes":"No");
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main()
{

    int n;
    cin>>n;
    int ans = n;
    for(int i=0;i<=n;i++){
        int x=0,num=i;
        while(num)x+=num%6,num/=6;
        num = n-i;
        while(num)x+=num%9,num/=9;
        ans=min(ans , x);
    }
    cout<<ans<<endl;

    return 0;
}


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

int main() {
  int n,x,t;
  cin >> n >> x >> t;
  
  int res = (n/x)*t;
  if(n%x > 0){
    res += t;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std; 
using namespace __gnu_pbds;
 
typedef long long ll;
typedef double db;
typedef long double ld;
typedef string str;
 
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<str, str> pstr;
 
typedef vector<int> vi; 
typedef vector<ll> vll; 
typedef vector<db> vdb; 
typedef vector<ld> vld;
typedef vector<str> vstr; 
typedef vector<pi> vpi;
typedef vector<pll> vpll; 
typedef vector<pdb> vpdb; 
 
#define fi first
#define se second
#define mp make_pair
#define pf push_front 
#define pb push_back
#define ins insert 
#define eb emplace_back 
#define fbo find_by_order
#define ook order_of_key
#define rsz resize
#define lb lower_bound 
#define ub upper_bound 

#define len(s) (int)s.length()
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))

#define rep(a, b, c) for(int a=b; a<c; a++) 
#define per(a, b, c) for(int a=b; a>c; a--) //do not include boundaries on the right
#define repn(a, b, c) for(int a=b; a<=c; a++) 
#define pern(a, b, c) for(int a=b; a>=c; a--) //include boundaries on the right
 
#define yes cout << "YES"<< "\n" 
#define no cout << "NO" << "\n" 
#define out(x) cout << x << "\n"
#define outs(x) cout << x << " "
#define el cout << "\n"

#define navi ios_base::sync_with_stdio(false); cin.tie(NULL)    
 
const ll mod = 998244353;
const double eps = 1e-9;

int main(){
	navi;
  	ll dp[3003][3003];
	ll a, b, c, d;
  	cin >> a >> b >> c >> d;
 	repn(i,a,c){
      repn(j,b,d){
      	if(i==a&&j==b){
          dp[a][b]=1;
          continue;
      	}
      dp[i][j]=((dp[i-1][j]*j)%mod+(dp[i][j-1]*i)%mod-(dp[i-1][j-1]*(i-1)*(j-1))%mod+mod)%mod;
    }
  }
  out(dp[c][d]);
}



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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

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

	auto A=in();
	if(A==1ll){
		out(0);
		return 0;
	}

	auto P = enum_prime(10000003);
	ll S=0;
	for(auto& x:P){
		if(A==1ll) break;
		ll y = x;
		while(!(A%y)){
			S++;
			A /= y;
			y *= x;
		}
		while(!(A%x)) A/=x;
	}

	if(A>1ll) S++;

	out(max(S,1ll));
	return 0;
}


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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int64_t LCM(int64_t x, int64_t y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}

int main() {
    int64_t A,B,C,D;
    cin >> A >> B >> C >> D;
    
    int64_t lcm = LCM(C,D);
    
    int64_t a,b;
    
    a = (A-1) - ( (A-1)/C + (A-1)/D - (A-1)/lcm );
    b = B - ( B/C + B/D - B/lcm);
    // A-1 以下の整数で、CでもDでも割り切れない整数
    
    cout << b - a << endl;
    
    return 0;
}


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

int main() {
    int N;
    scanf("%d", &N);
    
    int V[N];
    int C[N];
    int sum=0;
    
    int i;
    
    for(i=0; i<N; ++i){
        scanf("%d",&V[i]);
    }
    for(i=0; i<N; ++i){
        scanf("%d",&C[i]);
    }
    
    for(i=0; i<N; ++i){
        if(V[i] - C[i] >= 0) sum += V[i] - C[i];
    }
    
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.size[x] < self.size[y]:
                x,y = y,x
            self.parents[y] = x
            self.size[x] += self.size[y]

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(M):
        X, Y, Z = map(lambda x: int(x)-1, input().split())
        uf.union(X, Y)
    # print(len(set(uf.parents)))
    ans = [uf.find(x) for x in uf.parents]
    print(len(set(ans)))

if __name__ == "__main__":
    main()


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

int main(){
  long N,A,B,res = 0,diff,direc,small,big;
  cin >> N >> A >> B;
  if((B - A)%2 != 0){
  	diff = (B - A) -1;
    direc = min((A -1) , (N - B));
   // cout << direc << endl;
    res = direc + 1;
    if(A-direc == 1){
   		A -= direc,B -= direc;
      	B -= 1;
    }else if(B+direc == N){
    	A += direc,B += direc;
      	A += 1;
    }
//	cout << small <<" " << big << " " << diff << " " << direc;
    res += (B - A) / 2;
  }else{
  	res = (B - A)/2;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N, M, X, Y = ds_in()
x_arr = ds_in()
y_arr = ds_in()

max_x = max(x_arr)
min_y = min(y_arr)
for z in range(X+1, Y+1):
    if max_x < z and z <= min_y:
        print('No War')
        exit()

print('War')


Measured memory_bytes: 3060
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int ans = 0;
		if(N <= 1999 && N >= 1800){
			ans = 1;
		}else if(N <= 1799 && N >= 1600){
			ans = 2;
		}else if(N <= 1599 && N >= 1400){
			ans = 3;
		}else if(N <= 1399 && N >= 1200){
			ans = 4;
		}else if(N <= 1199 && N >= 1000){
			ans = 5;
		}else if(N <= 999 && N>= 800){
			ans = 6;
		}else if(N <= 799 && N >= 600){
			ans = 7;
		}else if(N <= 599 && N >= 400){
			ans = 8;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35632
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
      cin >> A[i];
    }
    vector<int> L(N), R(N);
    vector<int> stk;
    for (int i = 0; i < N; i++) {
      while (!stk.empty() && A[stk.back()] > A[i]) {
        stk.pop_back();
      }
      L[i] = stk.empty() ? -1 : stk.back();
      stk.push_back(i);
    }
    stk.clear();
    for (int i = N - 1; i >= 0; i--) {
      while (!stk.empty() && A[stk.back()] > A[i]) {
        stk.pop_back();
      }
      R[i] = stk.empty() ? N : stk.back();
      stk.push_back(i);
    }
    ll res = 0;
    for (int i = 0; i < N; i++) {
      res += 1ll * A[i] * (i - L[i]) * (R[i] - i);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3704
#include <iostream>

#define LL long long

LL GCD(LL a, LL b) {
	LL
		c = a > b ? a : b,
		d = a < b ? a : b;
	while (c != d) {
		c -= d;

		LL tmp[] = {c, d};
		c = std::max(tmp[0], tmp[1]);
		d = std::min(tmp[0], tmp[1]);
	}

	return c;
}

LL LCM(LL a, LL b) {
	return a * b / GCD(a, b);
}

int main() {
	int a, b;
	while (std::cin >> a >> b) {
		std::cout << GCD(a, b) << " " << LCM(a, b) << std::endl;
	}
}

Measured memory_bytes: 1156
/* volume0 - 0000
 * QQ
 */

#include<iostream>
using namespace std;

int main(){

	for(int i=1; i<10; i++){
		for(int j=1; j<10; j++){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 3050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int r, c, k;
ll v[N][N];
ll dp[N][N][5], ans;

inline void solve()
{
    scanf("%d%d%d", &r, &c, &k);
    for (int i = 1; i <= k; ++i)
    {
        int x, y, val;
        scanf("%d%d%d", &x, &y, &val);
        v[x][y] = val;
    }
    for (int i = 1; i <= r; ++i)
        for (int j = 1; j <= c; ++j)
        {
            if (!v[i][j])
                dp[i][j][0] = max(dp[i - 1][j][0], max(dp[i - 1][j][1], max(dp[i - 1][j][2], dp[i - 1][j][3])));
            else
                dp[i][j][1] = v[i][j] + max(dp[i - 1][j][0], max(dp[i - 1][j][1], max(dp[i - 1][j][2], dp[i - 1][j][3])));
            for (int k = 1; k <= 3; ++k)
                dp[i][j][k] = max(dp[i][j][k], max(dp[i][j - 1][k - 1] + v[i][j], dp[i][j - 1][k]));
        }
    for (int i = 1; i <= r; ++i)
        for (int j = 1; j <= c; ++j)
            for (int k = 0; k < 4; ++k)
                ans = max(ans, dp[i][j][k]);
    cout << ans << '\n';
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 432532
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main ()
{
	int n;
	int a[105];
	while(cin>>n)
	{
		int mmax=0,mmin=105;
		int ans=10000000;
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
			mmax=max(mmax,a[i]);
			mmin=min(mmin,a[i]);
		}
		for(int j=mmin;j<=mmax;j++)
		{
			int sum=0;
			for(int i=0;i<n;i++)
			{
				sum+=(a[i]-j)*(a[i]-j);
			}
			ans=min(ans,sum);
		} 
		cout<<ans<<endl;
	}
	return 0;
} 

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

int main(){
    int n;
    cin >> n;
    vector<string> w(n);
    map<string,int> m;
    rep(i,n){
        cin >> w[i];
        m[w[i]]++;
    }
    if(m.size() != n) {cout << "No" << endl;return 0;}
    bool ok = true;
    for(int i=0;i<n-1;i++){
        if(w[i].back() != w[i+1].front()){cout << "No" << endl; return 0;}
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 256