akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
const int maxm=10001;
int u[maxm];
void makeset()
{
    for(int i=1;i<maxm;i++)
        u[i]=i;
}
int Find(int x)
{
    if(x!=u[x])
    {
        u[x]=Find(u[x]);
    }
    return u[x];

}
int Union(int a1,int a2)
{
    int r1=Find(a1);
    int r2=Find(a2);
    if(r1!=r2)
    {u[r2]=r1;
    return 1;
    }
    return 0;
}
using namespace std;
int main()
{
    long long int m,i,j,k,n,a,b;

    while(scanf("%lld%lld",&n,&m)!=EOF)
    {
        if(n<=0&&m>=0)
        {
           printf("Zero\n") ;
        }

            if(m<0&&(m-n-1)%2==0)
        {
            printf("Positive\n");
        }
        if(m<0&&(m-n)%2==0)
            printf("Negative\n");
        if(n>0) printf("Positive\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int N[110];
int A[1050];
int main(void){
  int n,g,r;
  g=0;
  r=0;
  cin >> n;
  vector<int>a(n);
  for(int i = 0; i<n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++)
  {
    if(a[i] % 2 == 0){
      g++;
    }
    if(a[i] % 2 == 0 && a[i] %3 ==0){
      r++;
    }else if(a[i] % 2 == 0 && a[i] %5 ==0){
      r++;
    }
  }
  //cout<<g<<'\n'<<r<<endl;
  if (g==r)
  {
    cout<< "APPROVED"<<endl;
  }else
  {
    cout<< "DENIED"<<endl;
  }
  
  
}

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

int main(){
  int m = 100, M = 0;
  int a;
  for(int i = 0; i < 3; i++){
    cin >> a;
    m = min(a, m);
    M = max(a, M);
  }
  cout << M - m << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input("").split()]

min = 0

left = []
for i in range(n-1):
    left.append(a[i])
    if i > 0:
        left[i] += left[i-1]

a.reverse()

right = []
for i in range(n-1):
    right.append(a[i])
    if i > 0:
        right[i] += right[i-1]

right.reverse()

min = 0
for i in range(1,n):
    if i == 1:
        min = abs(left[i-1] - right[i-1])
    else:
        if min > abs(left[i-1] - right[i-1]):
            min = abs(left[i-1] - right[i-1])

print(min)

Measured memory_bytes: 28552
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

const int siz = 1e6 + 10;
int counter[siz] = {0};

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}

void primes(int n)
{
    if (n % 2 == 0)
    {
        counter[2]++;
    }
    while (n % 2 == 0)
    {
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        if (n % i == 0)
        {
            counter[i]++;
        }
        while (n % i == 0)
        {
            n = n / i;
        }
    }
    if (n > 2)
        counter[n]++;
}

int32_t main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++)
    {
        primes(a[i]);
    }
    int flag = 0;
    for(int i=1;i<siz;i++){
        if(counter[i]>=2){
            flag=1;
            break;
        }
    }
    if(!flag){
        cout<<"pairwise coprime";
        return 0;
    }else {
        int gc = a[0];
        for(int i=1;i<n;i++){
            gc = __gcd(a[i],gc);
        }
        if(gc==1){
            cout<<"setwise coprime";
        }else{
            cout<<"not coprime";
        }
    }
    return 0;
}

Measured memory_bytes: 19096
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

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

    vector<int> color;
    vector<vector<int>> ans(h, vector<int>(w));

    rep(i,n){
        int tmp;
        cin >> tmp;
        color.pback(tmp);
    }

    int x = 0;
    int y = 0;

    for(int i = 1; i <= n; i++){
        while(color[i - 1] > 0){
            ans[y][x] = i;

            if(y % 2 == 0){
                if(x == w - 1){
                    y++;
                }else{
                    x++;
                }
            }else{
                if(x == 0){
                    y++;
                }else{
                    x--;
                }
            }
            
            color[i - 1]--;
        }
    }

    rep(i,h){
        rep(j,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

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

#define mod 1000000007
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp) {
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
int main()
{
    LL q,h,s,d,n; cin>>q>>h>>s>>d>>n;
    q*=8; h*=4; s*=2;
    LL ans=(n/2)*min(min(q,h) , min(s,d));
    if(n%2)ans+=min(min(q/2 , h/2) , s/2);
    cout<<ans;
}


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

int s[2][100010], t[2][100010];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    string S, T; cin>>S>>T;
    for(int i=0; i<S.size(); ++i) {
        int k=S[i]=='B';
        s[k][i+1]=s[k][i]+1;
        s[!k][i+1]=s[!k][i];
    }
    for(int i=0; i<T.size(); ++i) {
        int k=T[i]=='B';
        t[k][i+1]=t[k][i]+1;
        t[!k][i+1]=t[!k][i];
    }

    int q; cin>>q;
    while (q--) {
        int a, b, c, d; cin>>a>>b>>c>>d;

        int sa=s[0][b]-s[0][a-1];
        int sb=s[1][b]-s[1][a-1];
        int ta=t[0][d]-t[0][c-1];
        int tb=t[1][d]-t[1][c-1];
        cout<<((sa+2*sb)%3==(ta+2*tb)%3 ? "YES" : "NO")<<'\n';
    }
}


Measured memory_bytes: 2512
N = int(input())
tannis = [1]

i = 1
while 6**i <= N:
    tannis.append(6**i)
    i += 1

i = 1
while 9**i <= N:
    tannis.append(9**i)
    i += 1

dp = [float('inf') for _ in range(N+1)]
dp[0] = 0

for i in range(1, N+1):
    for t in tannis:
        if i-t >= 0:
            dp[i] = min(dp[i], dp[i-t]+1)

#print(dp)
print(dp[N])


Measured memory_bytes: 6296
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, x := scanInt(), scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}
	sort.Ints(a)

	for i := range a {
		x -= a[i]
		if x < 0 {
			fmt.Println(i)
			return
		}
	}
	if x == 0 {
		fmt.Println(n)
	} else {
		fmt.Println(n - 1)
	}
}


