akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main(){
	char c[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	vector<int> ans(26,0);
	string str;
	char ch;
	while(cin>>ch){
		int n=ch-'0';
		if(49<=n && n<= 74){
			ans[n-49]+=1;
		}else if(17<=n && n<=42){
			ans[n-17]+=1;
		}
	}
	for(int i=0; i<ans.size(); i++){
		cout<<c[i]<<" : "<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){
	int n;
	int m=0;
	string s,t;
	cin >> n >> s >> t;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=(i-1);j++){
			if(s[n-i+j]!=t[j])break;
			if(j==(i-1))m=i;
		}
	}
	if(m==0)cout << 2*n << endl;
	else{
		cout << 2*n-m <<endl;
	}
	return 0;
}

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

int main() {
   int H,W,N;
   cin >> H >> W >> N;
   int a[N];
   for (int i=0; i<N; i++) {
       cin >> a[i];
   }
   vector<vector<int>> C(H,vector<int>(W));
   int count=0;
   int b=1;
   for (int i=0; i<H; i++) {
       for (int j=0; j<W; j++) {
           C[i][j]=b;
           count++;
        //cout << i << " " << j << " " << b << " " << count << " " << a[b-1] << endl;
           if (count==a[b-1]) {
               count=0;b++;
           }
       }
   }
   for (int i=0; i<H; i+=2) {
       reverse(C[i].begin(),C[i].end());
   }
   for (int i=0; i<H; i++) {
       for (int j=0; j<W; j++) {
           if (j!=W-1) {
               cout << C[i][j] << " " ;
           }
           else cout << C[i][j] << endl;
       }
   }
}

Measured memory_bytes: 3632
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin>>n;
int a[n];
int s[n+1]={0};
for(int i=1;i<n;i++)
{
    cin>>a[i];
}
for(int i=1;i<n;i++)
{
    s[a[i]]++;
}
for(int i=1;i<=n;i++)
{
    cout<<s[i]<<endl;
}
}



Measured memory_bytes: 5208
//AtCoder Beginner Contest 174
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e6 + 5;
const double E = 1e-9;

//------------------------------------------------------------------------------

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	int n, ans = 0;
	string s;
	cin >> n >> s;
	string t = s;
	sort(t.begin(), t.end());
	for (int i = 0; i < t.size(); i++)
	{
		if (s[i] != t[i])
			++ans;
	}
	cout << ans / 2;
	return 0;
}
//02-08-2020 17:57:16
//------------------------------------------------------------------------------

Measured memory_bytes: 3872
X, K, D = map(int, input().split())
X = abs(X)

ans = 0
if X // D > K:
    ans = X - D*K
else:
    e = X // D
    K -= e
    X -= D * e
    if K % 2 == 1: X = abs(X-D)
    ans = X

print(ans)

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

int main(){
  long i=0;
  long len;
  string s;
  cin >> s;
  len = s.length();
  for(i=0;i<len;i+=2){
  cout << s[i];
    }
    cout << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second


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

const ll MOD = 1e9+7;
const int INF = numeric_limits<int>::max();

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

	int n, w; cin >> n >> w;
	vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));

	ll v[107][2];
	FOR(i, n) cin >> v[i+1][0] >> v[i+1][1];

	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= w; j++){
			if(j < v[i][0])
				dp[i][j] = dp[i-1][j];
			else
				dp[i][j] = max(dp[i-1][j],
				       dp[i-1][j-v[i][0]] + v[i][1]);
		}
	}

	cout << dp[n][w] << '\n';

	return 0;
}

Measured memory_bytes: 80256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

