akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9

typedef long long ll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int maxn = 2e3 + 10;
int n, m, a, b, c, edge = 0;
int head[maxn], Next[maxn], to[maxn], cnt[maxn];
ll val[maxn], dis[maxn];
bool vis[maxn], vis1[maxn];
bool flag;

inline void add_edge(int u, int v, int _val) {
    to[edge] = v; val[edge] = _val; Next[edge] = head[u]; head[u] = edge++;
}
void dfs(int u) {
    if (u == n) { flag = true; return; }
    for (int i = head[u]; i != -1; i = Next[i]) {
        if (vis1[to[i]]) { continue; } vis1[to[i]] = true; dfs(to[i]);
    }
}
bool judge(int u) { memset(vis1, false, sizeof(vis1)); flag = false; dfs(u); return flag; }

bool spfa() {
    memset(vis, false, sizeof(vis)); memset(cnt, 0, sizeof(cnt)); int f;
    dis[1] = 0; for (int i = 2; i <= n; ++i) { dis[i] = INF; }
    queue<int> q; q.push(1);
    while (!q.empty()) {
        f = q.front(); q.pop(); vis[f] = false; ++cnt[f];
        if (cnt[f] > n + 1) {
            if (judge(f)) { return false; } vis[f] = true;
        }
        for (int i = head[f]; i != -1; i = Next[i]) {
            if (dis[to[i]] > dis[f] + val[i]) {
                dis[to[i]] = dis[f] + val[i];
                if (!vis[to[i]]) { vis[to[i]] = true; q.push(to[i]); }
            }
        }
    }
    return true;
}



int main() {
#ifdef __AiR_H
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    memset(head, -1, sizeof(head));
    scanf("%d %d", &n, &m);
    while (m--) {
        scanf("%d %d %d", &a, &b, &c); c = -c; add_edge(a, b, c);
    }
    if (spfa()) { printf("%lld\n", -dis[n]); } else { printf("inf\n"); }
#ifdef __AiR_H
    printf("Time used = %.2fs\n", (double)clock() / CLOCKS_PER_SEC);
#endif // __AiR_H
    return 0;
}


Measured memory_bytes: 384
function main()
  
  N = parse(Int,readline())
  
  a = zeros(Int,N)
  
  for i in 1:N
    a[i] = parse(Int,readline())
  end
  
  count = 0
  check = 1
  
  for i in 1:N
    
    count += 1
    
    if a[check] == 1 || count == N
      println(-1)
      break
    elseif a[check] == 2
      println(count)
      break
    else
      check = a[check]
    end
    
  end
    
end

main()

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


int main() {
    int N, M, ai, bi;
    vector<pair<int,int>> ab;
    cin >> N >> M;
    // vector<vector<int>> dp(N+1);
    map<int, vector<int>> day2weight;
    rep(i, N){
        cin >> ai >> bi;
        day2weight[ai].push_back(bi);
    }

    priority_queue<int> tasks;
    int ans = 0;
    for(int i=1; i < M+1; i++) {
        vector<int> weights = day2weight[i];
        rep (j, weights.size()) {
            tasks.push(weights[j]);
        }
        if (!tasks.empty()) {
            ans += tasks.top();
            tasks.pop();
        }
    }
    cout << ans;
}

