akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MOD 1000000007
#define MAXN 200000
//---------------------
ll inv[MAXN];
ll fac[MAXN];
ll facinv[MAXN];


ll modpow(ll a, ll b){
  	if(b==-1) return inv[a];
  	if(b<-1) {
  		a=inv[a%MOD];
  		b*=-1;
  	}
	if(b==0) return 1;
	if(b==1) return a%MOD;
	ll ret=modpow(a%MOD,b>>1)%MOD;
	return (ret*ret%MOD)*((b%2)?(a%MOD):1)%MOD;
}

ll fermat(ll a){
  	if(a%MOD) return -1;
	return modpow(a,MOD-2);
}

inline ll modmult(ll a, ll b){
	return (a%MOD)*(b%MOD)%MOD;
}

inline ll modmult(ll a, ll b ,ll c){
	return (a%MOD)*(b%MOD)%MOD*(c%MOD)%MOD;
}


inline ll modfact(ll n){
	if(n==0 || n==1) return 1;
	if(n>=MOD) return 0;
	return fac[n];
}

inline ll modcomb(ll m, ll n){
  	if(m>=MOD || n>=MOD || n<0 || m<0) return -1;
  	if(n==0||n==m) return 1;
	return fac[m]*facinv[m-n]%MOD*facinv[n]%MOD;
}
      
void makelist(){
  	inv[0]=-1;
  	inv[1]=1;
	for(ll i=2;i<MAXN;i++) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
	fac[0]=1;
	REP1(i,MAXN) fac[i]=(fac[i-1]*i)%MOD;
	facinv[MAXN-1] = modpow(fac[MAXN-1],MOD-2);
	REPB(i,MAXN-1) facinv[i]=(facinv[i+1]*(i+1))%MOD;
}

void makepowlist(ll *list,ll a,ll num){
	list[0]=1;
	REP1(i,num-1){
		list[i] = modmult(list[i-1],a);
	}
}

void makepowinvlist(ll *list, ll a,ll num){
	list[0]=1;
	REP1(i,num-1){
		list[i] = modmult(list[i-1],inv[a]);
	}
}

ll n,a,b,c,r;
ll powA[MAXN],powB[MAXN],powinvApB[MAXN];
int main(){
  	cin>>n>>a>>b>>c;
  	makelist();
  	makepowlist(powA,a,MAXN);
  	makepowlist(powB,b,MAXN);
  	makepowinvlist(powinvApB,a+b,MAXN);
  	r=0;
  	ll hmcinv=inv[100-c];
  	for(ll m=n;m<=2*n-1;m++){
  		r=
  		(r+
  		modmult(
  			modmult(
  				modcomb(m-1,n-1),
  				100,
  				m
  			),
  			modmult(
  				(modmult(powA[n],powB[m-n])+modmult(powA[m-n],powB[n]))%MOD,
  				powinvApB[m],
  				hmcinv
  			)
  		)
  		)%MOD;
  	}
  	
  	cout<<r<<endl;
	
	return 0;
}

Measured memory_bytes: 9600
import java.util.*;
class Main{
	static final int MaxN=100000+1;
	static boolean vis[]=new boolean[MaxN];
	static ArrayList<ArrayList<Integer>>link=new ArrayList<ArrayList<Integer>>();
		static int id[]=new int [MaxN];
static int rank[]=new int [MaxN];
public static class DSU{


static int root(int i){
	while(i!=id[i]){
		i=id[i];
	}
	return i;
}

static void union(int p,int q){
int i=root(p);
int j=root(q);
if(rank[i]>rank[j]){
id[j]=id[i];
rank[j]+=rank[i];
}
if(rank[i]<=rank[j]){
id[i]=id[j];
rank[i]+=rank[j];
}}
static boolean connected(int i,int j){

	return root(i)==root(j);
}

}
static void dfs(int i){
vis[i]=true;
for(int x:link.get(i)){
if(!vis[x])
	dfs(x);}
}
	static Scanner scan=new Scanner(System.in);

public static void main(String[] args) {


	//
	
	int n=scan.nextInt();
	int m=scan.nextInt();
	int temp=0;
		for(int i=0;i<=n;i++){

link.add(new ArrayList());
	}
	for(int i=0;i<m;i++){
		//link.add(new LinkedList());
		int a=scan.nextInt();
		int b=scan.nextInt();
		link.get(a).add(b);
		link.get(b).add(a);
	}
	
int cnt=0;
for(int i=1;i<=n;i++){
	if(!vis[i]){
		cnt++;
		dfs(i);
		
	}
}



	

System.out.println(cnt-1);
}
}

