akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAX (ll)(1e3 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	ll n;
	cin >> n;
	ll ar[n];
	for (ll i = 0; i < n; i++) {
		cin >> ar[i];
	}
	sort (ar, ar + n);
	ll ss = ar[n - 1], c = 0, r = n - 2, cur = n - 2;
	while (r > 0) {
		ss += ar[cur];
		cur -= c;
		c++;
		c %= 2;
		r--;
	}
	cout << ss << "\n";
}
		


Measured memory_bytes: 5196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] t = new int[n];
		int[] v = new int[n+1];
		for(int i=0;i<n;i++) {
			t[i] = in.nextInt();
		}
		for(int i=0;i<n;i++) {
			v[i] = in.nextInt();
		}
		int limitSpeed = 0;
		for(int i=n-1;i>=0;i--) {
			if(v[i]>limitSpeed+t[i]) {
				v[i] = limitSpeed+t[i];
				limitSpeed = limitSpeed+t[i];
			}else {
				limitSpeed = v[i];
			}
		}
		int maxSpeed = 0;
		for(int i=0;i<n;i++) {
			if(v[i]>maxSpeed+t[i]) {
				v[i] = maxSpeed+t[i];
				maxSpeed = maxSpeed+t[i];
			}else {
				maxSpeed = v[i];
			}
		}
		double ans = 0;
		int vnow = 0;
		for(int i=0;i<n;i++) {
			if(v[i]>=vnow+t[i] && (v[i+1]>=vnow+t[i])) {
				ans += (double)vnow*t[i] + (double)t[i]*t[i]/2;
				vnow += t[i];
			}else if(v[i]>=((double)t[i]+vnow+v[i+1])/2) {
				ans += ((double)t[i]+vnow+v[i+1])*t[i]/2 - ((double)t[i]-vnow+v[i+1])*((double)t[i]-vnow+v[i+1])/8 - ((double)t[i]+vnow-v[i+1])*((double)t[i]+vnow-v[i+1])/8;
				vnow = v[i+1];
			}else {
				ans += v[i]*t[i] - ((double)v[i]-vnow)*((double)v[i]-vnow)/2 - (v[i]>v[i+1]?((double)v[i]-v[i+1])*((double)v[i]-v[i+1])/2:0);
				vnow = Math.min(v[i], v[i+1]);
			}
		}
		System.out.println(ans);
		in.close();

	}

}


Measured memory_bytes: 23764
N = gets.to_i

ans = Hash.new(0) # 0で初期化したhash

1.upto Math.sqrt(N).floor do |x|
  1.upto Math.sqrt(N).floor do |y|
    1.upto Math.sqrt(N).floor do |z|
      pol = x*x + y*y + z*z + x*y + y*z + z*x
      # if pol > N
      #   next
      # end
      ans[pol] += 1
    end
  end
end

N.times do |i|
  puts ans[i+1]
end



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

int n, k;

int main()
{
	cin >> n >> k;
	int d[k + 1];
	int a[k + 1][n + 1];
	bool f[n + 1][k + 1];
	memset(d, 0, sizeof(d));
	memset(a, 0, sizeof(a));
	memset(f, false, sizeof(f));
	for(int i = 1; i <= k; i++)
	{
		cin >> d[i];
		for(int j = 1; j <= d[i]; j++) 
		{
			cin >> a[i][j];
			f[a[i][j]][i] = true;
		}
	}
	
	bool ok = false;
	int t = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= k; j++) if(f[i][j]) ok = true;
		if(!ok) t++;
		ok = false;
	}
	
	cout << t;
	
//	system("pause");
	return 0;
}

Measured memory_bytes: 3640
/* なぞなぞ
 
 
 　　ケーキ屋さんが、毎月２２日を　「ショートケーキの日」としています。
 　　なぜ２２日なのでしょうか？
 
*/





/* わたしのプログラムみても何も良い事ないですよ？　*/
/* すっごくさむい。トランプしたいな。おこめたべたい　*/

#include<stdio.h>
#include<string.h>

#define M 999997/* ちがうきがする　*/
#define L 14

char H[M][L]; /* hashed potato */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value *//* 整数形に変えてくれるのね */
/*どういう計算しているのかわけわからないっす*//*だからできないのか*/
long long getKey(char str[]){  /* long2つかかれても*/
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
    return key%M;//ジョナサン
}
int h2(int key){
    return key%(M-1)+1;
}



int find(char str[]){
    int i=0,j;
    long long sum;
    sum=getKey(str);
        while(1){
        
            j=(h1(sum)+i*h2(sum))%M;
        
            if(H[j][0] =='\0' || i == M )return 0;
        
            if( strcmp(H[j],str)==0 )return 1;
            
            else i=i+1;
        
        
    }
}
/*来週のアルゴのソースでまた会いましょう
 ソーっスか。*/
