akhauriyash/Code-Regression huggingface dataset:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    cnt = 0
    if n % 2 == 0:
        m = 1
        for i in range(1, n, 2):
            if not a[i] == a[i - 1] == m:
                print(0)
                exit()
            m += 2
            cnt += 1
    else:
        m = 0
        for i in range(0, n, 2):
            if i == 0:
                if not a[i] == m:
                    print(0)
                    exit()
            else:
                if not a[i] == a[i-1] == m:
                    print(0)
                    exit()
                cnt += 1
            m += 2
    print((2 ** cnt) % (10 ** 9 + 7))


if __name__ == '__main__':
    slove()


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

public class Main {

    private static List<Long> divisors(long n) {
        List<Long> list = new ArrayList<>();
        for (long i = 1; i * i < n; i++) {
            if (n % i != 0) {
                continue;
            }
            list.add(i);
            if (i != 1 && i * i != n) {
                list.add(n / i);
            }
        }
        return list;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        List<Long> divs = divisors(n);
        long ans = 0;
        for (long div : divs) {
            if (div > 1000000) {
                continue;
            }
            if (n > div * div + div) {
                ans += (n - div) / div;
            }
        }
        System.out.println(ans);
    }

}


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

int main() {
  int N;
  cin >> N;
  int rest = N;
  
  int divisor = 0;
  while (rest > 0) {
    int remainder;
    remainder = rest % 10;
    divisor += remainder;
    rest = (rest - remainder) / 10;
  }
  
  if (N % divisor == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	ll ct=0;
	cin >> n;
	ll sum=n-1;
	for(ll i=2;i<=sqrt(n);i++)
		if(n%i==0)
		{
			ll x=n/i;
			ll su=x+i;
			sum=min(sum,su-2);
		}
	cout << sum;
}

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

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	ll a,b;
	ll d;
	cin>>a>>b;

	d=a*b;

	if(d%2==0){
		cout<<"Even"<<endl;
	}else{
		cout<<"Odd"<<endl;
	}

	return 0;



}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/05/02.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC16８8
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const int MOD = 1000000007;
const double PI = 3.141592653589793;
//#define __DBG__



void solve(void){
  
  int A, B, H, M;
  
  cin >> A >> B >> H >> M;
  
  double RA = H * PI / 6 + M * PI /360;
  double RB = M * PI / 30;
  double COSTH = cos(abs(RA - RB));
  
  double C = sqrt(A*A+B*B-2*A*B*COSTH);
  
  cout << fixed;
  cout << setprecision(15) << C << endl;
  
  return;
}



#define TESTCASES 1

int main() {


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}




Measured memory_bytes: 4140
//lover~ crazy~
#include<bits/stdc++.h>
using namespace std;
int a[3005],n,ans;
int main() {
    cin>>n;
    for(int i=0;i<n;i++) {
    	cin>>a[i];
    	ans+=a[i];
	}
	cout<<ans-n;
	return 0;
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  rep(y, h){
    rep(x, w){
      if(s[y][x] == '.'){
        int ans = 0;
        if(y-1 >= 0 && s[y-1][x] == '#') ans++;
        if(y-1 >= 0 && x+1 < w && s[y-1][x+1] == '#') ans++;
        if(x+1 < w && s[y][x+1] == '#') ans++;
        if(x+1 < w && y+1 < h && s[y+1][x+1] == '#') ans++;
        if(y+1 < h && s[y+1][x] == '#') ans++;
        if(y+1 < h && x-1 >= 0 && s[y+1][x-1] == '#') ans++;
        if(x-1 >= 0 && s[y][x-1] == '#') ans++;
        if(x-1 >= 0 && y-1 >= 0 && s[y-1][x-1] == '#') ans++;
        cout << ans;
      }else{
        cout << '#';
      }
    }
    cout << endl;
  }
  return 0;
}

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