Measured memory_bytes: 77052
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int a[100010];
int g[100010],f[100010];
int gcd(int u,int v){
    if(u<v)return gcd(v,u);
    if(v==0)return u;
    return gcd(v,u%v);
}
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=0;i<n;++i){
        g[i]=i?gcd(a[i],g[i-1]):a[i];
    }
    for(int i=n-1;i>=0;--i){
        f[i]=i==n-1?a[i]:gcd(a[i],f[i+1]);
    }
    int ans=0;
    for(int i=0;i<n;++i){
        ans=max(ans,gcd(i?g[i-1]:0,i==n-1?0:f[i+1]));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ci const int&
using namespace std;
int n,m,a[200010],l,r,mid,ans;
bool Check(int x){
	if(!(x&1))--x;
	for(int i=x,j=(n<<1);i<j;++i,--j)if(a[i]+a[j]<m)return 0;
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=(n<<1);++i)scanf("%d",&a[i]);
	sort(a+1,a+(n<<1)+1);
	l=1,r=(n<<1)+1;
	while(l<r)mid=l+r>>1,Check(mid)?r=mid:l=mid+1;
	ans=0;
	for(int i=1,j=l-1;i<j;++i,--j)ans=max(ans,a[i]+a[j]);
	for(int i=l,j=(n<<1);i<j;++i,--j)ans=max(ans,a[i]+a[j]-m);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    int sum = 0;
    rep(i, n) {
        int x;
        cin >> x;
        sum += min(abs(x) * 2, abs(x-k) * 2);
    }
    cout << sum << endl;
    return 0;
}



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

using namespace std;

int main(){
	int a[30];
	for (int i = 0; i < 30; i++){
		a[i] = i+1;
	}
	int b;
	for (int i = 0; i < 28; i++){
		scanf("%d", &b);
		a[b-1] = 0;
	}
	for (int i = 0; i < 30; i++){
		if (a[i])
			printf("%d\n", a[i]);
		}
	return 0;
}

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

int main(){
    int A,B,x,z,y;
    cin >>A>>B;
    x=A+B;
    y=A-B;
    z=A*B;
    if (x>=z && x>=y){
            cout <<x;}
    else if (y>=x && y>=z){
          cout <<y;}
    else if (z>=x && z>=y){
           cout <<z;}
    return 0;

}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cEdges=vector<vector<pair<int,int>>>;

