akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

struct edge{int to,cost;};

const double INF=1e10;
const double EPS=1e-6;

int main()
{
    int n,m,p,a,b;
    while(cin >>n >>m >>p >>a >>b,n)
    {
        --a;
        --b;

        vector<int> t(n);
        rep(i,n) scanf(" %d", &t[i]);

        vector<vector<edge>> G(m);
        rep(i,p)
        {
            int x,y,z;
            scanf(" %d %d %d", &x, &y, &z);
            --x;
            --y;
            G[x].pb(edge{y,z});
            G[y].pb(edge{x,z});
        }

        // ??????i?????¬???????????¨??¶???j??§??¨?????????????????????????????????????°????
        double d[30][257];
        fill(d[0],d[30],INF);
        d[a][0]=0;

        queue<pi> que;
        que.push(pi(a,0));
        while(!que.empty())
        {
            pi v=que.front();
            que.pop();

            int now=v.fi, state=v.se;

            rep(i,G[now].size())
            {
                edge e=G[now][i];
                rep(j,n)
                {
                    // ????????¢?????????????????¬??????????????§??????
                    if(state>>j&1) continue;

                    int nxstate=state+(1<<j);
                    if(d[e.to][nxstate] > d[now][state]+(double)e.cost/t[j])
                    {
                        d[e.to][nxstate] = d[now][state]+(double)e.cost/t[j];
                        que.push(pi(e.to,nxstate));
                    }
                }
            }
        }

        double ans=INF;
        rep(i,1<<n) ans=min(ans,d[b][i]);

        if(fabs(ans-INF)<EPS) printf("Impossible\n");
        else printf("%.10lf\n", ans);
    }
    return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N,K;
ll dp [101] [256] [101];
const ll MOD = 1e9 + 7;

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

	cin >> N >> K;
	vector<int> A(N);
	FOR(i,0,N){
		cin >> A [i];
	}

	dp [0] [0] [0] = 1;
	FOR(i,0,N) FOR(j,0,256){
		for(int k = 0;k <= N;k++) if(dp [i] [j] [k]){
			(dp [i + 1] [j] [k] += dp [i] [j] [k]) %= MOD;
			(dp [i + 1] [j ^ A [i]] [k + 1] += dp [i] [j] [k]) %= MOD;
		}
	}

	ll ans = 0,fact = 1;
	for(int i = 1;i <= N;i++){
		(fact *= i) %= MOD;
		(ans += fact * dp [N] [K] [i]) %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 19712
s=int(input())
#print(s)
a1=s
arr=[]
arr.append(s)
i=1
while True:
  i=i+1
  if arr[-1]%2==0:
    temp=arr[-1]//2
  else:
    temp=int(arr[-1]*3+1)
  if temp in arr:
    print(i)
    break
  else:
    arr.append(temp)
    #print(arr)

Measured memory_bytes: 3060
#include <stdio.h>

#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))

#define INF 1000000000

int adj[100][100];
int d[100], flag[100];

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++) {
		d[i] = INF;
		flag[i] = 0;
	}

	d[s] = 0;
	while (1) {
		int min, from, to;

		min = INF;
		for (i = 0; i < n; i++)
			if (!flag[i] && d[i] < min)
				min = d[from = i];
		if (min == INF)
			break;

		flag[from] = 1;

		for (to = 0; to < n; to++)
			d[to] = min(d[to], min + adj[from][to]);
	}
}

