akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long long n, A[1000000000];
	//ll n, m, q;
	cin >> a;
	b = 100000000000;
	if (a==1)
	{
		b = 1;
	}
	for (int i = 1; i < min(sqrt(a)+100,double(a)); i++)
	{
		if (a%i==0)
		{
			b=min(max(log10(a/i) + 1, log10(i) + 1),double(b));
		}
	}


	cout << b << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//accumulate(x, x + a, 0);
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

//////////////////ここの値は必ず確認！！！！！////////////////////
//---------------------------------------------------------//
const int MOD = 1e9+7;
const int MAXR = 510000;
//---------------------------------------------------------//

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(n<k)return 0;
    if(n<0)return 0;
    if(k==0) return 1;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    int N; cin >> N;
    map<int,int> A;
    REP(i,N){
        int a; cin >> a;
        A[a] ++;
    }

    if(N%2==1){
        REP(i,N/2+1){
            if(i==0 && A[0]!=1){
                cout << 0 << endl;
                return 0;
            }else if(i!=0 && A[i*2]!=2){
                cout << 0 << endl;
                return 0;
            }
        }
    }else{
        REP(i,N/2){
            if(A[i*2+1]!=2){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << modpow(2,N/2) << endl;
    return 0;
}

Measured memory_bytes: 18464
# vim: fileencoding=utf-8


def main():
    a, b = map(int, input().split())
    c = 0
    for i in range(a, b + 1):
        #     s = str(i)
        #     r = "".join(reversed(list(s)))
        #     if s == r:
        #         c += 1
        if (i % 10) == (i // 10000 % 10) and (i // 10 % 10) == (i // 1000 % 10):
            c += 1
    print(c)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64480
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int count=1;
    int ans=0;
    rep(i,n){
        if(a[i]==count)count++;
        else ans++;
    }
if(count==1)cout<<"-1";
else cout<<ans;
return 0;
}

Measured memory_bytes: 3668
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ary[] = new int[3];
		int A = Integer.parseInt(S.substring(0, 1));
		ary[0] = Integer.parseInt(S.substring(1, 2));
		ary[1] = Integer.parseInt(S.substring(2, 3));
		ary[2] = Integer.parseInt(S.substring(3, 4));
		for (int i = 0; i < (Math.pow(2, 3)); i++) {
			int ans = A;
			StringBuilder sb = new StringBuilder(S);
			for (int j = 0; j < 3; j++) {
				if ((1&i>>j) == 1) {
					ans += ary[j];
					sb.insert(2 * j + 1, "+");
				} else {
					ans -= ary[j];
					sb.insert(2 * j + 1, "-");
				}
			}
			if(ans == 7) {
				System.out.println(sb.append("=7"));
				return;
			}
		}
	}
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = 50;

vector<int> G[MAX_N];

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

	rep (i, MAX_N) G[i].clear();

	int N, M; cin >> N >> M;	
	rep (i, M){
		int a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	} // end rep
	
	rep (i, N){
		cout << (int)G[i].size() << endl;
	} // end rep
	
	return 0;
}

Measured memory_bytes: 256
/* 
chirag11032000
Chirag Thakur
*/

#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;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	ll r, d, x;
	cin >> r >> d >> x;
	for (int i = 1; i <= 10; ++i) {
		x = r * x - d;
		cout << x << "\n";
	}
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    char a, b, ans; cin >> a >> b;

    if(a == b) ans = 'H';
    if(a != b) ans = 'D';

    cout << ans;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
}

void solve()
{
	int a[3];
	rep(i, 3) cin >> a[i];
	sort(a, a+3);
	cout << a[0] + a[1] + a[2] * 10 << endl;
}


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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int ans,n;
  cin>>n;
  ans=sqrt(n);
  cout<<ans*ans<<endl;
}

Measured memory_bytes: 256
#abc133b

