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

signed main(){

  int n,k; cin >> n >> k;
  string s; cin >> s;
  for(int i = 0; i < n; i++){
    if(i == k-1) s[i] = s[i] + 'a' - 'A';
    cout << s[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100005;

int a[maxn],b[maxn],c[maxn];

int main()
{
	ll n,i,j,k;
	scanf("%lld",&n);
	for (i=0;i<n;i++) scanf("%d",&a[i]);
	for (i=0;i<n;i++) scanf("%d",&b[i]);
	for (i=0;i<n;i++) scanf("%d",&c[i]);
	sort(a,a+n);sort(b,b+n);sort(c,c+n);
	i=0;j=0;
	ll tot=0;
	for (k=0;k<n;k++)
	{
		while (b[k]>a[i] && i<n) i++;
		while (b[k]>=c[j] && j<n) j++;
		//cout<<i<<' '<<j<<' '<<(i+1)*(n-j)<<endl;
		tot+=i*(n-j);
	}
	printf("%lld\n",tot);
	return 0;
}

Measured memory_bytes: 1536
a = list(input())
flag = True
for i in range(len(a)):
    if i % 2 == 1:
        if a[i] == 'L' or a[i] == 'U' or a[i] == 'D':
            pass
        else:
            flag = False
    else:
        if a[i] == 'R' or a[i] == 'U' or a[i] == 'D':
            pass
        else:
            flag = False

if flag:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <complex>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

// 2直線の交点
P crosspointLL(P a1, P a2, P b1, P b2) {
  D d1 = cross(b2-b1, b1-a1);
  D d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  if (EQ(d2, 0)) throw "kouten ga nai";   // 交点がない
  return a1 + d1/d2 * (a2-a1);
}

// 三角形の外心。点a,b,cは同一線上にあってはならない
P circumcenter(P a, P b, P c) {
  a = (a-c)*0.5;
  b = (b-c)*0.5;
  return c + crosspointLL(a, a*P(1,1), b, b*P(1,1));
}

int main() {
  int n;
  cin >> n;
  D x1,y1,x2,y2,x3,y3;
  rep(_,n) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    P a = P(x1,y1);
    P b = P(x2,y2);
    P c = P(x3,y3);
    P center = circumcenter(a,b,c);
    printf("%.3lf %.3lf %.3lf\n", center.X, center.Y, abs(center - a));
  }
  return 0;
}

Measured memory_bytes: 1264
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll h[N];
    rep(i, N){
        cin >> h[i];
    }
    sort(h, h + N);

    ll p = 0;
    ll ans = 10000000000;
    while(p + K - 1 < N){
        ans = min(ans, h[p + K - 1] - h[p]);
        p++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k,n,t,sum,a,b;
	
	while(cin>>t&&t) {
		cin>>n;
		sum=0;
		for(i=0;i<n;i++) {
			cin>>a>>b;
			sum+=b-a;
		}
		if(sum>=t) cout<<"OK"<<endl;
		else cout<<t-sum<<endl;
	}
}

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

class Relation{
public:
	Relation(int tmp_n,int tmp_m){
		n = tmp_n;
		m = tmp_m;
		V = new vector<int>[n];
		group = new int[n];
		for(int i=0;i<n;i++){
			group[i] = 0;
		}
		group_number = 1;
	}

	void push(int s,int t){
		V[s].push_back(t);
		V[t].push_back(s);
	}

	void makeGroup(){
		int node;
		queue<int> Q;
		for(int i=0;i<n;i++){
			if(group[i] == 0){
				group[i] = group_number;
				Q.push(i);
				while(!Q.empty()){
					node = Q.front();
					Q.pop();
					if(V[node].size() > 0){
						for(int k=0; k < V[node].size();k++){
							if(group[V[node][k]] == 0){
								group[V[node][k]] = group[node];
								Q.push(V[node][k]);
							}
						}
					}
				}
				group_number++;
			}
		}
	}

	bool canAccsess(int s,int t){
		return group[s] == group[t];
	}

private:
	vector<int>* V;
	int* group;
	int group_number;
	int n,m;
};

int main(){
	int n,m,s,t,q;
	scanf("%d %d",&n,&m);

	Relation relation(n,m);
	for(int i=0;i<m;i++){
		scanf("%d %d",&s,&t);
		relation.push(s,t);
	}
	relation.makeGroup();
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d %d",&s,&t);
		if(relation.canAccsess(s,t)){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
    return 0;
}

Measured memory_bytes: 8532
#include <stdio.h> 

int main(void)
{
	int a, b, c, d, e, f, g, h, i, j;
	int x;
	scanf("%d %d %d %d %d %d %d %d %d %d", &a, &b, &c, &d, &e, &f, &g, &h, &i, &j);

	x=a+b+c+d+e+f+g+h+i+j;

	printf("%d\n", x);

	return 0;


}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int cnt=0;
  int cntb=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='a'&&cnt<a+b){
      cout << "Yes" << endl;
      cnt++;
    }
    else if(s[i]=='b'&&cnt<a+b&&cntb<b){
      cout << "Yes" << endl;
      cnt++;
      cntb++;
    }
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    double x,h,temen,ht,mt,hyomen;
    for(;;){
        cin>>x>>h;
        if(x==0&&h==0)break;
        temen=x*x;
        ht=(x/2)*(x/2);
        h=h*h;
        mt=sqrt(ht+h);
        hyomen=(mt*x)*2+temen;
        printf("%.6f",hyomen);
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int button, num = 1;
    int ans;
    rep(i, n) {
        button = a.at(num - 1);
        if (num == 2) {
            ans = i;
            goto last;
        }
        int change = num;
        num = button;
    }
    cout << -1 << endl;
    return 0;
    last:
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	double a, b, p, q, r;
	cin >> a >> b >> p >> q >> r;
	double n = a * p;
	n -= (b - a)*(q - p);
	double ans = n / (r + q);
	cout << ans + b << endl;
}


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(long long N, std::vector<std::string> S){

    map<string, int> C;
    vector<string> A;
    int max = 0;
    for (auto s : S) C[s] = 0;
    for (auto s : S) C[s] += 1;
    for (auto pair : C) {
        if (max < pair.second) {
            max = pair.second;
            A = vector<string>();
        }
        if (max == pair.second) {
            A.push_back(pair.first);
        }
    }
    sort(A.begin(), A.end());
    rep(i,A.size()) cout << A[i] << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    func(N, std::move(S));
    return 0;
}


Measured memory_bytes: 28404
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

bool mycompari(string s, string t){
  return (s.compare(t)) < 0;
}

int main(int argc, char const *argv[]) {
  string s;
  int k, l;
  cin >> s >> k;
  vector<string> svec;
  l = s.length();
  for (int i = 1; i <= min(k,l); i++) {
    for (int j = 0; j <= s.size()-i; j++) {
      svec.push_back(s.substr(j, i));
    }
  }

  sort(svec.begin(), svec.end(), mycompari);
  svec.erase(unique(svec.begin(), svec.end()),svec.end());

  cout << svec[k-1] << endl;

  return 0;
}


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

using namespace std;
int main(){
	int n;
	cin>>n;
	string a,b;
	cin>>a>>b;
	string c="";
	for(int i=0;i<n;i++){
		c+=a[i];
		c+=b[i];
	}
	cout<<c;
	return 0;
}

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

using namespace std;

const int N = 1e3 + 3;

int n, m;
int a[N], b[N], c[N];
int dp[N][(1 << 12) + 5];

int go(int idx, int mask) {
	if (mask == (1 << n) - 1) return 0;
	if (idx > m) return 1e9 + 7;
	if (dp[idx][mask] != -1) return dp[idx][mask];
	int ans = 1e9 + 7;
	ans = min(ans, go(idx + 1, mask));
	ans = min(ans, go(idx + 1, mask | c[idx]) + a[idx]);
	return dp[idx][mask] = ans;
}

void solve() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b[i];
		for (int j = 1; j <= b[i]; j++) {
			int x;
			cin >> x;
			x--;
			c[i] |= (1 << x);
		}
	}
	memset(dp, -1, sizeof(dp));
	int ans = go(1, 0);
	if (ans == (int)(1e9 + 7)) cout << "-1";
	else cout << ans;
}

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

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N);
    for (int i = 0; i < N; i++) 
    cin >> A.at(i);
  sort(A.begin(), A.end());
  cout << A.at(N-1)-A.at(0) << endl;
}

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/abc120/tasks/abc120_a

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int A, B, C;