int main() {
	int h, w;
	cin >> h >> w;
	VS a(h);
	for (int i = 0; i < h; i++) cin >> a[i];

	for (int i = 0; i < w + 2; i++) cout << "#";
	cout << "\n";

	for (int i = 0; i < h; i++) {
		cout << "#" << a[i] << "#" << endl;
	}

	for (int i = 0; i < w + 2; i++) cout << "#";
	cout << "\n";

}


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


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

  ll n;
  cin >> n;
  vector<ll> u(n-1), v(n-1);
  rep(i,n-1) {
    cin >> u[i] >> v[i];
    if(u[i]>v[i]) swap(u[i],v[i]);
  }
  ll ans = n*(n+1)*(n+2)/6;
  rep(i,n-1){
    ans -= u[i] *(n+1-v[i]);
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 6356
N, X = map(int, input().split())

l, p = [1], [1]
for i in range(N):
    l.append( l[i]*2 + 3 )
    p.append( p[i]*2 + 1 )

def patty(n, x):
    if n == 0:
        if x > 0 : return 1
        else : return 0
    elif x <= 1 + l[n-1]:
        return patty(n-1,x-1)
    else:
        return p[n-1] + 1 + patty(n-1, x-2-l[n-1])

print(patty(N,X))


Measured memory_bytes: 3064
import java.util.*;

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

    String s = sc.next();
    String t = sc.next();

    String ans = "No";

    for (int i=0; i < s.length(); i++) {
      int tmp_ans = 0;

      for (int j=0; j < s.length(); j++) {
        if (t.charAt(j) != s.charAt((i+j)%(s.length()))) {
          tmp_ans = 1;
        }
      }

      if (tmp_ans == 0) {
        ans = "Yes";
        break;
      }
    }

    System.out.println(ans);
  }
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int mx=max(a*c,max(a*d,max(b*c,b*d)));
	cout<<mx<<endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    bool can = true;
    int cnt = 0;
    while (can) {
        for (int i = 0; i < N; i++) {
            if (A[i] % 2 != 0) {
                can = false;
            }
            else A[i] /= 2;
        }
        if (can) cnt ++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
# Date [ 2020-08-22 21:07:07 ]
# Problem [ d.py ]
# Author Koki_tkg

import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

import numpy as np
from numba import i8, njit, u1, b1
from heapq import heappop, heappush

@njit(i8(b1[:,:], i8, i8, i8, i8), cache=True)
def solve(grid, ch, cw, dh, dw):
    h, w = grid.shape
    
    dist = np.full((h, w), INF, dtype=np.int64)
    dist[ch][cw] = 0

    que = [(0, ch, cw)]

    while que:
        cnt, y, x = heappop(que)

        if y == dh and x == dw:
            break

        for dy in range(-2, 3):
            for dx in range(-2, 3):
                if dx == 0 and dy == 0:
                    continue

                if abs(dx) == 2 or abs(dy) == 2 or (abs(dx) == 1 and abs(dy) == 1):
                    warp = 1
                else:
                    warp = 0

                nx, ny = x + dx, y + dy
                if nx < 0 or nx >= w or ny < 0 or ny >= h or grid[ny][nx]:
                    continue
                
                if dist[ny][nx] > cnt + warp:
                    dist[ny][nx] = cnt + warp
                    heappush(que, (cnt + warp, ny, nx))

    if dist[dh][dw] == INF:
        return - 1
    else:
        return dist[dh][dw]


def Main():
    H, W = read_ints()
    ch, cw = read_ints(); ch -= 1; cw -= 1
    dh, dw = read_ints(); dh -= 1; dw -= 1

    grid = np.array([[g == '#' for g in read_str()] for _ in range(H)])
    
    print(solve(grid, ch, cw, dh, dw))

def cc_export(config):
    from numba.pycc import CC
    cc = CC('my_module')
    for func, signature in config:
        vars()[func.__name__] = njit(signature)(func)
        cc.export(func.__name__, signature)(func)
    cc.compile()

if __name__ == '__main__':
    Main()


Measured memory_bytes: 119912
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES//(M_PIに使える（π）)

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
#include<numeric>
#include<random>
#include <functional>
using namespace std;

int main() {
	int N = 0;
	int A = 0;
	int ans = 0;
	cin >> N>>A;

	ans = N*N - A;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,ans=0;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a.at(i);
  int max=a.at(0);
  rep(i,n){
   if(a.at(i)>=max){
   ans++;
     max=a.at(i);
   }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[200000];
int main()
{
	int num, mok;
	scanf("%d%d", &num, &mok);
	if (mok == 1 || mok == num * 2 - 1)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	if (mok == num * 2 - 2)
	{
		d[num - 1] = mok;
		d[num] = mok + 1;
		for (int i = 0; i <= num - 2; i++)d[i] = i + 1;
		for (int i = num + 1; i < num * 2 - 1; i++)d[i] = i - 1;
	}
	else
	{
		d[num - 1] = mok;
		d[num] = mok - 1;
		d[num - 2] = mok + 1;
		d[num + 1] = mok + 2;
		int pt = 1;
		for (int i = 0; i <= num - 3; i++)
		{
			if (pt == mok - 1)pt = mok + 3;
			d[i] = pt++;
		}
		for (int i = num + 2; i < num * 2 - 1; i++)
		{
			if (pt == mok - 1)pt = mok + 3;
			d[i] = pt++;
		}
	}
	for (int i = 0; i < num * 2 - 1; i++)printf("%d ", d[i]); printf("\n");
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
#define fr first
#define sc second
#define mpr make_pair
#define pb push_back
#define ppb pop_back()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define ins insert
const int mod = 1e9 + 7;
const int INF = 1e9;
const int N = 3e5 + 1, N2 = 5001;
int v, l, r, len, last, a[N], b[N], n, add;
set <int> :: iterator it;
set <int> st;
int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int sum = (n * (n + 1)) / 2;
    int Mx = INF - sum;
    //cout << Mx;
    //return 0;
    st.ins(0);
    st.ins(n + 1);
    a[n + 1] = b[0] = Mx;
    for(int i = 1;i <= n; ++ i){
        cin >> v;
        it = st.ub(v);
        r = *it;
        --it;
        l = *it;
        len = r - l;
        //cout << a[l] + a[r] << endl;
        a[v] = a[l] + (((a[r] - a[l]) / len) * (v - l));
        b[v] = b[r] + (((b[l] - b[r]) / len) * (r - v));
        //cout << b[v] << endl;
        sum = a[v] + b[v];
        add = 0;
        if(sum <= last){
            add = (last - sum + 2) / 2;
        }
        a[v] += add;
        b[v] += add;
        last = a[v] + b[v];
        st.ins(v);
    }
    for(int i = 1;i <= n; ++ i){
        cout << a[i] << " ";
    }
    cout << endl;
    for(int i = 1;i <= n; ++ i){
        cout << b[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

namespace Template
{
    public static class Scan
    {
        public static string NextLine => Console.ReadLine();
        public static int NextInt => int.Parse(NextLine);
        public static long NextLong => long.Parse(NextLine);
        public static double NextDouble => double.Parse(NextLine);

        public static string[] StrAry(char separator = ' ') => Console.ReadLine().Split(separator);
        public static int[] IntAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), int.Parse);
        public static long[] LongAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), long.Parse);
        public static double[] DoubleAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), double.Parse);
    }

    internal class Template
    {
        public static void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
        private static void Fill<T>(T[] src, T value, int len) { for (int i = 0; i < len; i++) { src[i] = value; } }

        static void Solve() 
        {
            var line = Scan.IntAry();
            int a = line[0], b = line[1], c = line[2];
            if (a + b == c ||
                a + c == b ||
                b + c == a)
            {
                Console.WriteLine("Yes");
            }
            else Console.WriteLine("No");
        }
        private static void Main()
        {
            Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> per(n);
    for (int i=0; i<n; i++) cin >> p[i];
    for (int i=0; i<n; i++) cin >> q[i];
    per = p;

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

    int cnt = 1;
    int pi,qi;
    do {
        if (p == per) pi = cnt;
        if (q == per) qi = cnt;
        cnt++;
    } while (next_permutation(per.begin(), per.end()));

    cout << abs(pi - qi) << endl;
}


Measured memory_bytes: 512
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll n;
       cin>>n;
       ll m;
       m=n%10;
       if(n==10)
       cout<<"pon";
       else if(m==2 || m==4 || m==5 || m==7 || m==9)
       cout<<"hon";
       else if(m==6 || m==1 || m==8 || m==0)
       cout<<"pon";
       else if(m==3)
       cout<<"bon";
    }        
    return 0;
}

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

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

	vector<ll> db(N, 0);
	for (int i = 0; i < N; i++) {
		int it = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
		db[i] = N - it;
	}

	for (int i = N - 2; i >= 0; i--) {
		db[i] += db[i + 1];
	}

	ll res = 0;
	for (int i = 0; i < N; i++) {
		int it = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
		res += db[it];
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3456
#include <cstdio>
#include <algorithm>
#define ll long long
#define maxn 100005

using namespace std;

ll a [maxn];
int n;

int main () {
    scanf ("%d", &n);
    for (int i = 0; i < n; ++i) scanf ("%lld", &a[i]);
    sort (a, a + n);
    ll sum = 0;
    int res = -1;
    for (int i = 0; i < n - 1; ++i) {
        sum += a[i];
        if (sum * 2 < a[i + 1]) res = i;
    }
    printf ("%d\n", n - res - 1);
    return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		System.out.println(Calc.fact(n));
	}

}

