akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    long int a,b,c,d;
  cin>>a>>b>>c>>d;
    unsigned long long int ans;
    if(a>0 && b>0){
        if(c>0&& d>0){
            ans=b;
            ans=ans*d;
            cout<<ans<<endl;
        }else if(c<0 && d>0){
            ans=b;
            ans=ans*d;
            cout<<ans<<endl;
        }else{
            cout<<d*a<<endl;
        }
        
        
    }else if(a<0 && b>0){
         if(c>0&& d>0){
            ans=b;
            ans=ans*d;
            cout<<ans<<endl;
        }else if(c<0 && d>0){
            ans=b;
            ans=ans*d;
            unsigned long long int ans2=abs(a);
            ans2=ans2*abs(c);
            cout<<max(ans,ans2)<<endl;
        }else{
            unsigned long long int ans2=abs(a);
            ans2=ans2*abs(c);
            cout<<ans2<<endl;
        }
    }else{
        if(c>0&& d>0){
            cout<<b*c<<endl;
        }else if(c<0 && d>0){
            ans=abs(c);
            ans=ans*abs(a);
            cout<<ans<<endl;
        }else{
           ans=abs(c);
            ans=ans*abs(a);
            cout<<ans<<endl;
        }
        
    }
    
    
    return 0;
}

Measured memory_bytes: 3608
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    x, y = list(map(int, input().rstrip('\n').split()))
    if (x + y) % 3 == 0:
        cnt = (x + y) // 3
        for i in range(0, cnt + 1):
            if (cnt - i) + i * 2 == x and (cnt - i) * 2 + i == y and cnt - i >= 0:
                print(alg_combination_mod(cnt, i, mod))
                exit()
        print(0)
    else:
        print(0)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF	INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long				ll;
typedef pair <int, int> ii;
 
/*
struct point{
	ll x;
	ll y;
	point(){x = 0;y = 0;}
	point(ll x, ll y):x(x), y(y){}
};
*/

int main() {
	
	int a, b, c;
	//vector<int> ans;
	cin >> a >> b >> c;
	if(a <= c && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a&&c >= b) {
		cout << a + b << endl;
	}
	else if (b >= a&&b >= c) {
		cout << a + c << endl;
	}
	else
		cout << b + c << endl;
}

Measured memory_bytes: 256
MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))

# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= MOD
# RをなるべくLに近づけてみる
R %= MOD
if R <= L:
    R += MOD

# print(L, R)
ans = 2**16
for i in range(L, R):  # i<jが成り立つ範囲に注意
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % MOD)
print(ans)

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

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

using ll = long long;
using P = pair<int,int>;
using graph = vector<vector<char>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    ll X,Y;
    cin>>X>>Y;
    int cnt = 0;
    while(X<=Y){
        X*=2LL;
        cnt++;
    }
    cout<<cnt<<endl;
}

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

int main()
{
	int M;
	scanf("%d", &M);
	std::vector<int> d(M);
	std::vector<int64_t> c(M);
	for (int i{}; i < M; i++)
		scanf("%d%lld", &d[i], &c[i]);
	int64_t sum{}, c_sum{};
	for (int i{}; i < M; i++)
	{
		sum += d[i] * c[i];
		c_sum += c[i];
	}
	printf("%lld\n", (sum - 1) / 9 + c_sum - 1);

	return 0;
}

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

typedef long long ll;

int main(void)
{
    ll a,b;
    cin>>a>>b;
    ll ans = (a+b)/2;
    if(abs(a-ans) == abs(b-ans))
        cout<<ans<<"\n";
    else
        cout<<"IMPOSSIBLE\n";

    return 0;
}


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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 5e3+5;

