akhauriyash/Code-Regression huggingface dataset:
n = int(input())

max_a = int(pow(n, 1/2))

ans = 999
for a in range(1, max_a + 1):
    if n % a == 0:
        b = n // a
        temp = 1
        while b >= 10:
            b //= 10
            temp += 1
        ans = min(ans, temp)

print(ans)

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
 
const int maxn = 5e3 + 10;
const long long max_val = 1LL << 62;
 
long long dp[maxn * 2], dp_min[maxn * 2];
int p[maxn];
 
long long cost(int p1, int p2, int A, int B) {
    if (p1 == p2) return 0;
    else if (p1 > p2) return B;
    else return A;
}
 
int main()
{
    int N, A, B, x;
    cin >> N >> A >> B;
    for (int i = 1; i <= N; i++) {
        cin >> x;
        p[x] = i;
    }
    for (int i = 1; i <= N; i++) for (int j = 0; j <= N; j++) dp[j] = max_val;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <=  N; j++) {
            dp[j] = dp_min[j] + cost(p[i], j, A, B);
        }
        dp_min[0] = dp[0];
        for (int j = 1; j <=  N; j++) dp_min[j] = min(dp_min[j - 1], dp[j]);
    }
    cout << dp_min[ N] << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105;

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

int main(){
    ll a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld\n",a*b/gcd(a,b));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll m=1e9+7;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
void add_self(int &a ,int b)
{
	a+=b;
	if(a>=m)
	a-=m;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	string s;
	cin>>s;
	ll d;
	cin>>d;
	ll len=s.length();
	 vector<vector<int>> dp(d,vector<int>(2));
	dp[0][0]=1;
	for(ll where=0;where<len;where++)
	{
		vector<vector<int>> new_dp(d,vector<int>(2));
		for(ll sum=0;sum<d;sum++)
		{
			for(bool sm_already :{true,false})
			{
				for(ll digit=0;digit<10;digit++)
				{
					if(digit>s[where]-'0' && !sm_already)
					break;
					add_self(new_dp[(sum+digit)%d][sm_already || digit<s[where]-'0'],dp[sum][sm_already]);
				}
			}
		}
		dp=new_dp;
	}
	ll answer=(dp[0][false]+dp[0][true]-1+m)%m;
	cout<<answer;
	cout<<"\n"; 
 } 
}



Measured memory_bytes: 384
n = int(input())
S =input().split(" ")
l =int(input())
T = input().split(" ")
ans =0
for t in T:
    S.append(t)
    j =0
    while S[j] !=t:
        j+=1
    if j !=n:
        ans +=1
    S=S[:-1]
print(ans)


Measured memory_bytes: 6308
n,k,q = list(map(int,input().split()))
a = [0 for i in range(n)]

for i in range(q):
    b = int(input())
    a[b-1] += 1
for i in range(n):
    if k - (q - a[i]) > 0:
        print("Yes")
    else:
        print("No") 

Measured memory_bytes: 51104
#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 main()
{
    ll N;
    cin  >> N;
    string name="",n;;
    N=N-1;
    string Alp="abcdefghijklmnopqrstuvwxyz";
    while(1){
        /*if(N%26==0){
            n="z";
            cout<<"XXXXX" <<endl;
        }else{*/
            n= Alp[N%26];
        //}
        name = n+name;
        if(N/26 == 0){
            break;
        }else{
            N=N/26-1;
        }
    }
    cout << name << endl;
    return 0;  
}


Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m:usize = read();
    let l:usize = read();
    let arr:Vec<Vec<usize>> = (0..n).map(|_| (0..m).map(|_| read()).collect() ).collect();
    let brr:Vec<Vec<usize>> = (0..m).map(|_| (0..l).map(|_| read()).collect() ).collect();
    let mut crr = vec![vec![0usize; l]; n];
    for i in 0..n {
        for j in 0..m {
            for k in 0..l {
                crr[i][k] += arr[i][j] * brr[j][k];
            }
        }
    }
    for i in crr {
        println!("{}", i.into_iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" "))
    }
}


Measured memory_bytes: 5052
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	vector<ll> ns(n + 1), ps(n + 1);
	ns[0] = ps[0] = 0;
	REP(i, n) {
		ns[i + 1] = ns[i];
		ps[i + 1] = ps[i];
		if (a[i] < 0) {
			ns[i + 1] += a[i];
		} else {
			ps[i + 1] += a[i];
		}
	}
	ll nb = LLONG_MIN, pw = LLONG_MAX;
	REP(i, n - k + 1) {
		ll temp1 = ns[i + k] - ns[i];
		chmax(nb, temp1);
		ll temp2 = ps[i + k] - ps[i];
		chmin(pw, temp2);
	}
	ll res = 0, sum = ps[n]-ps[0];
	chmax(res, sum + nb);
	chmax(res, sum - pw);
	put(res);
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 2003

