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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 18, MAXV = 51;

int dp[1 << MAXN][MAXV];

int a[2][MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, 2) {
		REP(j, 0, n) {
			scanf("%d", &a[i][j]);
		}
	}
	REP(i, 0, 1 << n) {
		REP(j, 0, MAXV) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	REP(i, 0, 1 << n) {
		int cnt1 = 0;
		REP(k, 0, n) {
			if (i & (1 << k)) {
				cnt1++;
			}
		}
		REP(j, 0, MAXV) {
			if (dp[i][j] == INF) {
				continue;
			}
			int cnt0 = 0;
			REP(k, 0, n) {
				if (!(i & (1 << k))) {
					int v = a[(k ^ cnt1) & 1][k];
					if (v >= j) {
						dp[i | (1 << k)][v] = min(dp[i | (1 << k)][v], dp[i][j] + cnt0);
					}
					cnt0++;
				}
			}
		}
	}
	int ans = INF;
	REP(i, 0, MAXV) {
		ans = min(ans, dp[(1 << n) - 1][i]);
	}
	if (ans == INF) {
		ans = -1;
	}
	cout << ans << endl;
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

int n, m, r, c[10], d[205][(1 << 8) + 5], k[205], ta, tb, tc, td, te, tf;
vector< int > va[205], vb[205];
priority_queue< pair< int, pair< int, int > >, vector< pair< int, pair< int, int > > >, greater< pair< int, pair< int, int > > > > q;

int main() {
	scanf("%d%d%d", &n, &m, &r);
	for (int i = 0; i < r; i++) {
		scanf("%d", c + i);
		k[c[i]] = 1 << i;
		q.push(make_pair(d[c[i]][k[c[i]]] = 1, make_pair(c[i], k[c[i]])));
	}
	while (m--) {
		scanf("%d%d%d", &ta, &tb, &tc);
		va[ta].push_back(tb);
		va[tb].push_back(ta);
		vb[ta].push_back(tc);
		vb[tb].push_back(tc);
	}
	while (1) {
		ta = q.top().first;
		tb = q.top().second.first;
		tc = q.top().second.second;
		q.pop();
		if (ta == d[tb][tc]) {
			if (tc == (1 << r) - 1) {
				printf("%d\n", ta - 1);
				break;
			}
			for (int i = 0; i < va[tb].size(); i++) {
				te = va[tb][i];
				tf = tc | k[te];
				td = ta + vb[tb][i];
				if (!d[te][tf] || td < d[te][tf]) {
					d[te][tf] = td;
					q.push(make_pair(td, make_pair(te, tf)));
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5620
import numpy as np
#import numpy as np
import itertools
n = int(input())
a = []
for i in range(n):
    a.append(input())
# [d1, d2, d3, ..., dN]
a = [int(m) for m in a]

a.sort()
if n % 2 == 0:
    small = []
    big = []
    for i in range(n):
        if i < n // 2:
            small.append(a[i])
        else:
            big.append(a[i])
    print(2 * (sum(big) - sum(small)) - big[0] + small[n // 2 - 1])
else:
    small = []
    big = []
    for i in range(n):
        if i < n // 2:
            small.append(a[i])
        elif i > n // 2:
            big.append(a[i])
    print(max(2 * (sum(big) - sum(small)) - big[0] + a[n // 2], 2 * (sum(big) - sum(small)) + small[n // 2 - 1] - a[n // 2]))

Measured memory_bytes: 23444
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    string S;
    cin >> S;
    ll zero = 0;
    ll one = 0;
    rep(i,S.length()){
        if(S[i]=='0') zero++;
        else one++;
    }
    cout << min(zero,one)*2 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = 0, y = 0;
  while (c > 0) {
    c -= b;
    x++;
  }
  while (a > 0) {
    a -= d;
    y++;
  }
  if (y >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main(){
  string s,t;cin>>s>>t;int n = s.length(),m = t.length();
  int dp[3010][3010];rep(i,3010)rep(j,3010)dp[i][j] = 0;
  repd(i,1,n+1){
    repd(j,1,m+1){
      if(s[i-1] == t[j-1])dp[i][j] = dp[i-1][j-1] + 1;
      else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
  int i = n, j = m;
  string ans = "";
  while(i > 0 && j > 0){
    if(dp[i][j] == dp[i - 1][j]){
      i--;
    }else if(dp[i][j] == dp[i][j - 1]){
      j--;
    }else{
      i--;j--;ans = s[i] + ans;
    }
  }
  cout << ans << endl;
}

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

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

    vector<int> vec(N);

    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    int count = 0;
    int minj = 0;

    for (int i = 0; i < N; i++) {
        minj = i;

        for (int j = i; j < N; j++) {
            if(vec.at(j) < vec.at(minj)) {
                minj = j;
            }
        }

        if(i != minj) {
            swap(vec.at(i), vec.at(minj));

            count++;
        }
        
    }

    for (int k = 0; k < N; k++) {
        if(k == N - 1) {
            cout << vec.at(k);
        } else {
            cout << vec.at(k) << " ";
        }
    }

    cout << endl;

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3092
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N, K = splitintinput()
p = listintinput()
tmpsum = 0
maxsum = 0
tmp = 0
for i in range(K):
    tmpsum += p[i]
maxsum = tmpsum
for i in range(K,N):
    tmpsum = tmpsum - p[i-K] + p[i]
    if tmpsum > maxsum:
        tmp = i
        maxsum = tmpsum

print((maxsum+K)/2)


Measured memory_bytes: 26248
n = int(input())
a_list = list(map(int, input().split()))
a_list = sorted(a_list, reverse=True)

alice_point = 0
bob_point = 0
for i in range(n):
    if i % 2 == 0:
        alice_point += a_list[i]
    else:
        bob_point += a_list[i]

print(alice_point - bob_point)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int S = Integer.valueOf(line);
        int h = S/3600;
        int m = S%3600/60;
        int s = S%60%60;
        String time = String.format("%s:%s:%s",h,m,s);
        System.out.println(time);
    }
}

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

using namespace std;

int main()
{
  int l,r,d;
  cin>>l>>r>>d;
  int count = 0;
  for(int i = l;i<=r;i++)
  {
    if(i % d == 0)
      count++;
  }
  
  cout<<count;
  
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,flag;
  cin>>n;
  for(int i=1;i<10;i++)
  {
    if((n/i)>10 && (n%i)==0)
      flag=1;
    else if((n/i)<10 && (n%i)==0)
      flag=0;
    else continue;
  }
  if(flag==1)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  string s;
  cin >> s;
  REP(i,3) printf("%c", s[i]=='1' ? '9' : '1');
  puts("");
  return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();
    int n, sum= 0;
    cin>> n;

    int a[n], t;


    for(int i=0; i<n; i++)
        cin>> a[i];

    for(int i=0; i<n; i++)
    {
        cin>> t;

        if(a[i]>t)
            sum+= (a[i]-t);
    }


    cout << sum;
    nl;

    return 0;
}




Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int a,b;
string n;
int main()
{
	cin>>a>>b;
	for(int s=0;s<b+2;s++)cout<<"#";
	cout<<endl;
	for(int s=0;s<a;s++)
	{
		cout<<"#";
		cin>>n;
		cout<<n<<"#"<<endl;
	}
	for(int s=0;s<b+2;s++)cout<<"#";
	cout<<endl;
}


Measured memory_bytes: 3540
H, W = gets.split.map(&:to_i)
S = []
S[0] = Array.new(W+2,".")

H.times {
  newArray = Array.new(1, ".")
  S << newArray + gets.chomp.split("") + newArray
}
S << Array.new(W+2,".")

judge = "Yes"

H.times do |i|
  W.times do |j|
    if S[i+1][j+1] == "#" then
      #p [i+1, j+1]
      count = 0
      if S[i][j+1] == "#"
        count += 1
      end
      if S[i+1][j] == "#"
        count += 1
      end
      if S[i+1][j+2] == "#"
        count += 1
      end
      if S[i+2][j+1] == "#"
        count += 1
      end
      if count == 0
        judge = "No"
      break
      end
      #p [i, j]
      #p count
    end
  end
  if judge == "No"
    break
  end
end
  
puts judge

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

using namespace std;

const int N = 22, M = (1<<22), MOD = 1e9 + 7;
int dp[N][M], n, a[N][N];

inline int add(int a, int b){
	a += b;
	if(a >= MOD)a -= MOD;
	return a;
}

inline int sub(int a, int b){
	a -= b;
	if(a < 0)a += MOD;
	return a;
}

int find(int id, int mask){
	if(id < 0)return mask == 0;
	if(dp[id][mask] != -1)return dp[id][mask];

	dp[id][mask] = 0;
	for(int i=0;i<n;++i)if((mask & (1<<i)) && a[id][i])
		dp[id][mask] = add(dp[id][mask], find(id - 1, mask ^ (1<<i)));

	return dp[id][mask];
}

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

	cin>>n;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)cin>>a[i][j];

	for(int i=0;i<n;++i)
		for(int mask=0;mask < (1<<n); ++mask)
			dp[i][mask] = -1;

	cout<<find(n - 1, (1<<n) - 1)<<"\n";
	return 0;
}

Measured memory_bytes: 213248
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define in cin >>
#define out cout <<
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


ll modpow(ll a,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1)res=a*res%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}



int main(){
    string s;
    cin >> s;
    int now=1;
    int l=s.length();
    int a[l];
    

    rep(i,l-1){
      if(i==0){
        a[i]=s[l-1]-'0';
       }else{
        now=(now*10)%2019;
        a[i]=((a[i-1]+now*(s[l-i-1]-'0'))%2019);
       
        }
    }
    vector<int> v(l);
    rep(i,l-1){
      v[i]=a[i];
    }
    sort(v);
    int n=v.size();
  int k=1;
  int i=1;
  bool bl=true;
  vector<int> ans;
    int as=0;
    for(int i=0;i<n;i++){
      if(v[i]==0)as++;
    }
    while(true){
    while(bl){
        if(v[i-1]==v[i]){
        k++;    
      }else{
          bl=false;
      }
      i++;
      }
     // cout << 'k' << k << endl;
      ans.push_back(k);
      if(i>=(n-1))break;
      k=1;
      bl=true;
    }
    for(int i=0;i<ans.size();i++){
      //  cout << ans[i] << endl;
    }
    for(int i=0;i<ans.size();i++){
      as=as+(ans[i]-1)*ans[i]/2;
    }
    cout <<  as;
    }
    


Measured memory_bytes: 4424
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			boolean[][] canMeet = new boolean[30][n];
			for (int i = 0; i < 30; i++)
				for (int j = 0; j < n; j++)
					canMeet[i][j] = false;
			for (int i = 0; i < n; i++) {
				int t = sc.nextInt();
				for (int j = 0; j < t; j++) {
					canMeet[sc.nextInt() - 1][i] = true;
				}
			}
			boolean[][] hasMaps = new boolean[n][n];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					hasMaps[i][j] = false;
			for (int i = 0; i < n; i++)
				hasMaps[i][i] = true;
			int result = -1;
			for (int t = 0; t < 30; t++) {
				ArrayList<Integer> meetList = new ArrayList<Integer>();
				for (int i = 0; i < n; i++) {
					if (canMeet[t][i]) {
						meetList.add(i);
					}
				}
				Set<Integer> mapsSet = new HashSet<Integer>();
				for (Integer i : meetList) {
					for (int j = 0; j < n; j++) {
						if (hasMaps[i][j]) {
							mapsSet.add(j);
						}
					}
				}
				for (Integer i : meetList)
					for (Integer j : mapsSet) {
						hasMaps[i][j] = true;
					}
				if (mapsSet.size() == n) {
					result = t + 1;
					break;
				}
			}
			System.out.println(result);
		}
		sc.close();
	}
}

Measured memory_bytes: 85048
import math
const=3500+1
N = int(input())
ans=4/N
flg=False
for h in range(int(N/4),const):
    for n in range(h,const):
        tmp=4*h*n-N*n-N*h
        if tmp != 0:
            w = N*h*n/tmp
            if w == int(w) and w>0:
                print(h,n,int(w) )
                flg=True
                break
    if flg==True:
        break



Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int N;

int main(){
	S(N);
	map<int, int> m;
	R(i, N) {
		int a;
		S(a);
		if (m.find(a) == m.end()) m.emplace(a, 1);
		else m[a]++;
	}
	int ans = 0;
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if (itr->first > itr->second) ans += itr->second;
		else if (itr->second > itr->first) ans += itr->second - itr->first;
	}
	P(ans);
} 

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

using namespace std;

int main() {

	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(9) << sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
}


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

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    x,a,b = LI()
    n = I()
    ans = x
    for _ in range(n):
        s = input()
        if s == "nobiro":
            if ans + a >= 0:
                ans += a
            else:
                ans = 0
        elif s == "tidime":
            if ans + b >= 0:
                ans += b
            else:
                ans = 0
        else:
            ans = 0
    print(ans)
    return

if __name__ == "__main__":
    solve()



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

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

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

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

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

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

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


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



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

	vector<ll> D(N + 1);
	repn(i, N) cin >> D[i];

	vector<pair<ll, ll>> Dp(N + 1);
	repn(i, N) Dp[i] = { D[i],i };

	sort(++Dp.begin(), Dp.end());

	vector<vector<edge>> g(N + 1);

	repn(i, M) {
		ll u, v;
		cin >> u >> v;
		g[u].push_back({i,u,v,0});
		g[v].push_back({i,v,u,0});
	}

	ll b = 1;
	
	repn(v, N) {
		
		ll bb = 0;
		for (edge e : g[v]) {
			ll w = e.to;
			if (D[w] <= D[v]) { bb = 1; }
		}

		if (bb == 0) { b = 0; break; }
	}

	if (b == 0) { cout << -1; }

	else {
		vector<ll> s(N + 1,-1);
		vector<ll> C(M + 1,1000000000);

		repn(i, N) {
			ll v = Dp[i].second;

			if (s[v] != -1) { continue; }

			ll u = 0;
			for (edge e : g[v]) {
				ll w = e.to;
				if (s[w] != -1) {
					u = w;
					s[v] = (s[u] + 1) % 2;
					C[e.ind] = D[v];
					break;
				}
			}


			if (u == 0) {
				s[v] = 0;

				for (edge e : g[v]) {
					ll w = e.to;
					if (D[v] == D[w]) {
						s[w] = 1;
						C[e.ind] = D[v];
						break;
					}
				}
			}
		}

		repn(i, N) {
			if (s[i] == 0) { cout << 'B'; }
			else { cout << 'W'; }
		}
		cout << endl;

		repn(i, M) {
			cout << C[i] << endl;
		}

	}
	system("PAUSE");
}


Measured memory_bytes: 27136
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC096D()
{
	constexpr int M = 55555;
	int N;
	cin >> N;

	vector<int> x(M + 1);
	for (int i = 2; i <= M; ++i)
	{
		if (x[i] == 1)
			continue;
		int k = 2 * i;
		while(k <= M)
		{
			x[k] = 1;
			k += i;
		}
	}
	set<int> prime;
	for (int i = 2; i <= M; ++i)
	{
		if (x[i] == 0)
			prime.insert(i);
	}
	vector<int> ret;
	for (auto& y : prime)
	{
		if (y % 5 == 1)
			ret.push_back(y);
		if (ret.size() == N)
		{
			for (int i = 0; i < N; ++i)
			{
				cout << ret[i];
				if (i < N - 1)
					cout << ' ';
			}
			cout << endl;
			return;
		}
	}
}
int main()
{
	ABC096D();
	return 0;
}

Measured memory_bytes: 768
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

int n, players[1000][1000], day;
int cur[1000];
vector<pair<int, int>> v;

void check(int id) {
    int tgt;
    if (cur[id] == n-1) return;
    tgt = players[id][cur[id]];
    if (cur[tgt] == n-1) return;
    if (players[tgt][cur[tgt]] == id) {
        pair<int, int> p;
        p.first = min(id, tgt);
        p.second = max(id, tgt);
        v.push_back(p);
    }
}
int main(void) {
    int i, j, tgt, day=0;
    cin >> n;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n-1; j++) {
            cin >> players[i][j];
            players[i][j]--;
        }
    }
    for (i = 0; i < n; i++) {
        check(i);
    }
    while (v.size() != 0) {
        day++;
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        vector<pair<int, int>> preV;
        swap(preV, v);
        for (auto p : preV) {
            cur[p.first]++;
            cur[p.second]++;
        }
        for (auto p : preV) {
            check(p.first);
            check(p.second);
        }
    }
    for (i = 0; i < n; i++) {
        if (cur[i] != n-1) {
            puts("-1");
            return 0;
        }
    }
    cout << day << endl;
    return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<math.h>

typedef struct{
  int h;
  int w;
  double r;
}Date;

int main(){
  int i,j,k;
  int h,w;
  double r;
  Date A[100000];
  double flag;
  Date ans;
  
  while(1){
    k=0;
    flag=1000000;
    scanf("%d %d",&h,&w);
    if(h==0&&w==0)break;

    r=sqrt(h*h+w*w);
  
    for(i=1;i<=150;i++){
      for(j=i+1;j<=150;j++){
	A[k].r=sqrt(i*i+j*j);
	if(A[k].r==r&&i>h){
	  A[k].h=i;
	  A[k].w=j;
	  k++;
	}else if(r<A[k].r&&A[k].r<flag){
	  A[k].h=i;
	  A[k].w=j;
	  flag=A[k].r;
	  k++;
	}
      }
    }
    for(i=0;i<k;i++){ 
      if(i==0){
	ans.h=A[0].h;
	ans.w=A[0].w;
	ans.r=A[0].r;
      }else{
	if(ans.r>A[i].r){
	  ans.h=A[i].h;
	  ans.w=A[i].w;
	  ans.r=A[i].r;
	}else if(ans.h>A[i].h){
	  ans.h=A[i].h;
	  ans.w=A[i].w;
	  ans.r=A[i].r;
	}
      }
    }
    printf("%d %d\n",ans.h,ans.w);  
  }
  
  return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],B[lim],C[lim];
// map<lld,lld> M;

int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc(n);
    curr = 0;
    while(curr <= n) {
        if((n - curr) % 4 == 0) {
            printf("Yes\n");
            return 0;
        }
        curr += 7;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#define DEBUG 0

/**
 * File    : B2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-5-21 22:10:05
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int H, W, N;
int sr, sc;
string S, T;

int main()
{
  cin >> H >> W >> N >> sr >> sc >> S >> T;
  int left = 0;
  int right = W - 1;
  int up = 0;
  int down = H - 1;
  sr--;
  sc--;
  reverse(T.begin(), T.end());
  reverse(S.begin(), S.end());
  for (auto i = 0; i < N; i++)
  {
    if (T[i] == 'L' && right < W - 1)
    {
      right++;
    }
    else if (T[i] == 'R' && left > 0)
    {
      left--;
    }
    else if (T[i] == 'U' && down < H - 1)
    {
      down++;
    }
    else if (T[i] == 'D' && up > 0)
    {
      up--;
    }
    if (S[i] == 'L')
    {
      left++;
    }
    else if (S[i] == 'R')
    {
      right--;
    }
    else if (S[i] == 'U')
    {
      up++;
    }
    else if (S[i] == 'D')
    {
      down--;
    }
    if (right < left || down < up)
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (left <= sc && sc <= right && up <= sr && sr <= down)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 776
from math import factorial
MOD = 10**9 + 7
n, m = map(int, input().split())
if n == m:
    print(2 * factorial(n)**2 % MOD)
elif n - 1 == m:
    print(n * factorial(m)**2 % MOD)
elif n == m - 1:
    print(m * factorial(n)**2 % MOD)
else:
    print(0)

Measured memory_bytes: 4736
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	double a, b;
	cin >> a >> b;
	if (!cin) return false;

	int n1 = ceil(a / 0.08);
	int n2 = ceil(b / 0.1);

	bool c1 = false, c2 = false;
	if (floor(n1 * 0.10) == b) c1 = true;
	if (floor(n2 * 0.08) == a) c2 = true;

	if (c1 && c2) cout << min(n1, n2);
	else if (c1) cout << n1;
	else if (c2) cout << n2;
	else cout << "-1";
	cout << '\n';


	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    int A,B,M; cin >> A >> B >> M;
    int a[A],b[B],mina,minb;
    mina = minb = 1000000;
    for (int i = 0; i < A; i++)
    {
        cin >> a[i];
        mina = min(mina,a[i]);
    }
    for (int i = 0; i < B; i++)
    {
        cin >> b[i];
        minb = min(minb,b[i]);
    }
    int ans = mina+minb;
    for (int i = 0; i < M; i++)
    {
        int x,y,c;
        cin >> x >> y >> c;
        ans = min(ans,a[x-1]+b[y-1]-c);
    }
    cout << ans << endl;

}

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int n; cin >> n;
	int p = 1;
	for(int i = 1, i_len = (int)n; i <= i_len; ++i){
		p*=i;
		p%=MOD;
	}

	cout << p << endl;
	return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const double inf = 1e9;

const long double eps = 1e-8;

struct TDsu {
    vector<i64> dsu;

    void init(i64 size) {
        dsu.resize(size);

        for (i64 i = 0; i < size; i++) {
            dsu[i] = i;
        }
    }

    i64 find_set(i64 v) {
        if (v == dsu[v]) {
            return v;
        }
        return dsu[v] = find_set(dsu[v]);
    }

    void union_sets(i64 a, i64 b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            dsu[b] = a;
        }
    }
};


const i64 maxn = 1'000'000;

i64 n;
vector<i64> a;

void read_input(bool fake) {
    if (!fake) {
        cin >> n;
        a = vector<i64>(n);
        for (i64 i = 0; i < n; i++) {
            cin >> a[i];
        }
    }
    else {
        n = maxn;
        srand(time(0));
        for (i64 i = 0; i < n; i++) {
            a[i] = rand();
        }
    }
}


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    read_input(false);

    vector<set<i64>> primes(maxn + 7);
    
    for (i64 i = 2; i <= maxn; i++) {
        if (primes[i].size()) {
            continue;
        }
        primes[i].insert(i);
        for (i64 j = 2; i * j <= maxn; j++) {
            primes[i * j].insert(i);
        }
    }

    map<i64, i64> q;
    for (i64 i = 0; i < n; i++) {
        for (auto t : primes[a[i]]) {
            q[t] += 1;
        }
    }

    bool pairwise_coprime = true;
    bool setwise_coprime = true;

    for (auto t : q) {
        if (t.second > 1) {
            pairwise_coprime = false;
        }
        if (t.second == n) {
            setwise_coprime = false;
        }
    }


    if (pairwise_coprime) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    if (setwise_coprime) {
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;


    return 0;
}

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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, k;
vector<int> g[N];
pair<int, int> E[N];

bool read() {
    if (!(cin >> n >> k))
        return false;

    for (int i = 0; i < n - 1; ++i) {
        auto& u = E[i].first;
        auto& v = E[i].second;
        cin >> u >> v;
        --u, --v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    return true;
}

void dfs(int v, int pr, int& cnt, int h, int mxh) {
    if (h > mxh)
        return ;

    ++cnt;

    for (auto to : g[v])
        if (to != pr)
            dfs(to, v, cnt, h + 1, mxh);
}

int calc(int v, int pr, int mxh) {
    int cnt = 0;
    dfs(v, pr, cnt, 0, mxh);
    return cnt;
}

void solve() {
    auto ans = n;
    auto d = k / 2;

    for (int i = 0; i < n; ++i)
        ans = min(ans, n - calc(i, -1, d));

    d = (k - 1) / 2;

    for (int i = 0; i < n - 1; ++i)
        ans = min(ans, n - calc(E[i].first, E[i].second, d) - calc(E[i].second, E[i].first, d));

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



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

int main() {

    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = 0;
    if (X > Y) {
        ans = min(A * X + B * Y, (X - Y) * A + Y * 2 * C);
        ans = min(ans, (X - Y) * 2 * C + Y * 2 * C);
    } else {
        ans = min(A * X + B * Y, (Y - X) * B + X * 2 * C);
        ans = min(ans, (Y - X) * 2 * C + X * 2 * C);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
  int cnt=0;
  string s;
  cin>>s;
  char c=s[0];
  for(int i=1;i<s.length();i++){
    if(s[i]!=c){
      cnt++;
      c=s[i];
    }
  }
  cout<<cnt<<endl;

  return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

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

signed main(){
    int N;
    while( cin >> N, N ){
        vector<int> a( N );
        REP( i, N ) cin >> a[i];

        sort( ALL( a ) );

        int ans = INF;
        REP( i, N - 1 ){
            chmin( ans, a[i + 1] - a[i] );
        }
        cout << ans << endl;
    }
}



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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define mod 1000000007



int main(){
	
		fast
		int x;
		cin>>x;
		x?cout<<"0":cout<<"1";


	return 0;
}





Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

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

  cin >> N;

  for (int i = 0; i < N; ++i) {
    int l;
    cin >> l;
    L.push_back(l);
  }

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

  ll ans = 0;

  for (int i = 0; i < N - 2; ++i) {
    for (int j = i + 1; j < N - 1; ++j) {
      int sum = L[i] + L[j];
      if (sum <= L[j + 1]) continue;
      // if (sum <= L[N - 1]) continue;

      auto k = lower_bound(L.begin(), L.end(), sum);
      ll m = distance(k, L.end());

      ans += (N - 1 - j) - m;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

ll max1=2000000;
ll pri[200000];
ll vis[2000000]={0};

bool isprime(ll n)
{
    if(n==1) return false;
	for(ll i=2;i<=sqrt(n+0.5);i++)
		if(n%i==0) return false;
	return true;

}


int main()
{
	vis[1]=1;
	for(int i=2;i<=sqrt(max1+0.5);i++)
		for(int k=i*i;k<=max1;k+=i)
			if(!vis[k]) vis[k]=1;
	int cnt=0;
	for(int i=2;i<=max1;i++)
		if(!vis[i]) pri[cnt++]=i;
	ll n;
	cin >> n;
	map<ll , int > ans;
	for(int i=0;i<148933&&n>=pri[i];i++)
	{
	    int flag=0;
		int cnt=0;
		while(n%pri[i]==0)
		{
			n/=pri[i];
			cnt++;
			flag=1;
		}
		if(flag)ans[pri[i]]=cnt;
	}
	if(isprime(n)) ans[n]=1;
	cnt=0;
	for(map<ll , int> :: iterator it=ans.begin();it!=ans.end();it++)
	{
	    //cout << it->first << "  " << it->second << endl;
		int i;
		for(i=1;1;i++)
		{
			if(it->second<i*(i+1)/2)
			{
				cnt+=i-1;
				break;
			}
		}

	}
	cout << cnt;

	return 0;
}



Measured memory_bytes: 20512
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			boolean[][] map = new boolean[8][8];
			for(int i=0;i<8;i++) {
				String str = sc.next();
				for(int j=0;j<8;j++) map[i][j] = str.charAt(j) == '1';
			}
			
			System.out.println(search(map));
		}
	}
	
	String search(boolean[][]map) {
		for(int i=0;i<8;i++) for(int j=0;j<8;j++) if(map[i][j]){
			if(i+3<8 && map[i+3][j]) return "B";
			else if( j+3 < 8 && map[i][j+3]) return "C";
			else if( j-1 >= 0 && i+2 < 8 && map[i+2][j-1] ) return "D";
			else if( j+2 < 8 && i+1 < 8 && map[i+1][j+2] ) return "E";
			else if( j+1 < 8 && i+2 < 8 && map[i+2][j+1] ) return "F";
			else if( j+1 < 8 && i+1 < 8 && !map[i+1][j+1] ) return "G";
			else return "A";
		}
		return "";
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

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

  int res = N;
  int sum = 0;
  for(int i=8; i>0; i--){
    int keta = res/pow(10,i-1);
    if(keta==0){
      continue;      
    }
    sum += keta;
    res -= keta*pow(10,i-1);
  }

  if(N%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}

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

int digit(int N) {
    int digit = 1;
    while(N>=10) {
        N /= 10;
        digit++;
    }
    return digit;
}

int max_num(int n) {
    int max=1;
    if (n <= 0) {
        return 0;
    } else {
        for (int i=0; i<n; i++) {
            max *=10;
        }
        max--;
    }
    return max;
}

int main(int argc, char const *argv[]) {
    int N, digN, num=0;
    cin >> N;

    digN = digit(N);

    for (int i=digN; i>0; i--) {
        if (i%2 != 0) {
            if (i == digN) {
                num += N - max_num(i-1);
            } else {
                num += max_num(i) - max_num(i-1);
            }
        }
    }

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


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

int main()
{
    ll n;
    cin >> n;
    //何桁か判定
    int i;
    ll tmp = 0;
    for (i = 1; i <= 15; i++)
    { //最大でも15桁以下
        tmp += pow(26, i);
        if (n <= tmp)
            break;
    }
    //その桁の中で何番目か(0インデックス)？
    n = n - (tmp - pow(26, i)) - 1;
    //26進数に変換
    for (int j = i - 1; j >= 0; j--)
    {
        int a = n / (ll)pow(26, j);
        n = n % (ll)pow(26, j);
        char c = a + 97;
        cout << c;
    }
    cout << endl;
}

//26進数風？

Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zh=0xff0000,MAXN=1e6+10;
int n,k,m,fa[1005];


int main()
{
    int n,m,l,r,ll,rr;
    cin>>n>>m;
    l=1;
    r=n;
    for(int i=0;i<m;i++)
    {
        cin>>ll>>rr;
        r=min(rr,r);
        l=max(ll,l);
    }
    if(r-l>=0)
    cout<<r-l+1;
    else
        cout<<'0';
    return 0;
}


Measured memory_bytes: 384
from sys import stdin

def solve(n, k):
    # 1が出た場合，
    # 2^n >= kとなるまで連続で表を出す必要がある
    s = 0
    for dice in range(1, 1 + n):
        coin = 0
        while dice * (2 ** (coin - 1)) < k:
            coin = coin + 1
        # `dice` が出たときに勝てる確率
        coin = max(0, coin - 1)
        percentage = 1 / 2 ** coin
        s = s + 1 / n * percentage
    return s


def main():
    n, k = [int(n) for n in stdin.readlines()[0].strip().split(' ')]
    ans = solve(n, k)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

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

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

inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


std::vector<int> A, P, Q;

int main(void){
    int n; scanf("%d", &n);
    P.resize(n); REP(i, n) scanf("%d", &P[i]);
    Q.resize(n); REP(i, n) scanf("%d", &Q[i]);
    A.resize(n); REP(i, n) A[i] = i + 1;

    int a = -1, b = -1, c = 0;
    do{
        if(a == -1 and P == A) a = c;
        if(b == -1 and Q == A) b = c;
        c++;
    }while(std::next_permutation(A.begin(), A.end()) and (a == -1 or b == -1));

    printf("%d\n", (a > b) ? a - b : b - a);
    


    return 0;
}

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

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

	return 0;
}

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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {

    ll x;
    cin >> x;
    bool flag = false;
    int a,b;
    for(ll i=1000;i>=-1000;--i){
        for(ll j=1000;j>=-1000;--j) {
            if(pow(i,5)-pow(j,5) == x) {
                cout << i << " " << j << endl;
                return 0;
                
            }
        }
    }
}



Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    for(int i = 0;i < N;i++)
        cin >> T[i];
    int sum = accumulate(T.begin(),T.end(),0);
    int M;
    cin >> M;
    int p,x;
    vector<int> ans;
    for(int i = 0;i < M;i++)
    {
        cin >> p >> x;
        ans.push_back(sum - T[p - 1] + x);
    }
    for(int i = 0;i < (int)ans.size();i++)
        cout << ans[i] << '\n';
}

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

int main(){
  int n,S[10001],q,T[501],i,j,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
    }
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if(T[i]<0 || T[i]>1000000000){
      exit(8);
    }
  }
  
  //Linearsearch
  for(i=0;i<q;i++){
    for(j=0;j<n-1;j++){
      if(T[i]==S[j]){
	count++;
	break;
      }
    }
  }
  
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 640
#include<stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    return *(int *)a-*(int *)b;
}

int main()
{   int n;
    scanf("%d",&n);
    int a[n+1];
    a[n+1]=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),compare);
    
    int ans=0,cnt=1;
    for(int i=0;i<n;i++){
        if(a[i]==a[i+1]){
            cnt++;
        }else if(cnt%2==1){
            ans++;
            cnt=1;
        }else{
            cnt=1;
        }
        
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 892
N = int(input())
start = [0, 0, 0]
for _ in range(N):
    goal = list(map(int, input().split()))
    dif = abs(goal[1] - start[1]) + abs(goal[2] - start[2])
    time = goal[0] - start[0]
    if dif > time or (dif - time ) % 2 != 0:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 3064