akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;
#define index_of(as, x) distance(as.begin(), lower_bound(as.begin(), as.end(), x))

int levenshtein_distance(string x, string y) {

    vector<vector<int>> LP(x.size() + 1, vector<int>(y.size() + 1, 0));

    for (int j = 1; j <= x.size(); j++) LP[j][0] = j;
    for (int k = 1; k <= y.size(); k++) LP[0][k] = k;

    //aをbに近づけたい!
    for (int j = 1; j <= x.size(); j++) {
        for (int k = 1; k <= y.size(); k++) {
            //a[j]を削除するか、a[j+1]にb[k]と同じ文字を挿入するか
            //上記２つの行為の回数で最小な方を採用
            int m = min(LP[j - 1][k] + 1, LP[j][k - 1] + 1);
            if (x[j - 1] == y[k - 1]) {
                //最後の文字が同じだから最後の文字がなくても編集距離は同じ
                m = min(m, LP[j - 1][k - 1]);
                LP[j][k] = m;
            } else {
                //最後の文字を置換する
                m = min(m, LP[j - 1][k - 1] + 1);
                LP[j][k] = m;
            }
        }
    }
    return LP[x.size()][y.size()];
}

int main() {

    string s, t;
    cin >> s >> t;
    cout << levenshtein_distance(s, t) << endl;

}




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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

int N;
//vi rows,cols;
vi a,b;
int H,W;
vector<ii> pts;
ll r[10];
set<ii> done;
int main() {
	ios::sync_with_stdio(0);
	cin >> H >> W >> N;
	a.resize(N);b.resize(N);
	for (int c=0;c<N;c++) {
		cin >> a[c] >> b[c];
		a[c]--;b[c]--;
		//for (int i=a[c],ct=0;ct<3 && i>=0;i--,ct++) rows.push_back(i);
		//for (int j=b[c],ct=0;ct<3 && j>=0;j--,ct++) cols.push_back
		pts.push_back({a[c],b[c]});
	}

	sort(pts.begin(),pts.end());
	ll tot=0;
	
	for (ii pt:pts) {
		for (int i=pt.x-2;i<=pt.x;i++) for (int j=pt.y-2;j<=pt.y;j++) {
			if (0<=i && i+3<=H && 0<=j && j+3<=W && !done.count({i,j})) {
				done.insert({i,j});
				int ct=0;
				for (int c=0;c<3;c++) for (int d=0;d<3;d++) if (binary_search(pts.begin(),pts.end(),ii{i+c,j+d}))
					ct++;
				r[ct]++;
				tot++;
			}
		}
	}
	if (H>=3 && W>=3)
	r[0]+=(ll)(H-2)*(W-2)-tot;

	for (int i=0;i<10;i++) cout << r[i] << endl;

}

