akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N,K,S;
  cin >> N >> K >> S;
  vi A(N);
  if(S<1e9) {
    rep(i,K) cout << S << ' ';
    rep2(i,K,N) cout << S+1 << ' ';
    cout << endl;
  }
  else {
    rep(i,K) cout << S << ' ';
    rep2(i,K,N) cout << 1 << ' ';
    cout << endl;
  }
}

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

int top;
int C[2];

int pop(void);
void push(int);

int main(){
  int a,b,x,n;
  char s[100];
  
  while(1){
    n = scanf("%s",s);
    if(n == EOF)break;
    switch(s[0]){     
    case '+':
      a = pop();
      b = pop();
      push(b+a);
      break;
       
    case '-':   
      a = pop();
      b = pop();
      push(b-a);
      break;
       
    case '*':
      a = pop();
      b = pop();
      push(b*a);
      break;
       
    default:
      x = atoi(s);
      push(x);
      break;
    }

  }
  x = pop();
  printf("%d\n",x);

  return 0;
}

int pop(void){
  top--;
  return C[top+1];
}

void push(int x){
  top++;
  C[top]=x;
}
  

Measured memory_bytes: 548
import itertools
import collections


def prime_factor_table(n):
    table = [0] * (n + 1)

    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i

    return table


def prime_factor(n, prime_factor_table):
    prime_count = collections.Counter()

    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n //= prime_factor_table[n]
    prime_count[n] += 1

    return prime_count


def solve(N):
    ans = 1

    table = prime_factor_table(1000000)

    for i in range(2, N):
        tmp = prime_factor(i, table)
        tt = 1
        for t in tmp:
            tt *= (tmp[t]+1)
        ans += tt
    return ans


if __name__ == "__main__":
    N = int(input())
    print(solve(N))


Measured memory_bytes: 82908
s = str(input())
t = [0 for i in range(len(s)-2)]
for i in range(len(s)-2):
    t[i] = int(s[i:i+3])
u = [0 for i in range(len(t))]
for i in range(len(t)):
    u[i] = abs(t[i]-753)
print(min(u))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

struct info{
    ll x,y,z;
};
bool comp(info a,info b){
    return a.x<b.x;
}

