akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
#define MOD 1000000007

long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}
long long int gcd(long long int a, long long int b) {
	if (a > b) {
		swap(a, b);
	}
	while (a) {
		swap(a, b);
		a %= b;
	}
	return b;
}
long long int lcm(long long int a, long long int b) {
	return a / gcd(a, b)*b;
}
#define MAX 5002

int n;
vector<long long int> v;
vector<int> g[MAX];

long long int dp[MAX][MAX][2];  //ans,min,is there server?
int child[MAX];
long long int tmp[MAX][2];
inline void dfs(int b,int pr=-1){
	child[b] = 1;
	for (int i = 0; i < g[b].size(); i++) {
		if (g[b][i] == pr)continue;
		dfs(g[b][i], b);
		child[b] += child[g[b][i]];
	}
	for (int i = 0; i <= child[b]; i++) {
		dp[b][i][0] = dp[b][i][1] = LLONG_MAX;
	}
	int cur = 1;
	int f = (v[b] < 0LL);
	dp[b][0][f] = v[b];
	for (int i = 0; i < g[b].size(); i++) {
		if (g[b][i] == pr)continue;
		//merge
		int node = g[b][i];
		int nex = cur + child[node];
		for (int f = 0; f <= nex; f++)tmp[f][0]=tmp[f][1] = LLONG_MAX;
		for (int c = 0; c <= cur; c++) {
			for (int k = 0; k <= child[node]; k++) {
				for (int jj = 0; jj < 2; jj++) {
					for (int kk = 0; kk < 2; kk++) {
						if (dp[b][c][jj] == LLONG_MAX || dp[node][k][kk] == LLONG_MAX)continue;
						tmp[c + k][jj | kk] = min(tmp[c + k][jj | kk], dp[b][c][jj] + dp[node][k][kk]);
						//cut
						if (kk == 0 || dp[node][k][kk] < 0LL) {
							tmp[c + k + 1][jj] = min(tmp[c + k + 1][jj], dp[b][c][jj]);
						}
					}
				}
			}
		}
		cur = nex;
		for (int f = 0; f <= nex; f++) {
			dp[b][f][0] = tmp[f][0];
			dp[b][f][1] = tmp[f][1];
		}
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	int ans = INT_MAX;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j < 2; j++) {
			if (dp[0][i][j] == LLONG_MAX)continue;
			if (j == 0) {
				ans = min(ans, i);
			}
			else {
				if (dp[0][i][j] < 0LL) {
					ans = min(ans, i);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 390912
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int n, c[510], s[510], f[510];
int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++)cin >> c[i] >> s[i] >> f[i];
	for (int i = 0; i < n; i++) {
		int ans = c[i] + s[i];
		for (int j = i + 1; j < n - 1; j++) {
			if (ans > s[j]) {
				ans = c[j] + s[j] + (ans - s[j] + f[j] - 1) / f[j] * f[j];
			}
			else ans = c[j] + s[j];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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

int main()
{
  int N;
  cin >> N;
  vector<P> v;
  REP(i, N) {
    ll x, y;
    cin >> x >> y;
    v.PB(MP(x, y));
  }

  if (v.size() == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll ans = LLINF;
  for (int i1 = 0; i1 < N; i1++) {
    for (int i2 = 0; i2 < N; i2++) {
      if (i1 == i2) continue;
      ll p = v[i2].FI - v[i1].FI;
      ll q = v[i2].SE - v[i1].SE;
      ll cnt = 0;
      for (int j1 = 0; j1 < N; j1++) {
        for (int j2 = 0; j2 < N; j2++) {
          if (v[j2].FI - v[j1].FI == p && v[j2].SE - v[j1].SE == q) cnt++;
        }
      }
      ans = min(ans, N - cnt);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
	int a, b, t;
	int ans = 0;
	cin >> a >> b >> t;
	int ag = a;
	while (true) {
		if (t >= a) {
			ans += b;
			a += ag;
		}
		else {
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_a

#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << "  = " << x << endl
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

#define dbg2(x, y)                                                       \
    {                                                                    \
        cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; \
    }
#define fo(i, n) for (int i = 0; i < n; i++)
#define fok(i, k, n) for (int i = k; i < n; i++)
#define foA(i, A) for (auto i : A)
const int mxN=100005;

int ar[mxN];
int dp[mxN];
int n, k;


int rfunII(){
    fo(i, n)dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);
    fo(i, n){
        for(int j=i-1;j>=0 and j>i-k-1;j--){
            dp[i]=min(dp[i], (dp[j]+abs(ar[i]-ar[j])));
        }
    }
    //fo(i, n)cout<<dp[i]<<" ";cout<<endl;
    int ans=dp[n-1];  
    return ans;  
}

int main(){
    fast;
    cin>>n>>k;
    fo(i, n)cin>>ar[i];
    cout<<rfunII();
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,ans;
map<string,bool>v;
char s[12];
int main(){
	n=read();
	while(n--){
		scanf("%s",s);
		if(!v[s])++ans,v[s]=1;
	}
	printf("%d",ans);
}


Measured memory_bytes: 19312
#N, K = [int(i) for i in input().split()]
#Hn = [int(i) for i in input().split()]

def attack(rem):
  if rem <= 1:
    return 1
  else:
    return 2 * attack(rem // 2) + 1

H = int(input())

count = attack(H)
print(count)



Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

std::int64_t func(std::int64_t x, std::int64_t y, std::int64_t z)
{
	return x * x + y * y + z * z + x * y + y * z + z * x;
}

void Main()
{
	int N;
	std::cin >> N;
	std::vector<std::int64_t> count(N + 1);
	for (auto x : boost::irange(1, N + 1))
	{
		for (auto y : boost::irange(1, N + 1))
		{
			for (auto z : boost::irange(1, N + 1))
			{
				auto v = func(x, y, z);
				if (N < v)
				{
					break;
				}
				++count[v];
			}
		}
	}
	for (auto i : boost::irange(1, N + 1))
	{
		std::cout << count[i] << std::endl;
	}
}

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

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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int n,k; cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];
    int tmp[n];
    
    for(int t = 0; t < k; t++){
        rep(i,n) tmp[i] = 0;
        rep(i,n){
            if(i - a[i] < 0){
                tmp[0]++; 
            }else{
                tmp[i-a[i]]++;
            }
            if(i + 1 + a[i] < n){
                tmp[i+1+a[i]]--;
            }
        }
        a[0] = tmp[0];
        rep(i,n-1){
            a[i+1] = a[i] + tmp[i+1];
        }
        bool f = true;
        rep(i,n) if(a[i] != n) f = false;
        if(f) break;
    }
    rep(i,n) cout << a[i] << ' ';
}

Measured memory_bytes: 5200
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <numeric>
using namespace std;

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);

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

  int count = 0;
  double sum = .0;
  for(int i=0; i<n; ++i){
    for(int j=i+1; j<n; ++j){
      double dx = x[j] - x[i];
      double dy = y[j] - y[i];
      sum += sqrt(dx*dx+dy*dy);
      count++;
    }
  }

  cout.precision(12);
  cout << (n-1) * sum / (double)count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

struct mint {
	ll x;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
	bool operator==(const mint a) const {
		return x == a.x;
	}
	bool operator!=(const mint a) const {
		return x != a.x;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<P> A(n);
    rep(i, n){
        ll t;
        cin >> t;
        if(t >= 0)A[i] = {t, 1};
        else A[i] = {-t, -1};
    }
    sort(rall(A));
    rep(i, n)a[i] = A[i].first * A[i].second;

    mint ans = 1;

    bool neg = true; rep(i, n)if(a[i] >= 0)neg = false;
    if(neg && k % 2 == 1){
        sort(rall(a));
        rep(i, k)ans *= a[i];
        cout << ans << endl;
        return 0;
    }

    int zero = 0, non_neg = 1;
    rep(i, k){
        ans *= a[i];
        if(a[i] < 0)non_neg ^= 1;
        if(a[i] == 0)zero = 1;
    }

    if(k == n || zero || non_neg){
        cout << ans << endl;
        return 0;
    }

    ll rm1 = inf, rm2 = inf;
    rep(i, k){
        if(a[i] > 0)rm1 = a[i];
        else rm2 = a[i];
    }

    ll ad1 = inf, ad2 = inf;
    for(int i = n-1; i >= k; i--){
        if(a[i] < 0)ad1 = a[i];
        else ad2 = a[i];
    }

    if(rm1 == inf || ad1 == inf){
        cout << ans / rm2 * ad2 << endl;
    }else if(rm1 == inf || ad2 == inf){
        cout << ans / rm1 * ad1 << endl;
    }else{
        if(rm2 * ad1 >= rm1 * ad2){
            cout << ans / rm1 * ad1 << endl;
        }else{
            cout << ans / rm2 * ad2 << endl;
        }
    }
}

Measured memory_bytes: 6420
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;


int main() {

    int n,m;
    cin >> n >> m ;
    int x[m];
    for(int i=0;i<m;i++) cin >> x[i] ;

    sort(x,x+m);

    int diff[m-1];
    for(int i=0;i<(m-1);i++){
        diff[i] = x[i+1]-x[i];
    }
    sort(diff,diff+(m-1));

    int ans = 0; 
    for(int i=0;i<m-n;i++){
        ans+=diff[i];
    }

    cout << ans << endl ;

    return 0 ;
}

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

long long MOD=1000000007LL;

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

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<2000001;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;
}
 
long long MODpow(long long a,int b){
	if(b==0)return 1;
	if(b%2==0){
		long long t=MODpow(a,b/2);
		return (t*t)%MOD;
	}
	return (a*MODpow(a,b-1))%MOD;
}

int main(){
	COMinit();
	int S;
	cin >> S;
	long long ans=0;
	
	for(int num=1;num<=S/3;num++){
		int s=S-num*3;
		long long add=fac[s+num-1];
		add*=finv[s];
		add%=MOD;
		add*=finv[num-1];
		add%=MOD;
		ans+=add;
		ans%=MOD;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 50512
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long dp[6000];
long long new_dp[6000] = {};
long long cnter[6000] = {};
int main() {
#define int long long
	int n;
	cin >> n;
	vector<tuple<long long, long long, long long, long long, long long>> gogo;
	REP(i, n) {
		long long r, a, t, w;
		cin >> r >> a >> w >> t;
		long long border = 5000 - (r + t);
		gogo.push_back(make_tuple(border, r, a, t, w));
		/*
		REP(q, r) {
			cnter[q] = -1e9;
		}
		for (int q = border + r; q < 5000; ++q) {
			cnter[q % r] = max(cnter[q % r] + w, dp[q - r] + a);
			new_dp[q] = max(dp[q], cnter[q % r]);
		}
		for(int i = border+r;i < 5000;++i){
			dp[i] = new_dp[i];
		}
		*/
	}
	sort(gogo.begin(), gogo.end());
	REP(i, n) {
		long long r, a, t, w;
		r = get<1>(gogo[i]);
		a = get<2>(gogo[i]);
		t = get<3>(gogo[i]);
		w = get<4>(gogo[i]);
		long long border = get<0>(gogo[i]);
		REP(q, r) {
			cnter[q] = -1e9;
		}
		for (int q = border + r; q < 5000; ++q) {
			cnter[q % r] = max(cnter[q % r] + w, dp[q - r] + a);
			new_dp[q] = max(dp[q], cnter[q % r]);
		}
		for (int i = border + r; i < 5000; ++i) {
			dp[i] = new_dp[i];
		}
	}
	long long ans = 0;
	for (int i = 0; i < 5000; ++i) {
		if (dp[i] == 0) continue;
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}


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

int main() {
    string s;
    cin>>s;
    int n = s.size();
    int p1=0,p2 = ((n-1)/2) -1,p3 = ((n+3)/2) -1,p4 = n-1;
    bool flag = true;
    while( p1<=p2 &&p3<=p4 ){
        
        // cout<<p1<<" "<<p2<<" "<<p3<<" " <<p4<<"\n";
        if( (s[p1]==s[p2]) && (s[p2] == s[p3])  && (s[p3]==s[p4]) ){
            flag = true;
        }
        else
        {
            flag = false;
            break;
        }
        
        p1++;
        p2--;
        p3++;
        p4--;
        

    }
    if(flag) cout<<"Yes";
    if(!flag) cout<<"No";
    return 0;

}

Measured memory_bytes: 256
S=input()
res=[]
for i in range(2**(len(S)-1),2**(len(S))):
    tmp=''
    for j in range(len(S)):
        if j==len(S)-1:
            tmp+=S[j]
        elif (str(bin(i))[3:])[j]=='1':
            tmp+=S[j]
        else:
            tmp+=S[j]+'+'
    if tmp[-1]=='+':
        tmp=tmp[:-1]
    res.append(eval(tmp))
print(sum(res))

Measured memory_bytes: 8992
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

vl A(MX), F(MX); 
 
int N; ll K;

bool poss(ll T) {
	ll sum = 0;
	F0R(i, N) {
		if (A[i] * F[i] > T) {
			
			sum += A[i] - T / F[i];
		}
	}

	return sum <= K;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	cin >> N >> K; A = vl(N); F = vl(N);
	F0R(i, N) cin >> A[i];
	F0R(i, N) cin >> F[i];
	
	sort(all(A)); 
	sort(all(F)); reverse(all(F));
	

	
	ll lo = 0, hi = 1000000000010;
	F0R(i, 50) {
		ll mid = (lo+hi)/2;
		if (poss(mid)) {
			hi = mid;
		} else {
			lo = mid+1;
		}
	}
	if (poss(min(hi, lo))) {
		cout << min(hi, lo) << endl;
	} else {
		cout << max(hi, lo) << endl;
	}
	
	
	
	
	
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 4208
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	int x = x2;
	int y = y2;
	for (int i = 0; i < 2; ++i) {
		swap(dx, dy);
		dx = -dx;
		x += dx;
		y += dy;
		cout << x << " " << y << " ";
	}
	return 0;
}


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

int main(void){
    
    ll x, y=0;
    
    cin >> x;
    
    for(ll i=-1000; i<=1000; i++){
        
        y = i * i * i * i * i;
        
        for(ll j=-1000; j<=1000; j++){
            
            if(x==y-j*j*j*j*j){
                
                cout << i << " " << j << endl;
                return 0;
                
            }
            
        }
        
    }
    
    return 0;
    
}

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2-x1, dy = y2-y1;
    int x3 = x2-dy, y3 = y2+dx;
    int x4 = x1-dy, y4 = y1+dx;
    cout << x3 << " " << y3 << " " << x4 << " "<< y4 << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$n = intval(fgets(STDIN));

// 階乗　1*2*3* ...... 100
while ($n !== 0){
    $number = 1;
    $count = 0;
    for ($j = $n; $j >= 1; $j--){
        /*
        12
        $j >= 1
        12
        11
        10
        ... 
        $j-- これで下がる。
        */ 
        $number *= $j;
        // $number = $number * $j;
        while($number % 10 == 0){
            $number /= 10;
            $count++;
        }
        if($number > 100000){
            /*
            230,456,999 / 10000
            = 23,045,6999 floorで切り捨てる。
            = 23,045 * 10000
            = 230,450,000

            230,456,999 - 230,450,000
            = 56,999
            */
            $number = $number - floor($number / 10000) * 10000;
        }
    }
    $n = intval(fgets(STDIN));
    echo $count;
    echo PHP_EOL;
}


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

int main() {
  int a, b;
  std::cin >> a >> b;
  if(a%2 != 0 && b%2 != 0) {
    cout << "Odd" << endl;
  } else {
    std::cout << "Even" << '\n';
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

def main():
    #N, M = map(int, input().split())
    N, M = map(int, input().split())

    As = list(map(int, input().split()))
    As = sorted(As)
    """
    queue = deque()
    for i in range(N):
        a = As[i]
        pos = bisect.bisect_left(queue, a)
        queue.insert(pos, a)
    """

    B_C = []
    for i in range(M):
        B, C = map(int, input().split())
        B_C.append((B, C))

    B_C = sorted(B_C, key=lambda x: x[1], reverse=True)

    total = 0
    for B, C in B_C:
        for i in range(B):
            if not As or C <= As[0]:
                break
            As.pop(0)
            total += C

    if As:
        total += sum(As)

    print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23252
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int X;
  cin >> X;
  if (X == 7 || X == 5 || X == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

int gcd(int x, int y) {
  while (y != 0) {
    int tmp = x;
    x = y;
    y = tmp % y;
  }
  return x;
}

int main() {
  int n, x;
  cin >> n >> x;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    ans = gcd(ans, abs(y - x));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int line=cin.nextInt();
			int n=cin.nextInt();
			if(line==0)break;
			int[][][] cost=new int[n+1][n+1][2];
			for(int i=0;i<line;i++){
				int a=cin.nextInt();
				int b=cin.nextInt();
				int c=cin.nextInt();
				int t=cin.nextInt();
				cost[a][b][0]=cost[b][a][0]=c;
				cost[a][b][1]=cost[b][a][1]=t;
			}
			for(int i=0;i<=n;i++){
				for(int j=0;j<=n;j++){
//					System.out.print(cost[i][j][0]+" ");
				}
//				System.out.println();
			}
			for(int k=cin.nextInt();k--!=0;){
				MyComparator comparator = new MyComparator();
				PriorityQueue<int[]> q = new PriorityQueue<int[]>(10000,comparator);
				int start=cin.nextInt();
				int goal=cin.nextInt();
				int type=cin.nextInt();
				boolean[]already=new boolean[n+1];
				q.add(new int[]{start,0});
				while(!q.isEmpty()){

					int[] array=q.poll();
					int a=array[0];
					int c=array[1];
//					System.out.println(a+" "+c);
					if(already[a])continue;
					already[a]=true;
					if(a==goal){
						System.out.println(c);
						break;
					}
					for(int i=0;i<=n;i++){
						if(cost[a][i][type]>0&&!already[i]){
							//						int[] next={i,c+cost[a][i][type]};
							q.add(new int[]{i,c+cost[a][i][type]});
							//						q.add(next);

						}
					}
				}
			}

		}
	}
	static class MyComparator implements Comparator<int[]>{

		public int compare(int[] a, int[]b ){
			return a[1]-b[1];
		}

	}

}

Measured memory_bytes: 159152
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);

    int MAX = 0;
    int MIN = 10000000000;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        MAX = max(A[i],MAX);
        MIN = min(A[i],MIN);
    }

    cout << MAX - MIN << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


def combination_mod(n, r, mod):
    # if r > n:
    #     return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


def ret_list_combination_mod(n, r, mod):
    ret = [1]
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    # r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
        ret.append(nf * pow(rf, mod - 2, mod) % mod)
    return ret

# https://atcoder.jp/contests/abc156/tasks/abc156_e


MOD = 10**9 + 7
n, k = read_ints()
# n<=kのときは簡単
if n <= k:
    print(combination_mod(n + n - 1, n, MOD))
    exit()
# n>kのときはどうしよう

ans = 1
nCa = ret_list_combination_mod(n, k, MOD)
n_1Ca = ret_list_combination_mod(n - 1, k, MOD)
for a in range(1, k + 1):
    ans += nCa[a] * n_1Ca[a]  # ここ高速化しないと厳しいかな
    ans %= MOD
print(ans)


Measured memory_bytes: 54644
import java.util.*;
import java.lang.*;

public class Main {
    static long difference(long a, long b, long c){
        long max = Math.max(a,Math.max(b,c));
        long min = Math.min(a,Math.min(b,c));
        return max-min;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int D = sc.nextInt();

        int ans = 0;

        for(int m=1; m<=M; m++) for(int d=1; d<=D; d++){
            int d1 = d%10, d10 = d/10;
            if(d1 >= 2 && d10 >= 2 && d1*d10==m) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#!/usr/bin/env python3
def solve(n, s):
    ans = float('inf')
    black = 0
    white = s.count('.')
    for m in range(n + 1):
        ans = min(ans, black + white)
        if m < n and s[m] == '#':
            black += 1
        if m < n and s[m] == '.':
            white -= 1
    return ans

n = int(input())
s = input()
print(solve(n, s))


Measured memory_bytes: 3500
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	int a=int.Parse(ReadLine());
    string s= ReadLine();
    if(a>=3200)
      WriteLine(s);
    else
      WriteLine("red");
  }

  int[] Readint(){
    string[] s = ReadLine().Split();
    int[] res=new int[s.Length];
    Parallel.For(0,s.Length,i=>{
      res[i]=int.Parse(s[i]);
    });
    return res;
  }
}


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

int main()
{
  int64_t N, K, d, a, ans = 0;
  cin >> N >> K;
  vector<int64_t> C(N, 0);
  for (int i = 0; i < K; i++)
  {
    cin >> d;
    for (int j = 0; j < d; j++)
    {
      cin >> a;
      a--;
      C.at(a)++;
    }
  }
  for (int i = 0; i < N; i++)
  {
    if (C.at(i) == 0)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
n = gets.chomp.to_i
a = gets.split.map(&:to_i)
h = Hash.new(0)
a.each do |e|
  if e % 4 == 0
    h[4] += 1
  elsif e % 2 == 0
    h[2] += 1
  else
    h[1] += 1
  end
end
if h[2] > 1
  n -= h[2]
  if h[4] >= (n/2.0).ceil
    puts 'Yes'
  else
    puts 'No'
  end
else
  if h[4] >= n/2
    puts 'Yes'
  else
    puts 'No'
  end
end


Measured memory_bytes: 8452
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    int N;
    cin >> N;
    map<string, int> mp;
    for (int i=0; i<N; i++) {
        string S;
        cin >> S;
        mp[S]++;
    }

    // output
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA  x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;


    return 0;
}


Measured memory_bytes: 3652
N, M = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
if N >= M:
    ans = 0
    print(ans)
else:
    X.sort()
    diff = [X[i+1] - X[i] for i in range(M-1)]
    diff.sort()
    for j in range(M-N):
        ans += diff[j]
    print(ans)

Measured memory_bytes: 90744
n = int(input())
l = []
if n == 1:
    print(1)
else:
    for i in range(1, n + 1):
        for j in range(2, n + 1):
            if i ** j > n:
                break
            l.append(i ** j)
    l = list(set(l))
    l = sorted(l)
    ans = 0
    for i in range(len(l)):
        if l[i] > n:
            break
        ans = l[i]
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
long long j,k;
cin>>s>>k;j=100007;
for(int i=0;i<s.length();i++){
	if(s[i]!='1'){j=i;break;}
}
if(j==100007)cout<<1<<endl;
else{
	if(k-1<j)cout<<1<<endl;
	else cout<<s[j]<<endl;
}
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		int W=cin.nextInt(),H=cin.nextInt(),x=cin.nextInt(),y=cin.nextInt(),r=cin.nextInt();
		
		if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)System.out.println("Yes");
		else System.out.println("No");
	}

}



Measured memory_bytes: 26288
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <vector>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L


const int N = 2e5 + 5;

 
int vis[N];


int32_t  main() {

	IOS;

 
	long double a, b, h, m;

	cin >> a >> b >> h >> m;


	long double tmp1 = h * 5.0 + m / 60 * 5.0;
	//cout << tmp1 << endl;
	long double diff = abs(tmp1 - m);

	long double degree = diff * 6.0;
	//cout << degree << endl;
	long double rad = (degree * PI) / 180;

	long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
		b) * cosl(rad);

	cout << fixed << showpoint << setprecision(20) << sqrt(rsq) << endl;

}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  vector<double> h;
  double in;
  while(cin >> in){
	h.push_back(in);
  }
  sort(h.begin(),h.end());
  cout << h[h.size()-1]-h[0] << endl; 
  return 0;
}

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

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

using namespace std;

int main(){
	int n,k; cin>>n>>k;

	double ans=0;
	for(int i=1;i<=n;i++){
		int a=i;
		double p=1.0/n;
		while(a<k) a*=2, p/=2;
		ans+=p;
	}
	cout<<setprecision(9)<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import defaultdict
import sys
sys.setrecursionlimit(10**5+10)

def main():
  n, m, k = map(int, input().strip().split())
  friends = defaultdict(lambda :{'children':list(), 'x':-1, 'visited':False})
  blocks = defaultdict(list)
  visited = set()
  
  for _ in range(m):
    a, b = map(int, input().strip().split())
    friends[a]['children'].append(b)
    friends[b]['children'].append(a)

  for _ in range(k):
    c, d = map(int, input().strip().split())
    blocks[c].append((d))
    blocks[d].append((c))
    
  def dfs(i, x):
    friends[i]['x'] = x
    friends[i]['visited'] = True
    count = 1
    for child in friends[i]['children']:
      if friends[child]['visited']:
        continue
      count += dfs(child, x)
    return count
  
  num = 1
  size = dict()
  for i in range(1, n+1):
    if friends[i]['visited']:
      continue
    count = dfs(i, num)
    size[num] = count
    num += 1
    
  ans = []
  for i in range(1, n+1):
    nblock = 0
    for ib in blocks[i]:
      if friends[i]['x'] == friends[ib]['x']:
        nblock += 1
    ans.append(size[friends[i]['x']] - len(friends[i]['children']) - nblock - 1)
  print(' '.join(list(map(str, ans))))
  
if __name__=='__main__':
  main()



Measured memory_bytes: 105264
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
a=array(n,1)
n.times do|i|
  a[i]=gets.to_i
end

INF=Float::INFINITY
dp=[]

dp.push(a[0])
n.times do|i|
  if dp[-1]<a[i]
    dp.push(a[i])
  else
    head=0
    tail=dp.size-1
    100.times do
      mid=(head+tail)/2
      if dp[mid]>=a[i]
        tail=mid
      else
        head=mid
      end
    end
    dp[tail]=a[i]
  end
end

puts dp.size


Measured memory_bytes: 8516
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cout << #x << " = " << x << endl
 
using namespace std;

int t[300];

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	t[1] = 300000;
	t[2] = 200000;
	t[3] = 100000;
	int c = t[a] + t[b];
	if(a == 1 && b == 1)
		c += 400000;
	printf("%d", c);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

int N,K;
int A[200005];
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,N)scanf("%lld",&A[i]);
    sort(A,A+N);
    if(K==1){
        printf("%lld\n",A[N-1]);
        return 0;
    }
    if(A[N-1]<0&&K%2==1){
        int prod=1;
        rep(i,K){
            prod*=A[N-i-1];
            prod%=mod;
        }
        printf("%lld\n",(prod%mod+mod)%mod);
        return 0;
    }
    int cnt=0;
    int left=-1;
    int right=N;
    int prod=1;
    while(cnt<K){
        if(K-cnt==1)
        {
            prod*=A[right-1];
            prod%=mod;
            break;
        }
        if(A[left+2]>=0)
        {
            prod*=A[right-1];
            prod%=mod;
            right-=1;
            cnt+=1;
            continue;
        }
        if(A[right-2]<0)
        {
            prod*=(A[left+1]*A[left+2])%mod;
            prod%=mod;
            left+=2;
            cnt+=2;
            continue;
        }
        int p1=A[left+1]*A[left+2];
        int p2=A[right-1]*A[right-2];
        if(p1>p2)
        {
            prod*=(A[left+1]*A[left+2])%mod;
            left+=2;cnt+=2;
        }
        else
        {

            prod*=A[right-1];
            right-=1;cnt+=1;
        }
        prod%=mod;
    }
    printf("%lld\n",(prod%mod+mod)%mod);
    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
int INF = 100000;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<string> S(n);
    for (int i = 0; i < n; i++){
      cin >> S[i];
    }
    while (1){
      bool update = false;
      for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
          if (i != j){
            int sz1 = S[i].size();
            int sz2 = S[j].size();
            bool ok = false;
            for (int k = 0; k <= sz1 - sz2; k++){
              if (S[i].substr(k, sz2) == S[j]){
                ok = true;
                break;
              }
            }
            if (ok){
              S.erase(S.begin() + j);
              update = true;
              break;
            }
          }
        }
        if (update){
          break;
        }
      }
      n = S.size();
      if (!update){
        break;
      }
    }
    vector<vector<int>> d(n, vector<int>(n));
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        int sz1 = S[i].size();
        int sz2 = S[j].size();
        for (int k = max(sz2 - sz1, 0); k <= sz2; k++){
          if ((S[i] + S[j].substr(sz2 - k)).substr(sz1 + k - sz2) == S[j]){
            d[i][j] = k;
            break;
          }
        }
      }
    }
    vector<vector<int>> dp(1 << n, vector<int>(n, INF));
    for (int i = 0; i < n; i++){
      dp[1 << i][i] = S[i].size();
    }
    for (int i = 0; i < (1 << n); i++){
      for (int j = 0; j < n; j++){
        if (i >> j & 1){
          for (int k = 0; k < n; k++){
            if (!(i >> k & 1)){
              dp[i + (1 << k)][k] = min(dp[i + (1 << k)][k], dp[i][j] + d[j][k]);
            }
          }
        }
      }
    }
    int ans = INF;
    for (int i = 0; i < n; i++){
      ans = min(ans, dp[(1 << n) - 1][i]);
    }
    cout << ans << endl;
  }
}


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

using namespace std;
const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
int h, w, d, dp[105][105];
char a[105][105];
bool path[101][101][101][101];

void BFS(int u, int v) {
    path[u][v][u][v] = 1;
    queue < pair <int, int > > q;
    q.push(make_pair(u, v));
    while(!q.empty()) {
        int xx = q.front().first;
        int yy = q.front().second;
        q.pop();

        for(int dir=0 ; dir<2 ; ++dir) {
        int nextU = xx + dx[dir];
        int nextV = yy + dy[dir];
        if(a[nextU][nextV]=='#' && path[u][v][nextU][nextV] == 0) {
            q.push(make_pair(nextU, nextV));
            path[u][v][nextU][nextV] = 1;
        }
    }
    }

}

int main()
{
    if (fopen(".inp", "r")) freopen(".inp", "r", stdin);
    cin >> h >> w;
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) cin >> a[i][j];
    }
    d = 0;

   for(int i=1 ; i<=h ; ++i)
       for(int j=1 ; j<=w ; ++j) {
            BFS(i, j);
       }

    for(int i = 2; i <= h; ++i) dp[i][0] = 1e9;
    for(int j = 2; j <= w; ++j) dp[0][j] = 1e9;
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            if(a[i][j] == '.') {dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]); continue;}
          //  dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
          dp[i][j] = 1e9;
            for(int u = 1; u <= i; ++u) {
                for(int v = 1; v <= j; ++v) {
                    if(path[u][v][i][j]) dp[i][j] = min(dp[i][j], min(dp[u - 1][v], dp[u][v - 1]) + 1);
                }
            }
        }
    }
    cout << dp[h][w];
    return 0;
}