int main() {
	int N;
	cin>>N;
	vector<int> a(N);
	for(auto& val:a)
		cin>>val;

	sort(begin(a),end(a));
	long long ans=LLONG_MAX;
	for(int i=a.front();i<=a.back();++i){
		long long sum=0;
		for(int j=0;j<N;++j){
			sum+=(i-a[j])*(i-a[j]);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int k,n;
    cin>>k>>n;
    vector<int> a(n+1,0);
    for (int i = 1; i < n+1; i++) cin>>a[i];
    vector<int> dist(n+1,0);
    for (int i = 1; i < n+1; i++)
    {
        dist[i]=abs(a[i]-a[i+1]);
        if(i==n) dist[i]=(k-a[i])+a[1];
    }

    sort(dist.begin(),dist.end(),greater<int>());
    int m=dist[0];
    int sum=accumulate(dist.begin(),dist.end(),0);
    cout<<sum-m<<endl;

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int ans = (N-1)/(K*2+1)+1;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
from sys import stdin, maxsize

def main():
    input = stdin.readline

    h, n = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]
    dp = [maxsize] * (h + 1)
    dp[0] = 0
    for i in range(h + 1):
        for x, y in a:
            if i + x < h and dp[i + x] > dp[i] + y:
                dp[i + x] = dp[i] + y
            elif i + x >= h and dp[h] > dp[i] + y:
                dp[h] = dp[i] + y
    print(dp[h])
main()

Measured memory_bytes: 41452
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;  // 1e9+9

ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}

ll mpow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll ncr[5000][5000];

ll nCr(ll n,ll r){
  if(n==r)return 1;
  if(r==0)return 1;
  if(ncr[n][r])return ncr[n][r];
  ncr[n][r]=(nCr(n-1,r-1)+nCr(n-1,r))%mod;
  return ncr[n][r];
}

ll nHr(ll n,ll r){
  return nCr( n+r-1 , n );
}

int main(){
  ll n,k;
  cin>>n>>k;
  cout<<nHr(n,k)<<endl;
  return 0;
}



Measured memory_bytes: 18964
#include <iostream>

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

using namespace std;

int main(){
  string S;
  long long K;
  cin >> S >> K;
  // 入力終了
  int N = S.size();
  string copy = S;
  
  // 全て同じ文字で構成されているなら，1つ飛ばしで変えていけばOK 
  bool all_same = true;
  rep(i, N-1)
    all_same *= (S[i] == S[i+1] );
  if(all_same){
    cout << N*K/2 << endl;
    return 0;
  }
  
  long long ans = 0;
  for(int i=1; i<N; i++){
    // 1つ前と同じなら，i番目を *(任意の文字)で置き換える
    if(S[i-1] == S[i] ){
      S[i] = '*';
      ans++;
      // 3つ連続するときは中央を変更すると考えて，indexを1つ先送り
      if(i<N-1 && S[i] == S[i+1] )
	i++;
    }
  }

  // 上の処理の後，先頭と末尾が同じなら繋ぎ目をK-1回書き換える
  // ただし，先頭から続く同じ文字の文字列長と，末尾からのそれの偶奇が
  // 一致しなければうまいこと調整できる
  long long tmp = 0;
  if(copy[0] == copy[N-1]){
    int l=0, r=N-2;
    while(copy[l] == copy[l+1])
      l++;
    while(copy[r] == copy[r+1])
      r--;
    if((l+1)%2 == (N-r-1)%2)
      tmp = K-1;
  }
  
  // 解答
  cout << ans*K + tmp << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int l = n/2;
  int r = n/2;
  char ll = s.at(l);
  char rr = s.at(r);
  while(l > 0){
    l--;
    if(s.at(l) != ll){
      l++;
      break;
    }
  }
  while(r < n-1){
    r++;
    if(s.at(r) != rr){
      r--;
      break;
    }
  }
  //cout << r << " " << l << endl;
  cout << min(r+1,n-l) << endl;
}

Measured memory_bytes: 512
# n個の点全てを含む円のうち半径が最小である円の
# 中心座標と半径を求める
class SolvCircle

    LOOP_MAX = 100

    # 移動距離がこの値以下になったら処理を終了させる
    CONVRGV = 1.0e-16

    #
    #=== 円の中心座標と半径を求める
    #
    #_pt_x_ :: n個の点のx座標の配列
    #_pt_y_ :: n個の点のy座標の配列
    # 
    #返り値::配列を返す。[中心点のx座標, 中心点のy座標, 円の半径]
    #
    def solv_circle(pt_x, pt_y)
        mv_rate  = 0.5 # 移動係数
        max_dist = 0.0 # 中心点から最遠点までの距離
        xsv      = 0.0 # 中心点のx座標
        ysv      = 0.0 # 中心点のy座標
        cx       = 0.0 # 仮中心点のx座標
        cy       = 0.0 # 仮中心点のy座標
        k        = 0
        cvgflg   = false

        while (cvgflg == false)

            LOOP_MAX.times { |t|
                # 最遠点を求める
                max_dist = 0.0
                pt_x.length.times { |i|
                    dist = distance(cx, cy, pt_x[i], pt_y[i])
                    if (dist > max_dist)
                        max_dist = dist
                        k        = i
                    end
                }

                # 仮の中心点を計算
                cx += (pt_x[k] - xsv) * mv_rate
                cy += (pt_y[k] - ysv) * mv_rate

                # 移動距離が境界値を下回っていればループを抜ける
                if (distance(cx, cy, xsv, ysv) <= CONVRGV)
                    cx     = xsv
                    cy     = ysv
                    cvgflg = true
                    break
                end

                xsv = cx
                ysv = cy
            }

            mv_rate /= 2.0

        end

        return [cx, cy, max_dist]
    end

    #
    #=== 二点の距離を求める
    #
    def distance(x1, y1, x2, y2)
        dx = x2 - x1
        dy = y2 - y1
        Math.sqrt(dx * dx + dy * dy)
    end
end

N = gets.to_i
x = Array.new(N)
y = Array.new(N)
N.times{|i| x[i],y[i] = gets.split.map(&:to_i)}

sc = SolvCircle.new
ans = sc.solv_circle(x, y)
puts ans[2]



Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define sc second
using namespace std;
const int N=1050;
const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m;
char mp[N][N];
int dis[N][N],ans=0;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",mp[i]+1);
	queue<pii>q;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(mp[i][j]=='#')dis[i][j]=1,q.push(pii(i,j));
	int x,y,nx,ny;
	while(!q.empty())
	{
		x=q.front().fi,y=q.front().sc,q.pop();
		ans=max(ans,dis[x][y]);
		for(int i=0;i<4;i++)
		{
			nx=x+dx[i],ny=y+dy[i];
			if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&!dis[nx][ny])
				dis[nx][ny]=dis[x][y]+1,q.push(pii(nx,ny));
		}
	}
	printf("%d\n",ans-1);
}

Measured memory_bytes: 13584
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, K;
int h[100010];


