akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ABC149
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] strs = Console.ReadLine().Split(' ');
			ulong[] nums = new ulong[strs.Length];
			for(int i = 0; i < strs.Length; i++)
			{
				nums[i] = ulong.Parse(strs[i]);
			}

			ulong a = nums[0];
			ulong b = nums[1];
			ulong k = nums[2];

			if(a + b < k)
			{
				a = 0;
				b = 0;
			}
			else
			{
				if (a >= k)
				{
					a = a - k;
				}
				else
				{
					b -= k - a;
					a = 0;
				}
			}
			
			Console.WriteLine(a.ToString() + ' ' + b.ToString());
		}
	}
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int main(){
	int n;cin>>n;
	n=n%10;
	if(n==2||n==4||n==5||n==7||n==9) puts("hon");
	if(n==0||n==1||n==6||n==8) puts("pon");
	if(n==3) puts("bon");
}


Measured memory_bytes: 3624
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

// a^n (mod m)
fn mod_pow(a: i64, n: u32, m: i64) -> i64 {
    if n == 0 {
        return 1;
    }

    if n == 1 {
        return a % m;
    }

    if n % 2 == 1 {
        let k = mod_pow(a, (n - 1) / 2, m);
        let mut ans = (a * k) % m;
        ans = (ans * k) % m;
        return ans;
    } else {
        let k = mod_pow(a, n / 2, m);
        let ans = (k * k) % m;
        return ans;
    }
}

fn main() {
    input! {
       S: i64,
    }

    const MOD: i64 = 1000_000_000 + 7;

    let mut ans: i64 = 0;
    let max_group: i64 = S / 3; // 切り捨て

    if S <= 2 {
        println!("0");
        return;
    }

    let mut fact_mod: Vec<i64> = vec![0; S as usize + 1];
    fact_mod[0] = 1;
    fact_mod[1] = 1;
    for i in 2..=S {
        let ind = i as usize;
        fact_mod[ind] = (i * fact_mod[ind - 1]) % MOD;
    }

    // グループ数をまず決めて、その場合の数を求める
    // 11を3グループ → OOOO|OOOO|OOO 仕切りの考え方
    for group_num in 1..=max_group {
        // まず各グループに3人ずつ配備する
        let mut rest = S;
        rest -= 3 * group_num;

        // あとは仕切りの考え方で分割
        // let cand = comb(rest+group_num-1,group_num-1, MOD);
        let fact_rest = fact_mod[rest as usize];
        let fact_inv_rest = mod_pow(fact_rest, (MOD - 2) as u32, MOD);

        let fact_gn_1 = fact_mod[(group_num - 1) as usize];
        let fact_inv_gn_1 = mod_pow(fact_gn_1, (MOD - 2) as u32, MOD);

        let mut cand = (fact_mod[(rest + group_num - 1) as usize] * fact_inv_rest) % MOD;
        cand = (cand * fact_inv_gn_1) % MOD;

        ans = (ans + cand) % MOD;
    }

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


Measured memory_bytes: 2192
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b) / 2 + (a + b) % 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final String s = scanner.next();
        final String t = scanner.next();

        IntStream.rangeClosed(0, s.length() - t.length())
            .mapToLong(i -> IntStream.range(0, t.length())
                .filter(j -> t.charAt(j) != s.charAt(i + j))
                .count())
            .min()
            .ifPresent(System.out::println);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}


Measured memory_bytes: 35148
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;

int main(){
	int a, b, k;
	cin>>a>>b>>k;
	while(k){
		if(k>=2){
			a/=2;
			b+=a;
			b/=2;
			a+=b;
			k-=2;
		}else{
			a/=2;
			b+=a;
			k--;
		}
	}
	cout<<a<<" "<<b<<"\n";
}

Measured memory_bytes: 256
X, K, D = list(map(int, input().split()))

X = abs(X)
count = X // D

if count >= K:
    answer = X - K*D
else:
    if (K - count) % 2 == 0:
        answer = X - count*D
    else:
        answer = abs(X - (count+1)*D)

print(answer)

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


int main() {
    int S;
    cin >> S;
    string ans;
    int anum,bnum;
    bool aflag,bflag;
    anum = S/100;
    bnum = S - anum*100;

    if(1 <= anum && anum <= 12){
        aflag = true;
    }else{
        aflag = false;
    }

    if(1 <= bnum && bnum <= 12){
        bflag = true;
    }else{
        bflag = false;
    }

    if(aflag == true && bflag ==false){
        ans = "MMYY";
    }else if(aflag == false && bflag ==true){
        ans = "YYMM";
    }else if(aflag == true && bflag ==true){
        ans = "AMBIGUOUS";
    }else if(aflag == false && bflag ==false){
        ans = "NA";
    }

    cout << ans << endl;

}


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

