akhauriyash/Code-Regression huggingface dataset:
a, b, theta = gets.chomp.split.map(&:to_f)
rad = theta / 180 * Math::PI
h = b * Math.sin(rad)
S = a * h / 2
c = Math.sqrt(a ** 2 + b **2 -  2 * a * b * Math.cos(rad))
L = a + b + c
printf("%.5f\n", S)
printf("%.5f\n", L)
printf("%.5f\n", h)

Measured memory_bytes: 8932
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e7+1)

using grid = vector<vector<int>>;

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

void bfs(int y, int x, vector<string> &vs, grid &gd){
    gd[y][x] = 0;
    queue<pii> que;
    que.push(pii(y,x));
    
    while(que.size()){
        int ty = que.front().first;
        int tx = que.front().second;
        rep(k,4){
            int ddy = ty+dy[k];
            int ddx = tx+dx[k];
            if(ddx<0 || ddy<0 || ddx>=w || ddy>=h)continue;
            if(vs[ddy][ddx]=='x')continue;
            if(gd[ddy][ddx]!=INF)continue;
            gd[ddy][ddx] = gd[ty][tx]+1;
            que.push(pii(ddy,ddx));
        }
        que.pop();
    }
}

int main(){
    while(cin>>w>>h&&(w||h)){
        vector<string> vs(h);
        rep(i,h)cin>>vs[i];
        
        vector<pii> vp;
        pii st;
        rep(i,h){
            rep(j,w){
                if(vs[i][j]=='*')vp.pb(pii(i,j));
                else if(vs[i][j]=='o')st = pii(i,j);
            }
        }
        
        vector<vector<grid>> dist(h,vector<grid>(w,grid(h,vector<int>(w,INF))));
        rep(i,h){
            rep(j,w){
                bfs(i,j,vs,dist[i][j]);
            }
        }
        
        sort(all(vp));
        
        int ans = INF;
        do{
            int tmp = 0;
            tmp += dist[st.first][st.second][vp[0].first][vp[0].second];
            rep(i,vp.size()-1){
                tmp += dist[vp[i].first][vp[i].second][vp[i+1].first][vp[i+1].second];
            }
            ans = min(ans,tmp);
        }while(next_permutation(all(vp)));
        
        if(ans==INF)cout<<-1<<endl;
        else cout<<ans<<endl;
    }
}



Measured memory_bytes: 4204
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll grundy(ll now,ll par,std::vector<std::vector<ll>>& graph){
  ll val=0;
  for(ll next:graph[now]){
    if(next!=par){
      val^=(1+grundy(next,now,graph));
    }
  }

  return val;
}
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  ll n;
  std::cin>>n;

  std::vector<std::vector<ll>> graph(n);

  rep(i,0,n-1){
    ll x,y;
    std::cin>>x>>y;
    x--;y--;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }

  ll ans=0;

  for(ll next:graph[0]){
    ans^=(1+grundy(next,0,graph));
  }

  if(ans==0)std::cout<<"Bob";
  else std::cout<<"Alice";
 
  return 0;
}

Measured memory_bytes: 12032
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll n,W; cin >> n >> W;
  vector<ll> v(n);
  vector<ll> w(n);
  vector<pll> a(0);
  vector<pll> b(0);
  rep(i,n){
    cin >> v[i] >> w[i];
  }
  rep(i,1<<(n/2)){
    ll va=0,wa=0;
    rep(j,n/2){
      if((i>>j)&1){
        va+=v[j];
        wa+=w[j];
      }
    }
    a.push_back(pll(wa,va));
  }
  rep(i,1<<(n-n/2)){
    ll vb=0,wb=0;
    rep(j,n-n/2){
      if((i>>j)&1){
        vb+=v[j+n/2];
        wb+=w[j+n/2];
      }
    }
    b.push_back(pll(wb,vb));
  }
  sort(all(a));
  sort(all(b));
  rep(i,b.size()-1){
    chmax(b[i+1].second,b[i].second);
  }
  ll ans=0;
  for(int i=0,j=b.size()-1;i<a.size();i++){
    while(a[i].first+b[j].first>W){
      j--;
      if(j<0) goto OUT;
    }
    chmax(ans,a[i].second+b[j].second);
  }
OUT:
  cout << ans << endl;
}


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

int main(){
  vector<int> a(100);
  int n;
  while (cin >> n) {
    if (n > 0) {
      a.push_back(n);
    } else {
      cout << a.back() << endl;
      a.pop_back();
    }
  }
}



Measured memory_bytes: 3140
a = int(input())
l = []

