akhauriyash/Code-Regression huggingface dataset:
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end

  def push(x)
    i = @node_num # 自分のノード番号
    @node_num += 1
    while i > 0
      par = (i - 1) / 2 # 親のノード番号
      break if @comp.call(@heap[par], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while i * 2 + 1 < @node_num
      # 子どうしを比較
      a, b = i * 2 + 1, i * 2 + 2
      a = b if b < @node_num && !@comp.call(@heap[a], @heap[b])
      break if @comp.call(x, @heap[a])
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    return get.nil?
  end

  def sum
    @heap.inject(:+)
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort.reverse
q = PriorityQueue.new(){ |x, y| x > y }
a.each do |ai|
    q << ai
end
m.times do
    max_n = q.pop()
    q << (max_n / 2)
end
p q.sum


Measured memory_bytes: 11008
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 


int main(){
    LL N;
    cin>>N;
    LL res1=1;
    for(LL i=1;i*i<=N;i++){
        if(N%i==0)res1=i;
    }
    LL res2=N/res1;
    cout<<SZ(toString(res2))<<endl;
    return 0;
}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

int n, ans;
string s;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> s;
    n = (int) s.size();
    s = ' ' + s;
    int cnt = 0;
    cont (i, n) {
        if (s[i] == 'S') {
            ++cnt;
        } else if (s[i] == 'T') {
            if (cnt) {
                ++ans;
                --cnt;
            }
        }
    }
    cout << n - 2 * ans << ln;
}

Measured memory_bytes: 788
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

ll N, M;
ll x, y;
ll red[100005], num[100005];
int main() {

	cin >> N >> M;

	rep(i, N) {
		num[i + 1] = 1;

	}

	red[1] = 1;
	rep(i, M) {
		cin >> x >> y;

		if (red[x] == 1) {
			red[y] = 1;
			if (num[x] == 1) {
				red[x] = 0;
			}
		}
		
		num[x] -= 1;
		num[y] += 1;


	}
	ll ans = 0;
	rep(i, N) {
		
		ans += red[i+1];
	}

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

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <map>

#define INF 100000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using P = pair<int, int>;

const int MAX = 1000000;
const int MOD = 1000000007;

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

//テーブルの前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        //そのまま計算すると負の値になるのでMODを足す
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

//二分累乗法
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


//UnionFind木
struct UnionFind{
   vector<long long int> par; //par[i] : iの親の番号
   vector<long long int> rnk; //root[i] : iの木のサイズ

   //コンストラクタ
   UnionFind(long long int n): par(n), rnk(n){
       //木の初期化
       for(long long int i = 0; i < n; i++){
           par[i] = i;
           rnk[i] = 1;
       }
   }

   //データxが属する木の根を再帰で取得
   long long int root(long long int x){
       if(par[x] == x){
           return x;
       }else{
           return par[x] = root(par[x]);
       }
   }

   //xとyが同じ木に属しているかを判定
   bool same(long long int x, long long int y){
       return root(x) == root(y);
   }

   //xとyの木を併合
   void unite(long long int x, long long int y){
       long long int rx = root(x); //xの根
       long long int ry = root(y); //yの根
       if(rx == ry) return; //根が同じならそのまま

       //併合するときにサイズを足し合わせる
       if(rnk[rx] < rnk[ry]){
           par[rx] = ry;
           rnk[ry] += rnk[rx];
       }else{
           par[ry] = rx;
           rnk[rx] += rnk[ry];
       }
   }

   //属している木のサイズを取得
   long long int size(long long int x){
       return rnk[root(x)];
   }
};

typedef struct edge{
   int to;
   int cost;
} edge;

vector<edge> graph[2010];
long long int d[2010];

void dijkstra(int s){
   priority_queue<P, vector<P>, greater<P> > que;
   for(int i = 0; i < 2010; i++){
       d[i] = INF;
   }
   d[s] = 0;
   que.push(P(s, 0));

   while (!que.empty()) {
       P p = que.top();
       que.pop();
       int v = p.first;
       if (d[v] < p.second) continue;

       for (int i=0; i<graph[v].size(); ++i) {
           edge e = graph[v][i];
           if (d[e.to] > d[v] + e.cost) {
               d[e.to] = d[v] + e.cost;
               que.push(P(e.to, d[e.to]));
           }
       }
   }
}
*/

int main(){
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    int rev=0;
    for(int i=1;i<N;i++)if(S[i-1]!=S[i])rev++;
    cout << min(N-1,N-1-rev+K*2) << endl;
}


Measured memory_bytes: 512
N = int(input())
S = input()

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if S[i] == S[j]:
            if i != 0:
                if S[i-1] == S[j-1]:
                    continue
            equal = 1
            for k in range(1, min(j-i, N-j)):
                if S[i+k] == S[j+k]:
                    equal += 1
                else:
                    break
            ans = max(ans, equal)

print(ans)


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

using namespace std;

#define int long long

char s1, s2, s3;

int a, b, c, d;

bool fin = false; 

void func(int deep, int sum)
{
    if (fin){return;}

    if (deep == 4)
    {
        if (sum == 7)
        {
            fin = true;
            return;
        }

        return;
    }

    if (deep == 1)
    {
        s1 = '+';
        func(deep + 1, sum + b);
        if (fin) { return; }

        s1 = '-';
        func(deep + 1, sum - b);
        if (fin) { return; }
    }

    if (deep == 2)
    {
        s2 = '+';
        func(deep + 1, sum + c);
        if (fin) { return; }

        s2 = '-';
        func(deep + 1, sum - c);
        if (fin) { return; }
    }


    if (deep == 3)
    {
        s3 = '+';
        func(deep + 1, sum + d);
        if (fin) { return; }

        s3 = '-';
        func(deep + 1, sum - d);
        if (fin) { return; }
    }

}

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

    string str;

    cin >> str;

    a = str[0] - '0';
    b = str[1] - '0';
    c = str[2] - '0';
    d = str[3] - '0';

    func(1, a);

    cout << a << s1 << b << s2 << c << s3 << d << "=" << 7 << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
public class Main {
	
	public static int sum = 0;
	
	public static int calc (int target) {
		
		for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
		for (int k = 0; k < 10; k++)
		for (int l = 0; l < 10; l++) {
			if (i + j + k + l == target) sum++;
		}
		return sum;
	}
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		while (true) {
			
			String s = br.readLine();
			if (s == null) break;
			int n = Integer.parseInt(s);
			ans.add(calc(n));
			sum = 0;
			
		}
		
		for (int a : ans) {
			System.out.println(a);
		}
		
	}

}

