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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;

Graph G;

vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

int main()
{
    ll n;
    cin >> n;
    vector<int> a(n);
    map<int, int> ans;
    rep(i, n) cin >> a[i], --a[i], ans.insert(make_pair(i, a[i]));

    ll cnt = 0;
    rep(i, n)
    {
        int like_a = ans[i];
        int like_b = ans[like_a];
        if (like_b == i)
        {
            cnt++;
        }
    }
    cout << cnt / 2 << endl;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
	int sx,sy,tx,ty;
	while(sf("%d %d %d %d",&sx,&sy,&tx,&ty)==4)
	{
		int r=tx-sx;
		int u=ty-sy;
		for(int i=0;i<u;i++)pf("U");
		for(int i=0;i<r;i++)pf("R");
		for(int i=0;i<u;i++)pf("D");
		for(int i=0;i<r;i++)pf("L");

		u++,r++;

		pf("L");
		for(int i=0;i<u;i++)pf("U");
		for(int i=0;i<r;i++)pf("R");
		pf("D");

		pf("R");
		for(int i=0;i<u;i++)pf("D");
		for(int i=0;i<r;i++)pf("L");
		pf("U");
		nl;
	}
    return 0;
}
 









 




























Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n = input()
    cnt = 1
    num = n[0]
    for i in range(1,4):
        if n[i]==num:
            cnt += 1
        else:
            num = n[i]
            cnt = 1
        if cnt>=3:
            print('Yes')
            return
    print('No')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 39788
import sys
n = int(sys.stdin.readline())
lia = list(map(int, sys.stdin.readline().split()))
lib = list(map(int, sys.stdin.readline().split()))
lic = list(map(int, sys.stdin.readline().split()))
s = sum(lib)
li = []
i = 0
while i < n-1:
  if lia[i+1] - lia[i] == 1:
    li.append(lia[i]-1)
  i += 1
for i in li:
  s += lic[i]
print(s)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>

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

using namespace std;