Measured memory_bytes: 640
import numpy as np
from collections import Counter
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix


N, X, Y = map(int, input().split())
l = [[0] * N for _ in range(N)]
l[X-1][Y-1] = 1
l[Y-1][X-1] = 1
for i in range(1, N):
    l[i-1][i] = 1
    l[i][i-1] = 1

csr = np.array(l)
s = shortest_path(csr, directed=False).astype(np.int16)
arr = s.flatten()
c = Counter(arr)
for i in range(1, N):
    print(c[i]//2)

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

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for(int i=0; i<h; i++){
		cin >> a.at(i);
	}
	vector<string> ans(h+2);
	for(int i=0; i<w+2; i++){
		ans.at(0)+='#';
		ans.at(h+1)+='#';
	}
	for(int i=1; i<h+1; i++){
		ans.at(i)+='#';
		ans.at(i)+=a.at(i-1);
		ans.at(i)+='#';
	}
	for(int i=0; i<h+2; i++){
		cout << ans.at(i) << endl;
	}
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(b-a)<=d&&abs(c-b)<=d)||abs(a-c)<=d) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(998244353)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5+5)

void solve()
{
    ll n;
    cin>>n;

    vector<ll> arr(n);
    map<ll,bool> ch;

    for(ll i=0;i<n;i++)
        cin>>arr[i] , ch[arr[i]] = 0;

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

    for(ll i=0;i<n;i++)
    {
        if(ch[arr[i]])
            continue;

        for(ll j=2;arr[i]*j<=arr[n-1];j++)
            ch[arr[i] * j] = 1;
    }

    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        if(ch[arr[i]])
            continue;
        if(i>0 && arr[i-1]==arr[i])
            continue;
        if(i<n-1 && arr[i+1]==arr[i])
            continue;
        ans++;
    }

    cout<<ans;

}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 67068
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

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

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

    stack<char> st;
    for(int i = 0; i < (int)s.length(); i++){
        if(s[i] == 'S'){
            st.push(s[i]);
            continue;
        }

        if(st.empty() || st.top() == 'T'){
            st.push(s[i]);
            continue;
        }

        st.pop();
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 832
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, a, b = ns()
    x = na()

    ans = 0
    for i in range(1, n):
        tmp = x[i] - x[i - 1]
        ans += min(b, tmp * a)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

	ll ans = 0;
	ll cnt = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == 0 || i == n-1){
			cnt += a[i];
			ans += cnt/2;
			cnt = 0;
		}else{
			cnt += a[i];
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
     int a,b;
     string s,t,u;
     cin>>s>>t;
     cin>>a>>b;
     cin>>u;
     if(s==u)
        a=a-1;
     else
        b=b-1;
     cout<<a<<" "<<b<<endl;



}


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