void insert(char str[]){
    int i=0,j;
    long long sum;
    
    sum=getKey(str);
    while(i != M){
        j=(h1(sum)+i*h2(sum))%M; //例のあれ
        if (H[j][0] == '\0'){
            strcpy(H[j],str);
            break;
            }
        else {
            i=i+1;
        }
        
    }
    

}

int main(int argc ,char *argv[]){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){/* 1が戻ってくれば良いんだね！ */
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

/* ＾＾ */

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

int main(void) {
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s < t) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef vector <int> VI;
typedef pair <int, int> NODE;
typedef priority_queue <NODE, vector <NODE>, greater <NODE> > QUEUE;
typedef pair <int, int> PII;
typedef vector <PII> VPII;

const int size = 3001;
int P[size][size];
int PC[size];
int L[size][size];
const int inf = INT_MAX;

void init() {
    for ( int i = 0; i < size; ++ i ) {
        PC[i] = 0;
    }
}

int main() {
    int n, m, k;
    while ( cin >> n >> m >> k ) {
        VPII R;
        for ( int i = 0; i < m; ++ i ) {
            int a, b, l; // a-b: l
            cin >> a >> b >> l;
            a --;
            b --;
            P[a][PC[a]++] = b;
            P[b][PC[b]++] = a;
            L[a][b] = L[b][a] = l;
            R.push_back( PII( a, b ) );
        }
        VI starts;
        QUEUE Q;
        VI D( n, inf );
        for ( int i = 0; i < k; ++ i ) {
            int a;
            cin >> a;
            a --;
            starts.push_back( a );
            Q.push( NODE( 0, a ) );
        }

        bool used[size];
        for ( int i = 0; i < size; ++ i ) used[i] = false;
        while ( ! Q.empty() ) {
            NODE node = Q.top();
            Q.pop();

            int cost = node.first;
            int src = node.second;

            if ( used[src] ) continue;
            used[src] = true;
            D[src] = cost;
            for ( int i = 0; i < PC[src]; ++ i ) {
                int dst = P[src][i];
                int ncost = cost + L[src][dst];
                Q.push( PII( ncost, dst ) );
            }
        }

        int answer = 0;
        for ( int i = 0; i <(int)R.size(); ++ i ) {
            int src = R[i].first;
            int dst = R[i].second;
            answer = max( answer, ( D[src] + D[dst] + L[src][dst] + 1 ) / 2 );
        }

        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 0
N = int(input())
L = list(map(int, input().split()))
ans = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            maxint = max(L[i],  L[j],  L[k])
            sumint = L[i] + L[j] + L[k]
            if sumint > 2 * maxint:
                if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] :
                    ans += 1

print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    // ll N,S,K;
    // ll a,b,c;
    // cin >> a >>b >>c;
    string s,t;
    cin >> s;
    cin >> t;


    ll ans=0;
    
    for (ll i = 0; i < 3; i++)
    {
      if (s[i]==t[i]) ans++;
    }
    


  cout << ans;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int cnt[maxn];
int main(){
  //freopen("aa.in","r",stdin);
  int n,k;scanf("%d%d",&n,&k);
  for(int i=1;i<=n;i++)cnt[i%k]++;
  long long ans=1LL*cnt[0]*cnt[0]*cnt[0];
  if(k%2==0){
    ans+=1LL*cnt[k/2]*cnt[k/2]*cnt[k/2];
  }
  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 640
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////


//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  

  lin(X);
  if(X >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
 
int main(){
 ll n ;cin>> n;
 vector<ll> A(n) ;
 rep(i,n) cin>>A[i] ;
 ll a=-1 ;ll b=-1 ;ll c=-1 ;
 mint ans=1 ;
 rep(i,n){
   mint cnt=0 ;
   if(a+1==A[i]) cnt+=1 ;
   if(b+1==A[i]) cnt+=1 ;
   if(c+1==A[i]) cnt+=1 ;
   
   if(a+1==A[i]) a++ ;
   else if(b+1==A[i]) b++ ;
   else if(c+1==A[i]) c++ ;
   ans*=cnt ;
 }
    cout<<ans<<endl ;
    return 0;
  }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int mo = 2019;
  int N = S.size();
  vector<int>A(N);
  string nu = "0123456789";
  for (int i = 0; i < N; i ++) {
    for (int j = 1; j < 10; j ++) {
      if (S[i] == nu[j]) {
        A[i] = j;
      }
    }
  }
  int dp[2019];
  for (int i = 0; i < 2019; i ++) dp[i] = 0;
  dp[0] = 1;
  int now = 0;
  int key = 1;
  for (int i = N - 1; i >= 0; i --) {
    now += A[i] * key;
    now %= mo;
    key *= 10;
    key %= mo;
    //cout << now << endl;
    dp[now] ++;
  }
  int ans = 0;
  for (int i = 2018; i >= 0; i --) {
    int k = dp[i] * (dp[i] - 1);
    k /= 2;
    ans += k;
  }
  cout << ans << endl;
}



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

const int inf = 1e4;

vector< vector<int> > dp(50,vector<int>(50,inf));

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

int main(){

	int h,w;
	cin>>h>>w;
	string s[h];
	for(int i = 0;i < h;i++){
		cin>>s[i];
	}

	dp[0][0] = 0;

	for(int l = 1;l<=h*w;l++){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			for(int k = 0;k<4;k++){
				int x = i+dx[k],y=j+dy[k];
				if(x<0 || y<0 || x>=h || y>=w) continue;
				if(s[x][y]=='#' || s[i][j] == '#') continue;
				dp[x][y] = min(dp[x][y],dp[i][j]+1);
				//cout<<x<<" "<<y<<endl;
				//return 0;
			}
		}
	}
}

	// for(int i = 0;i<h;i++){
	// 	for(int j = 0;j<w;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }	

	int bl = 0;
	for(int i = 0;i < h;i++){
		for(int j = 0;j<w;j++){
			if(s[i][j]=='#') bl++;
		}
	}

	if(dp[h-1][w-1]>=inf) cout<<-1;
	else cout<<(h*w)-1-dp[h-1][w-1]-bl;

}

Measured memory_bytes: 256
import sys
import math
# from itertools import permutations
input = sys.stdin.readline

N=int(input())

arr=list(map(int,input().split()))

s=sum(arr)
t=0
minn=abs(s-t)
for i in range(1,N):
	s-=arr[i-1]
	t+=arr[i-1]
	minn=min(minn,abs(s-t))

print(minn)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[303030];
ll B[303030];
ll S[2];
int ok(ll v) {
	int i;
	FOR(i,N) B[i]=A[i];
	for(int cur=N-1;cur>0;cur-=2) if(B[cur]<v || B[cur-1]<B[cur]) B[cur-2]+=B[cur]-B[cur-1];
	return B[0]>=v;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		S[i%2]+=A[i];
	}
	if(N%2==0) {
		cout<<max(S[0],S[1])<<" "<<min(S[0],S[1])<<endl;
		return;
	}
	
	ll Z=-1LL<<40;
	for(i=40;i>=0;i--) if(ok(Z+(1LL<<i))) Z+=1LL<<i;
	
	cout<<(S[1]+Z)<<" "<<(S[0]-Z)<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc095/tasks/abc095_b

int main() {
    int N, X;
    cin >> N >> X;

    int sum=0;
    int min=INF;
    int m;
    for (int i = 0; i < N; i++) {
        cin >> m;
        sum+=m;
        min = std::min(min, m);
    }

    int n = (X - sum) / min;

    cout << n + N << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;

struct Node{
	Node(){
		brother = parent = -1;
		height = depth = num_of_children = 0;
	}
	int parent,brother,depth,num_of_children,height;
	vector<int> children;
};

void calcDepth(Node nodes[],int root_id){
	for(int i = 0;i < nodes[root_id].num_of_children;i++){
		nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
		calcDepth(nodes,nodes[root_id].children[i]);
	}
}

void calcHeight(Node nodes[],int height,int parent){
	nodes[parent].height = max(nodes[parent].height,height+1);
	if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}

int main(){
	int n,id,left_id,right_id,root_id;
	scanf("%d",&n);
	Node nodes[n];

	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left_id,&right_id);
		if(left_id != -1){
			nodes[id].children.push_back(left_id);
			nodes[id].num_of_children++;
			nodes[left_id].parent = id;
		}
		if(right_id != -1){
			nodes[id].children.push_back(right_id);
			nodes[id].num_of_children++;
			nodes[right_id].parent = id;
		}
		if(left_id != -1 && right_id != -1){
			nodes[left_id].brother = right_id;
			nodes[right_id].brother = left_id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(nodes[root_id].parent == -1) break;
	}

	if(n > 1){
		calcDepth(nodes,root_id);

		for(int i = 0; i < n; i++){
			if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
		}
	}

	for(int i = 0; i < n; i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
				,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
		if(nodes[i].parent == -1){
			printf(" root\n");
		}else if(nodes[i].num_of_children == 0){
			printf(" leaf\n");
		}else{
			printf(" internal node\n");
		}

	}
}


Measured memory_bytes: 2780
#include <stdio.h>
int main(){
  long x, z, y=0;
  
  scanf("%ld",&x);
  z=x;
 
  y+=(z/11)*2;
  z=z%11;
  
  if(7<=z){
    y+=2;
  } else if(1<=z && z<7) {
    y+=1;
  }
  
  printf("%ld",y);
}

Measured memory_bytes: 1708
from functools import lru_cache
# 上がうまく使えない場合、以下を使う(僕はうまくいかなかったのでこっちを使った)
# from functools32 import lru_cache 

k = int(input())

@lru_cache(maxsize=None)
def check(num, keta):
  if keta == 1:
    return 1
  l = [i for i in range(10) if abs(num-i) <= 1]
  result = 0
  for i in l:
    result += check(i, keta-1)
  return result

s = ''
n = 10
keta = 2
f = True

if k <= 9:
  print(k)
else:
  checker = 9
  while f:
    for i in range(1, 10):
      pre_checker = checker
      checker += check(i, keta)
      if checker >= k:
        n = i
        s += str(i)
        keta -= 2
        checker = pre_checker
        f = False
        break
    keta += 1
    
  while keta != 0:
    l = [i for i in range(10) if abs(n-i) <= 1 ]
    for i in l:
      pre_checker = checker
      checker += check(i, keta)
      if checker >= k:
        keta -= 1
        s += str(i)
        n = i
        checker = pre_checker
        break
  
print(s)

Measured memory_bytes: 3828
object Main extends App {
  var list = Seq[Int](1)
  (2 to 999).foreach { i =>
    list :+= (i + list.last)
  }

  val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  var i: Int = 1

  while (true) {
    val x = list.indexWhere(_ == a + i)
    if (x != -1) {
      if (list(x + 1) == b + i) {
        println(i)
        System.exit(0)
      }
    }

    i = i + 1
  }
}


Measured memory_bytes: 35272
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int		main(void)
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x + r <= W && x - r >= 0 &&\
			y + r <= H && y - r >= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return (0);
}



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