int solve(){
	int ans = INF;
	rep(i, 0, N-K+1){
		chmin(ans, h[i+K-1]-h[i]);
	}
	return ans;
}


signed main(){
	cin >> N >> K;
	rep(i, 0, N) cin >> h[i];

	sort(RNG(h, 0, N));

	cout << solve() << endl;

	return 0;

}

Measured memory_bytes: 640
p,q,r,s=map(int,input())
flag=False
if p+q+r+s==7:
    print(str(p)+'+'+str(q)+'+'+str(r)+'+'+str(s)+'=7')
    flag=True
elif p+q+r-s==7 and flag==False:
    print(str(p)+'+'+str(q)+'+'+str(r)+'-'+str(s)+'=7')
    flag=True
elif p+q-r+s==7 and flag==False:
    print(str(p)+'+'+str(q)+'-'+str(r)+'+'+str(s)+'=7')
    flag=True
elif p+q-r-s==7 and flag==False:
    print(str(p)+'+'+str(q)+'-'+str(r)+'-'+str(s)+'=7')
    flag=True
elif p-q+r+s==7 and flag==False:
    print(str(p)+'-'+str(q)+'+'+str(r)+'+'+str(s)+'=7')
    flag=True    
elif p-q+r-s==7 and flag==False:
    print(str(p)+'-'+str(q)+'+'+str(r)+'-'+str(s)+'=7')
    flag=True
elif p-q-r+s==7 and flag==False:
    print(str(p)+'-'+str(q)+'-'+str(r)+'+'+str(s)+'=7')
    flag=True
elif p-q-r-s==7 and flag==False:
    print(str(p)+'-'+str(q)+'-'+str(r)+'-'+str(s)+'=7')
    flag=True
    

Measured memory_bytes: 38384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, t, a, h[1001];
  cin >> n >> t >> a;
  double dis = 10000.0;
  int res = 1;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    double x = abs(a - (t - 0.006 * (double)h[i]));
    if (dis > x) {
      dis = x;
      res = i + 1;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

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

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}

string rot(string S){
    return S[S.size() - 1] + S.substr(0, S.size() - 1);
}

int main(){

    int N, M;
    cin >> N >> M;

    vector<Pii> p(M);
    int a, b;
    for(int i = 0; i < M; i++){
        cin >> a >> b;
        p[i] = Pii(b, a);
    }

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

    int ans = 0;
    int last = -1;

    for(int i = 0; i < M; i++){
        if(last < p[i].second){
            last = p[i].first - 1;
            ans++;
        }
    }

    cout << ans;

    return 0;

}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back

int bexp(int a, int b)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a);

        a = (a * a); 
        b >>= 1;
    }
    return res;
}

#define N 200010
#define MOD 1000000007

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


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int l, r, d;
    cin >> l >> r >> d;

    int ans = r / d - (l + d - 1) / d + 1;

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, x, a, b, ans;
vector<int> g[N];
int dist1[N], dist2[N];

void dfs(int u, int par, int dist[])
{
	dist[u]= dist[par] + 1;
	for(auto &it:g[u])
	{
		if(it == par)
			continue;
		dfs(it, u, dist);
	}
}