Measured memory_bytes: 9500
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A=sc.nextInt();
      int B=sc.nextInt();
      int C=sc.nextInt();
      int cnt=0;
      if(A==B){
         cnt++;
      }
      if(A==C){
         cnt++;
      }
      if(B==C){
         cnt++;
      }
      if(cnt==1){
         System.out.print("Yes");
      }else{
         System.out.print("No");
      }
   }
}


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

int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    int p;
    for (int i = 1; i <= n; i++){
        if (i >= k) ans += (double)1 / n;
        else {
            p = 0;
            while (i * pow(2, p) < k) p++;
            ans += (double)1 / pow(2, p) / n;
        }
    }
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]
if nn == 3
  puts 61
  exit
end

# body
if $debugFlag
end

def isOK3(str)
  return (str != 'AGC' and str != 'ACG' and str != 'GAC')
end

def isOK4(str)
  cond = true
  3.times do |i|
    tmp = str.clone
    tmp[i], tmp[i+1] = tmp[i+1], tmp[i]
    cond = false if (tmp[0..2] == 'AGC' or tmp[1..3] == 'AGC')
  end
  cond = false if (str[0..2] == 'AGC' or str[1..3] == 'AGC')  

  return cond
end

last3 = {}
cand = ['A', 'C', 'T', 'G']
cand.each do |i|
  cand.each do |j|
    cand.each do |k|
      if isOK3 (i + j + k)
        if last3[i+j+k] != nil
          last3[i+j+k] += 1
        else
          last3[i+j+k] = 1
        end
      end
    end
  end
end

pd last3
if $debugFlag
  cnt = 0
  last3.each do |k,v|
    cnt += v
  end
  p cnt
end

for i in 4..nn do
  i = i
  prev_last3 = last3.clone
  last3 = {}
  cand.each do |c|
    prev_last3.each do |k, v|
      if isOK4(k + c)
        #pd k+c
        if last3[k[1..2] + c] != nil
          last3[k[1..2] + c] += v
        else
          last3[k[1..2] + c] = v
        end
      else
        #puts k + c
      end
    end
  end
  ans = last3.clone
