akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N,K;
  cin>>N>>K;
  if(K%2 == 1)
  {
    cout<<(int)pow((N/K),3);
  }
  else
  {
    int M = N/K;
    int M2 = N/K + ((N%K)>=(K/2));
    int ANS = 0;
    ANS += pow(M,3);
    ANS += pow(M2,3);
    cout<<ANS<<endl;
  }
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<long long> a (n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = k; i < n; i++){
    if(a[i] > a[i-k]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4756
#include <iostream>

using namespace std;

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

    int qtd, max;
    int a, b;
    int aux = 0;

    cin >> qtd >> max;
    int menor = 1000;

    while (qtd--) {
        cin >> a >> b;
        if (b <= max) {
            aux = 1;
            if (a < menor) {
                menor = a;
            }
        }
    }

    if (aux == 0) {
        cout << "TLE" << endl;
    }
    else {
        cout << menor << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.*;
import java.util.*;
 
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
		long number = Long.parseLong(sc.next());
      	long constNum = Long.parseLong(sc.next());
      	long answer=number%constNum;
      	while(true){
        	long afterNum=Math.abs(answer-constNum);
          	if(answer<=afterNum){
              	break;
            }
          	answer=afterNum;
        }
      System.out.println(answer);
    }
}

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

vector<int> graph[10];
vector<bool> visit(10, false);
int n, cnt = 0;

bool check(void)
{
	rep(i, n)
	{
		if (!visit[i])
			return false;
	}
	return true; 
}

void dfs(int v, int p = -1)
{
	if (check()) 
	{
		cnt++;
		return;
	}
	for(int i = 0; i < graph[v].size(); i++)
	{
		if (graph[v][i] == p) continue;
		if (visit[graph[v][i]]) continue;
		visit[graph[v][i]] = true;
		dfs(graph[v][i], v);
		visit[graph[v][i]] = false;
	}
}

signed main(void)
{
	int m; 
	cin >> n >> m;
	rep(i, m)
	{
		int x, y;
		cin >> x >> y;
		x--; y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	visit[0] = true;
	dfs(0);
	cout << cnt << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N;
    string S;
    cin >> N >> S;

    int r = 0, b = 0;
    for (auto &i : S) {
        if (i == 'R') r++;
        else b++;
    }

    cout << (b < r? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
Imports System

Module Program
    Sub Main(args As String())

        Dim N As Integer = Integer.Parse(Console.ReadLine())
        Dim c As String = Console.ReadLine()
        Dim r As Integer = 0
        Dim w As Integer = 0
        Dim bw As Integer = 0
        Dim ar As Integer = 0
        Dim ans As Integer = 0

        For i As Integer = 0 To N - 1
            If c(i) = "R" Then
                r += 1
            Else
                w += 1
            End If
        Next

        If r = 0 Or w = 0 Then
            ans = 0
        Else
            Dim i As Integer = 0
            Dim j As Integer = N - 1
            Do
                Dim we As Boolean = False
                Do
                    If c(i) = "W" Then
                        we = True
                        Exit Do
                    End If
                    If i >= j Then Exit Do
                    i += 1
                Loop
                Dim re As Boolean = False
                Do
                    If c(j) = "R" Then
                        re = True
                        Exit Do
                    End If
                    If i >= j Then Exit Do
                    j -= 1
                Loop
                If i < j AndAlso we And re Then
                    ans += 1
                    i += 1
                    j -= 1
                End If
                If i >= j Then Exit Do
            Loop
        End If

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 38416
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let sc: Vec<char> = s.chars().collect();
    for i in 0..sc.len() {
        let si = sc[i];
        if si == '9' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

using namespace std;

int main()
{
  long long int n, temp = 0;
  scanf("%lld", &n);
  while(1){
    temp = n;
    long long int x = sqrt(temp);
    x *= x;
    if(x == temp) break;
    n--;
  }
  printf("%lld\n", temp);
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <map>


const int mod = 1000000007;
//const int mod = 998244353;
int maximum(int a, int b) { return a < b ? b : a; }
int main() {
	int N;
	scanf("%d", &N);
	auto s = new char[N][11];
	for (int i = 0; i < N; i++)scanf("%s", s[i]);
	auto S = new std::string[N];
	for (int i = 0; i < N; i++)S[i] = s[i];
	std::sort(S, S + N);
	auto n = new int[N] {};
	n[0] = 1;
	int max = 1;
	for (int i = 1; i < N; i++) {
		if (S[i - 1] == S[i])n[i] = n[i - 1] + 1;
		else n[i] = 1;
		if (n[i] > max)max = n[i];
	}
	for (int i = 0; i < N; i++) {
		if (n[i] == max)printf("%s\n", S[i].c_str());
	}
	return 0;
}

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

int main()
{
    ll n, a,b;
    cin >> n>> a>> b;;
    ll c=a+b, q,r;
    q = n/c;
    r = n%c;
    ll ans;
    ans = q* a;
    if(r < a)
        ans+=r;
    else
        ans+=a;
    
    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

class ModCombination
  attr_reader :fac, :inv, :finv, :mod

  def initialize(n, mod: MOD)
    @mod = mod
    @fac = [1, 1]
    @inv = [1, 1]
    @finv = [1, 1]

    (2..n).each do |i|
      @fac[i] = fac[i - 1] * i % mod
      @inv[i] = mod - inv[mod % i] * (mod / i) % mod
      @finv[i] = finv[i - 1] * inv[i] % mod
    end
  end

  def combination(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0

    fac[n] * (finv[k] * finv[n - k] % mod) % mod
  end

  def repeated_combination(n, k)
    combination(n + k - 1, k)
  end
end

N, K = gets.split.map(&:to_i)
MI = ModCombination.new(2 * N)

1.upto(K) do |i|
  puts (MI.combination(N - K + 1, i) * MI.combination(K - 1, i - 1)) % MOD
end


Measured memory_bytes: 1916
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int x = (a + b + 1) / 2;
        out.printf("%d\n", x);
        out.flush();
    }
}

Measured memory_bytes: 21716
import sys
# from collections import deque, defaultdict, Counter
# from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
# from itertools import permutations, combinations, product
# from operator import itemgetter, mul
# from copy import deepcopy
# from string import ascii_lowercase, ascii_uppercase, digits
# from numpy.fft import fft, ifft
# from fractions import gcd
# import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
S = [input() for _ in range(H)]

L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			L[i][j] = 0
		elif j == 0:
			L[i][j] = 1
		else:
			L[i][j] = L[i][j-1] + 1

for i in range(H):
	for j in range(W-1, -1, -1):
		if S[i][j] == '#':
			R[i][j] = 0
		elif j == W-1:
			R[i][j] = 1
		else:
			R[i][j] = R[i][j+1] + 1

for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			U[i][j] = 0
		elif i == 0:
			U[i][j] = 1
		else:
			U[i][j] = U[i-1][j] + 1

for i in range(H-1, -1, -1):
	for j in range(W):
		if S[i][j] == '#':
			D[i][j] = 0
		elif i == H-1:
			D[i][j] = 1
		else:
			D[i][j] = D[i+1][j] + 1

# L = np.array(L)
# R = np.array(R)
# U = np.array(U)
# D = np.array(D)

ans = 0
for i in range(H):
	for j in range(W):
		ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)

print(ans)
# print((L+R+U+D).max()-3)


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



int main() {
    stack<int> S;
    int a, b;
    string s;
    // int cnt = 0;

    while (cin >> s) {
        // cout << "loop " << cnt << endl;
        // cout << s << endl;
        // cnt++;
        if (s[0] == '+') {
            // cout << "+" << endl;
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a + b);
            // cout << "a + b = " << S.top() << endl;
        }
        else if (s[0] == '-') {
            // cout << "-" << endl;
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a - b);
            // cout << "a - b = " << S.top() << endl;
        }
        else if (s[0] == '*') {
            // cout << "*" << endl;
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a * b);
            // cout << "a * b = " << S.top() << endl;
        }
        else {
            // cout << "push" << endl;
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
//#define fastIO cin.tie(0);ios_base::sync_with_stdio(false)
#define N 10010
#define ll long long
#define INF 1000000000000000000
//min-cost flow problem
using namespace std;

struct edge {
  ll from, to, cap, flow, cost;
};

ll n, d[2 * N + 5], pre[2 * N + 5], Maxflow = 0, COST = 0;
bool inqueue[2 * N + 5];
vector<edge> Edge;     // store edges
vector<ll> G[2 * N + 10];

inline void addEdge( ll from, ll to, ll cap, ll cost )
{
    Edge.push_back( edge{from, to, cap, 0, cost} );
    Edge.push_back( edge{to, from, 0, 0, -cost} );

    G[from].push_back( Edge.size() - 2 );
    G[to].push_back( Edge.size() - 1 );
}

inline bool bfs( ll s, ll t )
{
    for ( int i = 0; i < 2 * N + 5; ++i )
        d[i] = INF;
    memset( inqueue, 0, sizeof( inqueue ) );

    queue<ll> q;
    q.push( s );

    d[s] = 0, inqueue[s] = true;

    ll now;
    while ( q.empty() == false ) {
        now = q.front();
        q.pop();
        inqueue[now] = false;
        for ( ll i = 0; i < G[now].size(); ++i ) {
            edge& tmp = Edge[G[now][i]];
            if ( tmp.cap > tmp.flow && d[now] + tmp.cost < d[tmp.to] ) {
                d[tmp.to] = d[now] + tmp.cost;
                pre[tmp.to] = G[now][i];

                if ( inqueue[tmp.to] == false && tmp.to != t ) {
                    inqueue[tmp.to] = true;
                    q.push( tmp.to );
                }
            }
        }
    }

    return d[t] != INF;
    /*
    if(d[t]==-INF)
        return false;
    else
        return true;
    */
}

inline void calc( ll s, ll t )
{
    ll minflow = INF;
    ll tmpu = t;
    while ( s != tmpu ) { //find minflow
        minflow = min( minflow, Edge[pre[tmpu]].cap - Edge[pre[tmpu]].flow );
        tmpu = Edge[pre[tmpu]].from;
    }

    Maxflow += minflow;
    COST += minflow * d[t];

    while ( s != t ) {
        Edge[pre[t]].flow += minflow;
        Edge[pre[t] ^ 1].flow -= minflow;
        t = Edge[pre[t]].from;
    }
}

inline void init()
{
    cin >> n;

    ll a, b, c;
    for ( int i = 1; i <= n; ++i ) {
        cin >> a >> b >> c;
        addEdge( 0, i, c, 0 );
        addEdge( i, 2 * n + 1, c, -a - b );
        addEdge( i, 2 * n + 2, c, a - b );
        addEdge( i, 2 * n + 3, c, -a + b );
        addEdge( i, 2 * n + 4, c, a + b );
    }
    for ( int i = 1; i <= n; ++i ) {
        cin >> a >> b >> c;
        addEdge( i + n, 2 * n + 5, c, 0 );
        addEdge( 2 * n + 1, i + n, c, a + b );
        addEdge( 2 * n + 2, i + n, c, -a + b );
        addEdge( 2 * n + 3, i + n, c, a - b );
        addEdge( 2 * n + 4, i + n, c, -a - b );
    }
}

inline void solve()
{
    ll s = 0, t = 2 * n + 5;

    while ( bfs( s, t ) == true ) {
        calc( s, t );  //update cost && Maxflow
    }
    cout << -COST << endl;
}

int main()
{
    init();
    solve();
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  ll n;
  cin >> n;
  vector<pair<ll, int>> vp;
  for (ll i = 2; i * i <= n; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      x++;
    }
    vp.emplace_back(i, x);
  }
  if (n != 1) vp.emplace_back(n, 1);

  int ans = 0;
  for (auto v : vp) {
    int t = v.second;
    int dis = 1;
    while (t >= dis) {
      t -= dis;
      dis++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19708
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int temp = n;
		int f = 0;
		
		while(temp != 0){
			int rem = temp % 10;
			temp /=10;
			f += rem; 
		}

		if(n % f == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 23892
import sys
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,K=LI()
As=LI()
As.sort()
Fs=LI()
Fs.sort(reverse=True)

rgt = 10**12
lft = 0
while lft < rgt:
    cost = K
    half = (lft + rgt) // 2
    for i in range(N):
        if As[i]*Fs[i] > half:
            cost -= (As[i]*Fs[i] - half) // Fs[i]
            cost -= 1 if (half - As[i]*Fs[i]) % Fs[i] > 0 else 0

    if cost < 0:
        lft = half + 1
    else:
        rgt = half
    # print(lft, rgt)

print(rgt)


Measured memory_bytes: 119500
using System;

class Program
{
    static void Main(string[] args) {

        int n = int.Parse(Console.ReadLine());

        string[] xwk = Console.ReadLine().Split(' ');
        string[] ywk = Console.ReadLine().Split(' ');

        int[] x = new int[n];
        int[] y = new int[n];

        for (int i = 0; i < n; i++) {
            x[i] = int.Parse(xwk[i]);
            y[i] = int.Parse(ywk[i]);
        }

        double p1 = 0;
        for (int i = 0; i < n; i++) {
            p1 += Math.Abs(x[i] - y[i]);
        }

        double p2 = 0;
        for (int i = 0; i < n; i++) {
            p2 += Math.Abs(x[i] - y[i]) * Math.Abs(x[i] - y[i]);
        }
        p2 = Math.Sqrt(p2);

        double p3 = 0;
        for (int i = 0; i < n; i++) {
            p3 += Math.Abs(x[i] - y[i]) * Math.Abs(x[i] - y[i]) * Math.Abs(x[i] - y[i]);
        }
        p3 = Math.Pow(p3, 1.0 / 3.0);

        double p4 = 0;
        for (int i = 0; i < n; i++) {
            p4 = Math.Max(Math.Abs(x[i] - y[i]), p4);
        }


        Console.WriteLine(p1);
        Console.WriteLine(p2);
        Console.WriteLine(p3);
        Console.WriteLine(p4);
    }
}


Measured memory_bytes: 15988
import std.stdio, std.string, std.conv, std.array, std.algorithm, std.range, std.math;

void main()
{
    auto s = readln.chomp;

    char last1 = s[0];
    char last2 = s[1];

    if (last1 == last2) {
        writeln("1 2");
        return;
    } else if (s.length == 2) {
        writeln("-1 -1");
        return;
    }

    foreach (long i, c; s[2..$]) {
        if (last1 == c || last2 == c) {
            writefln("%d %d", i+1, i+3);
            return;
        }
        last1 = last2;
        last2 = c;
    }

    writeln("-1 -1");
}

Measured memory_bytes: 2556
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

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


Measured memory_bytes: 26124
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e6+5;
int a[maxn];
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	int pos=1;
	for(int i=1;i<=n;i++){
		int p=1;
		for(int j=pos;j<=n;j++){
			if(a[j]==i){
				pos=j;ans++;p=0;
				break;
			}
		}
		if(p)
		break;
		
	}
	if(ans>0)
	cout<<n-ans;
	else
	cout<<-1;
	
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int b=0,a=0;
    cin >> N;
    vector<int> A(N);
    set <int> s;
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        s.insert(A.at(i));
    } 
    
    cout << s.size() << endl;
}

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

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

  cin>>k>>s;

  for(int x=0;x<=k;x++)
  {
    for(int y=0;y<=k;y++)
    {
      int z=s-x-y;
      if(z>=0&&z<=k)
      {
       ans += 1;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from itertools import groupby

N = int(input())
V = [int(v) for v in input().split()]

def main():
    a = sorted(V[::2])
    b = sorted(V[1::2])

    freq_a = [(k, len(list(g))) for k, g in groupby(a)]
    freq_b = [(k, len(list(g))) for k, g in groupby(b)]

    freq_a.sort(key=lambda t: t[1], reverse=True)
    freq_b.sort(key=lambda t: t[1], reverse=True)

    freq_a.append((0, 0))
    freq_b.append((0, 0))

    if freq_a[0][0] == freq_b[0][0]:
        if freq_a[0][1] > freq_b[0][1]:
            na = freq_a[0][1]
            nb = freq_b[1][1]
        elif freq_a[0][1] < freq_b[0][1]:
            na = freq_a[1][1]
            nb = freq_b[0][1]
        else:
            if freq_a[1][1] >= freq_b[1][1]:
                na = freq_a[1][1]
                nb = freq_b[0][1]
            else:
                na = freq_a[0][1]
                nb = freq_b[1][1]
    else:
        na = freq_a[0][1]
        nb = freq_b[0][1]
        
    ans = len(a) - na + len(b) - nb

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15896
mod = 10**9+7
MAX = 10**5+1
fact = [1]*(MAX+1)
for i in range(1, MAX+1):
    fact[i] = (fact[i-1]*i)%mod
inv = [1]*(MAX+1)
for i in range(2, MAX+1):
    inv[i] = inv[mod%i]*(mod-mod//i)%mod
fact_inv = [1] * (MAX + 1)
for i in range(1, MAX + 1):
    fact_inv[i] = fact_inv[i-1]*inv[i]%mod
def comb(n, r):
    if n < r:
        return 0
    return fact[n]*fact_inv[n-r]*fact_inv[r] % mod

n = int(input())
L = list(map(int,input().split()))
M = []
for i in range(n+1):
    M.append(L[i])
M.sort()
dou = 1 #重複する数
for i in range(n+1):
    if M[i] == dou:
        dou += 1
    else:
        dou = M[i]
        break
l = 0
r = 0
cnt = 0
for i in range(n+1):
    if L[i] == dou and cnt == 0:
        l = i+1
        cnt += 1
    elif L[i] == dou and cnt == 1:
        r = i+1
        break
for i in range(1,n+1):
    print((comb(n+1,i)-comb(l+n-r,i-1))%mod)
print(1)


Measured memory_bytes: 25716
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

S,T=map(str, input().split())
A,B=map(int, input().split())
U=str(input())
if U == S:
    print(A-1, B)
else:
    print(A, B-1)

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

typedef long long int lli;

char path[1001][1001];
lli dp[1001][1001];
lli mod = 1000000007;
int hmax, wmax;

lli grid(int h, int w)
{
	if(path[h][w] == '#' || h == hmax || w == wmax) dp[h][w] = 0;
	if(h == hmax - 1 && w == wmax - 1) dp[h][w] = 1;
	if(dp[h][w] != -1) return dp[h][w];

	dp[h][w] = (grid(h,w+1)%mod + grid(h+1,w)%mod)%mod;

	return dp[h][w]%mod;
}

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

	cin >> hmax >> wmax;

	for(int i = 0; i < hmax; i++)
		for(int j = 0; j < wmax; j++)
		{
			cin >> path[i][j];
			dp[i][j] = -1;
		}

	lli m = grid(0, 0);

	cout << m%mod << endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int n=N;
  int size=1;
  while(1){
    if(n/10==0) break;
    else{
      n/=10;
      size++;
    }
  }
  int tmp=1;
  for(int i=0;i<size-1;i++) tmp*=10;
  vector<int> S(size,0);
  n=N;
  for(int i=0;i<size;i++){
    S.at(i)=n/tmp;
    n%=tmp;
    tmp/=10;
  }
  //for(int i=0;i<size;i++) cout << S.at(i);

  int ans=0;
  for(int i=1;i<=N;i++){
    int a;
    int b=i%10;
    int tmp=1e6;
    while(1){
      if(i/tmp==0)  tmp/=10;
      else{
        a=i/tmp;
        break;
      }
    }
    if(a==0 || b==0)  continue;
    if(a==b) ans++;
    for(int siz=2;siz<=size;siz++){
      if(siz<size)  ans+=pow(10,siz-2);
      if(siz==size){
        vector<int> T(size,0);
        T.at(0)=b;
        T.at(size-1)=a;
        if(S.at(0)<T.at(0)) continue;
        if(S.at(0)>T.at(0)){
          ans+=pow(10,size-2);
          continue;
        }
        int res=0;
        if(S.at(0)==T.at(0)){
          for(int j=1;j<size-1;j++){
            res*=10;
            res+=S.at(j);
          }
          //res*=10;
          if(S.at(size-1)>=T.at(size-1))  res++;
          ans+=res;
        }
      }
    }
    //cout << i << "," << ans << endl;
  }
  cout << ans << endl;

	return 0;
}


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

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N), b(N);
	for(ll i=0; i<N; i++) cin >> a[i];
	for(ll i=0; i<N; i++) cin >> b[i];

	map<ll,ll> am,bm;
	for(ll i=0; i<N; i++){
		am[a[i]]++;
		bm[b[i]]++;
	}
	for(auto&& pr:am){
		if(pr.second + bm[pr.first]> N){
			cout << "No\n";
			return 0;
		}
	}

	vector<pair<ll,ll>> ans;
	priority_queue<array<ll,4>> q; //(a+bの要素数, aの要素数, bの要素数, 値)
	vector<ll> onlya, onlyb;
	for(auto&& pr:am){
		ll acount=am[pr.first];
		ll bcount=bm[pr.first];
		if(bcount){
			q.push({acount+bcount, acount, bcount, pr.first});
		}else{
			for(ll i=0; i<pr.second; i++)onlya.push_back(pr.first);
		}
	}
	for(auto&& pr:bm){
		if(am[pr.first])continue;
		for(ll i=0; i<pr.second; i++)onlyb.push_back(pr.first);
	}

	while((ll)q.size()>=2){
		array<ll,4> x=q.top();
		q.pop();
		array<ll,4> y=q.top();
		q.pop();
		x[0]--; y[0]--; x[1]--; y[2]--;
		ans.push_back({x[3], y[3]});
		if(x[1]==0){
			for(ll i=0; i<x[2]; i++)onlyb.push_back(x[3]);
		}else{
			q.push(x);
		}
		if(y[2]==0){
			for(ll i=0; i<y[1]; i++)onlya.push_back(y[3]);
		}else{
			q.push(y);
		}
	}

	while(!q.empty()){
		array<ll,4> x=q.top();
		q.pop();
		for(ll i=0; i<x[1]; i++){
			ans.push_back({x[3], onlyb.back()});
			onlyb.pop_back();
		}
		for(ll i=0; i<x[2]; i++){
			ans.push_back({onlya.back(), x[3]});
			onlya.pop_back();
		}
	}

	for(ll i=0; i<(ll)onlya.size(); i++){
		ans.push_back({onlya[i], onlyb[i]});
	}

	sort(ans.begin(), ans.end());
	cout << "Yes\n";
	for(ll i=0; i<N; i++) cout << ans[i].second << " \n"[i==N-1];

	return 0;
}


Measured memory_bytes: 46404
import itertools
D,G = map(int,input().split())
S = []
for _ in range(D):
    S.append(list(map(int,input().split())))
cmin = 10**4
for x in itertools.product((0,1),repeat=D):
    cnt = 0
    s = 0
    for i in range(D):
        if x[i]==1:
            p,c = S[i][0],S[i][1]
            s += 100*(i+1)*p+c
#     print("s={},x={}".format(s,x))
    if s>=G:
        ind = x.index(1)
        s1 = 0
        for i in range(ind+1,D):
            if x[i]==1:
                s1 += 100*(i+1)*S[i][0]+S[i][1]
                cnt += S[i][0]
        if s1>=G:
            continue
        t = 0
        while t<S[ind][0]:
            s1 += 100*(ind+1)
            cnt += 1
            if s1>=G:
                break
            t += 1
        cmin = min(cmin,cnt)
#         print("cmin={},x={}".format(cmin,x))
print(cmin)            

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	int n; cin >> n;
	bool flag = false;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	int cnt = 0;

	while (1)
	{
		for (int i = 0; i < n; i++)
		{
			if (a[i] % 2 == 0)
			{
				a[i] /= 2;
			}
			else flag = true;
		}

		if (flag) break;
		else cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		int right = 0;
		int base = arr[0];
		long count = 0;
		for (int left = 0; left < n; left++) {
		    while (right < n - 1 && (base & arr[right + 1]) == 0) {
		        right++;
		        base += arr[right];
		    }
		    count += right - left + 1;
		    base -= arr[left];
		}
		System.out.println(count);
    }
}



Measured memory_bytes: 83844
N,X = map(int,input().split())
L = list(map(int,input().split()))
LL = [0 for i in range(N+1)]
cnt = 1
for i in range(N):
    LL[i+1] = L[i] + LL[i]
    if LL[i+1] <= X:
        cnt += 1

# print(LL)
print(cnt)

Measured memory_bytes: 38384
N,M = map(int, input().split())
 
AB = []
 
for i in range(N) : 
    tmp_AB = [int(i) for i in input().split()]
    AB.append(tmp_AB)
    
P = sorted(AB)
 
sum = 0
cnt = 0 # Mに達したら終了

for i in range(len(P)) : 
    for j in range(P[i][1]) : 
        if cnt < M: 
            sum += P[i][0]
            cnt += 1
        else :
            break
        
    if cnt >= M : 
        break
    
print(sum)

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

int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if(x-r<0){
    cout << "No" << endl;
  }else if(y-r<0){
    cout << "No" << endl;
  }else if(x+r>W){
    cout << "No" << endl;
  }else if(y+r>H){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 3104
// AOJ 1237
#include <bits/stdc++.h>
using namespace std;
int m;
string s;
map<int,vector< vector<string> > > res;
vector<string> his;
int dfs(string x,int t){
	if( x.size() == 0 ){
		//cout << t << endl;
		if( m >= t ) res[t].push_back(his);
		return 0;
	}
	//if( dp.count(make_pair(t,x)) ) return dp[make_pair(t,x)];
	int ans = 0;
	for(int i = 0 ; i < x.size() ; i++){
		string s = x.substr(0,i+1);
		stringstream ss(s);
		int w;
		ss >> w;
		his.push_back(s);
		ans += dfs(x.substr(i+1),t+w);
		his.pop_back();
	}
	//return dp[make_pair(t,x)] = ans;
}


int main(){
	while( cin >> m >> s && m){
		res.clear();
		dfs(s,0);
		if( res.size() == 0 ) cout << "error" << endl;
		else if( (*res.rbegin()).second.size() > 1 ) cout << "rejected" << endl;
		else{
			cout << (*res.rbegin()).first;
			for(int i = 0 ; i < (*res.rbegin()).second[0].size() ; i++)
				cout << " " << (*res.rbegin()).second[0][i];
			cout << endl;
		}
	}
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    ll n, k;
    cin >> n >> k;

    ld sum=0;
    ld nd = n;
    for(ll i=1; i<=n; i++){
        ld tmp=(ld)k/i;
        ll tmp2 = tmp;
        if( (tmp2-tmp)!=0 )tmp2 = tmp2+1;
        ld tmp3 = log2(tmp2);
        ll tmp4=tmp3;
        if( (tmp3-tmp4)!=0 )tmp4 = tmp4+1;
        
        //cerr << tmp << "," << tmp2;
        //double tmp2 = logbl(tmp, 2.0);
        sum += 1/(nd*pow(2,tmp4));
    }

    cout << setprecision(10) << sum << endl;;
    return 0;
}



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

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& (a) : (x))
#define all(x) (x).begin (), (x).end ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair<int, int> pii;
#define f first
#define s second
#define mkp(x) make_pair ((x))

typedef vector<int> vi;
#define pb(x) push_back ((x))

#define DEBUG 0
#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

#define ddprintfv(v) if (DEBUG) { trav (a, v) cout << a << " "; cout << "\n"; }

#define EXIT ddprintf ("Time elapsed %lf\n", 1.0 * clock() / CLOCKS_PER_SEC); exit (0)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  1e+6+7;

int main ()
{
    int i, j, t;
    int N, K;
    scanf ("%d %d", &N, &K);
    vector <ll> H (N + 2);
    vector <vector <ll> > dp (N + 2, vector <ll> (N + 2, INF));
    dp[0][0] = 0;
    for (i = 0; i != N; i++)
        scanf ("%lld", &H[i + 1]);
    for (i = 0; i < N + 1; i++)
        for (j = 0; j < min (i + 1, K + 1); j++)
            for (t = 0; t < j + 1; t++)
            {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i - t][j - t] + max(0LL, H[i + 1] - H[i - t]));
                ddprintf ("i:%d, j:%d, t:%d\n", i, j, t);
                if (DEBUG)
                trav (a, dp)
                {
                    trav (b, a)
                        ddprintf ("%21lld", b);
                    ddprintf ("\n");
                }
                ddprintf ("\n");
            }
    printf ("%lld\n", dp[N + 1][K]);

    EXIT;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<string.h>
#include<stdlib.h>
using namespace std;

int main()
{
	int n,i,j=0,scoreT=0,scoreH=0,pos;
	string s,s1,s2;
	cin>>n;
	cin.ignore();
	for(i=0;i<n;i++){
		getline(cin,s);
		pos = s.find(" ",0);
		s1 = s.substr(0,pos);//substr(0,n)获得从第0位开始长度为n的字符串 
		s2= s.substr(pos+1,s.size()-pos-1);
		if(s1>s2) scoreT+=3;
		else if(s1<s2) scoreH+=3;
		else{
			scoreT++;
			scoreH++;
		}
	}
	cout<<scoreT<<" "<<scoreH<<endl;
	return 0; 
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    set<int> se;
    rep(i, s.size()){
        if(se.count(s[i])){
            cout << "no" << endl;
            return 0;
        }
        se.insert(s[i]);
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 3604
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
result = 0

for i in range(len(a)):
    result += b[i]
for i in range(len(a) - 1):
    if a[i + 1] == a[i] + 1:
        result += c[a[i] - 1]

print(result)

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

vector<P> shogen[100];
int n;


bool check(vector<int> shoujiki){
    int m = shoujiki.size();
    vector<int> people(n,0);
    rep(i,m)people[shoujiki[i]] = 1;
    rep(i,n){
        if(people[i] == 0)continue;
        for(auto s:shogen[i]){
            if(people[s.first] == 1 &&s.second == 0)return false;
            if(people[s.first] == 0 && s.second == 1)return false;
        }
    }
    return true;
}

int dfs(int d,vector<int> shoujiki){
    if(d == n){
        if(check(shoujiki) == true)return shoujiki.size();
        else return 0;
    }
    int res = 0;
    shoujiki.push_back(d);
    res = max(res,dfs(d+1,shoujiki));
    shoujiki.pop_back();
    res = max(res,dfs(d+1,shoujiki));
    
    return res;
    

}


signed main(){
    cin >> n;
    rep(i,n){
        int a;cin >> a;
        rep(j,a){
            int x,y;cin >> x >> y;
            x--;
            shogen[i].emplace_back(x,y);
        }
    }
    vector<int> v;
    int ans = dfs(0,v);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string s;
    ll x, y;
    cin >> s >> x >> y;
    ll dic = 0;
    vector<char> run;
    vector<ll> length;
    ll cnt = 1;
    Rep (i, s.size()-1) {
        if (s[i] == s[i+1]) {
            cnt++;
        } else {
            run.push_back(s[i]);
            length.push_back(cnt);
            cnt = 1;
        }
    }
    run.push_back(s[s.size()-1]);
    length.push_back(cnt);

    // Rep (i, run.size()) {
    //     cout << run[i] << "\t" << length[i] << endl;
    // }

    if (*run.begin() == 'F') {
        x -= *length.begin();
        run.erase(run.begin());
        length.erase(length.begin());
    }

    // Rep (i, run.size()) {
    //     cout << run[i] << "\t" << length[i] << endl;
    // }

    ll n = run.size();
    vector<vector<ll>> move(2);
    Rep (i, 2) {
        move[i].push_back(0);
    }
    Rep (i, n) {
        if (run[i] == 'F') {
            move[dic].push_back(length[i]);
        } else {
            length[i] %= 2;
            dic ^= length[i];
            // cout << "dic:" << dic << "\n";
        }
    }

    // Rep (i, 2) {
    //     for (ll e : move[i]) {
    //         cout << e << " ";
    //     }
    //     cout << "\n";
    // }

    bool ans = true;
    // Rep (i, 2) {
    //     ll target;
    //     if (i == 0) target = x;
    //     else target = y;

    //     // cout << "target: " << target << endl;
    //     ll total = 0;
    //     for (ll e : move[i]) {
    //         total += e;
    //     }
    //     if (total + target < 0 || (total + target) % 2 == 1) ans = false;
    //     ll goal = (total + target) / 2;

    //     vector<vector<bool>> dp(move[i].size()+1, vector<bool>(1e4, false));
    //     dp[0][0] = true;
    //     Rep (j, move[i].size()) {
    //         Rep (k, 1e4) {
    //             if (dp[j][k]) {
    //                 dp[j+1][k] = true;
    //                 if (k+move[i][j] < 1e4) dp[j+1][k+move[i][j]] = true;
    //             }
    //         }
    //     }

    //     if (!dp[move[i].size()][goal]) ans = false;
    // }

    Rep (i, 2) {
        ll target;
        if (i == 0) {
            target = x;
        } else {
            target = y;
        }

        vector<vector<bool>> dp(move[i].size() + 1, vector<bool>(40000, false));
        dp[0][20000] = true;
        Rep (j, move[i].size()) {
            Rep (k, 40000) {
                if (dp[j][k]) {
                    if (0 <= k-move[i][j] && k-move[i][j] <= 40000) dp[j+1][k-move[i][j]] = true;
                    dp[j+1][k] = false;
                    if (0 <= k+move[i][j] && k+move[i][j] <= 40000) dp[j+1][k+move[i][j]] = true;
                }
            }
        }

        if (!dp[move[i].size()][target + 20000]) ans = false;
    }

    if (ans) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 13568
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int M = sc.nextInt();
		List<Integer> sumList = new ArrayList<>();
		long res = 0;
		sumList.add(0);
		for(int i=0;i<N;i++){
			res += sc.nextInt();
			res %= M;
			sumList.add((int)res);
		}
		Collections.sort(sumList);
		long result = 0;
		int befNum = 0;
		long count = 0;
		int tmp = 0;
		for(int i=0;i<=N;i++){
			tmp = sumList.get(i);
			if(tmp == befNum){
				count++;
			}else{
				result += count*(count-1)/2;
				count = 1;
				befNum = tmp;
			}
		}
		result += count*(count-1)/2;
		out.println(result);
		out.flush();
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

#define       sf                 scanf
#define       pf                 printf
#define       pb                 push_back
#define       sz                 200005
#define       MOD                1000000007
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define 	  optimize           ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef       long long int      ll;

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

ll func(ll n)
{
	ll left = 1, right = 1000000, ans = 1;

	while(left<=right)
	{
		ll mid = (left+right)/2ll;

		if((mid*mid+mid)/2ll<=n)
		{
			ans = mid;
			left = mid+1;
		}
		else right = mid-1;
	}

	return ans;
}

int main()
{
	// READ
	optimize

	ll n, ans = 0;;

	cin >> n;

	ll limit = sqrt(n);

	for(ll i = 2; i <= limit; i++)
	{
		if(n%i==0ll)
		{
			ll cn = 0;

			while(n%i==0ll)
			{
				cn++;
				n /= i;
			}

			ans += func(cn);
		}
	}

	if(n!=1ll) ans += func(1);

	cout << ans << endl;



    return 0;
}


Measured memory_bytes: 3696
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var abcd = Console.ReadLine().Split(' ');
        // Takahasi
        var a = long.Parse(abcd[0]);
        var b = long.Parse(abcd[1]);
        // Aoki
        var c = long.Parse(abcd[2]);
        var d = long.Parse(abcd[3]);

        while (true)
        {
            c -= b;
            if (c <= 0)
            {
                Console.WriteLine("Yes");
                break;
            }
            a -= d;
            if (a <= 0)
            {
                Console.WriteLine("No");
                break;
            }
        }
    }
}


Measured memory_bytes: 17852
package main

import (
	"bufio"
	"os"
	"strconv"
	"sort"
	"fmt"
)

func main()  {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	s := scanner.Text()
	scanner.Scan()
	K, _ := strconv.Atoi(scanner.Text())
	subs := make([]string, len(s) * K)
	idx := 0
	for i := 0; i < len(s); i++ {
		for j := 1; j <= K; j++ {
			k := i + j
			var end int
			if k < len(s) {
				end = k
			} else {
				end = len(s)
			}
			subs[idx] = s[i:end]
			idx++
		}
	}
	sort.Strings(subs)
	ans := make([]string, K)
	idx = 0
	for i := 0; i < len(subs); i++ {
		if idx == 0 || ans[idx - 1] != subs[i] {
			ans[idx] = subs[i]
			idx++
		}
		if idx == K {
			break
		}
	}
	fmt.Println(ans[K - 1])
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int M = 256;
const double EPS = 1e-9;

int n, I[M];

double calc(int S, int A, int C){
  int r = S, cnt[M];
  fill(cnt, cnt+M, 0);
  for(int i=0;i<n;i++){
    r = (A * r + C) % M;
    cnt[(I[i] + r) % M]++;
  }
  double res = 0.0;
  for(int i=0;i<M;i++) if(cnt[i]) res -= (double)cnt[i] * (log((double)cnt[i]) - log((double)n));
  return res;
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++) cin >> I[i];
    int ans[3];
    double valm = 1e77;
    for(int S=0;S<=15;S++){
      for(int A=0;A<=15;A++){
        for(int C=0;C<=15;C++){
          double tmp = calc(S, A, C);
          if(valm > tmp && !(abs(valm - tmp) < EPS)){
            ans[0] = S;
            ans[1] = A;
            ans[2] = C;
            valm = tmp;
          }
        }
      }
    }
    cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
  }
}

Measured memory_bytes: 1196
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int d[n];
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int k = i + 1; k < n; k++) {
            ans += d[i] * d[k];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n;
	map<int, int> a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int ai;
		cin >> ai;
		a[ai]++;
	}
	int count = 0;
	for (auto x:a) {
		if (x.second % 2 == 1)count++;
	}
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 4864
#include <iostream>
#define rep(i, N) for(int i = 0; i < N; ++i)

using namespace std;

int main()
{
    int a[9];
    bool checked[9];
    rep(i, 9)
    {
        checked[i] = false;
        cin >> a[i];
    }

    int n;
    cin >> n;
    rep(i, n)
    {
        int b;
        cin >> b;
        rep(j, 9)
        {
            if (a[j] == b)
            {
                //check
                checked[j] = true;
            }
        }
    }

    if ((checked[0] && checked[1] && checked[2])
        ||(checked[3] && checked[4] && checked[5])
        ||(checked[6] && checked[7] && checked[8])
        ||(checked[0] && checked[3] && checked[6])
        ||(checked[1] && checked[4] && checked[7])
        ||(checked[2] && checked[5] && checked[8])
        ||(checked[0] && checked[4] && checked[8])
        ||(checked[2] && checked[4] && checked[6]))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a[300005];
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>b) printf("%d\n",a-1);
    else printf("%d\n",a);
    return 0;
}



Measured memory_bytes: 128
N = int(input())
A = [int(_) for _ in input().split()]


def sub_problem(x):
    S = [0] * (N + 1)
    for i in range(N):
        S[i + 1] = S[i] + 1 if A[i] >= x else S[i] - 1

    geta = abs(min(S)) + 1
    for i in range(N + 1):
        S[i] += geta

    forward = 0
    size = max(S)
    bit = [0] * (size + 1)
    for s in S:
        i = s
        while i > 0:
            forward += bit[i]
            i -= i & -i

        i = s
        while i <= size:
            bit[i] += 1
            i += i & -i

    return forward >= (M + 1) // 2


M = N * (N + 1) // 2  # (N+1)C2
sorted_A = sorted(A)

inf = 0
sup = N
while sup - inf > 1:
    mid = (sup + inf) // 2
    x = sorted_A[mid]

    if sub_problem(x):
        inf = mid
    else:
        sup = mid

print(sorted_A[inf])


Measured memory_bytes: 85860