akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    vi v = a;
    sort(all(v));
    map<int, int> m;
    forn(i, v.size()) m[v[i]] = i;
//    i64 S = 1LL * n * (n - 1) / 2;
    int ans = 0;
    forn(i, n) {
        int x = m[a[i]];
        ans += (i % 2 != x % 2);
    }
    cout << ans / 2 << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string t = "2019/04/30";
    string ans = "_";
    rep(i,n){
        if(s[i] == t[i]) continue;
        else if(s[i] > t[i]){
            ans = "TBD";
            break;
        }
        else{
            ans = "Heisei";
            break;
        }
    }
    if(ans == "_") ans = "Heisei";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int he[1000][1000];
int give[1000][1000];
PII p[1000000];

int dxy[] = {0,1,0,-1,0};

int main() {
	int h,w;
	cin >> h >> w;
	REP(j,h)
		REP(i,w){
			cin >> he[i][j];
			he[i][j]--;
			p[he[i][j]] = MP(i,j);
	}
	int ans=0;
	REP(i, w*h){
		bool f=false;
		REP(d,4){
			int nx = p[i].first + dxy[d], ny = p[i].second + dxy[d+1];
			if(nx < 0 || w <= nx || ny < 0 || h <= ny)continue;
			if(i>he[nx][ny])f|=true;
		}
		if(f)continue;
		queue<PII> q;
		q.push(p[i]);
		bool did[w][h];
		CLR(did);
		while(!q.empty()){
			int x = q.front().first, y = q.front().second;
			int nhe = he[x][y];
			q.pop();
			REP(d,4){
				int nx = x + dxy[d], ny = y + dxy[d+1];
				if(nx < 0 || w <= nx || ny < 0 || h <= ny)continue;
				if(nhe>he[nx][ny])continue; // exclude i
				if(did[nx][ny])continue;
				did[nx][ny]=true;
				if(give[nx][ny]>1)continue;
				give[nx][ny]++;
				if(give[nx][ny]>1)
					ans++;
				q.push(MP(nx,ny));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19740
#include<stdio.h>

int main(){
    int n;
    long long a[1000000], X=0LL, x=0LL;
    long long res, ans=1000000000000000000LL;
    int i, j;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%lld", &a[i]);
        X+=a[i];
    }

    for(i=0; i<n; i++){
        x+=a[i];
        res=X-2*x;

        if(res<0){
            res*=-1;
        }
        if(res<ans && i+1<n){
            ans=res;
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3712
import sys
sys.setrecursionlimit(10**5)

n, m = map(int, input().split())

edges = [[] for _ in range(n+1)]
for _ in range(m):
    x, y = map(int, input().split())
    edges[x].append(y)

dp = [-1 for _ in range(n+1)]

def longest_path(u):
    if dp[u] != -1:
        return dp[u]
    d = 0
    for v in edges[u]:
        d = max(d, 1+longest_path(v))
    dp[u] = d
    return d

for u in range(1, n+1):
    longest_path(u)

print(max(dp))


Measured memory_bytes: 162508
#include <iostream>

using namespace std;

int main()
{
    long long X;
    cin >> X;

    long long yokin = 100;

    long int year = 0;

    while (yokin < X) {
        yokin += (long long)(yokin / 100);
        year++;
    }

    cout << year;

    return 0;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys


ALH = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def solve(N: int):
    dfs("", 0, N)

def dfs(s: str, mx: int, N: int):
    if len(s) == N:
        print(s) 
    else:
        for i in range(mx + 1):
            dfs(s + ALH[i], mx + 1 if i == mx else mx, N)

# def solve(N: int):
#     alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
#     print("a" * N)
#     for i in range(N - 1, 0, -1):
#         s = ("a" * i) + "b"
#         if i == N - 1:
#             print(s)
#             continue
#         r_len = N - 1 - i
#         for j in range((r_len + 1) ** r_len + 1):
#             if j == (r_len + 1) ** r_len:
#                 print(s, end="")
#                 for l in range(r_len):
#                     print(alph[l+2], end="")
#                 print()
#                 continue
#             nokori = j
#             s2 = s
#             prev_val = set()
#             for k in range(r_len):
#                 if k == r_len - 1:
#                     val = nokori
#                 else:
#                     val = nokori // ((r_len + 1) ** (r_len - k - 1))
#                 prev_val.add(val)
#                 nokori = nokori % ((r_len + 1) ** (r_len - k - 1))
#                 s2 += alph[val]
#                 if val >= 3 and not val - 1 in prev_val:
#                     break
#             else:
#                 print(s2)
    # if N >= 3:
    #     for i in range(N):
    #         print(alph[i], end="")
    #     print()



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4412
#include <stdio.h>

int main(void){
  int i, n, N, ans = 0;
  scanf("%d", &N);
  
  int count;
  for(n = 1; n <= N; n += 2){
    count = 0;
    for(i = 1; i <= n; i++){
      if(n % i == 0) count++;
    }
    if(count == 8) ans++;
  }
  
  printf("%d\n", ans);
}

Measured memory_bytes: 128
N = int(input())
h = list(map(int, input().split()))
dp = [0] * N
dp[0] = 0;
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    dp[i] = min(abs(h[i]-h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2])
print(dp[N-1])

Measured memory_bytes: 20652
#include<iostream>
#include<climits>
#include<vector>
#include<queue>
using namespace std;

enum Color{WHITE, GRAY, BLACK};
struct edge{
        int v,c;
        edge(int v, int c): v(v), c(c){}
};
bool operator< (const edge &e, const edge &f){return e.c<f.c;}

int n;
vector<vector<edge>> a;
int *r;

void dijkstra(){
        Color color[n];
        for(int i=0;i<n;i++) color[i]=WHITE;
        color[0] = GRAY;
        priority_queue<edge> pq;
        pq.push(edge(0,0));
        while(!pq.empty()){
                edge e = pq.top(); pq.pop();
                if(color[e.v]==BLACK) continue;
                color[e.v] = BLACK;
                r[e.v] = - e.c;

                for(int i=0;i<a[e.v].size();i++){
                        edge f = a[e.v][i];
                        if(color[f.v]==BLACK) continue;
                        color[f.v] = GRAY;
                        int cost = e.c - f.c;
                        pq.push(edge(f.v, cost));
                }
        }

}

int main(){
        int u,k,v,c;
        cin>>n;
        a = vector<vector<edge>>(n);
        r = new int [n];
        for(int i=0;i<n;i++){
                cin>>u>>k;
                for(int j=0;j<k;j++){
                        cin>>v>>c;
                        a[u].emplace_back(edge(v,c));
                }
        }

        dijkstra();

        for(int i=0;i<n;i++)
                cout<<i<<" "<<r[i]<<endl;
        return 0;
}



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

int main() {
  int N;
  priority_queue<int> A;
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    A.push(num);
  }
  
  int alice = 0, bob = 0;
  bool a_turn = true;
  while (!(A.empty())) {
    if (a_turn) {
      alice += A.top();
      A.pop();
      a_turn = false;
    } else {
      bob += A.top();
      A.pop();
      a_turn = true;
    }
  }
  
  cout << (alice - bob) << endl;  
}

Measured memory_bytes: 3636
n, m = gets.chomp.split(" ").map(&:to_i)
arr = Array.new(n+1){[]}
m.times do |i|
    a, b = gets.chomp.split(" ").map(&:to_i)
    arr[a] << b
    arr[b] << a    
end
list = []
arr[1].each do |i|
    list << arr[i]
end
list.each do |i|
    if i.include?(n)
        puts "POSSIBLE"
        exit
    end
end
puts "IMPOSSIBLE"

Measured memory_bytes: 21500
#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(){
  long long int N,K;
  cin>>N>>K;
  
  long long int ans1=N%K;
  long long int ans2=K-ans1;
  
  long long int ans=min(ans1,ans2);
  cout<<ans<<endl;


}


Measured memory_bytes: 256
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.numeric;

void main(string[] args)
{
    long n, m;
    readf("%d %d\n", &n, &m);
    auto counts = new long[](n);
    long ac = 0;
    long wa = 0;
    foreach (_; 0 .. m)
    {
        long i;
        char[] s;
        readf("%d %s\n", &i, &s);
        i--;

        if (s == "AC" && counts[i] >= 0)
        {
            wa += counts[i];
            ac++;
            counts[i] = -1;
        }
        else if (counts[i] >= 0)
        {
            counts[i]++;
        }
    }
    writefln("%d %d", ac, wa);

}


Measured memory_bytes: 4092
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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




int main(){
    long long N; int K; std::cin >> N >> K;
    long long sum(0);
    for(long long i(K), i_len(N+1); i <= i_len; ++i){
        long long a((N+1)*N/2 - (N-i+1)*(N-i)/2 - i*(i-1)/2 + 1);
        sum = (sum + a) % MOD;
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<cmath>
#include<unordered_set>
#define int long long
#define P pair<int,int>
#define p pair<int,P>
using namespace std;

template<typename Type>
class RMQ {
private:
	int size_; std::vector<Type> dat;
public:
	RMQ() : size_(0), dat(std::vector<Type>()) {};
	RMQ(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat.resize(size_ << 1, std::numeric_limits<Type>::max());
	}
	template<class T>
	RMQ(T begin_, T end_) {
		int n = end_ - begin_;
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
		for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void update(unsigned i, Type x) {
		i += size_; dat[i] = x;
		while (i > 1) {
			i >>= 1;
			dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	inline Type query(unsigned l, unsigned r) {//(l,r]
		Type ret = std::numeric_limits<Type>::max();
		l += size_; r += size_;
		while (l != r) {
			if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1;
			if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1;
		}
		return ret;
	}
};
int n;
int t[500001];
vector<P>ans;
signed main() {
	cin >> n;
	RMQ<int>A(n), B(n);//偶数番目  奇数番目
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		t[a] = i;
		if (i & 1) {
			B.update(i / 2, a);
		}
		else {
			A.update(i / 2, a);
		}
	}
	priority_queue<p, vector<p>, greater<p>>Q;
	Q.push({ A.query(0, n / 2) ,{0,n} });
	while (Q.size()) {
		p w = Q.top(); Q.pop();
		int x = w.second.first, y = w.second.second;
		if (x >= y)continue;
		if (x & 1) {
			int S = B.query(x / 2, y / 2);
			int index = t[S];
			int K = A.query(index / 2 + 1, y / 2 + 1);
			int o = t[K];
			ans.push_back({ S,K });
			Q.push({ B.query(x / 2,index / 2),{x,index} });
			Q.push({ A.query((index+1) / 2,o / 2),{ index + 1, o } });
			Q.push({ B.query((o+1) / 2,y / 2),{ o + 1, y } });
		}
		else {
			int S = A.query(x / 2, y / 2);
			int index = t[S];
			int K = B.query(index / 2, y / 2);
			int o = t[K];
			ans.push_back({ S,K });
			Q.push({ A.query(x / 2,index / 2),{ x,index } });
			Q.push({ B.query((index + 1) / 2,o / 2),{ index + 1, o } });
			Q.push({ A.query((o + 1) / 2,y / 2),{ o + 1, y } });
		}
	}
	for (int i = 0; i < n / 2; i++) {
		if (i)cout << " ";
		cout << ans[i].first << " " << ans[i].second;
	}
	cout << endl;
}

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

int main()
{
    int n, x, i, min, max;
    int count = 0;

	do{
        cin >> n >> x;
        if((n == 0) && (x == 0)) break;

        count = 0;
            if((x < 6) || (x > (3 * n - 3))){
                cout << 0 << endl;
            }else{
                i = 1;
                if(x > 2 * n) i = x - 2 * n;
                for( ; 3 * i + 3 <= x; i++){
                    min = i + 1;
                    if(min < x - i - n) min = x - i - n;
                    max = (x - i - 1) / 2;
                    if(min <= max) count = count + max - min + 1;
            }
                cout << count << endl;
            }

    }while(1);

    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll unsigned long long

using namespace std;

ll trailing_zero(ll n)
{
ll sum = 0;
  while(n)
  {
    sum += ((n / 5) / 2);
    n = n / 5;
  }

  return sum;
}

int main()
{
  ll n;
  cin >> n;
  if(n % 2 == 0)
  {
//    ll sum =  0;
//    for(ll i = 5; i <= n; i = i * 5)
//    {
//      sum += (n / i) / 2;
//    }
    //cout <<  sum << '\n';
    cout << trailing_zero(n) << '\n';
  }
  else
  {
    cout << 0 << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
c=0
while 1:
    n=int(input())
    if n==0:break
    c+=1
    p=[complex(*map(int,input().split())) for _ in range(n)]
    s,pre=0,p[0]
    while p:
        now=p.pop()
        s+=now.real*pre.imag-now.imag*pre.real
        pre=now
    print(c,abs(s)/2);input()

Measured memory_bytes: 7616
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 7 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int n;

    cin>>n;

    double sum = 0;

    while(n--){
        double amount ;
        string currency;

        cin>>amount>>currency;

        if(currency=="JPY"){
            sum+=amount;
        }else{
            amount*=(float)380000;
            sum+=amount;
        }
    }


    cout<<setprecision(4)<<fixed<<sum<<endl;



    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("bin","r",stdin);
    freopen("bout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

using namespace std;

int main(void){
    long long N, M;
    long long A = 0;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        long long a;
        cin >> a;
        A += a;
    }
    cout << max(-1LL, N - A) << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 6005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {
	int MOD;
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;
 
inline int ksm(int x, int k) {
    int ret = 1;
   	for (; k; k >>= 1) {
        if (k & 1) ret = Mul(ret, x);
        x = Mul(x, x);
    }
    return ret;
}

int n, n3, fac, inv[MAXN * 3], dp[MAXN][MAXN * 2];

void init() {
	read(n); read(MOD);
	n3 = n + n + n;
	inv[0] = inv[1] = fac = 1;
	for (int i = 2; i <= n3; ++i) {
		fac = Mul(fac, i);
		inv[i] = Mul(MOD - MOD / i, inv[MOD % i]);
	}
}

void solve() {
	dp[0][n3] = 1;
	for (int i = 0; i < n3; ++i) {
		for (int j = n3 - i; j <= n3 + i; ++j) {
			int x = dp[i][j];
			if (!x) continue;
			Inc(dp[i + 1][j + 1], Mul(x, inv[i + 1]));
			Inc(dp[i + 2][j - 1], Mul(x, inv[i + 2]));
			Inc(dp[i + 3][j], Mul(x, inv[i + 3]));
		}
	}
	int ans = 0;
	for (int i = n3; i <= n3 * 2; ++i) {
		Inc(ans, dp[n3][i]);
	}
	printf("%d\n", Mul(ans, fac));
}

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


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

int main(){
    ios_base::sync_with_stdio(0);
    string a;
    cin>>a;
    int c=(int)a.size();
    for (int i = 0; i < a.size()-1; ++i)
    {
        if(a[i]!=a[i+1]){
            c = min(c,max(i+1,(int)(a.size())-i-1));
        }
    }    
    cout<<c<<endl;
    return 0;   
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
   
  int64_t h,a;
  cin>>h>>a;
  if(h%a==0)cout<<h/a<<endl;
  else cout<<h/a+1<<endl;
      
  
  
}

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

pre = sum(a)

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

print(pre - sum(a))

Measured memory_bytes: 14132
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  string s,t;
  cin >> s >> t;
  
  bool flag = 0;
  for(int i = 0; i < s.size(); i++) {
    string a = s.substr(0,i);
    string b = s.substr(i);
    if(a+b == t | b+a == t) flag = 1;
  }

  if(flag)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

typedef long long LL;

const int N=200000;

char s[N+9];
int n;

void into(){
  scanf("%s",s+1);
  n=strlen(s+1);
}

int dp[N+9][2];

void Get_dp(){
  dp[1][0]=1;
  for (int i=2;i<=n;++i){
	dp[i][0]=max(dp[i-1][1]+1,s[i-1]==s[i]?0:dp[i-1][0]+1);
	dp[i][1]=max(dp[i-2][0]+1,i<=3||s[i-3]==s[i-1]&&s[i-2]==s[i]?0:dp[i-2][1]+1);
  }
}

void work(){
  Get_dp();
}

void outo(){
  printf("%d\n",max(dp[n][0],dp[n][1]));
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 5536
import platform
ver = platform.python_version_tuple()
if int(ver[1]) < 5:
    from fractions import gcd
else:
    from math import gcd

from functools import reduce
from sys import stdin, stdout

input = lambda: stdin.readline()
# write = stdout.write

def main():
    N, X = map(int, input().split())
    Xn = map(int, input().split())

    city = [abs(i - X) for i in Xn]
    ans = reduce(gcd, city)
    print(ans)

main()


Measured memory_bytes: 16640
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#include <vector>
#include <iterator>
typedef  long long int ll;
typedef  long double ld;
#define PT(x) cout << (#x) << " is " << (x) << endl;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int M = 1000000007;
#define int long long
void PV( vi v) { for(ll i=0 ; i<v.size() ; i++) cout<< v[i] << " "; cout<< endl;}
void PA( int v[] , int n ){ for(ll i=0 ; i<n ; i++)cout<< v[i] << " " ; cout<< endl;}
 int rn(double d ){
  int k=floor(d);
  return k;
 }
signed  main(){
     SPD_emergency
   //ll t; cin>> t; while(t--)
    {
        int a , b;
        cin>>a>>b;
        int c = a / 0.08;
        int d = b /0.1;
        c=max(c,d);
        int ans=-1;
        for(int i = 1;i<=c+100;i++){
            if(rn(i*0.08)==a && rn(i*0.1)==b){ans=i; break;}
        }
        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)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i,n) maxs(ans, uf.size(i));
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3988
import java.util.*;

public class Main {

    private static int Q;
    private static int N;
    private static int M;
    private static int[] a;
    private static int[] b;
    private static int[] c;
    private static int[] d;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        Q = sc.nextInt();
        a = new int[Q];
        b = new int[Q];
        c = new int[Q];
        d = new int[Q];
        for (int i = 0; i < Q; i++) {
            a[i] = sc.nextInt()-1;
            b[i] = sc.nextInt()-1;
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < Q; i++) {
            int[] A = new int[N];
            A[0] = 1;
            int tmp = dfs(1, 1, A);
            ans = Math.max(ans,tmp);
        }
        System.out.println(ans);
    }

    private static int dfs(int pos, int val, int[] A) {
        if (pos == N) {
            return calc(A);
        }

        int max = 0;
        for (int i = val; i <= M; i++) {
            A[pos] = i;
            int tmp = dfs(pos+1, i, A);
            max = Math.max(max,tmp);
        }

        return max;
    }

    private static int calc(int[] A) {
        int ret = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]]-A[a[i]] == c[i]) ret += d[i];
        }
        return ret;
    }

}



Measured memory_bytes: 36788
n, s = int(input()), str(input())

num1, num2, num3 = set([]), set([]), set([])
for i in range(n):
    if s[i] in num1:
        continue
    num1.add(s[i])
    for j in range(i + 1, n):
        tmp2 = s[i] + s[j]
        if tmp2 in num2:
            continue
        num2.add(tmp2)
        for k in range(j + 1, n):
            tmp3 = tmp2 + s[k]
            if tmp3 in num3:
                continue
            num3.add(tmp3)
print(len(num3))

Measured memory_bytes: 3188
n, m = map(int,input().split())
people = []
points = []
for i in range(n):
  person = list(map(int,input().split()))
  people.append(person)
for i in range(m):
  point = list(map(int,input().split()))
  points.append(point)

for person in people:
  mini = 1000000000
  minIndex = 0
  for i in range(m):
    distance = abs(person[0]-points[i][0]) + abs(person[1]-points[i][1])
    
    if mini > distance:
      mini = distance
      minIndex = i
  print(minIndex+1)
  

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

const int MAX_C = 1000;
long long Com[MAX_C][MAX_C];
void calc_com() {
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for(int i = 1; i < MAX_C; ++i) {
        Com[i][0] = 1;
        for(int j = 1; j < MAX_C; ++j) {
            Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]) % MOD;
        }
    }
}

int main() {
    int N, K;
    cin >> N >> K;
    calc_com();
    if(K > Com[N - 1][2]) {
        cout << -1 << endl;
        return 0;
    }
    int M = Com[N - 1][2] + N - 1 - K;
    vector<pii> res;
    for(int i = 1; i < N; i++) {
        res.pb(MP(1, i + 1));
    }
    for(int i = 1; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            res.pb(MP(i + 1, j + 1));
        }
    }
    cout << M << endl;
    rep(i, M) { cout << res[i].first << " " << res[i].second << endl; }

    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  ll n, m; std::cin >> n >> m;
  if (n == 1 && m == 1)
    std::cout << 1 << "\n";
  else if (n == 1 || m == 1)
    std::cout << max(n, m) - 2 << "\n";
  else
    std::cout << n*m - (2*n + 2*m - 4) << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x[10000],i,y=0;
  for(i=0;i<=10000;i++){
    scanf("%d",&x[i]);
    if(x[i]==0)break;
    y++;
  }
  for(i=0;i<y;i++){
    printf("Case %d: %d\n",i+1,x[i]);
      }
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int main(){
    while(1){
        int x,y;
        scanf("%d%d",&x,&y);
        if(x==0&&y==0){
            break;
        }
        if(x<y){
            printf("%d %d\n",x,y);
        }else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}


Measured memory_bytes: 2044
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


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

    int n; cin>>n;
    vector<int> v(n); rep(i,n) cin>>v[i];
    vector<int> ans(n);

    rep(i,n) ans[v[i]-1] = i + 1;

    rep(i,n) cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	int ans = 1;
	rep(i, 6) if(n>=pow(2,i+1)) ans=pow(2,i+1);
	cout << ans << endl;
}


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

int main() {

  int N,M,C;
  
  cin >> N >> M >> C;
  
  int S=0,X=0;
  
  // M要素の配列で初期化
  vector<int> vec(M);

  // M個の入力を受け取る
  for (int l = 0; l < M; l++) {
    cin >> vec.at(l);
    }
    
  
  for (int i = 0; i < N; i++) {

    S=0;
    
    // M要素の配列で初期化
      vector<int> A(M);

    for (int j = 0; j < M; j++){
           cin >> A.at(j);
    }
      
    for (int k = 0; k < M; k++){
          S += vec.at(k) * A.at(k);
    }
      
      if (S+C > 0) {
      X++;
      }
   }
  
    cout << X << endl;
}

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

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back

typedef long long     ll;

//-*-*-*-*-*-*-*-*-
ll n;
bool visw[4000];

int main()
{
         ll ans=0;ll c=0;
         string s;
         cin>>s;
            for(int i=0;i<s.size();i++){
                         if(s[i]=='B'){
                                       c++;
                         }else{ans+=c;}
              }
              cout<<ans;
 
          
}

Measured memory_bytes: 640
# coding=utf-8

import itertools
get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

# N, K = 5, 3
N, K = gets()

total = (N - 1) * (N - 2) / 2
if K > total:
    print -1
    exit()
res = []
for i in range(1, N):
    res.append([i, N])

res.extend(list(itertools.combinations(range(1, N), 2))[:total - K])
print len(res)
for i, j in res:
    print i, j


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007
#define rev(v) reverse(v.begin(), v.end());

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int n; cin >> n;
    int a, b;
    if(n==1) cout << "Hello World";
    else{
        cin >> a >> b;
        cout << a+b;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	lli x, a, b, ans;
	cin >> x;
	b = x/11;
	a = x%11;
	if(a == 0) ans = b*2;
	else if(a >= 1 && a <= 6) ans = b*2+1;
	else if(a >= 7)ans = b*2+2;
	cout << ans <<endl;
	return 0;
}


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

try:
    blue_num = A * (N // (A + B))
    residue = N - ((A + B) * (N // (A + B)))
    if(residue > A):
        blue_num += A
    else:
        blue_num += residue
except ZeroDivisionError:
    blue_num = 0

print(blue_num)

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

// 0 ~ nの総和を求める
int sum(int N) {
  if (N == 0) {
    // sum0のケースを場合分け
    return 0;
  }

  // それ以外のケース
  int s = sum(N - 1);  // 1~(n-1)の総和を計算
  return s + N;  // nを足して返す
}

int main() {
  int N;
  cin >> N ;
  cout << sum(N) << endl;  // 6
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s, v;
    cin >> s;
    v = s[0];
    for (int i = 1; i < s.length(); i++) {
        if (v.back() != s[i]) {
            v += s[i];
        }
    }
    cout << v.size() - 1 << endl;
}

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

ans = 0
for i in range(1, n + 1):
    if i % 2 == 0:
        continue
    dividors = []
    for j in range(1, n + 1):
        if i % j == 0:
            dividors.append(j)
    if len(dividors) == 8:
        ans += 1
print(ans)

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

struct P
{
    long long x,y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<int> v;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[111115];
int l[1];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=998244353,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s[222][22];
//priority_queue<P> q;
queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

string r;
//char r[222253];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;
}



int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&o[t]);
        if(o[t]%2)
        {puts("first");
            return 0;
        }
    }
    //sort(o+1,o+a+1);
    //if((o[a]-o[a-1])%2)
    //else
    puts("second");
}





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

#define forn(i,n) for(int i = 0;i<n;i++)
#define forne(i,j,n) for(int i = j;i<n;i++)
const ll mod = 1e9+7;
const ll INF = 1000000001;
const ll N = 1000001;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

ll powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
ll A[N],B[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];

int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n;
cin>>n;
ll nn = n;
ll ans = 0;
forne(i,2,sqrt(nn)+1){
	ll c = 0;
	while(n%i == 0){
		c++;
		n/=i;
	}
	ans+=((-1+sqrt(1+8*c))/2);
}
if(n > 1) ans++;
cout<<ans<<endl;

}

Measured memory_bytes: 3696
from collections import defaultdict, deque
def solve():
    N = int(input())
    G = defaultdict(list)

    for i in range(N-1):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append((b,c))
        G[b].append((a,c))
    
    Q, K = map(int,input().split())
    K -= 1
    visited = [False] * N
    q = deque()
    q.append((K,0))
    visited[K] = True
    depth = [0] * N
    depth[K] = 0
    while len(q) > 0:
        now, d = q.popleft()
        for next,distance in G[now]:
            if not visited[next]:
                q.append((next,d+distance))
                visited[next] = True
                depth[next] = d+distance
        
    ans = []
    for i in range(Q):
        x,y = map(int,input().split())
        x -= 1
        y -= 1
        ans.append(depth[x] + depth[y])
    
    print(*ans,sep='\n')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 101848
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
//#include <boost/graph/adjacency_list.hpp>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define IN_V(type, name) vector<type> name; for(auto& x: name) cin >> x

int main()
{
	cout << fixed << setprecision(6);
	IN(int, a);
	IN(int, b);
	IN(int, c);
	//IN_V(int, als);

	cout << max(0, c - (a - b)) << endl;
	
	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int A,B,K;cin>>A>>B>>K;

  if (B-A+1<=2*K) {
    FOR(i,A,B+1) OUT(i);
  } else {
    FOR(i,A,A+K) OUT(i);
    FOR(i,B-K+1,B+1) OUT(i);
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
int main(){
	fast;
	ll n,ac=0,wa=0,tle=0,re=0;
	cin>>n;
	string s;
	for(ll i=0;i<n;i++)
	{
		cin>>s;
		if(s=="AC")
			ac++;
		else if(s=="WA")
			wa++;
		else if(s=="TLE")
			tle++;
		else
			re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
}



Measured memory_bytes: 3652
W,H,N=map(int, input().split())
w=0
h=0
for i in range(N):
 x,y,a=map(int, input().split())
 if a==1:
  w=max(w,x)
 elif a==2:
  W=min(W,x)
 elif a==3:
  h=max(h,y)
 else:
  H=min(H,y)
print(max(0,(W-w))*max(0,(H-h)))

  


 

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

long long fac(int k){long long sum = 1;for(int i=1;i<=k;++i)sum *= i;return sum;}
long long per(int n,int r){long long nn,rr;nn=fac(n);rr=fac(r)*fac(n-r);return nn/rr;}

int main(){
    long long a,b;
    cin >> a >> b;
    long long diff = b - a;
    long long sum = 0;
    for(int i=1;i<=diff;i++){
        sum += i;
    }
    cout << sum - b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  if (a + b > n+1) {
    cout << -1 << endl;
    return 0;
  }
  if (b < (n+a-1) / a) {
    cout << -1 << endl;
    return 0;
  }
  int mx = n;
  REP(i,a) {
    if (i) cout << ' ';
    cout << mx - a + 1 + i;
  }
  mx -= a;
  int reduce = n+1 - (a+b);
  while (reduce > 0) {
    if (reduce >= a) {
      REP(i,a) {
        cout << ' ' << mx - a + 1 + i;
      }
      mx -= a;
    } else {
      REP(i,reduce+1) {
        cout << ' ' << mx - reduce + i;
      }
      mx -= reduce+1;
    }
    reduce -= min(a-1, reduce);
  }
  while(mx > 0) {
    cout << ' ' << mx;
    --mx;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n, m;
  cin >> n;
  map <string, ll> score;
  string s;
  rep(i, n) {
    cin >> s;
    if (score.count(s)) {
      score.at(s)++;
    } else {
      score[s] = 1;
    }
  }
  cin >> m;
  rep(i, m) {
    cin >> s;
    if (score.count(s)) {
      score.at(s)--;
    } else {
      score[s] = -1;
    }
  }
  ll ans = score.at(s);
  for (auto p : score) {
    if (ans < p.second) ans = p.second;
  }
  if (ans < 0) {
    cout << 0 << endl;
  } else {
    cout << ans << endl;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int x; cin >> x;
    int r = (2000 - x + 200 - 1) / 200;
    cout << r << '\n';   
    
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

Measured memory_bytes: 3644