ll modpow(ll a,ll n,ll p){
  if (n == 0){
    return 1; 
  }
  if (n == 1){
    return a % p;
  }
  if (n % 2 == 1){
    return ((a % p) * (modpow(a, n - 1, p) % p)) % p;
  }
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

ll modconb(ll n,ll k,ll p){
  ll a=1;
  for(ll x=n;x>=n-k+1;x--){
    a = a*x%p;
  }
  ll b=1;
  for(ll y=k;y>=1;y--){
    b = b*y%p;
  }
  return a*modpow(b,p-2,p)%p;
}

int main() {
  ll n;
  cin >> n;
  ll a,b;
  cin >> a >> b;
  ll S=modpow(2,n,1000000007)-1;
  S = S - modconb(n,a,1000000007);
  S = S - modconb(n,b,1000000007);
  if(S<0){
    while(S<0){
      S+=1000000007;
    }
  }
  cout << S%1000000007 <<endl;
}

Measured memory_bytes: 3640
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
int h, w, n;
int sx, sy;
string s, t;
char tmp[maxn];

bool read() {
  if (scanf("%d%d%d%d%d", &h, &w, &n, &sx, &sy) < 5) {
    return false;
  }
  sx--;
  sy--;
  scanf("%s", tmp);
  s = tmp;
  scanf("%s", tmp);
  t = tmp;
  return true;
}

bool check() {
  int l = 0, r = w;
  for (int i = n - 1; i >= 0; i--) {
    if (t[i] == 'L') {
      r = min(w, r + 1);
    } else if (t[i] == 'R') {
      l = max(0, l - 1);
    }
    if (s[i] == 'L') {
      l++;
    } else if (s[i] == 'R') {
      r--;
    }
    if (l >= r) {
      return false;
    }
  }
  return l <= sy && sy < r;
}

void flip(char &c) {
  if (c == 'L') {
    c = 'U';
  } else if (c == 'R') {
    c = 'D';
  } else if (c == 'U') {
    c = 'L';
  } else {
    c = 'R';
  }
}

void solve() {
  if (!check()) {
    printf("NO\n");
    return;
  }
  swap(h, w);
  swap(sx, sy);
  for (int i = 0; i < n; i++) {
    flip(s[i]);
    flip(t[i]);
  }
  if (!check()) {
    printf("NO\n");
    return;
  }
  printf("YES\n");
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 500005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,q,ans,cnt[N];
ll block_size,ar[N],answe[N];
pair< pair<ll,ll>,ll> quer[N];
bool mo_cmp(const pair< pair<ll,ll>,ll>&x,const pair< pair<ll,ll>,ll>&y){
	ll block_x=x.fs.fs/block_size;
	ll block_y=y.fs.fs/block_size;
	if(block_x!=block_y){
		return block_x<block_y;
	}
	return x.fs.sc<y.fs.sc;
}
void mo_add(ll x){
	if(cnt[x]==0) ans++;
	cnt[x]++;
}
void mo_remove(ll x){
	cnt[x]--;
	if(cnt[x]==0) ans--;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l,n,q;
	cin>>n>>q;
	block_size=sqrt(0.0+n)+1;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=1;i<=q;i++){
		cin>>quer[i].fs.fs>>quer[i].fs.sc;
		quer[i].sc=i;
	}
	sort(quer+1,quer+q+1,mo_cmp);

	ll mo_left=1,mo_right=0; ans=0;
	for(i=1;i<=q;i++){
		ll left,right;
		left=quer[i].fs.fs;
		right=quer[i].fs.sc;
		// cout<<left<<" "<<right<<endl;
		while(mo_right<right){
			mo_right++;
			mo_add(ar[mo_right]);
		}
		while(mo_right>right){
			mo_remove(ar[mo_right]);
			mo_right--;
		}
		while(mo_left<left){
			mo_remove(ar[mo_left]);
			mo_left++;
		}
		while(mo_left>left){
			mo_left--;
			mo_add(ar[mo_left]);
		}
		answe[quer[i].sc]=ans;
	}
	
	for(i=1;i<=q;i++){
		cout<<answe[i]<<endl;
	}
	return 0;	
}

Measured memory_bytes: 27176
N = int(input())
A = list(map(int, input().split()))

dp = [[-float('inf'), -float('inf')] for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
    dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])

print(dp[N][0])

Measured memory_bytes: 25572
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
template<class T, class Func = function<T(T, T)>>
class segtree {
	vector<T> obj;
	int offset;
	Func updater;
	T e;
	int bufsize(int num) {
		int i = 1;
		for (; num >i; i <<= 1);
		offset = i - 1;
		return (i << 1) - 1;
	}
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return e;
		if (a <= l && r <= b)return obj[k];
		else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
public:
	T query(int a, int b) {//[a,b)
		return query(a, b, 0, 0, offset + 1);
	}
	void updateall(int l = 0, int r = -1) {
		if (r == -1)r = offset + 1;
		l += offset, r += offset;
		do {
			l = l - 1 >> 1, r = r - 1 >> 1;
			for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
		} while (r);
	}
	void update(int k, T a) {
		k += offset;
		obj[k] = a;
		while (k) {
			k = k - 1 >> 1;
			obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
		}
	}
	segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
	segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
		copy(vec.begin(), vec.end(), obj.begin() + offset);
		updateall();
	}
	typename vector<T>::reference operator[](int n) {//reference?????????????????????T&
		return obj[n + offset];
	}
};
int main() {
	int n, q;
	cin >> n >> q;
	segtree<int, plus<int>> seg(n+1,0);
	rep(i, q) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c) {
			cout << seg.query(x, y + 1) << endl;;
		}
		else {
			seg.update(x, seg[x]+y);
		}
	}
}

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

