akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut m = 0;
    let mut ans = 0;
    for &x in &a {
        if x <= m {
            continue;
        }
        let v = (x - 1) / (m + 1);
        if v >= 1 {
            ans += v;
            m = max(m, 1);
        } else {
            m = max(m, x);
        }
    }

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


Measured memory_bytes: 4352
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int T = in.nextInt();
        for (int t = 0; t < T; t++) {
            int N = in.nextInt();
            long[] A = new long[N];
            for (int n = 0; n < N; n++)
                A[n] = in.nextLong();
            String S = in.next();
            char[] cs = S.toCharArray();
            boolean flag = true;
            for (int n = N - 1; n >= 0; n--) {
                if (A[n] == 0) continue;
                if (cs[n] == '1') {
                    flag = false;
                    break;
                }
                long msb = 0x1000000000000000L;
                while ((A[n] & msb) == 0) msb /= 2;
                for (int m = 0; m < n; m++) if ((A[m] & msb) != 0) {
                    A[m] ^= A[n];
                }
            }
            if (flag)
                out.println(0);
            else
                out.println(1);
        }

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 39144
#include <cstdio>
#include <algorithm>
#include <cstdint>

using namespace std;

int main() {
    int64_t N, X;
    scanf("%lld %lld", &N, &X);

    int64_t res=N;
    N -= X;
    if (N < X) swap(N, X);

    while (X) {
        res += 2*(N/X)*X;

        if (N % X == 0) {
            res -= X;
            break;
        }

        swap(N%=X, X);
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 128
def solve(N_t, D_t):
    ans = D_t
    for i in range(N_t - 1):
        ans -= D_t
        ans += 127
        D_t = 127 ^ D_t
        ans += D_t
    return ans

T = int(input())
for i in range(T):
    N_t, D_t = map(int, input().split())
    print(solve(N_t, D_t))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}

int N,W;
ll weights[110];//[no][w]:重さ
ll values[110];//[no][v]:価値
ll dp[110][101010];//[no][w]:重さの総和w以下で価値の総和の最大

int main(){
	cin>>N>>W;
	rp(no, 1, N+1)cin>>weights[no]>>values[no];
	rp(no, 1, N+1){//商品No.
		rp(w, 0, W+1){//重さ制限
			dp[no][w] = dp[no-1][w];
			if(w - weights[no] >= 0)
				dp[no][w] = max(
					dp[no][w],
					dp[no-1][w - weights[no]] + values[no]);
		}
	}
	cout<< dp[N][W] <<endl;
}


Measured memory_bytes: 79360
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll L,R;
    cin >> L >> R;
    ll ans;
    if(R-L>2019)ans=0;
    else{
        ll i,j;
        ans=2019;
        for(i=L;i<=R-1;i++){
            for(j=i+1;j<=R;j++){
                ans=min(ans,i*j%2019);
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,a[MAXN],deg[MAXN];
int main()
{
    for(int i=0;i<3;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        deg[u]++;deg[v]++;
    }
    int cnt=0;
    for(int i=1;i<=4;i++) if(deg[i]&1) cnt++;
    if(cnt>2) puts("NO"); else puts("YES");
    return 0;
}



Measured memory_bytes: 256
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
for i in range(1, N):
    A1[i] += A1[i - 1]
A2[0] += A1[0]
for i in range(1, N):
    A2[i] += max(A1[i], A2[i - 1])
print(A2[N - 1])

Measured memory_bytes: 3064
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()
ab = [readInts() for i in range(n)]
ab.sort()
i = 0
ans = 0
while m>0:
	if m>=ab[i][1]:
		m-=ab[i][1]
		ans+=ab[i][0]*ab[i][1]
		i+=1
	else:
		ans += m*ab[i][0]
		m = 0
print(ans)

Measured memory_bytes: 27780
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
    ll n;
    cin>>n;
    ll p[55];
    rep(i,0,n)cin>>p[i];

    ll x=0;
 
    rep(i,0,n) {
        if(p[i]!=i+1) x++;
    }
    if(x<3) cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    register int i;
    int n;
    scanf("%d",&n);
    long h[n];
    for(i = 0;i < n;i++)scanf("%ld",&h[i]);
    static long ds[200001];
    static long as[200001];
    for(i = 0;i < n;i++){
        if(i + h[i] < 200000)as[i+h[i]]++;
        if(i - h[i] > 0 && i - h[i] < 200000)ds[i - h[i]]++;
    }
    long long a = 0;
    for(i = 0;i <= 200000;i++)a += as[i] * ds[i];
    printf("%lld",a);
}


Measured memory_bytes: 6380
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	s := getNextString(scanner)
	m := ysp48(s[:n], n)
	mm := ysp48(reverseString(s[n:], n), n)
	var ans int64
	for ss, c := range m {
		ans += c * mm[ss]
	}

	fmt.Fprintln(writer, ans)
}
func ysp48(s string, n int) map[string]int64 {
	m := map[string]int64{}
	t := make([]string, n+1)
	ss := strings.Split(s, "")
	for i := 0; i < 1<<uint(n); i++ {
		red := 0
		blue := n
		for ii := 0; ii < n; ii++ {
			if i>>uint(ii)%2 == 0 {
				t[red] = ss[ii]
				red++
				continue
			}
			t[blue] = ss[ii]
			blue--
		}
		t[red] = "_"
		r := strings.Join(t, "")
		m[r] = m[r] + 1
	}
	return m
}

func reverseString(s string, n int) string {
	ss := strings.Split(s, "")
	t := make([]string, n)
	for i := 0; i < n; i++ {
		t[n-i-1] = ss[i]
	}
	return strings.Join(t, "")
}


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

int main(){
    string S, T;
    cin >> S >>T;
    int count = 0;

    for(int i = 0; i < 3; i++){
        if(S.at(i) == T.at(i)){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3632
#95 C - Big Array
N,K = map(int,input().split())
lis = []
for _ in range(N):
    a,b = map(int,input().split())
    lis.append((a,b))

lis = sorted(lis,reverse = False)

cnt = 0
num = 0
for a,b in lis:
    cnt += b
    num = a
    if cnt >= K:
        break
print(num)

Measured memory_bytes: 23572
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    char a[15];
    scanf("%s",a);
    int num=0;
    for (int i=0;i<strlen(a);i++)
    {
        if (a[i]=='1')
            num++;
    }
    cout <<num << endl;
}


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

using namespace std;

void action()
{
    long long n,k;
    scanf("%lld%lld",&n,&k);
    long long ans=0;
    if(k==0)
    {
        ans = n*n;
    }
    else
    {
        for(long long i=k+1; i<=n; i++)
        {
            long long nub_zu = n/i;
            long long sheng = n%i;
            if(sheng >= k)
                ans += (sheng-k+1);
            ans += nub_zu * (i-k);
        }
    }
    cout<<ans<<endl;

}
int main()
{
    action();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    int N, x; cin >> N >> x;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        x -= v[i];
        if(x>=0){
            ans++;
        } else {
            break;
        }
    }
    if(x>0&&ans==N) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np

X, N = list(map(int, input().split()))
p_list = set(sorted(list(map(int, input().split()))))

if N == 0:
  print(X)
  exit()
  
i = sorted(list(set(range(X-N, X+1)) - p_list))[-1]
j = sorted(list(set(range(X, X+N+1)) - p_list))[0]

if X-i <= j-X:
  print(i)
else:
  print(j)

Measured memory_bytes: 27148
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long dp[3][100001] = {};
	for (int i = 0; i < n; i++) {
		int a[3] = {};
		for (int j = 0; j < 3; j++) {
			cin >> a[j];
		}
		for (int j = 0; j < 3; j++) {
			dp[j][i + 1] = max(dp[(j + 1) % 3][i] + a[(j + 1) % 3], dp[(j + 2) % 3][i] + a[(j + 2) % 3]);
		}
	}
	cout << max({dp[0][n], dp[1][n], dp[2][n]}) << endl;
	return 0;	
}

Measured memory_bytes: 2560
#include <iostream>

typedef long long ll;

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

  int N;  std::cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (i % 3 != 0 and i % 5 != 0)
      ans += i;
  }

  std::cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int a,b,c;
int k;

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&k);
    while(k--){
        if(b<=a){
            b*=2;
        }
        else if(c<=b){
            c*=2;
        }
    }
    if(a<b && b<c) printf("Yes\n");
    else puts("No\n");

    return 0;
}