int main(){
    ll s;
    cin>>s;
    ll x=(s+INF-1)/INF;
    ll y=x*INF-s;
    cout<<"0 0 1 1000000000 "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
par,rank = [i for i in range(n+1)],[0 for i in range(n+1)]
def root(x):
	if par[x]!=x: par[x] = root(par[x])
	return par[x]
def unite(x,y):
	x2,y2 = root(x),root(y)
	if x2!=y2:
		if rank[x2]<rank[y2]: par[x2] = y2
		else: par[y2] = x2
		if rank[x2]==rank[y2]: rank[x2]+=1
p = [int(i) for i in input().split()]
x = [[int(i) for i in input().split()] for i in range(m)]
for i,j in x: unite(i,j)
ans = -1
for i,j in enumerate([0]+p):
	if root(i)==root(j): ans += 1
print(ans)

Measured memory_bytes: 30656
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a: Vec<i64> = sc.vec(n);

    let mut k = -1;
    let b: Vec<i64> = a
        .iter()
        .map(|e| {
            k += 1;
            e + k
        })
        .collect();
    k = -1;
    let c: Vec<i64> = a
        .iter()
        .map(|e| {
            k += 1;
            k - e
        })
        .collect();
    let mut ans: i64 = 0;
    let mut count: std::collections::BTreeMap<i64, i64> = std::collections::BTreeMap::new();
    for i in 0..n {
        ans += *count.entry(c[i]).or_insert(0);
        *count.entry(b[i]).or_insert(0) += 1;
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

int Pow(int m, int n) {
  if (n == 0)
    return 1;

  int res = Pow(m * m, n / 2);
  if (n % 2 == 1)
    res = res * m;

  return res;
}

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

  int n2 = n;
  map<int, int> m;
  for (int i = 2; i * i <= n; ++i)
    while (n2 % i == 0)
      ++m[i], n2 /= i;

  if (n2 != 1)
    ++m[n2];

  int ans = 1;
  for (auto i : m)
    ans *= Pow(i.first, i.second - 1) * (i.first - 1);

  cout << ans << endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[100005];

ll comb(ll a, ll b) {
  if(a<b) return 0;
  ll ans = frac[a];
  ll sh1, sh2;
  ll two, h=mod-2;
  while(h>0) {
    two = 1;
    sh1 = frac[b];
    sh2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      sh1 *= sh1;
      sh1 %= mod;
      sh2 *= sh2;
      sh2 %= mod;
    }
    h -= two;
    ans *= sh1*sh2%mod;
    ans %= mod;
  }
  return ans;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<100005;++i) frac[i] = frac[i-1]*i%mod;
  int N;
  cin>>N;
  int A[N];
  map<int, int> amap;
  int doub;
  for(int i=0;i<=N;++i) {
    cin>>A[i];
    if(amap[A[i]]==1) doub = A[i];
    amap[A[i]]++;
  }
  int L=0, M=0, R=0;
  int doubnum = 0;
  for(int i=0;i<=N;++i) {
    if(A[i]==doub) {
      doubnum++;
      continue;
    }
    if(doubnum==0) L++;
    else if(doubnum==1) M++;
    else R++;
  }
  ll ans[N+1];
  for(int i=1;i<=N+1;++i) {
    ans[i-1] = (((comb(L+M+R, i)+comb(L+M+R, i-2))%mod+comb(L+M+R, i-1)*2%mod)%mod-comb(L+R, i-1)+mod)%mod;
  }
  for(int i=0;i<=N;++i) cout<<ans[i]<<endl;
}


Measured memory_bytes: 10212
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef int ll;
typedef long double ld;
using namespace std;
typedef pair<int, int> pi;