long long getNextRansu(long long x) {
	unsigned long long xx=x;
	xx^=xx<<13;
	xx^=xx>>7;
	xx^=xx<<17;
	return (long long)xx;
}

int qsort_comp_ll(const void* x,const void* y) {
	long long a=*((const long long*)x);
	long long b=*((const long long*)y);
	if(a>b)return 1;
	if(a<b)return -1;
	return 0;
}

int bunpu[262144];

int ransuListNum;
long long ransuList[1000]; /* based on an experiment */

int getBunpuID(long long x) {
	return (int)(x/70368744177664ll)+131072;
}

long long getLowerBound(int id) {
	if(id==0)return 0x8000000000000000ll;
	if(id<=131072)return ((id-1)-131072)*70368744177664ll+1ll;
	return (id-131072)*70368744177664ll;
}

long long getUpperBound(int id) {
	if(id<131072)return (id-131072)*70368744177664ll+1ll;
	return ((id+1)-131072)*70368744177664ll;
}

int main(void) {
	int n,k,x0;
	long long x;
	int i;
	int now;
	int offset;
	long long lowerBound,upperBound;
	scanf("%d%d%d",&n,&k,&x0);
	if(x0==0) {
		puts("0");
		return 0;
	}
	x=x0;
	for(i=0;i<n;i++) {
		bunpu[getBunpuID(x)]++;
		x=getNextRansu(x);
	}
	offset=now=0;
	for(i=0;i<262144;i++) {
		now+=bunpu[i];
		if(now>=k) {
			lowerBound=getLowerBound(i);
			upperBound=getUpperBound(i);
			break;
		}
		offset=now;
	}
	x=x0;
	ransuListNum=0;
	for(i=0;i<n;i++) {
		if(lowerBound<=x && x<upperBound) {
			ransuList[ransuListNum++]=x;
		}
		x=getNextRansu(x);
	}
	qsort(ransuList,ransuListNum,sizeof(ransuList[0]),qsort_comp_ll);
	printf("%lld\n",ransuList[k-offset-1]);
	return 0;
}

Measured memory_bytes: 1676
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
ll NUM = 1e9+7;

ll calc(ll a,ll b){
    if(b==0)    return 1;
    else if(b%2==0){
        ll d = calc(a,b/2);
        return (d*d)%NUM;
    }
    return (a*calc(a,b-1))%NUM;
}