ld pw[N];
ll x;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> x;
  ll a = 100;
  int cnt = 0;
  while(a < x) a += ll(0.01 * a), cnt++;
  cout << cnt << "\n";

}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

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

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << c[i][j];
        }
        cout << endl;
        for(int j = 0; j < w; j++){
            cout << c[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int H=1,W=1,i,j;
	
	while((H !=0)||(W!=0))
	{
		scanf("%d %d",&H,&W);
		if((H !=0)||(W!=0))
		{
			for(i=0;i<W;i++)
			{
				printf("#");
			}
			printf("\n");
			for(i=0;i<H-2;i++)
			{
				printf("#");
				for(j=0;j<W-2;j++)
				{
					printf(".");
				}
				printf("#\n");
			}
			for(i=0;i<W;i++)
			{
				printf("#");
			}
			printf("\n\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2048
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void coVec(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll h, n;
	cin >> h >> n;
	Vec a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];

	Vec dp(2e4+1, LINF);
	dp[0] = 0;
	rep(i, n){
		rep(j, 2e4+1) if(j >= a[i]) chmin(dp[j], dp[j-a[i]]+b[i]);
	}

	ll ans = LINF;
	REPN(i, h, 2e4) chmin(ans, dp[i]);
	co(ans);

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll qpow(ll a,ll n)
{
    ll r=1%P;
    for (a%=P; n; a=a*a%P,n>>=1)
        if(n&1)
            r=r*a%P;
    return r;
}
int main()
{
double n,d;
double x,y;
cin>>n>>d;
int ans=0;
   for(int i=1;i<=n;i++)
   {
       cin>>x>>y;
       if(sqrt(x*x+y*y)<=d)
        ans++;
   }
   cout<<ans<<endl;

}



Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll unsigned long long int
ll m=1000000007;
int main()
{
	fast;
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int c=0;
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(a[i]!=a[j])
			{
				ll sum=a[i]+a[j];
				for(int k=j+1;k<n;k++)
				{
					if(sum>a[k] && k!=i && k!=j && a[i]!=a[k] && a[j]!=a[k])
					{
						//cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<nl;
						c++;
					}
				}
			}
			else
				continue;
			
		}
	}
	cout<<c;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    double ans=0;
    for(int i=1;i<=n;i++){
        if(i%2!=0)ans++;
    }
    cout<<ans/(double)n<<endl;
}

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  int x=abs(a-b-1);
  cout<<((x&1)^(a>b)?"Alice":"Borys")<<endl;
  return 0;
}


Measured memory_bytes: 764
import numpy as np
N,K = map(int,input().split())
hlist = list(map(int, input().split()))
h = np.array(hlist)

cost = [-1 for _ in range(N)]
dp = np.zeros(N, dtype="int32")
 
for i in range(1, N):
    if i < K:
        dp[i] = np.min(dp[:i] + np.abs(h[i]-h[:i]))
    else:
        dp[i] = np.min(dp[i-K:i] + np.abs(h[i]-h[i-K:i]))

print(dp[N - 1])

Measured memory_bytes: 22836
// D - Semi Common Multiple

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int a_half[100000];

ll get_gcd(ll x, ll y) {
	if (x < y) {
		swap(x, y);
	}

	ll m = x % y;

	while (m != 0) {
		x = y;
		y = m;
		m = x % y;
	}

	return y;
}

ll get_lcm(ll x, ll y) {
	return x / get_gcd(x, y) * y;
}

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

	int a;
	for (int i=0; i<N; i++) {
		cin >> a;
		a_half[i] = a / 2;
	}

	// a/2の最小公倍数Lを求める
	ll L = 1;
	for (int i=0; i<N; i++) {
		L = get_lcm(L, a_half[i]);
	}

	// Lが半公倍数でなければ答えは0
	for (int i=0; i<N; i++) {
		if ((L / a_half[i]) % 2 == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	// Lの奇数倍が半公倍数なのでその数を数える
	int ans = 0;
	int i = 1;
	while(L * i <= M) {
		ans++;
		i += 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
S = input()
N = len(S)

if N == 3:
    if S[0] == S[2]:
        print('Yes')
    else:
        print('No')
    exit()

def is_circular(string):
    reverse = string[::-1]
    if string == reverse:
        return True
    else:
        return False

if is_circular(S) and is_circular(S[:(N)//2]) and is_circular(S[(N+3)//2]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    multiset<int> ms;
    vector<int> x;
    int n;
    cin >> n;
    for (int i=0; i < n; i++){
        int a;
        cin >> a;
        x.push_back(a);
        ms.insert(a);
    }
    multiset<int>::iterator it = ms.begin();
    int nz = (n+1) / 2 - 1;
    while (nz > 0){
        nz--;
        it++;
    }
    for (int i=0; i < n; i++){
        int el = x[i];
        if (el > *it) cout << *it << endl;
        else{
            it++;
            cout << *it << endl;
            it--;
        }
    }
    return 0;
}





Measured memory_bytes: 12404
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  int n,mini;
  cin >> n;
  string a[36]={},b[36]={};
  for(int i=0; i<n; i++) {
      cin >> a[i];
      b[i]=a[i];
  }
  for(int i=0; i<n-1; i++) {
      for(int j=n-1; j>i; j--) {
          if(a[j][1]<a[j-1][1]) {
            swap(a[j],a[j-1]);
          }
      }
  }
  for(int i=0; i<n-1; i++) {
      cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  cout << "Stable" << endl;
  for(int i=0; i<n; i++) {
      mini=i;
      for(int j=i; j<n; j++) {
          if(b[mini][1]>b[j][1]) {
              mini=j;
          }
      }
      if(i!=mini) {
          swap(b[mini],b[i]);
      }
  }
  for(int i=0; i<n-1; i++) {
      cout << b[i] << " ";
  }
  cout << b[n-1] << endl;
  for(int i=0; i<n; i++) {
      if(a[i]==b[i]) {
          continue;
      }
      else {
          cout << "Not stable" << endl;
          return 0;
      }
  }
  cout << "Stable" << endl;
}


Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int N; cin >> N;
  vector<ll> A;
  for(int i = 1;i <= N;i++){
    ll a; cin >> a;
    A.push_back(a-i);
  }

  sort(A.begin(),A.end());

  ll mid = 0;
  for(int i = 1;i <= N;i++){
    if(i == N/2 + 1)mid = A[i-1];
  }

  ll ans = 0;

  for(int i = 0;i < N;i++){
    ans += abs(mid - A[i]);
  }

  cout << ans << endl;


  return 0;
}


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

int n,m,k,num[10010],mp[110][110],x,y;

inline void solve(int c,bool dic)
{
	if(num[c])
	{
		mp[x][y]=c;
		num[c]--;
		if(dic==0&&y==m-1) x++,solve(c,1);
		else if(dic==1&&y==0) x++,solve(c,0);
		else if(dic==0) y++,solve(c,0);
		else y--,solve(c,1);
	}
}

int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++) cin>>num[i];
	
	for(int i=1;i<=k;i++) if(x%2==0) solve(i,0); else solve(i,1);
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++) cout<<mp[i][j]<<' ';
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
 
int main(){
  int i,j,N,a,b,minj,result=0;
  char A[36][3],B[36][3],C[36][3];
   
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",A[i]);
  }
   
 
  for(i=0;i<N;i++){
    strcpy(C[i],A[i]);
  }
   
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j][1]<A[j-1][1]){
    strcpy(B[j],A[j-1]);
    strcpy(A[j-1],A[j]);
    strcpy(A[j],B[j]);
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
    for(b=a+1;b<N;b++){
      if(C[i][1]==C[j][1] && strcmp(C[i],A[b])==0 && strcmp(C[j],A[a])==0)
        result=1;
    }
      }
    }
  }
 
  for(i=0;i<N-1;i++){
    printf("%s ",A[i]);
  }
  printf("%s\n",A[N-1]);
  if(result==1){
    printf("Not stable\n");
  }
  else printf("Stable\n");
 
 
   
  result=0;
   
   for(i=0;i<N;i++){
    strcpy(A[i],C[i]);
  }
   
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j][1]<A[minj][1]){
    minj=j;
      }
    }
 
    strcpy(B[i],A[i]);
    strcpy(A[i],A[minj]);
    strcpy(A[minj],B[i]);
 
  }
    for(i=0;i<N;i++){
      for(j=i+1;j<N;j++){
    for(a=0;a<N;a++){
      for(b=a+1;b<N;b++){
        if(C[i][1]==C[j][1] && strcmp(C[i],A[b])==0 && strcmp(C[j],A[a])==0)
          result=1;
      }
    }
      }
    }
 
    for(i=0;i<N-1;i++){
      printf("%s ",A[i]);
    }
   printf("%s\n",A[N-1]);
    if(result==1){
    printf("Not stable\n");
    }
    else printf("Stable\n");
     
  return 0;
}