int n, m;
string ss[mx];
int jaw;
int tadi[mx], a[mx][mx];
int main(){
	cin >> n >> m;
	jaw = max(n, m);
	for(int i = 0; i < n; i++)
		cin >> ss[i];
	for(int i = 1; i < n; i++){
		for(int j = 1; j < m; j++){
			int cnt = 0;
			if(ss[i - 1][j - 1] == '.')
				cnt += 1;
			if(ss[i - 1][j] == '.')
				cnt += 1;
			if(ss[i][j - 1] == '.')
				cnt += 1;
			if(ss[i][j] == '.')
				cnt += 1;
			if(cnt % 2 == 0)
				a[i][j] = 1;
			else
				a[i][j] = 0;
		}
	}
	// for(int i = 1; i < n; i++){
	// 	for(int j = 1; j < m; j++)
	// 		cout << a[i][j];
	// 	cout << endl;
	// }
	for(int i = 1; i < n; i++){
		for(int j = 1; j < m; j++){
			if(a[i][j] == 1)
				tadi[j] += 1;
			else tadi[j] = 0;
		}
		stack<int> st;
		for(int j = 1; j < m; j++){
			while(!st.empty() && tadi[st.top()] >= tadi[j]){
				int now = st.top();
				st.pop();
				int atas = 0;
				if(!st.empty())
					atas = st.top();
				jaw = max(jaw, (tadi[now] + 1) * (j - atas));
			}
			st.push(j);
		}
		while(!st.empty()){
			int now = st.top();
			st.pop();
			int atas = 0;
			if(!st.empty())
				atas = st.top();
			jaw = max(jaw, (tadi[now] + 1) * (m - 1 - atas + 1));
			// debug(tadi[now]);
			// debug(now - atas + 1);
		}
	}
	cout << jaw << endl;
}

Measured memory_bytes: 19968
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string o,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;
}

Measured memory_bytes: 256
import java.util.*;

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

        Scanner var = new Scanner(System.in);

        int A = var.nextInt(); 
        int B = var.nextInt();
        int C = var.nextInt();

        
        if (A+B >= C){
            System.out.println(B+C);
        }else if(A+B < C){
            System.out.println(2*B+A+1);
        }





    }

}

