akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

typedef pair<int, int> P;

int main() {
  int h, w;
  cin >> h >> w;
  char s[h][w];
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> s[i][j];
    }
  }
  ll ans = -1;
  for (int sy = 0; sy < h; ++sy) {
    for (int sx = 0; sx < w; ++sx) {
      for (int gy = 0; gy < h; ++gy) {
        for (int gx = 0; gx < w; ++gx) {
          if (s[sy][sx] == '#') continue;
          if (s[gy][gx] == '#') continue;
          ll dist[h][w];
          for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; ++j) {
              dist[i][j] = -1;
            }
          }
          queue<P> que;
          dist[sy][sx] = 0;
          que.push(P(sy, sx));
          while (que.size()) {
            P p = que.front();
            que.pop();
            int y = p.first, x = p.second;
            for (int d = 0; d < 4; ++d) {
              int ny = y + dy[d], nx = x + dx[d];
              if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
              if (s[ny][nx] != '#' && dist[ny][nx] == -1) {
                que.push(P(ny, nx));
                dist[ny][nx] = dist[y][x] + 1;
              }
            }
          }
          ll res = -1;
          for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; ++j) {
              if (s[i][j] == '.') {
                res = max(res, dist[i][j]);
              }
            }
          }
          if (res != -1) ans = max(ans, res);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define var auto
#define ll long long
//#define APPLY(a, f) f(a.begin(), a.end())
#define APPLY(a, f, ...) f(a.begin(), a.end(), __VA_ARGS__)
#define FUN1(x, f) [&](auto& x){return f;}
#define FUN2(x, y, f) [&](auto& x){return f;}
using namespace std;


int main() {
    string s;
    cin >> s;
    stack<int> st{};
    st.push(0);
    var flag = false;
    for (auto c : s){
        if (c == 'm') {
            if (st.empty() || st.top() % 2 == 1) goto invalid;
            var next = st.top() + 1;
            st.pop();
            st.push(next);
            st.push(0);
        }
        if (c == 'e'){
            if (st.empty() || st.top() >= 2) goto invalid;
            st.pop();
            st.push(2);
        }
        if (c == 'w'){
            if (st.empty() || st.top() < 2) goto invalid;
            st.pop();
        }
    }
    if (st.size() != 1 || st.top() != 1) goto invalid;
    cout << "Cat" << endl;
    return 0;
    invalid:;
    cout << "Rabbit" << endl;
}


Measured memory_bytes: 3228
use proconio::input;

fn main() {
    input! {
        n:i32,
        s:String,
    }
    let input: Vec<char> = s.chars().collect();
    let mut result = 0;

    for i in 0..10 {
        let mut key: Vec<char> = Vec::new();
        key.push(i.to_string().chars().nth(0).unwrap());
        key.push('0');
        key.push('0');
        for c in &input {
            if key.last().unwrap() == c {
                key.pop();
            }
            if key.is_empty() {
                result += 1;
                break;
            }
        }
    }
    for i in 10..100 {
        let mut key: Vec<char> = Vec::new();
        key.push(i.to_string().chars().nth(1).unwrap());
        key.push(i.to_string().chars().nth(0).unwrap());
        key.push('0');
        for c in &input {
            if key.last().unwrap() == c {
                key.pop();
            }
            if key.is_empty() {
                result += 1;
                break;
            }
        }
    }
    for i in 100..1000 {
        let mut key: Vec<char> = Vec::new();
        key.push(i.to_string().chars().nth(2).unwrap());
        key.push(i.to_string().chars().nth(1).unwrap());
        key.push(i.to_string().chars().nth(0).unwrap());
        for c in &input {
            if key.last().unwrap() == c {
                key.pop();
            }
            if key.is_empty() {
                result += 1;
                break;
            }
        }
    }

    println!("{}", result);
}

Measured memory_bytes: 2380
#include<bits/stdc++.h>
using namespace std;
int main () {
  int fro[100001];
  int ba[100001];
  int ju = 0;
  int N, K;
  cin >> N >> K;
  vector<char> hu(N + 4);
  for (int i = 2; i <= N + 1; i ++) cin >> hu[i];
  hu[0] = '0';
  hu[1] = '1';
  hu[N + 2] = '1';
  hu[N + 3] = '0';
  //for (int i = 0; i < N + 4; i ++) cout << hu[i] << ' ';
  //cout << endl;
  for (int i = 1; i < N + 4; i ++) {
    if (hu[i - 1] == '0' && hu[i] == '1') fro[ju] = i;
    if (hu[i - 1] == '1' && hu[i] == '0') {
      ba[ju] = i - 1;
      ju ++;
    }
  }
  //for (int i = 0; i < ju; i ++) cout << fro[i] << ' ' << ba[i] << endl;
  if (ju - 1 <= K) {
    cout << N << endl;
    return 0;
  }
  vector<int>as(ju - K);
  for (int i = 0; i < ju - K; i ++) {
    as[i] = ba[i + K] - fro[i];
    if (i == 0 || i == ju - K - 1) as[i] --;
  }
  sort(as.begin(), as.end());
  cout << as[ju - K - 1] + 1 << endl;
}
  
  
  
    
  