Measured memory_bytes: 85236
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int d = sc.nextInt();
		int i = sc.nextInt();

		if((d*i)%2==0){
		System.out.println("No");

		}else{
		System.out.println("Yes");

		}

	}

}

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

int main()
{
    int n;
    cin >> n;
    vector<int> L(n);
    rep(i, n) cin >> L.at(i);

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

    int answer = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int k = lower_bound(L.begin(), L.end(), L.at(i) + L.at(j)) - L.begin();
            answer += max(0, k - (j + 1));
        }
    }
    cout << answer << endl;
}

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

int main() {
 int k;
  long long int n,j=3,j2,s=754;cin>>n;for(long long int i=3;;i++){
   
  if(n>pow(10,i)) j++;
   else break;
 }
  j2=j;
   long long int a[j];for(int i=0 ;i<j;i++) {
     a[i]=n/pow(10,j2-1);//cout<<a[i]<<endl;;
     
     n=n-a[i]*pow(10,j2-1); j2--;
   }
  
for(int i=0;i<j-2;i++){
  k=100*a[i]+10*a[i+1]+a[i+2];//cout<<k<<endl;
  if(max(753,k)-min(753,k)<s){
    s=max(753,k)-min(753,k);
}
                                    
}
cout<<s<<endl;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  sort(A.begin(), A.end());
  int B = A.back();
  int S = A.front();
  using P = pair<int, int>;
  vector<P> ans;
  rep(i, 1, N-1) {
    if(A[i] >= 0) {
      ans.push_back(P(S, A[i]));
      S -= A[i];
    } else {
      ans.push_back(P(B, A[i]));
      B -= A[i];
    }
  }
  ans.push_back(P(B, S));
  cout << B - S << endl;
  for(P p : ans) cout << p.first << " " << p.second << "\n";
  return 0;
}


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