Measured memory_bytes: 21332
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, K, A[2000], COUNT = 0, X[2010] = {}, Y[2010] = {}, ANS = 0, C, MOD = 1000000007;
	cin >> N >> K;
	C = (K * (K - 1) / 2) % MOD;
	for (int i = 0; i < N; i++) cin >> A[i], X[A[i]]++;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (A[i] > A[j]) COUNT++;
		}
	}
	for (int i = 0; i < 2000; i++) {
		Y[i + 1] = Y[i] + X[i + 1];
	}
	ANS = (COUNT * K) % MOD;
	for (int i = 1; i <= 2000; i++) {
		ANS += ((X[i] * Y[i - 1]) % MOD) * C;
		ANS %= MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int mod=1e9+7;
const int N=2e5+5;
int n;
long long a[N],sum,ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%lld",&a[i]);
		sum=(sum+a[i])%mod;
	}
	for (int i=1;i<n;i++){
		sum=(sum+mod-a[i]%mod)%mod;
		ans=(ans+a[i]*sum%mod)%mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3288
#include <iostream>
#include <queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, G[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i = 0; i < n; i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty()){
    u = q.front();
    q.pop();
    for(int v = 0; v < n; v++){
      if(G[u][v] == 0) continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for(int i = 0; i < n; i++){
    cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
  }
}

int main(){
  int u, k, v;

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

  for(int i = 0; i < n; i++){
    cin >> u >> k;
    u--;
    for(int j = 0; j < k
          ; j++){
      cin >> v;
      v--;
      G[u][v] = 1;
    }
  }

  bfs(0);
  return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

//////////////////////////////////////////////////
//nCr Calculation/////////////////////////////////
//////////////////////////////////////////////////
static const ll FACT_SIZE = 1000000;
ll fact[FACT_SIZE] = {};

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
void factorial(ll f) {
	fact[0] = fact[1] = 1;
	rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i % MOD;
}

ll nCr(ll n, ll r) {
	if (fact[0] == 0)	factorial(1000000);
	return ((fact[n] * (Pow(fact[r], MOD - 2) % MOD)) % MOD * Pow(fact[n - r], MOD - 2)) % MOD;
}
// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N) {
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (j == 0 or j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}

ll v[51];
map<ll, ll> m;
int main() {
	comb_table(50);

	ll n, a, b; cin >> n >> a >> b;
	rep(i, 0, n) {
		cin >> v[i];
		m[v[i]]++;
	}
	sort(v, v + n);
	reverse(v, v + n);

	double ans = 0;
	rep(i, 0, a) {
		ans += v[i];
	}
	printf("%.7f\n", ans / a);

	ll minV = v[a - 1];
	ll M = m[minV];

	bool all = true;
	rep(i, 0, a) {
		//if (minV != v[i]) {
		//	all = false;
		//	break;
		//}
		if (i > 0) {
			all &= (v[i] == v[i - 1]);
		}
	}

	if (!all) {
		ll P = 0;
		rep(i, 0, a) {
			if (v[i] == minV) P++;
		}
		cout << C[M][P] << endl;
	}
	else {
		ll cnt = 0;
		repe(i, a, b) cnt += C[M][i];
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, PP> PPP;
typedef pair<string, int> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

int main(){
	int n, m;
	cin >> n >> m;
	int res = 0;
	for(int i = 0; i < n; i++){
		int c = 0;
		int a;
		for(int j = 0; j < m; j++){
			cin >> a;
			if(a) c++;
		}
		res = max(res, c);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length(),i,c=0;
    for(i=0;i<l-1;i++)
    {
        if(s[i]!=s[i+1]) c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3756
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
        t: usize,
    }
    println!("{}", t / a * b)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define F(i,a,b) for(int i=a;i<b;i++)
#define RF(i,a,b) for(int i=a;i>b;i--)
#define mp(a,b) make_pair(int a,int b)
#define ll long long
const int mxn=1e5+10,mxm=4e5+10;
const ll modl=998244353;
int nm,n,m,p,t,k;
int ans,sum;
int a[mxn],b[mxn],h[mxn];
int l,r;
int main(){
    ios_base::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    cin>>nm;
//    string s,s1,s2;char c;
    while(cin>>m>>n){
//        priority_queue<dp,vector<dp>,cmp>q;
        cin>>p;nm=p;
        F(i,1,n){
            cin>>t;
            k=max(k,t-p);
            p=t;
        }
        k=max(k,m+nm-p);
        cout<<m-k;
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"def solve():\n"
"    from collections import deque\n"
"    h, w, k = map(int, input().split())\n"
"    maze = [input() for _ in range(h)]\n"
"    visited = [[-1]*w for _ in range(h)]\n"
"    for i in range(h):\n"
"        if 'S' in maze[i]:\n"
"            sy, sx = i, maze[i].index('S')\n"
"            break\n"
"    queue = deque([[sy, sx]])\n"
"    visited[sy][sx] = 0\n"
"    r = 10**18\n"
"    while queue:\n"
"        y, x = queue.popleft()\n"
"        r = min(r, y, h-1-y, x, w-1-x)\n"
"        if visited[y][x] == k: continue\n"
"        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):\n"
"            new_y, new_x = y+i, x+j\n"
"            if new_y < 0 or new_y >= h or new_x < 0 or new_x >= w: continue\n"
"            if maze[new_y][new_x] == '.' and visited[new_y][new_x] == -1:\n"
"                visited[new_y][new_x] = visited[y][x] + 1\n"
"                queue.append([new_y, new_x])\n"
"    print(1 -(-r // k))\n"
"if __name__ == '__main__':\n"
"    solve()\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 26552
#include <stdio.h>
#include <string.h>

int main()
{
    char a[102], b[102];
    int la, lb;
    scanf("%s%s", a, b);
    la = strlen(a);
    lb = strlen(b);
    if (la > lb) {
        printf("GREATER\n");
    } else if (la < lb) {
        printf("LESS\n");
    } else {
        if (strcmp(a, b) > 0) {
            printf("GREATER\n");
        } else if (strcmp(a, b) < 0) {
            printf("LESS\n");
        } else {
            printf("EQUAL\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

void fibonacci(void);

int f[45];

int main(){

  int n;
  
  scanf("%d",&n);
  fibonacci();
  printf("%d\n",f[n]);

  return 0;

}

void fibonacci(){
  f[0]=f[1]=1;

  int i;
  
  for(i=2;i<45;i++){
    f[i]=f[i-1]+f[i-2];
  }
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

int main()
{
    fastio;
    int t;
    cin>>t;
    set <string> s;
    while(t--){
        string x;
        cin>>x;
        s.insert(x);
    }

    cout<<s.size()<<endl;
}

Measured memory_bytes: 19248
package main

import (
	"fmt"
	"sort"
)

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func main() {
	n := nextInt()
	k := nextInt()

	dic := map[int]int{}
	for range make([]struct{}, n) {
		a := nextInt()
		dic[a]++
	}
	seq := []int{}
	for _, v := range dic {
		seq = append(seq, v)
	}
	sort.Ints(seq)

	cnt := 0
	for len(seq) > k {
		cnt += seq[0]
		seq = seq[1:]
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 17920
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        a: [u64; n]
    }

    let mut sum = 0;
    let mut right = 0;
    let mut cnt = 0;
    for left in 0..n {
        while right < n && sum + a[right] == sum ^ a[right] {
            sum += a[right];
            right += 1;
        }

        cnt += right - left;
        
        if right == left {right+=1;}
        else {sum -= a[left];}
    }

    println!("{}", cnt);
}


Measured memory_bytes: 6396
main = do
  s <- getLine
  let ans = compute s
  putStrLn $ if ans then "YES" else "NO"

compute s = null k2
  where
    (k1,s1) = chomp "keyence" s
    (k2,_) = chomp (reverse k1) (reverse s1)

chomp xxs@(x:xs) yys@(y:ys)
  | x == y = chomp xs ys
  | True = (xxs, yys)
chomp xs ys = (xs,ys)

Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <functional>

typedef long long ll;
using namespace std;


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    bool flag = false;
    for(int i = 0; i < k; i++){
        if(a >= b){
            b *= 2;
        } else {
            if(b >= c){
                c *= 2;
            } 
        }
        if(a < b && b < c) flag = true;
    }
    if(flag){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

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

using ll = long long;

ll a[100010] = {};

int main(void){
    ll n;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    sort(a,a+n);
    
    ll tmp = 0;
    ll before = a[0];
    
    for(int i = 1; i < n; i++){
        if(before*2 >= a[i]){
            before += a[i];
        }else{
            tmp = i;
            before += a[i];
        }
    }
    
    cout << n-tmp << endl;
    
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    char c = in<char>() + 1;
    cout << c << "\n";
}

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

#define int long long

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

int n,i,t,A[N];

signed main(){
    cin >> n;
    for(i=1;i<=n+1;i++){
        if(i <= n) cin >> A[i];
        t += abs(A[i]-A[i-1]);
    }
    
    for(i=1;i<=n;i++){
        cout << t - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i+1]-A[i-1]) << endl;
    }
    
    return 0;
}   

Measured memory_bytes: 2048
N,W = map(int,input().split())

wv = []
vmax = 0

for i in range(N):

    w,v = map(int,input().split())

    vmax += v
    wv.append([w,v])


lis = [[0] + [float("inf")] * vmax]

for i in wv:

    new = [0] + [float("inf")] * vmax

    for j in range(vmax+1):

        new[j] = min(new[j] , lis[-1][j])

        if j + i[1] <= vmax:

            new[j + i[1]] = min (new[j + i[1]] , lis[-1][j] + i[0])

    lis.append(new)

#print (lis)

lis[-1].reverse()

for i in range(vmax+1):

    if lis[-1][i] <= W:
        print (vmax - i)
        break

    

Measured memory_bytes: 301168
#include<iostream>
using namespace std;
int main() {
	int x, y, z;
	cin >> x >> y >> z  ;
	if (x <= y){
		if (y <= z){
			cout << x << " " << y << " " << z << endl;
		}
		if (z < y){
			if (x <= z){
				cout << x << " " << z << " " << y << endl;
			}
			if (x > z){
				cout << z << " " << x << " " << y << endl;
			}
		}
	}
	if (x > y){
		if (y <= z){
			if (x < z) {
				cout << y << " " << x << " " << z << endl;
			}
			if (x >= z) {
				cout << y << " " << z << " " << x << endl;
			}
		}
		if (y > z){
			cout << z << " " << y << " " << x << endl;
		}
	}









	return 0;
}


Measured memory_bytes: 3088
def main():
    import numpy as np
    import sys
    input = sys.stdin.readline

    N, M, Q = map(int, input().split())
    # city[L][R]
    city = [[0] * (N + 1) for _ in range(N + 2)]

    for _ in range(M):
        L, R = map(int, input().split())
        city[L][R] += 1

    city = np.array(city).reshape(N + 2, N + 1)
    np.cumsum(city, axis=0, out=city)
    np.cumsum(city, axis=1, out=city)

    for _ in range(Q):
        p, q = map(int, input().split())
        print(city[q][q] - city[q][p - 1] - city[p - 1][q] + city[p - 1][p - 1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 16372
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=200005;
const int NN=2005;
const ll md=998244353;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    str ans="";
    while(n>0){
        if (n%26==0){
            ans+='z';
            n/=26;
            n--;
        }else{
            ans+=char(n%26+'a'-1);
            n/=26;
        }

    }
    reverse(ans.begin(),ans.end());
    cout << ans << E;
    return 0;
}


/*







*/


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){

	lli x,y;
	cin>>x>>y;

	lli a = (2*x-y)/3;
	lli b = (2*y-x)/3;

	if(a<0 || b < 0 || (2*y-x)%3!=0 || (2*x-y)%3!=0){
		cout<<0<<endl;
		return 0;
	}

	COMinit();

	cout<< COM(a+b,a)<<endl;


	return 0;
}

Measured memory_bytes: 119808
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str , st , s;
	int n , x ;
	while(1){
		cin >> str ;
		if(str=="-")break;
		cin >> n;
		for( int i=0 ; i<n ; i++ ){
			cin >> x ;
			st="";
			s="";
			for( int j=0 ; j<x ; j++ )
				st += str[j];
			for( int j=x ; j<str.size(); j++)
				s += str[j];
			str = s+st;
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

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

    int M, K;
    cin >> M >> K;

    if (K == 0) {
        REP(i, 1 << M) {
            cout << i << " " << i << " ";
        }
        cout << endl;
        return 0;
    }

    int N = 1 << M;
    vector<int> res(1 << (M + 1));
    int n = 0;
    int idx = 0;
    REP(i, 1 << M) {
        if (i == K) continue;
        n ^= i;
        res[idx] = i;
        res[2 * N - 2 - idx] = i;
        idx++;
    }
    if (n == K) {
        res[N - 1] = K;
        res[(1 << (M + 1)) - 1] = K;
        REP(i, res.size()) {
            cout << res[i] << " ";
        }
        cout << endl;
    } else {
        cout << -1 << endl;

    }


    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int k;cin>>k;
  if(k%2==0){
    P((k/2)*(k/2));
  }else{
    P((k/2)*(k/2 + 1));
  }
  return 0;
}


Measured memory_bytes: 256
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 22 May 2020
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
#define endl '\n'

const int N = 100005;
int v,e;
vector<int> g[N];
vector<bool>vis(N);
vector<int>dp(N);

int dfs(int root){
	vis[root] = 1;

	for(int nei: g[root]){
		if(!vis[nei]){
			dp[root] = max(dp[root], 1 + dfs(nei));
		}
		else{
			dp[root] = max(dp[root], 1 + dp[nei]);
		}
	}

	return dp[root];

}

signed main(){

    fastio;
    for(int i=0;i<N;i++){
    	g[i].clear();
    }
    vis.clear();
    dp.clear();


    int v,e;
    cin>>v>>e;

    int x,y;
    for(int i=0;i<e;i++){
    	cin>>x>>y;
    	g[x].push_back(y);
    }
    int ans = 0;
    for(int i=1;i<=v;i++){
    	if(!vis[i]){ // Once a node is visited => its dp value has been calculated...
			ans = max(ans, dfs(i));
		}
		else{
			ans = max(ans, dp[i]);
		}
    }

    // for(int i=1;i<=v;i++){
    // 	cout<<dp[i]<<" ";
    // }

    cout<<ans;




    return 0;
}

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

// 真ん中のブロックを取り除いて半分にする
//
// 取り扱う数字が大きいため、事前に剰余を算出する。
// mod P を取るため、算出した面積の数字を2で割ることができない。
// そのため、逆元を用いて、割り算の代わりに掛け算を使って、剰余を求める。
//
// これは和・差・積は最後に mod を取るのと、各演算ごとに mod を取るのとで結果が一致するためである。
//
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  int mod = 1000000007;

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum = sum + a.at(i);
    sum = sum % mod;
  }

  // sum = 正方形の縦軸 または 横軸の長さ
  // sum * sum = 正方形の全体の面積
  // 和・差・積は最後に mod を取るのと、各演算ごとに mod を取るのとで結果が一致する
  ll ans = (sum * sum) % mod;

  // 中央の正方形を取り除く
  for (int i = 0; i < n; i++) {
    //
    // * Ai <= 10**9 のため Ai * Ai < 2**64 となり、long long 型で保持できる
    // * この時点で mod 同士の引き算となる
    // * A mod M - B mod M = (A-B) mod M より、(sum * sum - a.at[i] * a[i]) mod M と同様である。
    //
    ans = ans - (a.at(i) * a.at(i) % mod);
    //
    // ans が負の数になった場合は、除数 p を加算して正の数にする
    //
    // ### 例
    //
    // n = -1, p = 3 の場合 n mod p = -1 mod 3 = -1 となる。
    // これに除数を複数回、加算する。
    //
    // # 1回
    // (n+p) mod p = (-1 + 3) mod 3 = 2 mod 3 = 2
    // # 2回
    // (n+p+p) mod p = (-1 + 3 + 3) mod 3 = 5 mod 3 = 2
    // # 3回
    // (n+p+p+p) mod p = (-1 + 3 + 3 + 3) mod 3 = 8 mod 3 = 2
    //
    // これらより、被除数が正の数になった後、除数を加算しても余りの数は変わらない。
    // 被除数が負の数から正の数になった場合、余りの数は |除数 - 被除数| の値となる。
    //
    if (ans < 0) { ans += mod; }
  }

  // この時点の ans は、大きい正方形から中央の正方形を取り除いた面積の mod 10**9+7 の剰余の数である。
  // 面積の半分を求めたいので 2 で割りたいが、ans が剰余の数であるため、2で割ることができない（結果がズレる可能性があるため）
  //
  // そのため、逆元を用いる。
  // 一般的な式は以下である。
  //
  //   (a/b) = a * (1/b) (mod 10**9+7)
  //   (a/b) = a * b**-1 (mod 10**9+7)
  //
  // これを今回の変数に当てはめる。
  //
  //   (ans/2) = ans * (2**-1) (mod 10**9+7)
  //
  // (mod 10**9+7) での 2 の逆元を求める。
  // つまり 2 * 2**-1 = 1 となる 2**-1 を求める。
  //
  //       2 * 2**-1
  //   --> 2 * ((10**9+7 + 1) / 2) (mod 10**9+7)
  //   --> (10**9+7 + 1) (mod 10**9+7)
  //   --> 剰余の数は 1 となる
  //
  // つまり、mod P において x の逆元は ((P+1) / x) となる。
  //
  //   x * (((P+1)) / x) (mod P)
  //   = (P+1) (mod P)
  //   = 剰余の数は1となる
  //
  ans = ans * ((mod + 1) / 2);
  ans = ans % mod;

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


Measured memory_bytes: 4816
#include <cstdio>
#include <cctype>
#include <array>
#include <unordered_map>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int n = 0, c = gcu();
	// bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
//template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

struct board {
	enum {size = 4};
	struct pos {int r, c;};
	typedef array<array<int, size>, size> arr;
	typedef unordered_map<int, int> mp;

	int h;
	arr b;
	pos p;

	void read() {
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				b[i][j] = in();
				if (!b[i][j])
					p.r = i, p.c = j;
			}
		h = hn(b);
	}

	void print() {
		for (auto &r: b) {
			for (int &c: r)
				out(&c == &r[0]?"":" ", c);
			out('\n');
		}
		out('\n');
	}

	static int hn(const arr &a) {
		int l = 0;
		for (int i = 0; i < size; i++)
			for (int j = 0; j < size; j++) {
				if (!a[i][j])
					continue;
				int k = a[i][j] - 1;
				l += abs(i - k / size) + abs(j - k % size);
			}
		return l;
	}

	static int key(const arr &a) {
		int k = 0;
		for (auto &r: a)
			for (int c: r)
				k = (k * 10) + c;
		return k;
	}

	static bool dfs(board &a, mp &m, int depth, int limit) {
		static const pos to[] = {-1, 0, 0, -1, 1, 0, 0, 1};
		if (!a.h)
			return true;

		if (depth + a.h > limit)
			return false;

		int k = key(a.b);
		auto res = m.find(k);
		if (res != m.end() && (*res).second <= depth) {
			return false;
		}


		pos tp = a.p;
		int th = a.h;
		for (pos o: to) {
			o.r += tp.r, o.c += tp.c;
			if (0 <= o.r && o.r < size && 0 <= o.c && o.c < size) {
				swap(a.b[tp.r][tp.c], a.b[o.r][o.c]);
				int f = a.b[tp.r][tp.c] - 1;
				a.h = th
					+ abs(tp.r - f / size) + abs(tp.c - f % size)
					- abs(o.r - f / size) - abs(o.c - f % size);
				a.p = o;
				if (dfs(a, m, depth + 1, limit))
					return true;
				swap(a.b[o.r][o.c], a.b[tp.r][tp.c]);
			}
		}
		a.p = tp;
		a.h = th;

		res = m.find(k);
		if (res == m.end()) {
			m[k] = depth;
		} else if ((*res).second > depth) {
			m[k] = depth;
		}
		return false;
	}

	int solver() {
		int limit = h;
		for (;;limit++) {
			mp m = {};
			if(dfs(*this, m, 0, limit))
				return limit;
		}	
	}
};

int main() {
	board b;
	b.read();
	out(b.solver(), '\n');
}



Measured memory_bytes: 33748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double angle = (h * 30 + m * 0.5 - m * 6);
    angle *= (M_PI/180);
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(angle));
    printf("%.10lf", ans);
}

Measured memory_bytes: 4176
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	w := getString()

	a := make([]int, 26)
	for _, v := range w {
		a[v-'a']++
	}

	ans := "Yes"
	for _, v := range a {
		if v%2 == 1 {
			ans = "No"
		}
	}
	fmt.Println(ans)

}


Measured memory_bytes: 640
#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;
using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
ll const mod = 998244353;
const ll MAX = 300000;
vector<vector<int>>node;
vector<P>edge;
int get_clo(int& a, int b) {
    if (a == b)return ++a;
    else return a;
}
map<P, int>mp;
int dfs(int a, int f, int pc) {
    int cl = 0;
    int mx = 0;
    for (int x : node[a]) {
        if (x == f)continue;
        cl++;
        int s = x, t = a;
        if (s < t)swap(s, t);
        mp[P(s, t)] = get_clo(cl, pc);
        mx = max(mx, dfs(x, a, mp[P(s, t)]));
    }
    return max(mx, cl);
}

int main() {
    int n;
    cin >> n;
    node.resize(n);
    edge.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        node[a].push_back(b);
        node[b].push_back(a);
        if (a < b)swap(a, b);
        edge[i] = P(a, b);
    }
    int ans = dfs(0, 0, 0);
    cout << ans << endl;
    rep(i, n - 1) {
        cout << mp[edge[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 15872
a, b, c, d = map( int, input().split() )
#print( a, b, c, d )
 
for i in range( 200 ):
    c = c - b
    if c <= 0:
        print( "Yes" )
        break
 
    a = a - d
    if a <= 0:
        print( "No" )
        break

Measured memory_bytes: 9120
n,i;
ea[2<<17],eb[2<<17],next[2<<17],first[1<<17];
long M,dp1[1<<17],dp2[1<<17],R[2<<17];
/*dfs1(u,p,i)
{
	dp1[u]=1;
	for(i=first[u];i;i=next[i])eb[i]-p?dfs1(eb[i],u),dp1[u]=dp1[u]*-~dp1[eb[i]]%M:0;
}*/
dfs1(u,p,i,I)
{
	dp1[u]=1;
	for(i=first[u];I=eb[i];i=next[i])I-p?dfs1(I,u),dp1[u]=dp1[u]*-~dp1[I]%M:0;
}
/*dfs2(u,p,x,i)
{
	i=first[u];
	dp2[u]=dp1[u]*x%M;
	make(i,p,x);
	for(;i;i=next[i])
	{
		if(eb[i]!=p)dfs2(eb[i],u,L[i]*R[next[i]]%M+1);
	}
}
make(i,p,x,t)
{
	if(i)
	{
		L[i]=x;
		t=eb[i]-p?-~dp1[eb[i]]:1;
		make(x=next[i],p,t%M*x%M);
		R[i]=R[x]*t%M;
	}
}*/
/*
dfs2(u,p,x,i)
{
	i=first[u];
	dp2[u]=dp1[u]*x%M;
	make(i,p);
	for(;i;i=next[i])eb[i]-p?dfs2(eb[i],u,R[next[i]]*x%M+1),x=x%M*-~dp1[eb[i]]%M:0;
}
*/
/**/
dfs2(u,p,x,i,I)
{
	//dp2[u]=dp1[u]*x%M;
	//for(make(i=first[u],p);I=eb[i];i=next[i])I-p?dfs2(I,u,R[next[i]]*x%M+1,0,0),x=x*-~dp1[I]%M:0;
	for(make(i=first[u],p);I=eb[i];I-p?dfs2(I,u,R[i]*x%M+1,0,0),x=x*-~dp1[I]%M:0)i=next[i];
	dp2[u]=x%M;
}
/**/
make(i,p)
{
	if(i)make(next[i],p),R[i]=R[next[i]]*(eb[i]-p?-~dp1[eb[i]]:1)%M;
}
main(u,v)
{
	/*for(scanf("%d%d",&n,&M);~scanf("%d%d",&u,&v);)
	{
		i++;
		ea[i]=u;
		eb[i]=v;
		i++;
		ea[i]=v;
		eb[i]=u;
	}*/
	//for(;~scanf("%d%d",&u,&v);)i++?ea[i]=eb[i+1]=u,ea[i+1]=eb[i]=v,i++:(n=u,M=v);
	for(;~scanf("%d%d",&u,&v);i++)i++?ea[i-1]=eb[i]=u,ea[i]=eb[i-1]=v:(n=u,M=v);
	//for(;~scanf("%d%d",&u,&v);)i++?ea[i-1]=eb[i]=u,eb[i-1]=ea[i++]=v:(n=u,M=v);
	for(;--i;first[ea[i]]=i)next[i]=first[ea[i]];
	dfs1(*R=1,0);
	dfs2(1,0,1);
	for(;i++<n;)printf("%d\n",dp2[i]);
}

Measured memory_bytes: 13824
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import qualified Data.IntMap as I
import qualified Data.Map as M

main = do
    n <- readLn
    s <- getLine
    print $ solve n s

solve :: Int -> String -> Int
solve n s = minimum (g s) + h s

h :: String -> Int
h s = length $ filter ('E'==) (tail s)

g :: String -> [Int]
g s = foldl f [0] (zip s (tail s))

f :: [Int] -> (Char,Char) -> [Int]
f [] _ = [0]
f all@(x:xs) (c,d) = x':all
    where x' = x + cc + dd
          cc = if c == 'W' then 1 else 0
          dd = if d == 'E' then -1 else 0

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

using namespace std;
using ll = int64_t;

void solve() {
    int n;
    cin >> n;
    vector<ll> ball(n);
    vector<ll> count(n+1);

    for (auto &&a:ball) {
        cin >> a;
        ++count[a];
    }

    ll comb = 0;
    for (auto j :count) {
        comb += j * (j - 1) / 2;
    }

    for (int i = 0; i < n; ++i) {
        if (count[ball[i]] == 0) continue;
        cout << comb - count[ball[i]] + 1 << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
//#include <iomanip.h>
#include <limits.h>
//#include <strstrea.h>
//#include <fstream.h>
#define ll long long
#define ull unsigned long long
//#define int64 long long
#define INF  0x3f3f3f3f

using namespace std;

const int maxn = 1e5 + 5;
int n, cnt;
int vis[maxn];

struct node {
    int val;
    int num;
} a[maxn];

bool cmp(const node & a, const node & b) {
    return a.val < b.val;
}

void print() {
    for (int i = 0; i < cnt; i++) cout << a[i].val << " ";
    cout << endl;
    for (int i = 0; i < cnt; i++) cout << a[i].num << " ";
    cout << endl;
}

int main() {
    cin >> n;
    memset(vis, 0, sizeof(vis));
    cnt = 0;
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        vis[tmp]++;
    }
    for (int i = 0; i < maxn; i++) {
        if (vis[i]) {
            a[cnt++] = {i, vis[i]};
        }
    }
    sort(a, a + cnt, cmp);
    //print();
    int i = 0;
    while (i < cnt) {
        while (a[i].num >= 3) a[i].num = (a[i].num % 3) + a[i].num / 3;
        i++;
    }
    //print();
    i = tmp = 0;
    while (i < cnt) {
        if (a[i].num > 1) tmp++;
        i++;
    }
    if (tmp % 2) cnt--;
    //print();
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1408
N=int(input())
ans=N
for i in range(N+1):
  cnt=0
  t=i
  while t>0:
    cnt+=t%6
    t//=6
  j=N-i
  while j>0:
    cnt+=j%9
    j//=9
  ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 3060
#ABC063C
N = int(input())
s = [int(input()) for _ in range(N)]
ans = -1
s.sort()
for _ in range(N+1):
    ans = sum(s)
    if ans % 10 != 0:
        break
    elif len(s) == 0:
        ans = 0
        break
    elif len(s) >= 2:
        del_ok = False
        for i in range(1, len(s)):
            if s[0]%10 == 0 and s[i]%10 != 0:
                s.pop(i)
                del_ok = True
                break
        if not del_ok:
            s.pop(0)
    else:
        s.pop(0)
print(ans)

Measured memory_bytes: 3064