n,d=map(int,raw_input().split())
x=[map(int,raw_input().split()) for i in xrange(n)]
res=0
for i in xrange(n):
 for j in xrange(i+1,n):
  norm=0
  for k in xrange(d):
   norm+=pow((x[i][k]-x[j][k]),2)
  if int(norm**0.5+0.01)**2==norm:
   res+=1
print res


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    REP(i, N) { cin >> A.at(i); }
    REP(i, N) { cin >> B.at(i); }

    int ans = INF;
    int bit = 0;
    while (bit < 1 << N) {
        vector<pair<int, int>> even, odd;
        int mask = 1;
        int sum = 0;
        REP(i, N) {
            if (mask & bit) { // ビットが立てば裏
                if (i % 2 == 0) {
                    odd.push_back(make_pair(B[i], i));
                } else {
                    even.push_back(make_pair(B[i], i));
                }
            } else {
                if (i % 2 == 0) {
                    even.push_back(make_pair(A[i], i));
                } else {
                    odd.push_back(make_pair(A[i], i));
                }
            }
            mask = mask << 1;
        }

        sort(ALL(even));
        sort(ALL(odd));

        if (!((even.size() == (N + 1) / 2) && (odd.size() == N / 2))) {
            bit++;
            continue;
        }

        bool flag = false;
        REP(i, odd.size()) {
            if (odd[i].first < even[i].first) {
                flag = true;
            }
        }
        FOR(i, 1, even.size()) {
            if (odd[i - 1].first > even[i].first) {
                flag = true;
            }
        }

        vector<int> ind;
        REP(i, N) {
            if (i % 2 == 0) {
                // cout << even[i / 2] << " ";
                ind.push_back(even[i / 2].second);
            } else {
                // cout << odd[i / 2] << " ";
                ind.push_back(odd[i / 2].second);
            }
        }

        int t = 0;
        for (int i = 0; i < N - 1; i++) {
            for (int j = 0; j < N - i - 1; j++) {
                if (ind[j] > ind[j + 1]) { // 右隣が小さければ入れ替える
                    swap(ind[j], ind[j + 1]);
                    t++;
                }
            }
        }

        if (flag) {
            bit++;
            continue;
        }
        chmin(ans, t);
        bit++;
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//Keep Working Hard
  // I__Like__Food  

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

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
  const double PI = 3.1415926535898;


int32_t main()
{






    int a,b;
    cin >> a >> b;

    if(a <= b)
    {
    	cout << "unsafe";
    }
    else
    {
    	cout << "safe";
    }





    return 0;
}


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

using namespace std;

int findgcd(int a, int b)
{
	if (b == 0)
	{
		return a;
	}
	return findgcd(b, a % b);
}

int main()
{
	int k, res = 0;
	cin >> k;
	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			int g = findgcd(i, j);
			for (int l = 1; l <= k; l++)
			{
				res += findgcd(g, l);
			}
		}
	}

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
int n;
ll func(vector<pair<ll,ll>>&v,ll a[][10001],int i,ll c)
{
    if(c<=0){return 0;}
    if(i==n){return 100000000000;}
    //cout<<i<<endl;
    //cout<<a[i][c]<<endl;
    if(!a[i][c])
    {
        a[i][c]=min(v[i].F+func(v,a,i,c-v[i].S),func(v,a,i+1,c));
      //  cout<<a[i][c]<<endl;
    }
   // cout<<a[i][c];
    return a[i][c];
}
int main()
{
  // fopen();
   ll h;
   cin>>h>>n;
   vector<pair<ll,ll>>v;
   //cout<<n;
   rep(i,n)
   {
        ll p,q;
        cin>>p>>q;
        v.pb({q,p});
        //cout<<v[i].F<<endl;
   }
   sort(v.begin(),v.end());
   ll a[n][10001];
   fll(a);
   cout<<func(v,a,0,h);
    
}

Measured memory_bytes: 79232
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)
a.append(0)
b=[]
c=0
for i in range(n+1):
    c=abs(a[i]-a[i+1])
    b.append(c)