Measured memory_bytes: 3756
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a == b) {

			System.out.println("Draw");

		} else if (a == 1) {

			System.out.println("Alice");

		} else if (b == 1) {

			System.out.println("Bob");

		} else if (a > b) {

			System.out.println("Alice");

		} else if (a < b) {

			System.out.println("Bob");

		}

	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,x,mind=1000000;cin>>n>>x;
  int ans=x;
  for(int i=0;i<n;i++)
  {
    int m[i];cin>>m[i];
    ans-=m[i];
    mind=min(mind,m[i]);
  }
 cout<<ans/mind+n<<endl;
}
    
  
    

Measured memory_bytes: 256
N, K = map(int, input().split())
P = int(1e9+7)
cnt = [0]*(K+1)

ans = 0
for i in range(K, 0, -1):
    c = pow(K//i, N, P) - sum(cnt[::i])
    cnt[i] = c
    ans = (ans+i*c)%P

print(ans%P)


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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }

int main(){
    int K;
    int count = 0;
    cin >> K;
    for(int a = 1; a < K+1; a++){
        for(int b = 1; b < K+1; b++){
            for(int c = 1; c < K+1; c++){
                if(a==1 || b==1 || c==1){
                    count += 1;
                    continue;
                }else{
                    count += gcd(a,gcd(b,c));
                }
            }
        }
    }
    cout << count << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int N, H, W;
	scanf("%d %d %d", &N, &H, &W);
	printf("%d\n", (N - H + 1) * (N - W + 1));
	return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define db long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define mod 1000000007
#define MAX 100005
using namespace std;

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

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);

    ll n,k;
    cin >> k >> n;
    ll a[n];
    ll mx = LLONG_MIN;
    rep(i,0,n){
       cin >> a[i];
    }
    sort(a,a+n);
    rep(i,1,n){
    	mx = max(mx,a[i]-a[i-1]);
    }
    mx = max(mx,k-a[n-1]+a[0]);
    cout << k - mx;
    return 0;

}


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