int main(){fastio
    ll r,c;cin>>r>>c;
    ll n;cin>>n;
    info io[n];
    rep(i,0,n-1){
        cin>>io[i].x>>io[i].y>>io[i].z;
        io[i].x--;io[i].y--;
    }
    sort(io,io+n,comp);
    vector<l_l>v[c];
    rep(i,0,n-2){
        if(io[i].x==io[i+1].x){
            ll dis=io[i+1].z-io[i].z;
            v[io[i].y].pb({io[i+1].y,dis});
            v[io[i+1].y].pb({io[i].y,-dis});
        }
    }
    ll sc[c];rep(i,0,c-1)sc[i]=-inf;
    rep(i,0,c-1){
        if(sc[i]==-inf){
            vector<ll>vec;
            queue<ll>q;q.push(i);
            sc[i]=0;
            while(!q.empty()){
                ll t=q.front();q.pop();vec.pb(t);
                for(auto x:v[t]){
                    if(sc[x.fi]==-inf){
                        sc[x.fi]=sc[t]+x.se;
                        q.push(x.fi);
                    }else{
                        if(sc[x.fi]!=sc[t]+x.se){
                            cout<<"No"<<endl;return 0;
                        }
                    }
                }
            }
            ll mi=vec[0];
            for(auto x:vec){
                if(sc[mi]>sc[x])mi=x;
            }
            mi=sc[mi];
            for(auto x:vec){
                sc[x]-=mi;
            }
        }
    }
    ll sr[r];rep(i,0,r-1)sr[i]=-inf;
    rep(i,0,n-1){
        ll res=io[i].z-sc[io[i].y];
        if(res<0){
            cout<<"No"<<endl;return 0;
        }
        if(sr[io[i].x]==-inf){
            sr[io[i].x]=res;
        }else if(sr[io[i].x]!=res){
            cout<<"No"<<endl;return 0;
        }
    }
    rep(i,0,r-1)if(sr[i]==-inf)sr[i]=0;
    
    
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 9332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,p,q,ct,x,z;
    string s;
    vector<ll>v;
    char c;
    map<char,ll>mp;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    ll flag=0,flagg=0;
    for(ll i=0;i<n-1;i++)
    {
        for(ll j=0;j<n;j++)
        {
            flag=0;
            swap(v[i],v[j]);
            for(ll k=0;k+1<n;k++)
            {
                if(v[k]>v[k+1]) flag=1;
            }
            if(flag==1)
            {
               swap(v[i],v[j]);
            }
            else {flagg=1; break;}
        }
            if(flagg==1) break;
    }

    if(flagg==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}





Measured memory_bytes: 256
#include<stdio.h>
#define max 10000
main(){
  int i,j,n,q,f[max],s[max],count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&f[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&s[i]);
  for(i=0;i<q;i++)
    for(j=0;j<n;j++)
      if(f[j]==s[i]){
    count++;
    break;
      }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 648
x=int(input())
a=0
for i in range(1,x+1):
    if i%3==0:
        print(" %d"%i,end="")
    else :
        a=i
        while (a):
            if a%10==3:
                print(" %d"%i,end="")
                break
            a//=10
print()


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

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

using namespace std;

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

  int tmp = max(b-a-w,a-b-w);
  cout<<max(tmp, 0);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 5e5 + 10;
const ll mod = 998244353;
char s[N], t[N];
int ans = INF;
int main() {
	scanf("%s%s", s, t);
	int n = strlen(s), m = strlen(t);
	for (int i = 0; i < n - m + 1; i++) {
		int tmp = 0;
		for (int j = 0; j < strlen(t); j++) {
			tmp += (t[j] != s[i + j]);
		}
		ans = min(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
   int n;
   cin >> n;
   int a[n];
   for(int i  = 0; i < n; i++)cin >> a[i];
   sort(a,a+n);
   int sum = 0;
   for(int i = 0; i < n-1; i++){
    sum += a[i];
   }
   if(sum > a[n-1]){
    cout << "Yes" << endl;
   }
   else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main(void){
    char s[11];
    char t[11];
    char u[11];
    int a,b;
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if(strcmp(s,u) == 0){
        printf("%d %d\n",a - 1,b);
    }
    if(strcmp(t,u) == 0){
        printf("%d %d\n",a,b - 1);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int cnt=0;
    for(int i=0;i<n-1;i++){
        if(a[i+1]==a[i]){cnt++;}
    }
    if(cnt%2==1){cnt++;}
    cout<<n-cnt<<endl;
}

Measured memory_bytes: 640
h,w = map(int,input().split())
b = [[i == "#" for i in list(input())]+[True] for _ in range(h)]+[[True]*(w+1)]
check = []
for i in range(h):
  for j in range(w):
    if b[i][j]:
      check.append((i,j))
ans = 0
while check:
  new = []
  k = 0
  for i,j in check:
    if not b[i-1][j]:
      new.append((i-1,j))
      b[i-1][j] = True
      k = 1
    if not b[i+1][j]:
      new.append((i+1,j))
      b[i+1][j] = True
      k = 1
    if not b[i][j-1]:
      new.append((i,j-1))
      b[i][j-1] = True
      k = 1
    if not b[i][j+1]:
      new.append((i,j+1))
      b[i][j+1] = True
      k = 1
  check = new
  if k:
    ans += 1
print(ans)

Measured memory_bytes: 105576
#include "bits/stdc++.h"
using namespace std;
#define FAST ios::sync_with_stdio(false); cin.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define ins insert
#define ph push
#define mmst(x,v) memset(x,v,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define LLINF ((long long)1e18)
#define cbr cerr << "hi\n"
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<e;i++)
#define MAXN 300006
#define siz(x) ((ll)x.size())
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
ll L, r, N, H;
vector<tuple<ll,ll,ll>>ans;
int main()
{
	FAST
	cin >> L;
	for(ll i=20;i>=0;i--) {
		if((1<<i)&L) { r = i; break; }
	}
	N = r+1; assert(N>1);
	for(ll i = 1; i < N; i++) {
		ans.pb(make_tuple(i,i+1,(1<<(i-1))));
		ans.pb(make_tuple(i,i+1,0));
		H=max(H,(1ll<<(i-1)));
	}
	H = (1<<(N-1));
	for(ll i = 0; i < r; i++) {
		if(!((1<<i)&L)) continue;
		assert(H<=(ll)1e6);ans.pb(make_tuple(i+1,N,H));
		H+=(1<<i);
	}
  assert(N<=20&&siz(ans)<=60);
	cout<<N<<' '<<siz(ans)<<'\n';
	for(auto i : ans) {
		cout << get<0>(i) << ' ' << get<1>(i) << ' ' << get<2>(i) << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[105];

int main(){

	scanf("%s",buf);

	bool FLG = true;

	for(int i = 0; buf[i] != '\0'; i++){
		if(i%2 == 0){

			if(buf[i] != 'R' && buf[i] != 'U' && buf[i] != 'D'){

				FLG = false;
				break;
			}

		}else{

			if(buf[i] != 'L' && buf[i] != 'U' && buf[i] != 'D'){

				FLG = false;
				break;
			}
		}
	}

	if(FLG){

		printf("Yes\n");

	}else{

		printf("No\n");
	}

	return 0;
}


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

ifstream fin("date.in");
int v[1010];
int main() {
    int n, k;

    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> v[i];

    sort(v + 1, v + 1 + n);

    int sum = 0;
    for (int i = 1; i <= k; i++)
        sum += v[i];

    cout << sum;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<PII> x[n];
  rep(i,n-1){
    int u,v,w;
    cin>>u>>v>>w;
    u--;v--;
    x[u].push_back(make_pair(v,w));
    x[v].push_back(make_pair(u,w));
  }
  int visited[n]={};
  visited[0]=1;
  queue<int> bfs;
  bfs.push(0);
  while(!bfs.empty() ){
    int num=bfs.front();
    // cout<<num<<endl;
    bfs.pop();
    rep(i,x[num].size() ){
      if(visited[x[num][i].F]==0){
	if(x[num][i].S % 2 == 0){
	  visited[x[num][i].F]=visited[num];
	}else{
	  visited[x[num][i].F]=(visited[num])*(-1);
	}
	bfs.push(x[num][i].F);
      }
    }
  }
  rep(i,n){
    if(visited[i]==-1) cout<<0<<endl;
    else cout<<1<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 8704
# -*- coding: utf-8 -*-


def main():
    n, k = map(int, input().split())
    s = list(input())

    nums = list()
    now = 1
    count = 0

    # See:
    # https://www.youtube.com/watch?v=FRzpDCx17vw
    # 1と0が連続していくつ続いているかを数える
    # 一つの配列で管理
    for si in s:
        if si == str(now):
            count += 1
        else:
            nums.append(count)
            now = 1 - now  # 0と1を切り替える
            count = 1

    # 端部の処理
    if count != 0:
        nums.append(count)

    # 1-0-1-0-1の形になっている必要がある
    if len(nums) % 2 == 0:
        nums.append(0)

    add = 2 * k + 1

    # 1. left，rightをfor文の前に
    left = 0
    right = 0  # [left, right)
    tmp = 0
    ans = 0

    # 偶数番目に着目
    for i in range(0, len(nums), 2):
        # 2. 次のleft, rightを決める
        next_left = i
        next_right = min(i + add, len(nums))

        # 3.
        # 左端を移動
        while next_left > left:
            tmp -= nums[left]
            left += 1

        # 右端を移動
        while next_right > right:
            tmp += nums[right]
            right += 1

        ans = max(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()


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

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

  int n,k;
  cin >> n >> k;

  int sum = 0;
  vector<int> a(n);
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }

  set<int> divisor;
  for (int i = 1; i * i <= sum; i++) {
    if(sum % i == 0) {
      divisor.insert(i);
      divisor.insert(sum/i);
    }
  }

  int answer = 0;
  for (auto d : divisor) {
    vector<int> mod(n);
    for (int i = 0; i < n; i++) {
      mod[i] = a[i] % d;
    }
    sort(mod.begin(),mod.end());

    vector<int> prefix_sum(n);
    prefix_sum[0] = mod[0];
    for (int i = 1; i < n; i++) {
      prefix_sum[i] = prefix_sum[i - 1] + mod[i];
    }

    // -A == Bとなる境界探し
    // iまでを含むところがマイナス
    for (int i = 0; i < n - 1; i++) {
      int left = prefix_sum[i];
      int right = (n - 1 - i) * d - (prefix_sum[n - 1] - prefix_sum[i]);
      int diff = abs(right - left);
      if(diff % d == 0 && max(left, right) <= k) {
        answer = d;
        break;
      }
    }
  }
  cout << answer << '\n';
}


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

int main() {
  // n 頂点
  // m 辺
  int n, m;
  cin >> n >> m;

  // パス情報を双方向で管理する
  vector<vector<int>> a(n, vector<int>(n, 0));
  vector<vector<int>> b(n, vector<int>(n, 0));
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--; // 0-indexed
    a.at(x).at(y) = 1;
    b.at(y).at(x) = 1;
  }

  // 初期順列
  vector<int> order(n);
  for (int i = 0; i < n; i++) {
    order.at(i) = i;
  }

  // 順列全探索
  int ans = 0;
  do {
    // 頂点1を始点とすること (0-indexed の場合は 0)
    if (order.at(0) != 0) { continue; }

    bool ok = true;
    for (int i = 1; i < n; i++) {
      int from = order.at(i-1);
      int to = order.at(i);
      // 辺が存在する場合は、次のパスを検証する
      if (a.at(from).at(to)) { continue; }
      if (b.at(from).at(to)) { continue; }

      // 辺が存在しない場合は、順列で作成した有限列のパターンが
      // 成立しないため、false とする
      ok = false;
    }
    if (ok) { ans++; }
  } while (next_permutation(order.begin(), order.end()));

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


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	long long ans1 = A * X + B * Y;
	long long ans2 = C * min(X, Y) * 2;
	if (X < Y) ans2 += B * (Y - X);
	else ans2 += A * (X - Y);
	long long ans3 = C * max(X, Y) * 2;
	long long Ans = min({ans1, ans2, ans3});
	cout << Ans << endl;
}

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

int main()
{
    int x, y, z, k;
    std::cin >> x >> y >> z >> k;
    std::vector<long long> a(x), b(y), c(z);
    for (int i = 0; (i < x); ++i) std::cin >> a[i];
    for (int i = 0; (i < y); ++i) std::cin >> b[i];
    for (int i = 0; (i < z); ++i) std::cin >> c[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    std::vector<long long> ab;
    for (int i = 0; (i < x); ++i) {
        for (int j = 0; (j < y); ++j) {
            ab.emplace_back(a[i] + b[j]);
        }
    }
    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());
    std::vector<long long> abc;
    for (int i = 0; (i < std::min(k, (int)ab.size())); ++i) {
        for (int j = 0; (j < z); ++j) {
            abc.emplace_back(ab[i] + c[j]);
        }
    }
    sort(abc.begin(), abc.end());
    reverse(abc.begin(), abc.end());
    for (int i = 0; (i < k); ++i) {
        std::cout << abc[i] << std::endl;
    }
    return 0;
}


Measured memory_bytes: 43240
#include<bits/stdc++.h>
const int maxn = 200100;
struct T {
	int to, nxt, v;
} way[maxn << 4];
int h[maxn], head[maxn], num = 1;
inline void adde(int x,int y,int v) {
	way[++num] = {y, h[x], v}, h[x] = num;
	way[++num] = {x, h[y], 0}, h[y] = num;
}
int dis[maxn];
inline bool bfs(int s,int t) {
	std::queue<int> q;
	for(int i = s;i <= t;++i) dis[i] = - 1, head[i] = h[i];
	for(q.push(s), dis[s] = 0;!q.empty();) {
		int t = q.front(); q.pop();
		for(int i = h[t];i;i = way[i].nxt) if(way[i].v && dis[way[i].to] < 0) 
			dis[way[i].to] = dis[t] + 1, q.push(way[i].to);
	}
	return dis[t] >= 0;
}
inline int dfs(int s,int t,int lim) {
	if(s == t || !lim) return lim;
	int ans = 0, mn;
	for(int & i = head[s];i;i = way[i].nxt)
		if(dis[way[i].to] == dis[s] + 1 && (mn = dfs(way[i].to, t, std::min(lim, way[i].v)))) {
			way[i].v -= mn;
			way[i ^ 1].v += mn;
			ans += mn; lim -= mn;
			if(!lim) break;
		}
	return ans;
}
inline int dinic(int s,int t) {
	int ans = 0;
	for(;bfs(s,t);) ans += dfs(s,t,1e9);
	return ans;
}
int n;
std::vector<int> v[maxn];
std::vector<int> to[maxn];
std::pair<int,int> ans[maxn];
int id[maxn], fa[maxn], idx[maxn];
int main(){
	std::ios::sync_with_stdio(false),std::cin.tie(0);
	std::cin >> n;
	for(int i = 1,x,a;i < n;++i) {
		std::cin >> x, adde(0, i, 1);
		for(;x--;) {
			std::cin >> a, v[i].push_back(a);
			if(a != n) adde(i, a + n, 1);
		}
	}
	for(int i = 1;i < n;++i) adde(i + n,n + n + 1,1);
	if(dinic(0,n + n + 1) != n - 1) {
		std::cout << -1 << '\n';
		return 0;
	}
	for(int i = 1;i < n;++i) for(int j = h[i + n];j;j=way[j].nxt) if(way[j].v == 1 && way[j].to < n) {
		id[way[j].to] = i;
		idx[i] = way[j].to;
	}
	for(int i = 1;i < n;++i) for(int j : v[i])
		to[j].push_back(id[i]);
	std::queue<int> q; 
	for(q.push(n), fa[n] = 1;!q.empty();) {
		int t = q.front(); q.pop();
		for(int i : to[t]) if(!fa[i]) {
			q.push(i), fa[i] = t;
			ans[idx[i]] = {i, t};
		}
	}
	if(std::count(fa + 1,fa + n + 1,0)) {
		std::cout << - 1 << '\n';
	} else {
		for(int i = 1;i < n;++i) std::cout << ans[i].first << ' ' << ans[i].second << '\n';
	}
}


Measured memory_bytes: 34080
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    int[] y = new int[n];
    for(int i = 0; i < n ;i++){
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
    }
    double sum = 0d;
    int count = 0;
    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n ; j++){
        count ++;
        sum += calc(x[i], y[i], x[j], y[j]);
      }
    }
    System.out.println(sum / count *(n - 1));
  }

  public static double calc(int x1, int y1, int x2, int y2){
    return Math.sqrt( (x1 - x2) *  (x1 - x2) + (y1 - y2) * (y1 - y2));
  }
}


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

using namespace std;

/*helpfull*/
using vl  = vector<long long>;
using vpl = vector<pair<long long, long long>>;
using vs = vector<string>;
using pl  = pair<long long, long long>;
using ll  = long long int;
using vb  = vector<bool>;


struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};
// #ifndef ONLINE_JUDGE
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
// #endif

// shortcut macros
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp              make_pair
#define fi              first
#define se              second
// #define mt              make_tuple
#define pb              push_back
#define all(x)          (x).begin(), (x).end()
#define ini(a, v)       memset(a, v, sizeof(a))
#define rep(i, a, n)    for(ll i=a ; i<n ; ++i)
#define For(i, n)       rep(i, 0, n)
#define sz(x)           (int((x).size()))
#define ump(x,y)        unordered_map<x,y>
#define umpr(x,y,z)     unordered_map<x,y,z>
void printcase(ll &x) {
    cout << "Case #" << x << ": ";
}
void read(vector<ll>&v, ll &n) {
    For(i, n)
    cin >> v[i];
}
void read(ll &x) {
    cin >> x;
}
void read(string &s) {
    cin >> s;
}
void read(int &x) {
    cin >> x;
}
void read(ll a[], ll &n) {
    For(i, n)
    cin >> a[i];
}
void print() {
    cout << endl;
}
void write(vector<ll>&v, ll &n) {
    For(i, n)
    cout << v[i] << " ";
    cout << endl;
}
void write(vector<ll>&v) {
    ll n = v.size();
    For(i, n)
    cout << v[i] << " ";
    cout << endl;
}
void write(ll x) {
    cout << x << endl;
}
void write(string &s) {
    cout << s << endl;
}
void write(int &x) {
    cout << x << endl;
}
void write(ll a[], ll &n) {
    For(i, n)
    cout << a[i] << " ";
    cout << endl;
}

ll knap(ll i, vector<vector<ll>> &v, vector<vector<ll>> &dp, ll &n, ll w) {
    if (i == n) return 0;

    if (dp[i][w] != -1)
        return dp[i][w];
    if (v[i][0] <= w) {
        dp[i][w] = max(v[i][1] + knap(i + 1, v, dp, n, w - v[i][0]), knap(i + 1, v, dp, n, w));
    }
    else {
        dp[i][w] = knap(i + 1, v, dp, n, w);
    }
    return dp[i][w];
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll n, w;
    cin >> n >> w;
    vector<vector<ll>> v(n, vector<ll>(2)), dp(n, vector<ll>( w + 1, -1));
    // vector<ll> dp(n, -1);
    For(i, n)
    cin >> v[i][0] >> v[i][1];
    cout << knap(0, v, dp, n, w) << endl;
    return 0;
}




Measured memory_bytes: 82256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        
        String s = sc.next();
        
        sb.append(s);
        sb.insert(4, " ");
        
        System.out.println(new String(sb));
        
        sc.close();
        
    }
}


