akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	vector<pair<double, double>> xy;
	for (int i = 0; i < n; i++) {
		double x,y;
		cin >> x >> y;
		xy.push_back({x,y});
	}
	SORT(xy);
	double count = 0;
	double sum = 0;
	do {
		count++;
		for (int i = 0; i < n-1; i++) {
			sum += sqrt((double)pow(xy[i+1].first - xy[i].first,2) + (double)pow(xy[i+1].second - xy[i].second,2));
		}
	} while (next_permutation(ALL(xy)));
	double ave = sum / count;
	cout << ave << endl;
	return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll even[8]={2,10,3,9,4,8,6,12},odd[8]={6,2,10,3,9,4,8,12};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  if(n==3){
    std::cout<<"2 5 63";
    return 0;
  }

  rep(i,0,n)std::cout<<(i/8)*12+((n%2==0)?even[i%8]:odd[i%8])<<" ";



  return 0;
}


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

#define sc(a) scanf("%d",&a)
#define scm(a,b) scanf("%d%d",&a,&b)
#define fl(c,i,n) for(int i=c;i<n;i++)
#define f(i,n) for(int i=0;i<n;i++)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long int
#define ull unsigned long long int
#define inf INT_MAX
#define linf LLONG_MAX
#define pb push_back
#define pp pop_back()
#define aov(a) a.begin(),a.end()
//#define mp make_pair
#define nl printf("\n")
#define PI 2.0*acos(0.0) //#define PI acos(-1.0)
#define xx first
#define yy second
#define mxv(a) *max_element(aov(a))
#define mnv(a) *min_element(aov(a))
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
#define to_c_string(a) a.c_str()
#define strtoint(c) atoi(&c[0])
#define pii pair<int,int>
#define MAXN 100005
#define MOD 1000000007
 