int main(){
    int N;
    string prev;
    string now;
    vector<string> ss;
    bool flag = true;
    cin >> N;
    rep(i, N){
        cin >> now;
        if(i != 0 && now[0] != prev[prev.size() - 1]){
            flag = false;
        }
        for(int j = 0; j < ss.size(); j++){
            if(ss[j] == now){
                flag = false;
            }
        }
        if(flag) {
            ss.push_back(now);
            prev = now;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  if (n%2 == 1) {
    printf("0\n");
    return 0;
  }
  long answer = 0;
  long base = 2;
  long plus;
  while (1) {
    base *= 5;
    plus = n/base;
    if (plus == 0) {
      break;
    }
    answer += plus;
  }
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }
template<typename T = i64>
void OUT(T& x) { cout << (x) << endl; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

#ifdef _DEBUG
signed Main()
#else
signed main()
#endif
{
	auto N = IN();
	auto S = IN<string>();

	int ans = 0;
	FOR(i, 1, N - 1)
	{
		map<string, int> before;
		map<string, int> after;
		REP(j, N)
		{
			string str = S.substr(j, 1);
			if (j < i)
				before[str]++;
			else
				after[str]++;
		}

		int count = 0;
		if (SIZE(before) < SIZE(after))
		{
			for (map<string, int>::iterator it = before.begin(), end = before.end(); it != end; ++it)
			{
				if (after.count((*it).first))
					count++;
			}
		}
		else
		{
			for (map<string, int>::iterator it = after.begin(), end = after.end(); it != end; ++it)
			{
				if (before.count((*it).first))
					count++;
			}
		}

		if (ans < count)
			ans = count;
	}

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


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

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

    map<ll, ll> mp;
    ll ans = 0;    
    for (ll i = 0; i < n; i++) {
        ans++;
        ll tmp_a; cin >> tmp_a;
        mp[tmp_a]++;

        if (tmp_a == mp[tmp_a]) {
            ans -= tmp_a;
        }        
    }

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

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  
  ll N,M;
  cin>>N>>M;
  vector<ll>L(M);
  vector<ll>R(M);
  
  ll min=100000;
  ll max=0;
  
  for(ll i=0;i<M;i++){
    cin>>L[i]>>R[i];
    if(L[i]>=max){
      max=L[i];
    }
    
    if(R[i]<=min){
      min=R[i];
  }
  }

  if(min-max+1>=0){
  cout<<min-max+1<<endl;
  }
  
  else{
    cout<<0<<endl;
  }
  
}

      
                
        


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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    cout  << A-min(A,K) << " " << B-min(B,max(K-A,(ll)0)) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int64_t K;
    int N;
    cin >> N >> K;
    vector<pair<int64_t, int64_t>> ab(N);
    rep(i, N) cin >> ab[i].first >> ab[i].second;

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

    int64_t sum = 0;

    rep(i, N)
    {
        sum += ab[i].second;
        if (sum >= K)
        {
            cout << ab[i].first << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

int main()
{
	// 入力

	int n;
	cin >> n;
	int sn = 1 << n;
	vector<int> model(sn);
	REP(i, sn) cin >> model[i];

	//

	// 処理

	sort(model.begin(), model.end());
	vector<int> slime;
	slime.push_back(model.back());
	model.back() = -1;
	REP(i, n)
	{
		vector<int> s = slime;
		sort(s.begin(), s.end());
		int k = sn - 1;
		while (s.size() > 0 && k >= 0) 
		{
			if (model[k] == -1)
			{
				k--;
				continue;
			}
			if (model[k] < s.back())
			{
				slime.push_back(model[k]);
				s.pop_back();
				model[k] = -1;
			}
			k--;
		}
		if (s.size() > 0)
		{
			cout << "No";
			return 0;
		}
	}

	//

	// 出力

	cout << "Yes";

	//

	return 0;
}


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

int main() {
  int N,i,j,x;
  x=0;
  j=0;
  int a[200];
  cin >> N;

  // ここにプログラムを追記
   for(i=0;i<N;i++){
      cin>>a[i];
    }
    
    while(x==0){
    for(i=0;i<N;i++){
      if(a[i]%2!=0){
          x=1;
      }
      else{
          a[i]=a[i]/2;
      }
    }
    j++;
    }
    
    cout<<j-1<<endl;
   
  
}


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

int main() {
  int n; cin>>n;
  n/=2;
  int  m=100000;
  vector<pii> even(m);
  rep(i,m){
    even[i].first= 0;
    even[i].second= i;    
  }
  vector<pii> odd(m);
  odd=even;
  rep(i,n){
    int a,b; cin>>a>>b;
    even[a-1].first ++;
    odd[b-1].first ++;
  }

  sort(even.begin(),even.end());
  sort(odd.begin(),odd.end());
  if(even[m-1].second!=odd[m-1].second){
    cout<<2*n-even[m-1].first-odd[m-1].first;
  }
  else{
    cout<<2*n-max(even[m-1].first+odd[m-2].first, even[m-2].first+odd[m-1].first);
  }
}
      

Measured memory_bytes: 4824
D = int(input())
C = list(map(int, input().split()))
S = []
con= 0
for _ in range(D):
    S.append(list(map(int, input().split())))
t = [-1]*D
best = [0]*D
last = [0]*26

for i in range(D-30):#1日ごと
    
    score = [-1]*26
    
    for x in range(26):#どの問題を選ぶか
        if i==0:
            con = 0
        else:
            con = best[i-1]
        
        con += S[i][x]
        #last[x] = i+1
        for j in range(26): #減少量の計算 #問題ごと
            if not j==x:
                con -= C[j]*(i-last[j]+1)

        score[x]=con
    m = -100000
    ii = 0
    for k in range(26):
        if m<score[k]:
            m=score[k]
            ii=k
    
    last[ii]=i+1
    best[i]=score[ii]
    t[i]=ii+1

for g in reversed(range(1, 16)):

    p2 = [0]*(26**2)
    for i in range(26):
        for j in range(26):
            #print(i*26+j)
            p2[i*26+j]+=S[D-2*g][i]
            p2[i*26+j]+=S[D-2*g+1][j]
            for k in range(26):
                if not k==i:
                    p2[i*26+j] -= C[k]*(25-last[k])
            for k in range(26):
                if not k==j:
                    if k==i:
                        p2[i*26+j] -= C[k]*2
    ma = 0
    ind = 0
    for h in range(26**2):
        if p2[h]>ma:
            ma=p2[h]
            ind = h
    t[D-2*g]= ind//26+1
    t[D-2*g+1]=ind%26+1
    last[t[D-2*g]-1]=D-2*g+1
    last[t[D-2*g+1]-1]=D-2*g+2      

    
for i in range(D):
    print(t[i])
#print(best)



Measured memory_bytes: 69156
#include <iostream>
#include <cstdio>
#include <queue>
#define N 1005
using namespace std;

int n, d, gc, cur, a[N][N], pos[N], nm[N];
queue<int> qu[2];
int main() {
	int i, j, x, y;
	cin >> n;
	for(i=1; i<=n; i++) {
		for(j=1; j<n; j++) scanf("%d", &a[i][j]);
		qu[0].push(i);
	}
	gc = n * (n-1) / 2;
	for(d=1; ; d++, cur = 1-cur) {
		while(!qu[cur].empty()) {
			x = qu[cur].front(); qu[cur].pop();
			y = a[x][++pos[x]];
			if(nm[y] == x) {
				gc--;
				qu[1-cur].push(x);
				qu[1-cur].push(y);
				nm[y] = nm[x] = 0;
			} else {
				nm[x] = y;
			}
		}
		if(gc==0) {cout << d; return 0;}
		if(qu[0].empty() && qu[1].empty()) {cout << -1; return 0;}
	}
}

Measured memory_bytes: 4224
//Palace

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    int n,t,a;cin>>n>>t>>a;
    int h[n];
    rep(i,0,n)cin>>h[i];
    int ans;
    double u = abs(a-(t-h[0]*0.006));
    rep(i,0,n){
        double c = abs(a-(t-h[i]*0.006));
        if(min(u,c)==c){
            ans=i+1;
            u=c;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;
const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;

int f[maxn][3];
int h[maxn][3];
int n;
int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%d%d%d", &h[i][0], &h[i][1], &h[i][2]);
	memset(f, 0, sizeof(f));
	f[0][0] = h[0][0];
	f[0][1] = h[0][1];
	f[0][2] = h[0][2];
	for(int i = 1; i < n; i++)
		{
			f[i][0] = h[i][0] + max(f[i-1][1], f[i-1][2]);
			f[i][1] = h[i][1] + max(f[i-1][0], f[i-1][2]);
			f[i][2] = h[i][2] + max(f[i-1][0], f[i-1][1]);
		}
	printf("%d\n", max(max(f[n-1][0], f[n-1][1]), f[n-1][2]));
	return 0;
}


Measured memory_bytes: 2560
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll aa=0,bb=0;
    sort(all(a));
    bool aaa=1;
    for(int i=n-1;i>=0;i--){
        if(aaa==1){
            aa+=a[i];
            aaa=0;
        }
        else{
            aaa=1;
            bb+=a[i];
        }
    }
    cout<<aa-bb<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N,K;
  cin >>N>>K;
  int h[N];
  int ans = 0;
  for(int i=0;i<N;i++)
    {
  cin >>h[i];
   if(K<=h[i]) ans++;
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
def sort_x(a):
    min = 100000
    min_num = 0
    n = len(a)
    A=[[0, 0] for i in range(n)]
    left_list = [1 for i in range(n)]

    for j in range(n):
        for i in range(n):
            if left_list[i]==1 and int(a[i][0]) < min:
                min = int(a[i][0])
                min_num = i
        left_list[min_num] = 0
        A[j] = a[min_num]
        min=100000
    return A

def sort_y(a):
    min = 100000
    min_num = 0
    n = len(a)
    A=[[0, 0] for i in range(n)]
    left_list = [1 for i in range(n)]

    for j in range(n):
        for i in range(n):
            if left_list[i]==1 and int(a[i][1]) < min:
                min = int(a[i][1])
                min_num = i
        left_list[min_num] = 0
        A[j] = a[min_num]
        min=100000
    return A

if __name__ == '__main__':
    n = int(input())
    a_ = [input().split() for i in range(n)]
    c_ = [input().split() for i in range(n)]
    a = [[0,0] for i in range(n)]
    c = [[0,0] for i in range(n)]
    c = sort_x(c_)
    a = sort_y(a_)
    
    frend_num = 0
    #print(a)
    #print(c)
    #min = 100000
    #min_index = 0
    filter_a = [1 for i in range(n)]
    for j in range(n):
        for i in reversed(range(n)):
            if filter_a[i]==1 and int(a[i][0])<int(c[j][0]) and int(a[i][1])<int(c[j][1]):
                        filter_a[i]=0
                        frend_num += 1
                        #print("{},{}".format(a,c))
                        #print("{}".format(filter_a))
                        #print("friend is detected")
                        break
    print(frend_num)


Measured memory_bytes: 3192
fun main(args: Array<String>) = abc156d()

fun abc156d() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toLong() }


    val nPow = modPow(2, n, MOD)

    var aM = Mint(1)
    for (i in 1..a) {
        aM *= Mint(n - i + 1) / i
    }

    var bM = Mint(1)
    for (i in 1..b) {
        bM *= Mint(n - i + 1) / i
    }

    var answer = Mint(nPow)
    answer -= 1
    answer -= aM
    answer -= bM

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private fun modPow(n: Long, p: Long, m: Long): Long {
    var x = n
    var y = p
    var result = 1L

    x %= m
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % m
        y = y shr 1
        x = (x * x) % m
    }

    return result
}

private class Mint(value: Long = 0L) {
    private val value = if (value < 0) (value % MOD) + MOD else value % MOD
    operator fun unaryPlus() = this
    operator fun unaryMinus() = Mint(MOD - this.value)
    operator fun inc() = this.plus(1)
    operator fun dec() = this.minus(1)
    operator fun plus(other: Long) = Mint(this.value + other)
    operator fun plus(other: Mint) = this.plus(other.value)
    operator fun minus(other: Long) = Mint(this.value - other)
    operator fun minus(other: Mint) = this.plus(-other)
    operator fun times(other: Long) = Mint(this.value * other)
    operator fun times(other: Mint) = this.times(other.value)
    operator fun div(other: Long) = this.times(modPow(other, MOD - 2, MOD))
    operator fun div(other: Mint) = this.div(other.value)
    override fun toString(): String = this.value.toString()
    override fun hashCode() = value.hashCode()
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as Mint
        return value == other.value
    }

    companion object Mod {
        private fun modPow(n: Long, p: Long, m: Long): Long {
            var x = n
            var y = p
            var result = 1L
            x %= m
            while (y > 0) {
                if (y % 2 == 1L) result = (result * x) % m
                y = y shr 1
                x = (x * x) % m
            }
            return result
        }
    }
}


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


int main() {
    int n;
    cin>>n;
    int num[n],nums[n];
    for (int i = 0; i < n; ++i) {
        cin>>num[i];
        nums[i]=num[i];
    }
    sort(nums,nums+n);
    int m1=nums[n/2],m2=nums[n/2-1];
    for (int j = 0; j < n; ++j) {
        if(num[j]>=m1)cout<<m2<<endl;
        else cout<<m1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 	int N;
  cin>>N;
  vector<tuple<string,int,int>>a;
  for(int i=1;i<=N;i++){
    string s;
    int d;
    cin>>s>>d;
    d=-d;
    a.push_back(tie(s,d,i));
  }
  sort(a.begin(),a.end());

  for(int i=0;i<N;i++){
   string p;
   int r;
   int g;
   tie(p,r,g)=a[i];
    cout<<g<<endl;
  }
	return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> tree(N), diff;
    rep(i, N) cin >> tree[i];

    int ans = 0;
    sort(tree.begin(), tree.end());
    reverse(tree.begin(), tree.end());

    rep(i, N - K + 1) {
        diff.push_back(tree[i] - tree[i + K - 1]);
    }

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

    cout << diff[0] << endl;
    return 0;
}

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

int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long s=max(a*c,a*d);
  long long t=max(b*c,b*d);
  cout<<max(s,t)<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long mincostrecursion(int A[],int i,int N)
{

  if(i==N-1)
  {
    return 0;
  }

  long long c ,r,l;
 r = l = INT_MAX;
 if(i+1<N)
 {
   r = abs(A[i]-A[i+1])+mincostrecursion(A,i+1,N);
 }
 if(i+2<N)
 {
  l = abs(A[i]-A[i+2])+mincostrecursion(A,i+2,N);
 }
 return min(r,l);
}

long long mincostdp(int A[],int N)
{
  long long *Dp = new long long[N];
  for(int i=N-1;i>=0;i--)
  {
    if(i==N-1)
    {
      Dp[i]=0;
    }
    else
    {
      if(i+2<N)
      {
            Dp[i] = min((abs(A[i]-A[i+1])+Dp[i+1]),(abs(A[i]-A[i+2])+Dp[i+2]));
      }else
      {
        Dp[i] = abs(A[i]-A[i+1])+Dp[i+1];
      }
    }
  }


  return Dp[0];
}


main()
{
  long long N;
  cin>>N;
  int *A = new int[N];
  for(int i=0;i<N;i++)
  {
    cin>>A[i];
  }

  cout<<mincostdp(A,N);
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, C, D, E, F =  MAP()
A *= 100
B *= 100
# 溶ける最大濃度
limit = E / (100+E)

# dp[i][j] := 水i、砂糖jの状態を実施可能か
dp = list2d(F+1, F+1, 0)
dp[0][0] = 1
for i in range(F+1):
    for j in range(F+1):
        # 枝刈り
        if i+j > F:
            break
        # 実施可能な状態なら、4つの行動を遷移させる
        if dp[i][j]:
            if i+A <= F:
                dp[i+A][j] = 1
            if i+B <= F:
                dp[i+B][j] = 1
            if j+C <= F:
                dp[i][j+C] = 1
            if j+D <= F:
                dp[i][j+D] = 1

ans1 = ans2 = mx = 0
for a in range(F+1):
    for b in range(F+1):
        if a+b > F:
            break
        if a == b == 0:
            continue
        if dp[a][b]:
            x = b / (a+b)
            # 濃度が濃すぎて溶け切らない
            if x > limit:
                continue
            # 最大濃度の更新
            if mx <= x:
                mx = x
                ans1 = a + b
                ans2 = b
print(ans1, ans2)


Measured memory_bytes: 107740
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int N = sc.nextInt();
		int[] a = new int[N];
		ArrayList<Integer> index = new ArrayList<>();
		ArrayList<Integer> value = new ArrayList<>();
		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			if(index.size()==0 || value.get(value.size()-1) < a[i]) {
				index.add(i);
				value.add(a[i]);
			}
		}
		index.add(N);
		value.add(Integer.MAX_VALUE);
		
		long[] sum = new long[index.size()+1];
		Arrays.sort(a);
		int p=0;
		for(int i=0; i<N; i++) {
			if(value.get(p)<=a[i]) {
				sum[p] += ((long)N-i)*(value.get(p)-(p>0 ? value.get(p-1) : 0));
				p++;
			}
			sum[p] += a[i]-(p>0 ? value.get(p-1) : 0);
		}
		
		long[] ans = new long[N];
		for(int i=0; i<index.size()-1; i++)
			ans[index.get(i)] = sum[i];
		for(int i=0; i<N; i++)
			pw.println(ans[i]);
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 63180
X,K,D=map(int, input().split())

if abs(X) // abs(D) > K:
    print(abs(X)-(K*D))
    exit()

K2= K - (abs(X) // D)


X= abs(X) - abs(((K-K2)*D))

if K2 % 2 == 1:
    X= abs(X) - D


print(abs(X))


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 21474836

int main(){
  int n,m,s,g;
  cin>>n>>m>>s>>g;
  s--;g--;
  vector<int> u(m),v(m),t(m),c(m);
  rep(i,m) cin>>u[i]>>v[i]>>t[i]>>c[i];
  rep(i,m) u[i]--,v[i]--;

  vector<vector<int>> st(200001), gt(200001), gc(200001);
  rep(i,m) st[t[i]].pb(i);

  vector<int> bs(n,-INF);
  bs[s] = 0;

  int ans = INF;
  rep(i,200001){
    int k = gt[i].size();
    rep(j,k){//dbg(i),dbg(bs);
      int arr = gt[i][j];
      int cost = gc[i][j];
      bs[arr] = max(bs[arr], cost);
      if(arr == g){
        ans = min(ans, i-bs[arr]);
      }
    }
    for(auto id : st[i]){//dbg(i),dbg(bs);
      gt[i+c[id]].pb(v[id]);
      gc[i+c[id]].pb(bs[u[id]] + c[id]);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 31776
#include <stdio.h>

int main(){

int i, n, x;

int max = -1000001, min = 1000001;

long sum;

sum = 0;

scanf("%d", &n);

for(i = 0; i < n; i++){

   scanf("%d", &x);
   if(x > 1000000 || x < -1000000 || n > 10001){break;}
   if(x > max){
   max = x;}
   if(x < min){
   min = x;}
   sum += x;

}

printf("%d %d %ld\n", min, max, sum);

return 0;

}

Measured memory_bytes: 1776
import statistics
n=int(input())
a=list()
b=list()
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)

if n%2==0:
    print(int(statistics.median(b)*2-statistics.median(a)*2+1))
else:
    print(int(statistics.median(b)-statistics.median(a)+1))

Measured memory_bytes: 28944
(let ((n (read))
    (s '())
    (a (make-array 3 :initial-element 0 :element-type 'fixnum))
    (ans 0))
    (setq s (loop for _ below n collect (read-char)))
    (loop for i below 1000 do
        (progn
            (setf (aref a 2) (floor (/ i 100)))
            (setf (aref a 1) (rem (floor (/ i 10)) 10))
            (setf (aref a 0) (rem i 10))
            (let ((f 0))
                (loop for j in s do
                    (progn
                        (if (= (char-code j) (+ (aref a f) 48)) (incf f))
                        (if (= f 3) (return))
                    )
                )
            (if (= f 3) (incf ans))
            )
        )
    )

    (format t "~D~%" ans)
)

Measured memory_bytes: 24984
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
 
class Point {
public:
    int x, y;
    Point(int a = 0, int b = 0)
    {
        int x = a;
        int y = b;
    };
    bool operator <(const Point& p) const {
        return y < p.y || (y == p.y && x < p.x);
    }
};
 
inline bool direct(Point& base, Point& a, Point& b) {
    return (a.x - base.x)*(b.y - base.y) - (a.y - base.y)*(b.x - base.x) < 0;
}
 
 
int main() {
    int n, i;
    int k = 2;
    scanf("%d", &n);
    vector <Point> P(n), H(2 * n);
    for (i = 0; i < n; ++i) {
        scanf("%d%d",&P[i].x, &P[i].y);
    }
    sort(P.begin(), P.end());
    H[0] = P[0];
    H[1] = P[1];
    for (i = 0; i < n - 2; ++i) {
        while (k >= 2 && direct(H[k - 2],H[k - 1],P[i + 2])) k--;
        H[k++] = P[i + 2];
    }
    H[k++] = P[n - 2];
    for (i = n; i > 2; i--) {
        while (k >= 2 && direct(H[k - 2],H[k - 1],P[i - 3])) k--;
        H[k++] = P[i - 3];
    }
    printf("%d\n", k - 1);
    for (i = 0; i < k - 1; ++i) {
        printf("%d %d\n", H[i].x, H[i].y);
    }
    return 0;
}


Measured memory_bytes: 4724
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int ans = 1000000;
string sans;

char ask(string xs){
    ll x = 0;
    REP(i,xs.length()) x = 10 * x + (xs[i] - '0');
    if ((ans <= x && sans <= xs) || (ans > x && sans > xs)) return 'Y';
    return 'N';
}

int main() {
    int p = ans;
    while (p){
        char c = (p % 10) + '0';
        sans = c + sans;
        p /= 10;
    }

    string s(11,'0');
    REP(i,10){
        int l = 0, r = 10;
        if (i == 0) l = 1;
        while (r - l > 1){
            int m = (l + r) / 2;
            s[i] = m + '0';
            cout << "? " << s << endl;
            char c;
            cin >> c;
            // c = ask(s);
            if (c == 'Y') r = m;
            else l = m;
        }
        s[i] = l + '0';

        string t = s.substr(0,i+1);
        while (t.length() < 10) t += '9';
        cout << "? " << t << endl;
        char c;
        cin >> c;
        // c = ask(t);
        if (c == 'Y') continue;
        string nine(i, '9');
        nine += '8';
        if (s.substr(0,i+1) == nine){
            FOR(j,i+1,10){
                string u = '1' + string(j,'0');
                cout << "? " << u << endl;
                // c = ask(u);
                cin >> c;
                if (c == 'N'){
                    string ans(i+1, '9');
                    while (ans.length() < j) ans += '0';
                    cout << "! " << ans << endl;
                    return 0;
                }
            }
        }
        FOR(j,i+1,10){
            string u(j, '9');
            cout << "? " << u << endl;
            // c = ask(u);
            cin >> c;
            if (c == 'Y'){
                s = s.substr(0,i+1);
                s[i]++;
                while (s.length() < j) s += '0';
                cout << "! " << s << endl;
                return 0;
            }
        }
    }

    FOR(j,1,10){
        string u(j, '9');
        cout << "? " << u << endl;
        // char c = ask(u);
        char c;
        cin >> c;
        if (c == 'Y'){
            string ans = "1";
            while (ans.length() < j) ans += '0';
            cout << "! " << ans << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

const ll INF=1000000007;

ll pmod(ll x,ll y) {
    ll res=1;
    rep(i,y) res=res*x%INF;
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = pmod(10,n)-pmod(9,n)-pmod(9,n)+pmod(8,n);
    ans%=INF;
    ans=(ans+INF)%INF;
    cout << ans << endl;
}   

Measured memory_bytes: 3552
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int n,max_num = -1000001,min_num = 1000001,tmp;
	long long int sum = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		sum += tmp;
		max_num = max(max_num,tmp);
		min_num = min(min_num,tmp);
	}
	printf("%d %d %lld\n",min_num,max_num,sum);
}


Measured memory_bytes: 2752
/******
author :- Mahmoud Tarek.
*******/

#include<bits/stdc++.h>

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

int n, w ;
vector<pair<int, int>> a ;
ll mem[101][100001] ;

ll solve(int i, int w){
if(i == n) return 0 ;
ll & ret = mem[i][w] ;
if(~ret) return ret ;
ret = 0 ;
if(w - a[i].first >= 0) ret = a[i].second + solve(i + 1, w - a[i].first) ;
ret = max(ret, solve(i + 1, w)) ;
return ret ;
}

int main() {
//    freopen("in.txt", "r", stdin) ;
      cin >> n >> w ;
      a.resize(n) ;
      for(int i = 0 ; i < n ; i++){
        cin >> a[i].first >> a[i].second ;
      }
      memset(mem, -1, sizeof mem) ;
      cout << solve(0, w) ;
}

/*
  Empty set of troubles.
*/


Measured memory_bytes: 79104
N, = map(int, input().split())
A = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
for a in A:
    d[a] += 1
r = 0
for a in d:
    if a > d[a]:
        r += d[a]
    else:
        r += d[a]-a
print(r)


Measured memory_bytes: 66344
#include<stdio.h>
int main()
{
    char S[3];
    gets(S);
    int i,k=1;
    for(i=0;i<2;i++){
        if(S[i]!=S[i+1]){
            k=0;
            break;
        }
    }
    if(k==0)
        printf("Yes");
    else
        printf("No");
    return 0;

}


Measured memory_bytes: 128
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($N,$K) =  explode(" ",trim(fgets(STDIN)));
//$a =  explode(" ",trim(fgets(STDIN)));

$len = strlen($N);

for($i=1;$i<$len;$i++) {
  if ($N[$i-1]==$N[$i]) {
    printf("Bad\n");
    exit;
  }
}
printf("Good\n");


Measured memory_bytes: 4604
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define F first
#define S second
#define pb push_back
#define bit __builtin_popcount
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mkp make_pair
#define ffs fflush(stdout)

using namespace std;
using namespace __gnu_pbds;

//order_of_key(k) : Number of items strictly smaller than k
//find_by_order(k) : K-th element in a set (counting from 0)

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

typedef long long ll;
typedef long double ld;
typedef vector <int> lnum;
typedef pair <int, int> pii;

const int N = (int)1e3 + 5;
const int MOD = (int)1e9 + 7;
const int inf = (int)1e18;
const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const ld eps = 1e9 - 7;
const int pp[] = {29, 31, 53, 67, 71};
const double pi = acos(-1.0);

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

char a[N][N];
int b[N][N];

signed main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j)
      cin >> a[i][j];
  }
  int cur = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == '#') {
        int p = i + 1;
        b[i][j] = cur;
        for (int h = p; h <= n; ++h) {
          if (a[h][j] == '#' || b[h][j])
            break;
          b[h][j] = cur;
        }
        p = i - 1;
        for (int h = p; h >= 1; h--) {
          if (a[h][j] == '#' || b[h][j])
            break;
          b[h][j] = cur;
        }
        ++cur;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (!b[i][j] && b[i][j - 1])
        b[i][j] = b[i][j - 1];
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (!b[i][j] && b[i][j + 1])
        b[i][j] = b[i][j + 1];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (!b[i][j] && b[i - 1][j])
        b[i][j] = b[i - 1][j];
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      if (!b[i][j] && b[i + 1][j])
        b[i][j] = b[i + 1][j];
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j)
      cout << b[i][j] << " ";
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 6528
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
 
void RI() {}
 
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
 
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }
 
template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}
 
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
 
template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
 
template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}
 
const int MAX_N = 2005;
int n, a[MAX_N];
unordered_map<int,int> M;
void input() {
    RI(n);
    REP(i, n) RI(a[i]);
}
 
void solve() {
	sort(a, a+n);
 
	LL ans=0;
	REP(i, n) {
		REP1(j, i+1, n-1) {
			int k = lower_bound(a+j+1, a+n, a[i]+a[j]) - a;
			// cout << i << ' ' << j << ' ' << k << endl;
			ans = ans+k-1-j;
		}
	}
	printf("%lld\n", ans);
}
 
int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int H = scan.nextInt();
    int W = scan.nextInt();
    while(H != 0 || W != 0){
	StringBuilder sb2 = new StringBuilder();
        for(int i=0;i<W; i++){
          sb2.append("#");}
      System.out.println(sb2);
      StringBuilder sb = new StringBuilder();
      for(int i=0; i<W-2; i++ ){
        sb.append(".");
      }
      for(int j=0; j<H-2; j++){
        System.out.println("#" + sb + "#");
      }
      System.out.println(sb2);
      System.out.println("");
      H = scan.nextInt();
      W = scan.nextInt();
    }
 
  }
}

Measured memory_bytes: 28012
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    string s; cin >> s;
    ll dp1[s.size()] , dp2[s.size()];
    dp1[0] = 0 , dp2[0] = 1;
    for(int i = 1 ; i <= s.size() ; i++){
        if(s[i-1] == '0'){
            dp1[i] = 3*dp1[i-1];
            dp2[i] = dp2[i-1];
        }
        else{
            dp1[i] = 3*dp1[i-1] + dp2[i-1];
            dp2[i] = 2*dp2[i-1];
        }
        if(dp1[i] >= Mod)   
            dp1[i] %= Mod;
        if(dp2[i] >= Mod)
            dp2[i] %= Mod;
    }
    cout << (dp1[s.size()]+ dp2[s.size()])%Mod << endl;
    return 0;
}

Measured memory_bytes: 2000
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
  unsigned short *A, *B;

  int C[VMAX + 1];
  int n, i, j;
  scanf("%d", &n);

  A = (unsigned short *)malloc(sizeof(short) * n + 1);
  B = (unsigned short *)malloc(sizeof(short) * n + 1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ) {
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 10464
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B;
  cin >> A >> B;

  int ret = 0;
  if(A > B){
    ret += A;
    A--;
  }else{
    ret += B;
    B--;
  }
  if(A > B){
    ret += A;
    A--;
  }else{
    ret += B;
    B--;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#define rep(i, b, e) for (auto i = b; i < e; ++i)
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#ifndef __GNUC__
#include <intrin.h>
#endif // !__GNUC__
#include <random>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstring>
#include <complex>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <functional>

int bsf(int x) {
#ifdef __GNUC__
    return __builtin_ctz(x);
#else
    unsigned long i;
    _BitScanForward(&i, x);
    return i;
#endif
}
int bsr(int x) {
#ifdef __GNUC__
    return 31 - __builtin_clz(x);
#else
    unsigned long i;
    _BitScanReverse(&i, x);
    return i;
#endif
}

using namespace std;
typedef long long int64;
const double pi = 3.14159265358979323846;
const int inf = (int)2e+9 + 2;
const int mod = (int)1e+9 + 7;
const double eps = 1e-8;
const int N = 100000;

int n, m, k;

void solve()
{
    string s;
    cin >> s;
    s.erase(s.end() - 8, s.end());
    cout << s;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int test = 1;
    //cin >> test;
    for (; test; --test)
        solve();
    return 0;
}

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

using namespace std;

map<int,int> mp;
int main() {
    
    mp[1] = 31;
    mp[2] = 28;
    mp[3] = 29;
    mp[4] = 30;
    mp[5] = 31;
    mp[6] = 30;
    mp[7] = 31;
    mp[8] = 30;
    mp[9] = 30;
    mp[10] = 31;
    mp[11] = 30;
    mp[12] = 31;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(mp[a] == b) puts("1");
    else puts("0");
    return 0;
}


Measured memory_bytes: 256