Measured memory_bytes: 14172
from collections import defaultdict, deque
import sys
import math

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    # N = int(input())
    N, K = [int(a) for a in input().split()]
    # H = [
    #     int(input())
    #     for _ in range(N)
    # ]
    A = sorted([int(a) for a in input().split()])
    SUM = sum(A)

    # bubu = [0] * N
    # max_K = 0
    # s = 0
    # for i, a in enumerate(A):
    #     s += a
    #     bubu[i] = s
    # for i in range(N):
    #     if bubu[i] >= K:
    #         max_K = N - i
    #         break
    # print("A", A)
    # print("bubu", bubu)
    # print(max_K)
    # print("SUM:", SUM)

    def check(nn):
        r = []
        for a in A:
            amari = a % nn
            if amari == 0:
                r.append((0, 0))
            else:
                r.append((amari, amari - nn))
            # if amari<nn-amari:
            #     r.append(amari)
            # else:
            #     r.append(amari-nn)
        # print(r)
        r = sorted(r, key=lambda a: a[0])
        ss = sum(a for a, _ in r)
        sss = ss // nn
        rsum = sum(a for a, b in r[:-sss])
        lsum = -sum(b for _, b in r[-sss:])
        vvv = max(rsum, lsum)
        # print(ss, sss, rsum, lsum)
        if vvv <= K:
            return True
        else:
            return False

    sq = int(math.sqrt(SUM))
    aaa = []
    for n in range(1, sq + 1):
        # print("@@", n)
        if SUM % n != 0:
            continue
        aaa.append(n)
        ddd = SUM // n
        # print("maybe:", ddd)
        if check(ddd):
            print(ddd)
            return
        # print(n, ddd)

    for n in reversed(aaa):
        # print("maybe:", n)
        if check(n):
            print(n)
            return
        # print(n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b;
    int cnt=0;
    
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0){
            break;
        }
        
        for(int i=1;i<=a-2;i++){
            for(int j=i+1;j<=a-1;j++){
                for(int k=j+1;k<=a;k++){
                    if(i+j+k==b)cnt++;
                }
            }
        }
        cout<<cnt<<endl;
        cnt=0;
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3148
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] put = ReadLine().Split(' ');
      	int a = int.Parse(put[0]);
      int b = int.Parse(put[1]);
      int c = int.Parse(put[2]);
      if(a<=c && c<=b){
        WriteLine("Yes");
      }else{
        WriteLine("No");
      }
    }
}

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N, M, C, cnt;
    cnt = 0;

    cin >> N >> M >> C;
    int B[M + 1];

    for(int i = 1; i <= M; i++) {
        cin >> B[i];
    }

    for(int i = 1; i <= N; i++) {
        int v, sum = C;
        for(int j = 1; j <= M; j++) {
            cin >> v;
            sum += v * B[j];
        }
        if(sum > 0) {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

int main() {
    int64_t A, B;
    cin >> A >> B;
    for (int64_t i = 0; ; i++) {
        int64_t t1 = (int64_t)(i * 1.08) - i;
        int64_t t2 = (int64_t)(i * 1.10) - i;
        if (t1 == A && t2 == B) {
            cout << i << endl;
            return 0;
        }
        if (t1 > A && t2 > B) {
            break;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 2000005;
int n, C[10][10];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++)
    {
        int a = i;
        while (a >= 10)
            a /= 10;
        C[a][i % 10] ++;
    }
    long long tot = 0;
    for (int i = 1; i <= n; i ++)
    {
        int a = i;
        while (a >= 10)
            a /= 10;
        tot += C[i % 10][a];
    }
    return !printf("%lld\n", tot);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

int main(){
    int n;
    std::cin>>n;
    std::vector<int> a(n),b(n);
    std::vector<std::pair<long long,int>> c(n);
    for(size_t i = 0; i < n; i++)
    {
        std::cin>>a[i]>>b[i];
        c[i]=std::make_pair(a[i]+b[i],i);
    }
    using plli=std::pair<long long,int>;
    std::sort(c.begin(),c.end(),[](plli a,plli b){return a.first>b.first;});


    long long ans=0;
    for(size_t i = 0; i < n; i++)
    {
        if(i%2==0){
            ans+=a[c[i].second];
        }
        else{
            ans-=b[c[i].second];
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int x,n;
    cin >> x >> n;
    if(n==0){
    	cout << x << endl;
    	return 0;
	}
	vector<int> p(n);
	
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	
	int l=0,r=0;
	for(int k=x;k>=-10;k--){
		int f=1;
		for(int i=0;i<n;i++){
			if(k==p[i]){
				f=0;
				break;
			}
		}
		if(f) {
			l=k;
			break;
		}
	}
	
	for(int k=x;k<=110;k++){
		int f=1;
		for(int i=0;i<n;i++){
			if(k==p[i]){
				f=0;
				break;
			}
		}
		if(f) {
			r=k;
			break;
		}
	}
	
	if(x-l<=r-x){
		cout << l << endl;
	} else {
		cout << r << endl;
	}
	
    return 0;
} 



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};
Node T[MAX];
int n, D[MAX];

void print(int id) {
    cout << "node " << id << ": ";
    cout << "parent = " << T[id].p << ", ";
    cout << "depth = " << D[id] << ", ";

    if (T[id].p == NIL) cout << "root, ";
    else if (T[id].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    int childId = T[id].l;
    while (childId != NIL) {
        cout << childId;
        childId = T[childId].r;
        if (childId != NIL) cout << ", ";
    }
    cout << "]" << endl;
}

void setDepth(int id, int depth) {
    D[id] = depth;
    // 右の兄弟に同じ深さを設定
    if (T[id].r != NIL) setDepth(T[id].r, depth);
    // 最も左の子に自分の深さ+1を設定
    if (T[id].l != NIL) setDepth(T[id].l, depth+1);
}

int main() {
    cin >> n;
    // 初期化
    for (int i = 0; i < n; i++) {
        T[i].p = T[i].l = T[i].r = NIL;
    }

    for (int i = 0; i < n; i++) {
        int id, k, prevChildId;
        Node t;
        cin >> id >> k;
        for (int j = 0; j < k; j++) {
            int childId;
            cin >> childId;
            T[childId].p = id;
            // 一番左の子
            if (j == 0) T[id].l = childId;
            // それ以外の子
            else T[prevChildId].r = childId;
            prevChildId = childId;
        }
    }

    int rootId;
    for (int i = 0; i < n; i++) {
        // 親が存在しないNodeがroot
        if (T[i].p == NIL) rootId = i;
    }
    setDepth(rootId, 0);

    for (int i = 0; i < n; i++) {
        print(i);
    }

    return 0;
}


Measured memory_bytes: 7704
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		 Scanner s=new Scanner(System.in);
      int n=s.nextInt();
      int m=s.nextInt();
      System.out.format("%.10f",(double)n/m);
	}
}


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


namespace Test1 {

    


    class ClassMain {

       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);

                int[] cards = Enumerable.Range(1, 2 * n).ToArray();

                int m = int.Parse(Console.ReadLine());
                for (int i = 0; i < m; i++) {
                    //Console.WriteLine(string.Join(",", cards));
                    int k = int.Parse(Console.ReadLine());
                    if (k == 0) {
                        //rifuru
                        int[] nexCards = new int[2 * n];
                        for (int j = 0; j < 2 * n; j++) {
                            if (j % 2 == 0) {
                                nexCards[j] = cards[j / 2];
                            }
                            else {
                                nexCards[j] = cards[(j / 2) + n];
                            }
                        }
                        cards = nexCards;
                    }
                    else {
                        //cut
                        int[] nexCards = new int[2 * n];
                        for (int j = 0; j < 2 * n; j++) {
                            if ( j < k) {
                                nexCards[2*n-k+j] = cards[j];
                            }
                            else {
                                nexCards[j-k] = cards[j];
                            }
                        }
                        cards = nexCards;
                    }

                }

                for (int i = 0; i < 2 * n; i++) {
                    Console.WriteLine(cards[i]);
                }
                break;
            }
        }

        
    }



    
}

Measured memory_bytes: 5948
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
// clang-format on

main {
  int n, a, b;
  cin >> n >> a >> b;
  vi v(n);
  rep(i, n) cin >> v[i];
  sort(rall(v));
  cout << prec(32) << 1.0 * accumulate(v.begin(), v.begin() + a, 0LL) / a << endl;
  int m = a - 1;
  int t = v[m];
  int c = count(all(v), t);
  int l = m - distance(v.begin(), find(all(v), t)) + 1;
  vvi dp(51, vi(51));
  dp[0][0] = 1;
  rep(i, 51) rep(j, 51) {
    if (i > 0) dp[i][j] += dp[i - 1][j];
    if (j > 0) dp[i][j] += dp[i][j - 1];
  }
  auto nCr = [&](int n, int r) { return dp[n - r][r]; };
  if (v.front() == t) {
    int s = 0;
    loop(i, a, min(c, b) + 1) s += nCr(c, i);
    cout << s << endl;
  } else {
    cout << nCr(c, l) << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c;

	cin >> a >> b >> c;

	if(a>b){
		swap(a,b);
	}
	if(b>c){
		swap(b,c);
	}
	if(a>b){
		swap(a,b);
	}
	cout << a << " " << b << " " << c << endl;
	
	return 0;
}

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

constexpr int INF = 1e8;

int main() {
    int N, A[3];
    cin >> N >> A[0] >> A[1] >> A[2];
    vector<int> idx(N);
    iota(idx.begin(), idx.end(), 0);
    int repr[3] = {};
    for(int i=0; i<3; ++i) {
        vector<int> tmp(A[i]);
        for(int j=0; j<A[i]; ++j) {
            cin >> tmp[j];
            tmp[j]--;
        }
        sort(tmp.begin(), tmp.end());
        repr[i] = tmp[0];
        for(int j=1; j<A[i]; ++j) {
            idx[tmp[j]] = tmp[0];
        }
    }
    int M;
    cin >> M;
    vector<vector<int>> g(N);
    for(int i=0; i<M; ++i) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[idx[x]].push_back(idx[y]);
        g[idx[y]].push_back(idx[x]);
    }
    vector<vector<int>> d(3, vector<int>(N, INF)), mi(3, vector<int>(N));
    for(int i=0; i<3; ++i) {
        iota(mi[i].begin(), mi[i].end(), 0);
    }
    for(int i=0; i<3; ++i) {
        int s = repr[i];
        d[i][s] = 0;
        mi[i][s] = s;
        queue<int> que;
        que.push(s);
        while(!que.empty()) {
            int v = que.front();
            que.pop();
            for(auto to : g[v]) {
                if(d[i][to] >= d[i][v] + 1) {
                    mi[i][to] = min(mi[i][to], mi[i][v]);
                }
                if(d[i][to] == INF) {
                    que.push(to);
                    d[i][to] = d[i][v] + 1;
                }
            }
        }
    }
    vector<int> d2(N), mi2(N, INF);
    int resd = INF, resid = INF;
    for(int i=0; i<N; ++i) {
        for(int j=0; j<3; ++j) {
            d2[i] += d[j][i];
            mi2[i] = min(mi2[i], mi[j][i]);
        }
        if(resd > d2[i]) {
            resd = d2[i];
            resid = mi2[i];
        }
        if(resd == d2[i]) {
            resid = min(resid, mi2[i]);
        }
    }
    cout << resd << ' ' << resid+1 << endl;
}


Measured memory_bytes: 9020
from heapq import heappush, heappop, heapify

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()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort()

P = P[:X]
Q = Q[:Y]

heapify(P)
heapify(Q)

for i in range(C):
    p = heappop(P)
    q = heappop(Q)
    if p <= q:
        heappush(Q, q)
        if R[i] >= p:
            heappush(P, R[i])
        else:
            heappush(P, p)
    else:
        heappush(P, p)
        if R[i] >= q:
            heappush(Q, R[i])
        else:
            heappush(Q, q)

print(sum(P) + sum(Q))

Measured memory_bytes: 116688
open Hashtbl

let id x = x
let n = Scanf.scanf "%d\n" id
let h = create 100

let f n =
  let rec g n' =
    if n' = 0 then ()
    else
      let a = Scanf.scanf "%d " id in
      let v = try find h a with _ -> 0 in
      let v' = try find h (a - 1) with _ -> 0 in
      let v'' = try find h (a + 1) with _ -> 0 in
      replace h a (v + 1) ;
      replace h (a - 1) (v' + 1) ;
      replace h (a + 1) (v'' + 1) ;
      g (n' - 1)
  in
  g n

let () =
  f n ;
  fold (fun _ v tmp -> max v tmp) h 0 |> Printf.printf "%d\n"

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;


int main() {
  int a,b,ans_s,ans_r;
  cin >> a >> b;
  ans_r = 2*(a+b);
  ans_s = a*b;
  cout << ans_s << " " << ans_r << endl;
  return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	int n;
	scanf("%lld", &n);
	if(n%2 == 0)printf("%lld\n", n);
	else printf("%lld\n", 2*n);
	return 0;
}






Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import math

a, b, h, m = [int(i) for i in input().split()]

m_angle = m / 60 * 360
h_angle = (h / 12 * 360) + (m / 60 * 30)

if abs(m_angle - h_angle) >= 180:
    theta = 360 - abs(m_angle - h_angle)
else:
    theta = abs(m_angle - h_angle)

if theta == 0:
    x = abs(a - b)
elif theta == 180:
    x = a + b
else:
    x2 = a**2 + b**2 - 2*a*b * math.cos(math.radians(theta))
    x = x2**0.5

print(x)

Measured memory_bytes: 9524
//include
//------------------------------------------
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

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

#define INF (1<<21)

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//typedef
//-------------------------------------------
typedef long long ll;
typedef pair<int, int> doll;

vector<doll> dolls;
int dp[200];

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

    while(1) {
        int n, m;
        cin >> n;
        if (!n) break;

        dolls.clear();
        REP(i, n) {
            int h, r;
            cin >> h >> r;
            dolls.push_back(doll(h, r));
        }
        cin >> m;
        REP(i, m) {
            int h, r;
            cin >> h >> r;
            dolls.push_back(doll(h, r));
        }
        sort(dolls.begin(), dolls.end());
        memset(dp, 0, sizeof(dp));
        int res = 0;

        REP(i, dolls.size()) {
            dp[i] = 1;
            REP(j, i) {
                if (dolls[j].first < dolls[i].first && dolls[j].second < dolls[i].second) {
                    dp[i] = max(dp[i], dp[j] + 1);
                }
                res = max(res, dp[i]);
            }
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>

int main(void)
{
    int N, X;
    char c;
    float F1, F2;
    
    
    scanf("%d%c", &N, &c);
    
    
    F1 = (float)N/1.08;
    F2 = (float)(N+1)/1.08;
    
    
    if(F1 > (int)F1 && F2 > (int)F2 && (int)F2 > (int)F1)
    {
        printf("%d\n", (int)F2);
    }
    else if(F1 == (int)F1)
    {
        printf("%d\n", (int)F1);
    }
    else
    {
        printf(":(\n");
    }
    
    
    //system("pause");
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;


int main(){
  vector<int> a(2); rep(i,2) cin >> a[i];

  if(a[0] != 1 && a[1] != 1) cout << 1 << endl;
  if(a[0] != 2 && a[1] != 2) cout << 2 << endl;
  if(a[0] != 3 && a[1] != 3) cout << 3 << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char c;

	while((c = getchar ()) != '\n')
	{
		if((c >= 'A') && (c <= 'Z'))
			c += 'a' - 'A';
		else if((c >= 'a') && (c <= 'z'))
			c -= 'a' - 'A';
		putchar(c);
	}
	printf("\n");

	return 0;
}

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

int main(){
  int N,Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> l(Q);
  vector<int> r(Q);
  for(int i=0; i<Q; i++) cin >> l.at(i) >> r.at(i);
  vector<int> P(N);
  int cnt=0;
  for(int i=1; i<N; i++){
    if(S.at(i-1)=='A' && S.at(i)=='C') cnt++;
    P.at(i)=cnt;
  }

  for(int i=0; i<Q; i++){
    int ans=P.at(r.at(i)-1)-P.at(l.at(i)-1);
    cout << ans << endl;
  }
}

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

int main() {
  int n,w;
  cin >> n >> w;
  vector<int> weight(n);
  vector<ll> value(n);
  for(int i = 0; i < n; i++){
    cin >> weight[i] >> value[i];
  }
  ll dp[n+1][w+1] = {};
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= w; j++){
      if(j >= weight[i]){
        dp[i+1][j] = dp[i][j-weight[i]] + value[i];
      }
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}

Measured memory_bytes: 79104
N=int(input())
a=list(map(int,input().split()))

print(2*N-2)
aa=list(map(abs,a))
nmax=aa.index(max(aa))
for i in range(N):
  if i==nmax:
    pass
  else:
    print("{} {}".format(nmax+1,i+1))
if a[nmax]>0:
  for i in range(N-1):
    print("{} {}".format(i+1,i+2))
else:
  for i in range(N-1):
    print("{} {}".format(N-i,N-i-1))


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

typedef long long LL;
typedef unsigned long long ULL;
const int N = 16384, mod = 998244353;

int pow(int x, int y, int ans = 1) {
	for (; y; y >>= 1, x = (LL) x * x % mod)
		if (y & 1) ans = (LL) ans * x % mod;
	return ans;
}
int n, m, dp[2][N], ans, c = 1, e[N], factor[N], ifactor[N];

int w[N], wn[N], lim, s, rev[N];
void fftinit(int len) {
	wn[0] = lim = 1, s = -1; while (lim < len) lim <<= 1, ++s;
	for (int i = 0; i < lim; ++i) rev[i] = rev[i >> 1] >> 1 | (i & 1) << s;
	const int g = pow(3, (mod - 1) / lim);
	for (int i = 1; i < lim; ++i) wn[i] = (LL) wn[i - 1] * g % mod;
}
void fft(int *A, int typ) {
	static ULL tmp[N];
	for (int i = 0; i < lim; ++i) tmp[rev[i]] = A[i];
	for (int i = 1; i < lim; i <<= 1) {
		for (int j = 0, t = lim / i / 2; j < i; ++j) w[j] = wn[j * t];
		for (int j = 0; j < lim; j += i << 1)
			for (int k = 0; k < i; ++k) {
				const ULL x = tmp[k + j + i] * w[k] % mod;
				tmp[k + j + i] = tmp[k + j] + mod - x, tmp[k + j] += x;
			}
	}
	for (int i = 0; i < lim; ++i) A[i] = tmp[i] % mod;
	if (!typ) {
		const int il = pow(lim, mod - 2); std::reverse(A + 1, A + lim);
		for (int i = 0; i < lim; ++i) A[i] = (LL) A[i] * il % mod;
	}
}

void init(int n) {
	factor[0] = 1;
	for (int i = 1; i <= n; ++i) factor[i] = (LL) factor[i - 1] * i % mod;
	ifactor[n] = pow(factor[n], mod - 2);
	for (int i = n; i; --i) ifactor[i - 1] = (LL) ifactor[i] * i % mod;
	n -= 2, fftinit(n + n + 1), std::memcpy(e + 1, ifactor + 3, n << 2), fft(e, 1);
}
int c2(int n) { return (LL) n * (n - 1) / 2 % mod; }
void transform(int *a, int *b) {
	static int c[N];
	std::memcpy(c, a, n + 1 << 2);
	for (int i = 0; i <= n; ++i)
		a[i] = (LL) a[i] * ifactor[i] % mod;
	fft(a, 1);
	for (int i = 0; i < lim; ++i)
		b[i] = (LL) a[i] * e[i] % mod;
	fft(b, 0);
	for (int i = 0; i <= n; ++i)
		b[i] = ((LL) b[i] * factor[i + 2] + (LL) c[i] * (c2(i + 1) + 1)) % mod;
	std::memset(b + n + 1, 0, lim - n - 1 << 2);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m, dp[0][0] = 1, init(n + 2);
	for (int i = 1; i <= m; ++i) transform(dp[i & 1 ^ 1], dp[i & 1]);
	for (int i = 0; i <= n; ++i) {
		ans = (ans + (LL) c * dp[m & 1][i]) % mod;
		c = (LL) pow(i + 1, mod - 2, n - i) * c % mod;
	}
	std::cout << ans << '\n';
	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

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

int main() {
	ll a, b, v, w, t;
	cin >>a>>v>>b>>w>>t;
	if (a == b) {
		cout <<"YES\n";
	} else if (v <= w) {
		cout <<"NO\n";
	} else {
		ll x = (v-w)*t;
		if (x >= abs(a-b)) cout <<"YES\n";
		else cout <<"NO\n";
	}
	return 0;
}

Measured memory_bytes: 3528
package main

import (
	"fmt"
)

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	if A%2 == 0 || B%2 == 0 || C%2 == 0 {
		fmt.Println(0)
	} else {
		ans := min(B*C, C*A, A*B)
		fmt.Println(ans)
	}
}

func min(a ...int) (r int) {
	r = a[0]
	for _, n := range a {
		if r > n {
			r = n
		}
	}
	return r
}


Measured memory_bytes: 512
import math
class Point(object):
     def __init__(self, x,y):
          self.x = x*1.0
          self.y = y*1.0
def Koch(n,p1,p2):
    s=Point((2*p1.x+p2.x)/3,(2*p1.y+p2.y)/3)
    t=Point((p1.x+2*p2.x)/3,(p1.y+2*p2.y)/3)
    u=Point((t.x-s.x)*math.cos(math.radians(60))-(t.y-s.y)*math.sin(math.radians(60))+s.x,(t.x-s.x)*math.sin(math.radians(60))+(t.y-s.y)*math.cos(math.radians(60))+s.y)
    if n==0:
        return
    Koch(n-1,p1,s)
    print s.x,s.y
    Koch(n-1,s,u)
    print u.x,u.y 
    Koch(n-1,u,t)
    print t.x,t.y
    Koch(n-1,t,p2)
n=input()
p1=Point(0,0)
p2=Point(100,0)
print p1.x,p1.y
Koch(n,p1,p2)
print p2.x,p2.y


Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read(), A = read(), B = read();
    printf("%d\n", min(N*A, B));
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

typedef pair<int, int> cand;

cand maximize(cand c1, cand c2)
{
	return make_pair(max(c1.first, c2.first), max(c1.second, c2.second));
}
cand minimize(cand c1, cand c2)
{
	return make_pair(min(c1.first, c2.first), min(c1.second, c2.second));
}

int Q;
char in_[1010];
int p;
string in;

char val(int p)
{
	if (p >= in.size()) return 'w';
	return in[p];
}
cand parse()
{
	if (val(p) == '^' || val(p) == '_') {
		bool ismax = (val(p) == '^');
		++p;
		++p;
		cand a = parse();
		++p;
		cand b = parse();
		++p;
		return (ismax ? maximize(a, b) : minimize(a, b));
	}
	if (val(p) >= '0' && val(p) <= '9') {
		++p;
		if (val(p - 1) == '0') {
			return{ 0, 0 };
		}
		if (val(p) >= '0' && val(p) <= '9') {
			++p;
			int a = (val(p - 2) - '0') * 10 + (val(p - 1) - '0');
			return{ a, a };
		}
		if (val(p) == 'w') {
			++p;
			int a = (val(p - 2) - '0');
			return{ a, 10 * a + 9 };
		}
		int a = (val(p - 1) - '0');
		return{ a, a };
	}
	return{ 0, 99 };
}

bool check(int L)
{
	in.clear();
	for (int i = 0; i < L; ++i) in.push_back(in_[i]);
	p = 0;
	cand a = parse();
	return a.first == a.second;
}

int main()
{
	scanf("%d", &Q);
	for (; Q--;) {
		scanf("%s", in_);
		int L = strlen(in_);
		int left = 0, right = L;
		while (left < right) {
			int mid = (left + right) / 2;
			if (check(mid)) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}
		in = in_;
		p = 0;
		cand a = parse();
		printf("%d %d\n", a.first, left);
	}
	return 0;
}


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

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

    if(s == "hi" || s == "hihi"|| s == "hihihi" || s == "hihihihi" || s == "hihihihihi") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall as wf

H, W = map(int, input().split())
C = [[int(i) for i in input().split()] for i in range(10)]
A = [[int(i) for i in input().split()] for i in range(H)]

B = wf(C)

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1:
            continue
        ans += B[A[i][j]][1]
        
print(int(ans))

Measured memory_bytes: 14060
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Remoting.Contexts;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray(int n)
        {
            var array = Array();
            var result = new int[n];
            for (int i = 0; i < n; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }


        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        public uint NextUint()
        {
            return uint.Parse(Next());
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.IntArray();
        }

        public void Solve()
        {
            Scan();
            int cnt = 0;
            for (int i = 1; i < N; i++)
            {
                if (A[i - 1] == A[i])
                {
                    A[i] = 1000;
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }

        static void Main() => new Program().Solve();
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<numeric>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;


Int final_pos[13][550000];
Int end_person[13][550000];
Int pos_significant[550000];

Int n3[13];

int main(){
    int n, m;
    string t;

    n3[0] = 1;
    for(int i = 1;i < 13;i++)n3[i] = n3[i-1] * 3;
    
    cin >> n;
    cin >> t;
    m = t.size();

    for(int i = 1;i <= n;i++){
        Int sls = 0;
        for(int j = 0;j < n3[i-1];j++){
            pos_significant[j] = 0;
            pos_significant[j + n3[i-1]] = 1;
            pos_significant[j + 2*n3[i-1]] = 2;
            final_pos[i][j] = final_pos[i-1][j];
            final_pos[i][j + n3[i-1]] = final_pos[i-1][j];
            final_pos[i][j + n3[i-1] * 2] = final_pos[i-1][j];
        }
        for(int j = 0;j < t.size();j++){
            char c = t[j];
            end_person[i][j] = end_person[i-1][j];
            int great = (sls % 2 == 0) ? 2 : 1;
            if(pos_significant[end_person[i-1][j]] == great)end_person[i][j] += n3[i-1] * 0;
            if(pos_significant[end_person[i-1][j] + n3[i-1]] == great)end_person[i][j] += n3[i-1] * 1;
            if(pos_significant[end_person[i-1][j] + n3[i-1] * 2] == great)end_person[i][j] += n3[i-1] * 2;
            if(c == 'S'){
                sls++;
            }
            else{
                int add = (sls % 2 == 0) ? 1 : 2;
                (pos_significant[end_person[i-1][j]] += add)%=3;
                (pos_significant[end_person[i-1][j] + n3[i-1]] += add)%=3;
                (pos_significant[end_person[i-1][j] + n3[i-1] * 2] += add)%=3;
            }
        }
        for(int j = 0;j < n3[i];j++){
            if(sls % 2 == 0)
                final_pos[i][j] += pos_significant[j] * n3[i-1];
            else
                final_pos[i][j] += (3-pos_significant[j])%3 * n3[i-1];
        }
    }

    for(int i = 0;i < n3[n];i++){
        cout << final_pos[n][i] << " ";
    }cout << endl;
    
    return 0;
}

Measured memory_bytes: 33696
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    if(abs(x) / d > k){
        if(x > 0){
            cout << abs(x - k * d) << endl; //3
        }else{
            cout << abs(x + k * d) << endl;
        }
    }else{
        ll step = abs(x) / d;
        if (x > 0) {
            if((k-step)%2){
                cout << abs(x - step * d - d) << endl;  //1
            }else{
                cout << abs(x - step * d) << endl;  //2
            }
        } else {
            if ((k - step) % 2) {
                cout << abs(x + step * d + d) << endl;
            } else {
                cout << abs(x + step * d) << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  double w,h,x,y;cin >>w >> h >> x >> y;
  if(w/2==x&&h/2==y){cout << w*h/2 << " " << 1 << endl;return 0;}
  else if(w/2==x||h/2==y){cout << w*h/2 << " " << 0 << endl;return 0;}
  else cout << w*h/2 << " " << 0 << endl;
}


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

typedef long double ld;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  ld s = (ld) n / 3.0;
  cout << fixed << setprecision(12) << s * s * s << '\n';  
  return 0;
}

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  cout << (M1 + 1 == M2 ? 1 : 0) << endl;
}


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

void input(llong& rnLow, llong& rnHigh, int& rnDivsor1, int& rnDivsor2)
{
  cin >> rnLow >> rnHigh >> rnDivsor1 >> rnDivsor2;
}

llong countAntiDiv(llong nNum, int nDivsor1, int nDivsor2)
{
  static llong stnDivLcm = 0;

  if (!stnDivLcm)
  {
    int nDividend = max(nDivsor1, nDivsor2);
    int nDivisor  = min(nDivsor1, nDivsor2);

    while (nDividend % nDivisor)
    {
      int nRemndr = nDividend % nDivisor;
      nDividend = nDivisor;
      nDivisor  = nRemndr;
    }
    stnDivLcm = (llong)nDivsor1 * (nDivsor2 / nDivisor);
  }
  llong nDiv1Cnt = nNum / nDivsor1;
  llong nDiv2Cnt = nNum / nDivsor2;
  llong nDLcmCnt = nNum / stnDivLcm;

  return nNum - (nDiv1Cnt + nDiv2Cnt - nDLcmCnt);
}
  
int main()
{
  llong nLow, nHigh;
  int nDivsor1, nDivsor2;

  input(nLow, nHigh, nDivsor1, nDivsor2);
  cout << countAntiDiv(nHigh, nDivsor1, nDivsor2) - countAntiDiv(nLow - 1, nDivsor1, nDivsor2);
  cout << endl;

  return 0;
}

Measured memory_bytes: 3628
using System; 
using System.Text; 
using System.Collections.Generic;
using System.Linq; 
using E = System.Linq.Enumerable; 

class Program {
     static long waru = 1000000007;
     static void Main(string[] args) {
     //入力を受け取る
     var S = Console.ReadLine();
     var T = Console.ReadLine();
     
     var Sdic = new Dictionary<char,int>();
     var Tdic = new Dictionary<char,int>();
     
     for(int i = 0;i < S.Length;i++){
         if(Sdic.ContainsKey(S[i])){
             Sdic[S[i]] += 1;
         }else{
             Sdic.Add(S[i],1);
         }
         if(Tdic.ContainsKey(T[i])){
             Tdic[T[i]] += 1;
         }else{
             Tdic.Add(T[i],1);
         }         
     }
     
     var SortS = Sdic.Values.ToArray();
     Array.Sort(SortS);
     var SortT = Tdic.Values.ToArray();
     Array.Sort(SortT);
     
     var flag = true;
     for(int i = 0;i < SortS.Length;i++){
         if(SortS[i] != SortT[i]){
             flag = false;
             break;
         }
     }
     
     if(flag){
         Console.WriteLine("Yes");
     }else{
         Console.WriteLine("No");
     }
     
     }
     
}
     
     
     
     
     


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

#define mod 1000000007
#define maxn 200005

typedef pair<ll, ll> P;

//bool cmp(P p1, P p2) { return p1.first == p2.first ? p1.second > p2.second : p1.first < p2.first; }

ll n, x, d;
map<int, vector<P>> mp;

int main()
{
    cin >> n >> x >> d;
    if (d == 0)
    {
        cout << ((x == 0) ? 1 : n + 1) << endl;
        return 0;
    }
    if (d < 0)
        x = -x, d = -d;
    for (ll i = 0; i <= n; i++)
    {
        ll gp = i * x % d;
        ll l = i * x + i * (i - 1) / 2 * d;
        ll r = i * x + (i * n - i * (i + 1) / 2) * d;
        mp[gp].push_back(P((l - gp) / d, (r - gp) / d));
    }
    ll ans = 0;
    for (auto iter = mp.begin(); iter != mp.end(); iter++)
    {
        vector<P> &v = iter->second;
        if (v.empty())
            continue;
        sort(v.begin(), v.end());
        ll l = v[0].first;
        ll r = v[0].second;
        for (int j = 1; j <= v.size(); j++)
        {
            if (j == v.size())
            {
                ans += (r - l + 1);
                break;
            }
            if (v[j].first > r)
            {
                ans += (r - l + 1);
                l = v[j].first;
                r = v[j].second;
            }
            else
                r = max(r, v[j].second);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0}, dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	ll p = n;
	map<ll, ll> mp;
	repl(i, 2, sqrt(p) + 1) {
		while (p % i == 0) {
			p /= i;
			mp[i]++;
		}
	}
	if (p > 1) mp[p]++;
	int ans = 0;
	ll a[100000];
	rep(i, 100000) a[i] = (i + 1) * i / 2;
	for (auto p : mp) ans += upper_bound(a, a + 100000, p.second) - a - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4456
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

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

	INT s1 = 2, s3 = 1;

	for (size_t i = 1; i < l.length(); i++)
	{
		s3 *= 3;
		if (l[i] == '1')
		{
			s3 += s1;
			s1 *= 2;
		}
		s1 %= 1000000007;
		s3 %= 1000000007;
	}

	cout << (s1 + s3) % 1000000007 << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
int d=scan.nextInt();
System.out.println(Math.max(a*b,c*d));
}
}


Measured memory_bytes: 10196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
double a[100010];

int main(){
	cin >> n;
	REP(i, n) cin >> a[i];
	double sum = 0;
	REP(i, n) sum += a[i];
	sum /= n;
	printf("%.lf\n", sum);
}

Measured memory_bytes: 1320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int[] ary = new int[N];
		for(int i=0; i<N; i++) {
			ary[i] = sc.nextInt();
		}
		sc.close();
		int d;
		for(int i=0; i<N; i++) {
			d = 0;
			for(int j=1; d<D; j++) {
				d = j*ary[i];
				X++;
			}
		}
		
		System.out.println(X);
	}

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  int m = n;
  int digit = 0;
  while(m)digit += (m%10),m/=10;
  (n%digit) ? cout << "No" << endl : cout << "Yes" << endl;


  

  return 0;
}


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

long long root(long long n){
    long long ret = pow((long double)n, 0.5L);
    while(ret*ret > n) ret--;
    while((ret+1)*(ret+1) <= n) ret++;
    return ret;
}

int main(){
    long long i, j, k;
    int Q;
    cin >> Q;
    for(i=0; i<Q; i++){
        long long A, B;
        cin >> A >> B;
        if(A>B) swap(A, B);
        long long R = root(A*B-1);
        long long ans = A-1 + max(R-A, 0LL) + (A*B-1)/(R+1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class COneQuadrillionAndOneDalmatians {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;in>>n;
        string res = "";
        --n;
        while(n>=0){
            char c = (n%26)+'a';
            res.push_back(c);
            n/=26;
            --n;
        }
        reverse(all(res));
        out<<res<<endl;
	}
};


int main() {
	COneQuadrillionAndOneDalmatians solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3108
program main
  implicit none
  integer :: a, b, c, i
  read(*, *) a, b, c
  do i = 1, 100
    if (mod(a * i, b) == c) then
      write(*, "(a)") "YES"
      stop
    end if
  end do
  write(*, "(a)") "NO"
end program main


Measured memory_bytes: 256
# Problem B - 1 Dimensional World's Tale

# input
N, M, X, Y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

# initialization
is_ok = True
x_koho = [X]
y_koho = [Y]

# x select
for x in x_list:
    if x>=X:
        x_koho.append(x)

# y select
for y in y_list:
    if y<=Y:
        y_koho.append(y)

x_max = max(x_koho)
y_min = min(y_koho)

# output
if y_min-x_max>0:
    print("No War")
else:
    print("War")


Measured memory_bytes: 38384