Measured memory_bytes: 1924
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
    int sign = 1;
    T ret = 0;
    char c;

    do{
        c = getc();
    }while(c == ' ' || c == '\n');
    if(c == '-')sign = -1;
    else ret = c-'0';
    while(1){
        c = getc();
        if(c < '0' || c > '9')break;
        ret = 10*ret + c-'0';
    }
    return sign * ret;
}

inline void ini(int& x){
    x = getnum<int>();
}

inline void scani(int& x){
    scanf("%d",&x);
}

//end of macro

int n,l;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>n>>l;
    int total = 0, ans = OO;
    REP(i,1,n){
        total += l+i-1;
    }
    REP(i,1,n){
        int tmp = 0;
        REP(j,1,n){
            if(i == j)continue;
            tmp += l+j-1;
        }
        if(ans == OO || abs(total-ans) > abs(total-tmp))ans = tmp;
    }
    cout << ans << endl;

    return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
ll num[200010];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n;cin >> n;
    vector<ll> a(n);
    rep(i,0,n){
        int tmp;cin >> tmp;
        num[tmp]++;
        a[i] = tmp;
    }
    ll ans=0;
    rep(i,0,200010){
        if(num[i]>1) ans += num[i]*(num[i]-1)/2;
    }
    rep(i,0,n){
        if(num[a[i]]>2)cout << ans - num[a[i]]*(num[a[i]]-1)/2+(num[a[i]]-1)*(num[a[i]]-2)/2 << endl;
        else cout << ans - num[a[i]]*(num[a[i]]-1)/2 << endl;
    }
    

}

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

