akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int P[MAX_N];
int D[510][510];
int C[510][510];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		rep(j, 0, N) {
			D[i][j] = min({i, j, N - 1 - i, N - 1 - j});
			C[i][j] = 1;
		}
	}
	queue<pi> que;
	int res = 0;
	rep(q, 0, N * N) {
		int a; cin >> a; a--;
		int x = a / N, y = a % N;
		res += D[x][y];
		C[x][y] = 0;
		que.push(pi(x, y));
		while(!que.empty()) {
			pi p = que.front(); que.pop();
			rep(i, 0, 4) {
				int nx = p.fst + dx[i], ny = p.sec + dy[i];
				if(D[nx][ny] > D[p.fst][p.sec] + C[p.fst][p.sec]) {
					D[nx][ny] = D[p.fst][p.sec] + C[p.fst][p.sec];
					que.push(pi(nx, ny));
				}
			}
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    string ref, s;
    int n, ans = 0;
    cin >> ref >> n;
    REP(n)
    {
        cin >> s; s = s + s;
        if(s.find(ref) != string::npos) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 0
let S = stdin.ReadLine()

let N = S.Length;
let even n =
  match n with
    |  n when (n % 2) <> 0 -> false;
    |  _ ->
         seq{ for i in 0..(n/2 - 1) do
                yield S.[i] = S.[i + n/2] }
         |> Seq.reduce (&&)

let rec f n = 
  match n with
    | 0 -> 0
    | n when not (even n) -> f (n - 1)
    | _ -> n


f (N - 1)
|> printfn "%d"



Measured memory_bytes: 14044
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>

#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	int n,m,l;
	cin>>n>>m>>l;
	ll a[n][m];
	ll b[m][l];
	REP(i,n) REP(j,m) cin>>a[i][j];
	REP(i,m) REP(j,l) cin>>b[i][j];
	REP(i,n) {
		REP(j,l) {
			ll res = 0;
			REP(k,m) res += a[i][k]*b[k][j];
			cout<<res;
			if(j!=l-1) cout<<" ";
			else cout<<endl;
		}
	}
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-conversion"

#define NDEBUG
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using uint = unsigned int;
using usize = std::size_t;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<typename T> constexpr T popcount(const T u) { return u ? static_cast<T>(__builtin_popcountll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T log2p1(const T u) { return u ? static_cast<T>(64 - __builtin_clzll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T msbp1(const T u) { return log2p1(u); }
template<typename T> constexpr T lsbp1(const T u) { return __builtin_ffsll(u); }
template<typename T> constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast<T>(u); }
template<typename T> constexpr bool ispow2(const T u) { return u and (static_cast<u64>(u) & static_cast<u64>(u - 1)) == 0; }
template<typename T> constexpr T ceil2(const T u) { return static_cast<T>(1) << clog(u); }
template<typename T> constexpr T floor2(const T u) { return u == 0 ? static_cast<T>(0) : static_cast<T>(1) << (log2p1(u) - 1); }
template<typename T> constexpr bool btest(const T mask, const usize ind) { return ((static_cast<u64>(mask) >> ind) & static_cast<u64>(1)); }
template<typename T> constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast<T>(0) : static_cast<T>((static_cast<u64>(mask) << (64 - ind)) >> (64 - ind)); }
template<typename T> bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); }
template<typename T> bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); }
constexpr unsigned int mod                  = 1000000007;
template<typename T> constexpr T inf_v      = std::numeric_limits<T>::max() / 4;
template<typename Real> constexpr Real pi_v = Real{3.141592653589793238462643383279502884};
template<typename T>
T read()
{
    T v;
    return std::cin >> v, v;
}
template<typename T>
std::vector<T> read_vec(const std::size_t size)
{
    std::vector<T> v(size);
    for (auto& e : v) { std::cin >> e; }
    return v;
}
template<typename... Types>
auto read_vals() { return std::tuple<std::decay_t<Types>...>{read<Types>()...}; }
#define SHOW(...) static_cast<void>(0)
template<typename T>
std::vector<T> make_v(const std::size_t size, T v) { return std::vector<T>(size, v); }
template<class... Args>
auto make_v(const std::size_t size, Args... args) { return std::vector<decltype(make_v(args...))>(size, make_v(args...)); }
int main()
{
    auto x = read<int>(), a = read<int>(), b = read<int>();
    const auto n = read<usize>();
    for (usize i = 0; i < n; i++) {
        const auto s = read<std::string>();
        if (s == "nobiro") {
            x = std::max(0, x + a);
        } else if (s == "tidime") {
            x = std::max(0, x + b);
        } else {
            x = 0;
        }
    }
    std::cout << x << std::endl;
    return 0;
}



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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int a, b;
	cin >> a >> b;
	int k = 0;
	if(a == b){
		cout << 0 << endl;
		return 0;
	}
	k = (a + b) / 2;
	if(abs(a-k) == abs(b-k)){
		cout << k << endl;
		return 0;
	}
	cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int ans[1010][1010];

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

	const int p = b;
	const int q = h - b;

	int pos = 0;
	rep(i, p){
		rep(j, w){
			ans[pos][j] = (j < a);
		}
		pos++;
	}

	rep(i, q){
		rep(j, w){
			ans[pos][j] = (j >= a);
		}
		pos++;
	}

	rep(i, h){
		rep(j, w) cout << ans[i][j];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 5120
numbers = {str(i) for i in range(10)}
N, K = map(int, input().split())
*D, = map(str, input().split())
D = set(D)
available = numbers - D
ans = 0
for i in range(N, 100000):
    nums = set(str(i))
    if nums <= available:
        print(i)
        break

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

using namespace std;


int main(){
    int x1,x2,y1,y2,temp;
    int x3,x4,y3,y4;
    scanf("%d",&x1);
    scanf("%d",&y1);
    scanf("%d",&x2);
    scanf("%d",&y2);
    int xd=x2-x1;
    int yd=y2-y1;
    temp=xd;
    xd=yd;
    yd=temp;
    xd= -xd;
    x3=x2+xd;
    x4=x1+xd;
    y3=y2+yd;
    y4=y1+yd;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>
#include <cstdint>
#include<deque>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main() {
	int a,b;
	cin >> a>>b;
	if (a == 1) {
		if (b == 2) {
			cout << 3;
		}
		else {
			cout << 2;
		}
	}
	else if(a==2) {
		if (b == 1) {
			cout << 3;
		}
		else {
			cout << 1;
		}
	}
	else {
		if (b == 1) {
			cout << 2;
		}
		else {
			cout << 1;
		}
	}
	
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            cnt = 0
            for k in range(-1, 2):
                for l in range(-1, 2):
                    if 0 <= i + k and 0 <= j + l and i + k < h and j + l < w and s[i + k][j + l] == '#':
                        cnt += 1
            s[i][j] = cnt
for i in range(h):
    print(*s[i], sep='')

Measured memory_bytes: 3444
#include<stdio.h>

void ShellSort(int arr[],int n)
{
	int incre = 1;
	while(incre < n/3)
		incre = incre*3 + 1;
	for(;incre >= 1;incre/=3)
		for(int i = incre;i < n;i++)
		{
			int pos = i;
			int val = arr[i];
			for(;pos >= incre && val < arr[pos - incre];pos-=incre)
				arr[pos] = arr[pos - incre];
			arr[pos] = val;
		}
}

int Find(int arr[],int n)
{
    int ans = 0;
    for(int i = 0;i < n - 2;i++)
        for(int j = i + 1;j < n - 1;j++)
            for(int k = j + 1;k < n;k++)
            {
                if(arr[i] + arr[j] > arr[k]) ans++;
                else break;
            }
    return ans;
}  
int main()
{
    int n;
    scanf("%d",&n);
    int arr[10002];
    for(int i = 0;i < n;i++)
        scanf("%d",arr + i);
    ShellSort(arr,n);
    printf("%d\n",Find(arr,n));
    return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N;
map<long long, long long> mp;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N ;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		if(mp.count(a)==0){
			mp[a] = 1;
		}
		else{
			mp[a]++;
		}
	}
	vector<pair<long long, long long>> v;

	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		long long k = itr->first;
		long long u = itr->second;
		v.push_back(make_pair(k, u));
	}

	sort(v.begin(), v.end());
	int found = 0;
	long long ans = 0;
	for(int i=v.size()-1; i>=0; i--){
		if(v[i].second < 2) continue;
		if(v[i].second >=4){
			if(found == 2){
				ans = ans*(v[i].first);
			}
			else{
				ans = (v[i].first)*(v[i].first);
			}
			found = 4;
			break;
		}
		if(v[i].second == 2 || v[i].second == 3){
			found += 2;
			if(found == 4){
				ans = ans * v[i].first;
				break;
			}
			else{
				ans = v[i].first;
			}
		}
		
	}
	if(found < 4) ans = 0;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8696
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

ll x1;
ll x2;
ll x3;
ll x4;
ll x5;

int main() {
    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if (x1 == 0) {
        cout << "1" << endl;
    } else if (x2 == 0) {
        cout << "2" << endl;
    } else if (x3 == 0) {
        cout << "3" << endl;
    } else if (x4 == 0) {
        cout << "4" << endl;
    }else{
        cout << "5" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

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

    vector<vector<int>> ch(N);
    vector<int> par(N, -1);
    vector<int> sibling(N, -1);

    for (int i = 0; i < N; ++i) {
        int v, l, r;
        cin >> v >> l >> r;
        if (l >= 0) {
            par[l] = v;
            sibling[l] = r;
            ch[v].push_back(l);
        }
        if (r >= 0) {
            par[r] = v;
            sibling[r] = l;
            ch[v].push_back(r);
        }
    }

    int r = min_element(par.begin(), par.end()) - par.begin();
    vector<int> dep(N), h(N);

    function<int(int, int)> dfs = [&](int v, int d) -> int {
        dep[v] = d;
        h[v] = 0;
        for (int sv : ch[v]) {
            h[v] = max(h[v], dfs(sv, d + 1) + 1);
        }
        return h[v];
    };
    dfs(r, 0);

    for (int v = 0; v < N; ++v) {
        cout << "node " << v
             << ": parent = " << par[v]
             << ", sibling = " << sibling[v]
             << ", degree = " << ch[v].size()
             << ", depth = " << dep[v]
             << ", height = " << h[v]
             << ", ";
        cout << (par[v] < 0 ? "root" : (ch[v].empty() ? "leaf" : "internal node")) << endl;
    }
    return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
ll N;
int in[80], n, dp[80][2][2][2];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> N;
	for(; N; N /= 2) in[n++] = N % 2;
	reverse(in, in + n);
	
	dp[0][0][0][0] = 1;
	rep(i, n) rep(xs, 2) rep(ss, 2) rep(sc, 2) if(dp[i][xs][ss][sc]) rep(a, 2) rep(b, a+1) rep(nc, 2){
		int nx = a ^ b;
		int ns = a + b + nc;
		if(sc != (ns >> 1)) continue;
		
		if(!xs && nx > in[i]) continue;
		if(!ss && (ns & 1) > in[i]) continue;
		int nxs = xs || nx < in[i];
		int nss = ss || (ns & 1) < in[i];
		
		(dp[i + 1][nxs][nss][nc] += dp[i][xs][ss][sc]) %= mod;
	}
	ll ans = 0;
	rep(i, 2) rep(j, 2) ans += dp[n][i][j][0];
	cout << ans % mod << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
int cnt[30];
int main()
{
#ifdef DEBUG
	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
#endif
	char c;
	memset(cnt,0,sizeof(cnt));
	while((c=getchar())!=EOF){
//		cout<<c;
		c=toupper(c);
		if(isalpha(c)){
			cnt[islower(c)?c:tolower(c)-'a']++;
		}
	}
	for(int i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,cnt[i]);
	}
	
	//insert code
	return 0;
}
//aoj1_8_c.cc

Measured memory_bytes: 1108
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
#include <set>
  
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;

int n;

void rec(int depth,double ax,double ay,double dx,double dy){
	if(depth>=n)return;
	double bx=(ax+ax+dx)/3.0;
	double by=(ay+ay+dy)/3.0;
	double cx=(ax+dx+dx)/3.0;
	double cy=(ay+dy+dy)/3.0;

	double vx=cx-bx;
	double vy=cy-by;

	double mx=bx+vx/2.0-vy*sqrt(3.0)/2.0;
	double my=by+vy/2.0+vx*sqrt(3.0)/2.0;

	rec(depth+1,ax,ay,bx,by);
	printf("%.10f %.10f\n",bx,by);
	rec(depth+1,bx,by,mx,my);
	printf("%.10f %.10f\n",mx,my);
	rec(depth+1,mx,my,cx,cy);
	printf("%.10f %.10f\n",cx,cy);
	rec(depth+1,cx,cy,dx,dy);
	
}

int main(){
	cin>>n;
	double ax=0.0;
	double ay=0.0;
	double dx=100.0;
	double dy=0.0;
	printf("%.10f %.10f\n",ax,ay);
	rec(0,ax,ay,dx,dy);
	printf("%.10f %.10f\n",dx,dy);
}


Measured memory_bytes: 3208
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    int i = 0;
    bool h;
    ll ans = 1;
    if(s1[i] == s2[i]){
        ans *= 3;
        i++;
        h = false;
    }else{
        ans *= 6;
        i += 2;
        h = true;
    }
    for(; i < n; i++){
        if(s1[i] == s2[i]){
            ans *= h ? 1 : 2;
            ans %= M;
            h = false;
        }else{
            ans *= h ? 3 : 2;
            ans %= M;
            i++;
            h = true;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int dp[1000001][2];


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

	string n;
	cin >> n;
	
	reverse(all(n));
	rep(i, n.size() + 1)rep(c, 2)dp[i][c] = INF;
	dp[0][0] = 0;

	rep(i, n.size())rep(c, 2) {
		if (dp[i][c] == INF)continue;
		int d = n[i] - '0';
		
		int y = (c + d) % 10;
		dp[i + 1][(c + d) / 10] = min(dp[i + 1][(c + d) / 10], dp[i][c] + y);
		if((c + d) / 10 == 0)
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][c] + 10 - y);

		if (c + d < 10) {
			int x = (10 - (c + d) + 1) / 2;
			y = (c + d + x * 2) % 10;
			dp[i + 1][(c + d + x * 2) / 10] = min(dp[i + 1][(c + d + x * 2) / 10], dp[i][c] + y + x * 2);
		}
	}
	int ans = min(dp[n.size()][0], dp[n.size()][1] + 1);
	cout << ans << endl;

	return 0;
}

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

using perm = vector<int>;
int N;
perm inv(const perm& a) {
	perm r(N);
	for (int i = 0; i < N; i++) r[a[i]] = i;
	return r;
}
perm operator * (const perm& a, const perm& b) {
	perm r(N);
	for (int i = 0; i < N; i++) r[i] = a[b[i]];
	return r;
}

perm pow(perm a, int b) {
	perm r(N);
	iota(r.begin(),r.end(),0);
	while (b) {
		if (b&1) r = r * a;
		a = a * a;
		b >>= 1;
	}
	return r;
}

int K;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> K; K--;
	perm P(N), Q(N);
	for (int i = 0; i < N; i++) cin >> P[i], P[i]--;
	for (int i = 0; i < N; i++) cin >> Q[i], Q[i]--;
	perm pref = Q * inv(P) * inv(Q) * P;
	pref = pow(pref, K / 6);
	perm mid;
	switch(K % 6) {
		case 0:
			mid = P;
			break;
		case 1:
			mid = Q;
			break;
		case 2:
			mid = Q * inv(P);
			break;
		case 3:
			mid = Q * inv(P) * inv(Q);
			break;
		case 4:
			mid = Q * inv(P) * inv(Q) * P * inv(Q);
			break;
		case 5:
			mid = Q * inv(P) * inv(Q) * P * P * inv(Q);
			break;
		default:
			assert(false);
	}
	perm res = pref * mid * inv(pref);

	for (int i = 0; i < N; i++) cout << res[i]+1 << " \n"[i+1==N];

	return 0;
}


Measured memory_bytes: 4688
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	var c int
	if b%a == 0 {
		c = b + a
	} else {
		c = b - a
	}
	fmt.Fprintf(writer, "%d", c)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int M = S.size();
    map<char,int> mp;
    rep(i,M){
        mp[S[i]]++;
    }
    int ma = max(mp['a'],max(mp['b'],mp['c']));
    int mi = min(mp['a'],min(mp['b'],mp['c']));
    if(ma-mi>=2)cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

int main()
{
    int N, ans;
    ans = 1;
    cin >> N;
    string S;
    cin >> S;
    for (int i = 0; i < S.size() - 1; i++)
    {
        if (S.at(i) != S.at(i + 1))
        {
            ans += 1;
        }
    }

    cout << ans << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll X;
ll mk[1111];
ll i, j, k,ans;

void answer(ll a,ll b){
    printf("%lld %lld\n", a, b);
    exit(0);
}

int main(){
    scanf("%lld", &X);
    fornum(i,0,1000){
        mk[i] = i * i * i * i * i;
    }
    fornum(i,0,1000){
        fornum(j,0,1000){
            if(mk[i]+mk[j]==X){
                answer(i, -j);
            }
            if(mk[i]-mk[j]==X){
                answer(i, j);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3836
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

int n, t;

int c(int k) {
    return min(k, t);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    cin >> n >> t;
    vector<pii> a(n);
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    sort(all(a));
    vector<vector<int>> dp(t + 1, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
        dp[c(a[i].first)][i] = max(dp[c(a[i].first)][i], a[i].second);
    }
    for (int i = 0; i < t; i++) {
        for (int j = 1; j < n; j++) {
            if (i) dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            dp[c(i + a[j].first)][j] = max(dp[c(i + a[j].first)][j], dp[i][j - 1] + a[j].second);
        }
    }
    int ans = 0;
    for (int i = 0; i <= t; i++) {
        for (int j = 0; j < n; j++) ans = max(ans, dp[i][j]);
    }
    cout << ans;
}
/*

*/


Measured memory_bytes: 70784
s = input()

if s[0] == "S":
  if s[1] == "S":
    if s[2] == "S":
      print("0")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("1")
    else:
      print("2")
if s[0] == "R":
  if s[1] == "S":
    if s[2] == "S":
      print("1")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("2")
    else:
      print("3")

Measured memory_bytes: 8968
import itertools
import numpy as np

res = 999999999999999999

H, W, K = [int(i) for i in input().split()]
arr = []
for h in range(H):
  arr.append([int(v) for v in input()])

arr = np.vstack(arr)

for p in itertools.product([0, 1], repeat = H-1):
  if sum(p) > res:
    continue
  sp = np.zeros((sum(p)+1, W), int)
  row = 0
  sp[0] += arr[0]
  for j in range(H-1):
    if p[j]:
      row += 1
    sp[row] += arr[j+1]
  if np.max(sp) > K:
    continue
  
  sum_arr = np.zeros(len(sp), int)
  cut_cnt = sum(p)
  for c in range(W):
    sum_arr += sp[:, c]
    if max(sum_arr) > K:
      sum_arr = sp[:, c]
      cut_cnt += 1
      if cut_cnt > res:
        break
  if cut_cnt < res:
    res = cut_cnt
print(res)

Measured memory_bytes: 12696
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    vector<int>y(n);
    for(int i=0;i<n;i++){
        y[i]=x[i];
    }
    sort(y.begin(),y.end());
    for(int i=0;i<n;i++){
        if(x[i]<y[n/2]){
        cout<<y[n/2]<<endl;
        }
        else{
            cout<<y[n/2-1]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 10002;

struct edge{
	int to;
	int dir;
};

int a[MAX_N];
int n,m;

int d[MAX_N];
vector<edge> G[MAX_N];

vector<int> prev[MAX_N];

void dijkstra(int s)
{
	priority_queue<P,vector<P>,greater<P> > que;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		vector<edge>::iterator it = G[v].begin();
		rep(i,G[v].size()){
			if(d[G[v][i].to] > d[v] + G[v][i].dir){
                prev[G[v][i].to].clear();
                prev[G[v][i].to].push_back(v);
				d[G[v][i].to] = d[v] + G[v][i].dir;
				que.push(P(d[G[v][i].to],G[v][i].to));
			}else if(d[G[v][i].to] == d[v] + G[v][i].dir){
                prev[G[v][i].to].push_back(v);
            }
		}
	}
}

int main()
{
    while(1){
        scanf("%d%d",&n,&m);
        if(n == 0 && m == 0){
            break;
        }
        rep(i,n){
            G[i].clear();
        }
        fill(d,d+n,INF);
        map<P,int> cost;
    	rep(i,m){
            int w,x,y,z;
    		scanf("%d%d%d%d",&w,&x,&y,&z);
            cost[P(w-1,x-1)] = z;
            cost[P(x-1,w-1)] = z;
            G[w-1].push_back((edge){x-1,y});
            G[x-1].push_back((edge){w-1,y});
    	}
        dijkstra(0);
        int res = 0;
        for(int i = 1; i < n; i++){
            int mn = INF;
            rep(j,prev[i].size()){
                mn = min(mn,cost[P(i,prev[i][j])]);
            }
            res += mn;
        }
        printf("%d\n",res);
    }
	return 0;
}

Measured memory_bytes: 7672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	bool flg=false;
	if(n>81) out("No");
	else{
		rep2(i,1,10){
			if( n%i==0 && n/i<=9 ){ 
			out("Yes");
			flg = true;
			break;
			}
		}
		if(!flg) out("No");
	}
	

}




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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];

typedef unsigned int Hash1;
typedef short Hash2;
typedef pair<Hash1,Hash2> Hash;
const Hash1 b1 = 29;
const Hash2 b2 = 29;
const Hash2 m2 = 127;
const int MAX = 100001;
Hash hsh[MAX];
Hash bpow[MAX];
Hash2 mdmp[65536];

struct HashHash {
  size_t operator()(const Hash &yey) const {
    hash<int> hasher;
    return hasher((int)yey.first)^hasher((int)yey.second);
  }
};

unordered_set<Hash,HashHash> S;
int calc(int x){
  S.clear();
  REP(i,n-x+1){
    // substr
    int l = i;
    int r = l+x;
    Hash h(0,0);
    h.first += hsh[l].first;
    h.second+= hsh[l].second;
    h.first *= bpow[x].first;
    h.second*= bpow[x].second;
    // mod & negative
    h.first = -h.first;
    h.second= m2 - mdmp[h.second];
    h.first += hsh[r].first;
    h.second+= hsh[r].second;
    h.second= mdmp[h.second];
    S.insert(h);
  }
  return S.size();
}

int main(){
  scanf("%s",s);
  n = strlen(s);
  REP(i,65536)mdmp[i] = i%m2;
  // create hash
  REP(i,n){
    int id = s[i]-'a';
    hsh[i+1].first = hsh[i].first*b1 + (Hash1)id;
    hsh[i+1].second= mdmp[ hsh[i].second*b2+ (Hash2)id ];
  }
  // base pow
  bpow[0] = Hash(1,1);
  REP(i,n){
    bpow[i+1].first = bpow[i].first*b1;
    bpow[i+1].second= mdmp[ bpow[i].second*b2 ];
  }
  // go
  int low = 1, high = n;
  while(low+2<high){
    int ml = (low+high)/2;
    int mh = ml+1;
    if(calc(ml)<calc(mh)){
      low = ml;
    }else{
      high = mh;
    }
  }
  int ans = 0;
  FOR(i,low,high+1)CHMAX(ans,calc(i));
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 6308
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    int N;
    cin >> N;
    vector<ll> X(N), Y(N);
    rep(i,0,N) {
        ll x, y;
        cin >> x >> y;
        X[i] = x - y;
        Y[i] = x + y;
    }

    ll maxX = -2000000000, minX = 2000000000;
    ll maxY = -2000000000, minY = 2000000000;
    rep(i,0,N) {
        maxX = max(maxX, X[i]);
        minX = min(minX, X[i]);
        maxY = max(maxY, Y[i]);
        minY = min(minY, Y[i]);
    }
    cout << max(maxX - minX, maxY - minY) << endl;
}

Measured memory_bytes: 6416
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int b[n];
    int k=0, c=0, flag = 0;
    for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
      b[i] = 0;
        if(a[i] == k+1) {
            b[i] = 1;
            k++;
            flag = 1;
        }
    }
    if(flag == 1){
        for(int i=0;i<n;i++){
            if(b[i] == 0) c++;
        }
    }
    if(c!=0) printf("%d\n",c);
    else if(flag == 1 && c==0) printf("0\n");
    else printf("-1\n");
    return 0;
}

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

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

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

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

    cout << lcm(a, b) << endl;
    return 0;
}

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

int main(){
	int a,b,counter=0;
	
	scanf("%d %d", &a,&b);
	
	for(a;a<=b;a++){
		int v1=10000,v2=10;
		if(a/v1==a%v2&&(a/(v1/10))%10==(a%100)/10){
			counter++;
		}
	}
	
	printf("%d\n", counter);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;



void solve(void){
    ll N, C, K;
    cin >> N >> C >> K;
    vector <ll> v(N);
    rep(N, i) cin >> v.at(i);
    sort(all(v));
    ll ans = 0LL;
    rep(N, i) {
        ll cnt = 1LL, last = v[i] + K;
        while(cnt < C && v[i+cnt] <= last) {
            cnt++;
        }
        i += cnt-1;
        ans++;
    }
    cout << ans << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(5);
  for (auto &v : vec)
    cin >> v;
  ll s = *min_element(vec.begin(), vec.end());
  cout << 4 + (n + (s - 1)) / s << endl;
}

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

struct UnionFind {
  vector<int> par;
  UnionFind(int N): par(N) {
    rep(i, 0, N) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  // input
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);

  int p[n];
  rep(i, 0, n) cin >> p[i];

  // calculation
  int x, y;
  rep(i, 0, m) {
    cin >> x >> y;

    // ごにょごにょして
    uf.unite(x-1, y-1);
  }

  // p[i] == i の数を数える
  int res = 0;
  rep(i, 0, n) {
    if (uf.same(p[i]-1, i)) {
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define For(i,l,r) for (register int i=l; i<=r; i++)
using namespace std;
typedef unsigned long long LL;
typedef signed long long ll;
template <typename T>
inline void read(T &x) {
	char c = getchar(); int w = 1; x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int w[100005], cc[30], n;
ll x;
char c[20];
map<long long, int> Map;
inline void has() {
	x = 0;
	memset(cc, 0, sizeof(cc));
	For(j,1,10)
		++cc[c[j]-'a'];
	For(j,0,25)
		For(k,1,cc[j])
			(x *= 26) += j;
}
int main() {
	cin >> n;
	memset(w, 0, sizeof(w));
	ll ans = 0;
	For(i,1,n) {
		scanf("%s", c+1);
		has();
		if (!Map[x]) Map[x] = i;
		ans += (w[Map[x]]++);
		//cout << x << endl;
	}
	cout << ans;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n,y; cin >> n >> y ;
  ll a,b,c; a=-1; b=-1; c=-1;
  
  rep(i,n+1){
    rep(j,n+1){
      if(9000*i+4000*j == y - 1000*n && i+j <=n){
        a = i; b = j; c = n-i-j;
        break;
      }
    }
  }
  
  cout << a << ' ' << b << ' ' << c << endl;
}

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

int main (){
    long a, b = 0;
    cin >> a >> b;
    if(a*b <= 0){
        cout << "Zero" << endl;
    }
    else if (a >= 1 && b >= 1)
    {
        cout << "Positive" << endl;
    }
    else{
        if(abs(abs(a) - abs(b))%2 == 0){
            cout << "Negative" << endl;
        }
        else{
            cout << "Positive" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  if(N<=111){
    cout<<111<<endl;
  }else if(N<=222){
    cout<<222<<endl;
  }else if(N<=333){
    cout<<333<<endl;
  }else if(N<=444){
    cout<<444<<endl;
  }else if(N<=555){
    cout<<555<<endl;
  }else if(N<=666){
    cout<<666<<endl;
  }else if(N<=777){
    cout<<777<<endl;
  }else if(N<=888){
    cout<<888<<endl;
  }else if(N<=999){
    cout<<999<<endl;
  }else{
    cout<<1111<<endl;
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define FOR(x,z,y) for(ll x=z; x < (ll)y; x++)



int main() {

    ll n,a,b;
    cin >> n >> a >> b;

    cout << n/(a+b)*a + min(n%(a+b),a);
}


Measured memory_bytes: 256
//import for Scanner and other utility classes
import java.util.*;
import java.io.*;
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    public static void main(String args[] ) {
        Scanner s = new Scanner(System.in);
       int n=s.nextInt();
      //int k=s.nextInt();
int a[]=new int[n];
List<Integer>l=new ArrayList<Integer>();
//int c=0;
for(int i=0;i<n;i++){
int t=s.nextInt();
 a[t-1]=i+1;
 
}
for(int i=0;i<n;i++)
      System.out.print(a[i]+" ");
      
        // Write your code here
 
    }
}

Measured memory_bytes: 62932
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    int i=0,x=0,y,ans;
    cin>>s;
    int ls=s.length();
    while(i<ls)
    {
        if(s[i]=='p') x++;
        i++; 
    }
    y=i/2;
    ans=y-x;
    cout<<ans;
    return 0;
 } 


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

#define pb push_back

using ll = long long;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v;
        --u, --v;
        g[u].pb(v);
    }
    vector<int> ans;
    for (int u = 0; u < n; ++u) {
        vector<int> par(n, -1);
        queue<int> q;
        for (int v : g[u]) {
            par[v] = u;
            q.push(v);
        }
        while (!q.empty()) {
            int cur = q.front();
            q.pop();
            if (cur == u) {
                vector<int> take;
                int x = par[u];
                while (x != u) {
                    take.pb(x);
                    x = par[x];
                }
                take.pb(u);
                if (ans.size() == 0 || take.size() < ans.size()) ans = take;
                break;
            }
            for (int nxt : g[cur]) {
                if (par[nxt] == -1) {
                    q.push(nxt);
                    par[nxt] = cur;
                }
            }
        }
    }
    if (ans.size()) {
        cout << ans.size() << "\n";
        for (int u : ans) cout << u + 1 << "\n";
    } else {
        cout << -1 << "\n";
    }
}

Measured memory_bytes: 384
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 not arr:
        arr.append([n, 1])

    return arr


n = int(input())
cnt = 0
z_list = []
f = factorization(n)
for fact in f:
    for j in range(1, fact[1] + 1):
        z = fact[0] ** j
        if z < 2:
            print(0)
            exit()
        if str(z) not in z_list:
            if n % z == 0:
                n = n // z
                cnt += 1
print(cnt)


Measured memory_bytes: 63492
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  if((N - 1) * (N - 2) / 2 < K) {
    cout << -1 << endl;
    return 0;
  }
  int M = N - 1 + (N - 1) * (N - 2) / 2 - K;
  cout << M << endl;
  REP(i, N - 1) { cout << N << ' ' << i + 1 << endl; }
  vector<P> p;
  FOR(i, 1, N - 1) {
    FOR(j, i + 1, N) { p.push_back(P(i, j)); }
  }
  REP(i, (N - 1) * (N - 2) / 2 - K) {
    cout << p[i].first << ' ' << p[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 512
def check(ans, n, s)
	# 2番からn-1番の回答に合致させる
	1.upto(n-2) do |i|
		temp = (ans[i-1] == "S") ^ (ans[i] == "S") ^ (s[i] == "o") 
		ans[i+1] = temp ? "S" : "W"
	end

	temp = (ans[n-2] == "S") ^ (ans[n-1] == "S") ^ (s[n-1] == "o")
	ans_zero = temp ? "S" : "W"

	temp = (ans[n-1] == "S") ^ (ans[0] == "S") ^ (s[0] == "o")
	ans_one = temp ? "S" : "W"

	if ans_zero == ans[0] && ans_one == ans[1] then
		return true
	else
		return false
	end
end


n = gets.to_i
s = gets.chomp

ans = []
ans[0] = "S"
ans[1] = "S"
if check(ans, n, s) 
	puts ans.join
	exit
end

ans = []
ans[0] = "S"
ans[1] = "W"
if check(ans, n, s) 
	puts ans.join
	exit
end

ans = []
ans[0] = "W"
ans[1] = "S"
if check(ans, n, s) 
	puts ans.join
	exit
end

ans = []
ans[0] = "W"
ans[1] = "W"
if check(ans, n, s) 
	puts ans.join
	exit
end

puts -1


Measured memory_bytes: 16820