int main(){
    ll n,k;
    cin >> n >> k;
    for(ll i=1;i<=k;i++){
        ll ans;
        ll blue = k-i;
        ll red = n-k-(i-1);
        ll ue=1,sita=1;
        for(ll x=blue+1;x<=(blue+i-1);x++) ue=(ue*x)%NUM;
        for(ll x=red+1;x<=(red+i);x++) ue=(ue*x)%NUM;
        for(ll x=1;x<=i-1;x++) sita=(sita*calc(x,NUM-2))%NUM;
        ans = ue*sita%NUM;
        ans = ans*(sita*calc(i,NUM-2)%NUM)%NUM;
        cout << ans<< endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
cin >> n;
vector<int>vec(n);
for(int t=0;t<n;t++){
    cin >> vec.at(t);
}
sort(vec.begin(),vec.end());
double ans = vec.at(0);
for(int i=0;i<n-1;i++){
    ans+=vec.at(i+1);
    ans/=2;
}
cout << ans << endl;
}

Measured memory_bytes: 256
while gets do
  @n, @s = $_.split(' ').map(&:to_i)
  break if @n == 0 and @s == 0
  @c = 0
  @a = []

  def dfs(i)
    if @a.size == @n
      @c += 1 if @a.inject(:+) == @s
    end

    (i..9).each do |j|
      @a.push(j)
      dfs(j+1)
      @a.pop
    end
  end

  dfs(0)
  puts @c
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 2147483647
typedef long long ll;
const ll N=2e5+20;
const ll M=500000+20;
ll a[N],sum[N];
map<ll,ll>mp;
int main()
{
    ll n;
    scanf("%lld",&n);
    mp[0]=1;
    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
        mp[sum[i]]++;
    }
    ll ans=0;
    for(auto it=mp.begin(); it!=mp.end(); it++)
    {
        ll a=it->first,b=it->second;
        if(b>=2)
            ans+=b*(b-1)/2;
        // cout<<it->first<<" "<<it->second<<endl;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 15872
#include<stdio.h>
int main(void)
{
    int a,b,c,n=-1,x=-1,q=-1;
    while(n+x!=0){
        while(n+x>0){
            for(a=1;a<=n-2;a++){
                for(b=a+1;b<=n-1;b++){
                    for(c=b+1;c<=n;c++){
                        if(a+b+c==x){
                            q++;
                        }
                    }
                }
            }
            n=0;
            x=0;
        }
        if(q>-1){
            printf("%d\n",q);
        }
        q=0;
        scanf("%d%d",&n,&x);
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
 
using namespace std;
int main(){
    int n;std::cin >> n;
    int p[n];
    int ma=0;int sum=0;
    rep(i,n){
        std::cin >> p[i];sum+=p[i];
        ma=max(ma,p[i]);
    }
    std::cout <<  sum-ma/2<< std::endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int A,B,K;
  cin >> A >> B >> K;
  vector<int> a;
  for(int i=1;i<=min(A,B);i++){
    if(A%i==0 &&B%i==0) a.push_back(i);
  }
  cout << a.at(a.size()-K) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <utility>
#define chmin(x, y) x = min(x , y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const int INF = 1e8;

int N, M;
vector<pair<int, int>> key;

void input() {
    cin >> N >> M;
    
    rep(i, M){
        int a, b;
        cin >> a >> b;
        int s = 0;
        //bitで集合をとる
        rep(j, b){
            int c;cin >> c;
            c--;
            s |= 1 << c;
        }
        key.emplace_back(s, a);
    }
}

void solve() {
    input();
    vector<int> dp(1<<N, INF);
    dp[0] = 0;
    rep(i, 1<<N){
        rep(j, M){
            int t = i | key[j].first;
            int cost = dp[i] + key[j].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 3011

using namespace std;

int n, arr[N], dp[2][N][N];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> arr[i];
	}
	for(int k=0; k<n; k++) {
		for(int i=0; i+k<n; i++) {
			for(int x=0; x<2; x++) {
				if(k == 0) dp[x][i][i+k] = (x ? -arr[i] : arr[i]);
				else {
					if(x == 0) dp[x][i][i+k] = max(dp[1-x][i+1][i+k] + arr[i], dp[1-x][i][i+k-1] + arr[i+k]);
					else dp[x][i][i+k] = min(dp[1-x][i+1][i+k] - arr[i], dp[1-x][i][i+k-1] - arr[i+k]);
				}
			}
		}
	}
	cout << dp[0][0][n-1] << endl;
	return 0;
}

Measured memory_bytes: 141696
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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<char>AL(26);
AL = {'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<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint D, N;
	cin >> D >> N;
	if (D == 0) {
		if (N == 100) {
			cout << 101 << endl;
		}
		else {
			cout << N << endl;
		}
	}
	if (D == 1) {
		if (N == 100) {
			cout << 10100 << endl;
		}
		else {
			cout << 100 * N << endl;
		}
	}
	if (D == 2) {
		if (N == 100) {
			cout << 1010000 << endl;
		}
		else {
			cout << 10000 * N << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 998244353
using namespace std;
using ll = long long;

template<int M>
class ModInt {
   public:
    ll value;
    constexpr ModInt(ll v = 0) { value = v % M; if (value < 0) value += M; }
    constexpr ModInt pow(ll n) const { if (!n) return 1; ModInt a = pow(n >> 1); a *= a; if (n & 1) a *= *this; return a; }
    constexpr ModInt inv() const { return this->pow(M - 2); }
    constexpr ModInt operator + (const ModInt &rhs) const { return ModInt(*this) += rhs; };
    constexpr ModInt operator - (const ModInt &rhs) const { return ModInt(*this) -= rhs; };
    constexpr ModInt operator * (const ModInt &rhs) const { return ModInt(*this) *= rhs; };
    constexpr ModInt operator / (const ModInt &rhs) const { return ModInt(*this) /= rhs; };
    constexpr ModInt &operator += (const ModInt &rhs) { value += rhs.value; if (value >= M) value -= M; return *this; };
    constexpr ModInt &operator -= (const ModInt &rhs) { value -= rhs.value; if (value <  0) value += M; return *this; };
    constexpr ModInt &operator *= (const ModInt &rhs) { value = value * rhs.value % M; return *this; };
    constexpr ModInt &operator /= (const ModInt &rhs) { return (*this) *= rhs.inv(); };
    constexpr bool operator == (const ModInt &rhs) { return value == rhs.value; }
    constexpr bool operator != (const ModInt &rhs) { return value != rhs.value; }
    friend ostream &operator << (ostream &os, const ModInt &rhs) { os << rhs.value; return os; }
};

using mint = ModInt<MOD>;

int main() {
    int N, K; cin >> N >> K;
    vector<int> L(K), R(K);
    REP(i, 0, K) cin >> L[i] >> R[i];

    vector<mint> dp(N + 1, 0);
    dp[1] = 1;
    REP(i, 1, N) {
        dp[i] += dp[i - 1];
        REP(j, 0, K) {
            if (i + L[j] <= N) {
                dp[i + L[j]] += dp[i];
            }
            if (i + R[j] + 1 <= N) {
                dp[i + R[j] + 1] -= dp[i];
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int N;
  cin >> N;
  bool nine = false;
  int i=1;
  while(!nine&&i<10){
      for(int j=1;j<10;j++){
        if(N==i*j){
          nine = true;
          break;
        }
      }
    i++;
  }
          
  if(nine){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	map<string,int> mp;
	string s;
	for(int i=0;i<n;i++){
		cin >> s;
		mp[s]++;
	}
	// keisan
	printf("AC x  %d\n",mp["AC"]);
	printf("WA x  %d\n",mp["WA"]);
	printf("TLE x  %d\n",mp["TLE"]);
	printf("RE x  %d\n",mp["RE"]);
	// syutsuryoku
}

Measured memory_bytes: 3724
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String str = "";
		String mei = "";
		String fro = "";
		String bac = "";
		String mew = "";
		String out = "";
		int q = 0;
		int a = 0;
		int b = 0;
		
		str = as.nextLine();
		q = as.nextInt();
		
		for(int i=0;i<q;i++){
			
			mei = as.next();
			
			switch(mei){
			case "print":
				a = as.nextInt();
				b = as.nextInt();
				
				out = str.substring(a,b+1);
				System.out.println(out);
				break;
			
			case "reverse":
				a = as.nextInt();
				b = as.nextInt();
				
				bac = str.substring(b+1,str.length());
				fro = str.substring(0,a);
				str = str.substring(a,b+1);
				
				StringBuffer sb = new StringBuffer(str);
				str = sb.reverse().toString();
				
				str = fro+str+bac;
				break;
				
			case "replace":
				a = as.nextInt();
				b = as.nextInt();
				mew = as.next();
				
				StringBuffer sc = new StringBuffer(str);
				str = sc.replace(a, b+1, mew).toString();
				break;
			
			
			}
			
		}

	}

}

Measured memory_bytes: 29444
#include <cstdio>
#include <cctype>

using namespace std;

int main() {
  char c;

  while (true) {
    scanf("%c", &c);
    if (isupper(c))
      c = tolower(c);
    else if (islower(c))
      c = toupper(c);

    printf("%c", c);

    if (c == '\n')
      break;
  }

  return 0;
}



Measured memory_bytes: 2680
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,i,j,d[100005];
int main()
{
	scanf("%d%d",&n,&m);
	while(m--)
	{
		scanf("%d%d",&i,&j);
		++d[i],++d[j];
	}
	for(i=1;i<=n;++i)
		if(d[i]&1)
		{
			printf("NO");
			return 0;
		}
	printf("YES");
	return 0;
}


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


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

    vector<int> v;
    int ans = INT_MAX, sum = 0, t;
    for(int i = 0; i < n; ++i) {
        v.push_back(l+i);
        sum += l+i;
        ans = min(ans, abs(l+i));
        if(ans == abs(l+i))
            t = l+i;
        //cout << abs(l+i) << endl;
    }

    cout << sum-t << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public static boolean equal(int m, String a) {
            if (a.length() % 2 != 0) {
                return false;
            } else {
                String arr[] = a.split("");
                int i = 0, j = m;
                boolean r = true;
                while (i < m && j < arr.length) {
                    if (arr[i].equals(arr[j])) {
                        i++;
                        j++;
                    } else {
                        r = false;
                        break;
                    }

                }
                return r;
            }


        }

        public void solve(int testNumber, Scanner sn, PrintWriter out) {
            String a = sn.next();
            a = a.substring(0, a.length() - 1);
            while (a.length() != 0) {
                if (equal(a.length() / 2, a)) {
                    out.println(a.length());
                    break;
                } else {
                    a = a.substring(0, a.length() - 1);
                }
            }
        }

    }
}



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

int dp[3005][3005];

string solution(string str1 , string str2){

    int n = str1.length();
    int m = str2.length();

    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            if(str1[i-1] == str2[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }else{
                dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
            }
        }
    }

    string ans = "";
    
    int i=n;
    int j=m;

    while(i>0 && j>0){
        if(dp[i][j] > dp[i-1][j] && dp[i][j] > dp[i][j-1]){
            ans = str1[i-1] + ans;
            i--;
            j--;
        }else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }else{
            j--;
        }
    }    
    
    return ans;

}


int main(){
    string str1, str2;
    cin>>str1>>str2;
    cout<<solution(str1 , str2)<<endl;
}

Measured memory_bytes: 35456
A,B,C,K=input().split()
A=int(A)
B=int(B)
C=int(C)
K=int(K)

if A>=K:
    print(1*K)
elif A+B>=K :
    print(K-B)
else:
    print((A*1)+(B*0)+((K-B-A)*(-1)))

Measured memory_bytes: 9192
// C++のテンプレート
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N-1);
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }
    int max=B[0];
    int sum=B[0];
    for(int i=0;i<N-1;i++){
        if(i==N-2){
            sum += B[i];
        }else{
            sum += min(B[i],B[i+1]);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func divmod(a, b int) (int, int) {return a / b, a % b}

func main() {
  var x int 
  fmt.Scan(&x)
  q, r := divmod(x, 500)
  res := 1000 * q + r / 5 * 5
  fmt.Println(res)

}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=500010;
int gi()
{
	int f=0; char ch=getchar();
	while(ch<'0' || ch>'9')ch=getchar();
	while(ch>='0' && ch<='9')f=f*10+ch-48,ch=getchar();
	return f;
}
int n,k,p[N],a[N];
struct node
{
	int mn;
}s[N<<2];
void pushup(int k)
{
	s[k].mn=min(s[k<<1].mn,s[k<<1|1].mn);
}
void build(int l,int r,int k)
{
	if(l==r)
	{
		s[k].mn=n+1;
		return; 
	}
	int mid=l+r>>1;
	build(l,mid,k<<1); build(mid+1,r,k<<1|1);
	s[k].mn=n+1;
}
int head[N],cnt,ct;
struct edge
{
	int fr,to,next;
	bool operator < (const edge a)const
	{
		return to<a.to;
	}
}e[N<<1];
void adde(int k)
{
	e[k].next=head[e[k].fr]; head[e[k].fr]=k;
}
int query(int L,int R,int l,int r,int k)
{
	if(l>r)return n+1;
	if(l<=L && R<=r)
		return s[k].mn;
	int mid=L+R>>1,res=n+1;
	if(l<=mid)
		res=min(res,query(L,mid,l,r,k<<1));
	if(r>mid)
		res=min(res,query(mid+1,R,l,r,k<<1|1));
	return res;
}
void modify(int l,int r,int p,int x,int k)
{
	if(l==r)
	{
		s[k].mn=x;
		return;
	}
	int mid=l+r>>1;
	if(p<=mid)
		modify(l,mid,p,x,k<<1);
	else
		modify(mid+1,r,p,x,k<<1|1);
	pushup(k);
}
int in[N];
priority_queue<int,vector<int>,greater<int> >q;
int id[N];
void topsort()
{
	for(int i=1;i<=n;i++)
		for(int j=head[i];j;j=e[j].next)
		{
			int v=e[j].to;
			in[v]++;
		}
	for(int i=1;i<=n;i++)
		if(!in[i])
			q.push(i);
	while(!q.empty())
	{
		int k=q.top(); q.pop(); id[k]=++ct;
		for(int i=head[k];i;i=e[i].next)
		{
			int v=e[i].to;
			in[v]--;
			if(!in[v])q.push(v);
		}
	}
}
int main()
{
	n=gi(); k=gi();
	for(int i=1;i<=n;i++)
		p[i]=gi(),a[p[i]]=i;
	build(1,n,1);
	for(int i=n;i;i--)
	{
		int x=query(1,n,max(a[i]-k+1,1),a[i]-1,1);
		if(x<=n)
			e[++cnt].fr=a[i],e[cnt].to=a[x];
		x=query(1,n,a[i]+1,min(a[i]+k-1,n),1);
		if(x<=n)
			e[++cnt].fr=a[i],e[cnt].to=a[x];
		modify(1,n,a[i],i,1);
	}
	sort(e+1,e+cnt+1);
	for(int i=1;i<=cnt;i++)
		adde(i);
	topsort();
	for(int i=1;i<=n;i++)
		printf("%d\n",id[i]);
	return 0;
}


Measured memory_bytes: 31224
#include <stdio.h>
#include <cassert>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
#include <iomanip>
 
#ifdef LOCAL_CODE
	#define DEBUG(x) cerr << "[" << #x << '=' << x << "]" << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int i = (N)-1; i >= 0; i--)
#define REP(i, N) for(int i = 0; i < (int)(N); i++)
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.first >> p.second; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.first << ' ' << p.second; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

unsigned long long n,m,k;//A,B,C,D;
void solve(istream& cin, ostream& cout) {
	cin >> n;
	int ans = 0;
	for(ll p = 2; p*p <= n; p++) {
		int t = 0;
		while(n % p == 0) {
			n /= p;
			t++;
		}
		int esum = 0;
		for(int ee = 1; esum+ee <= t; ee++) {
			esum += ee;
			ans++;
		}
	}
	if(n > 1) ans++;
	cout <<ans<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


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

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

  rep(i, n) cout<<a[i]<<b[i];
  cout<<endl;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int dp[N][4];
int mat[3][N];
int n;
int rec(int pos, int hw) {
    if (pos == n)
        return 0;
    if (pos > n)
        return INT_MIN;
    int &ans  = dp[pos][hw];
    if (ans != -1)
        return ans ;
    if (hw == 0) {
        ans  = max({mat[0][pos] + rec(pos + 1, 1), mat[1][pos] + rec(pos + 1, 2), mat[2][pos] + rec(pos + 1, 3)});
    }
    else if (hw == 1) {
        ans  = max(mat[1][pos] + rec(pos + 1, 2), mat[2][pos] + rec(pos + 1, 3));
    }
    else if (hw == 2) {
        ans  = max(mat[0][pos] + rec(pos + 1, 1), mat[2][pos] + rec(pos + 1, 3));
    } else if (hw == 3) {
        ans  = max(mat[1][pos] + rec(pos + 1, 2), mat[0][pos] + rec(pos + 1, 1));
    }
    return ans ;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    memset(dp, -1, sizeof(dp));

    cin >> n;
    int a[n][3];
    forr(i, n) {
        forr(j, 3)
        cin >> a[i][j];
    }
    forr(i, 3) {
        forr(j, n) {
            mat[i][j] = a[j][i];
        }
    }
    int ans  = rec(0, 0);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 12800
import sys
input = sys.stdin.readline
N = int(input())
ab = [list(map(int,input().split())) for _ in range(N)]
ab = sorted(ab, key = lambda x:x[1],reverse=False)
deadline = 0 #sum(ab[:][0])
for i in range(N):
    a = ab[i][0]
    b = ab[i][1]
    deadline += a
    if deadline > b:
        print("No")
        exit()
print("Yes")


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N, W;
    cin >> N >> W;
    int N_MAX = 110;
    int W_MAX = 20010;
    int v[N_MAX];
    int w[N_MAX];
    REP(i, N){
        cin >> v[i] >> w[i];
    }
    int DP[W_MAX];
    REP(i, N){
        for (int j=0;j<W+1;j++){
            if(j + w[i] <= W){
                DP[j+w[i]] = max(DP[j+w[i]], DP[j] + v[i]);
            }
        }
    }
    cout << DP[W] << endl;
    return 0;
}

Measured memory_bytes: 3116
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	map<int, int> mc;
	int flag = 0;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		mc[x]++;
		if (mc[x] >= 3) mc[x] -= 2;
	}
	for (auto& p : mc)
	{
		if (p.second > 1) flag ^= 1;
	}
	cout << mc.size() - flag << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb       push_back
#define conv(a)  bitset<30>(a).to_string() ;
#define mxpq     priority_queue <int>
#define mnpq     priority_queue<int,vector<int>,greater<int>>
#define S(v)     sort(v.begin(),v.end())
#define RS(v)    sort(v.rbegin(),v.rend())
#define print    printf("%.16f\n", ans)
#define inf      LLONG_MAX
#define mini     LLONG_MIN
#define T        int tc;cin>>tc;while(tc--)
#define int      long long 
#define MAXN     10000001
#define M        1000000007
#define fio      cin.sync_with_stdio(false) ; cin.tie(0);cout.tie(0) ;
#define endl     "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;


void Xarr(){
     
       int n ; cin>> n;
       map<int,int> m ;
       for(int i=0;i<n-1;i++){
             int x ;cin>>x ;
             m[x]++ ;
       }

       for(int i=1;i<=n;i++){
            cout<<m[i]<<endl ;
       }
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
int32_t main(){
 
    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    #ifndef ONLINE_JUDGE
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif
    
    cout << setprecision(9) << fixed;
     clock_t z = clock();
     
     Xarr();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
 
     return 0;

}

Measured memory_bytes: 16352
#include <bits/stdc++.h>
using namespace std;
 
int main(){

int W, H, N, x, y, a;
  cin >> W >> H >> N;
int xmin = 0, ymin = 0; 
int xmax = W, ymax = H;  
  
  for(int i = 0;i < N;i++){
  cin >> x >> y >> a;
  if(a == 1) xmin = max(xmin, x);
  else if(a == 2) xmax = min(xmax, x);
  else if(a == 3) ymin = max(ymin, y); 
  else ymax = min(ymax, y);  
  }
  
  if(xmax - xmin < 0) cout << 0 << endl;
  else if(ymax - ymin < 0) cout << 0 << endl;
  else cout << (xmax - xmin) * (ymax - ymin) << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k; cin >> n >> k;
	int i = 0;
	while(pow(k, i) <= n) i++;

	cout << i << nl;
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else cout<<0<<endl;
    return 0;
 } 

Measured memory_bytes: 256