using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  vector<int> w(N);
  vector<int> v(N);
  for(int i = 0; i < N; i++) cin >> P[i];
  for(int i = 0; i < N; i++) cin >> Q[i]; 
  int count = 1;
  vector<int> R(N);
  R = P;
  sort(P.begin(),P.end());
 
  int a,b;
 do{
   if(R == P) a = count;
   if(Q == P) b = count;

   count++;

  }while(next_permutation(P.begin(),P.end()));
  cout << abs(a-b) << endl;
 return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
D = [0] * (n+1)
now = 1
for i in range(1, k+1):
    tmp = A[now-1]
    if not D[tmp]:
        now = tmp
        D[now] += i
    else:
        pre = D[tmp]
        loop = i - D[tmp]
        if loop>1:
            now=D.index((k - pre) % loop + pre)
        else:
            now=tmp
        break
print(now)

Measured memory_bytes: 32368
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;

const int INF = 2e9;
const LL LINF = 3e18;

LL n;
LL a[200010];
LL ans = 0;

LL solve(LL first)
{
  LL ret = 0;
  LL *p1, *p2;
  p1 = lower_bound(a + first, a + n + first, a[n] / 3 + a[first]);
  p2 = lower_bound(p1, a + n + first, (a[n + first] - *p1) / 2 + *p1);
  
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p2--;
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p1--;
  p2 = lower_bound(p1, a + n + first, (a[n + first] - *p1) / 2 + *p1);
  
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p2--;
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));


  p2 = lower_bound(a + first, a + n + first, a[n] / 3 * 2 + a[first]);
  p1 = lower_bound(a + first, p1, (*p2 - a[first]) / 2 + a[first]);
  
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p1--;
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p2--;
  p1 = lower_bound(a + first, p1, (*p2 - a[first]) / 2 + a[first]);
  
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));

  p1--;
  ret = max(ret, min(*p1 - a[first], min(*p2 - *p1, a[n + first] - *p2)));
  return ret;
}

int main()
{
  scanf("%lld", &n);
  for(LL i = 1; i <= n; i++)
    scanf("%lld", &a[i]);

  for(LL i = n + 1; i <= 2 * n; i++)
    a[i] = a[i - n];

  for(LL i = 2; i <= 2 * n; i++)
    a[i] += a[i - 1];

  for(LL i = 0; i < n; i++)
    ans = max(ans, solve(i));

  printf("%lld\n", ans);
  return 0;
}

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

typedef long long ll;

int main() {
    int R;
    cin >> R;
    cout << fixed << setprecision(10) << 3.14159265358979 * R * 2 << "\n";
}

Measured memory_bytes: 3788