int main(void) {
	int i, j, o;
	int n, m, l, k, a, h;

	while (scanf("%d %d %d %d %d %d", &n, &m, &l, &k, &a, &h), n) {
		int canFreeze[100] = {0};

		canFreeze[a] = canFreeze[h] = 1;
		for (i = 0; i < l; i++) {
			int x;
			scanf("%d", &x);
			canFreeze[x] = 1;
		}

		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				adj[i][j] = INF;
		for (i = 0; i < k; i++) {
			int x, y, t;
			scanf("%d %d %d", &x, &y, &t);
			adj[x][y] = adj[y][x] = t;
		}

		for (o = 0; o < n; o++)
			for (i = 0; i < n; i++)
				for (j = 0; j < n; j++)
					adj[i][j] = min(adj[i][j], adj[i][o] + adj[o][j]);

		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				if (!canFreeze[i] || !canFreeze[j] || adj[i][j] > m)
					adj[i][j] = INF;

		for (o = 0; o < n; o++)
			for (i = 0; i < n; i++)
				for (j = 0; j < n; j++)
					adj[i][j] = min(adj[i][j], adj[i][o] + adj[o][j]);

		dijkstra(n, a);

		if (d[h] != INF)
			printf("%d\n", d[h] + max(0, d[h] - m));
		else
			puts("Help!");
	}

	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <string>

using namespace std;

int mcxiToInt(const char c)
{
	switch (c)
	{
	case 'm':
		return 1000;
	case 'c':
		return 100;
	case 'x':
		return 10;
	case 'i':
		return 1;
	default:
		break;
	}

	return 0;
}

int parseInt(string str)
{
	int num{ 0 };
	int digit{ 0 };
	bool prev_is_digit{ false };

	for (int i = 0; i < str.size(); ++i) {
		char c = str[i];

		if (isdigit(c)) {
			digit = static_cast<int>(c - '0');
			prev_is_digit = true;
			continue;
		}

		if (prev_is_digit) {
			num += digit * mcxiToInt(str[i]);
			prev_is_digit = false;
			continue;
		}

		num += mcxiToInt(str[i]);
	}

	return num;
}

string toString(int num)
{
	string ans;

	int m = num / 1000;
	int c = (num - m * 1000) / 100;
	int x = (num - m * 1000 - c * 100) / 10;
	int i = num - m * 1000 - c * 100 - x * 10;

	if (m > 0) {
		if(m > 1) {
			ans += static_cast<char>('0' + m);
		}
		ans += 'm';
	}

	if (c > 0) {
		if(c > 1) {
			ans += static_cast<char>('0' + c);
		}
		ans += 'c';
	}

	if (x > 0) {
		if(x > 1) {
			ans += static_cast<char>('0' + x);
		}
		ans += 'x';
	}

	if (i > 0) {
		if(i > 1) {
			ans += static_cast<char>('0' + i);
		}
		ans += 'i';
	}

	return ans;
}

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

	for (int i = 0; i < n; ++i) {
		string str1, str2;
		cin >> str1 >> str2;
		int ans = parseInt(str1) + parseInt(str2);
		cout << toString(ans) << endl;
	}
}

Measured memory_bytes: 3116
def bubble_sort(array, n)
  n.times do |i|
    (n - 1).downto(i + 1) do |j|
      if array[j].num < array[j - 1].num
        array[j], array[j - 1] = array[j - 1], array[j]
      end
    end
  end
  array
end

def selection_sort(array, n)
  n.times do |i|
    minj = i
    i.upto(n - 1) do |j|
      minj = j if array[j].num < array[minj].num
    end
    array[i], array[minj] = array[minj], array[i]
  end
  array
end

# 安定化どうか判定 バブルソートと比較して判定
def stable?(bubble, sorted)
  bubble.each_with_index do |element, index|
    return false if element.mark != sorted[index].mark
  end
  true
end

class Card
  def initialize(mark, num)
    @mark = mark
    @num = num
  end
  attr_accessor :mark, :num

  def to_s
    @mark + @num
  end
end

n = gets.to_i
cards = gets.split(' ').map do |card|
  Card.new(card[0], card[1])
end
cards2 = cards.clone
bubble = bubble_sort(cards, n)
selection = selection_sort(cards2, n)

puts bubble.map(&:to_s).join(' ')
puts 'Stable'
puts selection.map(&:to_s).join(' ')
if stable? bubble, selection
  puts 'Stable'
else
  puts 'Not stable'
end



Measured memory_bytes: 6884
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  vector<int> a(3);
  for(int i=0; i<3; ++i) cin >> a[i];
  sort(a.begin(), a.end());

  if(a[0]%2 == 0 || a[1]%2 == 0 || a[2]%2 == 0) cout << 0 << endl;
  else{
    cout << (ll)a[0]*a[1];
  }
  return 0;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, K = sc.nextInt()
    val P = Array.fill(N)(sc.nextInt())

    val z = P.take(K).map(p => (p + 1) / 2.0).sum
    val max = (K until N)
      .foldLeft((z, z))((b, i) => {
        val next = b._2 - ((P(i-K) + 1) / 2.0) + ((P(i) + 1) / 2.0)
        (b._1 max next, next)
      })._1

    println(max)
  }

}


Measured memory_bytes: 70012
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to;ll cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

string s;
ll ans;

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

	cin>>s;
	REP(i,1<<s.size()-1) {
		ll sum=0;
		string t=s.substr(0,1);
		REP(j,s.size()-1) {
			if((i>>j)&1) {
				sum+=stoll(t);
				t.clear();
				t=t+s[j+1];
			}
			else t=t+s[j+1];
		}
		if(t.size()) sum+=stoll(t);
		ans+=sum;
	}
	cout<<ans<<endl;

	return 0;
}


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