int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main(void) {
    int k, n, h[200000], sum = 0;
    int i, j, tmp, err;
    unsigned long long int ans = 0;

    err = scanf("%d", &n);
    err = scanf("%d", &k);

    for (i = 0; i < n; i++) {
        err = scanf("%d", &h[i]);
    }

    qsort(h, n, sizeof(int), compare_int);

    for (i = 0; i < n - k; i++) {
        ans += h[i];
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int mobile[][];
	static int n;
	static long weight[];

	public static long f(int id) {
		if (0 < weight[id]) {
			return weight[id];
		}

		long le = 1;
		long ri = 1;
		if (mobile[id][2] != 0) {
			le = f(mobile[id][2] - 1);
		}
		if (mobile[id][3] != 0) {
			ri = f(mobile[id][3] - 1);
		}

		long kle = 1;
		long kri = 1;
		while (true) {
			if (le * kle * mobile[id][0] == ri * kri * mobile[id][1]) {
				break;
			} else if (le * kle * mobile[id][0] < ri * kri * mobile[id][1]) {
				kle++;
			} else {
				kri++;
			}
		}

		return weight[id] = le * kle + ri * kri;
	}

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

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			mobile = new int[n][4];
			weight = new long[n];
			for (int i = 0; i < n; i++) {
				mobile[i][0] = sc.nextInt();
				mobile[i][1] = sc.nextInt();
				mobile[i][2] = sc.nextInt();
				mobile[i][3] = sc.nextInt();
			}
			Arrays.fill(weight, -1);
			for (int i = 0; i < n; i++) {
				f(i);
			}

			Arrays.sort(weight);
			System.out.println(weight[n - 1]);
		}
	}
}

Measured memory_bytes: 24004
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dpr(x) cerr<<#x<<": "<<x<<endl;
#define dprc(c) do{cerr<<#c<<":";for(auto&_i:(c)){cerr<<" "<<_i;}cerr<<endl;}while(0)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define rtr(i,c) for(auto i=(c).rbegin();i!=(c).rend();i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

#define MAX_N 110

class UnionFind {
public:
  UnionFind(size_t s) : parent_(s), rank_(s, 0) {
    for (size_t i = 0; i < s; i++) {
      parent_[i] = i;
    }
  }

  void unite(size_t x, size_t y) {
    size_t xp = find(x);
    size_t yp = find(y);

    if (xp == yp) return;
    if (rank_[xp] < rank_[yp]) {
      parent_[xp] = parent_[yp];
    } else {
      if (rank_[xp] == rank_[yp]) rank_[xp]++;
      parent_[yp] = parent_[xp];
    }
  }

  bool is_same(size_t x, size_t y) {
    return find(x) == find(y);
  }

  size_t find(size_t x) {
    if (parent_[x] == x) return x;
    else return parent_[x] = find(parent_[x]);
  }

  size_t size() const {
    return parent_.size();
  }

private:
  vector<int> parent_;
  vector<int> rank_;
};

struct edge {
  int w, v, u;
};

void printuf(UnionFind& uf) {
  for (int i = 0; i < sz(uf); i++) {
    fprintf(stderr, " %-2d", i);
  }
  puts("");
  for (int i = 0; i < sz(uf); i++) {
    fprintf(stderr, " %-2lu", uf.find(i));
  }
  puts("");
}

int main(int argc, char **argv)
{

  int n;
  scanf("%d", &n);

  vector<edge> E;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int x;
      scanf("%d", &x);
      if (i >= j) continue;
      edge e = {x, i, j};
      if (x >= 0) E.pb(e);
    }
  }

  sort(all(E), [=](const edge& lhs, const edge& rhs) { return lhs.w < rhs.w; });

  UnionFind S(n);

  int total = 0;

  for (int i = 0; i < sz(E); i++) {
    edge& e = E[i];

    int v = S.find(e.v);
    int u = S.find(e.u);

    if (v == u) continue;
    total += e.w;
    S.unite(e.v, e.u);
  }

  printf("%d\n", total);

  return 0;
}

Measured memory_bytes: 3348
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"
#include "boost/functional/hash.hpp"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

typedef long long ll;

const ll MOD = 1e9 + 7;

class ELeague {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<queue<pair<int,int>>> queues(N+1);
	    REP(i,1,N+1) {
	        REP(j,0,N-1) {
	            int e;
	            in >> e;
	            queues[i].push({min(i,e),max(i,e)});
	        }
	    }
	    int answer = -1;
	    queue<int> nexts;
	    unordered_set<pair<int,int>, boost::hash<pair<int,int>>> unmatched;
	    REP(i,1,N+1) nexts.push(i); // head elements
	    while (!nexts.empty()) {
	        const int s = nexts.size();
	        REP(i,0,s) {
	            const int next = nexts.front();
	            nexts.pop();
	            if (queues[next].empty()) continue;
                const auto p = queues[next].front();
                queues[next].pop();
                if (unmatched.find(p) != unmatched.end()) {
                    unmatched.erase(p);
                    nexts.push(p.first);
                    nexts.push(p.second);
                    continue;
                }
                unmatched.insert(p);
	        }
	        answer++;
	    }
	    if (!unmatched.empty()) {
	        out << -1 << "\n";
	        return;
	    }
        out << answer << "\n";
	}
};