class Calc {
	public static long fact (int n){
		if(n == 0|| n==1){
			return 1;
		}
		else {
			return n*fact(n-1);
		}
	}
}

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

int main(){
	int n, m;
	string a, b, c;
	vector<pair<string, string> > v;
	vector<string> vs;
	while(1){
		string s;
		cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> a >> b;
			v.push_back(make_pair(a, b));
		}
		cin >> m;
		for(int i = 0; i < m; i++){
			cin >> c;
			for(int j = 0; j < v.size(); j++){
				if(c == v[j].first){
					c = v[j].second;
					break;
				}
			}
			s += c;
		}
		vs.push_back(s);
		v.clear();
	}
	for(int i = 0; i < vs.size(); i++){
		cout << vs[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3308
s = gets.chomp.each_char.to_a
gets
r = false
STDIN.each do |q|
  q = q.chomp.split
  if q[0] == "1"
    r = !r
  else
    if((q[1] == "1" && !r) || q[1] == "2" && r)
      s.unshift(q[2])
    else
      s.push(q[2])
    end
  end
end

puts(r ? s.reverse.join : s.join)

Measured memory_bytes: 30972
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N];
int main()
{
	ll n;
	cin >> n;
	a[1] = 1;
	for(int i = 2; i <= 1000; i ++)
		a[i] = a[i - 1] + i;
	ll ans = 0;
	for(ll i = 2; i * i <= n; i ++)
	{
		ll c = 0;
		while(n % i == 0)
		{
			n /= i;
			c ++;
		}
		ll id = upper_bound(a + 1, a + 1000 + 1, c) - a;
		id --;
		ans += id;
	}
	if(n > 1)
	{
		ans ++;
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL<<60;
constexpr auto mod = 1000000007;
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; }

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

int main() {
	int n;
	cin >> n;
	VI a(n);
	FOR(i, n)cin >> a[i];

	ll ans = INF;
	for (int i = -100; i <= 100; i++) {
		ll cnt = 0;
		FOR(j, n)cnt += pow(a[j] - i, 2);
		chmin(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if a[i] > x:
        ans += a[i] - x
        a[i] = x
    
    if a[i] + a[i+1] > x:
        ans += a[i] + a[i+1] - x
        a[i+1] = x - a[i]

print(ans)



Measured memory_bytes: 14152
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        cout<<0;
    }
    else if(n==1&&a!=b){
        cout<<0;
    }
    else if(n==1&&a==b){
        cout<<1;
    }
    else if(a==b){
        cout<<1;
    }
    else{
        ll x=0,y=0;
        rep(i,n-1){
            x+=a;
            y+=b;
        }
        x+=b;
        y+=a;
        cout<<y-x+1<<endl;

    }
}


Measured memory_bytes: 256
#include <stdio.h>
char s[200000];
int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	int w = 0, r = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			w++;
		} else {
			r++;
		}
	}
	int ans = 0;
	for (int i = 0; i < r; i++) {
		if (s[i] == 'W') {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1900
def addedge(graph, fr, to, cap)
  graph[fr]<<[to,cap,graph[to].size]
  graph[to]<<[fr,0,graph[fr].size-1]
end

def dfs (graph, used, from, sink, flow)
  return flow if from == sink
  used[from] = true
  
  graph[from].each{|edge|
    next if used[edge[0]] || (edge[1]<=0)
    
    fmin = edge[1]
    fmin = flow if fmin > flow
    
    d = dfs(graph, used, edge[0], sink, fmin)
    
    if d > 0 then
      edge[1] -= d
      graph[edge[0]][edge[2]][1] += d
      return d
    end
  }
  return 0
end

n = gets.to_i
a = gets.split.map &:to_i

#
inf = 1000000000
v = n+2
#
source = 0
sink = n+1
graph = v.times.map{[]}
used = Array.new(v, false)
#
all = 0

for j in 1..n
  #p j,a[j-1]
  if a[j-1]>0 then
    addedge(graph, source, j, a[j-1])
    all += a[j-1]
  else
    addedge(graph, j, sink, -a[j-1])
  end
  
  x = j*2
  while x<=n
    addedge(graph, x, j, inf)
    #p x, j 
    x+=j
  end
end

#fordFulkerson
flow = 0
while true
  v.times{|i| used[i]=false}
  f = dfs(graph, used, source, sink, inf)
  break if f==0
  flow += f
end

puts all-flow


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N, K;
    long long sum=0;
    cin >> N >> K;
    vector<int> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    sort( H.begin(), H.end() );
    if(K>=N) cout<< 0 <<endl;
    else{
        for(int j=0; j<N-K; j++){
            sum+=H[j];
        }
        cout << sum << endl;
    }
    
}

Measured memory_bytes: 1024
use std::io::stdin;

fn main () {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let s: Vec<isize> = s.trim().split('/').flat_map(str::parse).collect();
    let y = s[0];
    let m = s[1];
    let d = s[2];
    if y >= 2019 && m >= 5 {
        println!("TBD");
    } else {
        println!("Heisei");
    }
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll dp[4][100005];

int main(){
  string s;
  cin >> s;
  int n=s.size();
  dp[0][0]=1;
  rep(i,n+1){
    if(s[i]=='?'){
      dp[0][i+1]=dp[0][i]*3;
    }else{
      dp[0][i+1]=dp[0][i];
    }
    dp[0][i+1]%=mod;
  }
  rep(i,n){
    if(s[i]=='A'){
      dp[1][i+1]=dp[1][i]+dp[0][i];
    }else if(s[i]=='?'){
      dp[1][i+1]=3*dp[1][i]+dp[0][i];
    }else{
      dp[1][i+1]=dp[1][i];
    }
    dp[1][i+1]%=mod;
  }
  rep(i,n){
    if(s[i]=='B'){
      dp[2][i+1]=dp[2][i]+dp[1][i];
    }else if(s[i]=='?'){
      dp[2][i+1]=3*dp[2][i]+dp[1][i];
    }else{
      dp[2][i+1]=dp[2][i];
    }
    dp[2][i+1]%=mod;
  }
  rep(i,n){
    if(s[i]=='C'){
      dp[3][i+1]=dp[3][i]+dp[2][i];
    }else if(s[i]=='?'){
      dp[3][i+1]=3*dp[3][i]+dp[2][i];
    }else{
      dp[3][i+1]=dp[3][i];
    }
    dp[3][i+1]%=mod;
  }
  rep(i,4){
    rep2(j,n){
      cerr<<dp[i][j]<<' ';
    }
    cerr<<endl;
  }
  cout<<dp[3][n]<<endl;
  return 0;
}

Measured memory_bytes: 3712
def is_not_primary(x):
    bln = False
    for i in range(2, x):
        if x % i == 0:
            bln = True
        else:
            continue
    return bln

def main():

    X = int(input())
    start = X
    while is_not_primary(start):
        start += 1
    else:
        print(start)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int binarysearch(vector<int> v, int i) {
	int l = 0;
	int r = v.size();
	while(l < r)
	{
		int m = (l + r) / 2;
		if(v.at(m) == i)
		{
			return m;
		}
		else if(i < v.at(m))
		{
			r = m;
		}
		else
			l = m + 1;
	}
	return -1;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> S(n);
	REP(i, n) cin >> S.at(i);
	int q;
	cin >> q;
	vector<int> T(q);
	REP(i, q) cin >> T.at(i);

	ull cnt = 0;

	REP(i, q)
	{
		int p = T.at(i);
		if(binarysearch(S, p) != -1) cnt++;
	}
	cout << cnt << endl;
}




Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1000010;
int n,ans,flg,a[MAXN];
char c[MAXN];
int main () {
	scanf("%d%s",&n,c+1);
	for (int i=1;i<=n;i++) {
		a[i]=c[i]-'1';
		if (a[i]==1) {flg=1;}
	}
	if (!flg) {
		for (int i=0;i<=n-1;i++) {
			if (((n-1)&i)==i) {
				ans^=a[i+1];
			}
		}
		printf("%d",ans);
	} else {
		for (int i=1;i<=n;i++) {
			if (a[i]==2) {a[i]=0;}
		}
		for (int i=0;i<=n-1;i++) {
			if (((n-1)&i)==i) {
				ans^=a[i+1];
			}
		}
		printf("%d",ans);
	}
	return 0;
}

Measured memory_bytes: 5120
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string s;
	cin >> s;
	string ans;
	rep(i, 0, SZ(s))
	{
		if (i % 2 == 0)ans += s[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 592
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(X);
    READV(T);
    cout<<T*((N+X-1)/X)<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int pow2int(int n){
 if(n ==0 ){return 1;}
else {return 2*pow2int(n-1);}
}
int main(){
int n,m;
cin>>n>>m;
int k[m];
int s[n][m];
int p[m];
int x[n];
for(int i=0;i<n;i++){x[i]=0;}
for(int i=0;i<n;i++){
 for(int j=0;j<m;j++){
 s[i][j] = 1000;
 }
}
for(int i=0;i<m;i++){
 cin>>k[i];
 for(int j=0;j<k[i];j++){
 cin>>s[i][j];
 s[i][j] -=1;
 }
}
for(int i=0;i<m;i++){
 cin>>p[i];
}
//cout<<"pow:"<<pow2int(n)<<endl;
// start
int ans=0;
 for (int i=0;i<pow2int(n);i++){
  // bit all search 
  for(int j =0;j<n;j++){
   if(x[j]==0&&j<n){
  x[j]+=1;
  break;
  } else{x[j]=0;}
}
//cout<<"patttern: "<<i<<",";
for(int ii=n-1;ii>=0;ii--){
  //cout<<x[ii];
  }
  //cout<<endl;
// __________________

 // switch
 bool addAns =false;  
 for(int l =0;l<m;l++){
    int powerOn =0;
    // connect
  for(int q=0;q<k[l];q++){
   if(x[s[l][q]]==1){powerOn += 1;}
  }
   if((powerOn % 2)!= p[l]){
   //cout<<"power: "<<powerOn<<","<<p[l]<<endl;
    break;
    }
   if(l==m-1){addAns=true;}
 }
 if(addAns){ans+=1;}
 }

cout<<ans<<endl;


}


Measured memory_bytes: 256
l, r = map(int, input().split())

mod = 2019
if l % mod == 0 or r % mod == 0 or l // mod != r // mod:
    print(0)
    exit()

ans = mod
for a in range(l, r):
    for b in range(a+1, r+1):
        if (a * b) % mod < ans:
            ans = (a * b) % mod
print(ans)

Measured memory_bytes: 41964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	ll n,a,b;
	cin >> n >> a >> b;
	ll n2 = n-2;
	ll ans;
	if(a>b) ans=0;
	else if(n==1&&a!=b) ans=0; 
	else if(n==1&&a==b) ans=1; 
	else ans = n2*b-n2*a+1;
	cout << ans << endl;
	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll Ai, Bi, Ci;
    priority_queue<pair<ll,ll>> q;
    for(int i=0;i<N;i++){
        cin >> Ai;
        q.push(make_pair(Ai,1));
    }
    for(int i=0;i<M;i++){
        cin >> Bi >> Ci;
        q.push(make_pair(Ci,Bi));
    }
    ll res = 0;
    int n = 0;
    while(n < N){
        auto v = q.top(); q.pop();
        for(int i=0;i<v.second;i++){
            res += v.first;
            n++;
            if(n>=N) break;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 6384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

int n, a[100014], res;

int main ()
{
  res = 1;
  R1(n);
  FOR(i, 0, n) R1(a[i]);
  FOR(j, 0, 2)
  {
    swap(a[0], a[1]);
    int num = a[0];
    int div = 1;
    while (div * div <= num) 
    {
      if (num % div); else
      {
        vector<int> cand = {div, num / div};
        FOR(k, 0, 2)
        {
          int cc = cand[k];
          int nocc = 0;
          FOR(i, 0, n) if (a[i] % cc) ++nocc;
          if (nocc <= 1) res = max(res, cc);
        }
      }
      ++div;
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define fo(i,n)         for(i=0; i<n; i++)
#define fo1(i,n)        for(i=1; i<=n; i++)
#define Fo(i,k,n)       for(i=k; k<=n?i<=n:i>=n; k<=n?i++:i--)
#define all(x)          x.begin(), x.end()
#define rall(x)         x.rbegin(), x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x, 0, sizeof(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr = new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x){cout<<x;}
void __print(float x){cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base, int exp){ int res = 1; base %= mod; while(exp > 0){ if(exp & 1) res = (res * base) % mod; base = (base * base) % mod; exp = exp >> 1; } return res; }
int inv(int x){ return power(x, mod - 2) % mod; }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N = 1e6 + 6, M = N;
int i, j;

void solve(){
    
    int n,k; cin>>n>>k;
    vi a(n);
    fo(i,n) cin>>a[i];
    sortall(a);
    int sm=0;
    fo(i,k) sm+=a[i];
    cout<<sm<<endl;
    
    
    
}




int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {

    int N, M;
    cin >> N >> M;

    vector<bool> ac(N);
    map<int, int> wa;

    int cntAc = 0;
    int p;
    string S;
    for (int i = 0; i < M; ++i) {
        cin >> p >> S;
        if (S == "AC") {

            if (!ac[p - 1]) {
                ac[p - 1] = true;
                cntAc += 1;
            }
        } else {
            if (!ac[p - 1]) {
                wa[p - 1] += 1;
            }
        }
    }

    int cntWa = 0;
    for (pair<int, int> p : wa) {
        if (ac[p.first]) {
            cntWa += p.second;
        }
    }

    cout << cntAc << " " << cntWa << endl;
    return 0;

}

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

using namespace std;
int32_t main()
{
 long long n;cin>>n;;
 long long a[n+1],b[n+1],c[n+1];
 for(long long i=1;i<=n;i++){
  cin>>a[i]>>b[i]>>c[i];
 }
 long long dp[n+1][3];
 dp[1][0]=a[1];
 dp[1][1]=b[1];
 dp[1][2]=c[1];

 for(long long i=2;i<=n;i++){
  dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
  dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
  dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
 }
 cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;

 return 0;
}


Measured memory_bytes: 8248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int x; cin >> x;
    int mx = 1;
    for(int b=2;b<=1000;b++) {
        for(int p=2;;p++) {
            if((int)pow(b, p) > x) break;
            mx = max(mx, (int)pow(b, p));
        }
    }
    cout << mx;
}


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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> a(N),b(N);
	for (int i = 0; i < N; i++)cin >> a[i];
	sort(a.begin(), a.end());
	vector<pair<int, int>> query(M);
	for (int i = 0; i < M; i++) {
		int b, c;
		cin >> b >> c;
		query[i] = { c,b };
	}
	sort(query.begin(), query.end(), greater<>());
	for (int i = 0, j = 0; j < M && i < N; j++) {
		for (int k = 0; k < query[j].second && i < N; i++, k++) {
			b[i] = query[j].first;
		}
	}

	ll ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		b[i] = max(a[i], b[i]);
		ans += b[i];
	}

	cout << ans << endl;

}


Measured memory_bytes: 1792
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

MAX_N = 110000

N = iin()

dp = [-1 for _ in range(MAX_N)]
dp[0] = 0

que = collections.deque()

que.append(0)

while (len(que) != 0):
    v = que.popleft()
    pow6 = 1
    while v+pow6 <= N:
        if dp[v+pow6] == -1:
            dp[v+pow6] = dp[v] + 1
            que.append(v+ pow6)
        pow6 *= 6
    pow9 = 1
    while v+pow9 <= N:
        if dp[v+pow9] == -1:
            dp[v+pow9] = dp[v] + 1
            que.append(v+pow9)
        pow9 *= 9
print(dp[N])

Measured memory_bytes: 71532
#include <iostream>
using namespace std;
int main() {

  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;

  if (r<=x && x<=W-r) {
    if (r<=y && y<=H-r) {
    cout<<"Yes\n";
    }
    else{
      cout<<"No\n";
    }
  }
  else {
    cout<<"No\n";
  }

  return 0;
}

Measured memory_bytes: 1128
#include <iostream>
#include <algorithm>
#include <string>
#include<vector>
using namespace std;

int main()
{	vector <int > w(10);
	 vector <int > k (10);	
	for (int i=0;i<10;i++) cin >> w[i];
	for (int i=0;i<10;i++) cin >> k[i];
	sort (w.begin (),w.end());
	sort (k.begin(),k.end());
	int wc=0,kc=0;
	for (int i=9;i>6;i--){
		wc+=w[i];
		kc+=k[i];
		}
	cout << wc <<" " << kc<<endl;		  
		return 0;
}


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

int main(){
  string str1, str2;
  cin >> str1 >> str2;
  string str = str1 + str2;
  
  int n = atoi(str.c_str());
  for(int i=1; i<n+1; i++){
  	if(i*i == n){
     	cout << "Yes" << endl;
      	return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 1; i < s.length(); i++){
        if(s[i] != s[i-1])  cnt++;
    }
    if(s[0]=='o'&&s[s.length()-1]=='o') cnt++;
    cout << (cnt%2 == 1 ? 'o' : 'x') << endl;
    return 0;
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;
using ll=int64_t;

vector<ll> ans;
void solve(ll a,ll b){
  for (int i = 1; i < a; ++i)
  {
    ll tmp=b*i;
    if(b%2==0){
      ll k=(a-i)*b/2;
      ans.emplace_back(abs(tmp-k));
    }
    else{
      ll k=(a-i)*(b-1)/2;
      ans.emplace_back( abs( max({tmp,k,k+a-i})-min({tmp,k,k+a-i}) ) );
    }
    if((a-i)%2==0){
      ll k=(a-i)/2*b;
      ans.emplace_back(abs(tmp-k));
    }
    else{
      ll k=(a-i-1)*b/2;
      ans.emplace_back( abs( max({tmp,k,k+b})-min({tmp,k,k+b}) ) );
    }
  }
}

int main()
{
  ll h,w;
  cin>>h>>w;
  solve(h,w);
  solve(w,h);
  cout<<*min_element(ans.begin(), ans.end());
}

Measured memory_bytes: 5616