int main()
{
    int n,d;cin>>n>>d;
    int ans;
    if(n%(2*d+1)==0){
        ans=n/(2*d+1);
    }
    else{
        ans=n/(2*d+1)+1;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#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;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int N,C,K,t[100000],bc,l,rem;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> C >> K;
	for (int i=0;i<N;i++) cin >> t[i];
	sort(t,t+N);
	l=-1;
	for (int i=0;i<N;i++) {
		if (t[i]>l || rem==0) {
			bc++;
			l=t[i]+K;
			rem=C-1;
		}
		else rem--;
	}

	cout << bc << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int a = scanner.nextInt();
        final int b = scanner.nextInt();
        final int c = scanner.nextInt();

        if (a == b) {
            if (a == c) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        } else if (a == c) {
            System.out.println("Yes");
        } else if (b == c) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll X[200005];
ll Y[200005];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y, Y + N);
    ll L = Y[N / 2 - 1];
    ll R = Y[N / 2];

    REP(i, N)
    {
        if (X[i] <= L)
            cout << R << endl;
        else
            cout << L << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n,m;cin>>n;
	int w[n];
	int su = 0;
	rep(i, n){
		cin>>w[i];
		su += w[i];
	}
	int mm = 1000000;
	int tmp = 0;
	rep(i, n-1){
		tmp += w[i];
		chmin(mm, (int)abs(su-2*tmp));
	}
	cout << mm << endl;
	return 0;
}


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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    int cnta=0;
    int cntb=0;
    
    for(int i=0;i<s.size();i++){
        if(i<a){
            if(s.at(i)>='0' && s.at(i)<='9') cnta++;
            else cnta-=9999;
        }else if(i==a){
            if(s.at(i)!='-') cnta-=9999;
        }else{
            if(s.at(i)>='0' && s.at(i)<='9') cntb++;
            else cntb-=9999;
        }
    }
    
    if(cnta==a && cntb==b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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

long long a[10];

int main(){
	long long ans;
	for (int i = 1; i <= 7; i++) scanf("%lld",&a[i]);
	ans = a[1] / 2 * 4 + a[4] / 2 * 4 + a[5] / 2 * 4 + a[2] * 2;
	if (a[1] == 0 || a[4] == 0 || a[5] == 0) ;
	else if (a[1] % 2 == 0 && a[4] % 2 == 0 && a[5] % 2 == 0) ;
	else if (a[1] % 2 == 1 && a[4] % 2 == 1 && a[5] % 2 == 1) ans += 6;
	else if ((a[1] + a[4] + a[5]) % 2 == 0) ans += 2;
	printf("%lld\n", ans / 2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,d;
    cin>>n>>m>>d;
    double unit = (m-1) * (min(n, d*2)*1.0 + max(0LL,(n-d*2))*1.0*2) / (n*n);
    if(d==0) {unit /= 2;}
    printf("%.10lf\n", unit);
    return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

void bfs(const vvi& G, vi& d, vector<bool>& seen, vi& in_dgree, int i) {
    queue<int> q;

    // Start from i.
    d[i] = 0;
    seen[i] = true;
    q.push(i);

    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto u : G[v]) {
            if (d[u] != INT_MAX) {
                d[u] = max(d[u], d[v] + 1);
            } else {
                d[u] = d[v] + 1;
            }
            --in_dgree[u];
            if (in_dgree[u] == 0) { q.push(u); }
        }
    }
}

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

    int n, m;
    cin >> n >> m;

    vvi G(n);
    vi in_dgree(n, 0);

    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        G[x - 1].push_back(y - 1);
        ++in_dgree[y - 1];
    }

    // d[i]: longest path to i.
    vi d(n, INT_MAX);
    rep(i, 0, n) {
        if (in_dgree[i] == 0) { d[i] = 0; }
    }
    // seen[i]: whether seen or not.
    vector<bool> seen(n, false);

    rep(i, 0, n) {
        if (d[i] == 0) { bfs(G, d, seen, in_dgree, i); }
    }

    int maxd = 0;
    rep(i, 0, n) {
        if (d[i] != INT_MAX) { maxd = max(maxd, d[i]); }
    }
    cout << maxd << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

long gcd(long m,long a){
    long r = m % a;
    if(r == 0)return a;
    else return gcd(a,r);
}

int main(void){
    vector<int> a;
    int n,box;
    long res=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> box;
        a.push_back(box);
    }
    for(int i=0;i<n;i++){
        res += --a[i];
    }
    cout << res << endl;
    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll  x,y ;
	cin >>x >>y;
	

	if(abs(y-x) <=1) puts("Brown");
	else puts("Alice");

/*	vector<VI> p(n, VI(n, 0));
	rep(i,2) p[i][0]=p[i][1]=2;
	
	rep(i,n) rep(j,n) if(p[i][j]==2){
		if(i-1>=0 && j+2<n) p[i-1][j+2]=1;
		if(j-1>=0 && i+2<n) p[i+2][j-1]=1;
	}
	for(auto xl: p){for(auto x :xl) printf("%d ",x); puts("");}
	*/
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e16;

int main(){

  ll n,m;
  cin >>n >> m;
  vector<vector<ll>> v(m);
  ll a[m],b[m];
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    for(int j=0;j<b[i];j++){
      ll c;
      cin >>c ;
      v[i].push_back(c-1);
    }
  }

  
  vector<ll> dp((1<<n)+1,inf);
  dp[0]=0;



  for(ll b=0;b<(1<<n);b++){
    for(int i=0;i<m;i++){
      ll c=b;
      for(int j=0;j<v[i].size();j++)c=c | (1<<v[i][j]);
      dp[c]=min(dp[c],dp[b]+a[i]);
    }
  }

  if(dp[(1<<n)-1]==inf)cout << -1 << endl;
  else cout << dp[(1<<n)-1] << endl;
  




}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