int main(){
    string S;
    cin >> S;
    int cnt = 0;
    for(int i = 0;i < 4; i++){
        if(S[i] == '+'){
            cnt++;
        }
        else if(S[i] == '-'){
            cnt--;
        }
    }
    cout << cnt << endl;
}

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

typedef long long ll;

const int MAXV = 100;
const ll INF = (1LL<<60);

int V, E;
ll adjMat[MAXV][MAXV];

int main(){

    scanf("%d%d",&V,&E);
    for (int i = 0; i < V; i++)
        for(int j = 0; j < V; j++)
            adjMat[i][j] = INF;

    for (int i = 0, s, t, d; i < E; i++) {
        scanf("%d%d%d",&s,&t,&d);
        
        adjMat[s][t] = d;
    }

    for (int k = 0; k < V; k++)
        for (int i = 0; i < V; i++)
            for (int j = 0;j < V; j++)
                if (adjMat[i][k] != INF && adjMat[k][j] != INF)
                    adjMat[i][j] = min(adjMat[i][j],adjMat[i][k]+adjMat[k][j]);

    for (int i = 0; i < V; i++) {
        if (adjMat[i][i] < 0) {
            printf("NEGATIVE CYCLE\n");

            return 0;
        }
    }

    for (int i = 0; i < V; i++){
        for (int j = 0; j < V; j++){
            if (j)
                printf(" ");
            if (i == j)
                printf("0");
            else if (adjMat[i][j] >= INF)
                printf("INF");
            else
                printf("%lld",adjMat[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1272
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    cout << 800 * n - ( n / 15 ) * 200 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    for(int i = 0; i < 3; i++){
        if(n[i] == '1'){
            n[i] = '9';
        }
        else if(n[i] == '9'){
            n[i] = '1';
        }
    }

    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7;

int main() {
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(1) << (double)W*H/2 << ' ';
  if(x*2==W&&y*2==H) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3748
from collections import Counter
n=input()
A=map(int,raw_input().split())

M0=[]
M1=[]

for i in range(n):
	if i%2==0: M0.append(A[i])
	else: M1.append(A[i])

C0=Counter(M0)
C1=Counter(M1)

L0=sorted(C0.items(), key=lambda x:x[1], reverse=True)
L1=sorted(C1.items(), key=lambda x:x[1], reverse=True)

a0=None
a1=None

if L0[0][0]!=L1[0][0]:
	a0=L0[0][0]
	a1=L1[0][0]
	b0=L0[0][0]
	b1=L1[0][0]
elif L0[0][0]==L1[0][0]:
	a0=L0[0][0]
	if len(L1)==1:
		a1=-1
	else:
		a1=L1[1][0]

	b1=L1[0][0]
	if len(L0)==1:
		b0=-1
	else:
		b0=L0[1][0]

ans0=0
ans1=0
for x in M0:
	if x!=a0:
		ans0+=1

for x in M1:
	if x!=a1:
		ans0+=1

ans1=0
for x in M0:
	if x!=b0:
		ans1+=1

for x in M1:
	if x!=b1:
		ans1+=1

print min(ans0, ans1)

	

Measured memory_bytes: 59760
A, B, Q = map(int, input().split())
INF = 10 ** 18
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]


def binary_search(q, A):
    l, r = 0, len(A)
    while r - l > 1:
        mid = (l + r) // 2
        if q > A[mid]:
            l = mid
        else:
            r = mid
    return A[l], A[r]


def main():
    for x in X:
        s1, s2 = binary_search(x, S)
        t1, t2 = binary_search(x, T)
        print(min(abs(s-t) + min(abs(s-x), abs(t-x)) for s in [s1, s2] for t in [t1, t2]))
    return

if __name__ == '__main__':
    main()


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



int main(void)
{
    int a,b;
    cin >> a >> b;

    if (a == b) {
        cout << a * 2 << endl;
    } else if (a > b) {
        cout << a * 2 -1 << endl;
    } else {
        cout << b * 2 -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */



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

    int n; cin >> n;
    string s; cin >> s;
    s = '0'+s;

    vector<vector<ll>> dp(3030, vector<ll>(3030, 0));

    rep(j, n) dp[1][j]=1;
    repr(i, 2, n+1){
        vector<ll> cum(n+5, 0);
        cum[0]=dp[i-1][0];
        repr(j, 1, n+1) { cum[j]=dp[i-1][j]+cum[j-1]; chmod(cum[j]); }
        if(s[i-1]=='<'){
            rep(j, n-i+1){
                dp[i][j] = cum[n]-cum[j];
                chmod(dp[i][j]);
            }
        }
        else{
            rep(j, n-i+1){
                dp[i][j] = cum[j];
                chmod(dp[i][j]);
            }
        }
    }

    cout << dp[n][0] << endl;

    return 0;
}


Measured memory_bytes: 72192
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define M 5005
#define rint register int
int n,m,p;
int a,b,c;
__int128 Dis[M];
struct Edge {
	int to,v;
};
bool inQ[M];
int cntTo[M];
vector<Edge>E[M];
vector<int>e[M];
queue<int>Q;
bool Mark[M];
void dfs(int x) {
	Mark[x]=1;
	for(int i=0; i<(int)e[x].size(); ++i)
		if(!Mark[e[x][i]])dfs(e[x][i]);
}
void Print(__int128 x) {
	if(x==0)return;
	Print(x/10);
	putchar((x%10)^48);
}
int main() {
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1; i<=m; ++i) {
		scanf("%d%d%d",&a,&b,&c);
		E[a].push_back((Edge)<%b,c-p%>);
		e[b].push_back(a);
	}
	dfs(n);
	for(int i=2; i<=n; ++i)Dis[i]=-1e28;
	Q.push(1);
	bool flag=1;
	while(!Q.empty()) {
		int x=Q.front();
		Q.pop();
		if(++cntTo[x]==n+20) {
			flag=0;
			break;
		}
		inQ[x]=0;
		for(int i=0; i<(int)E[x].size(); ++i) {
			int u=E[x][i].to,v=E[x][i].v;
			if(!Mark[u])continue;
			if(Dis[u]<Dis[x]+v) {
				Dis[u]=Dis[x]+v;
				if(!inQ[u])Q.push(u);
			}
		}
	}
	if(!flag)puts("-1");
	else {
		if(Dis[n]<=0)putchar('0');
		else Print(Dis[n]);
	}
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int a;
	cin >> a;

	cout << a + a * a + a * a * a;
	return 0;
}

Measured memory_bytes: 3632
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n = S()
s = n[len(n)-1]

if(s == '3'):
    print('bon')
elif(s == '0' or s == '1' or s == '6' or s == '8'):
    print('pon')
else:
    print('hon')

Measured memory_bytes: 9132
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(void){
    int n;
    int num,d2,sum=0;
    vector<int> v;
    double d=0,a,b;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>num;
        v.push_back(num);
        d+=num;
    }
    d/=n;
    a = modf(d, &b);
    if(a>=0.5)d2=b+1;
    else d2=b;
    
    for(int i=0;i<n;i++){
        sum+=pow(abs(v[i]-d2),2);
    }
    cout<<sum;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		int count = 0;
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty())
				break;

			String newLine = new StringBuilder(line).reverse().toString();
			if (line.equals(newLine)) {
				count++;
			}
		}
		System.out.println(count);
	}

}

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

int main(){
  string s;
  cin >> s;
  if( s.size()%2 != 0 ){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0;i<s.size()-1;i++){
    if( s.at(i) == 'h' && s.at(i+1) == 'i' ){
      i++;
      continue;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  long N, x = 0, y = 0;
  cin >> N;
  string s = to_string(N), ans = "No";
  x = s.size();
  
  for (int i = 0; i < x; i++) {
    if (s[i] == '1') y += 1; 
    if (s[i] == '2') y += 2; 
    if (s[i] == '3') y += 3; 
    if (s[i] == '4') y += 4; 
    if (s[i] == '5') y += 5; 
    if (s[i] == '6') y += 6; 
    if (s[i] == '7') y += 7; 
    if (s[i] == '8') y += 8; 
    if (s[i] == '9') y += 9; 
  }
  
  if (N%y == 0) ans = "Yes";
  
  cout << ans << endl;
}

Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
const double EPS = 1e-10;
struct Vec2 {
  double x;
  double y;

  Vec2() : x(0.0),y(0.0){} 
  Vec2(double _x,double _y) :x(_x),y(_y){}  
  
  Vec2 operator+(const Vec2& other) const { return { x + other.x , y + other.y }; }
  Vec2 operator-(const Vec2& other) const { return { x - other.x , y - other.y }; }

  double dot(const Vec2& other) const { return x * other.x + y * other.y; }
  double cross(const Vec2& other) const { return x * other.y - y * other.x; }
  double length() const { return sqrt(x * x + y * y); }
};

// cosθを返す。A とB のなす角θ
double Cos(const Vec2 A, const Vec2 B) {
  return A.dot(B) / (A.length()*B.length());
}

double Sin(const Vec2 A, const Vec2 B) {
  return A.cross(B) / (A.length()*B.length());
}

int main()
{
  double p0x,p0y,p1x,p1y; cin >> p0x >> p0y >> p1x >> p1y;
  int q; cin >> q;
  vector<double> p2x(q),p2y(q);
  rep(i,q) cin >> p2x[i] >> p2y[i];
  Vec2 A(p1x - p0x, p1y - p0y);
  
  rep(i,q) {
    Vec2 B(p2x[i] - p0x, p2y[i] - p0y);
    if(abs(B.length()) < EPS) {
      cout << "ON_SEGMENT" << "\n";
      continue;
    }
    double sine = Sin(A, B);
    if(abs(sine) < EPS) {
      double cosi = Cos(A, B);
      if(cosi < 0) {
	cout << "ONLINE_BACK" << "\n";
      }
      else {
	if(A.length() + EPS < B.length()) cout << "ONLINE_FRONT" << "\n";
	else cout << "ON_SEGMENT" << "\n";
      }
    }
    else if(sine > 0) {
      cout << "COUNTER_CLOCKWISE" << "\n";
    }
    else if(sine < 0) {
      cout << "CLOCKWISE" << "\n";
    }
  }
  
  return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
#define M 200005

using namespace std;

int ar[300005];
map<int,int>mp,mp2;
bool vis[300005];
vector<int>v[300005];
int main()
{

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


    int h,w,m;
    cin >> h >> w >> m;

    pair<int,int>p[m+3];
    for(int i=1;i<=m;i++)
    {
        cin >> p[i].f >> p[i].ss ;
        mp[p[i].f]++;
        mp2[p[i].ss]++;
    }
    int ans = 0;
    int mx = 0;
    for(auto it:mp)
        mx = max(it.ss,mx);
    vector<int>v1;

    for(auto it:mp)
    {
        if(it.ss==mx)
            v1.pb(it.f);
    }
    ans += mx;

     mx = 0;
    for(auto it:mp2)
        mx = max(it.ss,mx);
    vector<int>v2;

    for(auto it:mp2)
    {
        if(it.ss==mx)
        {
            v2.pb(it.f);
        vis[it.f] = true;
        }
    }
    ans += mx;

    for(int i=1;i<=m;i++)
    {
        if(vis[p[i].ss]==true)
        {
          //  cout << "C " << p[i].f << " " << p[i].ss << endl;
            v[p[i].f].pb(1);
        }
    }
    int f=0;
    for(int i=0;i<v1.size();i++)
    {
    //    cout << v1[i] << " "  <<  v[v1[i]].size() << "sc " << endl;
        if(v[v1[i]].size()!=v2.size())
        {
            f=1;
            break;
        }
    }
    if(!f && ans) ans--;
  //  cout << v1.size() << endl << v2.size() << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 52620
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,k;
  cin >> n >> k;
  vector<ll> p(n),cnt(n+1);
  for(ll i = 0; i < n; ++i) cin >> p[i];
  for(ll i = 1; i < n; ++i){
    if(p[i] > p[i-1]) cnt[i-1] = 1;
  }
  vector<ll> psum(n+1);
  if(k >= 3){
    for(ll i = 0; i < k-2; ++i) psum[0] += cnt[i];
    for(ll i = 1; i+k-3 < n; ++i) psum[i] = psum[i-1]+cnt[i+k-3]-cnt[i-1];
  }
  set<ll> q;
  for(ll i = 0; i < k-1; ++i) q.insert(p[i]);
  ll ans = 0,more = 0;
  for(ll i = 0; i+k < n; ++i){
    q.insert(p[i+k-1]);
    if(i > 0) q.erase(p[i-1]);
    ll small = *begin(q);
    auto it = end(q);
    --it;
    ll big = *it;
    if(small != p[i]){
      ++ans;
      //cout << "i " << i << " ans " << ans << endl;
    }
    else if(big > p[i+k]){
      if(k >= 3){
        if(psum[i+1] < k-2){
          ++ans;
          //cout << "i " << i << " ans " << ans << endl;
        }
        else more = 1;
      }
      else more = 1;
    }
  }
  q.insert(p[n-1]);
  if(n > k) q.erase(p[n-k-1]);
  vector<ll> test;
  test.assign(begin(q),end(q));
  ll more2 = 1;
  for(ll i = 0; i < k; ++i){
    if(test[i] != p[n-k+i]){
      ++ans;
      more2 = 0;
      break;
    }
  }
  cout << ans+max(more,more2);
  return 0;
}

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

using namespace std;

long long n;

int solve(int x)
{
    int s=0,i=0;
    while (s<=x)
    {
        i++;
        s+=i;
    }
    return i-1;
}

void process()
{
    int kq=0;
    int dem=0;
    while (n%2==0)
    {
        dem++;
        n/=2;
    }
    kq+=solve(dem);
    for (long long i=3;i*i<=n;i+=2)
    {
        dem=0;
        while (n%i==0)
        {
            dem++;
            n/=i;
        }
        kq+=solve(dem);
    }
    if (n>2) kq++;
    cout<<kq;
}

int main()
{
    scanf("%lld",&n);
    process();
    return 0;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n; cin >> n;
    ll cn = n;
    ll ans = 0;
    while(n > 0){
        ans += n % 10;
        n /= 10;
    }
    if(cn % ans == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef string s;
typedef vector
 vs;

void p(vs &v)
{
	for (s &x: v)
		cout << (&x == &v[0] ? "" : " ") << x;
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	vs bs(n), ss(n);
	for (s &x: bs)
		cin >> x;
	ss = bs;

	auto cmp = [](s a, s b){return a[1] < b[1];};
	stable_sort(bs.begin(), bs.end(), cmp);
	p(bs);
	cout << "Stable" << endl;

	for (auto i = ss.begin(), e = ss.end(); i != e - 1; i++) {
		auto min = min_element(i ,e, cmp);
		if (i != min)
			swap(*i, *min);
	}
	p(ss);
	cout << (bs == ss ? "Stable" : "Not stable") << endl;
}


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

int main(){
    int N;
    cin >> N;
    int c = 1;
    int ans;
    while (true) {
        if (N <= c * 2 - 1) {
            ans = c;
            break;
        }
        else {
            c *= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

void solve(int n, vector<int> &as) {
  int cnt = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int j = n - 1; j > 0; --j) {
      if (as[j] < as[j - 1]) {
        swap(as[j], as[j-1]);
        ++cnt;
        flag = true;
      }
    }
  }
  bool fst = true;
  for (auto &&a: as) {
    cout << (fst? "":" ") << a;
    fst = false;
  }
  cout << "\n" << cnt << "\n";
}

int main() {
  // cout << fixed << setprecision(10);

  int N; cin >> N;
  vector<int> as;
  REP(i, N) {
    int A;
    cin >> A;
    as.push_back(A);
  }
  solve(N, as);
  return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll a[n-1]={0};
	ll mp[n+1]={0};
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<mp[i]<<'\n';
	}


}

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

int main(int argc, char const *argv[]) {
  char str1[4];

  for (int i = 0; i < 3; i++) {
    str1[i] = getchar();
    if (str1[i] == ' ') str1[i] = getchar();
  }
  str1[3] = '\0';

  if (atoi(str1) % 4 == 0) {
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}


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

template <int32_t MOD>
struct mint {
    int32_t value;
    mint() : value() {}
    mint(int64_t value_) : value(value_ < 0 ? value_ % MOD + MOD : value_ >= MOD ? value_ % MOD : value_) {}
    inline mint<MOD> operator + (mint<MOD> other) const { int32_t c = this->value + other.value; return mint<MOD>(c >= MOD ? c - MOD : c); }
    inline mint<MOD> & operator += (mint<MOD> other) { this->value += other.value; if (this->value >= MOD) this->value -= MOD; return *this; }
};

int64_t msb(int64_t n) {
    if (not n) return 0;
    return 1ull << (63 - __builtin_clzll(n));
}

constexpr int MOD = 1e9 + 7;
mint<MOD> solve(int64_t l, int64_t r) {
    array<array<mint<MOD>, 2>, 2> cur = {};
    for (int64_t i = 1ull << 62; i; i >>= 1) {
        array<array<mint<MOD>, 2>, 2> prv = cur;
        cur = {};
        if (msb(l) <= i and i <= msb(r)) {
            cur[i == msb(l)][i == msb(r)] += 1;
        }
        REP (p, 2) REP (q, 2) REP (xy, 3) {
            bool x = (xy >= 2);
            bool y = (xy >= 1);
            if (p and (l & i) and not x) continue;
            if (q and not (r & i) and y) continue;
            bool np = p and ((bool)(l & i) == x);
            bool nq = q and ((bool)(r & i) == y);
            cur[np][nq] += prv[p][q];
        }
    }
    mint<MOD> cnt = 0;
    REP (p, 2) REP (q, 2) {
        cnt += cur[p][q];
    }
    return cnt;
}

int main() {
    int64_t l, r; cin >> l >> r;
    cout << solve(l, r).value << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;

const int N = 301;
char s[N];
int k;
int d[N][N][N];
inline void Max(int &x, int y)
{
  if (x < y) x = y;
}
int dp(int l, int r, int k)
{
  if (l > r) return 0;
  int &ret = d[l][r][k];
  if (ret == -1)
    {
      if (l == r) return ret = 1;
      if (s[l] == s[r]) return ret = 2 + dp(l+1, r-1, k);
      ret = 0;
      Max(ret, dp(l, r-1, k));
      Max(ret, dp(l+1, r, k));
      if (k != 0)
        Max(ret, 2 + dp(l+1, r-1, k-1));
    }
  return ret;
}
int main()
{
  scanf("%s %d", s, &k);
  memset(d, -1, sizeof(d));
  printf("%d\n", dp(0, strlen(s)-1, k));
}


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

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

const int N = 2e5 + 5;

int n, h[N], a[N];
ll seg[N << 2], ans;

void upd(int pos, ll val, int id = 1, int b = 0, int e = N) {
	if(e - b == 1) {
		seg[id] = max(seg[id], val);
		return;
	}
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	if(pos < mid)
		upd(pos, val, lc, b, mid);
	else
		upd(pos, val, rc, mid, e);
	seg[id] = max(seg[lc], seg[rc]);
}

ll get(int l, int r, int id = 1, int b = 0, int e = N) {
	if(l >= e || b >= r)
		return 0;
	if(l <= b && e <= r)
		return seg[id];
	int mid = (b + e) >> 1, lc = id * 2, rc = lc | 1;
	return max(get(l, r, lc, b, mid), get(l, r, rc, mid, e));
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		ll best = get(0, h[i]) + a[i];
		ans = max(ans, best);
		upd(h[i], best);
	}
	cout << ans << "\n";
}


Measured memory_bytes: 7936
n,k = map(int, input().split())
n = (n - (n//k-1)*k) if n > k else n
n_min = 0
while n_min <= n:
    n_min = abs(n-k)
    if n_min >= n and n < k:
        print(min(n_min, n))
        break
    n = n_min

Measured memory_bytes: 61752
#include<bits/stdc++.h>
int n,x,y,i,j,a[2001];
main(){
  std::cin>>n>>x>>y;
  for(;++i<=n;)
    for(j=i;++j<=n;)
      a[std::min(j-i,abs(x-i)+1+abs(y-j))]++;
       for(i=0;++i<n;
          )
         printf("%d\n",a[i]);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 1003

using namespace std;

struct edge{
	int to, nxt;
}e[N * N * 3];

int n, cnt;
int ins[N * N], mp[N][N], fir[N * N], t[N * N];

queue < int > Q;

int id(int ,int);
void add(int ,int);

int main(){
	scanf("%d", &n); int ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < n; ++j)
			scanf("%d", mp[i] + j);
	for(int i = 1; i <= n; ++i)
		for(int j = 2; j < n; ++j)
			add(id(i, mp[i][j - 1]), id(i, mp[i][j]));
	for(int i = 1; i <= n * n; ++i){
		if(!ins[i]) Q.push(i);
		t[i] = 1;
	}
	while(!Q.empty()){
		int u = Q.front(); Q.pop(); ans = max(ans, t[u]);
		for(int i = fir[u]; i; i = e[i].nxt){
			int v = e[i].to;
			--ins[v];
			if(!ins[v])
				Q.push(v), t[v] = t[u] + 1;
		}
	}
	for(int i = 1; i <= n * n; ++i) 
		if(ins[i]) ans = -1;
	cout << ans << endl;
	return 0;
}

int id(int x,int y){
	if(x > y) swap(x, y);
	return (x - 1) * n + y;
}

void add(int u,int v){
	e[++cnt] = (edge){v, fir[u]}; fir[u] = cnt; ++ins[v];
	return ;
}


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

using namespace std;

long long n;
long long a;
long long b;
long long c[100000]={};

int main(){
    scanf("%lld",&n);
    
    for(long long i=1;i<n;i++){
        a = i;
        b = n-i;
        for(int j=5;j>=0;j--){
            int a1 = a / pow(10,j);
            int b1 = b/ pow(10,j);
            c[i]+=  a1 + b1 ;
            a -= a1 * pow(10,j);
            b -= b1 * pow(10,j); 
        }
    }
    sort(c,c+n);

    for(long long i=0;i<n;i++){
        if(c[i] != 0){
            cout << c[i] << endl;
            break;
        }
    }
    


    return 0;
}

Measured memory_bytes: 1024