end

cnt = 0
ans.each do |k,v|
  cnt += v
end

puts cnt%(10**9+7)




Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, 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 ll INF = 1LL << 60;
const int MAX_ITEM = 10e5+10;
ll dp[MAX_ITEM] = {0};

int main() {
  int n,k;
  cin >> n >> k;
  int h[n];
  rep(i,n) cin >> h[i];

  // 最小化問題なので INF or 0 で埋める
  rep(i,MAX_ITEM) {
    dp[i] = INF;
  }
   
  // 初期値は 0 or INF
  dp[0] = 0;

  // 足場だけ回す
  rep(i,n) {
    // 足場i+j の値は 足場iのコストに abs(h[i] - h[i+j]) を足した数
    rep(j,k+1) {
      if (j == 0) continue;
      chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
    }
  }
  
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 8448
#include <stdio.h>
int count=0;
void sw(int *a,int *b){
  int t;
  t = *a;
  *a = *b;
  *b = t;
}

void B_sort(int array[],int s){
  int a,b;
  for(a=0;a<s-1;a++){
    for(b=s-1;b>=a+1;b--){
      if(array[b]<array[b-1]){
          sw(&array[b],&array[b-1]);
          count++;
        }
    }
  }
}
int main(){
  int s;
  int a[10000];
  int i;
  scanf("%d",&s);
  for(i=0;i<s;i++){
    scanf("%d",&a[i]);
  }
  B_sort(a,s);

  for(i=0;i<s-1;i++){
    printf("%d",a[i]);
    printf(" ");
  }
  printf("%d",a[s-1]);
  printf("\n");
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;

    bool a=true;
    int g;
    set<int> memo;
    cin>>g;
    int copy_g=g;
    for(int i=2;i*i<=g;i++){
        if(g%i==0){
            memo.insert(i);
            while(g%i==0)g/=i;
        }
    }
    memo.insert(g);
    g=copy_g;
    rep(i,n-1){
        int in;
        cin>>in;
        g=gcd(g,in);
        for(int j=2;j*j<=in;j++){
            if(in%j==0) {
                if (memo.count(j)) a = false;
                memo.insert(j);
                while(in%j==0)in/=j;
            }
        }
        if(in!=1){
            if (memo.count(in)) a = false;
            memo.insert(in);

        }
    }
    if(a)cout<<"pairwise coprime"<<endl;
    else if(g==1)cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}


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

using namespace std;

struct Stack {
    int pos = -1;
    vector<int> data;
};

void push(Stack &t, int x) {
    if (t.pos == t.data.size() - 1) {
        t.data.push_back(x);
        t.pos++;
    } else
        t.data[++t.pos] = x;
}

void top(Stack &t) {
    if (t.pos > -1)
        cout << t.data[t.pos] << endl;
}

void pop(Stack &t) {
    if (t.pos > -1)
        t.pos--;
}

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

    Stack S[n];

    while (Q--) {
        int q, t;
        cin >> q >> t;
        switch (q) {
            case 0:
                int x;
                cin >> x;
                push(S[t], x);
                break;
            case 1:
                top(S[t]);
                break;
            case 2:
                pop(S[t]);
                break;
        }
    }
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i = (a);i <= (b);++i)
#define LOCAL
typedef long long ll;
const int maxn = 105;
int num[maxn],k;
string a;
ll dp[maxn][4];
ll dfs(int pos,int now,bool limit){
    if(pos==-1)return now==k;
    if(!limit&&dp[pos][now]!=-1)return dp[pos][now];
    int up = limit?num[pos]:9;
    ll ans = 0;
    for(int i = 0;i <= up;++i)
    {
        if(i==0)
        {
            ans+=dfs(pos-1,now,limit&&i==up);
        }
        else if(now<k){
            ans+=dfs(pos-1,now+1,limit&&i==up);
        }
    }
    if(!limit)dp[pos][now]=ans;
    return ans;
}
int main()
{
#ifdef LOCALa
    freopen("simple.in","r",stdin);
    freopen("simple.out","w",stdout);
#endif
    memset(dp,-1,sizeof(dp));
    cin>>a>>k;
    for(int i = 0;i < a.size();++i)
        num[i]=a[i]-'0';
    reverse(num,num+a.size());
    cout<<dfs(a.size()-1,0,1)<<endl;
    return 0;
}

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