int main() {
    cin >> A >> B >> C;

    int k = B / A;
    int ans;
    ans = min(C, k);
    cout << ans << endl;
    return 0;
}


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

const int INF = 1e+9;
typedef pair<int, int> P;
typedef pair<P, int> pi;

int main() {
	vector<pi> data;
	for(int y = 1; y <= 150; ++y){
		for(int x = y + 1; x <= 150; ++x){
			data.push_back(pi(P(x * x + y * y, y), x));
		}
	}
	sort(data.begin(), data.end());
	int h, w;
	while(cin >> h >> w && (h || w)){
		int base = h * h + w * w;
		auto it = lower_bound(data.begin(), data.end(), pi(P(base, h), w));
		while((*it).first.first == base && (*it).first.second == h){
			++it;
		}
		cout << (*it).first.second << " " << (*it).second << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr);
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 

int32_t main(){
    // boost;
    
    string s;
    cin>>s;
    if(s[2]==s[3] && s[5] ==s[4]){
        cout<<"Yes\n";
    }else
    cout<<"No\n";
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>


using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  string map[H];
  for(int i = 0 ; i < H; i++) cin >> map[i];
  int MOD = 1000000007;
  long long dp[H][W];
  for(int i = 0; i<H; i++)for(int j=0; j <W; j++) dp[i][j] = 0;
  dp[0][0] = 1;
  for(int i = 0 ; i < H; i++){
     for(int j=0; j < W; j++){
        if(i==0&&j==0) continue;
        if(map[i][j]=='#') dp[i][j] = 0; 
        else{
           if(i-1>=0) dp[i][j] += dp[i-1][j];
           if(j-1>=0) dp[i][j] += dp[i][j-1];
           dp[i][j] %= MOD;
        }
     }
  }
  cout << dp[H-1][W-1]<<endl;
  

  return 0;
}


Measured memory_bytes: 9088
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char S[2000020];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fread(S, 1, 2000020, stdin);

	char* c = S, ct;
	int N = 0;
	
	while ((ct = *c++) >= '0') N = N * 10 + ct - '0';

	int L = 0, R = 2000001;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (*(c + M) >= ' ') L = M;
		else R = M;
	}

	if (*c == '0') {
		printf("0\n");
		return 0;
	}

	//for (char* d = c; d < c + R - 8; d += 7) {
	//	ll tmp = *(ll*)(d);
	//	tmp += 0x1010101010101010;
	//	tmp ^= 0xcfcfcfcfcfcfcfcf;

	//	ll tmp2 = tmp + 0x0001000100010001;
	//	if ((tmp2 << 1 ^ tmp2) & 0x2000200020002000) {
	//		printf("0\n");
	//		return 0;
	//	}
	//	tmp2 = tmp + 0x0000010001000100;
	//	if ((tmp2 << 1 ^ tmp2) & 0x0020002000200000) {
	//		printf("0\n");
	//		return 0;
	//	}
	//}
	for (char* d = c; d < c + R; d++) {
		if (*d == ' ' && *(d + 1) == '0') {
			printf("0\n");
			return 0;
		}
	}

	if (R >= N * 2 + 18) {
		printf("-1\n");
		return 0;
	}

	ll kotae = 1;
	auto owa = c + R;
	while (c < owa) {
		ll tmp = *(ll*)(c);
		if (tmp != 0x2031203120312031) {
			ll k = 0;
			while ((ct = *c++) >= '0') k = k * 10 + ct - '0';
			if (ll(1e18) / kotae < k) {
				printf("-1\n");
				return 0;
			}
			else kotae *= k;
		}
		else c += 8;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3264
def inpl():
    return list(map(int, input().split()))


def Check(S, T):
    for i in range(len(S)):
        if S[i] != T[i]:
            return False
    return True


N = int(input())
S = input()
T = input()

for i in range(N):
    if Check(S[i:], T) is True:
        print(N + i)
        break
else:
    print(2 * N)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
const int nax=20;
int edge[nax][nax];
int n;
bool ok(int res) {
/*	rep(i,0,n) (res&(1<<i))?cout<<1:cout<<0;
	cout<<'\n';*/
	rep(i,0,n) {
		if((res&(1<<i))) {
			rep(j,0,n) {
//				cout<<i<<' '<<j<<' '<<edge[i+1][j+1]<<'\n';
				if(edge[i+1][j+1]==-1) continue;
	//			cout<<(res&(1<<j))<<'\n';
				if(!edge[i+1][j+1]==(res&(1<<j))>0) return false;
			}
		}
	}
	return true;
}
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n;
		memset(edge,-1,sizeof edge);
		rep(i,0,n) {
			int a;
			cin>>a;
			rep(j,0,a) {
				int x,y;
				cin>>x>>y;
				edge[i+1][x]=y;
			}
		}
//		rep(i,0,n) {rep(j,0,n) cout<<edge[i+1][j+1]<<' '; cout<<'\n';}
		int m=0;
		int it=(1<<n);
		rep(i,0,it) {
			if(ok(i)) {
				m=max(m,__builtin_popcount(i));
			}
		}
		cout<<m;
		return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc159/tasks/abc159_c

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int L_MAX = 1000;

int L;

int main() {
  cin >> L;
  double ans = pow((double) L / 3, 3);
  cout << fixed << setprecision(12);
  cout << ans << endl;
}


Measured memory_bytes: 4092
import sys

a = sys.stdin.readlines()
input = map(str, a)
lines = ','.join(input)
lines.replace('\n','')

i = 1
n = ord('a') - 1
m = ord('A') - 1
while n != ord('z'):
    n += 1
    m += 1
    counter = lines.count(chr(n)) + lines.count(chr(m))
    print('{} : {}'.format(chr(n),counter))



Measured memory_bytes: 5564
package main

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


func main() {
     stdin := bufio.NewScanner(os.Stdin)
     stdin.Scan()
     day := stdin.Text()
     days := map[string]int{"SUN":0, "MON":1, "TUE":2, "WED":3, "THU":4, "FRI":5, "SAT":6}
     subDay := 7 - days[day]
     fmt.Println(subDay)
}

Measured memory_bytes: 640
#include <stdio.h>
int main (void)
{
	int n,i,j,maxv,minv;
	scanf("%d",&n);
	int x[n];
	
	for(i=0;i<n;i++)
	{
		scanf("%d", &x[i]);
	}
	
	minv=x[0];
	maxv=-x[0];
	for(j=1;j<=n-1;j++)
	{
		
		if(maxv<x[j]-minv)maxv=x[j]-minv;
		if(minv>x[j])minv=x[j];
	}
	printf("%d\n",maxv);
}


Measured memory_bytes: 2532
// abc103_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
template<class T> bool contain(const std::string& s, const T& v) {
  return s.find(v) != std::string::npos;
}
int main(int argc, char *argv[])
{
  string s,t;
  cin>>s>>t;
  s += s;
  if (contain(s, t)) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	int len, cnt = 0, ans = 0;

	cin >> S;
	len = S.length();

	rep(i, len) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') cnt++;
		else cnt = 0;
		ans = max(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		long[] XpYpZp = new long[N];
		long[] XmYpZp = new long[N];
		long[] XmYpZm = new long[N];
		long[] XmYmZp = new long[N];
		long[] XpYmZp = new long[N];
		long[] XpYmZm = new long[N];
		long[] XpYpZm = new long[N];
		long[] XmYmZm = new long[N];
		for (int i = 0; i < N; i++) {
			long x = sc.nextLong();
			long y = sc.nextLong();
			long z = sc.nextLong();
			XpYpZp[i] = x + y + z;
			XmYpZp[i] = (-x) + y + z;
			XmYmZp[i] = (-x) + (-y) + z;
			XmYmZm[i] = (-x) + (-y) + (-z);
			XpYmZp[i] = x + (-y) + z;
			XpYmZm[i] = x + (-y) + (-z);
			XmYpZm[i] = (-x) + y + (-z);
			XpYpZm[i] = x + y + (-z);
		}
		
		Arrays.sort(XpYpZp);
		Arrays.sort(XmYpZp);
		Arrays.sort(XmYmZp);
		Arrays.sort(XmYmZm);
		Arrays.sort(XpYmZm);
		Arrays.sort(XpYmZp);
		Arrays.sort(XmYpZm);
		Arrays.sort(XpYpZm);
		
		long[][] bigmap = new long[8][N];
		bigmap[0] = XpYpZp;
		bigmap[1] = XmYpZp;
		bigmap[2] = XmYmZp;
		bigmap[3] = XmYmZm;
		bigmap[4] = XpYmZm;
		bigmap[5] = XpYmZp;
		bigmap[6] = XmYpZm;
		bigmap[7] = XpYpZm;
		
		long ans = 0;
		for (int i = 0; i < 8; i++) {
			ans = Math.max(ans, calc(bigmap[i], M));
		}
		
		System.out.println(ans);
		
	}
	
	public static long calc(long[] map, int M) {
		int pos = map.length - 1;
		long ret = 0;
		for (int i = M; i > 0; i--) {
			ret += map[pos];
			pos--;
		}
		return ret;
	}
	
}

Measured memory_bytes: 28352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int main()
{

	
	ll n,k;
	cin>>n>>k;ll ans=0;
	//ll ans=0;
	for(ll i=k;i<=n+1;i++)
	{ans+=i*(n-i+1)+1;ans%=mod;}
	cout<<ans<<"\n";
	
	
}

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



int main() {
    int a, b;
    cin >> a >> b;
    
    for(int i = 1; i <= 3; i++) {
        if(i != a && i != b)
            cout << i << endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 2e5;
int N;
ll A[Nmax], B[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i] >> B[i];

	vector<pair<ll, ll> > v(N);
	for(int i=0; i<N; i++) v[i] = {B[i], A[i]};
	sort(v.begin(), v.end());

	int t = 0;
	for(int i=0; i<N; i++){
		t += v[i].second;
		if(t > v[i].first){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


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

constexpr int MAX = 64;
constexpr int INF = 1e8;
int w, h;
char grid[MAX][MAX] = {};
int d[MAX][MAX][2] = {};

struct Node {
    int x_;
    int y_;
    int cost_;
    int side_; // 0 | 1 = left | right
    Node(int x, int y, int cost, int side) 
        : x_(x), y_(y), cost_(cost), side_(side) {}   
};

auto clear() -> void {
    for (int i = 0; i < MAX; ++i) {
        for (int j = 0; j < MAX; ++j) {
            for (int k = 0; k < 2; ++k) {
                d[i][j][k] = INF;
            }
        }
    }
}

auto check_range(int x, int y) -> bool {
    if (x >= 0 && x < w 
        && y >= 0 && y < h 
        && grid[y][x] != 'X') {
        return true;
    }
    return false;
}

auto dijkstra() -> int {
    constexpr int dx[9] = {1, 1, 2, 1, 2, 3, 1, 2, 1};
    constexpr int dy[9] = {2, 1, 1, 0, 0, 0, -1, -1, -2};
    clear();

    auto comp = [](auto& lhs, auto& rhs) { return lhs.cost_ > rhs.cost_; };
    priority_queue<Node, vector<Node>, decltype(comp)> que(comp);

    for (int y = 0; y < h; ++y) {
        for (int x = 0; x < w; ++x) {
            if (grid[y][x] == 'S') {
                que.push(Node(x, y, 0, 0));
                que.push(Node(x, y, 0, 1));
                d[y][x][0] = 0;
                d[y][x][1] = 0;
            }
        }
    }

    int ans = -1;
    while(!que.empty()) {
        Node node = que.top();
        que.pop();
        const int x = node.x_;
        const int y = node.y_;
        const int current_side = node.side_;

        if(grid[y][x] == 'T'){
            ans = node.cost_;
            break;
        }

        for (int j = 0; j < 9; ++j) {
            const int nx = x + dx[j] * (current_side ? -1 : 1);
            const int ny = y + dy[j];
            const int next_side = !current_side;
            if (check_range(nx, ny)) {
                const int grid_cost = (grid[ny][nx] == 'T') ? 0 : grid[ny][nx] - '0';
                if(d[ny][nx][next_side] > node.cost_ + grid_cost) {
                    d[ny][nx][next_side] = node.cost_ + grid_cost;
                    que.push(Node(nx, ny, d[ny][nx][next_side], next_side));
                }
            }
        }
    }  
    return ans;
}

auto main(int argc, char const *argv[]) -> int {
    while( cin>>w>>h, w || h ) {
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin>>grid[i][j];
            }
        }
        cout<<dijkstra()<<endl;
    }
    return 0;
}

Measured memory_bytes: 3060
my $n = <STDIN>;
my $a_b = <STDIN>;

my ($a, $b) = split / /, $a_b;
my @p = split / /, <STDIN>;

my $under_a = 0;
my $under_b = 0;
my $over_b = 0;

foreach $p (@p){
    if($p <= $a){
        $under_a++;
    }elsif($p <= $b){
        $under_b++;
    }else{
        $over_b++;
    }
}

$ret = $under_a;
if($ret > $under_b){
    $ret = $under_b;
}
if($ret > $over_b){
    $ret = $over_b;
}

print $ret;


Measured memory_bytes: 512
use proconio::input;
fn main() {
    input! {
        n: usize,
        q: usize,
        a: [u32;n],
        qs: [(usize,usize,usize);q],
    }
    let mut ft=vec![0;n+1];
    for (i,a) in a.into_iter().enumerate() {
        add(&mut ft, i, a as u64);
    }
    for q in qs {
        if q.0==0 {
            add(&mut ft, q.1, q.2 as u64);
        }
        else {
            println!("{}",sum(&mut ft, q.2)-sum(&mut ft, q.1));
        }
    }
}
fn add(ft: &mut Vec<u64>, p: usize, x: u64) {
    let n=ft.len();
    let mut p=p+1;
    while p<n {
        ft[p]+=x;
        p+=p&p.wrapping_neg();
    }
}
fn sum(ft: &mut Vec<u64>, p: usize) -> u64 {
    let mut x=0;
    let mut p=p;
    while p>0 {
        x+=ft[p];
        p-=p&p.wrapping_neg();
    }
    x
}

Measured memory_bytes: 33216
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define T3I tuple<int, int, int>
#define x first
#define y second
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    string s;
    cin >> s;
    int n = s.size();
    if(n%2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < n; i+=2) {
        if(s[i] == 'h' && s[i+1] == 'i') {
            continue;
        }else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import bisect
import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n = getint()
values = list(sorted(getints()))

mx = max(values)
idx1 = bisect.bisect_left(values, mx // 2)
idx2 = idx1 - 1 if idx1 > 0 else idx1

if abs(mx - values[idx1] * 2) < abs(mx - values[idx2] * 2):
    idx = idx1
else:
    idx = idx2

print(mx, values[idx])

Measured memory_bytes: 14928
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int n,r,s_n;
    cin>>n;
    s_n=n;
    char str[4];
    int k=0;
    if(n)
    while(s_n){
        r=s_n%10;
        str[k]=r+'0';
        k++;
        s_n/=10;
    }
    str[k]='\0';
    if((str[0]==str[1]&&str[1]==str[2])||(str[1]==str[2]&&str[2]==str[3])){
    cout<<"Yes"<<endl;
}
    else
        cout<<"No"<<endl;
    return 0;

}

Measured memory_bytes: 256
n = int(input())
l = 1
while n-26**l > 0:
    n -= 26**l
    l += 1
else:
    n -= 1
    res = ""
    for i in range(l):
        n,r = divmod(n,26)
        res += chr(ord("a")+r)
    ans = res[::-1]
print(ans)

Measured memory_bytes: 9136
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
void up(int&x,int y){x+=y;if(x>=P)x-=P;}
/*int n,a;
int main(){
    read(n),read(a);
    if (a>=n) puts("Yes");
    else{
        for (int i=0;i<=a;i++){
            if ((n-i)%500==0) return puts("Yes"),0;
        }
        puts("No");
    }
    return 0;
}*/
int n,a[105];
int main(){
    read(n);
    for (int i=1;i<=n;i++) read(a[i]);
    sort(a+1,a+1+n);
    reverse(a+1,a+1+n);
    int ans=0;
    for (int i=1;i<=n;i+=2){
        ans+=a[i]-a[i+1];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 764
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 505
#define N 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char ch[maxn][maxn];

struct node{int from,to,cap,flow;};
vector <node> edges;
vector <int> mp[N];
int n,m,s,t,d[N],cur[N],F;
bool vis[N];
queue <int> que;

inline void A(int u,int v,int w)
{
	//cout<<u<<" "<<v<<" "<<w<<endl;
	edges.push_back((node){u,v,w,0});
	edges.push_back((node){v,u,0,0});
	int pp=edges.size();
	mp[u].push_back(pp-2);
	mp[v].push_back(pp-1);
}

inline bool bfs()
{
	for(int i=0;i<=2*n*m;i++) d[i]=inf,vis[i]=0; d[s]=0; vis[s]=1; que.push(s);
	while(!que.empty())
	{
		int u=que.front(); que.pop();
		for(int i=0;i<mp[u].size();i++)
		{
			node v=edges[mp[u][i]];
			if(v.cap-v.flow>0&&!vis[v.to])
			{
				d[v.to]=d[u]+1;
				vis[v.to]=1; que.push(v.to);
			}
		}
	}
	if(vis[t]) return true;
	return false;
}

inline int dfs(int u,int w)
{
	int flow=0,r=0;
	if(u==t||w==0) return w;
	for(int i=0;i<mp[u].size();i++)
	{
		node &v=edges[mp[u][i]];
		if(d[v.to]==d[u]+1&&(r=dfs(v.to,min(v.cap-v.flow,w)))>0)
		{
			flow+=r;
			edges[mp[u][i]].flow+=r;
			edges[mp[u][i]^1].flow-=r;
			w-=r;
			if(w==0) break;
		}
	}
	return flow;
}

inline int max_flow()
{
	int ff=0;
	while(bfs())
	{
		memset(cur,0,sizeof(cur));
		ff+=dfs(s,inf);
	}
	return ff;
}

inline int X(int x,int y){return (x-1)*m+y;}

inline void jud(int x,int y)
{
	for(int i=1;i<=n;i++) if(ch[i][y]=='T') F=1;
	for(int i=1;i<=m;i++) if(ch[x][i]=='T') F=1;
}

inline void a1(int x,int y)
{
	for(int i=1;i<=n;i++) if(ch[i][y]=='o') A(s,X(i,y),1);
	for(int i=1;i<=m;i++) if(ch[x][i]=='o') A(s,X(x,i),1);
}

inline void a2(int x,int y)
{
	for(int i=1;i<=n;i++) if(ch[i][y]=='o') A(X(i,y)+n*m,t,1);
	for(int i=1;i<=m;i++) if(ch[x][i]=='o') A(X(x,i)+n*m,t,1);
}

inline void a3(int x,int y)
{
	for(int i=1;i<=n;i++) if(ch[i][y]=='o'&&i!=x) A(X(x,y)+n*m,X(i,y),1);
	for(int i=1;i<=m;i++) if(ch[x][i]=='o'&&i!=y) A(X(x,y)+n*m,X(x,i),1);
}

int main()
{
	n=read(); m=read(); rep(i,1,n) scanf("%s",ch[i]+1);
	rep(i,1,n) rep(j,1,m)
	{
		if(ch[i][j]=='.') continue;
		if(ch[i][j]=='S') s=X(i,j),jud(i,j),a1(i,j);
		else if(ch[i][j]=='T') t=X(i,j)+n*m,a2(i,j);
	}
	rep(i,1,n) rep(j,1,m) if(ch[i][j]=='o') a3(i,j);
	rep(i,1,n) rep(j,1,m) if(ch[i][j]!='S'&&ch[i][j]!='T') A(X(i,j),X(i,j)+n*m,1);
	if(F) return puts("-1"),0;
	printf("%d\n",max_flow());
	return 0;
}

Measured memory_bytes: 112712
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] word = ReadLine().Split(' ');
        int l1 = word[0].Length;
        int l2 = word[1].Length;
        if(word[0][l1-1] == word[1][0] && word[1][l2-1] == word[2][0]){
            WriteLine("YES");
        }else{
            WriteLine("NO");
        }
    }
}


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

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

    double x, ans = 0;
    string u;
    for (int i = 0; i < n; i++) {
        cin >> x >> u;
        if (u == "JPY") 
            ans += x;
        else
            ans += x * 380000.0;
    }
    cout << ans << endl;
}

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

int main() {
	std::uint32_t N;
	std::cin >> N;
	std::uint64_t a;
	std::vector<std::uint64_t> b(N + 1);

	std::uint32_t j = (N + 1) / 2;
	for (std::uint32_t i = 0; i < N; ++i) {
		std::cin >> a;

		j += (i % 2 == 0 ? -i : i);
		b[j] = a;
	}

	if (N - j < j) {
		for (std::uint32_t i = j; i >= 1; --i) {
			std::cout << b[i] << " ";
		}
	} else {
		for (std::uint32_t i = j; i <= N; ++i) {
			std::cout << b[i] << " ";
		}
	}

	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 3840
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int x = sc.nextInt();
        int nn = 2 * n - 1;

        if (x == 1 || x == nn) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
            for (int i = 0; i < nn; i++) {
                System.out.println((i + x + n - 1) % nn + 1);
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 46908
import sys
from functools import lru_cache

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    N = len(S)

    @lru_cache(maxsize=None)
    def rec(i):
        if i == N:
            return 0

        ans = 0
        for j in range(i + 1, N + 1):
            ans += int(S[i:j]) * pow(2, max(N - j - 1, 0)) + rec(j)

        return ans

    print(rec(0))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9448
n,k=map(int,input().split())
a,b=list(map(int,input().split())),0
for i,j in enumerate(a):
    for h in a[i:]:
        if j<h:b+=k*(k-1)//2
        elif j>h:b+=k*(k+1)//2
print(b%(10**9+7))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define mod 1000000007 
using namespace std;
bool pri(ll n)
{
if(n==2)
{
return 1;
}
if(n%2==0)
{
return 0;
}
for(ll i=3;i<=sqrt(n);i++)
{
if(n%i==0)
{
return 0;
}
}
return 1;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
ll ans=0;
ll k=sqrt(n);
for(ll i=2;i<=k;i+=2)
{
ll cnt=0;
while(n%i==0)
{
n/=i;
cnt++;
}
ll d=(-1+sqrt(1+8*cnt))/2;
if((d+1)*(d+2)/2<=cnt)
{
d++;
}
ans+=d;
if(i==2)
{
i--;
}
}
if(n!=1)
{
ans++;
}
cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll N;
    ll count = 0;
    int K;
    cin >> N>>K;
    int h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
        if(h[i]>=K){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Distributing Integers
 */

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

/* constant */

const int MAX_N = 200000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

int ps[MAX_N], cns[MAX_N], ss[MAX_N], ds[MAX_N];
vi nbrs[MAX_N];
int fs[MAX_N + 1], invfs[MAX_N + 1];

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

inline int nck(int n, int k) {  // nCk % MOD
  return (ll)fs[n] * invfs[n - k] % MOD * invfs[k] % MOD;
}

inline int inverse(int n) { return powmod(n, MOD - 2); }

void prepare_fracs(int n) {
  fs[0] = invfs[0] = 1;
  for (int i = 1; i <= n; i++) {
    fs[i] = (ll)fs[i - 1] * i % MOD;
    invfs[i] = inverse(fs[i]);
  }
}

/* main */

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

  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;

    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  prepare_fracs(n);

  ps[0] = -1;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int up = ps[u];
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int v = *vit;
      if (v != up) {
	ps[v] = u;
	cns[u]++;
	q.push(v);
      }
    }
  }

  for (int u = 0; u < n; u++) {
    ds[u] = 1;
    if (cns[u] == 0) q.push(u);
  }

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int up = ps[u];
    vi &nbru = nbrs[u];

    ss[u]++;

    if (up >= 0) {
      ss[up] += ss[u];
      ds[up] = (ll)ds[up] * nck(ss[up], ss[u]) % MOD * ds[u] % MOD;
      if (--cns[up] == 0) q.push(up);
    }
  }
  //printf("%d\n", ds[0]);

  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int up = ps[u];
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int v = *vit;
      if (v != up) {
	ds[v] =
	  (ll)ds[u] * inverse(nck(n - 1, ss[v])) % MOD *
	  nck(n - 1, n - ss[v]) % MOD;
	q.push(v);
      }
    }
  }

  for (int u = 0; u < n; u++) printf("%d\n", ds[u]);
  return 0;
}