vector<vector<pi>> mp(400000, vector<pi>());
vvl item = VV(400000, 2, 0, ll); // W, V

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  for(int i=1;i<=n;i++) scanf("%d %d", &item[i][1], &item[i][0]);

  ll th = (1<<12)-1;
  for(int i=1;i<=min(th, n);i++){
    mp[i].push_back(pi(item[i][0], item[i][1])); // w, v
    ll par = i/2;
    if(par==0) continue;
    for(auto t:mp[par]){
      mp[i].push_back(pi(t.first + item[i][0], t.second + item[i][1]));
      mp[i].push_back(pi(t.first, t.second));
    }
    sort(all(mp[i]), [](pi a, pi b){
      if(a.first==b.first) return a.second > b.second;
      return a.first < b.first;
    });
    ll m = 0;
    for(int j=0;j<mp[i].size();j++){
      m = max(m, mp[i][j].second);
      mp[i][j].second = m;
    }
  }

  for(int i=th+1;i<=n;i++){
    mp[i].push_back(pi(item[i][0], item[i][1])); // w, v
    ll par = i/2;
    if(par>th){
      for(auto t:mp[par]){
        mp[i].push_back(pi(t.first + item[i][0], t.second + item[i][1]));
        mp[i].push_back(pi(t.first, t.second));
      }
    }
    sort(all(mp[i]), [](pi a, pi b){
      if(a.first==b.first) return a.second > b.second;
      return a.first < b.first;
    });
    ll m = 0;
    for(int j=0;j<mp[i].size();j++){
      m = max(m, mp[i][j].second);
      mp[i][j].second = m;
    }
  }

  ll q;std::cin >> q;

  for(int i=0;i<q;i++){
    ll u, l;scanf("%d %d", &u, &l);
    if(u<=th){
      auto itr = upper_bound(all(mp[u]), pi(l, 1000000000));
      if(itr==mp[u].begin()) std::cout << 0 << '\n';
      else{
        itr--;
        std::cout << (*itr).second << '\n';
      }
    }else{
      ll p = u;
      while(p>th) p/=2;
      ll ans = 0;

      for(auto t:mp[u]){
        ll w = t.first, v = t.second;
        if(w>l) continue;
        ans = max(ans, v);
        // l - w 以下のもの
        auto itr = upper_bound(all(mp[p]), pi(l-w, 100000000));
        if(itr==mp[p].begin()) ans = max(ans, v);
        else{
          itr--;
          ans = max(ans, v + (*itr).second);
        }
      }
      auto itr = upper_bound(all(mp[p]), pi(l, 100000000));
      if(itr!=mp[p].begin()){
        itr--;
        ans = max(ans, (*itr).second);
      }
      std::cout << ans << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 213128
N,M=map(int,input().split())
P=[];S=[]
judge=[0]*N
wa_c=[0]*N

for m in range(M):
  p,s = input().split()
  P.append(int(p))
  S.append(s)
  
for m in range(M):
  if judge[P[m]-1]==0 and S[m]=="WA":
    wa_c[P[m]-1] +=1
   
  elif judge[P[m]-1]==0 and S[m]=="AC":
    judge[P[m]-1]=1
    

for n in range(N):
  if judge[n]==0:
    wa_c[n]=0
  
  
print(sum(judge),sum(wa_c))

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

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

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

    int q;
    cin >> q;

    while(q-- > 0){
        int k;
        cin >> k;
        cout << (a[lower_bound(a, a+n, k)-a] == k) << endl;
    }

    return 0;
}


Measured memory_bytes: 3488
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] ans = new int[N+1];
		for( int i=0; i<=N-2; i++ ){
			if( S.charAt(i)=='A' && S.charAt(i+1)=='C' ){
				ans[i+2] += ans[i+1]+1;
			}else{
				ans[i+2] += ans[i+1];              
            }              
		}              
		for( int i=0; i<Q; i++ ){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(ans[b] - ans[a]);          
		}
	}
}


Measured memory_bytes: 66352
use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        l_vec: [i32; n]
    }

    let mut patterns_num = 0;
    for combination in (0..n as usize).combinations(3) {
        let mut edges = vec![
            l_vec[combination[0]],
            l_vec[combination[1]],
            l_vec[combination[2]],
        ];
        edges.sort();

        let is_different = edges[0] != edges[1] && edges[1] != edges[2] && edges[0] != edges[2];
        let is_triangle = edges[0] + edges[1] > edges[2];
        if is_different && is_triangle {
            patterns_num += 1;
        }
    }
    println!("{}", patterns_num);
}


Measured memory_bytes: 2144
d,m=1e9+7,dp[10001][2][100];l;
char s[11111];
main()
{
	scanf("%s%d",s,&d);
	l=strlen(s);
	dp[0][0][0]=1;
	for(int i=0;i<l;i++)
	{
		for(int j=0;j<2;j++)
		{
			int L=j?9:s[i]-48;
			for(int l=0;l<=L;l++)
			{
				for(int k=0;k<d;k++)
					dp[i+1][j|l<L][(k+l)%d]=(dp[i+1][j|l<L][(k+l)%d]+dp[i][j][k])%m;
			}
		}
	}
	printf("%d",(dp[l][0][0]+dp[l][1][0]-1+m)%m);
}