int main(void)

{	
	int n,k,i;
	long long int ans=1;
	scanf("%d %d",&n,&k);
	
	for(i=1;i<=n-1;i++){
		ans*=(k-1);
	}
	ans*=k;
	
	printf("%lld\n",ans);
	return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

int spf[N],cnt[N];
vector<int> primes;

void sieve()
{
    for(int i=2;i<N;i++)
    {
        if(!spf[i])
        {
            primes.pb(i);
            spf[i]=i;
            for(int j=i*i;j<N;j+=i)if(!spf[j])spf[j]=i;
        }
    }
}

signed main()
{
    FAST
    sieve();
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,x;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            while(x > 1)
            {
                int p = spf[x];
                while(!(x%p))x /= p;
                cnt[p]++;
            }
        }
        int ok1 = 1,ok2 = 0;
        for(int i:primes)ok1 &= (cnt[i] <= 1);
        if(ok1)return cout<<"pairwise coprime",0;
        for(int i:primes)ok2 |= (cnt[i] == n);
        if(ok2)return cout<<"not coprime",0;
        cout<<"setwise coprime"<<endl;
    }
    return 0;
}


Measured memory_bytes: 19724
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a);
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef double db;
const int N = 20;
const db EPS = 1e-9;
using namespace std;

void dbg() {cout << "\n";}
template<typename T, typename... A> void dbg(T a, A... x) {cout << a << ' '; dbg(x...);}
#define logs(x...) {cout << #x << " -> "; dbg(x);}

int n,x[N],y[N],ans,vis[N],flag[N],sz;

void dfs(vector<int> v, int tmp){
	ans = max(ans, tmp);
	int sz = v.size();
	if(sz == 0) return;
	rep(i,0,sz-1){
		rep(j,i+1,sz-1){
			int x1 = x[v[i]]-x[v[j]], y1 = y[v[i]]-y[v[j]];
			int cnt = 0;
			rep(k1,0,sz-1){
				if(flag[v[k1]]) continue;
				rep(k2,k1+1,sz-1){
					if(flag[v[k2]]) continue;
					int x2 = x[v[k2]]-x[v[k1]], y2 = y[v[k2]]-y[v[k1]];
					if(y2*x1 == y1*x2){
						flag[v[k1]] = flag[v[k2]] = 1;
						cnt++;
						break;
					}
				}
			}
			if(cnt > 1){
				vector<int> vv; vv.clear();
				rep(k1,0,sz-1)
					if(!flag[v[k1]]) vv.push_back(v[k1]);
				dfs(vv, tmp+cnt*(cnt-1)/2);
				vv.clear();
			}
			rep(k1,0,sz-1) flag[v[k1]] = 0;
		}
	}
	v.clear();
}