Measured memory_bytes: 22484
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
const int INF = 1e9;
using namespace std;

int A, B, C, N;
vector<int> L;

int rec(int i, int a, int b, int c) {
    // 竹L[i]を，cond 1-4に分けて再帰的に探索
    if (i==N) {
        if(!a || !b || !c) return INF;
        return abs(a-A) + abs(b-B) + abs(c-C);
    }

    // cond 1: 今ある竹を利用しない
    int res = rec(i+1, a, b, c);

    // cond 2-4: A, B, Cを使う場合
    chmin(res, rec(i+1, a+L[i], b, c) + (a?10:0));
    chmin(res, rec(i+1, a, b+L[i], c) + (b?10:0));
    chmin(res, rec(i+1, a, b, c+L[i]) + (c?10:0));


    return res;
}

int main() {
    cin >> N >> A >> B >> C;
    L.resize(N);
    REP(i, N) cin >> L[i];

    cout << rec(0, 0, 0, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,k,h,a=0,i; 
    scanf("%d %d", &n, &k);
    for(i=0; i<n; i++)
    {
        scanf("%d", &h);
        if(h>=k)
        a++;
    }
    printf("%d\n", a);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
     
    int main() {
        int n, max_w;
     
        cin >> n >> max_w;
     
        vector<int> w(n);
        vector<int> v(n);
     
        for ( int i = 0; i < n; i++ ) {
            cin >> w[i] >> v[i];
        }
     
        vector<vector<ll>> dp(n+1, vector<ll>(max_w+1));
    //    vector<vector<ll>> dp(n, vector<ll>(max_w));
     
     
     
        for ( int i = 1; i <= n; i++ ) {
            for ( int j = 0; j <= max_w; j++ ) {
    //            dp[i][j] = max(dp[i][j], dp[i-1][j]);
                dp[i][j] = dp[i-1][j];
                if ( j - w[i-1] >= 0 ) {
                    dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
                }
            }
        }
     
        ll ans = 0;
        for ( int i = 0; i <= max_w; i++ ) {
            ans = max(ans, dp[n][i]);
        }
     
        cout << ans << endl;
     
        return 0;
    }

Measured memory_bytes: 80256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	char s[10];
	int i,a,x=0,y=0,z=0,b=0,c=0,d=1000;
	scanf("%s",s);
	a=strlen(s);
	for(i=0;i<a-2;i++){
		x=s[i]-'0';
		y=s[i+1]-'0';
		z=s[i+2]-'0';
		b=(x*100)+(y*10)+z;
		c=753-b;
		if(c<0) c*=-1;
		if(d>c) d=c;
	}
	printf("%d\n",d);
	return 0;
}


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

int main() {
    int a[5];
    int ans = 0;
    for (int i = 0;i < 5;i++) {
        cin >> a[i];
        if (a[i] == 0) ans = i;
    }

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


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
	int a[5];
	
	cin >> a[0] >> a[1] >>a[2]>>a[3]>>a[4];
	sort(a, a+5,greater<int>());
	
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;

map<int,int> ans;

void dfs(int r,int x,int p,int d,vector<vector<int>> &G,vector<vector<int>> &D){
    if(D[r][x]>=d||D[x][r]>=d){
        D[r][x]=d;
        D[x][r]=d;
    }
    else return;
    for(auto i:G[x]){
        if(i==p)continue;
        dfs(r,i,x,d+1,G,D);
    }
}

int main() {
    int n,x,y;
    cin>>n>>x>>y;
    vector<vector<int>> dist(n,vector<int>(n,2*n));
    vector<vector<int>> G(n);
    for(int i = 0;i < n-1;++i) {
        G[i].emplace_back(i+1);
        G[i+1].emplace_back(i);
        if(i==x-1){
            G[i].emplace_back(y-1);
            G[y-1].emplace_back(i);
        }
    }
    for(int i = 0;i < n;++i) {
        dfs(i,i,-1,0,G,dist);
        //cerr<<i<<endl;
    }
    vector<int> ans(n,0);
    for(int i = 0;i < n;++i) {
        for(int j = i+1;j < n;++j) {
            if(dist[i][j]<n)++ans[dist[i][j]];
        }
    }
    for(int i = 1;i < n;++i) {
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 16256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<stack>
#include<map>
#include<set>
#include<assert.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;


void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	rep1(i, 100000) {
		int num = lower_bound(a.begin(), a.end(),i) - a.begin();
		if (num == n / 2) {
			ans++;
		}
	}
	cout << ans << endl;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout<<fixed<<setprecision(10);
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

/*
 貪欲
 ①決定問題 必ず解に含まれる(含むように変換できる)ものから決めていく みんプロ本選B
 ②最適化問題 任意の解から評価を落とさず解に含められるようなものから決めていく 区間スケジューリングとか
 ③
 */

/*
 DP
 ①DPはある程度決め打ちをするべき
 */
ll n;
string s1,s2;
ll dfs(ll pos, ll b) {
	if(pos==n) return 1;
	ll ret=1;
	if(s1[pos]!=s2[pos]) {
		if(b==-1) {
			ret*=6*dfs(pos+2,1);
		}
		if(b==0) {
			ret*=2*dfs(pos+2,1);
		}
		if(b==1) {
			ret*=3*dfs(pos+2,1);
		}
	} else {
		if(b==-1) {
			ret*=3*dfs(pos+1,0);
		}
		if(b==0) {
			ret*=2*dfs(pos+1,0);
		}
		if(b==1) {
			ret*=1*dfs(pos+1,0);
		}
	}
	return ret%MOD;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n;
	cin>>s1>>s2;
	cout<<dfs(0,-1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int a[n];
	set<int> s;
	map<int,int> mp;
	for(int i = 0;i<n; i++)
	{
		 cin>>a[i];
		 s.insert(a[i]);
		 mp[a[i]]++;
	}
	ll ans = 0,cnt = 0, c = s.size();
	int b[c];
	for(int i =0 ;i <s.size(); i++)
	{
		b[i]= *s.begin();
		s.erase(s.begin());
	}
	map<int,int> y;
	for(auto it:mp)
	{
		y[it.first-1] += it.second;
		y[it.first+1] += it.second;
	}
	for(auto it:mp)
	{
		y[it.first] += it.second;
	}
	for(auto it:y)
		if(it.second>cnt)
			cnt = it.second;
	cout<<cnt<<endl;	
	return 0;
}

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

int main(){
  long n,k;
  cin >> n >> k;
  long kekka;
  if(k % 2 != 0){
    kekka = (n/k)*(n/k)*(n/k);
  }
  else{
    kekka = (n/k)*(n/k)*(n/k);
    long i;
    for(i = 0;k/2 + k*i <= n;i++){
    }
    kekka += i*i*i;
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static String[] s = null;
    static int h = 0, w = 0;
    static int[] dy = {1, 0, -1, 0};
    static int[] dx = {0, 1, 0, -1};
    static int[][] dist = null;
    static int ans = 0;

    public static void main(String[] args) {
        h = sc.nextInt();
        w = sc.nextInt();
        s = new String[h];
        for(int y = 0; y < h; ++y) s[y] = sc.next();
        dist = new int[h][w];

        for(int y = 0; y < h; ++y) {
            for(int x = 0; x < w; ++x) {
                if(s[y].charAt(x) == '.') bfs(y, x);
            }
        }
        System.out.println(ans);
    }
    
    static void initializeDist(int sy, int sx) {
        for(int y = 0; y < h; ++y) {
            for(int x = 0; x < w; ++x) dist[y][x] = (y == sy && x == sx) ? 0 : -1;
        }
    }

    static void bfs(int sy, int sx) {
        initializeDist(sy, sx);
        ArrayDeque<Coordinate> coordinates = new ArrayDeque<>();
        coordinates.add(new Coordinate(sy, sx));

        while(coordinates.size() > 0) {
            Coordinate fc = coordinates.remove();
            for(int i = 0; i < 4; ++i) {
                int ny = fc.y + dy[i];
                int nx = fc.x + dx[i];
                if(isOutOfMaze(ny, nx) || s[ny].charAt(nx) != '.' || dist[ny][nx] >= 0) continue;
                dist[ny][nx] = dist[fc.y][fc.x] + 1;
                ans = Math.max(ans, dist[ny][nx]);
                coordinates.add(new Coordinate(ny, nx));
            }
        }
    }

    static boolean isOutOfMaze(int y, int x) {
        return y < 0 || h <= y || x < 0 || w <= x;
    }
}

class Coordinate {
    int y;
    int x;
    
    public Coordinate(int y, int x) {
        this.y = y;
        this.x = x;
    }
}

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

using namespace std;

int main(void)
{
	int N, M;
	while(cin >> N >> M && N > 0){
		vector<int> h(N);
		vector<int> w(M);
		for(int i=0;i<N;i++){
			cin >> h[i];
		}
		for(int i=0;i<M;i++){
			cin >> w[i];
		}
		vector<int> freqh(N*1000, 0);
		for(int i=0;i<N;i++){
			int sum=0;
			for(int j=i;j<N;j++){
				sum += h[j];
				freqh[sum]++;
			}
		}
		vector<int> freqw(M*1000, 0);
		for(int i=0;i<M;i++){
			int sum=0;
			for(int j=i;j<M;j++){
				sum += w[j];
				freqw[sum]++;
			}
		}
		long long int cnt=0;
		for(int i=0;i<min(N*1000, M*1000);i++){
			cnt += freqh[i]*freqw[i];
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 14648
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include <sstream>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef pair<int,int> Point;
const int N = 10, M = 12;
int blur[N][N], COUNT, TOTAL, total;
enum Size{ LARGE, MID, SMALL, N_SIZE };
vector<Point> delta[] = { //dx,dy
    vector<Point> {
        Point(0,0), Point(-1,0), Point(0,-1), Point(1,0), Point(0,1),
        Point(-1,-1), Point(1,-1), Point(1,1), Point(-1,1),
        Point(-2,0), Point(0,-2), Point(2,0), Point(0,2)
    }, vector<Point> {
        Point(0,0), Point(-1,0), Point(0,-1), Point(1,0), Point(0,1),
        Point(-1,-1), Point(1,-1), Point(1,1), Point(-1,1)
    }, vector<Point>{
        Point(0,0), Point(-1,0), Point(0,-1), Point(1,0), Point(0,1)
    },
};
int minimul_count[]={13, 9, 5};
Point target[]{ Point(0,2), Point(1,1), Point(0,1) };
struct Data {
    int x, y, size;
    Data(){}
    Data(int x, int y, int size): x(x), y(y), size(size){}
    string description() const {
        ostringstream oss;
        oss << x << " " << y << " " << N_SIZE-size;
        return oss.str();
    }
};
Data history[M];
inline bool canSub(const Data &data){
    for(const Point &d: delta[data.size]){
        Data p(data.x+d.first, data.y+d.second, data.size);
        if(!(0 <= p.x && p.y < N && 0 <= p.x && p.x < N && blur[p.y][p.x] != 0)) return false;
    }
    return true;
}
inline void add(const Data &d){
    for(const Point &p: delta[d.size]){ ++blur[d.y+p.second][d.x+p.first]; ++total;}
}
inline void sub(const Data &d){
    for(const Point &p: delta[d.size]){ --blur[d.y+p.second][d.x+p.first]; --total;}
}
bool solve(const Data &b, int d){
    if(d == COUNT && total == 0) return true;
    Point p(-1,-1);
    [&](){ REP(y,N) REP(x,N) if(blur[y][x] > 0){ p.first = x; p.second = y; return; } }();
    if(p.first < N-1 && p.second < N-1 && p.first != -1){
        REP(size,N_SIZE){
            if(minimul_count[size] > total) continue;
            Data data = Data(p.first + target[size].first, p.second + target[size].second, size);
            if(canSub(data)){
                sub(data);
                history[d] = data;
                if(solve(data, d+1)) return true;
            }
        }
    }
    add(b);
    return false;
}
int main(){
    cin >> COUNT;
    REP(i,N) REP(j,N){ cin >> blur[i][j]; TOTAL += blur[i][j]; }
    total = TOTAL;
    assert(solve(Data(),0));
    REP(i,COUNT) cout << history[i].description() << endl;
}

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

static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;

void solve() {
        long long n, e, t;
        cin >> n >> e >> t;
        vector<long long> x(n);
        for (int i = 0; i < n; i ++) cin >> x[i];
        vector<long long> dp(n, INFL);
        dp[0] = t;
        int now = 0;
        long long mi = INFL;
        for (int i = 1; i < n; i ++) {
                if (2 * (x[i] - x[0]) <= t) {
                        dp[i] = t;
                        continue;
                }
                mi = min(mi, -2 * x[0]);
                while (2 * (x[i] - x[now + 1]) > t) {
                        mi = min(mi, dp[now] - 2 * x[now + 1]);
                        now ++;
                }
                dp[i] = mi + 2 * x[i];
                dp[i] = min(dp[i], dp[now] + t);
        }
        cout << dp[n - 1] + e << endl;
        return;
}

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



Measured memory_bytes: 1920
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
A_s, B_s = sorted(A), sorted(B)
if any(a > b for a, b in zip(A_s, B_s)):
    print("No")
    quit()
A_idx = [(a, i) for i, a in enumerate(A)]
A_idx.sort()
B = [B[idx] for _, idx in A_idx]
B_idx = [(b, i) for i, b in enumerate(B)]
B_idx.sort()
perm = [i for _, i in B_idx]
cycle_len = 0
used = [False] * N
for i in range(N):
    if used[i]:
        continue
    cnt = 0
    now = i
    while not used[now]:
        used[now] = True
        cnt += 1
        now = perm[now]
    cycle_len += cnt - 1
if cycle_len < N - 1:
    print("Yes")
    quit()

if all(B_idx[i][0] < A_idx[i+1][0] for i in range(N-1)):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 35316
N = int(input())
A = list(map(int,input().split()))
mid = sum(A)/2
length = 0
i = 0
while True:
    if length >= mid:
        length = min(abs(length-mid),abs(length-mid-A[i-1]))+mid
        break
    length += A[i]
    i += 1
print(int(length-(sum(A)-length)))

Measured memory_bytes: 26220
/* ALDS1_1_B: Greatest Common Divisor - http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_B

Greatest Common Divisor
Write a program which finds the greatest common divisor of two natural numbers a and b

Input
a and b are given in a line sparated by a single space.

Output
Output the greatest common divisor of a and b.

Constrants
1 ≤ a, b ≤ 109

Hint
You can use the following observation:

For integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)

Sample Input 1
54 20
Sample Output 1
2
Sample Input 2
147 105
Sample Output 2
21
*/
fn gcd(a: u32, b: u32) -> u32 {
    // Computes the greatest common divisor of a and b recursively.
    if b > a {
        // Swap a and b.
        let temp = a;
        let a = b;
        let b = temp;
    }
    if b == 0 {
        return a;
    }
    gcd(b, a%b)
}
 
fn main() {
    let v: Vec<u32> = read_line()
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap()).collect();

    let ans = gcd(v[0], v[1]);

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

// ------------------------------------------------------------------
// Auxiliary methods.
fn array_to_str(arr: &Vec<i32>) -> String {
    // Converts a numerical array to a string for output purposes.
    let mut ans = String::new();
    for a in arr {
        ans.push_str(&format!("{} ", *a));
    }
    return ans.trim().to_string();
}

fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}



Measured memory_bytes: 5028
import bisect
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


n = int(input())
ls = sorted(read_i())
ls2 = ls[::-1]
res = 0
for i, x in enumerate(ls2):
    for j, y in enumerate(ls2[i + 1:], i + 1):
        res += n - j - 1 - bisect.bisect(ls[:-(j + 1)], x - y)
print(res)

Measured memory_bytes: 62652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value,vector<ll> a)
{
	
	for (ll i = 0; i < a.size();i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
	int n, t;
	cin >> n >> t;
	vector<int> a;
	rep(i, n) {
		int c, x; cin >> c >> x;
		if (x <= t) {
			a.push_back(c);
		}
	}
	int ans = 1001;
	rep(i, a.size()) {
		ans = min(ans, a[i]);
	}
	if (ans == 1001)cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}

void solve() {
	int r;
	cin >> r;
	cout << (3 * r * r);	
}	

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
            
    if(n<=111) {
    	System.out.println("111");
    }else if(n<=222) {
    	System.out.println("222");
    }else if(n<=333) {
    	System.out.println("333");
    }else if(n<=444) {
    	System.out.println("444");
    }else if(n<=555) {
    	System.out.println("555");
    }else if(n<=666) {
    	System.out.println("666");
    }else if(n<=777) {
    	System.out.println("777");
    }else if(n<=888) {
    	System.out.println("888");
    }else {
    	System.out.println("999");
    }
    }
}

Measured memory_bytes: 35832
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define rrep(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
    #define vec(n) vector<int>(n)
    #define vvec(m,n) vector<vector<int>> vec(m,vector(n))

  
    int main(){
      int n,c,k;
      cin >> n >> c >> k;
      auto t = vec(n);
      rep(i,n)cin >> t[i];

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

      int cnt = 0;
      int i = 0;
      while(i<n){
        int st = t[i];
        int j = 1;
        for(;j < c && i+j < n && t[i+j] <= st+k;j++);
        cnt++;
        i += j;

        //cout << cnt <<endl;
        
      }

      cout << cnt <<endl;
    }


Measured memory_bytes: 640
import heapq
from collections import defaultdict
v_num = int(input())
edges = defaultdict(list)
for i in range(v_num):
    data = [int(n) for n in input().split(" ")[1:]]
    for j in range(i + 1, v_num):
        if data[j] != -1:
            edges[i].append([data[j], j])
            edges[j].append([data[j], i])
queue = []
heapq.heapify(queue)
for c in edges[0]:
    heapq.heappush(queue, c)
visited = {0}
answer = 0
while len(visited) < v_num:
    q = heapq.heappop(queue)
    weight, one = q[0], q[1]
    if one in visited:
        continue
    answer += weight
    for e in edges[one]:
        if e[1] not in visited:
            heapq.heappush(queue, e)
    visited |= {one}
print(answer)

Measured memory_bytes: 8812
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main() {
	int n;
	cin>>n;
	int ans=1,i=0;
	while(ans<=n){
		ans=pow(2,i);
		i++;
	}
	cout<<ans/2;
}



Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

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

vector <pair<ll, ll>> prime_factorize(ll n) {
    vector <pair<ll, ll>> res;
    for(ll i=2;i*i<n;++i) {
        if(n%i!=0) continue;
        ll num=0;
        while(n%i==0) {
            ++num;
            n/=i;
        }
        res.push_back(make_pair(i,num));
    }
    if(n!=1) res.push_back(make_pair(n,1));
    return res;
}

int main() {
    ll a,b;
    cin >> a >> b;
    ll x=gcd(a,b);
    auto pf=prime_factorize(x);
    cout << pf.size()+1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>//万能头文件
using namespace std;
int main()
{
    long long x,a,b,c,ans=0;//long long保险
    cin>>a>>b>>c>>x;//输入这四个数
    for(int i=0;i<=a;i++)//枚举500硬币的个数
        for(int j=0;j<=b;j++)//枚举100硬币的个数
            for(int z=0;z<=c;z++){//枚举50硬币的个数
                int k=i*500+j*100+z*50;//定义k为此时硬币总值
                if(k==x)//如果就是x
                   ans++;//计数器加一
                if(k>x)//这是一个优化，如果k值已经超过了x，后面的z到c时k的值一定大于x，肯定不等于x，所以可以直接退出当前循环
                   break;//退出当前循环
            }
    cout<<ans<<endl;//输出ans的值(AT题都要打换行)
    return 0;
}

Measured memory_bytes: 256