Measured memory_bytes: 896
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()
    a = i_list()
    dic = {}
    for i in a:
        dic[i] = dic.get(i,0) + 1

    l = len(dic.keys())

    if l <= k:
        print(0)
        exit()
    l = l - k
    ans = 0
    cnt = 0

    for i in sorted(dic.values()):
        ans += i
        cnt += 1
        if cnt == l:
            break
    print(ans)







if __name__=="__main__":
    main()


Measured memory_bytes: 121784
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};module.exports=I;

function main(input) {
  const o = new I(input);

  const N = o.a();
  const edges = [];
  for (let i = 1; i<= N; i++) {
    for (let j = i + 1; j <= N; j++ ) {
      if (N % 2 === 0) {
        if (j !== N + 1 - i) {
          edges.push(`${i} ${j}`);
        }
      } else {
        if (j !== N - i) {
          edges.push(`${i} ${j}`)
        }
      }
    }
  }

  console.log(edges.length);
  edges.forEach(e => console.log(e));
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 10592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

  int n;
	cin >> n;

	vector<pair<int,int>> x(n);
	
	rep(i, n) {
	  int _x, _l;
	  cin >> _x >> _l;

		x[i] = {_x + _l, _x - _l};
	}


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

	if(n == 1) std::cout << 1 << endl;
	else {
		int ans = 1, i = 1, r = x[0].first;
		while(i < n){
			while (i < n && x[i].second < r) {
				i++;
			}
	  if (i < n && x[i].second >= r) {
		  ans++;
		  r = x[i].first;
		}
		}

		std::cout << ans << endl;
	}

}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 1e5+10;
char s[maxn];
int main()
{

    scanf("%s",s);
    long long ans =0;
    int n1=0,n0=0;
    int len = strlen(s);
    for(int i=0;i<len;i++){
        if(s[i]=='1')n1++;
        if(s[i]=='0')n0++;

    }
    ans = n1>n0?n0:n1;
    cout<<ans*2;

    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int S,A,B,C,D;
    scanf("%d",&S);
    D=S%10;
    C=(S/10)%10;
    B=(S/100)%10;
    A=S/1000;
    if(A+B+C+D==7) printf("%d+%d+%d+%d=7\n",A,B,C,D);
    else if(A+B+C-D==7) printf("%d+%d+%d-%d=7\n",A,B,C,D);
    else if(A+B-C+D==7) printf("%d+%d-%d+%d=7\n",A,B,C,D);
    else if(A-B+C+D==7) printf("%d-%d+%d+%d=7\n",A,B,C,D);
    else if(A-B-C+D==7) printf("%d-%d-%d+%d=7\n",A,B,C,D);
    else if(A-B+C-D==7) printf("%d-%d+%d-%d=7\n",A,B,C,D);
    else if(A+B-C-D==7) printf("%d+%d-%d-%d=7\n",A,B,C,D);
    else if(A-B-C-D==7) printf("%d-%d-%d-%d=7\n",A,B,C,D);

}

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