int main()
{
	scanf("%d",&n);
	rep(i,1,n) scanf("%d %d",&x[i],&y[i]);
	vector<int> v;
	rep(i,1,n) v.push_back(i);
	dfs(v,0);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3268
N = int(input())
L = input().split(" ")
for i in range(N):
  L[i] = int(L[i])
L.sort()

count = 0
for i in range(N):
  a1 = i+1
  if a1 > N:
    break
  for j in range(N):
    a2 = a1 + j + 1
    if a2 > N:
      break
    for k in range(N):
      a3 = a2 + k + 1
      if a3 > N:
        break
      a = [L[a1-1],L[a2-1],L[a3-1]]
      a.sort()
      if a[0] != a[1] and a[1] != a[2]:
        if a[0]+a[1] > a[2]:
          count = count + 1
        else:
          None
      else:
        None
print(count)

Measured memory_bytes: 9228
#include <stdio.h>

int main(int argc, char** argv)
{
	int i, j, k, n, q;
	long S[10000], T[500], result[500];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%ld", &S[i]);
	}

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%ld", &T[i]);
	}

	int cnt = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < q; j++) {
			if (S[i] == T[j]) {
				int is_match = 0;
				for (k = 0; k < cnt; k++) {
					if (result[k] == S[i]) {
						is_match = 1;
						break;
					}
				}
				if (!is_match) {
					result[cnt++] = S[i];
					break;
				}
			}
		}
	}

	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<ll(n); i++)
#define REPR(i, n) for(ll i=n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=m; i<ll(n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(ALL(a));
  int ans = 0;
  REP(i,n) FOR(j,i+1,n) FOR(k,j+1,n){
    if(a[i]==a[j]) continue;
    if(a[i]==a[k]) continue;
    if(a[j]==a[k]) continue;
    if(a[i]+a[j]>a[k]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    string a,b,c;
    cin >> a >> b >> c;

    int a_len = a.size();
    int b_len = b.size();
    int c_len = c.size();

    int a_key = 0;
    int b_key = 0;
    int c_key = 0;
    queue<char> que;
    que.push('a');

    while( true )
    {
        if( que.front() == 'a' )
        {
            if( a_key == a_len )
            {
                cout << "A" << endl;
                return 0;
            }
            que.pop();
            que.push(a[a_key]);
            a_key++;
        }
        else if( que.front() == 'b' )
        {
            if( b_key == b_len )
            {
                cout << "B" << endl;
                return 0;
            }
            que.pop();
            que.push(b[b_key]);
            b_key++;
        }
        else
        {
            if( c_key == c_len )
            {
                cout << "C" << endl;
                return 0;
            }

            que.pop();
            que.push(c[c_key]);
            c_key++;
        }
        //cout << a_key << " " << b_key << " " << c_key << endl;
    }
}


Measured memory_bytes: 256
#include<set>
#include<cstdio>
#include<cctype>
#include<string>
inline int getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
int main() {
	std::multiset<std::string> set;
	for(register int i=getint();i;i--) set.insert("a");
	for(register int i=getint();i;i--) set.insert("b");
	for(register int i=getint();i;i--) set.insert("c");
	while(set.size()>1) {
		std::string s=*set.begin(),t=*set.rbegin();
		set.erase(set.lower_bound(s));
		set.erase(set.lower_bound(t));
		set.insert(s+t);
	}
	printf("%s\n",(*set.begin()).c_str());
	return 0;
} 

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		long[] A = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = nl();
		}
		Arrays.sort(A);
		BigInteger result = BigInteger.valueOf(1L);
		for(int i = 0; i < N; i++) {
			result = result.multiply(BigInteger.valueOf(A[i]));
			if(result.compareTo(BigInteger.valueOf(1000_000_000_000_000_000L)) > 0 ) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(result.toString());
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 50596
N,M = map(int,input().split())
number = M
answer = 0
ABlist = []

for x in range(0,N):
    A,B = map(int,input().split())
    ABlist.append([A,B])

ABlist.sort()

for x in ABlist:
    if x[1] >= number:
        answer += x[0] * number
        break
    else:
        answer += x[0] * x[1]
        number -= x[1]

print(answer)

Measured memory_bytes: 20048
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int d, g, ans = 0;
    cin >> d >> g;
    vector<int> p(d), c(d);

    rep(i, d) {
        cin >> p[i] >> c[i];
        ans += p[i];    //全部解いたと仮定(最大値で初期化)
    }

    // 00…0(0がd個)から11…1(1がd個)まで全ての0＆1列を調べる
    for(int i = 0; i < (1 << d); i++) { 
        int score = 0;  //いまの得点
        int num = 0;    //解いた問題数
        int rest = -1;  //部分的に解く問題の問題番号

        //iのjビット目が0か1か調べる
        rep(j, d) {
            //jビット目が1だったら
            if( (i >> j) & 1 ) {
                //j番目の問題をすべて解く。コンプリボーナスも得点に加える
                score += ((j+1)*100*p[j] + c[j]);
                //解いた問題数をp[j]増やす
                num += p[j];
            }
            //jビット目が0だったら
            else {
                /*j番目の問題を部分的に解く。ループが終わるときには、
                   iの0＆1列の0のものの中で最も得点の高い
                   問題番号がrestに入る。*/
                rest = j;
            }
        }

        //0＆1列中の1の問題をすべて解いてもスコアがGに届かない場合
        if(g > score) {
            int need;   //残り解く問題数

            //100*(rest+1)は、rest番目の問題を1問解くごとに得られる点数
            //p[rest]はrest番目の問題数の最大値
            /* (g-score-1)/(100*(rest+1)) + 1で、残りg-score点必要で
               1問ごとに100*(rest+1)点入るときに解く必要のある最低問題数
               が求まる。これをp[rest]と比べればよい */
            need = min( (g-score-1)/(100*(rest+1)) + 1, p[rest] );
            //部分的に解く問題の合計点数を得点に加える
            score += (rest+1)*100*need;
            //解いた問題数をneed増やす
            num += need;
        }

        //スコアがGを超えたら
        if(score >= g) {
            //numの最小値がansに入る
            ans = min(ans, num);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

ll count(vector<ll> a, ll n, ll v) {
    ll tot = 0;
	for (ll i = 0; i < n; ++i) {
		tot += n - (lower_bound(a.begin(), a.end(), v - a[i]) - a.begin());
	}
	return tot;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n,0);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<ll> s(n+1,0);
    for (ll i = 0; i < n; ++i) {
        s[i+1] = s[i] + a[n - 1- i];
    }

	ll mi = 0;
	for (ll i=40; i>=0; i--) {
        if (count(a, n, mi+(1LL<<i)) >=m ) {
            mi += 1LL<<i;
        }
    }

	ll num=0;
	ll ret=0;
    for (ll i = 0; i < n; ++i) {
		ll x = n - (lower_bound(a.begin(), a.end(), mi - a[i]) - a.begin());
		num += x;
		ret += a[i]*x + s[x];		
	}

	ret -= (num-m)*mi;
	cout<<ret<<endl;
}


Measured memory_bytes: 2572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BReverseandCompare solver = new BReverseandCompare();
        solver.solve(1, in, out);
        out.close();
    }

    static class BReverseandCompare {
        static char[] alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
                'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            long len = s.length();
            long res = len * (len - 1) / 2;
            for (int i = 0; i < 26; i++) {
                long cnt = 0;
                for (int j = 0; j < len; j++) {
                    if (s.charAt(j) == alphabet[i]) {
                        cnt++;
                    }
                }
                res -= cnt * (cnt - 1) / 2;
            }
            out.println(res + 1);
        }

    }
}