Measured memory_bytes: 19060
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll N, M;cin>>N>>M;
	// 解法
	ll ans = N*(N-1)/2 + M*(M-1)/2;

	//出力
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))
temp=1
summ=0
cont=0
templist=[1]
for i in range(N+1):
  #print(temp)
  if A[i]<temp:
    if i<N:
      summ+=temp
      temp=2*(temp-A[i])
      templist.append(temp)
    elif i==N:
      summ+=temp
      cont+=1
  elif A[i]==temp:
    if i==N:
      summ+=temp
      #templist.append(temp)
      cont+=1
    else:
      print("-1")
      break
  else:
    print("-1")
    break
    
if cont==1:
  if A[N]==temp:
  	print(summ)
  else:
    #print(templist)
    #print(A)
    comp=A[-1]
    for i in range(N):
      summ-=(templist[-(i+1)]-comp)
      comp+=A[-(i+2)]
      #print(comp)
      #print(templist[-(i+2)])
      #print(summ)
      if comp>templist[-(i+2)]:
        print(summ)
        break
      if i==N-1:
        print(summ)
        break
        

Measured memory_bytes: 674368
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;

int main(){
  int w,h;
  cin>>w>>h;
  int x[10][10];
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++)cin>>x[i][j];
  }

  rep(k,10)rep(i,10)rep(j,10){
    x[i][j]=min(x[i][j],x[i][k]+x[k][j]);
  }
  int ans =0;
  rep(i,w)rep(j,h){
    int a;
    cin>>a;
    if(a==-1)continue;
    ans+=x[a][1];
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int main(){
    int x,k;
    cin>>k>>x;
    if(k*500>=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    deque<int> d;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        if(!i)
            d.push_back(a);
        else
        {
            if(i%2)
                d.push_back(a);
            else
                d.push_front(a);
        }
    }
    if(n%2==0)
        reverse(d.begin(),d.end());
    for(int i=0;i<n;i++)
    {
        if(i)
            cout<<" ";
        cout<<d[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
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;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};
vector<vector<int>>G;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  int m;
  cin >> m;
  ll tot=0;
  ll sum=0;
  rep(i,m){
    ll d,c;
    cin >> d >> c;
    tot+=d*c;
    sum+=c;
  }
  ll ans=0;
  ans+=sum-1+(tot-1)/9;
  
  cout << ans << endl;
  
}


Measured memory_bytes: 12160
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[6], i, j = 0;
    scanf("%s", s) ;
    if((s[2]==s[3])&&(s[4]==s[5]))
        j++;
    if(j==1)
        puts("Yes");
    else
        puts("No") ;
    return 0;
}

Measured memory_bytes: 128
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = a + b + c
n = int(input())
n_list = [int(input()) for i in range(n)]
o = [False, False, False, False, False, False, False, False, False]
flag = False
for i in n_list:
    if i in d:
        o[d.index(i)] = True

for i in range(0, 7, 3):

    if o[i] and o[i + 1] and o[i + 2]:
        flag = True
        break

for i in range(0, 3):
    if o[i] and o[i + 3] and o[i + 6]:
        flag = True
        break

if o[0] and o[4] and o[8]:
    flag = True
if o[2] and o[4] and o[6]:
    flag = True

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064