akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[400010];//適宜変える(ecnt)
	int id[200010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld",&n);
	rep(i,0,n-1){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
	}
	g.vcnt=n;
	g.ecnt=2*n-2;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


ll dp[200010];

ll dfs(int v,int pre,int c){
    dp[v]=c;
	rep(i,g.id[v],g.id[v+1]){
		if(g.e[i].g!=pre){
			dfs(g.e[i].g,v,c^1);
		}
	}
}

int main(){
    readgraph();
    dfs(0,-1,0);
    
    
    int n1=(g.vcnt+2)/3;
    int n2=(g.vcnt+1)/3;
    int n3=g.vcnt/3;
    
    int cnt1=0;
    rep(i,0,g.vcnt)if(dp[i])cnt1++;
    if(cnt1<=n3){
        rep(i,0,g.vcnt){
            if(dp[i]){
                printf("%d ",n3--*3);
            }else{
                if(n1)printf("%d ",n1--*3-2);
                else if(n2)printf("%d ",n2--*3-1);
                else printf("%d ",n3--*3);
            }
        }
    }else if(g.vcnt-cnt1<=n3){
        rep(i,0,g.vcnt){
            if(!dp[i]){
                printf("%d ",n3--*3);
            }else{
                if(n1)printf("%d ",n1--*3-2);
                else if(n2)printf("%d ",n2--*3-1);
                else printf("%d ",n3--*3);
            }
        }
    }else{
        rep(i,0,g.vcnt){
            if(dp[i]){
                if(n1)printf("%d ",n1--*3-2);
                else printf("%d ",n3--*3);
            }else{
                if(n2)printf("%d ",n2--*3-1);
                else printf("%d ",n3--*3);
            }
        }
    }
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	vecl(A);
	vecl(B);
	pb(A, 0);
	fx(N) {
		vecp(A);
		A[x + 1] += A[x];
	}
	fx(M) {
		vecp(B);
	}
	fx(M-1) {
		B[x + 1] += B[x];
	}

	int ans = 0;
	fx(N+1) {
		int k = K - A[x];
		if (k<0) {
			break;
		}
		int b = upper_bound(B.begin(), B.end(), k) - B.begin();
		if (b>=M) {
			ans = max(ans, x + M);
		}
		else if (A[x] + B[b] <=k) {
			ans = max(ans, x + b+1);
		}
		else {
			ans = max(ans, x + b);
		}


	}
	ce(ans);
    return 0;
}



Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll func(string s){
  ll r = 0;
  ll buf = 0;
  REP(i,s.size()){
    if(s[i]=='+'){
      r += buf;
      buf = 0;
    }else{
      buf = buf*10 + ctoi(s[i]);
    }
  }
  r += buf;
  return r;
}

int main(){
  string s; cin>>s;
  int s_size = s.size();
  ll r = 0;
  for(ll bits=0;bits<pow(2,s_size-1);bits++){
    string t = "0"; t[0] = s[0];
    REP(i,s_size-1){
      if( (bits>>i)&1 ){
        t += "+";
      }
      t += s[i+1];
    }
    r += func(t);
  }
  cout << r<< "\n";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
int main(){
    int h,w;
    cin>>h>>w;
    char m[h][w];
    rep(i,h){
        rep(j,w){
            cin>>m[i][j];
        }
    }
    int yoko[h][w],tate[h][w];
    rep(i,h){
        int tmp1[w]={},tmp2[w]={};
        rep(j,w){
            if(j==0){
                if(m[i][j]=='.'){
                    tmp1[j]=1;
                }
                else{
                    tmp1[j]=0;
                }
            }
            else{
                if(m[i][j]=='.'){
                    tmp1[j]=tmp1[j-1]+1;
                }
                else{
                    tmp1[j]=0;
                }
            }
        }
        for(int k=w-1;k>=0;k--){
            if(k==w-1){
                if(m[i][k]=='.'){
                    tmp2[k]=1;
                }
                else{
                    tmp2[k]=0;
                }
            }
            else{
                if(m[i][k]=='.'){
                    tmp2[k]=tmp2[k+1]+1;
                }
                else{
                    tmp2[k]=0;
                }
            }

        }
        rep(l,w){
            yoko[i][l]=max(0,tmp1[l]+tmp2[l]-1);
        }
    }


    rep(i,w){
        int tmp1[h],tmp2[h];
        rep(j,h){
            if(j==0){
                if(m[j][i]=='.'){
                    tmp1[j]=1;
                }
                else{
                    tmp1[j]=0;
                }
            }
            else{
                if(m[j][i]=='.'){
                    tmp1[j]=tmp1[j-1]+1;
                }
                else{
                    tmp1[j]=0;
                }
            }
        }
        for(int k=h-1;k>=0;k--){
            if(k==h-1){
                if(m[k][i]=='.'){
                    tmp2[k]=1;
                }
                else{
                    tmp2[k]=0;
                }
            }
            else{
                if(m[k][i]=='.'){
                    tmp2[k]=tmp2[k+1]+1;
                }
                else{
                    tmp2[k]=0;
                }
            }

        }
        rep(l,h){
            tate[l][i]=max(0,tmp1[l]+tmp2[l]-1);
        }
    }
    /*
    rep(i,h){
        rep(j,w){
            cout<<yoko[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
    rep(i,h){
        rep(j,w){
            cout<<tate[i][j];
        }
        cout<<endl;
    }*/
    int ans=-100;
    rep(i,h){
        rep(j,w){
            ans=max(tate[i][j]+yoko[i][j]-1,ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

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

    reverse(all(a));
    rep(i, n) {
        if(i == n-1) cout << a[i] << endl;
        else cout << a[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 3100
N, T = map(int, input().split())
X = []
for _ in range(N):
    a, b = map(int, input().split())
    X.append((a,b))

X.sort(key=lambda x:x[0]/(x[1]+1))
X=X[::-1]

dp = [[0]+[T+2]*29 for _ in range(N+1)]
bs = []
fi=0
for i, (a, b) in enumerate(X):
    if a==0:
        bs.append(b)
        continue
    for j in range(1, 30):
#        if j==1:
#            print(a*(dp[i][j-1]+1)+b)
        dp[i+1][j] = min(min(dp[i][j], (a+1)*(dp[i][j-1]+1)+b), T+1)
    fi = i+1

#print(dp)

bs.sort()
bbs = [0]
for i, b in enumerate(bs):
    bbs.append(bbs[-1]+bs[i]+1)
bbs.append(10**18)


#print(dp[fi], bbs)
r=0
for i in range(30):
    if dp[fi][i] > T:
        break
    nt = T-dp[fi][i]
#    print(nt)
    for j, b in enumerate(bbs):
#        print(1, b)
        if b > nt:
            break
    r=max(r, i+j-1)
print(r)


Measured memory_bytes: 142416
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

const long long INF = 1ll<<60;

int main(){
	int n;
	std::cin >> n;
	std::vector<long long> h(n);
	for(int i=0; i<n; i++){
		std::cin >> h[i];
	}

	std::vector<long long> dp(n, INF);
	dp[0] = 0;
	for(int i=0; i<n-1; i++){
		dp[i+1] = std::min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
		if(i+2<n){
			dp[i+2] = std::min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
		}
	}
	std::cout << dp[n-1] << std::endl;
	return 0;

}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//こんなクソコードを生み出してしまうなんて趣味は罪ね

const int mod = 1e9 + 7;
const int IMAX = 200000;
class unko {
public:
	int f[IMAX + 1];
	constexpr unko() : f() {
		f[0] = 1;
		rep1(i, IMAX) f[i] = ll(f[i - 1]) * 2 % mod;
	}
} f;

const ull ma = (1ull << 52) - 1;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	ull AB[200001];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int n = f.f[0] - 1;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		if (a < 0) {
			a = -a;
			b = -b;
		}
		bool p = (b > 0);
		if (!p) {
			b = -b;
			swap(a, b);
		}

		ull tmp = 0;
		rep(i, 3) {
			tmp *= 3;
			if (b) {
				int k = __builtin_clzll(a) - __builtin_clzll(b);
				if (k > 0) a <<= k;
				else b <<= -k;
				if (a > b) {
					b <<= 1;
					k--;
				}
				double d = double(b) / a;
				ull tmp1 = *(ull*)& d;
				ull c = tmp1 & ma | (1ull << 52);
				lll sa = (lll(b) << 52) - lll(a) * c;
				while (sa >= 0) {
					sa -= a;
					c++;
				}
				while (sa < 0) {
					sa += a;
					c--;
				}
				tmp += ull(k + 63) << 53 | c;
				b = sa;
			}
		}

		if (p) AB[n++] = tmp << 1 | 1ull;
		else AB[n++] = tmp << 1;
	}
	sort(AB, AB + n);

	ll kotae = 1;
	ull mae = AB[0] >> 1;
	int k1 = 0, k2 = 0;
	rep(i, n) {
		if (mae != AB[i] >> 1) {
			kotae = kotae * (f.f[k1] + f.f[k2] - 1) % mod;
			k1 = 0;
			k2 = 0;
			mae = AB[i] >> 1;
		}
		if (AB[i] & 1ull) k1++;
		else k2++;
	}
	kotae = kotae * (f.f[k1] + f.f[k2] - 1) % mod;

	kotae = kotae * (f.f[a0] + f.f[b0] - 1) % mod;

	printf("%lld\n", (kotae - 1 + ab00 + mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 5300
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


int main(){
    int n;
    cin >> n;
    int s, t, c, answer = n;
    for (int i = 0; i <= n; i++){
        c = 0;
        s = i;
        t = n - i;
        while(s > 0){
            c += s % 6;
            s /= 6;
        }
        while(t > 0){
            c += t % 9;
            t /= 9;
        }
        answer = min(answer, c);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	
	public static final int SIZE = 8;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long num = 0;
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++){
			num += sc.nextInt();
		}
		
		System.out.println(num / n);
	}
	
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	string a, b;
	cin >> a >> b;
	
	double v = stod(a+b);
	
	int sq = (int)sqrt(v);
	
	if (sq*sq == (int)v) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	
	cout << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

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

    vector<pair<ll, int>> ab(n);
    for (int i = 0; i < n; i++) cin >> ab[i].first >> ab[i].second;

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

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        if (m > ab[i].second) {
            sum += ab[i].first * ab[i].second;
            m -= ab[i].second;
        }
        else {
            sum += ab[i].first * m;
            break;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    LL x;
    cin >> x;
    LL res = x / 11 * 2;
    if( x % 11 > 6 ) ++res;
    if( x % 11 ) ++res;
    cout << res << endl;

    return 0;
}



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

ans = 0
s = [0]
xs = [0]

for i in x:
    s.append(s[-1]+i)
    xs.append(xs[-1]^i)

def search(start, ok, ng):
    if abs(ok-ng) <= 1:
        if ok == ng:
            return ok
        mid = ok + 1
        if s[mid] - s[start] == xs[mid] ^ xs[start]:
            return mid
        else:
            return ok
    mid = (ok+ng) // 2
    if s[mid] - s[start] == xs[mid] ^ xs[start]:
        return search(start, mid, ng)
    else:
        return search(start, ok, mid)

for i in range(n+1):
    ans += search(i, i, n) - i
print(ans)

Measured memory_bytes: 30080
#include<iostream>
#include<cmath>
using namespace std;
int h[100001],dp[100001];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	dp[1]=0;dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};
 
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

string S;
int T[200005];
int Q;

bool reversed=false;
deque<char> deq;
string ans;

signed main(){
    cin>>S;
    cin>>Q;
    for(auto s:S)deq.push_back(s);
    for(int i=0;i<Q;++i){
        cin>>T[i];
        if(T[i]==1)reversed=!reversed;
        if(T[i]==2){
            int F;
            char C;
            cin>>F>>C;
            if(!reversed){
                if(F==1)deq.push_front(C);
                else deq.push_back(C);
            }
            else {
                if(F==1)deq.push_back(C);
                else deq.push_front(C);
            }
        }
    }
    while(deq.size()){
        ans+=deq.front();
        deq.pop_front();
    }
    if(reversed)reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 5856
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;




  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    A = scanner.nextInt();

    B = scanner.nextInt();

    int Q = scanner.nextInt();

    long[] s = new long[A + 2];
    long[] t = new long[B + 2];


    s[0] = 0;
    for (int i = 1; i <= A; i++) {
      s[i] = scanner.nextLong();
    }
    s[A + 1] = 10000000001L;
    t[0] = 0;
    for (int i = 1; i <= B; i++) {
      t[i] = scanner.nextLong();

    }
    t[B + 1] = 10000000001L;


//    Arrays.sort(s);
//    Arrays.sort(t);dd

//    System.out.println("ok");

    for (int i = 0; i < Q; i++) {
      long x = scanner.nextLong();
      System.out.println(retAns(s,t, x));
    }


  }

  public static long  retAns(long[] s, long[] t, long x){
    int l = 0;
    int r = A + 1;
    int mid;
    while(l + 1 < r){
      mid = (l + r) / 2;
      if(s[mid] > x){
        r = mid;
      }else{
        l = mid;
      }
//      System.out.println(l + " " + r );
    }

//    System.out.println(l + " " + r);

//    System.out.println(s[l] + " " + s[r]);
    int ll = 0;
    int rr = B + 1;

    while(ll + 1  < rr){
      mid = (ll + rr) / 2;
      if(t[mid] > x){
        rr = mid;
      }else{
        ll = mid;
      }
//      System.out.println("o");
    }

//    System.out.println(t[ll] + " " + t[rr]);


    long[] ans = new long[4];

    if(l == 0 || ll == 0){
      ans[0] = 999999999999999999L;
    }else{
      ans[0] = Math.max(x - s[l], x - t[ll]);
    }

    if(l == 0 || rr == B + 1){
      ans[1] = 999999999999999999L;
    }else{
      ans[1] = x - s[l] + t[rr] - x + Math.min(x - s[l], t[rr] - x);
    }

    if(r == A + 1 || ll == 0){
      ans[2] = 999999999999999999L;
    }else{
      ans[2] = s[r] - x + x - t[ll] + Math.min(s[r] - x, x - t[ll]);
    }

    if(r == A + 1 || rr == B + 1){
      ans[3] = 999999999999999999L;
    }else{
      ans[3] = Math.max(s[r] - x , t[rr] - x) ;
    }


//    System.out.println();
//    System.out.println("ans = ");
    long min = 999999999999999999L;
    for (int i = 0; i < 4; i++) {
      min = Math.min(min, ans[i]);
//      System.out.println(ans[i]);
    }


//    System.out.println(min);












    return min;
  }


}


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

using namespace std;


int main(){
  int n;
  cin >> n;
  vector<int> a(n,0);
  vector<int> b(n,0);
  vector<int> c(n,0);

  int x;
  cin >> x;
  for(int i=0;i<x;++i){
    int y;
    cin >> y;
    a[y-1]=1;
  }
  cin >> x;
  for(int i=0;i<x;++i){
    int y;
    cin >> y;
    b[y-1]=1;
  }
  cin >> x;
  for(int i=0;i<x;++i){
    int y;
    cin >> y;
    c[y-1]=1;
  }

  int num=0;
  for(int i=0;i<n;++i){
    if((a[i]==0&&c[i]==1)||(b[i]==1&&c[i])) num++;
  }

  cout << num <<endl;
  
  return 0;
}



Measured memory_bytes: 3104
N,K = map(int,input().split())
S = list(input())
a = S[K-1]
if a == 'A':
  S[K-1] = 'a'
elif a == 'B':
  S[K-1] = 'b'
elif a == 'C':
  S[K-1] = 'c'
for s in S:
  print(s, end ="")
  

Measured memory_bytes: 2940
#include<stdio.h>
int main()
  { 
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a!=b&&a!=c&&b==c)
      printf("Yes");
    else if(a!=b&&b!=c&&a==c)
      printf("Yes");
    else if(a!=c&&c!=b&&a==b)
      printf("Yes");
  else
    printf("No");
  return 0;
  }

Measured memory_bytes: 128
#include<stdio.h>
int cal(int *p);
int main(){
int r,g,b,p;
scanf("%d%d%d",&r,&g,&b);
if((r>=1 && r<=9)&&(g>=1 && g<=9)&&(b>=1 && b<=9)){
p=(r*100)+(g*10)+(b*1);
cal(&p);
}
return 0;
}
int cal(int *p){
if(*p%4==0){
    printf("YES\n");
}
else{
    printf("NO\n");
}
}

Measured memory_bytes: 1604
object Main {
  def main(args:Array[String]) {
    val N = readLine().toInt
    var H = readLine().split(' ').map(_.toLong)

    var flag = true
    for(i <- (N - 1) until 0 by -1) if(H(i - 1) > H(i)) H(i - 1) -= 1
    for(i <- (N - 1) until 0 by -1) if(H(i - 1) > H(i)) flag = false
    if(flag) println("Yes")
    else println("No")
  }
}

Measured memory_bytes: 46476
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

K = int(input())

ans = 0
flag = 0
new = 7
for i in range(K):
    ans = (ans + new%K)%K
    if ans % K == 0:
        flag = 1
        break
    #print(i,ans,new)
    new = (new*10)%K
if flag==0:
    print(-1)
else:
    print(i+1)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

const int max_n=510000;
ll fac[max_n], finv[max_n], inv[max_n];
// テーブルを作る前処理 O(max_n)
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_n; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv [mod%i] *  (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算 O(1)
long long modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
vi sosuu(ll n){ //n以下の素数列挙
    vector<bool> b(n-1,true);
    for(ll i=2;i<=sqrt(n);i++){
        if(!b[i-2])continue;
        for(ll j=2;i*j<=n;j++)b[i*j-2]=false;
    }
    vi v;
    rep(i,n-1)if(b[i])v.pb(i+2);
    return v;
}
vector<P> bunkai(ll n){
    vector<P> v;
    vi x=sosuu(sqrt(n)+1);
    for(ll i:x){
        if(n%i!=0)continue;
        ll k=0;
        while(n%i==0){
            k++;
            n/=i;
        }
        v.eb(i,k);
    }
    if(n!=1)v.eb(n,1);
    return v;
}

int main(){
    ll n,m,ans=1;cin>>n>>m;
    auto v=bunkai(m);
    init();
    for(auto x:v)ans=ans*modcom(n-1+x.second,x.second)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 12288
main = input => {
    input = input.split('\n')[0].split('');
    var result = input.every(function(element, index){
        if ((index + 1) % 2 == 1) {
          return ['R','U','D'].indexOf(element) >= 0;
        }else{
          return ['L','U','D'].indexOf(element) >= 0;
        }
    })
    console.log(result ? 'Yes' : 'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){

    ll a;
    string b;

    cin >> a >> b;
    
    ll b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    ll ans = a * b100 / 100;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
dic = {}
raw = []
dic[1] = []
for i in range(M):
  P, Y = map(int, input().split())
  raw.append([P, Y, i])
raw.sort()
for i in range(M):
  if i == 0:
    raw[i][1] = 1
    p, y, ind = raw[i]
    continue
  pp, yy, iind = raw[i]
  if pp == p:
    raw[i][1] = y + 1
  else:
    raw[i][1] = 1
  p, y, ind = raw[i]
raw.sort(key = lambda x:x[2])
for r in raw:
    p, y, ind = r
    P = "{0:06d}".format(p)
    Y = "{0:06d}".format(y)
    print(P+Y)

Measured memory_bytes: 69720
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[10];
	int m=0;
	while(n!=0){
		a[m++]=n%10;
		n/=10;
	}
	for(int i=m-1;i>=0;i--){
		if(a[i]==9) a[i]=1;
		else a[i]=9;
		cout<<a[i];
	}
		
		
}

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

using namespace std;

int main() {

    int n;
    cin>>n;
    if(n & 1)
    {
        cout<<fixed<<setprecision(10)<<(n + 1) / 2.0 / n;
    }
    else
    {
         cout<<fixed<<setprecision(10)<<0.5;
    }
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef long double ld;
typedef pair<ld, ll> P;

void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001000000;
const ll mod=1000000007;


int main(){
  ll n,k;
  cin>>n>>k;
  ll a[n];
  ll m=0;
  ll now=0;
  rep(i,n){
    cin>>a[i];
    now+=a[i];
    m=max(m,a[i]);
  }
  
  ll nl,nh;
  nl=1;
  nh=m;
  ll nm;
  
  while(nh-nl>0){
    nm=nl+(nh-nl)/2;
    ll cnt=0;
    rep(i,n){
      if(a[i]%nm==0){
        cnt+=a[i]/nm;
        cnt--;
      }
      else{
        cnt+=a[i]/nm;
      }
    }
    if(cnt>k){
      nl=nm+1;
    }
    else{
      nh=nm;
    }
  }
  cout<<nh<<endl;
}



Measured memory_bytes: 5152
// ALDS1_4_D Allocation

#include <iostream>
#define NMAX	100000

int s_weight[NMAX];	// weight of shipment

// 最大積載量w_maxのときトラックk台でn個のうち何個積めるか
int loadableNum(int n, int k, int w_max){
	int w = 0; // weight of shipments in a track
	int t = 1; // number of track
	for(int i=0 ; i<n ; i++){
		w += s_weight[i];
		if(w > w_max){
			if(t == k){
				return i;
			}
			w = 0; t++; i--;
		}
	}
	return n;
}

int main(int argc, char *argv[]){
	int n, k, p, l_num;
	int p_min = 0;
	int p_max = 0;

	std::cin >> n >> k;
	for(int i=0 ; i<n ; i++){
		std::cin >> s_weight[i];
		p_max += s_weight[i];
		if(p_min < s_weight[i]){
			p_min = s_weight[i];
		}
	}

	while(p_max >= p_min){
		p = (p_min + p_max) / 2;
		l_num = loadableNum(n, k, p);
		if(l_num == n){
			p_max = p - 1;
		}
		else{
			p_min = p + 1;
		}
	}

	p = (l_num == n) ? p : p+1;
	std::cout << p << std::endl;

	return 0;
}



Measured memory_bytes: 3488
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int T1, T2;
  ll A[2], B[2];

  cin >> T1 >> T2 >> A[0] >> A[1] >> B[0] >> B[1];

  ll dA = T1 * A[0] + T2 * A[1];
  ll dB = T1 * B[0] + T2 * B[1];

  if (dA > dB) {
    swap(A[0], B[0]);
    swap(A[1], B[1]);
    swap(dA, dB);
  }

  ll d = dB - dA;

  if (d == 0) {
    puts("infinity");
    return 0;
  }

  ll d1 = (T1 * A[0] - T1 * B[0]);

  debug(d1);
  debug(d);

  ll ans1 = A[0] > B[0] ? (d1 / d - (d1 % d == 0)) : 0;
  ll ans2 = A[0] > B[0] ? (d1 / d + 1) : 0;

  cout << ans1 + ans2 << endl;

  return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

//Ford-Fulkerson 法による最大流
//verified GRL_6_A
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3029333#1

class MaximumFlow {
  struct Edge {
    int to;
    long long capacity;
    int id;
    Edge(int to, long long cap, int id)
        : to(to), capacity(cap), id(id){};
    Edge() { Edge(0, 0, -1); }
  };
  using Graph = vector<vector<Edge>>;
  using Flow = vector<unordered_map<int, long long>>;
  //typedef vector<vector<LL>> Flow;
  int n;
  Graph graph;
  Flow flow;
  vector<char> used;

 public:
  MaximumFlow(int n) : n(n), graph(n), flow(n), used(n) {}
  //MaximumFlow(int n) : n(n), graph(n), flow(n, vector<long long>(n)) {}
  void addEdge(int a, int b, long long cap) {
    graph[a].emplace_back(b, cap, graph[b].size());
    graph[b].emplace_back(a, 0, graph[a].size() - 1);
  }
  long long maximumFlow(int s, int t) {
    long long f = 0;
    while (1) {
      fill(used.begin(), used.end(), 0);
      auto res = dfs(s, t, LINF);
      if (res == 0) return f;
      f += res;
    }
  }

 private:
  long long dfs(int now, int t, long long ff) {
    DBG(now, t, ff)
    if (now == t) return ff;
    if (used[now]) return 0;
    used[now] = 1;
    for (int i = 0; i < graph[now].size(); i++) {
      auto &e = graph[now][i];
      if (e.capacity > 0) {
        long long res = dfs(e.to, t, min(ff, e.capacity));
        DBG(now, e.to, e.capacity, res)
        if (res > 0) {
          e.capacity -= res;
          graph[e.to][e.id].capacity += res;
          return res;
        }
      }
    }
    return 0;
  }
};

namespace Problem {
using namespace std;

class Solver {
 public:
  int h, w;
  MaximumFlow mf;
  Solver(int h, int w) : h(h), w(w), mf(0){};

  void solve() {
    mf = MaximumFlow(h + w + 2);
    //vertex 0-h-1 : row
    //vertex h-h+w-1: column
    //vertex h+w :  S
    //vertex h+w+1: T
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        char tmp;
        cin >> tmp;
        if (tmp == 'o') {
          mf.addEdge(i, h + j, 1);
          mf.addEdge(h + j, i, 1);
        } else if (tmp == 'S') {
          mf.addEdge(h + w, i, LINF);
          mf.addEdge(h + w, h + j, LINF);
        } else if (tmp == 'T') {
          mf.addEdge(i, h + w + 1, LINF);
          mf.addEdge(h + j, h + w + 1, LINF);
        }
      }
    }
    auto ans = mf.maximumFlow(h + w, h + w + 1);
    cout << (ans > LINF / 2 ? -1 : ans) << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long h = 0, w;
  std::cin >> h >> w;

  Problem::Solver sol(h, w);
  sol.solve();
  return 0;
}


Measured memory_bytes: 1536
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static List<Integer> solve(int[] pre, int[] in, int preroot, int infirst, int inlast) {
        List<Integer> res = new ArrayList<>();

        int root = infirst;
        for(int i = infirst; i < inlast; i++) {
            if(pre[preroot] == in[i]) {
                root = i;
                break;
            }
        }

        if(infirst < root) res.addAll(solve(pre, in, preroot + 1, infirst, root));
        if(root < inlast - 1) res.addAll(solve(pre, in, preroot + (root - infirst + 1), root + 1, inlast));

        res.add(in[root]);
        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int[] pre = new int[n];
        for(int i = 0; i < n; i++) {
            pre[i] = sc.nextInt();
        }
        int[] in = new int[n];
        for(int i = 0; i < n; i++) {
            in[i] = sc.nextInt();
        }

        List<Integer> ans = solve(pre, in, 0, 0, n);
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++) {
            if(i != 0) sb.append(" ");
            sb.append(ans.get(i));
        }
        System.out.println(sb);

        sc.close();
    }
}



Measured memory_bytes: 26204
//============================================================================
// Name        : abc141c.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); ++i){
		if((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R')){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            if ( ( vs[du[i][0]] and not vs[du[i][1]] ) or ( not vs[du[i][0]] and vs[du[i][1]]) ) and min_dist > du[i][2]:
                min_dist,ind,pf,pt = du[i][2],i,du[i][0],du[i][1]
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
        if all(vs):
            break
        for e in du:
            if vs[e[0]] and vs[e[1]]:
                du.remove(e)
    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

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

int main() {
  
  
  /* input data */
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin >> d.at(i);
  }
  
  /* count step */
  sort(d.begin(),d.end());
  
  int previous=d.at(0);
  int step=1;
  for(int i=0;i<N;i++){
    if(previous != d.at(i)){
      step++;
    }
    previous = d.at(i);
  }
  
  /* output data */
  cout << step << endl;
}


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

int main()
{
	int N, K;
	int L[60];
	int res = 0;

	cin >> N >> K;
	for  (int i = 0; i < N; ++i) cin >> L[i];

	sort(L, L + N, greater<int>());

	for (int i = 0; i < K; ++i) res += L[i];
	
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll ,P> P3;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if(b<0){
        cout << c*(b-a) << endl;
    }
    else if (a<0){
        cout << -c*a + d + e*b << endl;
    }
    else cout << e*(b-a) << endl;
    return 0;
}



Measured memory_bytes: 3108
from numba import jit
@jit
def main():
    n,k = map(int,input().split())
    lamps = list(map(int,input().split()))
    for ki in range(k):
        lamplog = [0]*(n+1)
        for i in range(n):
            lamplog[max(0,i-lamps[i])  ] += 1   #先端を出す
            lamplog[min(i+lamps[i]+1,n)] -= 1   #末尾を出す
        # print(lamplog)
        for i in range(n):                      #累積和を計算
            lamplog[i+1] += lamplog[i]
        # print(lamplog)
        lamplog.pop()
        if(lamplog == lamps):                   #１つ前の結果と今回の結果が同じだったら。
            break
        lamps = lamplog                         #今回の結果を記録
    return lamplog

lamplog = main()
ans = ""
for i in range(len(lamplog)):
    ans += str(lamplog[i]) +" "
print(ans.rstrip())

Measured memory_bytes: 136876
#include <bits/stdc++.h>
using namespace std;
#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 main() {
  int n;
  cin>>n;
  vector<long>a(n);
  int ans=0;
  rep(i,n){
    cin>>a.at(i);
    if(i%2==0&&a[i]%2==1){
      ans++;
    }
  }
  
  cout<<ans<<endl;
}




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

int main(){
  int n;
  cin >> n;
  int ans = 100000;
  for (int i = 0; i < n; i++) {
    ans *= 1.05;
    if (ans % 1000 != 0) {
      int tmp = ans / 1000;
      ans = (tmp + 1) * 1000;
    }
  }
  cout << ans << endl;
}


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

int p = 2019;

int main() {
	int l, r;
	cin >> l >> r;
	if(l / p < r / p) cout << 0 << endl;
	else {
		l %= p;
		r %= p;
		int m = p - 1;
		for(int i=l;i<=r;i++) for(int j=i+1;j<=r;j++) {
			int t = (i * j) % p;
			if(t < m) m = t;
		}
		cout << m << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem169d(n))
}

fun problem169d(n: Long): Long {
    /**
     * 素因数分解
     */
    fun computePrimeFactorList(n: Long): List<Pair<Long, Long>> {
        val p = mutableListOf<Pair<Long, Long>>()
        var primeFactor = n
        for (i in 2..(Math.sqrt(n.toDouble()) + 1).toLong()) {
            var count = 0L
            while (primeFactor % i == 0L) {
                primeFactor /= i
                count++
                if (primeFactor == 1L) break
            }
            p.add(i to count)
        }
        if (primeFactor != 1L) p.add(primeFactor to 1L)
        return p
    }

    val pf = computePrimeFactorList(n)
    var count = 0L
    for (i in 0 until pf.size) {
        var (a, b) = pf[i]
        var j = 1
        while (b > 0) {
            if (b < j) break
            b -= j
            count++
            j++
        }
    }
    return count
}


Measured memory_bytes: 96904
/* ABC074_A
    Stuartyg */
 
#include <stdio.h>
#include <string.h>
#include <math.h>
 
int main(){
    int n,a;
 
    //入力受け取り
    scanf("%d", &n);
    scanf("%d", &a);
    //差を出力
    printf("%d\n",n*n-a);
    return 0;
}


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

using namespace std;

int main()
{
	int x, y;
	int t_num = 0, q_num = 0;
	cin >> x >> y;
	if (y % 2 == 1)
	{
		puts("No");
		return 0;
	}

	if (y % 4 == 2)
	{
		t_num++;
	}
	
	q_num = y / 4;

	if (t_num + q_num == x)
	{
		puts("Yes");
		return 0;
	}
	else if (t_num + q_num > x)
	{
		puts("No");
		return 0;
	}

	while(q_num > 0)
	{
		q_num--;
		t_num += 2;
		if (t_num + q_num == x)
		{
			puts("Yes");
			return 0;
		}
	}

	puts("No");
	return 0;
}

Measured memory_bytes: 3636
n = int(input())
L_dict, R_dict = {}, {}
i = 0
for ipt in input().split():
    try:
        L_dict[i + int(ipt)] += 1
    except KeyError:
        L_dict[i + int(ipt)] = 1
    try:
        R_dict[i - int(ipt)] += 1
    except KeyError:
        R_dict[i - int(ipt)] = 1
    i += 1
cnt = 0
for Lk, Lv in L_dict.items():
    try:
        cnt += R_dict[Lk] * Lv
    except KeyError:
        pass
print(cnt)

Measured memory_bytes: 59624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)v[i]=i;
    ll d=log2(n-1)+1;
    rep(i,n-1){
        repl(j,i+1,n){
            rep(k,d){
                if((v[i]&1<<k)!=(v[j]&1<<k)){
                    cout << k+1 <<" ";
                    break;
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, dis[100001], a, c;
	deque<pair<int, int> > dq;
	cin >> n;
	fill(dis, dis + n, 1e9);
	dis[1] = 0;
	dq.push_back(make_pair(0, 1));
	while(!dq.empty()){
		a = dq.front().second, c = dq.front().first;
		dq.pop_front();
		if(dis[a] != c) continue;
		if(dis[a * 10 % n] > c){
			dis[a * 10 % n] = c;
			dq.push_front(make_pair(c, a * 10 % n));
		}
		if(dis[(a+1) % n] > c + 1){
			dis[(a+1) % n] = c + 1;
			dq.push_back(make_pair(c + 1, (a + 1) % n));
		}
	}
	cout << dis[0] + 1;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL xs(N*2);
  REP(i,N){
	cin >> xs[i];
	xs[i+N] = xs[i];
  }
  VL acc(2*N+1);
  REP(i,N*2) acc[i+1] = acc[i] + xs[i];

  LL lb = 0, ub = 1e18;
  while(ub-lb > 1){
	LL m = (lb + ub) / 2;
	bool ok = false;
	REP(i,N){
	  int b1 = lower_bound(begin(acc)+i, end(acc), acc[i]+m) - begin(acc);
	  if(b1 == 2*N+1) continue;
	  int b2 = lower_bound(begin(acc)+b1, end(acc), acc[b1]+m) - begin(acc);
	  if(b2 == 2*N+1) continue;
	  int b3 = lower_bound(begin(acc)+b2, end(acc), acc[b2]+m) - begin(acc);
	  if(b3 == 2*N+1) continue;
	  if(b3-i <= N){
		ok = true;
		break;
	  }
	}
	if(ok) lb = m;
	else ub = m;
  }
  cout << lb << endl;

  return 0;
}

Measured memory_bytes: 5972
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

const int N=1e5+5;
int cnt[N];
priority_queue<ll,vector<ll>,greater<ll>>pq;

int main(){	
	fastio;
	int n,k;cin>>n>>k;
	vector<ii>mm(n);
	FER(i,0,n)cin>>mm[i].ss>>mm[i].ff;
	sort(mm.rbegin(),mm.rend());
	ll x=0,tot=0;
	FER(i,0,k){
		if(cnt[mm[i].ss]==0)x++;
		else pq.push(mm[i].ff);
		tot+=mm[i].ff;
		cnt[mm[i].ss]++;
	}
	ll mx=tot+x*x;
	FER(i,k,n){
		if(pq.empty())break;
		if(cnt[mm[i].ss]==0){
			tot+=mm[i].ff-pq.top();
			pq.pop();
			x++;
			mx=max(mx,tot+x*x);
			cnt[mm[i].ss]++;
		}
	}
	cout<<mx<<endl;

	return 0;
}


Measured memory_bytes: 2812
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b;
  cin >> a >> b;
  printf("%lld",max({2*a-1,2*b-1,a+b}));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	cout<<fixed<<setprecision(10)<<(n+1)/2*1.0/n<<'\n';
	return 0;
}


Measured memory_bytes: 256