Measured memory_bytes: 25936
#include <stdio.h>

using namespace std;

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

	for(int i = 0; i < n; i++) scanf("%d",&A[i]);

	for(int i = n-1; i > 0; i--) printf("%d ",A[i]);
	printf("%d\n",A[0]);
}


Measured memory_bytes: 2752
n,w=gets.split.map &:to_i
given=Array.new(n){gets.split.map &:to_i}
dp=Array.new(w+1,0)
0.upto(n-1) do |i|
  w.downto(given[i][0]) do |j|
    can=dp[j-given[i][0]] + given[i][1]
    if can > dp[j]
      dp[j] = can
    end
  end
end

puts dp.last

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

void chmin(int &x,int y){x=min(x,y);}

main()
{
    string n; cin>>n;
    reverse(begin(n),end(n));
    int len=n.size();
    int inf=1e9;
    vector<vector<int>> dp(len+1,vector<int>(2,inf));
    dp[0][0]=0;
    for(int i=0;i<len;++i)
    {
        for(int j=0;j<2;++j)
        {
            int now=n[i]-'0'+j;
            if(now and now<10)
            {
                chmin(dp[i+1][0],dp[i][j]+now);
                chmin(dp[i+1][1],dp[i][j]+10-now);
            }
            if(now==10)
            {
                chmin(dp[i+1][1],dp[i][j]+10-now);
            }
            
            if(!now)
            {
                chmin(dp[i+1][0],dp[i][j]+now);
            }
        }
    }
    cout << min(dp[len][0],1+dp[len][1]) << "\n";
}