Measured memory_bytes: 7936
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

x,y = map(int,input().split())

a = x
ans = 0

while a <= y:
	#print(a)
	ans = ans + 1
	a = a*2

print(ans)


Measured memory_bytes: 38384
n = int(input())

alphabets = [chr(ord('a') + x) for x in range(26)]

tmp = []

def dfs(s, i):
    if len(s) == n:
        yield s
        return
    for j in range(i):
        for k in dfs(s+alphabets[j], i):
            yield k
    for k in dfs(s+alphabets[i], i+1):
        yield k

for w in dfs('', 0):
    print(w)

Measured memory_bytes: 9100
N = int(input())
A = list(map(int,input().split()))
ans = 0
dic = {}
for i in range(1,N):
  x = i-A[i]
  if x<0:
    continue
  else:
    if x in dic:
      dic[x]+=1
    else:
      dic[x]=1
if A[0] in dic:
  ans+=dic[A[0]]
for i in range(1,N):
  x = i+A[i]
  
  if i-A[i] in dic:
    dic[i-A[i]]-=1
    
  if x in dic:
    ans+=dic[x]
  
print(ans)

Measured memory_bytes: 32192
import sys
from io import StringIO
import unittest
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

import re


def resolve():
    s_prime = sys.stdin.readline().split()[0]
    T = sys.stdin.readline().split()[0]
    logger.debug(s_prime)
    logger.debug(T)

    s_len = len(s_prime)
    t_len = len(T)

    r_s_prime = s_prime[::-1]
    r_t = T[::-1]

    answer = "UNRESTORABLE"
    for i_s, s_char in enumerate(r_s_prime):
        if s_len - i_s >= t_len:
            is_match = True
            for i_t, t_char in enumerate(r_t):
                if r_s_prime[i_s + i_t] == '?' or r_s_prime[i_s +
                                                            i_t] == t_char:
                    pass
                else:
                    is_match = False
                    break

            if is_match:
                answer = r_s_prime[:i_s] + r_t + r_s_prime[i_s + len(r_t):]
                answer = answer[::-1]
                pattern = re.compile(r'\?')
                answer = pattern.sub('a', answer)
                break
        else:
            break

    print(answer)


if __name__ == "__main__":
    resolve()


# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """?tc????
coder"""
        output = """atcoder"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """??p??d??
abc"""
        output = """UNRESTORABLE"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """?
a"""
        output = """a"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """?
ab"""
        output = """UNRESTORABLE"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """??????????