int main()
{
  string S;long long K;cin>>S;scanf("%lld",&K);
  long long count1=0;int ans=1;
  for(int i=0;i<S.size();i++)
  {
    if(count1==K){break;}
    if(S[i]=='1'){count1++;continue;}
    ans=S[i]-'0';break;
  }
  cout<<ans;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

ll dp[100000];

int main(void){
  ll n;
  cin >> n;
  vector<ll> h(n);
  REP(i, n) cin >> h[i];
  REP(i, n) dp[i] = INF;
  dp[0] = 0;
  REP(i, n){
    if(i+1 < n) chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
    if(i+2 < n) chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 4800
#include <stdio.h>
int main()
{
	int n, b, f, r, v;
	
	scanf("%d\n",&n);
	
	int a[4][3][10] = { 0 };
	
	while(n--){
		scanf("%d %d %d %d",&b, &f, &r, &v);
		
		a[b-1][f-1][r-1]+=v;
	}
	
	for(b=0;b<4;b++){
		for(f=0;f<3;f++){
			for(r=0;r<10;r++){
			printf(" %d",a[b][f][r]);
			}
			printf("\n");
		}
		if(b<3)printf("####################\n");
	}
	return 0;
}


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

int main()
{
	int S, h, m, s;
	cin >> S;

	h = S/(60*60);
	m = (S-h*60*60)/60;
	s = S-h*60*60-m*60;

	cout << h << ":" << m << ":" << s << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int n; cin >> n;

    ll ans = 0;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int i = 1; i < n; ++i) {
        if (a[i] < a[i - 1]) {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 4372
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String S = sc.next();

		int A = S.charAt(0) - '0';
		int B = S.charAt(1) - '0';
		int C = S.charAt(2) - '0';
		int D = S.charAt(3) - '0';

		String op1;
		String op2;
		String op3;
		for (int i = 0; i < (1 << 3); i++) {
			int sum = A;
			if (((i >> 0) & 1) == 0) {
				op1 = "+";
				sum += B;
			} else {
				op1 = "-";
				sum -= B;
			}

			if (((i >> 1) & 1) == 0) {
				op2 = "+";
				sum += C;
			} else {
				op2 = "-";
				sum -= C;
			}

			if (((i >> 2) & 1) == 0) {
				op3 = "+";
				sum += D;
			} else {
				op3 = "-";
				sum -= D;
			}

			if (sum == 7) {
				System.out.println(A + op1 + B + op2 + C + op3 + D + "=7");
				break;
			}
		}

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint f(int n){ 
  if(n == 0)return 1;
  mint x = f(n / 2); 
  x *= x; 
  if(n % 2 == 1)x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i = 0; i < a; ++i){
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<ll> sum(n + 1, 0);
  for(int i = 1; i <= n; ++i){
  	sum[i] = sum[i - 1] + i;
  }

  vector<mint> cnt(n + 1, 0);
  mint ans = 0;
  for(int i = k; i <= n; ++i){
  	if(i == 1)ans += (mint)(n + 1);
  	// sum(0, i - 1) to sum(n - i + 1, n)
  	// cnt[i] += (mint)((sum[n] - sum[n - i]) - sum[i]);
  	// cout << "sum(0, i - 1) to sum(n - i + 1, n)" << sum[i - 2] << " " << sum[n] - sum[n - i] << endl;
  	else ans += (mint)((sum[n] - sum[n - i]) - sum[i - 1] + 1);
  }

  ans += 1;

  // mint ans = cnt[n] - cnt[k - 1];
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 6372
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);

	int n;
	scanf("%d", &n);
	vi a(n+1), b(n+1), c(n+1);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
	for (int i = 1; i < n; i++) scanf("%d", &c[i]);

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += b[a[i]];
		if (i > 1 && a[i] == a[i-1] + 1) ans += c[a[i-1]];
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll m = n;
    vector<ll> p;
    rep(i,2,sqrt(n)+1){
        if (m%i == 0){
            p.push_back(i);
            while(m%i == 0){
                m /= i;
            }
        }
    }
    if (m > 1) p.push_back(m);
    //array_output(all(p));
    ll s = p.size();
    ll ans = 0;
    rep(bit,(1<<s)){
        if (bit == 0) continue;
        ll c = 0,q = 1;
        rep(i,s){
            if (bit&(1<<i)){
                c++;
                q *= p[i];
            }
        }
        q = n/q;
        if (c%2){
            ans += q;
        }
        else{
            ans -= q;
        }
    }
    PRINT(n-ans);
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;

int a,b,k; 

int main(){
	cin>>k>>a>>b;
	bool f=false;
	for(int i=a;i<=b;i++) if(i%k==0) f=true;
	if(f) cout<<"OK";
	else cout<<"NG";
	return 0;
}


Measured memory_bytes: 3632
while 1:
        H,W = map(int ,input().split())
        if W == H == 0: break
        for i in range(H):
                for j in range(W):
                        if i <1 or i>=H -1  or j < 1 or j >= W - 1:
                                print('#',end ="")
                        else:
                                print('.',end ="")
                print('')
        print('')


Measured memory_bytes: 7016
#include<iostream>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
using namespace std;

int main(void){
    int n;
    vector <int> a;
    vector <int> b;

    cin>>n;

    rep(i, n){
        int tmp;
        cin>>tmp;
        a.push_back(tmp);
        b.push_back(tmp);
    }

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

    rep(i, n){
        int ans=a[n-1];
        if (a[n-1]==b[i]){
            ans=a[n-2];
        }
        cout<<ans<<endl;
    }


}



Measured memory_bytes: 3436
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,sum=0;
    cin>>n;
    for(long long int i=1;i<=n;i++)
    {
        if(i%3==0 && i%5==0)
        {
            continue;
        }
        else if(i%3==0)
        {
            continue;
        }
        else if(i%5==0)
        {
            continue;
        }
        else
        {
            sum+=i;
        }

    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

char s[20];
int main() {
	scanf("%s", s);
	int k, w = 0;
	for (k = 0; s[k]; k++)
		if (s[k] == 'o')
			w++;
	if (8 <= w + (15 - k))
		printf("YES\n");
	else
		printf("NO\n");
}

Measured memory_bytes: 128
#include<stdio.h>
main(){
  int i,ans;
  double l[10],km,k,v[2];
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1])!=EOF){
    km=l[0]+l[1]+l[2]+l[3]+l[4]+l[5]+l[6]+l[7]+l[8]+l[9];
    k=km*v[0]/(v[0]+v[1]);
    for(i=0;i>=0;i++){
      k-=l[i];
      if(k<=0){
	ans=i+1;
	i=-2;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, in;
	vector<ll> v;
	cin >> n;
	rep(i, n) {
		cin >> in;
		v.push_back(in);
		cin >> in;
		if (i == n - 1)v.push_back(in);
	}
	vector<vector<ll>> vv(n, vector<ll>(n));
	for (int i = 1; i < n; i++) {
		vv[i - 1][i] = v[i - 1] * v[i] * v[i + 1];
	}
	for (int i = 2; i < n; i++) {
		for (int j = 0; i+j < n; j++) {
			ll ans;
			for (int k = 0; k <= i - 1; k++) {
				if (k == 0) {
					ans = vv[j][j + k] + vv[j + k+1][j + i] + v[j] * v[j + k + 1] * v[i + j + 1];
				}
				else {
					ll tmp = vv[j][j + k] + vv[j + k+1][j + i] + v[j] * v[j + k + 1] * v[i + j + 1];
					if (ans > tmp)ans = tmp;
				}
			}
			vv[j][i + j] = ans;
		}
	}
	cout << vv[0][n - 1] << endl;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 510;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << x << '\n'

char c;
void run(){
    cin >> c;
    if(c <= 'Z') cout << 'A';
    else cout << 'a';
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    run();
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < ((int)b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= ((int)a); --i)
#define sz(c) ((int)c.size())
#define all(c) c.begin(),c.end()

using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

void dump_impl(string str) {}
template <class H, class... T>
void dump_impl(string s, const H &head, const T&... tail) {
    int par = 0;
    rep(i, 0, sz(s)) {
        char ch = s[i];
        if (ch == ',' && par == 0) {
            cerr << " = " << head << ", ";
            dump_impl(s.substr(i + 1), tail...);
            return;
        } else {
            cerr << ch;
            if (ch == '(') par++;
            if (ch == ')') par--;
        }
    }
}
#define dump(...) do { cerr << "\x1b[33;1m"; dump_impl(#__VA_ARGS__ ",", __VA_ARGS__); cerr << "\x1b[0m" << endl; } while (0)

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

signed main() {
    int T;
    cin >> T;
    while (T--) {
        string S;
        cin >> S;
        set<string> can;
        rep(i, 1, sz(S)) {
            string A = S.substr(0, i);
            string B = S.substr(i);

            can.insert(A + B);
            can.insert(B + A);
            
            reverse(all(A));
            can.insert(A + B);
            can.insert(B + A);
            reverse(all(A));

            reverse(all(B));
            can.insert(A + B);
            can.insert(B + A);

            reverse(all(A));
            can.insert(A + B);
            can.insert(B + A);
        }
        cout << sz(can) << endl;
    }
}



Measured memory_bytes: 3156
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
using ll = long long;
using namespace std;


int main() {
    int d, g, p[11], c[11];
    cin >> d >> g;
    for (int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
    }
    int ans = INF;
    for (int i = 0; i < (1 << d); i++) {
        int sum = 0, num = 0, tmax = -1;
        for (int j = 0; j < d; j++) {
            if (i >> j & 1) {
                sum += 100 * (j + 1)*p[j] + c[j];
                num += p[j];
            }
            else {
                tmax = j;
            }
        }
        if (sum < g) {
            int b = 100 * (tmax + 1);
            int need = (g - sum + b - 1) / b;
            if (need >= p[tmax])continue;
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N (100010)


int n, m;
vector<int>e[N];
bool used[N];
long long a[N];
vector<pair<long long,int> >q[N];
vector<pair<long long,int> >s;
int qs;
void init(void){
	memset(used, false, sizeof(used));
	return;
}

void dfs(int x,int y){
	used[x] = true;
	q[y].push_back(make_pair(a[x], x));
	f(i, e[x].size()){
		if (!used[e[x][i]]){
			dfs(e[x][i], y);
		}
	}
}


int main(void){
	int k;
	int x, y;
	long long ans;
	scanf("%d %d", &n, &m);
	init();
	f(i, n){
		scanf("%lld", &a[i]);
		s.push_back(make_pair(a[i], i));
	}
	sort(s.begin(), s.end());
	f(i, m){
		scanf("%d %d", &x, &y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	if (((m+1)*2)<n){
		printf("Impossible\n");
		return 0;
	}
	else if (m == (n - 1)){
		printf("0\n");
		return 0;
	}
	qs = 0;
	f(i, n){
		if (!used[i]){
			dfs(i, qs);
			qs++;
		}
	}
	init();
	ans = 0;
	f(i, qs){
		sort(q[i].begin(), q[i].end());
		ans += (q[i][0].first);
		used[q[i][0].second] = true;
	}
	k = 0;
	for(int i=0;i<(qs-2);){
		if (!used[s[k].second]){
			ans += (s[k].first);
			used[s[k].second] = true;
			i++;
		}
		k++;
	}

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


	return 0;
}

Measured memory_bytes: 13680
from collections import deque


n, q = map(int, input().split())
tree = [[] for _ in range(n + 1)]
score = [0 for _ in range(n + 1)]

dq = deque()
dq.append((1, 0))

for i in range(n - 1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    score[p] += x

while(dq):
    k = dq.popleft()
    score[k[0]] += score[k[1]]
    for i in tree[k[0]]:
        if not i == k[1]:
            dq.append((i, k[0]))

print(*score[1:])


Measured memory_bytes: 57980
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

a,b=MI()
if b==1:
    print(0)
    sys.exit()
for i in range(1,100):
    num=a+(a-1)*(i-1)
    if num>=b:
        print(i)
        sys.exit()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl
#define PII pair<int,int>
typedef long long ll;
const int maxn=4e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=1e9;
const double ep=1e-7;
using namespace std;
int main()
{
	int n,k,c,i,j,sum1[maxn]={0},sum2[maxn]={0},ma1[maxn]={0},ma2[maxn]={0};
	scanf("%d%d%d",&n,&k,&c);
	char s[maxn];
	scanf("%s",s+1);
	for(i=1;i<=n;i++)
	{
		if(s[i]=='x')sum1[i]=sum1[i-1];
		else
		{
			if(i>c+1)sum1[i]=sum1[i-c-1]+1;
			else sum1[i]=1;
		}
		ma1[i]=max(sum1[i],ma1[i-1]);
	}
	for(i=n;i>=1;i--)
	{
		if(s[i]=='x')sum2[i]=sum2[i+1];
		else
		{
			if(i>=n-c)sum2[i]=1;
			else sum2[i]=sum2[i+c+1]+1;
		}
		ma2[i]=max(sum2[i],ma2[i+1]);
	}
	int vis[maxn]={0},ans=0,l=0;
	for(i=1;i<=n;i++)
	{
		if(s[i]=='o')
		{
			if(ma2[i+1]>=k||ma1[i-1]>=k)vis[i]=1;
			if(i>=c+1&&ma1[i-c-1]+ma2[i+c+1]>=k)vis[i]=1;
		}
	}
	queue<int>q;
	for(i=1;i<=n;i++)
	{
		if(s[i]=='o'&&!vis[i])q.push(i);
		if(ma1[i]+ma2[i+c+1]>=k)
		{
			for(j=max(l,i+1);j<=i+c;j++)
			{
				if(s[j]=='o'&&!vis[j])vis[j]=1;
			}
			l=i+c;
		}
	}
	while(!q.empty())printf("%d\n",q.front()),q.pop();
}

Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int res = Math.max(0, c - (a - b));
        System.out.println(res);
    }
}


Measured memory_bytes: 20692
#解説解答
s = input()
k = int(input())
can = []
for l in range(len(s)):
  for w in range(5):
    try:
      now = s[l:l+w+1]
      if now in can:
        pass
      else:
        can.append(now)
    except:
      pass
can.sort()
print(can[k-1])

Measured memory_bytes: 3956
#include<stdio.h>
unsigned int d[3002][3002]={0};
int main(){
  int n,m,t,a,b,i;
  scanf("%d %d %d",&n,&m,&t);
  //for(i=0;i<=m;i++)printf("%2d ",i);printf("\n");
  while(n--){
    scanf("%d %d",&a,&b);
    for(i=0;i<=m;i++){
      if(d[n][i  ]<d[n+1][i])d[n][i  ]=d[n+1][i];
      if(d[n][i+1]<d[n  ][i])d[n][i+1]=d[n  ][i];
      if(i+b<=t||t<=i&&i+b<=m){
	if(d[n][i+b]<d[n+1][i]+a)d[n][i+b]=d[n+1][i]+a;
      }
    }
    /*for(i=t;i+b<m;i++){
      if(d[n][i  ]<d[n+1][i]  )d[n][i  ]=d[n+1][i];
      if(d[n][i+1]<d[n  ][i]  )d[n][i+1]=d[n  ][i];
      if(d[n][i+b]<d[n+1][i]+a)d[n][i+b]=d[n+1][i]+a;
      }//*/
    //printf("%2d ",n);for(i=0;i<=m;i++)printf("%2d ",d[n][i]);printf("\n");
  }
  printf("%d\n",d[0][m]);
  return 0;
}

Measured memory_bytes: 35780
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18
# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}



int main(){
    IOS;
    make(ll,n);
    ll ans=0;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ll c=0;
            while(n%i==0){c++; n/=i;}
            ll p=1;
            while((p*(p+1))/2<=c) p++;
            ans+=p-1;
        }
    }
    if(n!=1) ans++;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3672
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> h >> w;
  if (h == 1 || w == 1) {
    Cout(1);
    return 0;
  }
  ll add;
  if (w % 2 == 0) {
    add = w;
  } else {
    add = w / 2 + w / 2 + 1;
  }
  if (h % 2 == 0) {
    ans += add * (h / 2);
  } else {
    ans += add * (h / 2);
    if (w % 2 == 1)
      ans += w / 2 + 1;
    else
      ans += w / 2;
  }
  Cout(ans);
  return 0;
}


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

using namespace std;
const int N = 1e5 + 5;

string s;
int n, k;
int res;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    cin >> s;
    s = ' ' + s;
    s = s + ' ';
    int cnt = 0;
    for (int i=1; i<=n+1; i++)
    {
        if (s[i]==s[i - 1]) cnt++;
        else 
        {
            if (cnt>1) res += cnt - 1;
            cnt = 1;
        }
    }
    cout << min(n - 1, res + 2*k);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

typedef struct Point_obj{
	double x,y;
};

double Length(Point_obj *p0,Point_obj *p1){
	double x = p0->x - p1->x;
	double y = p0->y - p1->y;
	return sqrt( x*x + y*y);
}

int main(){
	//0は固定、1,2を動かす.
	Point_obj p[4];
	double s=0;
	double z=0;
	double a,b,c;
	char tmp;
	cin>>p[0].x,cin>>tmp,cin>>p[0].y;
	cin>>p[1].x,cin>>tmp,cin>>p[1].y;
	while(cin>>p[2].x){
		if(p[2].x==-1)break;
		cin>>tmp;
		cin>>p[2].y;
		a = Length(&p[0],&p[1]);
		b = Length(&p[1],&p[2]);
		c = Length(&p[2],&p[0]);
		z = (a+b+c)/2.0;
		s += sqrt(z*(z-a)*(z-b)*(z-c));
		p[1].x = p[2].x,p[1].y = p[2].y;
	}
	printf("%.6f\n",s);
}

/*

Sample Input
0.0,0.0
0.0,1.0 
1.0,1.0 
2.0,0.0 
1.0,-1.0 
Output for the Sample Input
2.500000

*/

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

int retAbs(vector<int> &weight,int s,int N){
    int res1 = 0;
    int res2 = 0;
    for(int i=0;i<s;i++){
        res1 += weight[i];
    }
    for(int i=s;i<N;i++){
        res2 += weight[i];
    }
    return abs(res1 - res2);
}

int main() {
  int N;
  cin >> N;
  vector<int> weight(100);
  for(int i=0;i<N;i++)
    cin >> weight[i];
  int min_abs = -1;
  for(int i=2;i<=N;i++){
    int diff = retAbs(weight,i-1,N);
    if(min_abs < 0 || min_abs > diff)
      min_abs = diff;
    }
    cout << min_abs << endl;
}

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

typedef long long ll;
typedef long double lg;
using namespace std;


int main(){

 long long lives,n;
 cin>>lives>>n;
   int a[n];

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

 long long sum=0;
 int flag = 0;

 for(int i=0;i<n;i++)
{
  sum += a[i];
  if(sum >= lives){
      flag = 1;
      break; }
 }

 if(flag  == 1)
    cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl;


return 0;
}

Measured memory_bytes: 3944
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> P;
int read()
{
    int x=0,flag=1;
    char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=2e5+5;
int a[maxn],M=0,n,f[maxn],ff[maxn];
LL tot,tott;
char s[maxn];

int get(int x)
{
    int ret=0;
    while(x)
    {
        ret++;
        x%=__builtin_popcount(x);
    }
    return ret;
}

void test()
{
    puts("");
    bitset<30> b(s+1);
    int x=b.to_ulong();
    REP(i,1,n)
    {
        int y=x^(1<<(n-i));
        printf("%d\n",get(y));
    }
    puts("");
}

int main()
{
    n=read();
    scanf("%s",s+1);
    REP(i,1,n) a[i]=s[i]-'0',M+=a[i];

    //test();

    if(M==0) {REP(i,1,n) puts("1"); return 0;}
    if(M==1)
    {
        if(a[n]==1)
        {
            REP(i,1,n-1) puts("2");
            puts("0");
            return 0;
        }
        else
        {
            REP(i,1,n-1) puts(a[i]?"0":"1");
            puts("2");
            return 0;
        }
    }
    f[0]=1%(M-1); ff[0]=1%(M+1);
    REP(i,1,n) f[i]=f[i-1]*2%(M-1),ff[i]=ff[i-1]*2%(M+1);
    REP(i,1,n) if(a[i]) tot+=f[n-i],tott+=ff[n-i];

    REP(i,1,n)
    {
        int x;
        if(a[i]) x=(tot-f[n-i])%(M-1);
        else x=(tott+ff[n-i])%(M+1);
        printf("%d\n",1+get(x));
    }


    return 0;
}


Measured memory_bytes: 6292
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define ll long long
using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1)<<endl;
    return 0;
}


Measured memory_bytes: 256