for i in range(a):
    t = int(input())
    l.append([])
    for j in range(t):
        x,y = map(int,input().split())
        x-=1
        l[-1].append((x,y))

def is_honest(i,j):
    return (i >> j)%2 ==1

def honest_cnt(i):
    ans = 0
    for j in range(a):
        ans += is_honest(i,j)
    return ans
ans =0

for i in range(1 << a):
    ok = True
    for j in range(a):
        if not is_honest(i,j):continue
        for (x,y) in l[j]:
            if y == 0 and is_honest(i,x):ok = False
            if y == 1 and not is_honest(i,x):ok = False
        
    if ok:
        ans = max(ans, honest_cnt(i))
print(ans)


Measured memory_bytes: 47196
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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 namespace std;

int main(){
    Init();
    string s; cin >> s;
    set<char> st;
    rep(i, s.size()) st.insert(s[i]);

    bool ans = true;
    if(st.count('N')){
        if(!st.count('S')) ans = false;
    }
    if(st.count('W')){
        if(!st.count('E')) ans = false;
    }
    if(st.count('S')){
        if(!st.count('N')) ans = false;
    }
    if(st.count('E')){
        if(!st.count('W')) ans = false;
    }
    ans ? Yes() : No();
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){
	double a,b;
	cin>>a>>b;
 
	if(a>b){
		cout<<"GREATER"<<endl;
	}else if(a<b){
		cout<<"LESS"<<endl;
	}else{
		cout<<"EQUAL"<<endl;
	}
	
 
} 

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
"""
1*1*1*1*m = mなども含める
4をそのまま使う場合と2*2に分ける場合などの場合分けが必要
約数列挙からどうこうする？

"""
n,m = map(int,readline().split())
mod = 10**9+7

def pow(n,p,mod=10**9+7): #繰り返し二乗法(nのp乗)
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod
def factrial_memo(n=10**6,mod=10**9+7):
    fact = [1, 1]
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % mod)
    return fact
fact = factrial_memo()

"""素因数分解"""
def factrize(n):
    b = 2
    fct = []
    while b*b <= n:
        while n % b == 0:
            n //= b
            #もし素因数を重複させたくないならここを加えてfct.append(b)を消す
            """
            if not b in fct:
                fct.append(b)
            """
            fct.append(b)
        b = b+1
    if n > 1:
        fct.append(n)
    return fct #リストが帰る

prime = factrize(m)

from collections import defaultdict
dic1 = defaultdict(int)

for i in prime:
    dic1[i] += 1

ans = 1

for i in dic1.values():
    ans *= fact[n+i-1]*pow(fact[n-1],mod-2)*pow(fact[i],mod-2)
    ans %= mod
print(ans)