Measured memory_bytes: 55940
#include<stdio.h>
int main(){
  int n,m,u,b[100],i,j,h;
  while(scanf("%d %d",&n,&m),n||m){
    h=1;
    for(i=0;i<m;i++){
      scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	scanf("%d",&u);
	b[j]-=u;
	if(b[j]<0)h=0;
      }
    }
    if(h)printf("Yes\n");
    else printf("No\n");
  }
  return 0;
} 

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

int main()
{
   ll x, y;
   cin >> x >> y;

   ll a = abs(x -y);
   if(a != 1 && a != 0) cout << "Alice" << endl;
   else cout << "Brown" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double t = acos(-1) * 2;
    double z = t / (12 * 60) * (h * 60 + m - m * 12);
    double x = a * cos(z) - b;
    double y = a * sin(z);

    printf("%.12f\n", hypot(x, y));

    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);

  int H, W, K;
  cin >> H >> W >> K;

  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  --sx, --sy;
  --gx, --gy;

  vector<string> G(H);
  for (int i = 0; i < H; ++i) cin >> G[i];

  vector<vector<vector<int>>> vis(H, vector<vector<int>>(W, vector<int>(2)));
  vector<vector<int>> dis(H, vector<int>(W, 0x3f3f3f3f));
  queue<tuple<int, int, int>> bag;
  bag.emplace(dis[sx][sy] = 0, sx, sy);
  while (bag.size()) {
    int d, x, y;
    tie(d, x, y) = bag.front();
    bag.pop();
    const int dx[] = { 0, 1, 0, -1 };
    const int dy[] = { 1, 0, -1, 0 };
    for (int _ = 0; _ < 4; ++_) {
      for (int i = 1; i <= K; ++i) {
        int nx = x + i * dx[_];
        int ny = y + i * dy[_];
        if (nx < 0 || nx >= H) break;
        if (ny < 0 || ny >= W) break;
        if (G[nx][ny] == '@') break;
        if (vis[nx][ny][_ & 1]) break;
        vis[nx][ny][_ & 1] = 1;
        if (dis[nx][ny] < d + 1) break;
        bag.emplace(dis[nx][ny] = d + 1, nx, ny);
      }
    }
  }

  if (dis[gx][gy] == 0x3f3f3f3f) cout << -1 << endl;
  else cout << dis[gx][gy] << endl;

  return 0;
}



Measured memory_bytes: 113620
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();
 
	public static void main(String[] args) {

		long N = in.nextLong();
		long sum=0;
		for(long i=1;i<N+1;i++) {
			if(i % 3 == 0 || i % 5 == 0) {
			}else {
				sum += i;
			}
		}

		System.out.println(sum);

	}

	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 35752
#include <bits/stdc++.h>
 
// headers {{{
using namespace std;
// using namespace rel_ops;
 