int32_t main()
{
	IOS;
	cin >> n >> a >> b;
	for(int i = 1; i <= n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dist1[0] = -1;
	dist2[0] = -1;
	dfs(a, 0, dist1);
	dfs(b, 0, dist2);
	for(int i = 1; i <= n; ++i)
	{
		if(dist1[i] < dist2[i])
		{
			int cur = dist2[i];
			if(dist2[i] % 2 == 0)
			{
				if(dist1[i] % 2)
					cur--;
				else
					cur--;
			}
			else
			{
				if(dist1[i]% 2 == 0)
					cur--;
				else
					cur--;
			}
			ans = max(ans, cur);
		}
	}
	cout << ans;
}

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

const int MOD = 1000000007;

int main(){
  long long n,k,ans = 0,mini,maxi;
  cin >> n >> k;
  vector<long long> ruiseki(n + 2,0);
  for(int i = 1;i < n + 1;i++){
    ruiseki[i + 1] = i + ruiseki[i];
  }
  for(int i = k;i <=n + 1;i++){
    maxi = ruiseki[n + 1] - ruiseki[n + 1 - i];
    mini = ruiseki[i];

    ans = (ans + maxi - mini + 1) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
from collections import deque
s = list(input())
q_num = int(input())

s_deq = deque(s)
reversed = False

for _ in range(q_num):
    query = input().split()
    if query[0] == '1':
        reversed = False if reversed else True
    elif query[0] == '2':
        if not reversed:
            if query[1] == '1':
                s_deq.appendleft(query[2])
            elif query[1] == '2':
                s_deq.append(query[2])
        else:
            if query[1] == '2':
                s_deq.appendleft(query[2])
            elif query[1] == '1':
                s_deq.append(query[2])
if reversed:
    s_deq.reverse()
print(''.join(s_deq))

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

using namespace std;

int main()
{
    bitset <64> b(0);
    long long q,x,y;
    cin>>q;
    while(q--)
    {
        cin>>x;
        if(x<4)
            cin>>y;
        if(x==0)
            cout<<b.test(y)<<endl;
        if(x==1)
            b.set(y);
        if(x==2)
            b.reset(y);
        if(x==3)
            b.flip(y);
        if(x==4)
            cout<<b.all()<<endl;
        if(x==5)
            cout<<b.any()<<endl;
        if(x==6)
            cout<<b.none()<<endl;
        if(x==7)
            cout<<b.count()<<endl;
        if(x==8)
            cout<<b.to_ullong()<<endl;
    }
    return 0;
}



Measured memory_bytes: 3084
/*
 *
 *
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int main() {
  int n;
  cin >> n;
  REP(ii, n){
    set<string> cnt;
    string s;
    cin >> s;
    FOR(i, 1, s.length()){
      stringstream s1, s2;
      REP(j, i){
        s1 << s[j];
      }
      FOR(j, i, s.length()){
        s2 << s[j];
      }
      string ss1 = s1.str();
      string ss2 = s2.str();
      string ss3 = s1.str();
      string ss4 = s2.str();
      reverse(ALL(ss3));
      reverse(ALL(ss4));

      cnt.insert(ss1 + ss2);
      cnt.insert(ss1 + ss4);
      cnt.insert(ss3 + ss2);
      cnt.insert(ss3 + ss4);
      cnt.insert(ss2 + ss1);
      cnt.insert(ss2 + ss3);
      cnt.insert(ss4 + ss1);
      cnt.insert(ss4 + ss3);
    }
    cout << cnt.size() << endl;
  }
}

Measured memory_bytes: 3196
from collections import deque

s = input()
q = int(input())

ans = deque(s)
rev = False

for _ in range(q):
    t = list(input().split())
    if t[0] == '1':
        rev = not rev
    elif t[0] == '2':
        if rev == False:
            if t[1] == '1':
                ans.appendleft(t[2])
            else:
                ans.append(t[2])
        else: # rev = Trueのとき
            if t[1] == '1':
                ans.append(t[2])
            else:
                ans.appendleft(t[2])

result = ''.join(ans)
if rev == True:
    result = result[::-1]

print(result)

Measured memory_bytes: 75864
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))

ev = 0
ad = 0
for i in A:
  if i % 2 == 0:
    ev += 1
  else:
    ad += 1

if P == 1:
  if ad == 0:
    print("0")
    exit()
  

f = [1, 1]
for i in range(2, ad + 1):
  f.append(f[-1] * i)
num = 0
for i in range(P, ad + 1, 2):
  num += f[ad] // (f[i] * f[ad - i])

print(pow(2, ev) * num)



Measured memory_bytes: 3188
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n::Int=parseInt(readline())
    cnt::Vector{Int}=ones(Int,n)
    for i in 2:n
        for j in 1:n÷i
            cnt[i*j]+=1
        end
    end
    ans::Int=0
    for i in 1:n
        ans+=cnt[i]*i
    end
    println(ans)
end
main()

Measured memory_bytes: 237744
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll mod = 1e9 + 7;

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

	int N;
	cin >> N;
	string S;
	cin >> S;
	
	int cnt = 0;
	for (int i = 0; i <= 999; i++) {
		int temp = i;
		vector<int>t;
		t.pb(temp / 100);
		temp -= 100 * (temp / 100);
		t.pb(temp / 10);
		temp -= 10 * (temp / 10);
		t.pb(temp);
		int cur = 0;
		int ok = 0;
		for (int j = 0; j < N;j++) {
			if ((S[j] - '0') == t[cur])cur++;
			if (cur == 3) {
				ok = 1;
				break;
			}
		}
		cnt += ok;
	}
	puts(cnt);
	return 0;
}

Measured memory_bytes: 384
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_B&lang=jp
  * Math Functions - Triangle
  */
object Main {
  def main(args: Array[String]): Unit = {
    val Array(a, b, degreeC) = io.StdIn.readLine().split(" ").map(_.toInt)
    val radianC = degreeC * math.Pi / 180.0
    val c = math.sqrt(a * a + b * b - 2.0 * a * b * math.cos(radianC))
    val el = a + b + c
    val s = el / 2.0
    val es = math.sqrt(s * (s - a) * (s - b) * (s - c))
    val h = 2.0 * es / a
    println(es)
    println(el)
    println(h)
  }
}

Measured memory_bytes: 43756
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define MOD 		1000000007
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define pi 			3.14159265358979323
#define endl '\n'
#ifdef WIN32
#define getchar_unlocked getchar
#endif
#define gc getchar
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define N 1000006
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef vector<long long int> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
template<typename T> T sqr(T x){return x*x;}
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
template<typename T> T pow(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%m;y/=2;x=(x*x)%m;}return ans%m;} //using this instead of inbuilt pow due to precision issues in that
template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}
int mneg(int x,int m){
	return (x%m<0)?x%m+m:x%m;
}
int main(){
	ll n,x,y; cin>>n;
	ll ans=0;
	vector<pair<ll,ll>> v;
	rep(i,0,n){
		cin>>x>>y; v.eb(mp(x,y));
	}
	reverse(all(v));
	tcf(v,i){
		//trace3(i.first,ans,i.second-(i.first+ans)%i.second);
		i.first+=ans;
		ans+=(i.second-i.first%i.second==i.second)?0:i.second-i.first%i.second;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2420
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil
    import copy

    #mod = 1000000007

    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    res = 10**17
    for i in range(2**n):
        total, m, cnt = 0, 0, 0
        for j in range(n):
            if(i>>j) & 1:
                cnt += 1
                total += max(m-a[j]+1, 0)
                m = max(m+1, a[j])
            else:
                m = max(m, a[j])
        if cnt == k:
            res = min(res, total)
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var N=Arr.shift()-0;
   if(N==0)break;
   var arr=[];
   for(var i=0;i<N;i++){
      var ipqr=(Arr.shift()).split(" ").map(Number);
      arr.push(ipqr);
   }
   var PQRC=(Arr.shift()).split(" ").map(Number);
   var result=[];
   arr.forEach(function(v){
      var bad=0;
      if(PQRC[0]<v[1])bad++;
      if(PQRC[1]<v[2])bad++;
      if(PQRC[2]<v[3])bad++;
      if(PQRC[3]<4*(v[1]+v[3])+(9*v[2]))bad++;
      if(bad==0)result.push(v[0]);
   });
   console.log((result.length==0)?"NA":result.join("\n"));
}

Measured memory_bytes: 20048
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef unordered_map<ULL, ULL> umap;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
const int MOD=1e9+7;
ULL pw(ULL a, ULL n){ ULL b=1; while(n){ if(n&1){ b=(b*a)%MOD; } a=(a*a)%MOD; n>>=1; } return b; }
umap to_umap(ULL n){
  umap U;
  while(n%2==0){ U[2]++; n>>=1; }
  for(ULL k=3; k*k<=n; k+=2){ while(n%k==0){ U[k]++; n/=k; } }
  if(n>1){ U[n]=1; }
  return U;
}
ULL to_ULL(umap &U){
  ULL n=1;
  for(auto p:U){ n=(n*pw(p.first, p.second))%MOD; }
  return n;
}
umap LCM(vector<umap> &V){
  umap U;
  REP(i, V.size()){ for(auto p:V[i]){ U[p.first]=max(U[p.first], p.second); } }
  return U;
}
int main(){
  int N; cin >> N; ULL A[N], L, x=0; vector<umap> VA; umap VL;
  REP(i, N){ cin >> A[i]; VA.push_back(to_umap(A[i])); }
  VL=LCM(VA); L=to_ULL(VL);
  REP(i, N){ x=(x+(L*pw(A[i], MOD-2))%MOD)%MOD; }
  cout << x << "\n";
}

Measured memory_bytes: 5840
import sys
readline = sys.stdin.readline

S = readline().strip()
A = ('SUN','MON','TUE','WED','THU','FRI','SAT')
B = (7, 6, 5, 4, 3, 2, 1)
C = {a: b for a, b in zip(A, B)}
print(C[S])

Measured memory_bytes: 38512
#include <stdio.h>
 
int main()
{
  int a, b, t;
  scanf("%d%d", &a, &b);
 
  while(a%b!=0){
    t = a%b;
    a = b;
    b = t;
  }
 
  printf("%d\n", b);
  return 0;
}

Measured memory_bytes: 592
import java.io.*;
import java.util.*;
class Main{
    public static int[] A;
    public static int[] B;
    public static int[] C;
    public static int n;
    public static void main(String[] args) {
	int i,k=0;
	A = new int[2000001];
	B = new int[2000001];
	C = new int[2000001];
	try{
	    BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
	    String str = buffer.readLine();
	    n = Integer.parseInt(str);
	    StringTokenizer st = new StringTokenizer(buffer.readLine());
	    for(i=0;i<n;i++){
		A[i] = Integer.parseInt(st.nextToken());
		if(k<=A[i]){k = A[i];}
	    }
	}catch(Exception e){
	    System.out.println("error");
	}
	CountingSort(A,B,k);
	StringBuffer sb = new StringBuffer();
	for(i=1;i<n;i++){
	    sb.append(B[i]+" ");
	}
	sb.append(B[i]);
	System.out.println(sb);
    }

    public static void CountingSort(int A[],int B[],int k){
	int i,j;
	for(i=0;i<k+1;i++){
	    C[i] = 0;
	}
	for(j=0;j<n;j++){
	    C[A[j]]++;
	}
	for(i=1;i<k+1;i++){
	    C[i] = C[i] + C[i-1];
	}
	for(j=n-1;j>=0;j--){
	    B[C[A[j]]] = A[j];
	    C[A[j]]--;
	}
    }

}



Measured memory_bytes: 219028
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int k;
    cin>>k;
    vector<ll> a(k);
    rep(i,k) cin>>a[i];
    vector<pair<ll,ll>> kids(k+1);
    kids[k]={2,2};
    
    if(a[k-1]!=2) {
        cout<<-1<<endl;
        return 0;
    }
    
    rrep(i,k) {
        ll L=kids[i+1].first,R=kids[i+1].second+a[i]-1;
        kids[i].first=(i==0 ? L : (((L-1)/a[i-1])+1)*a[i-1]);
        kids[i].second=(i==0 ? R : (R/a[i-1])*a[i-1]);
        if(!(L<=kids[i].first && kids[i].first<=R)) {
            cout<<-1<<endl;
            return 0;
        }
        if(!(L<=kids[i].second && kids[i].second<=R)) {
            cout<<-1<<endl;
            return 0;
        }
        //cout<<kids[i].first<<" "<<kids[i].second<<endl;
    }
    
    cout<<kids[0].first<<" "<<kids[0].second<<endl;
}


Measured memory_bytes: 2560
n,k = map(int,input().split())
dic = {}
for i in range(1,n+1):
    dic[i] = 0
for j in range(1,k+1):
    d = int(input())
    lis1 = list(map(int,input().split()))
    for i in lis1:
        dic[i] += 1
lis = [i for i in dic.values()]

print(lis.count(0))


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

using namespace std;

typedef long long ll;

int N;
ll L, x[100000];
ll dp[100000][18];//use DOUBLING
//100000 <= 2^17

void doubling() {
	//しゃくとりでまずDPテーブルの初期化をする
	
	int r = 0;
	for (int l = 0; l < N; l++) {
		//[L, R)
		while (x[r] - x[l] <= L && r < N) {
			r++;
		}
		dp[l][0] = r - 1;
		
		if (l == r)r++;
	}
	for (int j = 1; j < 18; j++) {
		for (int i = 0; i < N; i++) {
			dp[i][j] = dp[dp[i][j - 1]][j - 1];
		}
	}

}

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

	doubling();
	
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		l--, r--;
		if (r < l)swap(l, r);
		int ans = 0;
		int cur = l;
		for (int j = 17; j >= 0; j--) {
			if(dp[cur][j] < r){
				cur = dp[cur][j];
				ans += (1 << j);
			}
		}
		ans++;//1ズレは上の式では対応不可能
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 15616
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
int nodes, edges, cnt, ans;
vector<int> adj[200001];
bool visited[200001];

void dfs(int src){
	visited[src] = true;
	cnt++;
	for(int x: adj[src]){
		if(!visited[x])
			dfs(x);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> nodes >> edges;
	int x, y;
	for(int i = 0; i < edges; ++i){
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	for(int i = 1; i <= nodes; ++i){
		cnt = 0;
		dfs(i);
		ans = max(ans, cnt);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 21040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int X;
  cin >> X;
  int ans;
  if (X < 600)
    ans = 8;
  else if (X < 800)
    ans = 7;
  else if (X < 1000)
    ans = 6;
  else if (X < 1200)
    ans = 5;
  else if (X < 1400)
    ans = 4;
  else if (X < 1600)
    ans = 3;
  else if (X < 1800)
    ans = 2;
  else if (X < 2000)
    ans = 1;

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

Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}
int main(){
  ll n;cin>>n;
  map<ll,ll>M=prime_factor(n);
  ll ans=0;
  for(auto p:M){
    ll d=p.second;
    ll i=1;
    while(d>=i){
      ans++;
      
      d-=i;
      i++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  string s;
  cin >> s;

  cout << (s <= "2019/04/30" ? "Heisei" : "TBD") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int i=1,rem,div=7;
    for(;i<10000000;i++)
    {
        rem=div%n;
        if(rem==0)
            break;
        div=rem*10+7;
    }
    if(i==10000000)
        cout << "-1";
    else
        cout << i << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
#define mod 1000000007
int main(){
	long long  dp[301][301][301]={};
	int n,m;
	cin >> n >> m;
	dp[0][1][1]=1;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				if(j==k){
					for(int l=1;l<=k;l++){
						dp[i][j][k] = (dp[i][j][k]+l*dp[i-1][j][l])%mod;
					}
				}else{
					dp[i][j][k] = (dp[i][j][k]+(n-j+1)*dp[i-1][j-1][k]+(j-k)*dp[i-1][j][k])%mod;
				}
			}
		}
	}
	cout << dp[m][n][n] << endl;
	return 0;
}

Measured memory_bytes: 213248
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int l;
	scanf("%d", &l);
	long double a = (l * l * l) / static_cast<long double>(27.0);
	printf("%.12Lf\n", a);
	return 0;
}


Measured memory_bytes: 256
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    P = sorted([ii() for _ in range(ii())])[::-1]
    print(sum(P[:1]) // 2 + sum(P[1:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){

  int i = 0, x[101];
  char s[101];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x[i - 1] += x[i];
      i--;
    } else if ( s[0] == '-' ){
      x[i - 1] -= x[i];
      i--;
    } else if ( s[0] == '*' ){
      x[i - 1] *= x[i];
      i--;
    } else {
      i++;
      x[i] = atoi(s);
    }
  }
  printf("%d\n", x[i]);
  return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll l, r, d; cin >> l >> r >> d;
    ll x = r / d;
    ll y = (l - 1) / d;
    cout << x - y << endl;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    while(h!=0 || w!=0){
        int i, j, k;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                k=i+j ;
                if(k%2==0) cout << "#" ;
                else cout << "." ;
            }
            cout << endl ;
        }
        cout << endl ;
        cin >> h >> w;
    }
    return 0 ;
}