Measured memory_bytes: 144400
#include <stdio.h>
int n;//数字を入力
int cnt = 0;//同じ数字をカウント
int nums[4];//四文字を入れるための配列
int flag = 0;//三文字以上の文字列を見つけた時のフラグ
int main() {
	scanf("%d", &n);
	for (int i = 0; i < 4; i++) {
		nums[i] = n % 10;
		
		n = (int)(n / 10.0);
	}
	/*for (int i = 0; i < 4; i++) {
		printf("%d ", nums[i]);
	}
	printf("\n");*/
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if(nums[i] == nums[j] ) {
				if (nums[j] == nums[j - 1] || j == 0 || j==1) {
					cnt++;
				}
			}
		}
		if (cnt >= 3) {
			flag = 1;
			break;
		}
		cnt = 0;
	}
	if (flag == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

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

int main(void) {
  int N, K, R, S, P;
  string T, A;
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;
  A = T;

  for(int i=0;i<T.size();i++) {
    if(T[i]=='r') { 
      A.erase(A.begin()+i); 
      A.insert(A.begin()+i, 'p');
    }
    else if(T[i]=='s') {
      A.erase(A.begin()+i); 
      A.insert(A.begin()+i, 'r');
    }
    else {
      A.erase(A.begin()+i); 
      A.insert(A.begin()+i, 's');
    }
  }

  int now;
  for(int i=0;i<K;i++) {
    now = i;
    while(now+K<T.size()) {
      if(A.at(now)==A.at(now+K)) {
        A.erase(A.begin()+now+K); 
        A.insert(A.begin()+now+K, 'l');
      }
      now += K;
    }
  }

  int ans=0;
  for(int i=0;i<T.size();i++) {
    if(T[i]=='r'&&A[i]=='p') ans += P;
    else if(T[i]=='s'&&A[i]=='r') ans += R;
    else if(T[i]=='p'&&A[i]=='s') ans += S;
    else ;
  }

  cout << ans << endl;
  for(int i=0;i<A.size();i++) {
    //cout << A.at(i);
  }

  return (0);
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    long long A,B,K;
    cin>>A>>B>>K;
    if(A<K && B>K-A)
    cout<<"0"<<" "<<B-(K-A);
    else if(A>=K)
    cout<<A-K<<" "<<B;
    else
    cout<<"0 0";
    return 0;
}

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

using namespace std;


vector<long long> readVec(int n) {
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    return a;
}

multiset<long long> takeBest(int need, int n) {
    auto a = readVec(n);
    multiset<long long> res;
    for (int i = 0; i < need; i++) {
        res.insert(a[i]);
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int needA, needB, nA, nB, nC;
    cin >> needA >> needB >> nA >> nB >> nC;
    auto a = takeBest(needA, nA);
    auto b = takeBest(needB, nB);
    auto c = readVec(nC);
    for (int v: c) {
        int imprA = v - *a.begin();
        int imprB = v - *b.begin();
        if (imprA >= imprB && imprA >= 0) {
            a.erase(a.begin());
            a.insert(v);
        }
        if (imprA < imprB && imprB >= 0) {
            b.erase(b.begin());
            b.insert(v);
        }
    }
    long long ans = 0;
    for (auto v: a) {
        ans += v;
    }
    for (auto v: b) {
        ans += v;
    }
    cout << ans << endl;
}



Measured memory_bytes: 9456
from collections import defaultdict

n, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = defaultdict(int)
dp[0] = 0

for w, v in wv:
    for k in sorted(dp.keys(), reverse=True):
        if k + w <= W:
            dp[k + w] = max(dp[k + w], dp[k] + v)

ans = max(dp.values())
print(ans)


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

#define fast                     ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll                       long long 
#define mk                       make_pair
#define pb                       push_back
#define pob                      pop_back
#define pii                      pair<int,int>
#define vi                       vector<int>
#define vii                      vector<pii>
#define mi                       map<int,int>
#define mii                      map<pii,int>
#define all(a)                   (a).begin(),(a).end()
#define x                        first
#define y                        second
#define sz(x)                    (int)x.size()
#define endl                     '\n'
#define MOD                      1000000007
#define loop(i,a,b)              for(int (i)=(a);(i)<(b);(i)++)
#define rloop(i,a,b)             for(int (i)=(a);(i)>=(b);(i)--)
#define Unique(A)                (A).resize(distance((A).begin(),unique(all((A)))));
#define mxe(A)                   *max_element(all(A))
#define mne(A)                   *min_element(all(A))
#define debv(x)                  for(auto i : (x)) cout << i << ' ';cout << endl;
#define SP(x,y)                  cout << fixed << setprecision((y)) << (x) << endl;
#define setBits(x)               __builtin_popcountll(x)
#define zroBits(x)               __builtin_ctzll(x)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define Max(x,y,z)               max(x,max(y,z))
#define Min(x,y,z)               min(x,min(y,z))
#define clr(x)                   memset(x,0,sizeof(x)) // not sure work for 2D arrya or not

template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

using namespace std;

string lcs(string a, string b){
    int n = sz(a) , m = sz(b);
    vector<vi> dp(n+1,vi(m+1,0));
    loop(i,1,n+1){
        loop(j,1,m+1){
            dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            if(a[i-1]==b[j-1]) dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1);
        }
    }
    int len = dp[n][m];
    string ans = string(len,'0');
    while(n>0 && m>0){
        if(a[n-1]==b[m-1]){
            ans[len-1] = a[n-1];
            n--;m--;len--; 
        }else if(dp[n][m-1]>dp[n-1][m]) m--;
        else n--;
    }
    return ans;
}

string a , b ;

int main(){
    cin >> a >> b ;
    cout << lcs(a,b) << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <stdio.h>
#include <stdlib.h>


int main(){

    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    int turn = 0;
    while((a>0)&&(c>0)){
        if(turn % 2 ==0){
            c -= b;
        }else{
            a -= d;
        }
        turn += 1;
    }
    if(a <= 0){
        printf("No");
    }else{
        printf("Yes");
    }

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define lf long double

//-------------------------------------------------

int main(void)
{
    ll A; scanf("%lld", &A);
    ll x,y; scanf("%lld.%lld", &x, &y);
    ll B = x*100+y;
    cout<<A*B/100<<"\n";
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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 ll INF = 1LL << 60;

int main(void){
  int n;
  ll k;
  cin >> n >> k;
  vl array(100100, 0);
  rep(i, n){
    int a,b;
    cin >> a >> b;
    array[a-1] += b;
  }

  ll cnt = 0;
  rep(i, 100100){
    if(array[i]){
      cnt += array[i];
      if(cnt>=k){
        cout << i+1 << endl;
        break;
      }      
    }
  }
  return 0;
}

Measured memory_bytes: 3976
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > b) System.out.println("a > b");
        else if (a < b) System.out.println("a < b");
        else System.out.println("a == b");
    }
}


Measured memory_bytes: 26128
def convert(t:int,k:int) -> str:
    ans = []
    if t == 0:
        return ans
    while(t >= k):
        ans.append(str(t%k))
        t = t//k
    ans.append(str(t))
    return "".join(ans[::-1])

n,k = map(int,input().split())
s = convert(n,k)
print(len(s))


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int i,j,A[100],minj;
  int N,a,count=0,num=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  for(i=0;i<=N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj])/*今比べてるやつが最小値より小さいか判別する*/
	minj=j;
    }
    if(A[i]==A[minj])num++;
    a=A[i];
    A[i]=A[minj];
    A[minj]=a;
    count++;
  }
  for(i=0;i<N-1;i++)printf("%d ",A[i]);
  printf("%d\n",A[N-1]);
  printf("%d\n",count-num);
  return 0;
}


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