typedef long long int64;
typedef unsigned long long uint64;
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define mem(a,b) memset(a, b, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#ifdef LOCAL
#define dbg(args...) printf(args); //##__VA_ARGS__
#define dout cout
#define out(x) (cout<<#x<<": "<<x<<endl)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
#else
#define dbg(...)
#define dout if(true);else cout
#define out(...)
#define show(...)
#endif
// }}}

// Generate primes[], phi[Z]
#define Z 1000005
// factor primes phi(x)欧拉函数 prime_count
int f[Z], prime[Z], phi[Z], prc;
void GenPrime() {
  int i, p, tmp;
  for (p = 2; p < Z; ++p) {
    if (!f[p]) f[p] = p, prime[prc++] = p, phi[p] = p - 1;
    for (i = 0; i < prc && prime[i] <= f[p] && (tmp = prime[i] * p) < Z; ++i) {
      f[tmp] = prime[i];
      if (prime[i] == f[p])
        phi[tmp] = phi[p] * prime[i];
      else
        phi[tmp] = phi[p] * (prime[i] - 1);
    }
  }
}
int main() {
    GenPrime();
    int64 N;
    while (cin >> N) {
        int ans = 0;
        for (int i = 2; i < Z && i < N; i++) {
            if (N%i == 0) {
                int k = 0;
                while (N%i==0) {
                    k++; N/=i;
                }
                for (int s = 1; s <= k; s++) {
                    k -= s; ans++;
                }
            }
        }
        if (N!=1) ans++;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 11756
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int n;
	scanf("%d", &n);
	vector<int> a(n), ans;
	bool b = true;
	rep(i, n)scanf("%d", &a[i]);
	while(!a.empty()){
	  b = false;
	  reprm(i, a.size()){
	    if(i + 1 == a[i]){
			   b = true;
			   ans.pb(a[i]);
			   a.erase(a.begin() + i);
			   break;
			}
		}
		if(!b)break;
	}
	if(!b)printf("-1\n");
	else reprm(i, n)printf("%d\n", ans[i]);
	
	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,N=2005;
int a[N],f[N][N];
int main()
{
	int n,k;
	for(int i=0;i<N;i++)f[i][0]=1;
	for(int i=1;i<N;i++)
		for(int j=1;j<=i;j++)
			f[i][j]=(f[i-1][j-1]+f[i-1][j])%mod;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		long long sum=1;
		sum=(sum*f[k-1][i-1])%mod;
		sum=(sum*f[n-k+1][i])%mod;
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 15104
# ライブラリのインポート
#import re #正規表現
#import sys
#import heapq
import collections


def main():
    n, q = map(int, input().split())
    deq = collections.deque()
    for i in range(n):
        name, time = input().split()
        deq.append((int(time),name))
    ans = []
    elps = 0
    while deq:
        time, name = deq.popleft()
        if time <= q:
            elps += time
            ans.append((name, elps))
        else:
            elps += q
            deq.append((time-q, name))
    [print(*i) for i in ans]
    


    
if __name__ == '__main__':
    main()



Measured memory_bytes: 14960
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for(int i=(a);i<(b);++i)
#define foreach(i, n) for (__typeof(n.begin()) i = n.begin(); i != n.end(); ++i)
#define sqr(x) ((x)*(x))
#define clr(a, b) memset(a, b, sizeof(a))
#define SZ(a) ((int)a.size())
#define inf 0x3f3f3f3f
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-8;
int dcmp(double x) { if (x < -eps) return -1; else return x > eps;}
#define se(x) cout<<#x<<" = "<<x<<endl

const int N = 10010;
int n, a, b;
int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a; 
}

int main(int argc, char *argv[]) {
	while (scanf("%d%d", &n, &a) != EOF) {
		int ret = -1;
		forn (i, n) {
			scanf("%d", &b);
			int t = abs(b - a);
			if (ret == -1) {
				ret = t;
			} else {
				ret = gcd(ret, t);
			}
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





vector<ll> a;
vector<vector<ll>> g;
vector<bool> used;

ll dfs(ll p){
    if(used[p]) return 0;
    used[p] = true;
    if(g[p].size() == 1) return a[p];
    
    ll sum = 0, mx = -1;
    for(auto &x : g[p]){
        ll tmp = dfs(x);
        sum += tmp;
        mx = max(mx, tmp);
    }
    
    ll l = max(mx, sum / 2);
    if(l > a[p] || sum < a[p]){
        cout << "NO" << endl;
        exit(0);
    }
    
    ll t = 2 * a[p] - sum;
    if(t < 0){
        cout << "NO" << endl;
        exit(0);
    }
    
    return t;
}

int main() {
    ll n;
    cin >> n;
    a.resize(n);
    g.resize(n);
    used.resize(n);
    REP(i, n){
        cin >> a[i];
    }
    REP(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    if(n == 2){
        if(a[0] == a[1]){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
        return 0;
    }
    
    REP(i, n){
        if(g[i].size() > 1){
            if(dfs(i) == 0){
                cout << "YES" << endl;
            }
            else{
                cout << "NO" << endl;
            }
            return 0;
        }
    }
}


Measured memory_bytes: 10496
#include <stdio.h>
int main ()
{
	int A1=1-13,A2=1-13,A3=1-13;
	scanf("%d", &A1);
	scanf("%d", &A2);
	scanf("%d", &A3);
	
	if(A1+A2+A3<22){
		printf("win");
	}else if(A1+A2+A3>=22){
		printf("bust");
	}
	return 0;
	
}

Measured memory_bytes: 3216