B=sum(b)
for i in range(n):
    print(B-b[i]-b[i+1]+abs(a[i+2]-a[i]))

Measured memory_bytes: 14048
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n;
int a[N];
ll p[N];

ll sum(int l, int r) {
	return p[r] - p[l - 1];
}
int left(int i) {
	int l = 2, r = i, ans = i;
	while (l <= r) {
		int mid = l + r >> 1;
		if (p[mid - 1] >= p[i] - p[mid - 1]) {
			ans = mid, r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	return ans;
	// return {max(p[ans - 1], p[i] - p[ans - 1]), min(p[ans - 1], p[i] - p[ans - 1])};
}
int right(int i) {
	int l = i + 1, r = n - 1, ans = i + 1;
	while (l <= r) {
		int mid = l + r >> 1;
		if (p[mid] - p[i] <= p[n] - p[mid]) {
			ans = mid, l = mid + 1;
		} else {
			r = mid - 1;
		}
	}
	return ans;
	// return {max(p[n] - p[ans], p[ans] - p[i]), min(p[n] - p[ans], p[ans] - p[i])};
}
ll ans = linf;
void upd (pair <ll, ll> x, pair <ll, ll> y) {
	ans = min(ans, max(x.f, y.f) - min(x.s, y.s));
}
void upd(ll x, ll y, ll z, ll w) {
	// cout << x << ' ' << y << ' ' << z << ' ' << w << nl;b
	ans = min(ans, max({x, y, z, w}) - min({x, y, z, w}));
}
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	rep(i, 1, n) {
		cin >> a[i];
		p[i] = p[i - 1] + a[i];
	}
	rep(i, 2, n - 1) {
		// i = 4;
		int l = left(i), r = right(i);
		// cout << l << ' ' << r << nl;
		upd(sum(l, i), sum(1, l - 1), sum(i + 1, r), sum(r + 1, n));
		if (l > 2) {
			upd(sum(l - 1, i), sum(1, l - 2), sum(i + 1, r), sum(r + 1, n));
			if (r + 2 <= n) {
				upd(sum(l - 1, i), sum(1, l - 2), sum(i + 1, r + 1), sum(r + 2, n));
			}
		}
		if (r + 2 <= n) {
			upd(sum(l, i), sum(1, l - 1), sum(i + 1, r + 1), sum(r + 2, n));
		}
		/* pair <ll, ll> l = left(i), r = right(i);
		cout << l.f << ' ' << l.s << nl;
		cout << r.f << ' ' << r.s << nl;
		l.f = max(l.f, r.f);
		l.s = min(l.s, r.s);
		ans = min(ans, l.f - l.s);
		break; */
		// break;/b/
	}
	cout << ans;
	ioi
}


Measured memory_bytes: 4480
N = int(input())

t0, x0, y0 = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - t0
    dx = x - x0
    dy = y - y0
    dxy = abs(dx) + abs(dy)  #; print(dt, dx, dy, dxy) 
    if dt%2 == dxy%2 and dxy <= dt :
        t0, x0, y0 = t, x, y
    else:
        print('No')
        break
else:
    print('Yes')

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

int main(){
  int n; cin >> n;
  ll a,b;
  vector<pair<ll, ll>> ab(n);

  rep(i,n) {
    cin >> ab.at(i).second >> ab.at(i).first;
  }

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

  ll sum = 0;
  bool flag=0;
  rep(i,n) {
    sum += ab.at(i).second;
   // cout << sum << endl;
    if(ab.at(i).first < sum) {
      flag=1;
      break;
    }
  }

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



Measured memory_bytes: 3328
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<vector<ll>> v(n, vector<ll>(3)); cin >> v;
  vector<vector<ll>> dp(n+1, vector<ll>(4, -linf));
  dp[0][3] = 0;
  rep(i, n) rep(j, 4) {
    if (dp[i][j] < 0) continue;
    rep(k, 3) {
      if (j == k) continue;
      chmax(dp[i+1][k], dp[i][j] + v[i][k]);
    }
  }
  ll ans = *max_element(all(dp[n]));
  cout << ans << endl;
}


Measured memory_bytes: 12800
#include <iostream>

#define MAX_LEN 1 << 19

using namespace std;

int main( int argc, char **argv )
{
    int M, K;
    cin >> M >> K;

    if ( M == 1 )
    {
        if ( K == 0 )
            cout << "0 0 1 1" << endl;
        else
            cout << -1 << endl;
    }
    else if ( K < ( 1 << M ) )
    {
        for ( int i = 0; i < ( 1 << M ); i++ )
        {
            if ( i != K ) cout << i << " ";
        }
        cout << K << " ";
        for ( int i = ( 1 << M ) - 1; i >= 0; i-- )
        {
            if ( i != K ) cout << i << " ";
        }
        cout << K << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}


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

count = 0
flag = True
while flag:
    flag = False
    for j in range(n - 1, 0, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            count += 1
            flag = True

print(' '.join(list(map(str, a))))
print(count)

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

min = 1
max = n

while True:
    if (max - min == 1):
        sqrt = min
        break
    ave = (min + max) // 2
    if (ave**2 > n):
        max = ave
    else:
        min = ave

# print(sqrt)

for i in reversed(range(sqrt+1)):
    if (n % i == 0):
        ans = (n // i) + i -2
        break

print(ans)

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

int main() {
    int n; cin >> n;
    int count = 0;
    int save = 0;
    vector<pair<int,int>> data;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        bool front = true;
        int f = 0, b = 0;
        for (int j = 0; j < (int)s.size(); j++) {
            if (s[j] == '(') {
                count++;
                f++;
            }
            else {
                count--;
                if (f) f--;
                else {
                    front = false;
                    b++;
                }
            }
        }
        if (f == 0 && b == 0) continue;
        if (front) save += f;
        else data.push_back(make_pair(b, f));
    }

    if (count != 0) { cout << "No" << endl; return 0; }

    sort(data.begin(), data.end(), [](pair<int,int> a, pair<int,int> b) {
        int aa = a.second - a.first >= 0 ? 0 : 1;
        int bb = b.second - b.first >= 0 ? 0 : 1;
        if (aa != bb) return aa < bb;
        if (aa == 0) return a.first < b.first;
        if (aa == 1) return a.second > b.second;
    } );

    bool check = true;
    for (int i = 0; i < (int)data.size(); i++) {
        save -= data[i].first;
        if(save < 0) check = false;
        save += data[i].second;
    }

    cout << (check ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string o,e;
    cin>>o>>e;
    rep(i,len(o)+len(e)){
      if(i%2==0){
        cout<<o[i/2];
      }else{
        cout<<e[i/2];
      }
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	int y = 1000;
	int k, i = 1;

	scanf("%d", &n);
	k = n / y;

	if (n % y == 0) {
		i = k;
		k = 0;
	}

	while (k != 0) {
		i++;
		y =1000*i;
		k = n / y;
	}

	printf("%d\n", 1000*i-n);

	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void write(int x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
int main()
{
    ll a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1);
    return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] h;
    int m, i, j;
    long sum;

    n = sc.nextInt();
    h = new int[n];
    for(i = 0;i < n;i++)h[i] = sc.nextInt();
    sum = 1; m = n;

    for(i = 1;m > 0;i++){
      if(m <= i * 4)break;
      else sum += (long)(i * 4);
      for(j = 0;j < n;j++)if(--h[j] == 0)m--;
    }
    for(i = 0;i < n;i++)if(h[i] > 0)sum += (long)h[i];

    out.println(sum);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 20864
#include<stdio.h>
int main(){
  int a,b,c,x,y,z;
  scanf("%d%d%d",&a,&b,&c);
  if(a>b){
    x=a;
    a=b;
    b=x;
  }
  if(b>c){
    y=b;
    b=c;
    c=y;
  }
  if(a>b){
    z=a;
    a=b;
    b=z;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef array<int, 2> duo;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        vector<int> a(n); cin >> a;
        sort(all(a));
        cout << a[n / 2] - a[n / 2 - 1];
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3724
// https://beta.atcoder.jp/contests/abc075
// status: [review][solve]

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(4 3
-1000000000 -1000000000
1000000000 1000000000
-999999999 999999999
999999999 -999999999
)");
    stringstream stream(program_input);
#endif
    int N, K;
    stream >> N >> K;

    vector<int> x(N), y(N);
    for (int i = 0; i < N; ++i) stream >> x[i] >> y[i];

    vector<int> x_sort(N), y_sort(N);
    copy(x.begin(), x.end(), x_sort.begin());
    copy(y.begin(), y.end(), y_sort.begin());

    sort(x_sort.begin(), x_sort.end());
    sort(y_sort.begin(), y_sort.end());

    ui64 ans = static_cast<ui64>(x_sort[N - 1] - x_sort[0]) * static_cast<ui64>(y_sort[N - 1] - y_sort[0]);
    for (int xi = 0; xi < N; ++xi) {
        for (int xj = xi + 1; xj < N; ++xj) {
            for (int yi = 0; yi < N; ++yi) {
                for (int yj = yi + 1; yj < N; ++yj) {
                    int n_contains = 0;

                    // 現在の長方形に含まれている点の個数を調べる
                    for (int i = 0; i < N; ++i) {
                        if (x_sort[xi] <= x[i] && x[i] <= x_sort[xj] && y_sort[yi] <= y[i] && y[i] <= y_sort[yj]) n_contains++;
                    }

                    if (K <= n_contains) ans = min(ans, static_cast<ui64>(x_sort[xj] - x_sort[xi]) * static_cast<ui64>(y_sort[yj] - y_sort[yi]));
                }
            }
        }
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#define Rint register int
#define LL long long
#define F(x,y,z) for(Rint x=y;x<=z;++x)
using namespace std;
inline LL R(){
    char c='!';LL x=0,z=1;
    for( ; c>'9'||c<'0';c=getchar()) if(c=='-')z=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
    return x*z;
}
int anss,n,m;
char s[100000];
int t1[10000],t2[10000];

int main(){
	n=R();
	scanf("%s",s+1);
	F(i,1,n){
		int ans=0;
		F(j,1,200) t1[j]=t2[j]=0;
		F(j,1,i) t1[s[j]]=1;
		F(j,i+1,n) t2[s[j]]=1;
		F(j,1,200) ans+=t1[j]&&t2[j];
		anss=max(anss,ans);
	}
	printf("%d\n",anss);
	return 0;
}



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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,k,c; cin >> n >> k >> c;
    string s; cin >> s;
    vi l(k, -1);
    vi r(k, -1);
    int pre = -c-1;
    int cur = 0;
    rep(i,n){
        if(i-pre >= c+1 && s[i] == 'o'){
            l[cur++] = i+1;
            pre = i;
        }
        if(cur == k) break;
    }
    pre = n+c;
    cur = 0;
    rrep(i,n){
        if(pre-i >= c+1 && s[i] == 'o'){
            r[k-1-cur++] = i+1;
            pre = i;
        }
        if(cur == k) break;
    }
    rep(i,k){
        if(l[i] == r[i]) cout << l[i] << endl;
    }
    return 0;
}

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

	while(true){

		int s1,s2;
		int max = 0,x = 0;

		cin >> s1 >> s2;

		if(s1 == 0 && s2 == 0)
			break;

		max = s1 + s2;
	
		for(int i=1 ;i<5 ;i++){

			cin >> s1 >> s2;

			if(max < (s1+s2)){
				max = s1 + s2;
				x = i;
			}
		}


		if(x==0)
			cout << 'A' << ' ' << max << endl;
		if(x==1)
			cout << 'B' << ' ' << max << endl;
		if(x==2)
			cout << 'C' << ' ' << max << endl;
		if(x==3)
			cout << 'D' << ' ' << max << endl;
		if(x==4)
			cout << 'E' << ' ' << max << endl;
		}
		return 0;
}

Measured memory_bytes: 0
/******************************************
* AUTHOR : Ashish Joshi* 
* INSTITUTION : NIT Hamirpur *
******************************************/
#include <bits/stdc++.h>
using namespace std;

#define N 100005
#define MOD 1000000007
#define PI 3.141592653589793

#define dd double
#define loop(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 fi first
#define se second
#define set(b,i) (b|(1<<i))
#define unset(b,i) (b&!(1<<i))
#define cbit(b,i) bool(b&(1<<i))

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;
ll w[100000],v[100000];
ll dp[100][100000];
ll n;
ll knap(ll i,ll cap)
{
	if(cap<0)
		return 0;
	if(i>=n)
		return 0;
	if(dp[i][cap]!=0)return dp[i][cap];
	if(cap>=w[i])
		dp[i][cap]= max(knap(i+1,cap-w[i])+v[i],knap(i+1,cap));
	else
		dp[i][cap]= knap(i+1,cap);
	return dp[i][cap];
}



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll W;
cin>>n>>W;
// ll w[n],v[n];
// memset(w,0,n*sizeof(w[0]));
// memset(v,0,n*sizeof(v[0]));
for(ll i=0LL;i<n;i++)
	cin>>w[i]>>v[i];
// for(int i=0;i<n;)
// dp[0]=
ll ans=knap(0,W);
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 76416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll a,b;cin>>a>>b;
    if(a%2==b%2){
        cout<<(a+b)/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    
    return 0;
}




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

#define INF (1<<30)

int main(){
	int n,m;	cin>>n>>m;
	priority_queue<int> PQ;
	for(int i=0; i<n; i++){
		int x;	cin>>x;
		PQ.push(x);
	}

	for(int i=0; i<m; i++){
		int M=PQ.top(); PQ.pop();
		M/=2;
		PQ.push(M);
	}

	long long ans=0;
	while(PQ.empty()==false){
		ans+=PQ.top();	PQ.pop();
	}
	cout<<ans<<endl;




	return 0;
}


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

long accumulate_possibility(string text, int& multi)
{
    if (text.size() == 0) {
        multi++;
        return 0;
    }

    long value = 0;
    for (int i = 0; i < text.size(); ++i) {
        string subText = text.substr(0, i + 1);
        string resText = text.substr(i + 1, text.size() - i);

        stringstream ss(subText);
        long tempValue;
        ss >> tempValue;

        int resMulti = 0;
        value += accumulate_possibility(resText, resMulti);
        value += tempValue * resMulti; 
        multi += resMulti;
    }

    return value;
}

int main() {
    string text;
    cin >> text;

    long ret = 0;
    int multi = 0;
    ret = accumulate_possibility(text, multi);

    cout << ret << endl;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr ll INF = numeric_limits<ll>::max()/2;
constexpr int MOD = 1e9+7;



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

    int n,m,r;cin>>n>>m>>r;
    vector<vector<ll>> dis(n,vector<ll>(n,1e9));
    for(int i=0;i<n;i++) dis[i][i]=0;
    vector<int> v(r);
    for(int i=0;i<r;i++){
        cin>>v[i];
        v[i]--;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;a--;b--;
        ll c;cin>>c;
        dis[a][b]=dis[b][a]=c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    ll res=1e15;
    do{
        ll tmp=0;
        for(int i=1;i<r;i++){
            tmp += dis[v[i-1]][v[i]];
        }
        //cout<<tmp<<endl;
        res=min(res,tmp);
    }while(next_permutation(v.begin(),v.end()));
    cout<<res<<endl;
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
 
using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"
 
int main() {
	int s, w;
	cin >> s >> w;
 
	cout << (w < s ? "safe" : "unsafe") << endl;
 
	return 0;
}

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

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

  int x = n;
  int answer = 0;
  for (int d = 2; d * d <= n; d++) {
    int cnt = 0;
    while(x % d == 0) {
      cnt++;
      x /= d;
    }
    int sub = 1;
    while(true) {
      cnt -= sub;
      if(cnt < 0) break;
      answer++;
      sub++;
    }
  }
  if(x > 1) answer++;
  cout << answer << '\n';
}

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

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

ll cnt;

void insertingSort(vector<ll>& A, int n, int g) {
    for(ll i = g; i < n; i++) {
        ll v = A.at(i);
        ll j = i - g;
        while( j >= 0 && A.at(j) > v) {
            A.at(j+g) = A.at(j);
            j-= g;
            cnt++;
        }
        A.at(j+g) = v;
    }
}

void shellSort(vector<ll>& A, int n) {
    stack<ll> d;
    for(ll i = 1; i <= n; i = i*3+1) {
        d.push(i);
    }
    cout << d.size() << endl;
    while(!d.empty()) {
        insertingSort(A, n, d.top());
        cout << d.top();
        d.pop();
        if(!d.empty()) cout << ' ';
    }
    cout << endl;
}

int main() {
    ll n; cin >> n;
    vector<ll> s(n);
    for(ll i = 0; i < n; i++) { cin >> s.at(i); }
    cnt = 0;
    shellSort(s, n);
    cout << cnt << endl;
    for (ll j = 0; j < n; j++) { cout << s.at(j) << endl; }
    return 0;
}



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

int extgcd(int a, int b, int c, int& x, int& y) {
    x = c / a; y = 0;
    if (b == 0) return a;
    int g = extgcd(b, a % b, c % b, y, x);
    y += -(a / b) * x + (c / b);
    return g;
}

pair<int, int> reverse(const pair<int, int>& p) { return make_pair(p.second, p.first); }

pair<int, int> solve(int a, int b, int d) {
    if (a < b) return reverse(solve(b, a, d));
    int x, y;
    int g = extgcd(a, b, d, x, y);
    a /= g; b /= g;
    auto comp = [&](int cx, int cy, int nx, int ny) {
        int cv = abs(cx) + abs(cy), nv = abs(nx) + abs(ny);
        return cv == nv ? a * abs(cx) + b * abs(cy) > a * abs(nx) + b * abs(ny) : cv > nv;
    };
    for (; comp(x, y, x + b, y - a); x += b, y -= a);
    for (; comp(x, y, x - b, y + a); x -= b, y += a);
    return make_pair(abs(x), abs(y));
}

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

int main() {
    for (int a, b, d; cin >> a >> b >> d, a | b | d;) cout << solve(a, b, d) << endl;
}

Measured memory_bytes: 3076
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
s = set([inp() for i in range(m)])
dp = [0] * (n+1)
dp[0] = 1
for i in range(n):
    if i+1 in s:
        dp[i+1] = 0
        continue
    if i == 0:
        dp[i+1] += dp[i]
    else:
        dp[i+1] += dp[i] + dp[i-1]
        dp[i+1] %= mod
print(dp[-1])

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

int main() {
  vector<int> V(3);
  cin >> V[0] >> V[1] >> V[2];
  sort(V.begin(), V.end());
  int ans, m;
  m=2*V[2]-V[0]-V[1];
  if (m%2==0) {
    ans = m/2;
  }
  else {
    ans = (m+3)/2;
  }
  cout << ans << endl;
}

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

int main(int argc, char const *argv[]) {
  ll a, b, c;std::cin >> a >> b >> c;
  set<ll> s;
  s.insert(a),s.insert(b),s.insert(c);
  std::cout << s.size() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a,b,n,i;
    scanf("%d%d",&a,&b);
         if(a<=9&&b<=9)
         n=a*10+b;
         if(a<=99&&a>9&&b<=9);
         n=a*10+b;
         if(a<=99&&a>9&&b>9&&b<=99)
          n=a*100+b;
         if(a<=9&&b>9&&b<=99)
         n=a*100+b;
         if(a<=9&&b==100)
         n=a*1000+b;
         if(a<=99&&a>9&&b==100)
         n=a*1000+b;
         if(a==100&&b==100)
            n=100*1000+100;
          if(a==100&&b<=9)
            n=a*10+b;
          if(a==100&&b<=99&&b>9)
            n=a*100+b;
            i=sqrt(n);
            if(i*i==n)
            printf("Yes\n");
            else
            printf("No\n");




    return 0;
}


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


using namespace std;

using ll = long long;

const ll INF = LONG_LONG_MAX / 2;


int main(void) {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> red, green, white;
    red.push_back(-1);
    for (ll i = 0; i < A; i++) {
        ll a;
        cin >> a;
        red.push_back(a);
    }
    green.push_back(-1);
    for (ll i = 0; i < B; i++) {
        ll b;
        cin >> b;
        green.push_back(b);
    }
    white.push_back(-1);
    for (ll i = 0; i < C; i++) {
        ll c;
        cin >> c;
        white.push_back(c);
    }

    sort(red.begin(), red.end());
    sort(green.begin(), green.end());
    sort(white.begin(), white.end());

    ll ans = 0;
    while (X > 0 || Y > 0) {
        ll ra, ga, wa;
        ra = *red.rbegin();
        ga = *green.rbegin();
        wa = *white.rbegin();

        if (ra > wa && X > 0) {
            ans += ra;
            X--;
            red.pop_back();
            continue;
        } else if (ga > wa && Y > 0) {
            ans += ga;
            Y--;
            green.pop_back();
            continue;
        }

        ll r_sacrifice, g_sacrifice;
        r_sacrifice = X > 0 ? *(red.rbegin() + X - 1) : INF;
        g_sacrifice = Y > 0 ? *(green.rbegin() + Y - 1) : INF;

        if (r_sacrifice > g_sacrifice) {
            // eat as green
            Y--;
        } else {
            // eat as red
            X--;
        }
        ans += wa;
        white.pop_back();
    }
    cout << ans << endl;
}


Measured memory_bytes: 6420
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    N = int(input())
    xy = []
    for i in range(N):
        x,y = map(int, input().split())
        xy.append([x, y, i])
    x_sort = sorted(xy, key=lambda x: x[0])
    y_sort = sorted(xy, key=lambda x: x[1])

    #[cost, 頂点1, 頂点2]
    cost = []
    for i in range(N-1):
        cost.append([x_sort[i+1][0]-x_sort[i][0], x_sort[i][2], x_sort[i+1][2]])
        cost.append([y_sort[i+1][1]-y_sort[i][1], y_sort[i][2], y_sort[i+1][2]])
    cost = sorted(cost, key=lambda x: x[0])

    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    
    def unite(x,y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x,y = y,x
            par[x] += par[y]
            par[y] = x
            return True
    
    def same(x,y):
        return find(x) == find(y)

    par = [-1]*N

    res = 0
    for c, v1, v2 in cost:
        if not same(v1, v2):
            unite(v1, v2)
            res += c
    print(res)


if __name__ == '__main__':
    main()

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

int main() {
  int x,a,b;
  a,b=0;
  cin>>x;
  while (500*a<=x)
  {
    a++;
  }
  while (5*b<=x-500*(a-1))
  {
      b++;
  }
  cout<<1000*(a-1)+5*(b-1)<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0;
long long dp[100][100];
long long find(long long x){
    while(x){
        if(x/10==0){
            return x;
        }
        x/=10;
    }
}
int main(){
    cin>>n;
    for(long long i=1;i<=n;i++){
        long long h=i;
        long long a1=h%10;
        long long a2=find(h);
        dp[a2][a1]++;
    }
    for(long long i=1;i<=9;i++){
        for(long long j=1;j<=9;j++){
            ans+=dp[i][j]*dp[j][i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256