int main(){
    long long a;
    cin>>a;
    long long ans=0;
    long long i=100;
    for(long long j=0;j<1000000;j++){
        i=i+i/100;
        ans++;
        if(i>=a)break;
    }
    cout<<ans;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#define int long long
using namespace std;
int n,ans;
string a;
signed main(){
    for(;;){
        cin>>n;
        if(n==0)break;
        ans=0;
        int dice[6]={1,2,3,4,5,6};
        for(int i=0;i<n;i++){
            cin>>a;
            if(a[0]=='N'){
                swap(dice[0],dice[1]);
                swap(dice[1],dice[5]);
                swap(dice[5],dice[4]);
                ans+=dice[0];
            }
            else if(a[0]=='E'){
                swap(dice[0],dice[3]);
                swap(dice[3],dice[2]);
                swap(dice[3],dice[5]);
                ans+=dice[0];
            }
            else if(a[0]=='S'){
                swap(dice[0],dice[1]);
                swap(dice[0],dice[5]);
                swap(dice[0],dice[4]);
                ans+=dice[0];
            }
            else if(a[0]=='W'){
                swap(dice[0],dice[2]);
                swap(dice[2],dice[5]);
                swap(dice[5],dice[3]);
                ans+=dice[0];
            }
            else if(a[0]=='R'){
                swap(dice[1],dice[2]);
                swap(dice[2],dice[4]);
                swap(dice[4],dice[3]);
                ans+=dice[0];
            }
            else if(a[0]=='L'){
                swap(dice[1],dice[2]);
                swap(dice[1],dice[3]);
                swap(dice[3],dice[4]);
                ans+=dice[0];
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1196
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()

    return (n+1)//2 / n


print(main())





Measured memory_bytes: 6220
import java.io.*;
import java.util.StringTokenizer;

class Counter {
	int count[] = new int[100];

	Counter() {
		for (int i=0;i<100;i++)
			this.count[i] = 0;
	}

	void add(int n) {
		this.count[n-1]++;
	}

	void printModeValue() {
		int max = 0;
		for (int i=0;i<100;i++)
			if (this.count[i]>max) max = this.count[i];
		for (int i=0;i<100;i++)
			if (max==this.count[i]) System.out.println(i+1);
	}
}

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			Counter c = new Counter();
			while ((buf = br.readLine())!=null) {
				c.add(Integer.parseInt(buf));
			}
			c.printModeValue();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16876
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int a,b;
    cin >> a >> b;
    if(b<a) cout << a-1 << endl;
    else cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 20
#define M 20

int di[] = { -1, 0, 1, 0 };
int dj[] = { 0, 1, 0, -1 };

char cc[N][M + 1];
int n, m;

int bfs(int is, int js) {
	static int dd[N][M], qu[N * M];
	int i, j, d, head, cnt;

	head = cnt = 0;
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			dd[i][j] = n * m + 1;
	dd[is][js] = 0;
	qu[head + cnt++] = is * m + js;
	d = 0;
	while (cnt > 0) {
		int ij, h;

		ij = qu[cnt--, head++];
		i = ij / m, j = ij % m;
		d = dd[i][j];
		for (h = 0; h < 4; h++) {
			int i_ = i + di[h];
			int j_ = j + dj[h];

			if (i_ >= 0 && i_ < n && j_ >= 0 && j_ < m && cc[i_][j_] == '.' && dd[i_][j_] > d + 1) {
				dd[i_][j_] = d + 1;
				qu[head + cnt++] = i_ * m + j_;
			}
		}
	}
	return d;
}

int main() {
	int i, is, js, ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", cc[i]);
	ans = 0;
	for (is = 0; is < n; is++)
		for (js = 0; js < m; js++)
			if (cc[is][js] == '.') {
				int x = bfs(is, js);

				if (ans < x)
					ans = x;
			}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
<?php
	
$xy = explode(' ',trim(fgets(STDIN)));
$yd = $xy[3] - $xy[1];
$xd = $xy[2] - $xy[0];

$y = ['U','D'];
$x = ['R','L'];

$mid = [];
for($h=0; $h<2; $h++){
  $m = [];
  for($i=0; $i<$yd; $i++){
    array_push($m, $y[$h]);
    echo $y[$h];    
  }
  for($j=0; $j<$xd; $j++){
    array_push($m, $x[$h]);
    echo $x[$h];
  }
  $mid[$h] = $m;
}

$ry = array_reverse($y);
$rx = array_reverse($x);
for($i=0; $i<2; $i++){
  echo $rx[$i].$y[$i];
  for($j=0; $j<count($mid[$i]); $j++){
    echo $mid[$i][$j];
  }
  echo $x[$i].$ry[$i];
}

?>

Measured memory_bytes: 4604
#include <stdio.h>

const int MAX_K = 100000;
const int MAX_N = 100;

int a[MAX_N];
bool isWinner[1 + MAX_K];

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i <= k; i++) {
    isWinner[i] = false;
    for (int j = 0; j < n && i - a[j] >= 0; j++)
      isWinner[i] |= !isWinner[i - a[j]];
    //printf("%d ", isWinner[i]);
  }
  if (isWinner[k])
    printf("First\n");
  else
    printf("Second\n");
  return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin >>s;
    int a = 300000, z = -1;
    
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i]=='A') a=min(a,i);
        else if(s[i]=='Z') z = max(z,i);
    }
    cout << z-a+1<<endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
int main(){
    int n;std::cin>>n;
    std::vector<long long>a(n+2);
    for(int i=0;i<n;i++){
        std::cin>>a.at(1+i);
    }
    std::vector<int>ord(n);
    std::iota(ord.begin(),ord.end(),1);
    std::sort(ord.begin(),ord.end(),[&a](int x,int y){return a.at(x)>a.at(y);});

    std::multiset<int>set;
    set.insert(-1);
    set.insert(0);
    set.insert(n+1);
    set.insert(n+2);
    long long ans=0;
    for(int i:ord){
        set.insert(i);
        int l0,l1,r0,r1;
        l1=*std::prev(set.upper_bound(i-1));
        l0=std::max(0,*std::prev(set.upper_bound(l1-1)));
        r0=*set.lower_bound(i+1);
        r1=std::min(n+1,*set.lower_bound(r0+1));
        ans+=a.at(i)*((l1-l0)*(r0-i)+(i-l1)*(r1-r0));
    }
    std::cout<<ans<<std::endl;
}



Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;


template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}
 
template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}