Measured memory_bytes: 3084
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());

            var a = k % 2 == 0 ? k / 2 : k / 2 + 1;
            var b = k / 2;

            Console.WriteLine(a * b);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<stack>
using namespace std;

int main(void){
    int a,b;
    stack<int> S;
    string c;
    while(cin >> c){
        if(c[0]=='+'){
            a=S.top();
            S.pop();
            b=S.top();
            S.pop();
            S.push(a+b);
        }
        else if(c[0]=='*'){
            a=S.top();
            S.pop();
            b=S.top();
            S.pop();
            S.push(a*b);
        }
        else if(c[0]=='-'){
            a=S.top();
            S.pop();
            b=S.top();
            S.pop();
            S.push(b-a);
        }
        else{
            S.push(atoi(c.c_str()));
        }
    }
    cout << S.top() << endl;
    return 0;
}

Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            int C = sc.nextInt();
            System.out.println(isMiserable(A, B, C) || isMiserable(B, C, A) || isMiserable(C, A, B) ? "Yes" : "No");
        }
    }

    private static boolean isMiserable(int a, int b, int c) {
        return a == b && b != c;
    }
}


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


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> grid[h];
    rep(i, h){
        string s; cin >> s;
        grid[i].push_back(s);
    }

    rep(i, h){
        cout << grid[i][0] << ln;
        cout << grid[i][0] << ln;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(){
  char str[100] = {};
  int num = 0, i, j;
  while(scanf("%s", str) != EOF){
    for(i = 0;i < strlen(str);i++){
      if(str[i] >= '0' && str[i] <= '9'){
	j = 1;
	while(1){
	  i++;
	  if(str[i] < '0' || str[i] > '9') break;
	  j++;
	}
	while(j > 0){
	  num += (str[i - j] - '0') * pow(10, j - 1);
	  j--;
	}
      }
    }
  }
  printf("%d\n", num);
  return 0;
}

Measured memory_bytes: 580
n,y = list(map(int,input().split()))
cnt = 0
a = y//10000+1
for i in range(a):
  for j in range(n-i+1):
    k = n-i-j
    if k*1000+j*5000+i*10000==y and k>=0 and cnt==0:
      print(i,j,k)
      cnt += 1
      break
    else:
      continue
    break
      
if cnt == 0:
  print(-1,-1,-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int  even = 0;
int main() {
  int n, p;
  cin >> n >> p;
  rep(i,n) {
    int b; cin >> b;
    if (b % 2 == 0) even++;
  }

  ll ans = 1;
  rep(i,n) ans *= 2;
  if (even == n) {
    if (p == 0) cout << ans << endl;
    else cout << 0 << endl;
  }
  else {
    cout << ans / 2 << endl;
  }

  return 0;
}

Measured memory_bytes: 3636