template <class T> inline T bigmod(T p,T e,T M){
    ll ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
/*int fact[MAXN];
int invfact[MAXN];
int inv(int a, int b){
    if(b==0)
        return 1;
    if(b&1)
        return (long long)a*inv(a, b-1)%MOD;
    else{
        int res = inv(a, b>>1);
        return (long long)res*res%MOD;
    }
}
void init(){
    fact[0] = 1;
    for(int i=1;i<MAXN;i++){
        fact[i] = (long long)fact[i-1]*i%MOD;
    }
    invfact[MAXN-1] = inv(fact[MAXN-1], MOD-2);
    for(int i=MAXN-1;i>0;i--){
        invfact[i-1] = (long long)invfact[i]*i%MOD;
    }
}
int C(int n, int r){
    if(r>n || r<0)
        return 0;
    return (long long)((long long)fact[n]*invfact[r]%MOD)*invfact[n-r]%MOD;
}*/

int n, d, x, y;
void solve(){
    cin>>n>>d;
    ll d2 = (ll)d*d;
    int ans = 0;
    while(n--) {
        cin>>x>>y;
        ll x2y2 = (ll)x*x + (ll)y*y;
        ans += (x2y2<=d2);
    }
    cout<<ans;
}





int main(){
    /*FILE *fin = freopen("C-small-attempt0.in", "r", stdin);
    assert( fin!=NULL );
    FILE *fout = freopen("C-small.out", "w", stdout);*/
    //init();
    solve();
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;

int main(){
  int N;
  vector<int> L;

  priority_queue<int> que;

  cin >> N;
  fflush(stdout);
  L.resize(2*N);
  for(int i=0; i<2*N; ++i){
    cin >> L[i];
    que.push(L[i]);
  }
  fflush(stdout);

  int sum = 0;
  for(int i=0; i<N; ++i){
    int largeer = que.top();
    que.pop();
    int smaller = que.top();
    que.pop();
    sum += smaller;
  }

  cout << sum << endl;

  return 0;
}


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


int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, K, p[1000];
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    
    sort(p, p + N);
    
    int sum = 0;
    
    for (int i = 0; i < K; i++) {
        sum += p[i];
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3644
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import Counter
def main():
    n = int(readline())
    S = []
    for i in range(n):
        S.append(''.join(sorted(readline().rstrip().decode())))
    ans = 0
    for v in Counter(S).values():
        ans += v*(v-1)//2
    print(ans)
if __name__ == '__main__':
    main()


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

/*
int vistd[10004];
vector<int>a[10004];
vector<int>dis(10004,0);
void dfs(int k){
   if(vistd[k]==0){
    vistd[k]=1;
    for(int i=0;i<a[k].size();i++){
        if(!vistd[a[k][i]]){
/// to find the distance between each node and their children dis[a[k][i]]=dis[k]+1;
            dfs(a[k][i]);
        }
    }
   }

}
int freq[2004];
*/
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);

 int n,x,y,ans=0;
 cin>>n>>x>>y;
 if(x>=n){
    cout << y << endl;
 }
 else{
    int a=n/x;
  ans+=a*y;
  if(n%x!=0){
    ans+=y;
  }

cout << ans << endl;
 }








/*
   int t;
   cin>>t;
   int hh=t;
   vector<string>last,f;
   while(t--){
    string s,m;
  cin>>s>>m;
    int countchar=0;
    for(int i=0;i<m.length();i++){
        if ((int(m[i])>=65 && int(m[i])<=90) || (int(m[i])>=97 && int(m[i])<=122))
           countchar++;
    }
    string tmp1="";
    for(int i=0;i<s.length();i++){
        if((int(s[i])>=65 && int(s[i])<=90) || (int(s[i])>=97 && int(s[i])<=122)){
            tmp1+=s[i];
        }
    }
    string tmp2="";
     if(countchar>1){
            int ff=0;
        for(int i=0;i<m.length();i++){
        if((int(m[i])>=65 && int(m[i])<=90) || (int(m[i])>=97 && int(m[i])<=122)){
                if(!ff){
                    m[i]=toupper(m[i]);
                    ff=1;
                }
            tmp2+=m[i];
        }
        last.push_back(tmp2);
        f.push_back(tmp1);
    }
     }
     else{
            tmp1[0]=toupper(tmp1[0]);
        last.push_back(tmp1);
        string c="";
        for(int i=0;i<m.length();i++){
            if((int(m[i])>=65 && int(m[i])<=90) || (int(m[i])>=97 && int(m[i])<=122)){
                    m[i]=toupper(m[i]);
            c+=m[i];
            c+=".";
            break;
        }
        }
        f.push_back(c);
     }
       sort(last.begin(),last.end());

   }
  for(int i=0;i<hh;i++)
    cout << last[i] << endl;
    */
}






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

int main() {
  int H, R;
  cin >> H >> R;
  int ans;
  if (H+R==0) {
    ans=0;
  } else if (H>=0) {
    ans=1;
  } else if (H+R<0) {
    ans=-1;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

#define f first
#define s second
typedef pair<int, int> P;

int ID, rec[22];

void split(string s){
  stringstream ss(s);
  int i = 0;
  while(ss >> rec[i]) i++;
}

bool compare(const P x, const P y){
  if(x.f == y.f){
    return x.s < y.s;
  }
  return x.f > y.f;
} 

int main(){
  int n;
  while(cin >> n, n){
    vector<P> data;
    string s;

    for(int cs = 0 ; cs < n ; cs++){
      memset(rec, 0, sizeof(rec));
      cin >> ID;
      getline(cin, s);
      split(s);
      
      int res = 0, flame = 1;
      for(int i = 0 ; flame <= 10 ; flame++, i++){
	res += rec[i] + rec[i+1];
	if(flame > 9) res += rec[i+2];
	else if(rec[i] == 10) res += rec[i+2];
	else{
	  if(rec[i]+rec[i+1] == 10) res += rec[i+2];
	  i++;
	}
      }
      data.push_back(P(res, ID));
    }
    
    sort(data.begin(), data.end(), compare);
    for(int i = 0 ; i < n ; i++){
      cout << data[i].s << ' ' << data[i].f << endl;
    }
  }
  return 0;
}

      

Measured memory_bytes: 1228
// Bismillahirrahmanirrahim
// by Batrrr Tolkynbayev
#include <bits/stdc++.h>
// skripi krasava
#define respa return 0
#define all(x) x.begin(), x.end()
#define sz size
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 2e5 + 17, M = N << 2, mod = 1e9 + 7; 

int tt = 1, n, p[N];
string s;

void solve () {
	cin >> s;
	n = s.sz();
	s = s + '#';
	int ct = 0, ct_t = 0;
	for (int i = n; i >= 0; --i) {
		ct_t += (s[i] == 'T');	                 
		if (s[i] == 'S' && (s[i + 1] == 'T' || ct_t)) {
			// cout << i << ' ' << i + 1 << '\n';
			++ct;
			--ct_t;
		}
	}
	cout << n - (ct << 1);
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// cin >> tt;
	while (tt--) solve();
	respa;
}

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

using namespace std;

int sticks[10]={0,2,5,5,4,5,6,3,7,6};

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a[m],dp[n+3];
    for(int i=0;i<m;i++)
        scanf("%d",a+i);
    sort(a,a+m,greater<int>());
    fill(dp,dp+n+1,-10000000000);
    dp[0]=0;
    for(int i=0;i<m;i++)
    {
        for(int j=sticks[a[i]];j<=n;j++)
        dp[j]=max(dp[j],dp[j-sticks[a[i]]]+1);
    }

    while(n){

        for(int i=0;i<m;i++){
            if(n-sticks[a[i]]>=0&&dp[n]==dp[n-sticks[a[i]]]+1){
                printf("%d",a[i]);
                n-=sticks[a[i]];
                break;
            }
        }

    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    long double x, h;
    while(cin >> x >> h, x || h){
        cout << fixed << x * x + sqrt((x / 2) * (x / 2) + h * h) * x * 2 << endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
 
#define online_judge            freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio                    ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)               for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                      while
#define mp                      make_pair
#define le                      length()
#define endl                    "\n"
#define sf						scanf	
 
const ll m=1e9+7; 
 
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
ll lcm(ll a,ll b)
{ return (a*b)/__gcd(a,b); }
 
 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;    
 
    x = x % p;
   
    if (x == 0) return 0;
 
    while (y > 0)  
    {  
       
        if (y & 1)  
            res = (res*x) % p;  
 
       
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<m);
}  

ll powmod(ll n)
{
    ll ret = 1;
    ll a = 2;
    while (n > 0) {
        if (n & 1) ret = ret * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return ret;
}
 
ll modfact(ll n, ll p)
{
    if (n >= p)
        return 0;
 
    ll result = 1;
    for (int i = 1; i <= n; i++)
        result = (result * i) % p;
 
    return result;
}

///////////// TEMPLATE END /////////////////////////////////

 


void solve()
{    
	string s;
	cin>>s;
	
	ll sum=0;
	fr(i,s.le)
	{
		sum+=s[i]-'0';
	}
	
	if(sum%9==0)
	{
		cout<<"Yes"<<endl;
		
	}
	else
	{
		cout<<"No"<<endl;
	}
	
}



int main()
{
    fastio
   
//    int t;
//    cin>>t;
//    wh(t--)
    {
//        cout<<"Case "<<i<<":"<<endl;
        solve();
    }
   
    return 0;
}

Measured memory_bytes: 3760
#include<stdio.h>
#include<string.h>
int main()
{
    char v[105],c='x';
    int l,i,j;
    scanf("%s",v);
    l=strlen(v);
    for(i=0;i<l;i++)
    {
        v[i]=c;
    }
    printf("%s",v);
    return 0;
}


Measured memory_bytes: 128
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n, d := readInt(), readInt()
	x := make([][]int, n)

	for i, _ := range x {
		x[i] = make([]int, d)
		for ii, _ := range x[i] {
			x[i][ii] = readInt()
		}
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			dist := 0
			for k := 0; k < d; k++ {
				dist += abs(x[i][k]-x[j][k]) * abs(x[i][k]-x[j][k])
			}
			if check(dist) {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

func check(x int) bool {
	for i := 1; i*i <= x; i++ {
		if i*i == x {
			return true
		}
	}
	return false
}


Measured memory_bytes: 1784
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    long long t = 0;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        t += v[i];
    }
    t = ceil(t/(4.0*m));
    int ans = 0;
    for (auto e : v) {
        if (e >= t) ans++;
    }
    cout << (ans >= m ? "Yes" : "No") << '\n';
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long a, b;
const int MAXN = 1000010;
bool isPrime[MAXN];
int primes[MAXN];
int primeCnt = 0;
int coef[MAXN];
long long gcd(long long x, long long y)
{
	return x % y ? gcd(y, x % y) : y;
}
int main()
{
	cin >> a >> b;
	if (a < b) swap(a, b);
	long long g = gcd(a, b);
	long long range = sqrt(g) + 1;
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[1] = isPrime[0] = 0;
	for (long long i = 2; i <= range; i++)
	{
		if (isPrime[i]) primes[++primeCnt] = i;
		for (long long j = 1; j <= primeCnt && (i * primes[j] <= range); j++)
		{
			isPrime[i * primes[j]] = 0;
			if (!i % primes[j]) break;
		}
	}
	bool hasExtra = false;
	int i = 1;
	while (g > 1)
	{
		if (!(g % primes[i]))
		{
			g /= primes[i];
			coef[i]++;
		}else{
			i++;
			if (i > primeCnt)
			{
				hasExtra = true;
				break;
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i <= primeCnt; i++)
	{
		if (coef[i] > 0)
		{
			ans++;
		}
	}
	cout << ans + hasExtra + 1 << endl;
	return 0;
}

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

/**
 * mod int
 */
template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

/**
 * Counting
 */
template<class T> struct Counting {
    Counting(int64_t n) {
        _fact.assign(n+1, 1);
        for(int64_t i = 1; i <= n; i++)  _fact[i] = T(i) * _fact[i-1];
    }

    T fact(int64_t n) {
        assert(0 <= n && n < (int)_fact.size());
        return _fact[n];
    }

    T perm(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / fact(n-k);
    }

    T comb(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / (fact(k) * fact(n-k));
    }

    private:
        vector<T> _fact;
};

void leave(string message) {
    cout << message << endl;
    exit(0);
}

int main() {
    Counting<mint> cnt(3e6);

    lint x, y;
    cin >> x >> y;

    lint z = 2 * x - y;

    if(z % 3 != 0)  leave("0");
    lint b = z / 3;
    lint a = x - 2 * b;

    if(a < 0 || b < 0)  leave("0");

    cout << cnt.comb(a+b, a) << endl;
}

Measured memory_bytes: 23680
#include <iostream>
#include <cstdio>
#define MAXN 2000001
#define VMAX 10000
using namespace std;
int C[VMAX + 2];
int A[MAXN], B[MAXN];
void countingSort(int A[], int B[], int n){
	for (int i = 0; i <= VMAX; i++) {
		C[i] = 0;
	}
	for (int j = 1; j <= n; j++) {
		C[A[j]]++;
	}
	for (int i = 1; i <= VMAX; i++) {
		C[i] = C[i] + C[i-1];
	}
	for (int j = n; j >= 1; j--) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
}

int main(int argc, char *argv[]) {
	int n;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i+1]);
	}
	
	countingSort(A, B, n);
	for (int i = 1; i <= n; i++) {
		if (i > 1) {
			printf(" ");
		}
		printf("%d", B[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 18856
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<string>

using namespace std;

	vector < int > conn[100090];;;;;;;;;;;;;;;;;;;;;;
	bool bio[100090];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	int makswei[100090];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	void gothru(int node){
		
		bio[node] = true;
		
		for(int i = 0; i < conn[node].size(); i++){
			if(bio[conn[node][i]] == true) continue;
			gothru(conn[node][i]);
		}
		
		for(int i = 0; i < conn[node].size(); i++){
			makswei[node] = max(makswei[node],makswei[conn[node][i]] + 1);
		}
		
		return;
		
	}
	
int main(){
	memset(bio,false,sizeof bio);;;;;;;;;;;;;;;;;;;;;
	int n, m; cin >> n >> m;;;;;;;;;;;;;;;;;;;;;;;;;;
	for(int i = 0; i < m; i++){;;;;;;;;;;;;;;;;;;;;;;
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
		int x,y; cin >> x >> y;;;;;;;;;;;;;;;;;;;;;;;
		conn[x].push_back(y);;;;;;;;;;;;;;;;;;;;;;;;;
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	int sol = 0;
	for(int i = 1; i <= n; i++){
		if(bio[i] == false){
			bio[i] = true;
			gothru(i);
		}
		sol = max(makswei[i],sol);
		
	}cout << sol;
	
	// ZASTO DRZI TVRDNJA



	return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int aindex=0, bindex=0, cindex=0;
	char index = a[0];
	while (1) {
		if (index == 'a') {
			index = a[aindex];
			aindex++;
			if (aindex == a.size()+1) {
				cout << "A" << endl;
				return 0;
			}
		}
		else if (index == 'b') {
			index = b[bindex];
			bindex++;
			if (bindex == b.size()+1) {
				cout << "B" << endl;
				return 0;
			}
		}
		else if (index == 'c') {
			index = c[cindex];
			cindex++;
			if (cindex == c.size()+1) {
				cout << "C" << endl;
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 256
def main():
  while True:
    n, c = map(int, input().split())
    if n == 0:break
    music = []
    for _ in range(n):
      line = list(map(int, input().split()))
      add_panel = sum([2 ** i * line[i] for i in range(16)])
      music.append(add_panel)
    
    hand = []
    for _ in range(c):
      line = list(map(int, input().split()))
      erase_panel = sum([2 ** i * line[i] for i in range(16)])
      hand.append(erase_panel)

    masks = tuple([2 ** i for i in range(16)])
    move = [{} for _ in range(2 ** 16)]
    
    dp = [{} for _ in range(n + 1)]
    dp[0][0] = 0
    for turn in range(n):
      add_panel = music[turn]
      dp_next_turn = dp[turn + 1]
      used = {}
      for state, score in sorted(dp[turn].items(), key=lambda x:-x[1]):
        new_state = add_panel | state
        if new_state in used:continue
        used[new_state] = True
        move_new_state = move[new_state]
        for erase_panel in hand:
          if erase_panel in move_new_state:
            erased_state, add_score = move_new_state[erase_panel]
          else:
            add_score = 0
            temp = erase_panel & new_state
            for mask in masks:
              if mask > temp:break
              if temp & mask:
                add_score += 1
            erased_state = new_state & ~erase_panel
            move_new_state[erase_panel] = (erased_state, add_score)
          
          new_score = score + add_score
          if erased_state not in dp_next_turn or dp_next_turn[erased_state] < new_score:
            dp_next_turn[erased_state] = new_score
    
    print(max(dp[n].values()))

main()


Measured memory_bytes: 344460
use std::cmp::min;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s = s.trim_right().to_owned();
    let b :Vec<i32> = s.into_bytes().iter().map(|&x|{if x=='0' as u8{0}else{1}}).collect();

    let mut now = 0;
    let mut ans;
    let mut temp = 0;
    for &i in &b{
        if i != now {
            temp = temp+1;
        }
        now = 1-now;
    }
    ans = temp;

    temp = 0;
    now = 1;
    for &i in &b{
        if i != now {
            temp = temp+1;
        }
        now = 1-now;
    }

    ans = min(ans,temp);

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


Measured memory_bytes: 4352
a = gets.split(" ").map{|s| s.to_i}

r = a[4]
W = a[0] - r * 2
H = a[1] - r * 2
x = a[2] - r
y = a[3] - r

if (0 <= x) && (x <= W) && (0 <= y) && (y <= H)
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 8908
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int n; cin >> n;
VI a(n); rep(i, 0, n) cin >> a[i];

// O(n^2)
// VI dp(n, 1);
// rep(i, 0, n)
//     rep(j, 0, i)
//         if (a[j] < a[i]) 
//             dp[i] = max(dp[i], dp[j] + 1);
// cout << *max_element(ALL(dp)) << endl;

VI dp(n, INF);
rep(i, 0, n) 
    *lower_bound(ALL(dp), a[i]) = a[i];
cout << distance(dp.begin(), lower_bound(ALL(dp), INF)) << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり




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

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

    ll ans = n*n*n;
    cout<<ans;


}

int main()
{
    ll t=1;
   // cin>>t;

    while(t-->0)
        solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=0;
	cin >>n;
	int bef=n;
	bool prime=true;
	map<int,ll> cr;
	for(int i=2;i<=n;i++){
		prime=true;
		for(int c=2; c<=sqrt(i);c++){
			if ( prime and (i % c == 0))
			{
				prime=false;
		//		clog << i << " x " << c << endl;
			}
			
		}
	//	clog << i << " "<<prime<<endl;
		if(prime==true){
			
			bef=n;
			cr[i]+=0;
			while(bef){
				cr[i]+=bef/i;
				bef/=i;
			}
			//clog<<i<<" "<<cr[i]<<endl;
		}
	}
	ll dis[]={0,0,0,0,0};
	int border[]={74,24,14,4,2};

	int at=0;
	int disat=0;
	repi(itr,cr){
		while(disat < 5 and  (itr->S) < border[disat] ){
			//clog << ((itr->S) < border[disat]) <<endl;
			if ((itr->S) < border[disat])
			{
				dis[disat] = at ;
			//	clog << border[disat] << " " << dis[disat] << endl;
				disat++;
			}
		}
		at++;

	}
	ans+=dis[0];
	ans+=dis[1]*max(0LL,dis[4]-1);
	ans+=dis[2]*max(0LL,dis[3]-1);
	ans+=max(0LL,dis[4]-2)*(dis[3]*max(0LL,dis[3]-1)/2);
	cout<<ans<<endl;
	/*
	75 = 3 * 5*  5
	 = 1* 75 , 3*25 , 5* 15, 3*5 * 5; 
	*/
//32400 = 2*2*5*5 * 3 * *3*3 * 3* 2*2 
}

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

int main(){
  
  string a;
  cin >> a;
  
  sort(a.begin(), a.end());
  
  if( a.at(0) == a.at(1) && a.at(2) == a.at(3) && !(a.at(0) == a.at(2)) ){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}
  


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int a,b;
    cin>>a>>b;
    if((a>=1&&a<=9)&&(b>=1&&b<=9)) cout<<a*b<<endl;
    else cout<<-1<<endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N-1);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  for(int i=0;i<N-1;i++){
    cin >> C.at(i);
  }
  int n,m;
  int ans=0;
  n=A.at(0);
  ans+=B.at(n-1);
  m=n;
  for(int i=1;i<N;i++){
    n=A.at(i);
    ans+=B.at(n-1);
    if(n-m==1){
      ans+=C.at(m-1);
    }
    m=n;
  }
  cout << ans << endl;
  return 0;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input(), M = input();
    vector< int > X(M);
    cin >> X;
    whole(sort, X);

    vector< int > diff;
    range(i, 1, M) diff.emplace_back(X[i] - X[i - 1]);

    rwhole(sort, diff);

    int ans = X.back() - X.front();
    range(i, 0, min(N - 1, (int)diff.size())) {
        ans -= diff[i];
    }

    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 1276
n=int(input())
 
A=list(map(int,input().split()))
 
X=[0]*(n+1)
 
for i in range(n):
    X[A[i]]+=1
 
ans=0

for i in range(n+1):
    if X[i]>1:
        ans+=X[i]*(X[i]-1)//2      
for i in range(n):
    if X[A[i]]==1:
        print(ans)
    elif X[A[i]]>1:
        print(ans-(X[A[i]]-1))

Measured memory_bytes: 24748
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N;
	cin >> N;

	vll div(N + 1, 0);
	repn(i, N) {
		for (ll j = i; j <= N; j += i) { div[j]++; }
	}

	ll ans = 0;
	repn(i, N) ans += i * div[i];
	cout << ans << endl;
}

Measured memory_bytes: 81396
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const Long MOD = 1e9 + 7;
const int MX = 1e5;
Long fact[MX + 2];
Long fastPow(Long x, Long y) {
  Long ans = 1LL;
  Long cur = x;
  while (y) {
    if (y & 1) ans = ans * cur % MOD;
    cur = cur * cur % MOD;
    y >>= 1;
  }
  return ans;
}
Long inv(Long x) {
  return fastPow(x, MOD - 2);
}
Long cnk(Long x, Long y) {
  if (y > x) return 0LL;
  return fact[x] * inv(fact[y]) % MOD * inv(fact[x - y]) % MOD;
}
void init() {
  fact[0] = 1LL;
  fore(i, 1, MX) fact[i] = fact[i - 1] * i % MOD;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  init();
  Long n;
  cin >> n;
  Long ans = 0;
  fore(i, 0, n) {
    Long items = i + 1;
    if (items * 3 > n) break;
    ans += cnk(n - 3 * items + items - 1, items - 1);
    ans %= MOD;
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 4400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    bool ok = false;
    rep (i, (int)s.size()) if (s[i] == '7') ok = true;
    if (ok) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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



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

   ll sum =0;
   rep(i,n){
       while (a[i] % 2 == 0) { a[i] /= 2; sum++; }
   }
   cout << sum << endl;
      }

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

#define F first
#define S second

using ll = long long;

const int N = 1e5 + 5;
pair<ll, ll> arr[N];
int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> arr[i].F >> arr[i].S;
    }
    sort(arr, arr + n);
    ll ans = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (cnt + arr[i].S > m) {
            ans += (m - cnt) * arr[i].F;
            break;
        }
        ans += arr[i].F * arr[i].S;
        cnt += arr[i].S;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    map<string,int> arr;
    for (int i = 0; i < N; i++) 
    {
        cin >> S;
        arr[S]++;
    }


    cout << "AC x " << arr["AC"] << endl;  
    cout << "WA x " << arr["WA"] << endl;  
    cout << "TLE x " << arr["TLE"]<< endl;  
    cout << "RE x " << arr["RE"];  
    return 0;
}

Measured memory_bytes: 3612
N = int(input())
Al = list(map(int,input().split()))
sd = {}
for i,A in enumerate(Al):
    sd[str(i+1)] = A

ans_l = []
for key,value in sorted(sd.items(),key=lambda x:x[1]):
    ans_l.append(key)

print(" ".join(ans_l))





Measured memory_bytes: 85292
#include<iostream>
using namespace std;
int main(){
    long long a,b,k;
    cin>>a>>b>>k;
    if(a+b<k){
        a=0;
        b=0;
    }else if(a>k){
        a=a-k;
    }else{
        b=b-(k-a);
        a=0;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

int manh(int x1, int x2, int y1, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}

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

	int n, m;
	cin >> n >> m;

	vector<int> a(n), b(n);
	vector<int> c(m), d(m);

	rep(i, n) cin >> a[i] >> b[i];
	rep(i, m) cin >> c[i] >> d[i];

	rep(i, n) {
		int mi = INF;
		int idx = -1;
		rep(j, m) {
			int t = manh(a[i], c[j], b[i], d[j]);
			if(mi > t){
				mi = t;
				idx = j + 1;
			}
		}
		out(idx);
	}

	return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<std::string> w(n);
    for(int i = 0; i < n; i++){
        std::cin >> w[i];
    }
    
    bool ans = true;
    for(int i = 1; i < n; i++){
        if(w[i].front() != w[i - 1].back() || std::find(w.begin(), w.begin() + i, w[i]) != w.begin() + i){
            ans = false;
            break;
        }
    }
    
    std::cout << (ans ? "Yes" : "No") << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int A = in.nextInt() - 1;
            int B = in.nextInt() - 1;
            int C = in.nextInt() - 1;
            int D = in.nextInt() - 1;
            String S = in.next();
            boolean canSwap = false;
            for (int i = B; i <= D; i++) {
                if (i - 1 < 0 || i + 1 >= S.length()) {
                    continue;
                }
                if (S.charAt(i) == '#') {
                    continue;
                }
                if (S.charAt(i - 1) == '.' && S.charAt(i + 1) == '.') {
                    canSwap = true;
                }
            }
            boolean canGoal = true;
            for (int i = A + 1; i <= Math.max(C, D); i++) {
                if (i - 1 < 0) {
                    continue;
                }
                if (S.charAt(i - 1) == '#' && S.charAt(i) == '#') {
                    canGoal = false;
                }
            }
            System.out.println(!canGoal ? "No" : C < D ? "Yes" : canSwap ? "Yes" : "No");
        }
    }
}


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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	vector<pair<ll, int> > arr(n);
	for(auto &x : arr){
		cin>>x.first>>x.second;
	}
	sort(arr.begin(), arr.end());
	ll ans = 0;
	for(auto x : arr){
		ans += min(m, x.second)*x.first;
		m -= min(m, x.second);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main () {
    input! {
        a: i32,
        b: i32,
    }
    println!("{}", (a+b+1)/2);
}


Measured memory_bytes: 4352