//vector<pair<int,int>> pairs;  pairs[i] = make_pair(value, value);
//sort(a.begin(),a+index_number);

//cin>>  cout<<'\n'

/*
vector<int> vec(100,-1);全ての値に-1をセット
vector<std::vector<int>> vec{{ 1, 2, 3 },{ 4, 5, 6 }};
vec.size() vec[i].size()
vec.emplace_back(20);追加
*/

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

    int ans = 0;

    int n,l;
    string s;
    cin >> n ;
    cin >> l;
    //cin >> s;

    int min = abs(1+l-1);

    rep(i,n){
        if(abs(i+l)<abs(min)){
            min = i+l;
        }
        ans += i+l;

    }

    ans -= min;

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    h[n] = 0;
    lint ans = 0;
    //各t:高さについて連結成分の個数を調べる
    for (int i = 1; i <= 100; i++) {
        for (int j = 0; j < n; j++) {
            if (h[j] >= i && h[j + 1] < i) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);

		while(scan.hasNext()) {
	        //??\???1
	        String num1 = scan.next();
		 	long int1 = Long.parseLong(num1);
		 	//??\???2
		    String num2 = scan.next();
		    long int2 = Long.parseLong(num2);

		      /*??? ?????????????????????????????? ???
		   ????????¢?????´???????????????2???????????¶??°???????±???¨??????????????§?????????????????? a, b ??¨?????????( a >= b > 0 )???
		   (1) a ??? b ??§???????????????????????? r ?????\????????????
		   (2) r ??? 0 ?????? b ????????§??¬?´???°??§?????????????????????????????????
		   (3) ????????§????????¨????????°a = b?????°b = r ??¨?????? (1) ???????????????????????????
		     */
		    long a;
		    long b;
		    long r;
		    long lcm;
		    //a?????????
		    if(int1 > int2){
		    	a = int1;
		    	b = int2;
		    }else{
		    	b = int1;
		    	a = int2;
		    }
		    while(true){
		    	r = a%b;
		    	if(r==0){
		    		break;
		    	}
		    	a = b;
		    	b = r;
		    }

		    //LCM = A*B???GCD
		    lcm = int1 * int2 / b;
		    System.out.println(b+ " " + lcm);
	       }

		    scan.close();

	}
}