int main()
{
	int x, hp = 0;
	cin >> x;

	if (x >= 500) {
		hp = (x / 500) * 1000;
		x %= 500;
	}

	if (x >= 5) hp += (x / 5) * 5;
	cout << hp << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
As = np.array(sorted(map(int, input().split())))
Fs = np.array(sorted(map(int, input().split()), reverse = True))

times = As * Fs

ng = -1
ok = np.amax(times)+1

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    k = np.sum(np.maximum(np.ceil((times - mid) / Fs), 0))
    if k > K:
        ng = mid
    else:
        ok = mid

print(ok)

Measured memory_bytes: 37196
// C++11
#include <iostream>
#include <array>

int main(){

    std::array<int, 4> num_a, num;

    while(std::cin >> num_a[0] >> num_a[1] >> num_a[2] >> num_a[3]){
        std::cin >> num[0] >> num[1] >> num[2] >> num[3];
        int hit = 0, blow = 0;
        for(size_t i = 0; i < 4; ++i){
            if(num_a[i] == num[i]){
                ++hit;
            }else{
                for(size_t j = 0; j < 4; ++j){
                    if(num_a[j] == num[i]){
                        ++blow;
                    }
                }
            }
        }
        std::cout << hit << " " << blow << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3056
def main(pro):
    ans = 'keyence'
    try:
        lokasi = pro.index(ans)
        if lokasi > 0 and lokasi + len(ans) < len(pro):
            raise ValueError()
        else:
            print('YES')
            return
    except:
        for i in range(len(ans)):
            if ans[i] != pro[i]:
                break
        r = len(ans) - i
        for a in range(1,r+1):
            if ans[-r] != pro[-r]:
                print('NO')
                return
        print('YES')

main(input())

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

typedef std::array<bool, 130> Line;
typedef std::array<Line, 130> Table;

Table table; // [X][Y]
std::array< std::array<int, 130>, 130> standed; // [X][Y]

int current_x;
int current_y;
int g_count;
int g_turn;
int g_current_turn;

int g_dx[] = { 0, 1, 1, 0, -1, -1 };
int g_dy[] = { 1, 1, 0, -1, -1, 0 };

int calc(int x) {
	return x + 65;
}

void solution() {
	if (standed[calc(current_x)][calc(current_y)] == -1) {
		++g_count;
	} else if (standed[calc(current_x)][calc(current_y)] <= g_current_turn) return;
	
	standed[calc(current_x)][calc(current_y)] = g_current_turn;
	if (g_current_turn >= g_turn) return;

	auto x = current_x;
	auto y = current_y;

	for (int i = 0; i < 6; ++i) {
		if (!table[calc(current_x + g_dx[i])][calc(current_y + g_dy[i])]) {
			current_x += g_dx[i];
			current_y += g_dy[i];

			++g_current_turn;
			solution();
			--g_current_turn;

			current_x = x;
			current_y = y;
		}
	}
}

int main() {

	while (true) {
		for_each(table.begin(), table.end(), [](Line & line) {
			line.fill(false);
		});
		for_each(standed.begin(), standed.end(), [](std::array<int, 130> & line) {
			line.fill(-1);
		});
		g_count = 0;
		g_current_turn = 0;

		int n;
		cin >> g_turn >> n;
		if (g_turn == 0) break;

		for (int i = 0; i < n; ++i) {
			int x, y;
			cin >> x >> y;
			table[calc(x)][calc(y)] = true;
		}

		cin >> current_x >> current_y;

		solution();

		cout << g_count << endl;
	}
}

Measured memory_bytes: 1240
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	int n=ci();
	bool ok = 1;
	rep(i,1,n){
		int x=ci();
		if( x%2==0 && (x%3!=0&&x%5!=0) ) ok=0;
	}
	puts(ok ? "APPROVED":"DENIED");
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


vector<int>zalgorithm(string s){
    vector<int>a(s.size());
    a[0]=s.size();
    int i=1,j=0;
    while(i<s.size()){
        while(i+j<s.size()&&s[j]==s[i+j])j++;
        a[i]=j;
        if(j==0){i++;continue;}
        int k=1;
        while(i+k<s.size()&&k+a[k]<j)a[i+k]=a[k],k++;
        i+=k;j-=k;
    }
    return a;
}


int N;
string S;

vint calc(string s){
    vint z=zalgorithm(s);

    vint ret(s.size(),1);
    for(int i=1;i<s.size();i++){
        for(int k=2;i*k<=s.size()&&z[i]>=i*(k-1);k++)ret[i*k-1]=0;
    }
    return ret;
}

signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    cin>>S;
    N=S.size();


    if(count(all(S),S[0])==N){
        cout<<N<<endl<<1<<endl;
        return 0;
    }

    vint X=calc(S);
    reverse(all(S));
    vint Y=calc(S);

    if(X[N-1]){
        cout<<1<<endl<<1<<endl;
        return 0;
    }

    int cnt=0;
    for(int i=0;i<N-1;i++){
        if(X[i]&&Y[N-2-i])cnt++;
    }

    cout<<2<<endl<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 13056
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B,C,K = inputIL()

if K<=A:
  print(K)
  exit()
if K<=A+B:
  print(A)
  exit()
else:
  print(A-C+(A+B+C)-K)

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

int binary_search(vector<long long> &h, long long x){
    int ok = (int)h.size();
    int ng = - 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (h[mid] > x) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    vector<long long> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    long long ok = 1'000'000'001;
    long long ng = - 1;
    while (abs(ok - ng) > 1){
        long long mid = (ok + ng) / 2;
        int tmp = binary_search(h, mid * b);
        long long res = 0;
        for (int i = tmp; i < n; i++){
            res += (h[i] - mid * b + a - b - 1)/(a - b);
        }
        if (res <= mid) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 1024
x,y,a,b,c=map(int,input().split())
r=sorted(list(map(int,input().split())),reverse=True)
g=sorted(list(map(int,input().split())),reverse=True)
w=list(map(int,input().split()))

p=sorted(r[:x]+g[:y]+w,reverse=True)
print(sum(p[:x+y]))

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

int saki,S[1000];

void in(int x){
  S[++saki]=x;
}

int hen(){
  saki--;
  return S[saki+1];
}
int main(){
  int a,b;
  saki=0;
  char s[100];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a=hen();
      b=hen();
      in(a + b);
    }
    else if(s[0] == '-'){
      b=hen();
      a=hen();
      in(a - b);
    }
    else if(s[0] == '*'){
      a=hen();
      b=hen();
      in(a * b);
    }
    else{
      in(atoi(s));
    }
  }
  printf("%d\n",hen());
  return 0;
}



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

int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    pair<int,int> s[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        s[i]={a[i]+b[i],i};
    }
    ll ans=0;
    sort(s,s+n);
    for(int i=n-1;i>=0;i--){
        if(n-i&1)ans+=a[s[i].second];
        else ans-=b[s[i].second];
    }
    cout<<ans<<endl;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int gcnt=0,ans;
  rep(i,n){
    if(gcnt==(n+1)/2){
      if(s[i]=='g')ans++;
      continue;
    }
    if(s[i]=='g')gcnt++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define REPR(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORR(i, a, b) \
  for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
#define ALL(f, x, ...) \
  ([&](auto& y) { return (f)(begin(y), end(y), ##__VA_ARGS__); })(x)
auto INDEX = [](auto& x, auto& xs) { return &x - &xs[0]; };
void async_io() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
const auto inf = INT_MAX / 3;
const auto pi = 2 * std::acos(0.0);
const auto eps = 1e-14;
using ll = signed long long;
using ull = unsigned long long;

signed main() {
  async_io();
  int a, b, c;
  cin >> a >> b >> c;
  // [0..a] + [a+b % 60 .. $0 + a % 60] ...
  bool seeked[60] = {};
  for (int i = 0, j = 0;;) {
    if (seeked[i]) {
      cout << "-1" << endl;
      return 0;
    }
    if (i <= c and c <= i + a) {
      cout << 60 * j + c << endl;
      return 0;
    }
    seeked[i] = true;
    if (i + a + b >= 60) j++;
    i = (i + a + b) % 60;
  }
}

Measured memory_bytes: 3160
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

int M, K;

int main(int argc, char **argv) {
    std::cin >> M >> K;

    if (M == 1) {
        if (K == 0) {
            std::cout << 0 << " " << 0 << " " << 1 << " " << 1 << std::endl;
        } else {
            std::cout << -1 << std::endl;
        }
    } else {
        int ub = pow(2, M);
        if (K < ub) {
            std::cout << K << " ";
            for (int i = 0; i < ub; i++) {
                if (i != K) {
                    std::cout << i << " ";
                }
            }
            std::cout << K << " ";
            for (int i = ub - 1; 0 <= i; i--) {
                if (i != K) {
                    std::cout << i << " ";
                }
            }
            std::cout << std::endl;
        } else {
            std::cout << -1 << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

// Eratosthenes's sieve
// create list of prime numbers in O(N)
// check if the given number is prime in O(1)
struct Sieve {
    vector<bool> isPrime;
    Sieve(size_t max) : isPrime(max + 1, true) {
        isPrime[0] = false;
        isPrime[1] = false;

        for (size_t i = 2; i * i <= max; ++i)
            if (isPrime[i])
                for (size_t j = 2; i * j <= max; ++j)
                    isPrime[i * j] = false;
    }
    bool operator()(size_t n) { return isPrime[n]; }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    Sieve isPrime(100000);
    vector<lint> p1, p3;
    map<lint, lint> p2tp;
    for (lint i = 1; i < 3000; ++i) {
        if (isPrime(i)) {
            p1.push_back(i);
            p3.push_back(i * i * i);
        }
    }
    for (lint i = 1; i <= 100000; ++i) {
        if (isPrime(i))
            p2tp[i * i] = i;
    }
    for (int i = 0; i < n; ++i) {
        for (auto &p : p3) {
            while (s[i] % p == 0)
                s[i] /= p;
        }
    }
    map<lint, pair<int, int>> pa;
    for (int i = 0; i < n; ++i) {
        lint t = s[i];
        lint v = 1;
        for (auto &p : p1) {
            lint cnt = 3;
            while (s[i] % p == 0) {
                cnt--;
                s[i] /= p;
            }
            if (cnt != 3) {
                for (int j = 0; j < cnt; ++j) {
                    v *= p;
                }
            }
        }
        if (p2tp.count(s[i]) == 0) {
            v *= s[i] * s[i];
        } else {
            v *= p2tp[s[i]];
        }
        if (t > v) {
            pa[v].second++;
        } else {
            pa[t].first++;
        }
    }
    lint ret = 0;
    for (auto &p : pa) {
        if (p.first == 1)
            ret++;
        else
            ret += max(p.second.first, p.second.second);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 7936
n,m=map(int,input().split())
h=list(map(int, input().split()))
li=[[0] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    li[a-1].append(h[b-1])
    li[b-1].append(h[a-1])
ans=0
for j in range(n):
    if h[j]>max(li[j]):
        ans+=1
print(ans)

Measured memory_bytes: 26012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    vector<pair<ll, ll>> q[n];
    rep(i, 0, n){
        ll a;
        cin >> a;
        rep(j, 0, a){
            pair<ll, ll> tmp;
            cin >> tmp.first >> tmp.second;
            tmp.first--;
            q[i].push_back(tmp);
        }
    }

    ll ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        bool flag = true;
        ll num = 0;
        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                num++;
                fore(x, q[i]){
                    if(bool(bit & (1 << x.first)) != bool(x.second)){
                        flag = false;
                        break;
                    }
                }
            }
            if(!flag)break;
        }
        if(flag){
            ans = max(ans, num);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>
#include <string>
using namespace std;

const int N_MAX = 100;
const int INF = (int)1e9;

struct Edge {
    int to, cost;
    Edge(int t, int c) : to(t), cost(c) {}
    bool operator <(const Edge &e) const {
        return cost > e.cost;
    }
};

bool used[N_MAX];

int main() {
    for(int N; cin >> N, N; ) {
        int M; cin >> M;
        cin.ignore();

        vector<Edge> D[N_MAX];

        for(int i = 0; i < M; i++) {
            string s; getline(cin, s);
            for(int j = 0; j < (int)s.length(); j++) if(s[j] == ',') s[j] = ' ';
            istringstream is(s);
            int a, b, cost;
            is >> a >> b >> cost;

            D[a].push_back(Edge(b, cost / 100 - 1));
            D[b].push_back(Edge(a, cost / 100 - 1));
        }

        fill(used, used + N, false);

        priority_queue<Edge> Q;
        Q.push(Edge(0, 0));

        int total = 0;

        while(!Q.empty()) {
            Edge e = Q.top(); Q.pop();

            if(used[e.to]) continue;

            used[e.to] = true;
            total += e.cost;

            for(Edge ne : D[e.to]) {
                if(used[ne.to]) continue;
                Q.push(ne);
            }

        }

        cout << total << endl;
    }
}

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

int main(){
	int k,s,z,ans=0;
	cin >> k >> s;

	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			z = s - i - j;
			if(z <= k && z >= 0){
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
s=[]
for i in range(a):
    s.append([p[i],1])
for i in range(b):
    s.append([q[i],2])
for i in range(c):
    s.append([r[i],0])
s.sort(reverse=True)
o=0
X,Y,Z=0,0,0
for i in range(a+b+c):
    if s[i][1]==1 and X<x:
        X+=1
        Z+=1
        o+=s[i][0]
    elif s[i][1]==2 and Y<y:
        Y+=1
        Z+=1
        o+=s[i][0]
    elif s[i][1]==0:
        Z+=1
        o+=s[i][0]
    if Z==x+y:
        break
print(o)

Measured memory_bytes: 134108
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long
int N,M;
//here begins your code
int dp[1100][5000];
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> M;
  vector<int> A(M),B(M),C(M,0);
  REP(i,M){
  	cin >> A[i] >> B[i];
  	REP(j,B[i]){
  		int t;
  		cin >> t;
  		t--;
  		C[i] += (1 <<t);
  	}
  }

  REP(i,1100){
  	REP(j,5000){
  		dp[i][j] = llINF;
  	}
  }

  dp[0][0] = 0;
  REP(i,M){
  	for(int j = 0; j < (1 << N); j++){
  		chmin(dp[i + 1][j],dp[i][j]);
  		int nj = j | C[i];
  		chmin(dp[i + 1][nj], dp[i][j] + A[i]);
  	}
  }
  cout << (dp[M][(1<<N)-1] < INF ? dp[M][(1<<N)-1] : -1) << endl;    
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 43264
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
    }
    int cnt = 1;
    REP(i,n){
        if(a[i] % 2 == 0) cnt *= 2;
    }
    cout << pow(3, n) - cnt << endl;
}

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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

map<string, vector<string> > wglist;
map<string, int> price;
map<string, int> memo;

int get_price(const string& name)
{
    if (memo.find(name) != memo.end()){
        return memo[name];
    }

    int base_price = price[name];
    if (wglist.find(name) == wglist.end()){
        return memo[name] = base_price;
    }

    vector<string> wg = wglist[name];
    int total_price = 0;
    rep(i, wg.size()){
        total_price += get_price(wg[i]);
    }
    return memo[name] = min(total_price, base_price);
}

int main()
{
    int n;
    while (n = in()){
        wglist.clear();
        price.clear();
        memo.clear();
        rep(i, n){
            string name;
            int p;
            cin >> name >> p;
            price[name] = p;
        }
        int wg = in();
        rep(i, wg){
            string name;
            cin >> name;
            int c;
            c = in();
            vector<string> lists;
            rep(j, c){
                string s;
                cin >> s;
                lists.push_back(s);
            }
            wglist[name] = lists;
        }
        string name;
        cin >> name;
        printf("%d\n", get_price(name));
    }
    return (0);
}

Measured memory_bytes: 1288
#include <iostream>
using namespace std;
 
int main() { 
    int n, sum, ans = 1000000000;
    cin >> n;
    char s[n];
    int w_ = 0, e_ = 0, w[n] = {0}, e[n] = {0};
    for(int i = 0; i < n; ++i) {
        cin >> s[i];
        if(s[i] == 'W') {
            w_++;
        }
        w[i] = w_;
    }
    for(int i = n-1; i >= 0; --i) {
        if(s[i] == 'E') {
            e_++;
        }
        e[i] = e_;
    }
    for(int i = 0; i < n; ++i) {
        sum = w[i] + e[i] - 1;
        if(sum < ans) ans = sum;
    }
    
    cout << ans << '\n';
}



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

int main() {
  string s;
  cin >> s;
  int count = 0;
  
  if (s[0] == '1') count++;
  if (s[1] == '1') count++;
  if (s[2] == '1') count++;
  
  cout << count << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

def check(l):
    count = 0
    for L in A:
        count += L // l
        if L % l != 0:
            count += 1
        count -= 1
    return count <= K

bottom, top = 0, max(A)

while top - bottom > 1:
    mid = (top + bottom) // 2
    if check(mid):
        top = mid
    else:
        bottom = mid

print(top)


Measured memory_bytes: 30628
#!/usr/bin/env python3
s = input()
for i in range(1,len(s)-1):
	if (len(s) - i) % 2 == 1: pass
	elif s[:(len(s) - i)//2] == s[(len(s) - i)//2:-i]:
		print(len(s) - i)
		#print(s[:-i])
		break

Measured memory_bytes: 2940
#include<cstdio>
#include<functional>
#include<algorithm>
#define MM	2100000000
using namespace std;
long long dp[51][2501][51],ssum;
int main(void)
{
	int n,a,i,j,k,l,x[50],sum;
	scanf("%d %d",&n,&a);
	sum=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&x[i]);
		sum+=x[i];
	}
	for(i=0;i<=n;i++)	{
		for(j=0;j<=sum;j++)	{
			for(k=0;k<=n;k++)	{
				dp[i][j][k]=0;
			}
		}
	}
	dp[0][0][0]=1;
	for(i=0;i<n;i++)	{
		for(j=0;j<=sum;j++)	{
			for(k=0;k<=n;k++)	{
				if(dp[i][j][k]!=0)	{
					dp[i+1][j][k]+=dp[i][j][k];
					dp[i+1][j+x[i]][k+1]=dp[i][j][k];
				}
			}
		}
	}
	ssum=0;
	for(i=1;i<=n;i++)	{
		ssum+=dp[n][i*a][i];
	}
	printf("%lld\n",ssum);
	return 0;
}

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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=2e3+5;

int n,m,is[N][N],ls[N][N],L[N],R[N];
int stak[N],a[N][N],ans,top;
char ch[N][N];

int main()
{
	n=read();
	m=read();
	ans=max(ans,max(n,m));
	for ( int i=1;i<=n;i++ )
	{
		scanf("%s",ch[i]+1);
		for ( int j=1;j<=m;j++ ) 
			a[i][j]=(ch[i][j]=='#');
	}
	for ( int i=1;i<n;i++ ) 
		for ( int j=1;j<m;j++ ) 
		{
			int gs=a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1];
			if(!(gs&1)) is[i][j]=1;
		}
	for ( int i=1;i<=n;i++ )
		for ( int j=1;j<=m;j++ ) 
			ls[i][j]=(is[i][j])?ls[i-1][j]+1:0;
	for ( int i=1;i<=n;i++ )
	{
		stak[top=1]=0;
		for ( int j=1;j<m;j++ ) 
		{
			while(top&&ls[i-1][stak[top]]>=ls[i-1][j]) top--;
			L[j]=stak[top];
			stak[++top]=j;
		}
		stak[top=1]=m;
		for ( int j=m-1;j>=1;j-- ) 
		{
			while(top&&ls[i-1][stak[top]]>=ls[i-1][j]) top--;
			R[j]=stak[top];
			stak[++top]=j;
		}
		for ( int j=1;j<m;j++ ) 
			ans=max(ans,(R[j]-L[j])*(ls[i-1][j]+1));
	}
	printf("%d\n",ans);
	return 0;
}
			 

Measured memory_bytes: 51328
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

struct combination {
    combination(ll Nmax, ll mod) {
        (this->MOD) = mod;
        (this->Nmax) = Nmax;
        factorial.resize(Nmax + 1, 1);
        inverse_factorial.resize(Nmax + 1, 1);
        init_factorial();
    }

    ll calc(ll n, ll r) {
        if (r < 0 || r > n)
            return 0;
        ll ret = (factorial[n] * inverse_factorial[r]) % MOD;
        ret = (ret * inverse_factorial[n - r]) % MOD;
        return ret;
    }

private:
    ll MOD, Nmax;
    vector<ll> factorial;
    vector<ll> inverse_factorial;
    ll mod_pow(ll n, ll p, ll mod) {
        n %= mod;
        if (p == 0)
            return 1;
        ll res = mod_pow(n * n % mod, p / 2, mod);
        if (p % 2 == 1)
            res = res * n % mod;
        return res;
    }

    void init_factorial() {
        for (ll i = 1; i <= Nmax; i++) {
            factorial[i] = (factorial[i - 1] * i) % MOD;
        }
        inverse_factorial[Nmax] = mod_pow(factorial[Nmax], MOD - 2, MOD);
        for (ll i = Nmax - 1; i >= 1; i--) {
            inverse_factorial[i] = (inverse_factorial[i + 1] * (i + 1)) % MOD;
        }
    }
};

int main() {
    int X, Y;
    cin >> X >> Y;
    ll mod = 1e9 + 7;
    combination comb(X, mod);

    ll ans = 0;
    for (int a = 0; a <= X; a++) {
        int b = Y - 2 * a;
        if (b >= 0 && a + 2 * b == X) {
            ans += comb.calc(a + b, a);
            ans %= mod;
        }
    }
    cout << ans << endl;
}


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

int main(){
  int n, a[110];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a+n, greater<int>());
  int l=0, b = 0;
  for (int i = 0; i < n; i++) {
    if (i%2==0) l += a[i];
    else b += a[i];
  }
  cout << l - b << endl;
}


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

int main(){
    int n, k; cin >> n >> k;
    str s; cin >> s;
    char tmp;
    for(int i=0; i<n; i++){
        if(i != k-1){
            printf("%c", s[i]);
        }else{
            if (('a' <= s[i]) && (s[i] <= 'z')){
                tmp = s[i] - 0x20;
            } else if (('A' <= s[i]) && (s[i] <= 'Z')){
                tmp = s[i] + 0x20;
            }
            printf("%c", tmp);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> s(9);
    for(int i=0;i<9;++i)cin>>s[i];
    
    vector<bool> f(9,false);
    
    int N;
    cin>>N;
    
    for(int i=0;i<N;++i){
        int b;
        cin>>b;
        const int pos=distance(s.cbegin(),find(s.cbegin(),s.cend(),b));
        f[pos]=true;
    }
    
    bool ok=false;
    for(int i=0;i<3;++i){
        ok=ok||(f[i]&&f[i+3]&&f[i+6])||(f[i*3]&&f[(i*3)+1]&&f[(i*3)+2]);
    }
    ok=ok||(f[0]&&f[4]&&f[8])||(f[2]&&f[4]&&f[6]);
    
    cout<<(ok?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;

bool isso(long long int a) {
	if (a == 1||a==0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}

struct edge {
	int from;
	int to;
	long double time;
};
struct aa {
	int now;
	long double time;
	bitset<8>tickets;
};

class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};

long long int powint(long long int a, long long int b) {
	assert(b >= 0);
	if (b == 0)return 1;
	if (b == 1)return a;
	long long int ans = 1;
	long long int aa = powint(a, b / 2);
	ans *= aa*aa;
	if (b % 2)ans *= a;
	return ans;
}



vector<pair<long long int, long long int>>smag, amag;
vector<long long int>hps;

long long int sdp[100001];
long long int adp[100001];


long long int getmp(const long long int damage) {
	long long int ans = 0;
	for (auto i : hps) {
		if (i - damage <= 0) {

		}
		else {
			ans += sdp[i - damage];
		}
	}
	return ans;
}
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		hps.clear();
		smag.clear();
		amag.clear();
		for (int i = 0; i < N; ++i) {
			int a; cin >> a;
			hps.emplace_back(a);
		}
		const long long int max_hp = *max_element(hps.begin(), hps.end());
		int M; cin >> M;
		for (int i = 0; i < M; ++i) {
			string st; cin >> st;
			long long int mp; cin >> mp;
			cin >> st;
			long long int dam; cin >> dam;
			if (st == "Single") {
				smag.push_back({ mp,dam });
			}
			else {
				amag.push_back({ mp,dam });
			}
		}

		memset(sdp, 9999999,sizeof(sdp));
		memset(adp, 9999999, sizeof(adp));
		sdp[0] = 0; adp[0] = 0;
		for (long long int i = 0; i < 100000; ++i) {
			for (auto mag : smag) {
				sdp[min(100000ll,i + mag.second)] = min(sdp[min(100000ll, i + mag.second)], sdp[i] + mag.first);
			}
			for (auto mag : amag) {
				adp[min(100000ll, i + mag.second)] = min(adp[min(100000ll, i + mag.second)], adp[i] + mag.first);
			}
		}
		for (int i = 0; i < 100000; ++i) {
			
			sdp[100000-i-1] = min(sdp[100000-i], sdp[100000 - i - 1]);
			
			
			adp[100000-i-1] = min(adp[100000-i], adp[100000 - i - 1]);
			
		}

		long long int ans = 9999999999999999;
		if (adp[1] > 1000) {
			ans = getmp(0);
		}
		else if (sdp[1] > 1000) {
			ans = adp[max_hp];
		}
		else {

			for (int alldamage = 0; alldamage <= max_hp; ++alldamage) {
				ans = min(ans, adp[alldamage] + getmp(alldamage));
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf LLONG_MAX

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    //cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;

        if(n==1)
        {
            cout<<0;
            continue;
        }

        vector<ll> sum;

        ll ans=0;

        for(ll i=1;i<50;i++)
        {
            sum.pb((i*(i+1))/2);
        }

        for(ll i=2;i<=sqrt(n);i++)
        {
            if(n%i==0)
            {
                ll no=0;
                
                while(n%i==0)
                {
                    n/=i;
                    no++;
                }

                ll val=upper_bound(sum.begin(),sum.end(),no)-sum.begin();

                ans+=val; 

            }
        }

        if(n!=1)
        ans++;

        cout<<ans;


    }
}













Measured memory_bytes: 3680
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

import sys,collections
sys.setrecursionlimit(100000)

INF = float("inf")

V,E = map(int,sys.stdin.readline().split())
st = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(E)) # multi line with multi param
#st = [[0,1],[0,2],[1,2],[2,3]]
G = {i:[] for i in range(V)}

for s,t in st:
    G[s].append(t)

def dfs_cycle(s):
    act.add(s)
    visited.add(s)
    #print(s,act,visited,G)
    if not s in G:
        act.remove(s)
        return
    for e in G[s]:
        #print(s,e,act)
        if e in act:
            global bad
            bad = True
            return
        elif not e in visited:
            dfs_cycle(e)
    act.remove(s)

bad = False
visited = set()
act = set()
for s,_ in st:
    if not s in visited:
        dfs_cycle(s)
if bad:
    print(1)#has cycle
else:
    print(0)


Measured memory_bytes: 6088
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007LL
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef vector<iii> Viii;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return gcd(a, b); return a*b / gcd(a, b); }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

int n, m;
int parent[100001];
int leng[100001];
int find(int a)
{
	if (parent[a] < 0)return a;
	find(parent[a]);
	leng[a] += leng[parent[a]];
	return parent[a] = find(parent[a]);
}
void merge(int a, int b,int d)
{
	leng[b] = leng[a] + d;
	a = find(a), b = find(b);
	if (a != b)
	{
		parent[a] += parent[b];
		parent[b] = a;
	}
}
int main() {
	MEM_1(parent);
	scanf("%d%d", &n, &m);
	fup(i, 0, m - 1, 1)
	{
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		if (find(l)!=find(r))
		{
			d += leng[l] - leng[r];
			merge(find(l), find(r), d);
		}
		else
		{
			if (leng[l] + d != leng[r])
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int Q;
    cin >> Q;
    while (Q--) {
        string X, Y;
        cin >> X >> Y;
        ll N = X.size();
        ll M = Y.size();
        vector<vector<ll>> dp(N + 1, vector<ll>(M + 1, 0));
        rep(i, N) {
            rep(j, M) {
                if (X[i] == Y[j]) {
                    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                }
                dp[i + 1][j + 1] = max({dp[i + 1][j + 1], dp[i][j + 1], dp[i + 1][j]});
            }
        }
        cout << dp[N][M] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 10784