int A,B;cin>>A>>B;
  if(A!=1&&B!=1){
    if(A<B){cout<<"Bob"<<endl;}
    if(A==B){cout<<"Draw"<<endl;}
    if(A>B){cout<<"Alice"<<endl;}
  }else{
    if(A==1&&B!=1){
      cout<<"Alice"<<endl;
    }
    if(A!=1&&B==1){
      cout<<"Bob"<<endl;
    }
    if(A==1&&B==1){
      cout<<"Draw"<<endl;
    }
  }
  

  
  
}



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

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(A < C && C < B)
		cout << "Yes" << endl;
	else if(B < C && C < A)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n,z,w;
int a[2010];

int main() {
    cin >> n >> z >> w;
    REP(i, n){
        cin >> a[i];
    }
    int res;
    if(n-1){
        res = max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));
    }else{
        res = abs(a[0]-w);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
static const int N = 501;
static const int INFTY=(1<<21);

int main(){
  int M[N][N];
  int n,u,k,v;
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
    return 0;
}
  



Measured memory_bytes: 2088
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
using namespace std;

#define MAX 120

struct Node {
	int key;
	Node *p, *l, *r;
};

Node *root, *NIL;

void insert(int k) {
	Node *x = root;
	Node *y = NIL;
	Node *z;
	z = new Node;
	z->key = k; z->l = NIL; z->r = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key) x = x->l;
		else x = x->r;
	}
	z->p = y;

	if (y == NIL) root = z;
	else if (z->key < y->key) y->l = z;
	else y->r = z;
}

void preorder(Node *u) {
	if (u == NIL) return;
	cout << " " << u->key;
	preorder(u->l);
	preorder(u->r);
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->l);
	cout << " " << u->key;
	inorder(u->r);
}

void find(int key) {
	Node* x = root;
	while (x != NIL && key != x->key) {
		if (key < x->key)  x = x->l;
		else x = x->r;
	}
	if (x == NIL) cout << "no" << endl;
	else if (key == x->key) cout << "yes" << endl;
}

void print() {
	inorder(root);
	cout << endl;
	preorder(root);
	cout << endl;
}

int main() {
	int n;
	int num;
	cin >> n; cin.ignore();
	string line;
	for (int i = 0; i < n; i++) {
		getline(cin, line);
		if (line[0] == 'i') {
			num = atoi(line.substr(7).c_str());
			insert(num); 
			
		}
		else if (line[0] == 'f') {
			num = atoi(line.substr(5).c_str());
			find(num);
		}
		else print();
	}
}

Measured memory_bytes: 21924
#include<iostream>

using namespace std;

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

Measured memory_bytes: 256
N, M = map(int,input().split())
minL = 1
maxR = N

for i in range(M):
    L, R = map(int,input().split())
    if L > minL:
        minL = L

    if R < maxR:
        maxR = R

if maxR-minL+1 > 0:
    print(maxR-minL+1)
else:
    print(0)


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < l.length; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int max = l[n - 1];
        int total = 0;
        for (int i = 0; i < l.length - 1; i++) {
            total += l[i];
        }
        if(max < total)System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
	int p,q,r;
	cin>>p>>q>>r;
	cout<<min(p+q,min(q+r,r+p))<<endl;
	return 0;
}


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

ll N, AI;

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

	cin >> N;
	ll cur = 0, ans = 0;
	for (ll i = 0; i < N; i++) {
		cin >> AI;
		if (AI >= cur) {
			ans++;
		}
		cur = max(cur, AI);
	}

	cout << ans << "\n";

}

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