Measured memory_bytes: 26096
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
module Main (main) where
import Control.Applicative
import Control.Monad
import qualified Data.ByteString as BS
import Data.ByteString.Char8 (readInt)
import qualified Data.IntSet as IS
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  n <- readLn
  as <- VU.replicateM n $ fst . fromJust . readInt <$> BS.getLine
  print $ solve as

solve :: VU.Vector Int -> Int
solve as = IS.size $ VU.foldl' f IS.empty as
  where
    f s e = case IS.lookupGE e s of
      Just ix | e < ix     -> IS.insert e $ IS.delete ix s
              | otherwise -> s
      Nothing -> IS.insert e s

Measured memory_bytes: 11284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b, result;
  double x;
  cin >> a >> b;
  x = (a + b) / 2.0;
  if ((x - int(x) ) * 10 > 4) {
    result = int(x) + 1;
  } else {
    result = int(x);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define vi         vector<int>
#define fr         first
#define se         second
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M  = 1e9+7 ;
const ll inf = 1e18 ;
const int si = 1e5+9;
const int N = 1e5+5 ;
//////////////////////    Hi    ^_^  hack me if you can :P



set<int> st;



int main()
{

    int x;
    
    cin>>x;
    st.insert(x);    cin>>x;
    st.insert(x);    cin>>x;
    st.insert(x);
    cout<<(sz(st));
    r0;
}

/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}
Wj0944296025*
*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy){
    if(!m) {d=n; xx=1; yy=0;}
    else {gcd(m,n%m,d,yy,xx); yy-=xx*(n/m);}
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

*/


Measured memory_bytes: 256
n = int(input().strip())
a = bytearray(input().strip(), encoding='ascii')
h, t = 0, len(a) - 1

ans = 0
while h < t:
    while a[h] == ord('R') and h < t:
        h += 1
    while a[t] == ord('W') and h < t:
        t -= 1
    if h >= t:
        break
    if a[h] == ord('W') and a[t] == ord('R'):
        a[h] = ord('R')
        a[h] = ord('W')
        h += 1
        t -= 1
        ans += 1
    elif a[h] == ord('W') and a[t] == ord('W'):
        a[h] = ord('R')
        h += 1
        ans += 1
    elif a[h] == ord('R') and a[t] == ord('R'):
        t -= 1
        ans += 1
    else:
        assert False

print(ans)

Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int l1=s1.length(),l2=s2.length();
	if(l1!=l2) {cout<<"No";return 0;}
	for(int i=0;i<l1;i++)
	{
		for(int j=0;j<l1;j++)
		{
			if(s1[(i+j)%l1]!=s2[j]) break;
			if(j==l1-1) {cout<<"Yes";return 0;}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int h, w;cin>>h>>w;
  vector<vector<char>> field(h, vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>field[i][j];
    }
  }
  for(int i=0;i<w+2;i++)cout<<'#';
  cout << endl;
  for(int i=0;i<h;i++){
    cout << '#';
    for(int j=0;j<w;j++){
      cout << field[i][j];
    }
    cout << '#' << endl;
  }
  for(int i=0;i<w+2;i++)cout<<'#';
  cout << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,w;
	cin>>n>>w;
	ll wt[n],val[n],dp[n+1][w+1];
	for(ll i=0;i<n;i++)cin>>wt[i]>>val[i];
	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=w;j++){
			if(!i || !j)dp[i][j]=0;
			else if(wt[i-1]<=j)dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	return 0;
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[120][10200] = {};
int main() {
	string S;
	cin >> S;
	sort(S.begin(), S.end());
	char k = '!';
	for (int i = 0; i < S.size(); i++) {
		if (k == S[i]) {
			cout << "no";
			return 0;
		}
		k = S[i];
	}
	cout << "yes";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class ListofTop3Hills
    {
        static void Main(string[] args)
        {
            List<int> param = new List<int>();
            for(int i=0; i<10 ; i++)
            {
                param.Add(int.Parse(System.Console.ReadLine()));
            }
            param.Sort();
            for(int j =9 ; j > 6 ; j--)
            {
                System.Console.WriteLine(param[j]);
            }
            System.Console.ReadLine();
        }
    }
}

Measured memory_bytes: 20092
#include "algorithm"
#include "cmath"
#include "iostream"
#include "map"
#include "string"
#include "unordered_map"
#include "vector"
constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9;
using namespace std; // std::を省略して書くことができる

int main() {
  string O, E, ans;
  cin >> O >> E;
  int o_ = 0;
  int e_ = 0;
  ans = "";
  for (int i = 0; i < INF; i++) {
    if (o_ != 1) {
      ans += O[i];
      if (i == O.size() - 1) {
        o_ = 1;
      }
    }
    if (e_ != 1) {
      ans += E[i];
      if (i == E.size() - 1) {
        e_ = 1;
      }
    }
    if (o_ == 1 && e_ == 1) {
      break;
    }
  }
  cout << ans << endl;
}

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

int main() {
	double x;
	while (cin >> x) {
		double v = 0, t, y;
		for (int i = 1;; i++) {
			y = 5 * i - 5;
			t = sqrt(y / 4.9);
			v = 9.8*t;
			if (v >= x) {
				cout << i << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3160
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    int i,c=0;
    cin>>s;
    cin>>t;
    for(i=0;i<s.size();++i){
    	if(s[i]!=t[i]){
    		c++;
		}
	}
	cout<<c;
}

Measured memory_bytes: 3868
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"
vector<pair<ll, int>> factorize(ll x) {
  ll tmp = x;
  vector<pair<ll, int>> ret;
  for (ll i = 2ll; i * i <= x; i++) {
    int cnt = 0;
    while (tmp % i == 0ll) {
      tmp /= i;
      cnt++;
    }
    if (cnt > 0) ret.push_back(pair<ll, int>(i, cnt));
  }
  if (tmp != 1ll) ret.push_back(pair<ll, int>(tmp, 1));
  return ret;
}

void solve() {
  ll N;
  cin >> N;
  auto fac = factorize(N);
  // dmp(fac);
  int ans = 0;
  for (auto p : fac) {
    int mx = 0;
    for (int i = 1; i < 1000; i++) {
      if (i * (i + 1) / 2 <= p.second) mx = i;
    }
    ans += mx;
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <utility>
using namespace std;

using i64 = long long;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getc() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

i64 D[2][13];
const i64 M = 1000000007;
signed main() {
	D[0][0] = 1;
	int p = 0;
	while(true) {
		char c = getc();
		if (c == '\n') {
			break;
		} else if (c == '?') {
			REP(r, 13) {
				i64 s = 0;
				REP(j, 10) {
					s += D[p][(j - r + 13) * 9 % 13];
				}
				D[p ^ 1][r] = s % M;
			}
		} else {
			i64 d = c - '0';
			REP(r, 13) {
				D[p ^ 1][r] = D[p][(d - r + 13) * 9 % 13];
			}
		}
		p ^= 1;
	}
	printf("%d", D[p][5]);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 5)
    {
        cout << 0 << endl;
    }
    else if (a >= 6 && a <= 12)
    {
        cout << b / 2 << endl;
    }
    else
    {
        cout << b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define inp(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define fr(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int T=1;
    while (T--) {
        ll a,v,b,w,t;
        cin>>a>>v;
        cin>>b>>w;
        cin>>t;
        ll dis=abs(b-a);
        ll sp=(v-w);
        if(sp==0 && dis==0) cout<<"YES\n";
        else if(sp==0 && dis!=0) cout<<"NO\n";
        else{
            if(sp*t>=dis) cout<<"YES\n";
            else cout<<"NO\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<queue>
using namespace std;
int dy1[6] = { 0,1,1,1,0,-1 }, dx1[6] = { -1,-1,0,1,1,0 };
int dy2[6] = { -1,0,1,0,-1,-1 }, dx2[6] = { -1,-1,0,1,1,0 };
int x[110][110], H, W, used[110][110], cnt;
int main() {
	cin >> W >> H; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++)cin >> x[i][j]; }
	queue<pair<int, int>>Q; Q.push(make_pair(0, 0)); used[0][0] = 1;
	while (!Q.empty()) {
		int a1 = Q.front().first, a2 = Q.front().second; Q.pop();
		for (int i = 0; i < 6; i++) {
			int p1, p2;
			if (a1 % 2 == 1) { p1 = a1 + dx1[i], p2 = a2 + dy1[i]; }
			if (a1 % 2 == 0) { p1 = a1 + dx2[i], p2 = a2 + dy2[i]; }
			if (p1<0 || p2<0 || p1>H + 1 || p2>W + 1)continue;
			if (used[p1][p2] == 1 || x[p1][p2] == 1)continue;
			used[p1][p2] = 1; Q.push(make_pair(p1, p2));
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			for (int k = 0; k < 6; k++) {
				int p1, p2;
				if (i % 2 == 1) { p1 = i + dx1[k], p2 = j + dy1[k]; }
				if (i % 2 == 0) { p1 = i + dx2[k], p2 = j + dy2[k]; }
				if (x[i][j] == 1 && x[p1][p2] == 0 && used[p1][p2] == 1) { cnt++; }
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 200010; // CAMBIAR ESTE

// GJNM
int A[maxN];

int main(){
	int n;
	ri(n);
	FOR(i,0,n)
		ri(A[i]);
	
	int tot_xor = 0;
	FOR(i,0,n)
		tot_xor ^= A[i];

	FOR(i,0,n)
		printf("%d ",tot_xor^A[i] );
	printf("\n");
	return 0;
}

Measured memory_bytes: 4412
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int Q;

signed main(){
    set<int> s;
    scanf("%d", &Q);
    s.insert(INF);
    for(int i = 0; i < Q; i++){
        int q;
        cin >> q;
        if(q < 3){
            int x;
            scanf("%d", &x);
            if(q == 0){
                s.insert(x);
                printf("%d\n", (int)s.size() - 1);
            }
            else if(q == 1)printf("%d\n", s.count(x));
            else {
                if(s.count(x))s.erase(x);
            }
        }
        else {
            int L, R;
            scanf("%d%d", &L, &R);
            auto lb = s.lower_bound(L);
            auto ub = s.upper_bound(R);
            for(auto j = lb; j != ub; j++){
                printf("%d\n", *j);
            }
        }
    }


    return 0;
}

/*

*/


Measured memory_bytes: 12500
n = int(input())
a, b = [], []
for _ in range(n):
    tmp = list(map(int, input().split()))
    a.append(tmp[0])
    b.append(tmp[1])

a.sort()
b.sort()

if n%2:
    print(b[(n+1)//2-1]-a[(n+1)//2-1]+1)
else:
    print(b[n//2-1]+b[n//2]-a[n//2-1]-a[n//2]+1)

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



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


    int n=s.size();

    int x=(n-1)/2;


    string s2=string(s.rbegin(),s.rend());


    string s3(s.begin(),s.begin()+x);
    string s4(s.begin() + (n+3)/2 -1,s.end());

    string s5=string(s3.rbegin(),s3.rend());
    string s6=string(s4.rbegin(),s4.rend());

    int tmp1=0,tmp2=0,tmp3=0;
    if(s3==s5){
        tmp1=1;
    }
    if(s4==s6){
        tmp2=1;
    }
    if(s==s2){
        tmp3=1;
    }

    if(tmp1==1 && tmp2==1 && tmp3==1){
        cout<<"Yes"<<endl;
    }else{
    cout<<"No"<<endl;
    }


    //cout<<s3<<endl;
    //cout<<s4<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef pair<string,int> SP;

int main(){
  int N, x;
  cin >> N;
  int count = 0;
  REP(i,N){
    cin >> x;
    if(x != i+1) count++;
  }
  if(count <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;

}

Measured memory_bytes: 256
N=int(raw_input())
M=[999999 for i in range(N+1)]
possible=sorted([1]+[6**i for i in range(1,100) if 6**i<=N]+[9**i for i in range(1,100) if 9**i<=N])
M[0]=0
for p in possible:
    M[p]=1

for m in range(N+1):
    tmp=999999
    for p in possible:
        if m-p>0:
            tmp=min(tmp, M[m-p]+1)

    M[m]=min(tmp,M[m])

print M[N]


Measured memory_bytes: 6636