bool solve(int n, int a){
  int r = n % 500;
  if(r == 0) return true;
  if(r > a) return false;
  return true;
}
int main()
{
  int n, a;
  cin >> n >> a;
  if (solve(n, a))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

bool ok[1001] = {};
int f(int a, int b){
	REP(i, b) a /= 10;
	return a%10;
}

int main(){
	int n, m; scanf("%d%d", &n, &m);
	if(n == 1) fill(ok, ok+10, true);
	if(n == 2) fill(ok+10, ok+100, true);
	if(n == 3) fill(ok+100, ok+1000, true);
	REP(i, m){
		int s, c; scanf("%d%d", &s, &c);
		if(s > n) {
			printf("-1\n");
			return 0;
		}
		REP(i, 1000) if(f(i, n-s) != c) ok[i] = false;
	}
	REP(i, 1000) {
		if(ok[i]){
			printf("%d\n", i);
			return 0;
		}
	}
	printf("-1\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int x;
  cin >> x;
  if (x >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3648
#include <stdio.h>
int prime(int x){
int i; 
if(x < 2)
 return 0; 
if(x == 2)
 return 1;
 if(x % 2 == 0)
 return 0;
 for(i = 3;i * i <= x;i += 2)
 if(x % i == 0)
 return 0;
 return 1; }
 int main(){ int i,n, c = 0, a; scanf("%d", &n); for(i = 0;i < n;i++){ scanf("%d", &a); c += prime(a); } printf("%d\n", c); return 0; } 
 




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

const double EPS = 1e-10;
double add(double a, double b) {
    if(abs(a+b) < EPS*(abs(a)+abs(b))) return 0;
    return a+b;
}
struct Vector {
    double x, y;
    Vector() {}
    Vector(double x, double y):x(x), y(y) {}
    Vector operator+(Vector v) {return Vector(add(x, v.x), add(y, v.y));}
    Vector operator-(Vector v) {return Vector(add(x, -v.x), add(y, -v.y));}
    Vector operator*(double d) {return Vector(x*d, y*d);}
    Vector operator/(double d) {return Vector(x/d, y/d);}
    double dot(Vector v) {return add(x*v.x, y*v.y);}
    double cross(Vector v) {return add(x*v.y, -y*v.x);}
};
istream &operator>>(istream &is, Vector &v) {return is >> v.x >> v.y;}
ostream &operator<<(ostream &os, const Vector &v) {return os << v.x << ' ' << v.y;}
double sqdist(Vector &v, const Vector &u) {return (v-u).dot(v-u);}
//線分v2-v1上にあるか
bool on_seg(Vector &v1,Vector &v2, const Vector &p) {
    return (v1-p).cross(v2-p) == 0 && (v1-p).dot(v2-p) <= 0;
}
//v1-v2とu1-u2の交点
Vector intersection(Vector &v1,Vector &v2,Vector &u1,Vector &u2) {
    assert((v1-v2).cross(u1-u2)); //2直線が平行だとだめ
    return v1 + (v2-v1)*((u2-u1).cross(u1-v1)/(u2-u1).cross(v2-v1));
}
//p2-p1へのQの投影
Vector projection(Vector &p1,Vector &p2,Vector &Q) {
    return p1+(p2-p1)*(Q-p1).dot(p2-p1)/sqdist(p1, p2);
}
//p1-p2を軸としたQの線対称移動
Vector reflection(Vector &p1,Vector &p2,Vector &Q) {
    return projection(p1, p2, Q)*2-Q;
}
bool cmp_x(const Vector &v, const Vector &u) {
    if(v.x != u.x) return v.x < u.x;
    return v.y < u.y;
}
//頂点数nの頂点集合vv
vector<Vector> convex_hull(vector<Vector> &vv, int n) {
    sort(vv.begin(), vv.end(), cmp_x);
    int k = 0;
    vector<Vector> res(n*2);
    for(int i = 0; i < n; i++) {
        while(k > 1 && (res[k-1]-res[k-2]).cross(vv[i]-res[k-1]) <= 0) k--;
        res[k++] = vv[i];
    }
    for(int i = n-2, t = k; i >= 0; i--) {
        while(k > t && (res[k-1]-res[k-2]).cross(vv[i]-res[k-1]) <= 0) k--;
        res[k++] = vv[i];
    }
    res.resize(k-1);
    return res;
}

signed main() {
    cout << fixed << setprecision(13);
    Vector p0, p1, p2, p3;
    int q;
    cin >> q;
    while(q--) {
        cin >> p0 >> p1 >> p2 >> p3;
        if(0) {
            if(on_seg(p1, p0, p2) or on_seg(p1, p0, p3) or on_seg(p2, p3, p0) or on_seg(p2, p3, p1)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        } else {
            Vector p = intersection(p0, p1, p2, p3);
            //cout << (on_seg(p0, p1, p) and on_seg(p2, p3, p)?1:0) << endl;
            cout << p << endl;
        }
    }

}


Measured memory_bytes: 3292
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n,m,p=0,ans=0;
struct task{
	int val,cost;
}t[100000];
bool operator <(task a,task b)
{
	return a.val<b.val;
}
bool operator >(task a,task b)
{
	return a.val>b.val;
}
priority_queue<task> h;
bool comp(task a,task b)
{
	return a.cost<b.cost;
}

int main(void)
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d%d",&t[i].cost,&t[i].val);
	sort(t,t+n,comp);
	for(int i=m-1;i>=0;i--){
		while(p<n&&t[p].cost<=m-i)
			h.push(t[p++]);
		if(h.size()>0){
			ans+=h.top().val;
			h.pop();
		}
	}
	printf("%d\n",ans);
	return 0;
}
/*
*/

Measured memory_bytes: 2168
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    string str;
    while(getline(cin,str),str!="END OF INPUT"){
        str+=" ";
        int cnt=0;
        for(int i=0;i<str.length();i++){
            if(str[i]==' '){
                cout<<cnt;
                cnt=0;
            }
            else{
                cnt++;
            }
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (a >= b) {
        b *= 2;
        k--;
    }
    while (b >= c) {
        c *= 2;
        k--;
    }
    if (k < 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

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

int l[55];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++)
		scanf("%d", l+i);
	sort(l, l+n, greater<int>());
	int ans = 0;
	for(int i = 0; i < k; i++)
		ans += l[i];
	printf("%d\n", ans);
}


Measured memory_bytes: 256
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline
P = 10 ** 9 + 7


@nb.njit("i8(i8[:],i8)", cache=True)
def solve(L, N):
    dp = np.zeros(shape=(N + 1, 2), dtype=np.int64)
    dp[0][0] = 1
    for i in range(N):
        n = L[i]
        for j in range(2):
            max_d = 1 if j == 1 else n
            for d in range(max_d + 1):
                next_j = int(j or d < n)
                dp[i + 1][next_j] += (d + 1) * dp[i][j]

        dp[i + 1][0] %= P
        dp[i + 1][1] %= P

    return (dp[N][0] + dp[N][1]) % P


def main():
    L = np.array(list(map(int, input().rstrip())), dtype=np.int64)

    N = len(L)
    ans = solve(L, N)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 109180
N, L = STDIN.gets.chomp.split(' ').map(&:to_i)

ary = Array.new(N, 0)
ary.map!.with_index { |a, idx|
	(L + idx)
}

minIdx = 0

if L > 0
  minIdx = 0
elsif L < 0 && L.abs >= N
  minIdx = N - 1
else
  minIdx = L.abs
end

puts ary.inject(:+) - ary[minIdx]

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 100003

int main(){
	string ss;
	long long jaw = 0;
	cin >> ss;
	for(int i = 0; i < (1 << (sz(ss) - 1)); i++){
		vector<bool> ya(sz(ss), false);
		for(int j = 1; j < sz(ss); j++){
			if(i & (1 << (j - 1)))
				ya[j] = true;
		}
		long long now = 0;
		for(int j = 0; j < sz(ss); j++){
			if(ya[j]){
				jaw = jaw + now;
				now = 0;
			}
			now *= 10;
			now = now + ss[j] - '0';
		}
		jaw = jaw + now;
	}
	cout << jaw << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String t_card, h_card;
		int t_cnt = 0, h_cnt = 0, com;
		int cnt = sc.nextInt();
		for(int i=0; i<cnt; i++){
			t_card = sc.next();
			h_card = sc.next();
			com = t_card.compareTo(h_card);
			if(com==0){ t_cnt++; h_cnt++; }
			else if(com>0) t_cnt+=3;
			else h_cnt+=3;
		}
		System.out.println(t_cnt + " " + h_cnt);
	}
}

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

int main(){
    long long N,M;
    cin>>N>>M;

    long long ans = N*M;

    if(N == 1 || M == 1){
        if(N == 1 && M == 1) ans = 1;
        else ans = N*M-2;
    }

    else ans = N*M-2*(N+M-2);

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}


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

    string S;cin >> S;
    //int G = 0,P = 0;
    int ans = 0;
    for(int i = 0;i<S.size();i++){
        if(i % 2 == 0){
            if(S.at(i) == 'p') ans--;
        }
        else{
            if(S.at(i) == 'g') ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  int a,b;
  a = 29;
  
  for(int i=0; i<N; i++){
    
    int x;
    cin >>x;
    b=0;
    
    while(x % 2 == 0){
      b++;
      x /= 2;
    }
    
    if(b<a){
      a = b;
    }
  }
  cout <<a <<endl;
}

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

using namespace std;

int simulate(vector<long long int> A){
  int N = A.size(), ret = 0;
  while(1){
    int t = 0;
    for(int i = 0; i < N; ++i){
      if(A[i] > A[t]) t = i;
    }
    if(A[t] < N) break;
    for(int i = 0; i < N; ++i){
      if(i != t) ++A[i];
      else A[i] -= N;
    }
    ++ret;
  }
  return ret;
}

int main(){
  long long int K, M = 1e16 + 1e3 + 1;
  cin >> K;
  vector<long long int> A(50);
  for(long long int i = 0; i < 50; ++i) A[i] = i + K/50;
  K %= 50;
  for(int i = 0; i < K; ++i) ++A[49-i];
  //cout << simulate(A) << endl;
  cout << 50 << endl;
  cout << A[0];
  for(int i = 1; i < 50; ++i) cout << " " << A[i];
  cout << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }
    int tmp = 0;
    rep(i, n){
        tmp = a[tmp];
        if(tmp==1){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n;
struct point{double x,y;}st,ed;
struct circle{point p;double r;}cir[1010];
struct node{int to,nxt;double cost;}sq[2002000];
int all=0,head[1010];
double dis[1010];
bool vis[1010];
struct hnode{int u;double dis;};
bool operator <(hnode p,hnode q) {return p.dis>q.dis;}
priority_queue<hnode> q;

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

void add(int u,int v,double w)
{
	all++;sq[all].to=v;sq[all].nxt=head[u];sq[all].cost=w;head[u]=all;
}

double calc(point a,point b)
{
	return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
}

int main()
{
	st.x=read();st.y=read();ed.x=read();ed.y=read();
	n=read();
	rep(i,1,n) 
	{
		cir[i].p.x=read();cir[i].p.y=read();cir[i].r=read();
	}
	cir[++n]=(circle){st,0};
	cir[++n]=(circle){ed,0};
	rep(i,1,n) rep(j,i+1,n)
	{
		double dis=calc(cir[i].p,cir[j].p)-cir[i].r-cir[j].r;
		dis=max(dis,0.0);
		add(i,j,dis);add(j,i,dis);
	}
	rep(i,1,n) dis[i]=1e18;
	dis[n-1]=0;q.push((hnode){n-1,0});
	while (!q.empty())
	{
		int u=q.top().u;q.pop();
		if (vis[u]) continue;vis[u]=1;
		go(u,i)
		{
			int v=sq[i].to;
			if (dis[v]>dis[u]+sq[i].cost)
			{
				dis[v]=dis[u]+sq[i].cost;
				if (!vis[v]) q.push((hnode){v,dis[v]});
			}
		}
	}
	printf("%0.10lf",dis[n]);
	return 0;
}


Measured memory_bytes: 22256
N,M=map(int,input().split())
if N>M:
    print(0)
    exit()
lst=list(map(int,input().split()))
lst.sort()
sum_1=max(lst)-min(lst)
D=[]
for i in range(1,M):
    D.append(lst[i]-lst[i-1])
D.sort(reverse=True)
sum_2=0
for i in range(N-1):
    sum_2+=D[i]
ans=0
ans=sum_1-sum_2
print(ans)


Measured memory_bytes: 20596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  int tar[M];
  for(int i=0;i<M;i++)
    cin>>tar[i];
  int fri[M][N];
  int mem[N]={0};
  int num=0;
  for(int i=0;i<M;i++){
    num=0;
    for(int j=0;j<N;j++){
      cin>>fri[i][j];
      if(tar[i]==fri[i][j])
	mem[j]++;
      else
	num++;
    }
    mem[tar[i]-1]+=num;
  }
  for(int i=0;i<N;i++)
    cout<<mem[i]<<endl;
  return 0;
}

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

using namespace std;

int main(){
    long n;
    cin>>n;
    vector<long> a(n);
    double sum = 0;
    for(int i=0; i<n; ++i){
        cin>>a[i];
        sum = sum + 1.0/a[i];
    }

    cout<<std::setprecision(10)<<1.0/sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
const int INF = 1000000;
int h, w;
int sx, sy; 
int gx, gy;
vector<string> maze;
vector<vector<int>> dist(30, vector<int>(30));

int dfs(int sx, int sy, int gx, int gy){
    queue<pair<int,int>> que;

    rep(i, h)rep(j, w) dist[i][j] = INF; 

    que.push(P(sx, sy));
    dist[sx][sy] = 0;

    while(que.size()){
        P p = que.front(); que.pop();
        if(p.first == gx and p.second == gy) break;

        rep(i, 4){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(0 <= nx and nx < h and 0 <= ny and ny < w and 
            maze[nx][ny] != '#' and dist[nx][ny] == INF){
                que.push(P(nx, ny));
                dist[nx][ny] = dist[p.first][p.second] + 1;
            }
        }
    }
    return dist[gx][gy];
}

int main(){
    cin >> h >> w;
    maze.resize(h);
    rep(i, h) cin >> maze[i];
    int max_ans = 0;
    rep(i, h){
        rep(j, w){
            rep(k, h){
                rep(l, w){
                    if(maze[i][j] == '#' or maze[k][l] == '#') continue;
                    sx = i, sy = j;
                    gx = k, gy = l;
                    max_ans = max(dfs(i, j, k, l), max_ans);
                }
            }
        }
    }
    cout << max_ans << endl;
}

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

int main(){
	int N;
	int a[100000];
	int count[100000]={0};
	int result=0;
	scanf("%d",&N);
	for(int i=0; i<N; i++)
		scanf("%d",&a[i]);
	sort(a,a+N);
	for(int i=0; i<N; ){
		for(int j=i; j<N; j++){
			if(a[i]==a[j]){
				count[i]++;
			}
			if(a[i]!=a[j])
				break;
		}
		if(count[i]>=a[i]){
			result+=count[i]-a[i];
		}
		else{
			result+=count[i];
		}
		i+=count[i];
		}
	printf("%d\n",result);
	return 0;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
a = list(map(int, input().split()))

s = sum((1 / a[i]) * (a[i] * (a[i] + 1) // 2) for i in range(k))

m = s

for i in range(k, n):
    s += (1 / a[i]) * (a[i] * (a[i] + 1) // 2)

    i -= k

    s -= (1 / a[i]) * (a[i] * (a[i] + 1) // 2)

    m = max(m, s)

print('%.12f'%m)

Measured memory_bytes: 24804
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int days[][11] = {
	0, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19,
	0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
};

int solve( int y, int m, int d )
{
	int res = -( accumulate( days[ y % 3 == 0 ], days[ y % 3 == 0 ] + m, 0 ) + d );
	for ( ; y < 1000; y++ )
	{
		res += accumulate( days[ y % 3 == 0 ], days[ y % 3 == 0 ] + 11, 0 );
	}
	return res + 1;
}

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

	int n;
	cin >> n;

	REP( i, 0, n )
	{
		int y, m, d;
		cin >> y >> m >> d;
		cout << solve( y, m, d ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main()
{
	bool DP[100001][2];
	int N,K,arr[101];
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		cin>>arr[i];
	}
	DP[0][0]=1;
	DP[0][1]=0;
	for(int i=1;i<=K;i++)
	{
		for(int j=0;j<2;j++)
		{
			bool best=j^1;
			for(int n=0;n<N;n++)
			{
				if(i>=arr[n]&&best!=j)
				{
					best=DP[i-arr[n]][j^1];
				}
			}
			DP[i][j]=best;
		}
	}
	if(DP[K][1]) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>

using namespace std;

int main()
{
  long long n,d;
  cin>>n>>d;
  long long x,y;
  int ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>x>>y;
    if(d*d>=(x*x+y*y))
    {
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

#define ll long long
const ll mod = 1e9 + 7;

int main () {
    ll A, B, N;
    cin >> A >> B >> N;
    ll val = min (B - 1, N);
    cout << floor((A * val) / B) << endl;
    return 0;   
}


Measured memory_bytes: 3820
N=int(input())
if N==1:
    print(0)
else:
    sup=int(N**0.5)
    ans=0
    kari=N
    div=[]
    for i in range(2,sup+1):
        if kari<i:
            break
        if kari%i==0:
            count=0
            while kari%i==0:
                count+=1
                kari//=i
            div.append(count)
    if kari!=1:
        div.append(1)

    for x in div:
        num=1
        while x-num>=0:
            ans+=1
            x-=num
            num+=1
    print(ans)


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

int main(){
 int N;
  int P[200010];
  cin>>N;
  for(int i=0;i<N;i++)cin>>P[i];
  int count=1;
    int MIN=P[0];
  for(int i=1;i<N;i++){
    if(MIN>=P[i])count++;
    MIN=min(MIN,P[i]);
  }
  cout<<count<<endl;
}
      
 
  
 

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

typedef long long ll;
using namespace std;



bool isPrime(int n){
    if(n < 2){
        return 0;
    }
    if(n%2 == 0){
        return n==2;
    }
    for(int i=3;i*i<=n;i++){
        if(n%i == 0) return 0;
    }
    return 1;
}


int main() {

    ll n,m,k;
   cin>>n>>m>>k;
   vector<ll> a(n);
   vector<ll> b(m);
   for(int i=0;i<n;i++)cin>>a[i];
   for(int i=0;i<m;i++)cin>>b[i];
   ll t = 0;
   ll no1 = 0;
   ll no2 = 0;
    for(int i=1;i<n;i++)a[i]+=a[i-1];
    for(int i=1;i<m;i++)b[i]+=b[i-1];
    for(int i=0;i<n;i++){
        ll curr = a[i];
      //  cout<<curr<<endl;
        if(curr> k) break;
        auto it = lower_bound(b.begin(),b.end(),k-curr+1);
        int indx = it-b.begin();
       // cout<<"indx "<<indx<<" val "<<*it<<endl;
        if(indx <= 0 ) indx=0;
        no1 = max((ll)(i+1+indx),no1);
    }
    for(int i=0;i<m;i++){
        ll curr = b[i];
        if(curr> k) break;
        auto it = lower_bound(a.begin(),a.end(),k-curr+1);
        int indx = it-a.begin();
        if(indx <= 0 ) indx=0;
        no2 = max((ll)(i+1+indx),no2);
    }

    cout<<max(no1,no2)<<endl;

   
    return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, auto init = 0) {
    return std::accumulate(all(vec), T(init));
}
// -------------------------------------------------------------------

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

    int x, y;
    cin >> x >> y;

    print(x + y / 2);

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
-- extension section
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}
-- not supported extension
--{-# LANGUAGE Strict, StrictData #-}


module Main where

-- @@@@@@@@@@@@@@@@@--
-- import section   --
-- @@@@@@@@@@@@@@@@@--
--    import A.B.C( function name )  ...
-- or import A.B.C 

--
import Prelude hiding(
  getLine,
  getContents,
  lines,
  words,
  read
  )

--
import Data.Either 
import Control.Monad

-- bytestring


-- containers


-- deepseq


-- regex-posix


-- text
import Data.Text.Lazy.IO as TIO
import Data.Text.Lazy as T
import Data.Text.Lazy.Read as TR

-- import Data.Text.IO as TIO
-- import Data.Text as T
-- import Data.Text.Read as TR

-- unordered-containers


-- vectors
import Data.Vector.Unboxed as UV
import Data.Vector.Unboxed.Mutable as MV

-- mtl
import Control.Monad.ST


-- @@@@@@@@@@@@@@@@@--
-- main section     --
-- @@@@@@@@@@@@@@@@@--

main :: IO ()
main = do
  input <- getInput
  Prelude.putStr . show . getAnswer $ input 
 
-- main :: IO()
-- main = do
--   answer <- getInputandanser
--   putStr . show $ answer


-- @@@@@@@@@@@@@@@@@@@@@--
-- I/O DataType section --
-- @@@@@@@@@@@@@@@@@@@@@--
data Input = I (Int,[Int] )
  deriving(Show)

type Answer = Int

-- instance Show Answer where
--   show = undefined


-- @@@@@@@@@@@@@@@@@--
-- answerSection    --
-- @@@@@@@@@@@@@@@@@--
getInput :: IO Input
getInput = do
  Right (n, _) <- getLine >>= ( return . TR.decimal )
  text2 <- getLine 
  let
    numTexts = fmap textToInt $ words text2 
  return (I (n, numTexts) )
  where 
    textToInt t = case TR.decimal t of
      Right (m , _) -> m

getAnswer :: Input -> Answer 
getAnswer ( I (_ , nums) ) = runST $ do  
  vec <- UV.thaw v
  _ <- Control.Monad.forM_ nums $ \num -> do
    MV.modify vec (+1) (num + 1)
    MV.modify vec (+1) (num-1 + 1)
    MV.modify vec (+1) (num+1 + 1)
    return ()
  returnV <- freeze vec  
  return ( UV.maximum returnV  )
  where v = UV.replicate (100000 + 2)  0 :: UV.Vector Int

getInputAndAnser :: IO Answer
getInputAndAnser = undefined


-- @@@@@@@@@@@@@@@@@@@@@@@@@@--
-- question unique section    --
-- @@@@@@@@@@@@@@@@@@@@@@@@@@--





-- @@@@@@@@@@@@@@@@@--
-- util section     --
-- @@@@@@@@@@@@@@@@@--

-- standard Input Function
gLine :: IO Text
gLine = getLine

gContents :: IO Text
gContents = getContents



Measured memory_bytes: 5500
import java.io.*;
import java.util.*;
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static long p=1000000007;
	static long[][][]dp;
	static String s;
	static int n;
	static int k;
	static long count(int ind,int mod,int st)
	{
		if(ind==n && mod==0)
			return 1;
		if(ind==n)
			return 0;
		if(dp[ind][mod][st]!=-1)
			return dp[ind][mod][st];
		int x=s.charAt(ind)-'0';
		if(st==0)
			x=9;
		long res=0;
		for(int i=0;i<=x;i++)
		{
			int status=(st==1 && i==x)?1:0;
			res=(res+count(ind+1,(mod+i)%k,status))%p;
		}
		dp[ind][mod][st]=res;
		return res;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		s=br.readLine();
		n=s.length();
		k=cin();
		dp=new long[n+1][k+1][2];
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=k;j++)
			{
				Arrays.fill(dp[i][j], -1);
			}
		}
		System.out.println((count(0,0,1)-1+p)%p);
	}
}


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

int main(){
  int n,t;
  cin >> n >> t;
  int a[n];
  vector<int> benefit;
  for(int i = 0;i < n;i++) cin >> a[i];
  priority_queue<int> que;
  set<int> s;
  for(int i = 0;i < n;i++) s.insert(-a[i]);
  for(int i = 0;i < n-1;i++){
    que.push(-a[i]);
    s.erase(-a[i]);
    auto iter = s.lower_bound(-1000000007);
    benefit.push_back(-(-*iter+que.top()));
  }
  sort(benefit.begin(),benefit.end());
  int b = -benefit.at(0);
  set<int> s2;
  int result = 0;
  for(int i = 0;i < n;i++) s2.insert(a[i]);
  for(int i = 0;i < n-1;i++){
    s2.erase(a[i]);
    auto iter = s2.lower_bound(a[i]+b);
    if(iter != s2.end() && *iter == a[i]+b){
      result++;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 6400