ans = min(h)
h = list(map(lambda x:x-ans, h))

while h.count(0) != len(h):

    pos = 0
    pos2 = 0

    for i in range(len(h)):
        if h[i] != 0:
            pos = i
            break

    for j in range(pos, len(h)):
        if h[j] == 0:
            pos2 = j
            break
        if j +1== len(h):
            pos2 = len(h)

    ans += min(h[pos:pos2])
    h[pos:pos2] = map(lambda x: x-min(h[pos:pos2]), h[pos:pos2])

print(ans)

Measured memory_bytes: 3064
/////////////////////////////////////////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define uniq(x) (x).erase(unique(all(x)),(x).end())
int qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
////////////////////////////// define /////////////////////////////////
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e16;
//const int MAX_N = 200001;

int main() {
	int ans = true;
	int h,w;cin >> h >> w;
	char grid[50][50];
	rep(h){repj(w) cin >> grid[i][j];}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(grid[i][j] == '.') continue;
			int c = 0;
			for(int k = 0;k < 4;k++){
				if(i+dx[k] >= 0 && i+dx[k] < h && j+dy[k] >= 0 && j+dy[k] < w){
					if(grid[i+dx[k]][j+dy[k]] == '#') c++;
				}
			}
			ans &= (c != 0);
		}
	}
	if(ans){cout << "Yes" << endl;}else{cout << "No" << endl;}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


//library mod int
template <int mod>
struct modint{
    ll x;

    //constructor
    modint(ll x=0): x((x%mod+mod)%mod){}

    //unary operator
    modint operator-() const { return modint(mod-x);}
    modint inv() const { return this->pow(mod-2);}
    
    //compound assignment
    modint& operator+=(const modint& a){
        if((x+=a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator-=(const modint& a){
        if((x-=a.x)<0) x+=mod;
        return *this;
    }
    modint& operator*=(const modint& a){
        (x*=a.x)%=mod;
        return *this;
    }
    modint& operator/=(const modint& a){
        return *this *= a.inv();
    }

    //arithmetic
    // なぜmodintの後ろに＆を書いたり書かなかったりしてるかの理解ができていない
    //おそらく＆をつけるとポインタで参照しているのでもとの値を書き換えることができる
    //＆をつけないとコピーを作ってからそれに対して計算するので、もとの値は変更されない
    modint operator-(const modint& a) const {return modint (*this) -= a ; }
    modint operator+(const modint& a) const {return modint (*this) += a ; }
    modint operator*(const modint& a) const {return modint (*this) *= a ; }
    modint operator/(const modint& a) const {return modint (*this) /= a ; }
    //n should not be smaller than 0.
    modint pow(ll n) const{
        auto x=modint(1);
        auto m=*this;
        while(n>0){
            if(n&1) x*=m;
            n>>=1;
            m*=m;
        }
        return x;
    }

    //compare
    bool operator==(const modint& a) const {return x==a.x ; }
    bool operator!=(const modint& a) const {return x!=a.x ; }

    //I/O
    friend istream& operator>>(istream& is, modint& a ) noexcept {return is >> a.x ; }
    friend ostream& operator<<(ostream& os, const modint& a ) noexcept {return os << a.x ; }
};

//modの調整
constexpr int mod = 1e9 + 7;
using mint = modint<mod>;

//////////////////////////////////////////////////////////////////////
//combination
//コンビネーション計算で代入できる値は3e6で設定している
vector<mint> mintcombvector;
int startmintcomb(int n){
    mintcombvector.push_back(0);
    mintcombvector.push_back(1);
    rep(i,n-5) mintcombvector.push_back(mintcombvector[i+1]*(i+2));
    return 0;
}
mint comb(mint a, mint b){
    if(a.x<b.x || a.x<=0 || b.x<0) return mint(0);
    if(b.x==0) return mint(1);
    if(a==b) return mint(1);
    return mintcombvector[a.x]*(mintcombvector[b.x].inv())*(mintcombvector[a.x-b.x].inv());
}
//combinationを使いたいときは　startmintcomb(n=代入したい数の最大値); を始めに打つこと


int main(){
    startmintcomb(3e6);
    int x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    int z=(x+y)/3;
    mint a=x-z, b=y-z;
    cout<<comb((a+b),b)<<endl;
    return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int a, b;
  cin >> a >> b;
  if((a * b) % 2 == 0) cout << "No\n";
  else cout << "Yes\n";
}


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

const int INF = 10011001001;


int main() {
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+1, INF);
    dp[0] = 0;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        rep(j, h){
            int nj = min(j+a, h);
            dp[nj] = min(dp[nj], dp[j]+b);
        }
    }

    cout << dp[h] << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make(pairs, n)
	bb := make(pairs, n)
	for i := 0; i < n; i++ {
		aa[i].x = getNextInt(scanner)
		aa[i].i = i
	}
	for i := 0; i < n; i++ {
		bb[i].x = getNextInt(scanner)
		bb[i].i = i
	}
	sort.Sort(aa)
	sort.Sort(bb)
	to := make([]int, n)
	for i := 0; i < n; i++ {
		if aa[i].x > bb[i].x {
			fmt.Fprintln(writer, "No")
			return
		}
		to[aa[i].i] = bb[i].i
	}
	cycle := 0
	visited := make([]int, n)
	for i := 0; i < n; i++ {
		if visited[i] == 1 {
			continue
		}
		cycle++
		visited[i] = 1
		v := to[i]
		for visited[v] == 0 {
			visited[v] = 1
			v = to[v]
		}
	}
	if cycle == 1 {
		for i := 1; i < n; i++ {
			if aa[i].x <= bb[i-1].x && aa[i-1].x <= bb[i].x {
				fmt.Fprintln(writer, "Yes")
				return
			}
		}
		fmt.Fprintln(writer, "No")
		return
	}
	fmt.Fprintln(writer, "Yes")

}

type pair struct {
	x, i int
}

type pairs []pair

func (a pairs) Len() int           { return len(a) }
func (a pairs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a pairs) Less(i, j int) bool { return a[i].x < a[j].x }


Measured memory_bytes: 9344
import bisect
def solve():
  n,c,k = (int(i) for i in input().split())
  t = [int(input()) for i in range(n)]
  t = sorted(t,reverse = True)
  ans = 0
  