abc"""
        output = """aaaaaaaabc"""
        self.assertIO(input, output)

Measured memory_bytes: 5612
h, w = map(int, input().split())
grid = []
for i in range(h):
    grid.append(list(input()))



grid = list(filter(lambda r: any([i=='#' for i in r]), grid))
grid = zip(*grid)
grid = list(filter(lambda r: any([i=='#' for i in r]), grid))
grid = zip(*grid)
for i in grid:
    print(''.join(i))

Measured memory_bytes: 39860
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}
 

int main(){
   fastIO();
   int n;
   string s;
   cin>>n>>s;
   if(n%2!=0){
   	cout<<"No"<<endl;
   }else{
   	 string s1="";
   	 string s2="";
   	 for(int i=0;i<(n/2);i++){
   	 	s1+=s[i];
   	 }
   	 for(int i=n/2;i<n;i++){
   	 	s2+=s[i];
   	 }
   	 if(s1==s2){
   	 	cout<<"Yes"<<endl;
   	 }else{
   	 	cout<<"No"<<endl;
   	 }
   }
}  
//VERIFICAR LONG VS INT
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<string> v;
    for(int i = 0; i < n; i++) {
        string S;
        cin >> S;
        sort(S.begin(), S.end());
        v.push_back(S);
    }

    int alphabet[n][26];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 26; j++) alphabet[i][j] = 0;

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < v[i].size(); j++) {
            alphabet[i][(int)v[i][j] - (int)'a']++;
        }
    }

    int mins[26];
    for(int i = 0; i < 26; i++) {
        int minimum = inf;
        for(int j = 0; j < n; j++) {
            minimum = min(minimum, alphabet[j][i]);
        }
        mins[i] = minimum;
    }
    string ans;
    for(int i = 0; i < 26; i++) {
        for(int j = 0; j < mins[i]; j++) ans += (char)((int)'a' + i);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>


int main()
{
	int *S, n;
	int *T, q;
	int left, right, center, num;
	int count;
	int i, j;


	scanf("%d", &n);
	S = (int *)malloc(sizeof(int) * n);
	for(i = 0; i < n; i++)
		scanf("%d", &S[i]);

	scanf("%d", &q);
	T = (int *)malloc(sizeof(int) * q);
	for(i = 0; i < q; i++)
		scanf("%d", &T[i]);


	count = 0;
	for(i = 0; i < q; i++){
		left = 0;
		right = n - 1;
		while(left <= right){
			center = (left + right) / 2;
			num = S[center];
			if(T[i] == num){
				count++;
				break;
			}else if(T[i] < num)
				right = center - 1;
			else if(num < T[i])
				left = center + 1;
		}
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2292
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque

def main():
    h,w = map(int,input().split())
    grid = [input() for _ in range(h)]
    dist = [[-1] * w for _ in range(h)]
    
    q = deque()
    for i in range(h):
        for j in range(w):
            if grid[i][j] == '#':
                q.append((i,j))
                dist[i][j] = 0
    
    ans = 0
    while q:
        i,j = q.popleft()
        for k in range(4):
            y = i + dy[k]
            x = j + dx[k]
            if 0 <= y < h and 0 <= x < w and dist[y][x] == -1:
                dist[y][x] = dist[i][j] + 1
                ans = max(ans,dist[y][x])
                q.append((y,x))
    
    print(ans)

if __name__ =='__main__':
    main()  


Measured memory_bytes: 86876
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    vector<int> m(n);
    vector< vector<lint> > c(n);
    rep(i, n){
        cin >> m[i];
        c[i].resize(m[i]);
        rep(j, m[i]){
            cin >> c[i][j];
        }
    }

    priority_queue<lint> que;
    lint ans = 0;

    rrep(i, n){
        rep(j, m[i]){
            que.push(c[i][j]);
        }
        ans += que.top();
        que.pop();
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}


Measured memory_bytes: 20444
#include <stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if (a < b && b < c){
        printf("Yes\n");
    }

    else {
        printf("No\n");
    }
    
    return 0;
    
}


Measured memory_bytes: 2100
al,ar,bl,br,cl,cr,dl,dr=0,0,0,0,0,0,0,0
while 1:
    try:
        l,r=map(float,raw_input().split())
        if l>=1.1:al+=1
        elif 0.6<=l<1.1:bl+=1
        elif 0.2<=l<0.6:cl+=1
        else:dl+=1

        if r>=1.1:ar+=1
        elif 0.6<=r<1.1:br+=1
        elif 0.2<=r<0.6:cr+=1
        else:dr+=1
    except EOFError:break
print "{} {}\n{} {}\n{} {}\n{} {}".format(al,ar,bl,br,cl,cr,dl,dr)

Measured memory_bytes: 4272
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

  long long h, w;
  int n;
  cin >> h >> w >> n;

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

  unsigned long long ans[10];
  for(int i=0; i<10; i++) {
    ans[i] = 0;
  }

  vector<pair<int, int>> window;

  for(int i=0; i<n; i++) {
    for(int j=0; j<3; j++) {
      for(int k=0; k<3; k++) {
        if(0 <= (a[i]-1)+j-2 && (a[i]-1)+j <= h-1
            && 0 <= (b[i]-1)+k-2 && (b[i]-1)+k <= w-1) {
          window.push_back(make_pair((a[i]-1)+j-2, (b[i]-1)+k-2));
        }
      }
    }
  }

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

  map<pair<int, int>, int> c;
  for(auto t: window) {
    ++c[t];
  }
  for(auto t: c) {
    ans[t.second]++;
  }

  ans[0] = (h-2) * (w-2);
  for(int i=1; i<10; i++) {
    ans[0] -= ans[i];
  }

  for(int i=0; i<10; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 64360
#include <stdio.h>

int main(){
  int n1, n2, S[10000], T[100000];
  int i, j, count = 0;
  
  scanf("%d",&n1);
  for(i = 0;i < n1;i++){
    scanf("%d", &S[i]);
  }
  
  scanf("%d",&n2);
  for(i = 0;i < n2;i++){
    scanf("%d",&T[i]);
  }
  
  for(i = 0;i < n2;i++){
    for(j = 0;j < n1;j++){
      if(T[i] == S[j]){
	count++; break;
      }
    }
  }
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
//打你马的ACM
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
typedef long long ll;
int main()
{
    int k;
    cin>>k;
    int target=7%k;
    int cnt=1;
    while(cnt<=k)
    {
        if(target==0)
        {
            cout<<cnt<<endl;
            return 0;
        }
        target=(target*10+7)%k;
        cnt++;
    }
    cout<<-1<<endl;
}


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

using namespace std;

void task()
{
    double l;

    scanf("%lf", &l);

    double rec = l / 3;

    double result = rec * rec * rec;

    printf("%0.8lf\n", result);
}

int main()
{
    task();

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<iterator>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<cstdint>
#include<chrono>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define chmax(a, b) (((a) < (b)) ? (b) : (a))
#define chmin(a, b) (((a) < (b)) ? (a) : (b))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

using namespace std;





signed main() {

	int H, W;
	cin >> H >> W;

	vector<vector<int>>A(H + 1, vector<int>(W + 1));
	vector<vector<int>>B(H + 1, vector<int>(W + 1));
	rep(i, H)rep(j, W)cin >> A[i + 1][j + 1];
	rep(i, H)rep(j, W)cin >> B[i + 1][j + 1];

	vector<vector<vector<uint8_t>>>answer(H + 1, vector<vector<uint8_t>>(W + 1, vector<uint8_t>(160 * 160 + 161)));

	answer[1][1][abs(A[1][1] - B[1][1])] = 1;

	for (int i = 1; i <= H; ++i)for (int j = 1; j <= W; ++j)for (int k = 0; k < 160 * 160; ++k) {
		if (answer[i - 1][j][abs(k - A[i][j] + B[i][j])])answer[i][j][k] = 1;
		if (answer[i - 1][j][abs(k + A[i][j] - B[i][j])])answer[i][j][k] = 1;
		if (answer[i][j - 1][abs(k - A[i][j] + B[i][j])])answer[i][j][k] = 1;
		if (answer[i][j - 1][abs(k + A[i][j] - B[i][j])])answer[i][j][k] = 1;
	}

	rep(i, 10000000) {
		if (answer[H][W][i]) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 169728
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

vector<int> divisor(int n)
{
    vector<int> divisor_list;
    for (int i = 1; i * i <= n; i++){
        if(n % i == 0){
            divisor_list.push_back(i);
            divisor_list.push_back(n / i);
        }
    }
    return divisor_list;
}

vector<int> mod_list(vector<int> a,int n)
{
    REP(i,a.size()){
        a[i] = a[i] % n;
    }
    return a;
}

int main(void)
{
    int n, k;
    int sum = 0;
    int ans = 1;
    cin >> n >> k;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }

    vector<int> div_l = divisor(sum);

    REP(i,div_l.size()){
        vector<int> mod_l = mod_list(a, div_l[i]);
        sort(all(mod_l));
        int mod_sum = 0;
        REP(j, mod_l.size()){
            mod_sum += mod_l[j];
        }
        int chcnt = mod_sum / div_l[i];
        int opecnt = 0;
        for (int j = mod_l.size() - 1; j >= mod_l.size() - chcnt; j--){
            opecnt += div_l[i] - mod_l[j];
        }
        if(opecnt <= k){
            chmax(ans, div_l[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np

def calc():
    _ = input()
    a = np.array([int(s) for s in input().split(" ")])
    ave = np.average(a)
    absolute = np.absolute(a - ave)

    return np.argmin(absolute)

if __name__ == '__main__':
    print(calc())

Measured memory_bytes: 21540
def gcd(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp

    r = a % b
    while r!=0:
        a = b
        b = r
        r = a % b
    return b

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

A, B, C, D = list(map(int, input().split()))
A_ = A - 1
lcm_CD = lcm(C, D)
B_res = B - (B//C + B//D - B//lcm_CD)
A_res = A_ - (A_//C + A_//D - A_//lcm_CD)
print(B_res - A_res)

Measured memory_bytes: 3064
num = int(input())
S = list(range(1,14))
H = list(range(1,14))
C = list(range(1,14))
D = list(range(1,14))
for i in range(1,num+1):
    a,b = input().split()
    b=int(b)
    if a == 'S':
        S[b-1]=0
    elif a == 'H':
        H[b-1]=0
    elif a == 'D':
        D[b-1]=0
    else:
        C[b-1]=0
    
Slist = [i for i in S if i != 0]
Hlist = [i for i in H if i != 0]
Dlist = [i for i in D if i != 0]
Clist = [i for i in C if i != 0]

for i in range(len(Slist)) :
    print("S "+ str(Slist[i]))
for i in range(len(Hlist)) :
    print("H "+ str(Hlist[i]))
for i in range(len(Clist)) :
    print("C "+ str(Clist[i]))
for i in range(len(Dlist)) :
    print("D "+ str(Dlist[i]))


Measured memory_bytes: 5608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	/**
	 * for (int i = 0; i < N; i++) {}
	 * System.out.println();
	 * HashMap<Integer, Integer> hm = new HashMap<>();
	 * int[] s = new int[M];
	 * ArrayDeque<Integer> deq = new ArrayDeque<>();
	 *
	 * 文字列のSort
	 * String sorted = S.chars()
						.sorted()
						.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
						.toString();
	 * for (char i = 'a'; i <= 'z'; i++) {}
	 */
	public void run() {
		FastScannerMain1 sc = new FastScannerMain1(System.in);

		try {
			//String S = sc.nextLine().trim();
			int N = sc.nextInt();
			long[] A = new long[N];
			long[] mid = new long[N];
			for (int i = 0; i < N; i++) {
				A[i] = sc.nextLong();
				mid[i] = A[i]-(i+1);
			}
			Arrays.sort(mid);


			int loc = (N-1)/2;
			long b = mid[loc];
			
			if((N-1)%2!=0){
				b = (mid[loc]+mid[loc+1])/2;
			}
			long ans = 0;
			for (int i = 0; i < N; i++) {
				ans+=Math.abs(A[i]-(b+(i+1)));
			}

			//System.out.println(Arrays.toString(A));
			
			//System.out.println(Arrays.toString(mid));
			//System.out.println(b);
			//System.out.println(loc);
			System.out.println(ans);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerMain1 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain1(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 57688
#include<iostream>
#include<cstdlib>
#include<vector>
#include <cmath>
#include <time.h>
using namespace std;

const int n_MAX = 50;

int main() {
  int n;
  int d[n_MAX];

  cin >> n;
  for (int i = 0; i < n; ++i) cin >> d[i];

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i != j) {
        cnt += d[i] * d[j];
      }
    }
  }

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


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;

public class Main {

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        Scanner sc = new Scanner(System.in);

        char[] s = nextString(sc).toCharArray();

        int count = 0;
        for (char c : s) {
            if (c == '1') {
                count++;
            }
        }

        out(count);

    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt(Scanner sc) {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString(Scanner sc) {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(Scanner sc, int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt(sc);
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }

    public static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }
}



Measured memory_bytes: 21716
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
     var line= chunk.split(' ');
     a = Number(line[0]);
     b = Number(line[1]);
     c = Number(line[2]);

 if( a < b && b < c ) {
    console.log( 'Yes' );
  } else {
    console.log( 'No' );
  }
});

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    i64 n, k;
    cin >> n >> k;
    vector<i64> a(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    vector<vector<i64>> v(40, vector<i64>(2, 0));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 40; ++j)
            ++v[j][1 ^ ((a[i] >> j) & 1)];
    }
    vector<i64> r(40, 0);
    for(int i = 0; i < 40; ++i)
        r[i] = max(v[i][0], v[i][1]) * (1LL << i);
    for(int j = 0; j < 39; ++j)
        r[j + 1] += r[j];
    i64 ans = 0;
    i64 sum = 0;
    for(int i = 39; i >= 0; --i){
        if(k & (1LL << i)){
            chmax(ans, sum + (v[i][0] * (1LL << i)) + (i ? r[i - 1] : 0));
        }
        sum += v[i][(k >> i) & 1] * (1LL << i);
    }
    cout << max(ans, sum) << endl;
}


Measured memory_bytes: 4032
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
    
using namespace std;

typedef long long ll;


int main() {
    int c[3];
    cin >> c[0] >> c[1] >> c[2];
    
    sort(c, c+2);
    cout << c[0]*c[1]/2 << endl;
}


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

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int c=a+b;
  if(c==3) cout <<3;
  else if(c==4) cout <<2;
  else if(c==5) cout<<1;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

// 素因数分解
std::map<long long, int> factor(long long n) {
	std::map<long long, int> factors;
	{
		int i = 0;
		while(n % 2 == 0) {
			n /= 2;
			i++;
		}
		if(i != 0) {
			factors[2] = static_cast<long long>(i);
		}
	}
	for(long long i = 3; i * i <= n; i += 2) {
		int j = 0;
		while(n % i == 0) {
			n /= i;
			j++;
		}
		if(j != 0) {
			factors[i] = j;
		}
	}
	if(n != 1) {
		factors[n] = 1;
	}
	return factors;
}

int main() {
	ll n;
	cin >> n;
	map<ll, int> factors = factor(n);
	ll result = 0;
	EACH(e, factors) {
		int i = 1;
		while(e.second >= i) {
			e.second -= i;
			result++;
			i++;
		}
	}
	cout << result << endl;
	return 0;
}


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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)
#define rreps(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rreps(v, 0, n - 1)
#define rlep(v, n) rreps(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define debug(x) std::cerr << #x << " = " << (x) << "\n";

using namespace std;

typedef long long int lint;

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

int main()
{
  map<string, int> dict;
  string word;
  while (cin >> word){
    if (dict.find(word) != dict.end()){
      dict[word] += 1;
    }
    else {
      dict.insert(make_pair(word, 1));
    }
  }
  int most_freq = 0;
  string most_string = "";
  string max_string = "";
  for (map<string, int>::iterator it = dict.begin(); it != dict.end(); it++){
    if (max_string.size() < (*it).first.size()){
      max_string = (*it).first;
    }
    if (most_freq < (*it).second){
      most_string = (*it).first;
      most_freq = (*it).second;
    }
  }
  cout << most_string << " " << max_string << endl;
  return 0;
}

Measured memory_bytes: 1196
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL =long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[11000][3][110], a[200000], b[200000];
string str, ss;
bool f;
char c[800][800];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<Edge>vec[20000];
vector<edge>ed;
vector<LL>v;
map<string,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> str;
	cin >> n;
	dp[0][1][0] = 1;
	rep(i, str.size()) {
		rep(j, 2) {
			rep(l, n) {
				int lim = (j == 0 ? 9 : str[i] - '0');
				rep(k, lim+1) {
					bool flag = ((j == 1 && str[i] - '0' == k) ? 1 : 0);
					dp[i + 1][flag][(l + k) % n] += dp[i][j][l];
					dp[i + 1][flag][(l + k) % n] %= MOD;
				}
			}

		}
	}
	
	cout << (dp[str.size()][0][0]+ dp[str.size()][1][0]-1+MOD)%MOD << endl;
	return 0;
}


Measured memory_bytes: 27392
//50
#include<iostream>
#include<algorithm>
#include<vector>

#define INF (1<<29)

using namespace std;

int eo[1000000];
int o[1000000];

int eoc,oc;

int p(int x){
  return x*(x+1)*(x+2)/6;
}

int main(){
  fill_n(eo,1000000,INF);
  fill_n(o,1000000,INF);
  eo[0]=0;
  o[0]=0;
  vector<int> eop,op;
  for(int i=1;p(i)<1000000;i++){
    eop.push_back(p(i));
    if(p(i)%2){
      op.push_back(p(i));
    }
  }
  for(int n;cin>>n,n;){
    while(eo[n]==INF){
      for(int i=0;i<1000000;i++){
	if(eo[i]==eoc){
	  for(int j=0;j<eop.size()&&i+eop[j]<1000000;j++){
	    eo[i+eop[j]]=min(eo[i]+1,eo[i+eop[j]]);
	  }
	}
      }
      eoc++;
    }
    cout<<eo[n]<<' '<<flush;
    while(o[n]==INF){
      for(int i=0;i<1000000;i++){
	if(o[i]==oc){
	  for(int j=0;j<op.size()&&i+op[j]<1000000;j++){
	    o[i+op[j]]=min(o[i]+1,o[i+op[j]]);
	  }
	}
      }
      oc++;
    }
    cout<<o[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 8716
#include <stdio.h>
int main()
{
  int i,n,array[100],t,y,j;
  
  scanf("%d\n",&n);
  
  for(i=0;i<n;i++){
    scanf("%d", &array[i]);
    
    printf("%d", array[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  printf("\n");

  
  for(i=1;i<=n-1;i++){
    t=i;

    while(t > 0 && array[t] < array[t-1]){
      y=array[t];
      array[t]=array[t-1];
      array[t-1]=y;
      t--;
    } 
    for(j=0;j<=n-1;j++){

      printf("%d", array[j]);
      if(j <= n-2){
	printf(" ");
      }
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  int X;
  cin >> X;
  
  if (X == 7 || X == 5 || X == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

ll nCr(ll n,ll r){
    if(r>n){
        return 0;
    }
    if(r*2>n){
        r=n-r;
    }
    if(r==0){
        return 1;
    }
    ll ans=n;
    for(ll i=2;i<=r;i++){
        ans*=(n-i+1);
        ans/=i;
    }
    return ans;
}

int main(){
    ll n,m,sum=0;
    cin>>n>>m;
    map<ll,ll> mp;
    mp[0]=1;
    for(ll i=0;i<n;i++){
        ll tmp;
        cin>>tmp;
        sum+=tmp;
        ll md=sum%m;
        if(mp.count(md)){
            mp[md]++;
        }else{
            mp[md]=1;
        }
    }
    sum=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        sum+=nCr(itr->second,2);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 4224