signed main() {
	ELeague solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,k;
ll a[100001];
ll dp[2][100001];

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

  cin>>n>>k;
  rep(i,n)cin>>a[i];

  int crt=0,nxt=1;
  dp[0][0]=1;
  rep(i,n){
    memset(dp[nxt],0,sizeof(dp[nxt]));
    rep(j,k+1){
      if(j==0){
        (dp[nxt][j]+=dp[crt][j])%=mod;
      }else if(j-a[i]-1<0){
        (dp[nxt][j]+=dp[nxt][j-1]+dp[crt][j])%=mod;
      }else{
        (dp[nxt][j]+=dp[nxt][j-1]+(mod-dp[crt][j-a[i]-1])+dp[crt][j])%=mod;
      }
    }
    swap(crt,nxt);
  }
  cout<<dp[crt][k]<<endl;

  return 0;
}


Measured memory_bytes: 1792
def bisect(f, ok, err):
    while abs(ok - err) > 1:
        m = (ok + err) // 2
        if f(m):
            ok = m
        else:
            err = m
    return ok

def main():
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    A -= B
    def f(n):
        return sum((max(0,h-B*n)+A-1)//A for h in H) <= n
    print(bisect(f, 10**9+1, 0))

if __name__ == "__main__":
    main()

Measured memory_bytes: 7072
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9+5;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	for(int &x: h)
		cin >> x;
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0; i<n; ++i) {
		for(int j=i+1; j<=i+k; ++j) {
			if(j<n) {
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	cout << dp[n-1] << "\n";
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    W = 0
    E = 0
    for c in S:
        if c == 'W':
            W += 1
        else:
            E += 1
    w, e = 0, 0
    ret = float('inf')
    for i in range(N):
        tmp = w + E - e
        if S[i] == 'W':
            w += 1
        else:
            e += 1
            tmp -= 1
        ret = min(ret, tmp)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

ll xorsum(ll n){
    switch(n%4){
        case 0:return n;
        case 1:return 1;
        case 2:return n+1;
        case 3:return 0;
    }
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans=xorsum(b)^xorsum(a-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define desync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS                 0.00000001
#define LL_MAX              1e18
#define LL_MIN              -1e18
#define MAX                 0x3f3f3f3f
#define MIN                 -0x3f3f3f3f
#define MOD                 1000000007
#define DEBUG(x)            cout << '>' << #x << ':' << x << endl;
#define REP(i,n)            for(int i=0;i<(n);i++)
#define FOR(i,a,b)          for(int i=(a);i<=(b);i++)
#define FORD(i,a,b)         for(int i=(a);i>=(b);i--)
#define n1                  '\n'

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> pt;
typedef vector<pt> pol;

int h, w;
char mat[1001][1001];
ll dp[1001][1001];

ll power(ll b, int e) {
    ll res = 1;
    for ( ; e>0; e/=2) {
        if (e&1) res = res*b % MOD;
        b = b*b % MOD;
    }
    return res;
}

int main()
{
    desync
    cin >> h >> w;
    vector<string> ss(h);
    REP(i, h) cin >> ss[i];
    REP(i, h) REP(j, w) mat[i][j] = ss[i].at(j);
    REP(i, h) {
        if (mat[i][0] == '.') dp[i][0] = 1;
        if (mat[i][0] == '#') break;
    }
    REP(j, w) {
        if (mat[0][j] == '.') dp[0][j] = 1;
        if (mat[0][j] == '#') break;
    }
    
    FOR(i, 1, h-1) {
        FOR(j, 1, w-1) {
            if (mat[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
        }
    }
    
    cout << (dp[h-1][w-1] + MOD) % MOD << n1;
    return 0;
}


Measured memory_bytes: 10112
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())
abl = []
for _ in range(m):
    a,b = map(int,input().split())
    abl.append((a,b))

all_uf = UnionFind(n)
for a,b in abl:
    all_uf.union(a-1,b-1)
k = all_uf.group_count()

ans = 0
for i in range(m):
    uf = UnionFind(n)
    for a,b in abl[:i] + abl[i+1:]:
        uf.union(a-1,b-1)
    if k != uf.group_count():
        ans += 1

print(ans)



Measured memory_bytes: 3064
#include <cstdio>
#include <map>

typedef long long LL;
const int Mod[3] = {999988679, 999988609, 999988589};
const int B[3] = {370728, 370732, 370729};
const int iB[3] = {396903752, 462741403, 834141573};
const int MN = 250005;

inline void Add(int &x, int y, int i) { x -= (x += y) >= Mod[i] ? Mod[i] : 0; }

typedef std::tuple<int, int, int> i3;

int N;
char S[MN];
int A[3][MN], D[3][MN];
std::map<i3, int> Buk;
LL Ans;

int main() {
	scanf("%d%s", &N, S + 1);
	for (int j = 0; j < 3; ++j) A[j][0] = 0, D[j][0] = 1;
	for (int i = 1, V[3] = {1, 1, 1}; i <= N; ++i) {
		for (int j = 0; j < 3; ++j) {
			A[j][i] = A[j][i - 1];
			if (S[i] == '+') Add(A[j][i], V[j], j);
			if (S[i] == '-') Add(A[j][i], Mod[j] - V[j], j);
			if (S[i] == '>') V[j] = (LL)V[j] * B[j] % Mod[j];
			if (S[i] == '<') V[j] = (LL)V[j] * iB[j] % Mod[j];
			D[j][i] = V[j];
		}
	}
	for (int i = N; i >= 0; --i) {
		Ans += Buk[std::make_tuple(
			(A[0][i] + (LL)A[0][N] * D[0][i]) % Mod[0],
			(A[1][i] + (LL)A[1][N] * D[1][i]) % Mod[1],
			(A[2][i] + (LL)A[2][N] * D[2][i]) % Mod[2]
		)];
		++Buk[std::make_tuple(A[0][i], A[1][i], A[2][i])];
	}
	printf("%lld\n", Ans);
	return 0;
}

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

int main() {
  int N;
  int count = 0;
  cin >> N;
  for(int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      for (int k = 0; k < N; k++)
      {
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  int s=0,m=0;
  rep(i,n){
    int a; cin >>a; s+=a;
    if(a>m) m=a;
  }
  print((2*m<s)?"Yes":"No");
}


Measured memory_bytes: 256
package main

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

func main() {
	fmt.Println(abc174c(os.Stdin))
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func abc174c(r io.Reader) int {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)

	k := nextInt(sc)

	if k%2 == 0 {
		return -1
	}

	mod := 7 % k
	for i := 1; i <= k+1; i++ {
		if mod == 0 {
			return i
		} else {
			mod *= 10
			mod += 7
			mod %= k
		}
	}

	return -1
}


Measured memory_bytes: 1788
I=Hash[?A,0,?B,1,?C,2,?D,4,?E,5,?F,6,?G,8,?H,9,?I,10]
$<.each{|p|p.chop.chars.each_cons(2){|f,t|d=(I[f]-I[t]).abs;p=nil if d!=1&&d!=4};puts p if p}

Measured memory_bytes: 6108
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
p = factorization(N)
def cou(n):
    temp = n
    count = 1
    out = 0
    while temp - count >= 0:
        temp -= count
        count += 1
        out += 1
    return out

ans = []

for i in range(len(p)):
    ans.append(cou(p[i][1]))

answer = 0 if N == 1 else sum(ans)
print(answer)


Measured memory_bytes: 9504
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int N;
  cin >> N;
  cout << (N/3) << endl;


  return 0;
}


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

def solve(inlist):
    if inlist == []:
        return []
    else:
        p = max([ i for i, v in enumerate(inlist,1) if i == v ])
        new_list = [ v for i, v in enumerate(inlist,1) if i != p ]
        return solve(new_list) + [p]

if all([ v <= i for i, v in enumerate(num,1) ]):
    for i in solve(num):
        print(i)
else:
    print(-1)


Measured memory_bytes: 39024
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int INF = 10000000;

int cast(int e)
{
	
	

	 int Min = INF;

	 for(int i = 0;i*i*i <= e;i++)
	 {
		 for(int j = 0;j*j <= e-i*i*i;j++)
		 {
			 int k = e - i*i*i - j*j;
			 if(k >= 0)
			 {
				Min = min(i+j+k,Min);
			 }else
			 {
				 break;
			 }
		 }
	 }


	return Min;
}


int main()
{

  while(1)
  {
	 int e;

	 cin >> e;
 
	 if(!e)break;
	
	 cout << cast(e) << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	private void doit() {
		while (true) {
			int n = sc.nextInt();
			if(n == 0) break;
			int m = sc.nextInt();
			int sum = 0;
			while(m-- > 0){
				int start = sc.nextInt();
				int end = sc.nextInt();
				sum += end - start;
			}
			System.out.println(sum >= n ? "OK" : n - sum);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

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

#define pb push_back
#define mp make_pair

using namespace std;

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

int main() {
  string o;
  string e;

  cin >> o >> e;

  for (int i = 0; i < e.size(); ++i) {
    cout << o.at(i) << e.at(i);
  }

  if (o.size() > e.size()) {
    cout << o.at(o.size()-1);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args) {
        var spl = Console.ReadLine().Split(' ');
        int a = int.Parse(spl[0]);
        int b = int.Parse(spl[1]);
        
        Console.WriteLine(process(a,b));
        //Console.ReadLine();
    }

    static string process(int a, int b) {
        if ((a + b) % 2 == 0) return ((a + b) / 2).ToString();
        else return "IMPOSSIBLE";
    }
}

Measured memory_bytes: 11092
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
using ll = long long;
//----------------------------------------------
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define putout(x) cout<<x<<endl
//----------------------------------------------



int main()//
{
	ll l, r;
	cin >> l >>r;

	if (r - l >= 2019)
	{
		putout(0);
	}
	else
	{
		int ans = 1e9;
		for (int i = l; i <= r; i++)
		{
			for (int j = i + 1; j <= r; j++)
			{
				int ii = i % 2019;
				int jj = j % 2019;
				ans = min(ans, (ii * jj) % 2019);
			}
		}
		putout(ans);
	}

	

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main() {
    int a, b, c, k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if (k <= a) printf("%d",k);
    else if (k <= a+b) printf("%d",a);
    else printf("%d",a-(k-a-b));
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char x;
  cin >> x;
  if( x == 'a' || x == 'i' ||  x == 'u' || x == 'e' || x == 'o') {
    cout << "vowel" << endl;
  }
  else {
  cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
	int takasa[10];
	for(int i=0;i<10;i++){
		cin>>takasa[i];
	}
	for(int i=0;i<9;i++){
		for(int j=i+1;j<10;j++){
			if(takasa[i]<takasa[j]){
				swap(takasa[i],takasa[j]);
			}
		}
	}
	for (int i=0;i<3;i++){
		cout<<takasa[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
{-# LANGUAGE FlexibleContexts #-}

import Data.Array.ST
import Data.Array
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Applicative

type UnionFindST s = STArray s Int (Int,Int)

newUFST :: Int -> ST s (UnionFindST s)
newUFST n = newListArray (1,n) (zip [1..n] (repeat 1))

findUFST :: Int -> UnionFindST s -> ST s Int
findUFST x uf = do
  (parent,size) <- readArray uf x
  if parent == x then
    return x
    else do
    next <- findUFST parent uf
    writeArray uf x (next,size)
    return next

sameUFST :: Int -> Int -> UnionFindST s -> ST s Bool
sameUFST x y uf = do
  xx <- findUFST x uf
  yy <- findUFST y uf
  return $ xx == yy

uniteUFST :: Int -> Int -> UnionFindST s -> ST s ()
uniteUFST x y uf = do
  xx <- findUFST x uf
  yy <- findUFST y uf
  (_,xs) <- readArray uf xx
  (_,ys) <- readArray uf yy

  if xx == yy then
    return ()
    else if xs < ys then do
    writeArray uf xx (yy,0)
    else if xs > ys then do
    writeArray uf yy (xx,0)
    else do
    writeArray uf yy (xx,0)
    writeArray uf xx (xx,xs+1)

type Node = Int
type Cost = Int
type Edge = (Node, Node, Cost)

kruskal :: [Node] -> [Edge] -> [Edge]
kruskal nodes edges = runST $ do
  let sorted = sortBy (\(_,_,c1) (_,_,c2) -> compare c1 c2) edges
  uf <- newUFST (length nodes)
  execStateT (kruskal' uf sorted) []
  where
    kruskal' _ [] = return ()
    kruskal' uf (e@(i,j,c):rest) = do
      isSame <- lift $ sameUFST i j uf
      unless isSame $ do
        lift $ uniteUFST i j uf
        modify (e:)
      kruskal' uf rest

listToTuple2 (a:b:_) = (a,b)

main = do
  n <- readLn :: IO Int
  nodes <- zip [1..] . map (listToTuple2 . map (fst . fromJust . BS.readInt) . BS.words) . BS.lines <$> BS.getContents :: IO [(Int,(Int,Int))]

  
  let roads = map (\((n1,d1),(n2,d2)) -> (n1,n2,dist d1 d2)) $ f (sortBy (comparing (fst . snd)) nodes) ++ f (sortBy (comparing (snd . snd)) nodes)

  print $ sum . map (\(_,_,x) -> x) $ kruskal [1..n] roads

  where
    f (_:[]) = []
    f (x:y:xs) = (x,y) : f (y:xs)
    dist (x1,y1) (x2,y2) = min (abs $ x1-x2) (abs $ y1-y2)



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

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, m;
    cin >> n >> m;
    if (n == 1 or m == 1) cout << 1 << endl;
    else cout << ((n+1)/2)*((m+1)/2) + (n-(n+1)/2)*(m-(m+1)/2) << endl;
    return 0;
}



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

//============================================================================
#define PI 3.14159265359
#define succ(x) ((x)+1)
#define pred(x) ((x)-1)
//============================================================================
enum {bld1ST, bld2ND, bld3RD, bld4TH, bldEND};
enum {flr1ST, flr2ND, flr3RD, flrEND};
enum {rm1ST, rm2ND, rm3RD, rm4TH, rm5TH, rm6TH, rm7TH, rm8TH, rm9TH, rm10TH, rmEND};
//============================================================================
void enter(FILE *file)
{
    int i,n,b,f,r,v; char room[bldEND][flrEND][rmEND];

    memset(room, 0, sizeof(room));
    fscanf(file, "%d", &n);
    for (i=0; i<n; i++){
        fscanf(file, "%d", &b);
        fscanf(file, "%d", &f);
        fscanf(file, "%d", &r);
        fscanf(file, "%d", &v);
        room[pred(b)][pred(f)][pred(r)]+=v;
    }
    for (b=0; b<bldEND; b++){
      for (f=0; f<flrEND; f++){
        for (r=0; r<rmEND;  r++){
           printf(" %d", room[b][f][r]);
        }
         printf("\n");
      }
      if (b!=pred(bldEND)){
        for (i=0; i<20; i++) printf("#");
        printf("\n");
      }
    }  
}
//============================================================================
#ifndef DESKTOP
int main(void)
{
    enter(stdin);
    return 0;
}
#endif
//============================================================================

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    long long K; cin >> K;
    int A[N];
    for(int i=0;i<N;i++)
        cin >> A[i];

    bool dp[K+1]={};
    for(int i = A[0]; i <= K; i++){
        bool res = false;
        for(int j=0;j<N;j++){
            int val = i - A[j];
            if(val < 0) break;
            if(!dp[val]) res = true;
        }
        dp[i] = res;
    }
    if(dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 998244353;
typedef long long LL;

// ----------- VECTOR ------------
template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
// ----------- VECTOR ------------
//

LL modpow(LL a, LL b) {
  LL r = 1;
  while (b) {
    if (b % 2 == 1) r = r * a % kMod;
    a = a * a % kMod;
    b /= 2;
  }
  return r;
}

LL invmod(LL a) {
  return modpow(a, kMod - 2);
}

class Comb {
 public:
  Comb(int n) {
    fact.resize(n + 1);
    finv.resize(n + 1);
    inv.resize(n + 1);

    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < n; i++){
        fact[i] = fact[i-1] * i % kMod;
        inv[i] = kMod - inv[kMod%i] * (kMod / i) % kMod;
        finv[i] = finv[i-1] * inv[i] % kMod;
    }
  }

  LL nCr(int n, int r) const {
    LL numerator = fact[n];
    LL denominator = finv[r] * finv[n-r] % kMod;
    return (numerator * denominator) % kMod;
  }

 private :
  vector<LL> fact;
  vector<LL> inv;
  vector<LL> finv;
};

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

  if (N == 1) {
    cout << M << endl;
    return 0;
  }

  vector<LL> f(N);
  f[0] = M;
  for (LL i = 1; i < N; ++i) {
    f[i] = (M-1)*f[i-1] % kMod;
  }

  Comb C(N);

  LL sum = 0;
  for (int k = 0; k <= K; ++k) {
    LL v = f[N-k-1] % kMod;
    LL c = C.nCr(N-1, k) % kMod;
    v = (v * c) % kMod;
    sum = (sum + v) % kMod;
  }
  cout << sum << endl;
}


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

int main(){
    int a,b;
    cin >> a >> b ;
    if (a < b) {
        cout << "a < b" << "\n";
    }else if(a > b){
        cout << "a > b"<< "\n";
    }else{
        cout << "a == b"<< "\n";
    }
    return 0;
}


Measured memory_bytes: 2984
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <map>
#include <cstring>
using namespace std;

const int dx[2][6] = {
    {-1, 0, -1, 1, -1, 0},
    {0, 1, -1, 1, 0, 1}
};
const int dy[2][6] = {
    {-1, -1, 0, 0, 1, 1},
    {-1, -1, 0, 0, 1, 1}
};

int m, n;
pair<int,int> bloc[100][100], tmp[100][100];

void dfs(int idx, int x, int y, int dist) {
    if (dist < bloc[y][x].second) {
        bloc[y][x] = make_pair(idx, dist);
        int k = y%2;
        for (int i=0; i<6; ++i) {
            if (0 <= x+dx[k][i] && x+dx[k][i] < m &&
                0 <= y+dy[k][i] && y+dy[k][i] < n) {
                dfs(idx, x+dx[k][i], y+dy[k][i], dist+1);
            }
        }
    } else if (idx != bloc[y][x].first && dist == bloc[y][x].second) {
        bloc[y][x] = make_pair(-1, dist);
    }
}

int main() {
    while (cin >> m >> n, (m || n)) {
        for (int i=0; i<100; ++i) for (int j=0; j<100; ++j) {
            bloc[i][j] = make_pair(INT_MAX, INT_MAX);
        }
        int s;
        cin >> s;
        int x, y;
        for (int i=0; i<s; ++i) {
            cin >> x >> y;
            dfs(i, x-1, y-1, 0);
        }
        int t;
        cin >> t;
        int p, q, res = 0;
        for (int i=0; i<t; ++i) {
            cin >> p >> q;
            memcpy(tmp, bloc, sizeof bloc);
            dfs(s, p-1, q-1, 0);
            int cnt = 0;
            for (int i=0; i<n; ++i) {
                for (int j=0; j<m; ++j) {
                    if (bloc[i][j].first == s) {
                        ++ cnt;
                    }
                }
            }
            res = max(res, cnt);
            memcpy(bloc, tmp, sizeof tmp);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1468
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
const long int MAXN = 1e5+100;

li power(li a, li b, li mod) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li powerinv(li a)
{
  return power(a,mod-2,mod);
}

li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

bool isprime(li n)
{
  if (n == 1)
    return false;
  int i = 2;
  while (i*i <= n){
      if (n % i == 0)return false;
      i += 1;
  }
  return true;
}

li lcm(li a,li b)
{
    return ((a*b)/__gcd(a,b));
}

// vector<li> G[MAXN];
// li visited[MAXN];
 
// void dfs(li n,li num)
// {
// 	visited[n] = 1; //visited this node set to true
// 	for(auto it : G[n])
// 	{
// 		dfs(it,n);
// 	}
// }

void solve()
{
	string str;
	cin>>str;

	li sum = 0;
	for(li i=0;i<size(str);i++)
	{
		sum+=(str[i]-'0');
	}

	if(sum%9)
		cout<<"No\n";
	else
		cout<<"Yes\n";
}	

int main()
{	
	IOS;

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	solve();
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int n;
int a[200100];
bool pp[1001000];
bool used[1001000];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)
	{
		if(used[a[i]]==1)
		{
			pp[a[i]]=1;
		}
		used[a[i]]=1;
		if(pp[a[i]]==0)for(int j=a[i]*2;j<=1000000;j+=a[i])
				pp[j]=1;
	}
	int ans=0;
	rep(i,n)if(!pp[a[i]])ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 6308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007

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

int main(){
    ll S;cin>>S;
    if(S==1000000000000000000){
        cout<<"0 0 1000000000 0 1000000000 1000000000"<<endl;
        return 0;
    }
    pair<ll,ll> A,B,C;
    A=make_pair(0,0);
    B.first=1000000000;
    C.second=1+S/B.first;
    B.second=1;
    C.first=(B.first*C.second-S)/B.second;
    cout<<A.first<<" "<<A.second<<" "<<B.first<<" "<<B.second<<" "<<C.first<<" "<<C.second<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();

		sc.close();
		if((n + 2) % 2 != 0) {
			System.out.println("No");
			return;
		}
      if(n == 2){
        System.out.println(s.charAt(0) == s.charAt(1) ? "Yes" : "No");
        return;
      }
		System.out.println(s.substring(0, n / 2 - 1).equals(s.substring(n / 2, n - 1)) ? "Yes" : "No");

	}
}



Measured memory_bytes: 35728
#include<stdio.h>

int keta(int num){
  int count=0;

  while(num>0){
    num/=10;
    count+=1;
  }
  return count;
}


int main(){
  int a,b;

  while(scanf("%d %d",&a,&b) != EOF){
    printf("%d\n",keta(a+b));
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
//
int main(){
  int N,M;
  int X,Y;
  int B[100000];
  bool F[100000];
  cin>>N>>M;
  fill(B,B+N,1);
  fill(F,F+N,0);
  F[0]=true;
  FOR(i,0,M){
    cin>>X>>Y;
    X--;Y--;
    if(F[X]){
      if(B[X]==1){
        F[X]=false;
        F[Y]=true;
        B[X]--;
        B[Y]++;
      }else{
        F[Y]=true;
        B[X]--;
        B[Y]++;
      }
    }else{
      B[X]--;
      B[Y]++;
    }
  }
  int C=0;
  FOR(i,0,N){
    if(F[i]){
      C++;
    }
  }
  cout<<C<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int N;
    cin >> N;
    vector<int> X(N);
    REP(i, N) cin >> X[i];

    vector<int> B = X;
    SORT(B);
    int l = B[N / 2 - 1];
    int r = B[N / 2];

    REP(i, N) {
        if (X[i] <= l) {
            cout << r << endl;
        } else {
            cout << l << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3840
package main

import (
	"fmt"
	"math"
)

func solve(a, b, n float64) float64 {
	if b-1 <= n {
		return math.Trunc(a * (b - 1) / b)
	}
	return math.Trunc(a * n / b)
}

func main() {
	var a, b, n float64
	fmt.Scan(&a, &b, &n)

	ans := solve(a, b, n)
	fmt.Println(ans)
}


Measured memory_bytes: 1756
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for (ll i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(begin(H), end(H));

  // 差分
  vector<ll> Sa(N - 1);
  for (ll i = 0; i < N - 1; i++) {
    Sa[i] = H[i + 1] - H[i];
  }

  // 累積和
  vector<ll> Wa(N);
  for (ll i = 0; i < N - 1; i++) {
    Wa[i + 1] = Wa[i] + Sa[i];
  }

  // leftとrightをずらしていく
  ll ans = 0;
  for (ll left = 0; left < N - K + 1; left++) {
    const ll right = left + K - 1;
    const ll Sabun = Wa[right] - Wa[left];
    if (left == 0) {
      // 初回のみans強制更新
      ans = Sabun;
    } else {
      ans = min(ans, Sabun);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main() {
  int pillar_height[3];
  scanf("%d %d %d", &pillar_height[0], &pillar_height[1], &pillar_height[2]);
  if(pillar_height[1] - pillar_height[0] == pillar_height[2] - pillar_height[1]) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}


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

int main(){
    int n, m, l;
    cin>>n>>m>>l;
    int a[n][m];
    int b[m][l];
    rep(i, n){
        rep(j, m){
            cin>>a[i][j];
        }
    }
    rep(i, m){
        rep(j, l){
            cin>>b[i][j];
        }
    }
    long long count=0;
    rep(i, n){
        rep(j, l){
            count=0;
            rep(k, m){
                count+=a[i][k]*b[k][j];
            }
            if(j){
                cout<<" "<<count;
            }
            else{
                cout<<count;
            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int l[n];
	int a = 0;
	REP(i, n) cin >> l[i];

	sort(l, l+n);
	REP(i, n-1) a += l[i];

	if (l[n-1] < a) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define y1 y749872
#define next nxt
using namespace std;
int i,j,k,n,s,t,m;
inline int read()
{
	int num=0;
	char ch=getchar();
	while(ch>'9'||ch<'0')
	ch=getchar();
	while(ch<='9'&&ch>='0')
	{
		num=num*10+ch-48;
		ch=getchar();
	}
	return num;
}
const int N=1e6+10; 
long long mod=998244353,js;
long long sum[N],c[N],pre[N],zs[N],mu[N];
int pd[N];
long long quick(int ss)
{
	long long ret=1;
	long long a=2;
	while(ss)
	{
		if(ss&1)
		ret=ret*a%mod;
		a=a*a%mod;
		ss=ss>>1;	
	}	
	return ret;
} 
void init()
{
	mu[1]=1;
	pd[1]=1; 
	for(i=2;i<N;i++)
	{
		if(!pd[i])
		zs[++js]=i,mu[i]=-1;
		for(j=1;j<=js&&zs[j]*i<N;j++)
		{
			pd[zs[j]*i]=1;
			if(i%zs[j]==0)
			break;
			mu[zs[j]*i]=-mu[i];
		}
	}
	for(i=1;i<N;i++)
	for(j=1;i*j<N;j++)
	sum[i*j]=(sum[i*j]+mu[i]*i*i*j%mod)%mod; 
	for(i=1;i<N;i++)
	for(j=1;i*j<N;j++)
	pre[i]=(pre[i]+c[i*j]*j)%mod;
} 
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//freopen(".ans","w",sdtout);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&t);
		c[t]++;
	}
	init();
	long long ans=0;
	for(i=1;i<N;i++)
	ans=(ans+sum[i]*pre[i]%mod*pre[i])%mod;
	for(i=1;i<N;i++)
	ans=(ans-c[i]*i)%mod;
	ans=ans*quick(mod-2)%mod;
	printf("%lld",(ans+mod)%mod);
	return 0;
}


Measured memory_bytes: 39416
n = input()
C = [9999]*256
for _ in range(n):
    S = raw_input()
    c = [0]*256
    for s in S:
        c[ord(s)] += 1
    for i in range(256):
        C[i] = min(C[i], c[i])
ans = ""
for i in range(256):
    ans += chr(i)*C[i]
print ans


Measured memory_bytes: 2568