  while t:
    ans += 1
    customer = t.pop(0)
    if len(t) >= 1:
     for i in range(c-1):
      if customer  <= t[0] + k:
        t.pop(0)
      else:
        break
      if len(t) == 0:
        break
  print(ans)
  
solve()

Measured memory_bytes: 8280
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[315][315],d2[315][315],co[315][315];
int main()
{
	int n,K,M;
	cin>>n>>K>>M;
	rep(i,310){
		co[i][0]=co[i][i]=1;
		REP(j,1,i) co[i][j]=(co[i-1][j]+co[i-1][j-1])%M;
	}
	memset(dp,0,sizeof(dp));memset(d2,0,sizeof(d2));
	rep(i,310) d2[0][i]=1;
	REP(i,1,310){
		REP(j,1,310){
			//cout<<i<<' '<<j<<endl;
			//dp[i][j]=d2[i-1][j];
			REP(k,0,i){
				dp[i][j]+=(d2[k][j-1]*d2[i-k-1][j])%M*co[i][k];
				dp[i][j]%=M;
			}
			//if(i<5) cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
			d2[i][j]=d2[i][j-1]+dp[i][j];d2[i][j]%=M;
		}
		//d2[i][i+1]=d2[i][i];
	}
	cout<<d2[n][K]<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,m; cin >> n >> m;
    vl p(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    vvl G(n);
    rep(i,m){
        ll a,b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<bool> visit(n,false);
    vl same(n);
    rep(i,n) same[i] = i;
    vvl renketu(n);
    rep(i,n){
        renketu[i].push_back(i);
        if(same[i] != i) continue;
        queue<ll> q;
        q.push(i);
        while(!q.empty()){
            ll u = q.front(); q.pop();
            visit[u] = true;
            for(auto v : G[u]){
                if(visit[v]) continue;
                renketu[i].push_back(v);
                same[v] = i;
                q.push(v);
            }
        }
    }
    rep(i,n) sort(all(renketu[i]));
    ll ans = 0;
    //rep(i,n) cout << same[i] << endl;
    rep(i,n){
        bool bs = binary_search(all(renketu[same[i]]),p[i]);
        if(bs) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14320
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K; cin >> N >> K;
  ll X = 0, Y = 0, Z = 0;
  for(ll i = 1; i <= N; i++){
    if(i%K == 0) X++;
    if(i%K == K/2 && K%2 == 0) Y++;
  }
  cout << X*X*X+Y*Y*Y << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve(n int64, m int64, as []int) int64 {
	if n == 1 {
		for m > 0 {
			if as[0] == 0 {
				break
			}
			as[0] /= 2
			m--
		}
		return int64(as[0])
	}

	sort.Ints(as)
	for m > 0 {
		if as[n-1] == 0 {
			break
		}
		as[n-1] /= 2
		m--
		for as[n-1] > 0 && as[n-1] >= as[n-2] && m > 0 {
			as[n-1] /= 2
			m--
		}
		end := as[n-1]
		if end == 0 {
			end = 1
		}
		for i := n - 2; i >= 1 && as[i] >= end && m > 0; i-- {
			as[i] /= 2
			m--
		}
		if m == 0 {
			break
		}
		sort.Ints(as)
	}

	var ret int64
	for _, a := range as {
		//fmt.Fprintf(out, "as[%d] : %d\n", i, a)
		ret += int64(a)
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	m := nextInt()
	a := nextInts(n)
	res := solve(n, m, a)
	fmt.Fprintln(out, res)
}

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

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int {
	ret := make([]int, n)
	for i := int64(0); i < n; i++ {
		ret[i] = int(nextInt())
	}
	return ret
}
func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll kai[100010];
ll bit[700010];

ll n, m;
ll a[100010];
ll ans;
ll sum[300010];

/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

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

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y)
{
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

void init()
{
	/*kai[0] = 1;
	for (int i = 1; i <= 10000; i++)
	{
		kai[i] = kai[i - 1] * i % mod;
	}*/
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
	{
		sum[i + 1] = sum[i] + a[i];
	}
}

void output()
{
	
}

bool cmp(ll x, ll y)
{
	return a[x] > a[y];
}

bool judge(ll X)
{
	ll num = 0;
	for (int i = 0; i < n; i++)
	{
		ll lb = -1, ub = n;
		while (lb + 1 < ub)
		{
			ll mid = (lb + ub) / 2;
			if (a[mid] + a[i] >= X)
			{
				ub = mid;
			}
			else
			{
				lb = mid;
			}
		}
		num += n - ub;
	}

	return num >= m;
}

void solve()
{
	ll lb = 0, ub = 10000000;
	while (lb + 1 < ub)
	{
		ll mid = (lb + ub) / 2;
		if (judge(mid))
		{
			lb = mid;
		}
		else
		{
			ub = mid;
		}
	}

	ll num_m = lb;
	
	ll num = 0;
	for (int i = 0; i < n; i++)
	{
		ll lb = -1, ub = n;
		while (lb + 1 < ub)
		{
			ll mid = (ub + lb) / 2;
			if (a[mid] + a[i] > num_m)
			{
				ub = mid;
			}
			else
			{
				lb = mid;
			}
		}
		num += n - ub;
		ans += sum[n] - sum[ub];
		ans += (n - ub) * a[i];
	}
	
	ans += (m - num) * num_m;
	
	cout << ans << endl;
}

int main()
{
	init();

	solve();



	output();
	ll N;
	cin >> N;
}

Measured memory_bytes: 3072
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

void searchAccess(const vector<vector<int> >& edges, int start, vector<bool>& access)
{
    int n = edges.size();
    access.assign(n, false);

    access[start] = true; // 有向グラフの場合、この行を削るとaccess[start]は閉路の有無
    queue<int> q;
    q.push(start);
    while(!q.empty()){
        int j = q.front();
        q.pop();
        for(unsigned i=0; i<edges[j].size(); ++i){
            if(!access[edges[j][i]]){
                q.push(edges[j][i]);
                access[edges[j][i]] = true;
            }
        }
    }
}
void searchAccess(const vector<vector<int> >& edges, vector<vector<bool> >& access)
{
    int n = edges.size();
    access.resize(n);
    for(int i=0; i<n; ++i)
        searchAccess(edges, i, access[i]);
}

int main()
{
    int n;
    cin >> n;
    map<string, int> index;
    vector<int> x(n);
    for(int i=0; i<n; ++i){
        string a;
        cin >> a >> x[i];
        index[a] = i;
    }

    int m;
    cin >> m;
    vector<vector<int> > edges(n);
    for(int i=0; i<m; ++i){
        string s, t;
        cin >> s >> t;
        int a = index[s];
        int b = index[t];
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<vector<bool> > access;
    searchAccess(edges, access);

    int ans = 0;
    for(int i=0; i<n; ++i){
        int cost = INT_MAX;
        for(int j=0; j<n; ++j){
            if(access[i][j])
                cost = min(cost, x[j]);
        }
        ans += cost;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5220
#include<iostream>
#include<tuple>
#include<string>
#include<algorithm>

int main() {
	int n;
	std::cin >> n;
	std::tuple<std::string, int, int>*t = new std::tuple<std::string, int, int>[n];
	for (int i = 0; i < n; i++) {
		std::cin >> std::get<0>(t[i]) >> std::get<1>(t[i]);
		std::get<1>(t[i]) *= -1;
		std::get<2>(t[i]) = i + 1;
	}

	std::sort(t, t + n);

	for (int i = 0; i < n; i++) printf("%d\n", std::get<2>(t[i]));
}

Measured memory_bytes: 256
array_index = gets(chomp:true).to_i
array = gets.split.map(&:to_i)
rep_count = 0
for loop_num in 0...array_index
rigth_ope_index = array_index - 1
left_cmp_index = rigth_ope_index - 1
while left_cmp_index >= loop_num 
if array[left_cmp_index] > array[rigth_ope_index]
temp_elem = array[rigth_ope_index]
array[rigth_ope_index] = array[left_cmp_index]
array[left_cmp_index] = temp_elem
rep_count += 1
end
left_cmp_index -= 1
rigth_ope_index -= 1
end
end
puts array.join(" ")
puts rep_count


Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    map<ll,ll> mp;
    REP(i,n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    vector<ll> b = a;
    sort(ALL(b), greater<ll>());
    UNIQUE(b);
    REP(i,n) {
        ll ans = (a[i]==b[0] && mp[a[i]]==1 ? b[1] : b[0]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 12160
#include<stdio.h>

int main(void)
{
   int i,n,t=0;
   int a[100000];
   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      t+=a[i];
   }
   printf("%d\n",t-n);
   return 0;
}


Measured memory_bytes: 128
/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0022&lang=jp
 */
#include <stdio.h>
#define N 5000

int getsign(int d){
	return d >= 0 ? 1 : -1;
}

int seqsum(int n){
	int a[N];
	int b[N];
	int c = 0;
	int s = 0;

	scanf("%d", a);
	b[0] = a[0];
	s = getsign(a[0]);

	for(int i=1; i<n; ++i){
		scanf("%d", a+i);
		if(s == getsign(a[i])){
			b[c] += a[i];
		}else{
			b[++c] = a[i];
			s = getsign(a[i]);
		}
	}

	int m = b[0];
	int sum = m;
	if(c == 0){
		if(m >= 0){ return m; }
		m = a[0];
		for(int i=1; i<n; ++i){
			if(m < a[i]){
				m = a[i];
			}
		}
		return m;
	}

	a[0] = b[0];
	m = a[0];
	for(int i=1; i<=c; ++i){
		a[i] = a[i-1] < 0 ? b[i] : a[i-1] + b[i];
		if(m < a[i]){
			m = a[i];
		}
	}

	//for(int i=1; i<=c; ++i){
	//	if(m < sum + b[i]){
	//		sum += b[i];
	//		m = sum;
	//	}else if(m < b[i]){
	//		sum = m = b[i];
	//	}else{
	//		sum += b[i];
	//	}
	//}

	return m;
}

int main(void){
	int n = 0;
	while(true){
		scanf("%d", &n);
		if(n == 0){ break;}
		printf("%d\n", seqsum(n));
	}
	return 0;
}

Measured memory_bytes: 1052
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int N;
    int i=0;
    scanf("%d",&N);
    printf("\n");
    
    for(;;){
        if(N-1000*i > 0){
            i++;
        }
        else{
            printf("%d",1000*i-N);
            printf("\n");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int N, M;
vector<vector<pair<int,int>>> edges;
vector<int> es;

bool dfs(int v, int tv, int par = -1){
    if(v == tv) return true;
    for(auto nv : edges[v]){
        if(nv.first == par) continue;
        if(dfs(nv.first, tv, v)){
            es.push_back(nv.second);
            return true;
        }
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    edges.resize(N);
    REP(i,N-1){
        int a, b;
        cin >> a >> b;
        --a, --b;
        edges[a].emplace_back(b, i);
        edges[b].emplace_back(a, i);
    }
    cin >> M;
    vector<ll> eset(M);
    REP(i,M){
        int u, v;
        cin >> u >> v;
        --u, --v;
        es = vector<int>();
        dfs(u, v);
        for(auto e : es) eset[i] |= (1LL << e);
    }
    ll ans = 0;
    REP(i,1LL<<M){
        ll bits = 0;
        REP(j,M) if((i>>j) & 1) bits |= eset[j];
        ll white = __builtin_popcountll(bits);
        if(__builtin_popcountll(i) % 2 == 0) ans += 1LL << (N - 1 - white);
        else ans -= 1LL << (N - 1 - white);
    }
    cout << ans << endl;
}

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

int main() {
  int n, k, f;
  cin >> n >> k;
  int min = 1;

  for (int i = 0; i < n; i++) {
    if (min * 2 > min + k) {
      min += k;
    }
    else {
      min *= 2;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 3632