Measured memory_bytes: 44020
//#include "pch.h" 
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
using namespace std;
int n, m;
pair<int, int>a[100010];
signed main() {
	cin >> n >> m;
	int cnt = 0;
	int sum = 0;
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	rep(i, n) {
		if (m - sum > a[i].second) {
			sum += a[i].second;
			cnt += a[i].first*a[i].second;
		}
		else {
			cnt += a[i].first*(m - sum);
			cout << cnt << endl;
			break;
		}
	}
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	long long int x;
	long long int t;
	cin >> x >> t;
	if (x <= t) {
		cout << 0;
	}
	else {
		cout << x - t;
	}
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

increase=None
ans=0

for i in range(n):
    if i!=n-1:
        if increase==None:
            if a[i]==a[i+1]:
                pass
            elif a[i]<a[i+1]:
                increase=True
            else:
                increase=False
        elif increase==True:
            if a[i]>a[i+1]:
                ans+=1
                increase=None
        else:
            if a[i]<a[i+1]:
                ans+=1
                increase=None
ans+=1
print(ans)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=1e5+1;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define sclli(x) scanf("%lld",&x);
#define pii pair<int,int>
#define plli pair<long long int ,lont long int>
#define foit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr);
#define sz(x) x.size()

int main()
{
    
    fast
    int n;
    cin>>n;
    int arr[n],dp[n];
    fo(i,0,n)
    cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    fo(i,2,n)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 1e5 + 5;
const int oo = 1e9 + 5;
const int MOD = 998244353;

int v[N];
void solve() {
    int n, k;
    cin >> n >> k;
    for (int i=0;i<n;++i) cin >> v[i];
    sort(v, v +n);
    long long ans = 0;
    for (int i=0;i<k;++i) ans += v[i];
    cout << ans << '\n';
} 

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  ll a;cin >> a;
  ll ans = 0;
  for(int i = 0; i <= a; ++i){
    if(i*(i+1)>=2*a){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
  INT(N);
  map<ll,int> mp;
  FOR(i,1,N+1){
    map<ll,int> mp1=prime_factor(i);
    for(auto p:mp1){
      mp[p.fi]+=p.se;
    }
  }
  ll cnt2=0;
  ll cnt4=0;
  ll cnt14=0;
  ll cnt24=0;
  ll cnt74=0;
  for(auto x:mp){
    if(x.se>=2){
      cnt2++;
    }
    if(x.se>=4){
      cnt4++;
    }
    if(x.se>=14){
      cnt14++;
    }
    if(x.se>=24){
      cnt24++;
    }
    if(x.se>=74){
      cnt74++;
    }
  }
  cout << (cnt2-2)*(cnt4*(cnt4-1)/2)+(cnt2-1)*cnt24+(cnt4-1)*cnt14+cnt74 << endl;
}

Measured memory_bytes: 3636
/*
 * Author       : YangDavid
 * Created Time : 2019年06月01日 星期六 20时33分03秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const int MOD = 1000000007;
int muln(int x, int y) {
    return 1LL  * x * y % MOD;
}
int qpow(int x, int y) {
    int ret = 1;
    for(; y; y >>= 1, x = muln(x, x))
        if(y & 1) ret = muln(ret, x);
    return ret;
}
int mo(int x) {
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}
int n, a, b, c, fac[211111], ifac[211111], ap[211111], bp[211111];
int inv(int x) {
    return qpow(x, MOD - 2);
}
int C(int from, int cho) {
    if(from < cho) return 0;
    return muln(fac[from], muln(ifac[cho], ifac[from-cho]));
}

int main() {
    fac[0] = ifac[0] = 1;
    rep(i, 200020) {
        fac[i] = muln(fac[i - 1], i);
        ifac[i] = inv(fac[i]);
    }
    cin >> n >> a >> b >> c;
    int inv100 = inv(100);
    a = muln(a, inv100);
    b = muln(b, inv100);
    c = muln(c, inv100);
    int na = muln(a, inv(a + b));
    int nb = muln(b, inv(a + b));
    a = na, b = nb;
    ap[0] = 1, bp[0] = 1;
    rep(i, 200020) ap[i] = muln(ap[i-1], a), bp[i] = muln(bp[i-1], b);
    int ans = 0, factor = inv(mo(1-c));
    for(int k = n; k <= 2 * n - 1; ++k) {
        int tot = mo(muln(ap[n], bp[k-n]) + muln(ap[k-n], bp[n]));
        ans = mo(ans + muln(k, muln(tot, C(k-1, n-1))));
    }
    printf("%d\n", muln(ans, factor));
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<vector<ll>> G;
vector<bool> seen;
struct UnionFind{
  vector<ll> par,siz;
  
  UnionFind(ll N):par(N+1),siz(N+1,1){
    for(int i=0; i<=N; i++)
      par[i]=i;
  }
  
  void mkpar(ll n, ll set){
    for(auto next_n: G[n]){
      if(seen[next_n]) continue;
      seen[next_n]=true;
      par[next_n]=set;
      mkpar(next_n,set);
    }
  } 
  
  ll root(ll x){
    if(par[x]==x)
      return x;
    return par[x]=root(par[x]);
  }
  
  void unite(ll x, ll y){
    ll rx=root(x), ry=root(y);
    if(rx==ry)
      return;
    par[ry]=rx;
    siz[rx]+=siz[ry];    
  }
  
  bool issame(ll x, ll y){
    return root(x)==root(y);
  }
  
  ll size(ll x){
    return siz[root(x)];
  }
};

void dfs(){
  
}
//どちらでも、いみわかった
//1は自分の都市自身だけか
//道路の関係いれたあと、線路でも満たしているか
//しゃくとり？TLEになんないかな
//1個にいれて2個はいってるか、かな
//2 3
//2 5と
//3 5で35判定か
//むずいな。unionfindするかどうか
//道路の3と5の親が一致して、かつ線路の3と5の親が一致してるか
//N^2/2すべての組み合わせで探索になると無理か
//KとLの組み合わせだけしらべりゃいいのか
//いけるけどやだな、、がんばるか。22:01
//いけた。22:12
//sample以外全部WAかい
//連結されているもの同士か。どう勘定するか。sizeか
//鉄道の連結が、道路で満たしてなければいれない、
//tree2のサイズが答えになる、かな
//なおした22:36 全部WAか
//ああ、
//2 5と
//2 3
//3 5
//があったら2 5は加算されるべきだが排除されているということだね
//DFSしてるんならつどissame判定もいけるじゃろか
//それだと、2-3 2-5のときに3-5の判定がいけないのか
//parが同じもので重複してるものを探す必要があるか
//tree1.par[1]のものが{1,2,3,4}
//tree2.par[1]のものが{1,2,4,5,6}とかだったら1,2,4は3になる
//{1,2,3}
//{2,3,5}とかだと詰むや
//{1,2,3,4}
//{1,2}{3,4}の場合
//tree1.par[1]=1
//tree1.par[2]=1
//tree1.par[3]=1
//tree1.par[4]=1
//tree1.par[5]=2
//tree1.par[6]=2
//...
//tree1.par[N]=N

//tree2.par[1]=1
//tree2.par[2]=2
//tree2.par[3]=3
//tree2.par[4]=3
//tree2.par[5]=2
//tree2.par[6]=2

//のとき5-6と3-4がペアになるべき
//(1,3)=3,4 (2,2)=5,6みたいな？
//multimapにいれるかんじ。サイズが2になったときにメモしとく
//AC増えたけどTLE6個だな
//mapに重複数だけメモしといて、mapのペアを出力させりゃいいかな
int main(){
  ll N,K,L; cin>>N>>K>>L;
  G.assign(N+1, vector<ll>(0,0));
  map<pair<ll,ll>,ll> mp;
  seen.assign(N+1, false);
  UnionFind tree1(N), tree2(N);
  for(int i=0; i<K; i++){
    ll p,q; cin>>p>>q;
    G[p].emplace_back(q);
    G[q].emplace_back(p);
  }
  for(int i=1; i<=N; i++){    
    tree1.mkpar(i,i);
  }
  G.assign(N+1, vector<ll>(0,0));
  for(int i=0; i<L; i++){
    ll p,q; cin>>p>>q;
    G[p].emplace_back(q);
    G[q].emplace_back(p);
  }
  seen.assign(N+1, false);
  for(int i=1; i<=N; i++)
    tree2.mkpar(i,i);
  //mapに入れる。カウントが2だったら保存しとく。これすごい重い
  for(ll i=1; i<=N; i++){
    ll t1=tree1.par[i], t2=tree2.par[i];
    mp[make_pair(t1,t2)]++;
  }
  for(int i=1; i<=N; i++){
    ll t1=tree1.par[i], t2=tree2.par[i];
    cout<<mp[make_pair(t1,t2)];
    if(i<N) cout<<" ";
  }
}


Measured memory_bytes: 27776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  int ans = N;
  if (N % 2 == 1)
    ans *= 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a){
    return 0<=a&&a<=5000;
}
int main(){
    while(cin>>n&&n){
        int x[5000],y[5001],an=0;
        for(int i=0;i<n;i++)cin>>x[i]>>y[i],p[x[i]][y[i]]=1;
        for(int i=0;i<n;i++)
            for(int j=i;j<n;j++){
                int dx = x[i]-x[j];
                int dy = y[i]-y[j];
                int x1 = x[i]-dy; int x2 = x[j]-dy;
                int y1 = y[i]+dx; int y2 = y[j]+dx;
                int x3 = x[i]-dy, y3 = y[i]+dx,x4 = x[j]+dy,y4 = y[j]-dx;
                if(c(x1)&&c(y1)&&p[x1][y1]&&c(x2)&&c(y2)&&p[x2][y2])
                    an = max(an, dx*dx+dy*dy);
                if(c(x3)&&c(y3)&&p[x3][y3]&&c(x4)&&c(y4)&&p[x4][y4])
                    an = max(an, dx*dx+dy*dy);
            }
        cout<<an<<endl;
    }
    return 0;
}

Measured memory_bytes: 22724
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<ll> w(n);
  rep(i,n) cin>>w[i];
  ll ans=1000000;
  rep(t,n-1) {
    ll s1=0;
    ll s2=0;
    rep(i,t+1) {
      s1+=w[i];
    }
    repeat(i,t+1,n) {
      s2+=w[i];
    }
    ans=min(ans,abs(s1-s2));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 6e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

long long n, m, u, v, k, t, q, a, x, d, b;

vector <long long> P[N];
int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> n >> m;
   
   for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
         cin >> u;
         P[i].push_back(u);
      }
   }
   
   int sol = 0;
   
   for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
         long long res = 0;
         for (int k = 0; k < m; ++k) res += (P[i][k] - P[j][k]) * (P[i][k] - P[j][k]);
         
         long long x = sqrt(res);
         if (x * x == res or (x + 1) * (x + 1) == res) sol++;
      }
   }
   
   cout << sol << endl;
}







Measured memory_bytes: 14336
def resolve():
    from collections import defaultdict
    N, M = [int(i) for i in input().split()]
    aabb = [list(map(int, input().split())) for _ in range(M)]
    d = defaultdict(int)
    for a, b in aabb:
        d[a] += 1
        d[b] += 1
    for i in range(1, N + 1):
        print(d[i])


resolve()


Measured memory_bytes: 9456
#include <cstdio>
#include <algorithm>
#include <vector>
int main(){
  int i,x;
  std::vector<int>v;
  for(i=0;i<10;i++)scanf("%d",&x),v.push_back(x);
  std::sort(v.begin(),v.end());
  printf("%d\n%d\n%d\n",v[9],v[8],v[7]);
}

Measured memory_bytes: 1052
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

int main(void){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z <<" "<<  x << " "<< y << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;	
  	ci(n);
  vdb A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  SORT(A);
  db ans=A[0];
  FOR(i,1,n){
    ans=(ans+A[i])/2;
  }
  co(ans)
}
  

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("4");
            WillReturn.Add("2");
            //7
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("4");
            WillReturn.Add("4");
            //16
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int a = int.Parse(InputList[0]);
        int b = int.Parse(InputList[1]);
        int h = int.Parse(InputList[2]);

        Console.WriteLine((a + b) * h / 2);
    }
}


Measured memory_bytes: 2904
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
// #define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }

const int sz = 2e5+1;

void dfs(int node,int curr,bool vis[],int dis[],map<int,vector<int>>& tree){
  if(vis[node]) return;
  else{
    vis[node] = true;
    dis[node] = curr;

    for(int i=0;i<tree[node].size();i++){
      if(!vis[tree[node][i]]){
        dfs(tree[node][i],curr+1,vis,dis,tree);
      }
    }
  }
}

int32_t main(){
    
  fast;
  int n,x,y; cin >> n >> x >> y;
  map<int,vector<int>> tree;

  for(int i=1;i<=n-1;i++){
    int a,b; cin >> a >> b;
    tree[a].pb(b);
    tree[b].pb(a);
  }

  bool vis1[sz] = {false},vis2[sz]={false};
  int dis1[sz]={0},dis2[sz]={0};
  
  dfs(x,0,vis1,dis1,tree);
  dfs(y,0,vis2,dis2,tree);

  int ans = -1;

  for(int i=1;i<=n;i++){
    if(dis1[i]<dis2[i]){
      ans = max(ans,dis2[i]-1);
    }
  }
  
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 23424
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int sc = scanner.nextInt();
        //System.out.println(sc);
//         String sc2 = scanner.next();
//                 System.out.println(sc2);
// }}
        List<String> list = new ArrayList<>();
        //list = Arrays.asList(sc2.split(" "));
        //             System.out.println(list);
        int i = 0;
        while(sc > i) {
            String sc2 = scanner.next();
            list.add(sc2);
            i++;
        }
        if(list.size() == new HashSet<>(list).size()) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n){
        cin >> x.at(i);
    }
    int dist = 0;
    for (auto xi: x){
        int d = min(abs(xi - 0)*2, abs(xi - k)*2);
        dist += d;
    }
    cout << dist << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a;
    cin >> a;
    n -= a;
  }
  if (n >= 0) cout << n << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define endl       "\n"
#define ll         long long
#define pb         push_back
#define FIO        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NUM        1000000007
#define MOD        998244353
#define F          first
#define S          second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a-1;i>=b;i--)
#define vi         vector<ll>
#define pii        pair<ll,ll>
#define vpi        vector<pii>
#define mi         map<ll,ll>
#define mpi        map<pii,ll>
#define all(v)     (v).begin(),(v).end()
#define rall(v)    (v).rbegin(),(v).rend()
#define fac(a)     tgamma(a+1)

bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{ 
    return (a.second < b.second);      // compare function for sorting modification
}

vector<ll> primes;
vector<bool> PRIME(1000005,true);       // prime no.s less than 10^6
void sieve(ll n)                        // PRIME[i]=true => i=prime no.
{  PRIME[0]=false;PRIME[1]=false;
    for (ll p=2; p*p<=n; p++) { 
        if (PRIME[p] == true) { 
            for (ll i=p*p; i<=n; i += p){PRIME[i]=false;} 
        } 
    } rep(i,2,n+1){if(PRIME[i]){primes.pb(i);}}
}  

ll nCr[1001][1001];
void combination(ll n)                  // nCr values
{
    rep(i,0,n+1){
        rep(j,0,i+1){
            if(j==0 or j==i)nCr[i][j]=1;
            else nCr[i][j]=(nCr[i-1][j-1]+nCr[i-1][j])%NUM;
        }
    }
}

#define N  1000005

ll a,b,c,d,e,i,j,k,l,m,n,q,p,r,u,v,w,x,y,z,mn,mx;
ll arr[N];
//ll dp[2005][2005];

int main() 
{
    FIO;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        mn=LONG_LONG_MAX;
        mx=LONG_LONG_MIN;
        cin>>n;
        rep(i,0,n){cin>>arr[i];}
        
        ll dp[n];
        dp[0]=0;
        dp[1]=abs(arr[1]-arr[0]);
        
        for(ll i=2;i<n;i++)
        {
            dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
        }
        
        cout<<dp[n-1];
        
        
        
        
        
        
        
        
        
        
        h:;
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 5304
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	public static void Main(string[] args)
	{
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        str = Console.ReadLine().Split(' ');
        int[] a = new int[N];
        for (int i = 0; i < N;i++){
            a[i] = int.Parse(str[i]);
        }
        float sum = 0;
        for (int i = 0; i < N;i++)
        {
            sum += a[i];
        }
        float average = sum / N;
        float minDistance = float.MaxValue;
        int ansIndex = 0;
        for (int i = 0; i < N;i++)
        {
            float tmpDistance = Math.Abs(a[i] - average);
            if(tmpDistance<minDistance)
            {
                ansIndex = i;
                minDistance = tmpDistance;
            }
        }
        Console.WriteLine(ansIndex.ToString());
        return;
	}
}

Measured memory_bytes: 11092
// $%D%$.$%M%$.$%Y%$
// $%h%$:$%m%$:$%s%$

#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    int n;
    cin >> n;
    ll res = 0;
    for (int i = 1, j = n; i <= n; ++i) {
        while(i * j >= n) {
            --j;
        }
        res += j;
    }
    cout << res << '\n';
}


Measured memory_bytes: 3632
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
	long  x,i,j,rem=0;
	Scanner num = new Scanner(System.in);
	x = num.nextLong();
        i= x/11;
        j= x%11;
        if(j>6){
        rem = rem +2;
        }else{
        rem = rem +1;
        }
        if(j == 0){
        rem = 0;
        }
        
        x = i*2 + rem;
        System.out.print(x);
        }
}        

Measured memory_bytes: 23124
int b[5];main(i,s,w){while(1){for(s=i=0;i-5&&scanf("%d",b+i);s|=1<<--b[i++]);if(i=*b<0)return 0;for(w=s-5?s-6?0:1:2;printf("%d\n",(s-1&&s-2&&s-4&&s-7)?b[i]-w?2:1:3)&&++i-5;);}}

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

int main()
{
  int N;
  while (cin >> N && N != 0) {
    int ans = 0;
    for (int k = 2; k*(k+1)/2 <= N; k++) {
      if ((N - k*(k+1)/2) % k == 0) {
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

const int N = 100005;

int n, L, q;
int x[N];
int rmq[N][18];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> x[i];
	cin >> L;
	
	int pt = 1;
	for (int i = 1; i <= n; ++i) {
		while(pt <= n && x[pt] - x[i] <= L) ++pt; --pt;
		rmq[i][0] = pt;
	}

	for (int j = 1; j <= 17; ++j) {
		for (int i = 1; i <= n; ++i) rmq[i][j] = rmq[rmq[i][j-1]][j-1];
	}

	cin >> q;
	while(q--) {
		int l, r; cin >> l >> r;
		if (l > r) swap(l, r);

		int ans = 0;
		for (int j = 17; j >= 0; --j) {
			if (rmq[l][j] < r) l = rmq[l][j], ans += (1 << j);
		}
		++ans;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <utility>
#include <set>

using namespace std;

int main(){
    int n;
    while(cin >> n &&n!=0){
        string s;
        cin >> s;
        set<pair<int,int> > st;
        int tmp=0;
        bool flag = 0;
        for(int i=0;i<n;i++){
            if(s[i]=='u'){
                tmp =0;
            }else{
                if(s[i+1]!='u'){
                    tmp += 1<<(s[i]-'0');
                    int tmp2 = 1<<(int)(s[i+1]-'0');
                    st.insert(make_pair(tmp,tmp2));
                    if((tmp&tmp2)==tmp2){
                        flag = 1;
                    }
                }
            }
        }
        
        set<pair<int,int> > st2=st;
        for(int j=0;j<10;j++){
            set<pair<int,int> > st3;
            for(auto x:st){
                for(auto y:st2){
                    if((x.first&y.first)==0){
                        int p =x.first|y.first;
                        int q =x.second|y.second;
                        st3.insert(make_pair(p,q));
                        if((p&q)==q){
                            flag = 1;
                            break;
                        }
                    }
                }
                if(flag)break;
            }
            st2 = st3;
        }
        if(flag){
            cout << "UNSAFE" << endl;
        }else{
            cout << "SAFE" << endl;
        }
    }






    return 0;
}


Measured memory_bytes: 6484
using System;
using System.Linq;

public class HelloWorld
{
    static long[,] C = new long[2001,2001];
    
    static long div = 1000000007;
    static public void Main ()
    {
        var NK = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        var N = NK[0];
        var K = NK[1];
        
        for(long i =1;i <= K;i++){
            var loc = Combination(N-K+1,i);
            var num = Combination(K-1,i-1);
            var res = (loc*num)%div;
            
            Console.WriteLine (res);
        }
        
        

    }
    
    static long Combination(long n,long r){
        if(n < r){
            return 0;
        }
        if(n == r || r == 0){
            C[n,r] = 1;
        }else if(C[n,r] == 0){
            
            C[n,r] = (Combination(n-1,r-1)+Combination(n-1,r))%div;
        }
        return C[n,r];
    }

}


Measured memory_bytes: 42324
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    add = 0
    ans = 1
    i = 0
    while i < N-1:
        if add == 0:
            add = 1 if A[i] < A[i + 1] else -1 if A[i] > A[i+1] else 0
        elif add == 1:
            if A[i] > A[i + 1]:
                add = 0
                ans += 1
        else:
            if A[i] < A[i+1]:
                add = 0
                ans += 1
        i += 1
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 63340
n = gets.to_i
s = gets.chomp

tmp1 = Hash.new(0)
tmp2 = Hash.new(0)

n.times do |i|
  if s[i] == "."
    tmp1[i] = 1
  else
    tmp2[i] = 1
  end
end

n.downto(0) do |i|
  tmp1[i] += tmp1[i + 1]
  tmp2[i] += tmp2[i + 1]
end

count = 0
min = Float::INFINITY

n.times do |i|
  next if s[i] == "."
  min = [min, count + tmp1[i]].min
  count += 1
end

puts [min, count].min


Measured memory_bytes: 28156
import heapq

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
set<ll> ret;

void hoge(ll N,ll a) {
	N/=a;
	while(N) {
		if((N-1)%a==0) {
			ret.insert(a);
			break;
		}
		if(N%a) return;
		N/=a;
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	for(ll a=1;a*a<=N-1;a++) if((N-1)%a==0) {
		ret.insert(a);
		ret.insert((N-1)/a);
	}
	
	for(ll a=1;a*a<=N;a++) if(N%a==0) {
		hoge(N,a);
		hoge(N,N/a);
	}
	
	ret.erase(1);
	cout<<ret.size()<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[200];
  cin >> s;
  sort(s,s+strlen(s));
  if(strlen(s)%2==1){
    cout << "No";
    return 0;
  }
  for(int i=0;i<strlen(s)-1;i++){
    if(s[i]!=s[i+1]){
      if(i%2==0){
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b, ans;
	char c;
	while (1)
	{
		scanf("%d %c %d", &a, &c, &b);
		if (c == '+'){
			ans = a + b;
		}
		else if (c == '-'){
			ans = a - b;
		}
		else if (c == '*'){
			ans = a * b;
		}
		else if (c == '/'){
			ans = a / b;
		}
		else if (c == '?'){
			break;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 600
x,y=map(int,input().split())
val=0
if x*y==1:
  print(1000000)
elif x*y==2:
  print(500000)
elif x*y==3:
  print(400000)
elif x==2 and y==2:
  print(400000)
elif x==2 and y==3:
  print(300000)
elif x==3 and y==2:
  print(300000)
elif x*y==9:
  print(200000)
elif x==1 or y==1:
  print(300000)
elif x==2 or y==2:
  print(200000)
elif x==3 or y==3:
  print(100000)
else:
  print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

struct Dijkstra{
  ll INF=1000000000000000009;
  ll MAX_V=1000000;
  ll st = -1;
  struct edge{ll to, cost;};
  typedef pair<ll, ll> p;
  vector<vector<edge>> G;
  vector<ll> pre, d;
  priority_queue<p, vector<p>, greater<p> > que; //class, inner, compair
  Dijkstra(ll s){
    G.resize(s+2);
    pre.resize(s+2, -1);
    d.resize(s+2, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(edge{b, c});
  }
  void init(){
    for(int i=0;i<d.size();i++) pre[i] = -1, d[i] = INF;
  }
  void dijkstra(int start){
    init();
    st = start;
    d[start]=0;
    que.push(p(0, start));
    while(!que.empty()){
      p p_now=que.top(); que.pop();
      ll v = p_now.second;
      if(d[v]<p_now.first) continue;
      for(int i=0;i<G[v].size();i++){
        edge e = G[v][i];
        if(d[e.to]>d[v]+e.cost){
          d[e.to]=d[v]+e.cost;
          pre[e.to] = v;
          que.push(p(d[e.to], e.to));
        }
      }
    }
  }
  vll get_path(int now){
    vll ret;
    while(now!=-1){
      ret.push_back(now);
      now = pre[now];
    }
    return ret;
  }
};
int main(int argc, char const *argv[]) {
  ll n, x, y;std::cin >> n >> x >> y;
  Dijkstra dj(n+1);
  for(int i=1;i<=n-1;i++) dj.insert(i, i+1, 1), dj.insert(i+1, i, 1);
  dj.insert(x, y, 1);
  dj.insert(y, x, 1);
  vll ans(n+1, 0);

  for(int i=1;i<=n;i++){
    dj.dijkstra(i);
    for(int j=1;j<=n;j++) ans[dj.d[j]]++;
  }

  for(int i=1;i<=n-1;i++) std::cout << ans[i]/2 << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

const int N_prime = 15000;

class prime
{
		public:
			prime();
			vector<int> primeList;
			bool used[N_prime];
};

prime::prime()
{
	memset(used, true, sizeof(used));

	//一千万までの素数
	for(int i = 2; i < sqrt( N_prime ); i++)
	{
		if(used[i] == false)
		{
			continue;
		}

		for(int j = i*2; j < N_prime; j += i)
		{
			used[j] = false;
		}
	}

	for(int i = 2; i < N_prime; i++)
	{
		if(used[i] == true)
		{
			primeList.push_back(i);
		}
	}
}
int main()
{
	prime twin;
	int limit;
	while(cin >> limit, limit)
	{
		for(int i = 0; i < 10001; i++)
		{
			if(twin.primeList[i] > limit)
			{
				limit = i-1;
				break;
			}
			else if(twin.primeList[i] == limit)
			{
				limit = i;
				break;
			}
		}
		for(int i = limit; i > 0; i--)
		{
			if(twin.primeList[i-1] == twin.primeList[i]-2)
			{
				printf("%d %d\n",twin.primeList[i-1] ,twin.primeList[i]);
				break;
			}
		}
	}
}

Measured memory_bytes: 1232
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	int size;
public:
	Union_find(int n){
		size = n;
		REP(i, n){
			par.push_back(i);
		}
	}

	int find(int x){
		if(x == par[x]) return x;

		return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		par[x] = y;
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int n, q;
	cin >> n >> q;
	Union_find uf(n);
	
	REP(i, q){
		int com, x, y;
		cin >> com >> x >> y;
		if(com == 0){
			uf.unite(x, y);
		}else{
			if(uf.same(x, y)){
				cout << 1 << endl;
			}else{
				cout << 0 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3296
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//
//using namespace __gnu_pbds;
using namespace std;

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

#define mx                     200005
#define INF_mx                 1e18
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)
/*
tree<
       int,
     null_type,
     less<int>,
     rb_tree_tag,
     tree_order_statistics_node_update>t;
*/

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

   double l;

   l=(double)L/3;

    printf("%.10f\n",l*l*l);
    return 0;
}
/*

 6 4

 2 4 5
 0

*/


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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; int t2 = 1; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD =  998244353;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;



ll ncr(int n, int r) 
{ 
    long long p = 1, k = 1; 
  
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            long long m = __gcd(p, k); 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
    } 
  
    else
        p = 1; 
  
    return p; 
}
int main() {_
	int n;
	cin >> n;

	vector<int> v(n);
	map<int,int> m;

	for(int i = 0; i < n; ++i) {
		cin >> v[i];
		m[v[i]]++;
	}
	ll ans = 0;
	for(auto x : m) {
		if(x.S > 1)
		ans += ncr(x.S,2);
	}
	for(int i = 0; i < n; ++i) {
		cout << ans - m[v[i]]+1 << "\n";
	}
}


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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> w(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> w[i];
    sum+=w[i];
  }
  int m=10000;
  int s1=0;
  int s2=sum;
  for(int i=0; i<n;i++){
    s1+=w[i];
    s2-=w[i];
    m=min(abs(s1-s2),m);
  }
  cout << m << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        List<Long> list = Arrays.asList((Long)a * c, (Long)a * d, (Long)b * c, (Long)b * d);
        System.out.println(list.stream().max(Long::compareTo).get());
    }
}


Measured memory_bytes: 35872