akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> H(n);
    vector<int> A(n,0);
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> H[i];
    }
    // for (int i = 0; i < n; i++) {
    //     cout << H[i] << endl;
    // }
    int a,b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        // cout << a << ":" << H[a-1] << endl;
        // cout << b << ":" << H[b-1] << endl;
        // cout << endl;
        if(H[a-1] < H[b-1]) A[a-1]++;
        else if (H[a-1] == H[b-1]) {
            A[a-1]++;
            A[b-1]++;
        }
        else A[b-1]++;
    }
    // for (int i = 0; i < n; i++) {
    //     cout << A[i] << endl;
    // }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (A[i] == 0) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3632
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;
	String S,T;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		S = next();
		T = next();
		out.print(T);
		out.println(S);

	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

	long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	}
}

Measured memory_bytes: 21716
n,k=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]

l=[]
l1=[]
for i in range(n):
    p=0
    for j in a:
        if j>a[i]:
            p+=1
    l.append(p)

for i in range(n):
    p=0
    for j in range(i):
        if a[j]>a[i]:
            p+=1
    l1.append(p)

ans=0
mod=10**9+7
for i in range(n):
    ans+=k*(2*l1[i]+(k-1)*(l[i]))//2
    ans=ans%mod
print(ans)






Measured memory_bytes: 3188
#include<stdio.h>
 
int main(){
	int a[3], b, i, j, e = 0, f = 0, g = 0, h = 0;
	while(scanf("%d %d %d", &a[0], &a[1], &a[2]) != EOF){
		for(i = 0; i < 2; i++){
			for(j = i + 1; j < 3; j++){
				if(a[i] < a[j]){
					b = a[i];
					a[i] = a[j];
					a[j] = b;
				}
			}
		}
		if(a[0] >= a[1] + a[2]) break;
		else e++;
		if(a[0] * a[0] > a[1] * a[1] + a[2] * a[2]) f++;
		else if(a[0] * a[0] == a[1] * a[1] + a[2] * a[2]) g++;
		else h++;
	}
	printf("%d %d %d %d\n", e, g, h, f);
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3


def main():
    n = int(input())
    sp_list = [input().split() + [i + 1] for i in range(n)]
    sp_list = [[s, int(p), i] for s, p, i in sp_list]
    sp_list.sort(key=lambda x: (x[0], -x[1]))
    for i in range(n):
        print(sp_list[i][2])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys
n,k = map(int,input().split())
c = (n-1)*(n-2) // 2
if c < k:print(-1);sys.exit()
count = 2
print(n-1 + c - k)
for i in range(n-1):
    print(1,count)
    count += 1
count = 0
if c == k:sys.exit()
for i in range(2,n+1):
    oo = False
    for j in range(i + 1,n + 1):
        count += 1
        print(i,j)
        if count >= c - k:oo = True;break
    if oo:break

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

public class Program
{
	public static void Main()
	{
		Console.ReadLine();
		if(0==Console.ReadLine().Split().Select(int.Parse).Where(x=>x%2==0).Where(x=>(!(x%3==0))&&(!(x%5==0))).Count()){
			Console.WriteLine("APPROVED");return;
		}
		Console.WriteLine("DENIED");
	}
}

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

using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    if(S.length() + 1 == T.length() && S == T.substr(0,S.length())){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a == b ? c : a == c ? b : a) << endl;
}

Measured memory_bytes: 3144
#include <stdio.h>
#include <iostream>

using namespace std;

long long int n,h;

long long int tai[100001];
long long int kai[100000];

#define DEEP 19

long long int seg[(1 << DEEP)];

int nextk[100000];

int st[100000];

long long int segmax(int beg,int end)
{
	if(end < beg)
	{
		return -1;
	}
	int nowb1 = beg + (1 << (DEEP - 1)) - 1;
	int nowb2 = end + (1 << (DEEP - 1)) - 1;
	long long int maxw = max(seg[nowb1],seg[nowb2]);
	for(int i = 0; i < DEEP; i++)
	{
		int nowb1n = (nowb1 - 1) / 2;
		int nowb2n = (nowb2 - 1) / 2;
		if(nowb1n == nowb2n)
		{
			return maxw;
		}
		if(nowb1 % 2 == 1)
		{
			maxw = max(maxw,seg[nowb1 + 1]);
		}
		if(nowb2 % 2 == 0)
		{
			maxw = max(maxw,seg[nowb2 - 1]);
		}
		nowb1 = nowb1n;
		nowb2 = nowb2n;
	}
	return maxw;
}

int main()
{
	scanf("%lld %lld",&n,&h);
	long long int nownt = 0;
	tai[0] = 0;
	for(int i = (1 << (DEEP - 1)) - 1; i < (1 << DEEP); i++)
	{
		seg[i] = -1;
	}
	for(int i = 1; i < n; i++)
	{
		long long int dw,hw;
		scanf("%lld %lld",&dw,&hw);
		nownt += dw;
		tai[i] = nownt;
		kai[i - 1] = hw;
		seg[(1 << (DEEP - 1)) - 1 + i - 1] = hw;
	}
	tai[n] = 10000000000000;
	kai[n - 1] = 100000000;
	int stn = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = stn - 1; j >= 0; j--)
		{
			if(kai[st[j]] <= kai[i])
			{
				nextk[st[j]] = i;
				stn--;
			}
			else
			{
				break;
			}
		}
		st[stn] = i;
		stn++;
	}
	for(int i = (1 << (DEEP - 1)) - 2; i >= 0; i--)
	{
		seg[i] = max(seg[i * 2 + 1],seg[i * 2 + 2]);
	}
	long long int all = 0;
	long long int nh = h;
	for(int i = 0; i < n - 1; i++)
	{
		long long int nt = tai[nextk[i]] - tai[i] + 1;
		long long int tari = nt - nh;
		if(tari <= 0)
		{
			i = nextk[i] - 1;
			nh -= (nt - 1);
			continue;
		}
		long long int kaikai = (tari - 1) / kai[i] + 1;
		long long int kaiw = kaikai * kai[i];
		if(kaiw + nh > h)
		{
			long long int na = h - nh;
			long long int cank = na / kai[i];
			long long int ak = h - (cank * kai[i] + nh);
			int now = i;
			int han = n - i;
			for(int j = 0; j < 20; j++)
			{
				if(tai[now + han] - tai[i] + 1 <= cank * kai[i] + nh)
				{
					now += han;
				}
				han = (han + 1) / 2;
			}
			long long int maxw = segmax(i + 1,now);
			if(maxw < ak)
			{
				all += cank + 1;
				nh = h - tai[i + 1] + tai[i];
			}
			else
			{
				all += cank;
				nh = nh + cank * kai[i] - tai[i + 1] + tai[i];
			}
		}
		else
		{
			i = nextk[i] - 1;
			nh = nh + kaiw - (nt - 1);
			all += kaikai;
		}
	}
	printf("%lld\n",all);
	return 0;
}

Measured memory_bytes: 7240
isPrev :: (Int,Int,Int)->(Int,Int,Int)->Bool
isPrev (y1,m1,d1) (y2,m2,d2)
    | y1<y2                     = True
    | y1==y2 && m1<m2           = True
    | y1==y2 && m1==m2 && d1<d2 = True
    | otherwise                 = False

era :: (Int,Int,Int)->String
era (y,m,d) 
    | isPrev (y,m,d) (1868, 9, 8) = "pre-meiji"
    | isPrev (y,m,d) (1912, 7,30) = "meiji " ++(show (y-1868+1))++" "++(show m)++" "++(show d)
    | isPrev (y,m,d) (1926,12,25) = "taisho "++(show (y-1912+1))++" "++(show m)++" "++(show d)
    | isPrev (y,m,d) (1989, 1, 8) = "showa " ++(show (y-1926+1))++" "++(show m)++" "++(show d)
    | otherwise                   = "heisei "++(show (y-1989+1))++" "++(show m)++" "++(show d)

solve str = do
    let y = read ((words str)!!0) :: Int
    let m = read ((words str)!!1) :: Int
    let d = read ((words str)!!2) :: Int
    putStrLn (era (y,m,d))

main = do
    str <- getContents
    mapM_ solve $ lines str

Measured memory_bytes: 3896
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll h, n, w;
  bool ok = false;
  for(ll i=1;i<=3500;++i) {
    for(ll j=1;j<=3500;++j) {
      if(4*i*j-N*i-N*j<=0) continue;
      if(i*j*N%(4*i*j-N*i-N*j)==0) {
        h = i;
        n = j;
        w = i*j*N/(4*i*j-N*i-N*j);
        ok = true;
        break;
      }
    }
    if(ok) break;
  }
  cout<<h<<" "<<n<<" "<<w<<endl;
}



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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> ma;
    rep(i, N) {
        cin >> A[i];
        ma[A[i]]++;
        ma[A[i] + 1]++;
        ma[A[i] - 1]++;
    }

    int ans = 0;
    for (auto m : ma) {
        ans = max(ans, m.second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;


int main() {
	//各々について伸ばしてるとだだっ広い空間で10^12ぐらいになって死ぬ
	//O(N^2)の前計算をすることで各マスに対してO(1)で答えを求められるようにしたい
	//縦に点灯できる数をランプのある場所を含めて求める
	//同様に横も求める，最後に２つを足すのだが，最後に重なってるランプのマスを除くため１を引くif
	//所属判定は尺取法が無難かなぁ。
	int H, W;
	cin >> H >> W;
	vector<string>S(H);
	for (size_t i = 0; i < H; i++)
	{
		cin >> S.at(i);
	}
	int leader, anchor,dist=0;//尺取法の先行者と後ろ
	vector<vector<int>>ans(H, vector<int>(W,1));
	for (size_t i = 0; i < H; i++)//横の捜査
	{
		leader = 0, anchor = 0;//両方閉区間にする。
		for (size_t j = 0; j < W; j++)
		{
			if (S.at(i).at(j) == '.')leader=j;
			if(S.at(i).at(j)=='#'||j==W-1) {
				dist = leader - anchor;
				for (size_t k = anchor; k <= min(leader,W-1); k++)
				{
					ans.at(i).at(k) += dist;
				}
				leader = j + 1, anchor = j + 1;
			}
			
		}
	}
	for (size_t i = 0; i < W; i++)//縦の捜査
	{
		leader = 0, anchor = 0;//両方閉区間にする。
		for (size_t j = 0; j < H; j++)
		{
			if (S.at(j).at(i) == '.')leader=j;
			if (S.at(j).at(i) == '#' || j == H - 1) {
				
				dist = leader - anchor;
				for (size_t k = anchor; k <= min(leader,H-1); k++)
				{
					ans.at(k).at(i) += dist;
				}

				leader = j + 1, anchor = j + 1;
			}

		}
	}
	int ass = 0;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t j = 0; j < W; j++)
		{
			if(S.at(i).at(j)=='.')ass = max(ass, ans.at(i).at(j));
		}
	}
	cout << ass;
}


Measured memory_bytes: 20096
def solve(depth, start, stop):
    global ans
    if depth == N:
        ans = max(ans, sum(d for a, b, c, d in queries if A[b - 1] - A[a - 1] == c))
    else:
        for n in range(start, stop):
            A[depth] = n
            solve(depth + 1, n, stop)

N, M, Q = map(int, input().split())
queries = tuple(tuple(map(int, input().split())) for _ in range(Q))
A = [0] * N
ans = 0
solve(0, 1, M + 1)
print(ans)


Measured memory_bytes: 9208
#include <iostream>
#include <iomanip>

const int MAX_N = 2999;

double f[MAX_N + 1];

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  int n;
  std::cin >> n;
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    double p;
    std::cin >> p;
    for (int j = i; j >= 1; --j) f[j] = f[j - 1] * p + f[j] * (1 - p);
    f[0] *= (1 - p);
  }
  double ret = 0;
  for (int i = n / 2 + 1; i <= n; ++i) ret += f[i];
  std::cout << std::fixed << std::setprecision(10) << ret;
}

Measured memory_bytes: 256
a,b,k=gets.split.map(&:to_i)
x=[]
s=a+k-1>b ? b : a+k-1
t=b-k+1<a ? 1 : b-k+1
if s>=t
  for i in a..b
    puts i
  end
else
  for i in a..s
    puts i
  end
  for i in t..b
    puts i
  end
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, int> p;
int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> B(N);
	for(int i=0;i<N;i++){
		cin >> A[i] >> B[i];
	}
	vector<p> point(N);
	for(int i=0;i<N;i++){
		point[i].first = A[i] + B[i];
		point[i].second = i;
	}
	sort(point.rbegin(),point.rend());
	ll sumA=0, sumB=0;
	for(int i=0;i<N;i++){
		if(i % 2) sumB += B[point[i].second];
		else sumA += A[point[i].second];
	}
	cout << sumA - sumB << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a > 0){
        cout << "Positive" << endl;
    }else if(a <= 0 && b >= 0){
        cout << "Zero" << endl;
    }else if(b < 0){
        int pos_count = b - a + 1;
        int is = pow(-1, pos_count);
        if(is == 1){
            cout << "Positive" << endl;
        }else if(is == -1){
            cout << "Negative" << endl;
        }else{
            cout << "Error" << endl;
        }
    }else{
        cout << "Error_2" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<int> lan[MAX_N];
int par[MAX_N];
int nrank[MAX_N];

void initial(int n){		//初期化
	for(int i=0;i<n;i++){
		par[i] = i;
		nrank[i] = 0;
	}
}

int find(int x){		//木の根を求める
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(nrank[x] < nrank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(nrank[x] == nrank[y])
			nrank[x]++;
	}
}

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

int main()
{
	int n,m,k,L;
	bool flag = true;
	cin >> n >> m;
	rep(i,n){
		cin >> k;
		rep(j,k){
			scanf("%d",&L);
			lan[L-1].push_back(i);
		}
	}
	initial(n);
	rep(i,m){
		if(!lan[i].empty()){
			rep(j,lan[i].size()-1){
				if(lan[i].size()>=2){
					unite(lan[i][j],lan[i][j+1]);
				}
			}
		}
	}
	rep(i,n-1){
		if(!same(i,i+1)){
			flag = false;
			break;
		}
	}
	if(flag){
		cout << "YES" << "\n";
	}else{
		cout << "NO" << "\n";
	}
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e5 + 5);

int n;
int a[MAX_N];

vector<vector<int>> store(MAX_N);
int cnt[MAX_N];
int b[MAX_N];

int ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

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

  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) {
      store[j].push_back(i);
    }
  }

  for (int i = n; i >= 1; --i) {
    if (cnt[i] % 2 != a[i]) {
      // printf("%d %d %d\n", i, cnt[i], a[i]);
      b[i] += 1;
      for (auto &e : store[i]) {
        cnt[e] += 1;
      }
    }
  }

  for (int i = 1; i <= n; ++i) {
    if (a[i] != cnt[i] % 2) {
      printf("%d\n", -1);
      return 0;
    }
  }

  // printf("a: ");
  // for (int i = 1; i <= n; ++i) {
  //   printf("%d ", a[i]);
  // }
  // printf("\n");

  // printf("c: ");
  // for (int i = 1; i <= n; ++i) {
  //   printf("%d ", cnt[i]);
  // }
  // printf("\n");

  for (int i = 1; i <= n; ++i) {
    ans += b[i];
  }

  printf("%d\n", ans);

  if (ans == 0) {
    return 0;
  }

  // printf("b: ");
  for (int i = 1; i <= n; ++i) {
    if (b[i] == 1) {
      printf("%d ", i);
    }
  }
  printf("\n");

  // printf("--------\n");

  return 0;
}


Measured memory_bytes: 24576
N = int(input())

a0 = N*(N+1)/2


b1 = N//3
a1 = (3*b1+3)*b1/2

b2 = N//5
a2 = (5*b2+5)*b2/2

b3 = N//15
a3 = (15*b3+15)*b3/2

ans = a0 - a1 - a2 + a3
print(int(ans))

Measured memory_bytes: 61740
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sousa=sum(b)-sum(a)
cnt=0
for i in range(n):
	if b[i]>a[i]:
		cnt+=(b[i]-a[i]+1)//2
if sousa>=cnt:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 4596
#include <iostream>
using namespace std;
int main()
{
  char X, Y;
  cin >> X >> Y;
  if (X < Y) {
    cout << "<" << endl;
  } else if (X > Y) {
    cout << ">" << endl;
  } else {
    cout << "=" << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define For(i, l, r) for (register int i = l, _r = r; i <= _r; ++i)
#define Ford(i, l, r) for (register int i = r, _l = l; i >= _l; --i)
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 20;

int q1,q2,n1,n2,n3;
ll a[maxn],b[maxn],c[maxn];
ll ans;

inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){if (ch == '-')f = -1;ch = getchar();}
	while (ch >= '0' && ch <= '9'){x = (x << 3) + (x << 1) + ch - '0';ch = getchar();}
	return x * f;
}

inline bool cmp(int x,int y)
{
	return x > y;
}

inline void readin()
{
	q1=read();
	q2=read();
	n1=read();
	n2=read();
	n3=read();
	For(i,1,n1) a[i]=read();
	For(i,1,n2) b[i]=read();
	For(i,1,n3) c[i]=read();
}

inline void run()
{
	int now1=1,now2=1,now3=1;
	sort(a+1,a+1+n1,cmp);
	sort(c+1,c+1+n3,cmp);
	For(i,1,q1)
	{
		if(now1<=n1&&now3<=n3)
		{
			if(a[now1]>=c[now3])
				ans+=a[now1++];
			else
				ans+=c[now3++];
		}
		else if(now1<=n1)
			ans+=a[now1++];
		else
			ans+=c[now3++];
	}
	For(i,2,now3)
	{
		if(now1>n1)
			break;
		b[++n2]=a[now1++];
	}
	sort(b+1,b+1+n2,cmp);
	For(i,1,q2)
	{
		if(now2<=n2&&now3<=n3)
		{
			if(b[now2]>=c[now3])
				ans+=b[now2++];
			else
				ans+=c[now3++];
		}
		else if(now2<=n2)
			ans+=b[now2++];
		else
			ans+=c[now3++];
	}
}

int main()
{
	readin();
	run();
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#define debug(a) {for (int i=1; i<=n; i++) cout << a[i] << ' '; cout << endl;}
using namespace std;
/*void inarr()
{
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i];
}*/
int main()
{
    //freopen("inp.txt","r",stdin);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a+b, min(a+c, b+c));
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();

		if(A * N < B ) {
			System.out.println(A * N);
		}else {
			System.out.println(B);
		}
	}
}

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

struct Card {
    char suit;
    int value;
    int inputTime;
};

void BubbleSort(Card A[], int n);
void SectionSort(Card A[], int n);
void printCard(Card A[], int n);
void checkStable(Card A[], int n);

int main(void)
{
    int n, i;
    cin >> n;
    Card *A = new Card[n];
    Card *B = new Card[n];
    for (i = 0; i < n; i++)
    {
        cin >> A[i].suit >> A[i].value;
        B[i].suit = A[i].suit;
        B[i].value = A[i].value;
        B[i].inputTime = A[i].inputTime = i;
    }
    
    BubbleSort(A, n);
    SectionSort(B, n);
    
    printCard(A, n);
    checkStable(A, n);
    printCard(B, n);
    checkStable(B, n);
}

void BubbleSort(Card A[], int n) 
{
    int i = 0, j = 0;
    bool flag = true;
    while (flag) 
    {
        flag = false;
        for (j = n - 1; j > i; j--)
        {
            if (A[j].value < A[j - 1].value)
            {
                swap(A[j], A[j - 1]);
                flag = true;
            }
        }
        i++;
    }
}

void SectionSort(Card A[], int n) 
{
    int i, j, min;
    for (i = 0; i < n - 1; i++)
    {
        min = i;
        for (j = i + 1; j < n; j++)
        {
            if (A[j].value < A[min].value)
            {
                min = j;
            }
        }
        swap(A[i], A[min]);
    }
}

void printCard(Card A[], int n) 
{
    int i;
    for (i = 0; i < n; i++)
    {
        if (i) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

void checkStable(Card A[], int n)
{
    int i;
    bool flag = true;
    for (i = 0; i < n - 1; i++)
    {
        if (A[i].value == A[i + 1].value && A[i].inputTime > A[i + 1].inputTime)
        {
            flag = false;
            break;
        }
    }
    if (flag) 
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    double n, x, t; cin >> n >> x >> t;
    cout << (int)(t * ceil(n / x));
    return 0;
}

Measured memory_bytes: 3736
"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
import bisect
import heapq
# from math import *
from collections import defaultdict as dd  # defaultdict(<datatype>) Free of KeyError.
from collections import deque  # deque(list) append(), appendleft(), pop(), popleft() - O(1)
from collections import Counter as c  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()


def out(var): sys.stdout.write(var)


def l(): return list(map(int, data().split()))


def sl(): return list(map(str, data().split()))


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]


n, p = sp()
s = data()
answer = 0
if p == 2:
    for i in range(n):
        if (ord(s[i])-ord('0')) % 2 == 0:
            answer += (i+1)
elif p == 5:
    for i in range(n):
        if int(s[i]) % 5 == 0:
            answer += (i+1)
else:
    dp = dd(int)
    dp[0] += 1
    a, tens = 0, 1
    for i in range(n-1, -1, -1):
        a = (a + int(s[i]) * tens) % p
        answer += dp[a]
        dp[a] += 1
        tens = (tens * 10) % p
out(str(answer))
exit(0)


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

int main() {
  int N;
  cin >> N;
  list<int> s(N);
  for (auto& x : s) cin >> x;
  s.sort();
  vector<int> acc(s.begin(), s.end());
  for (int i = 1; i < acc.size(); ++i) acc[i] += acc[i - 1];
  int sum = acc.back();
  if (sum % 10) {
    cout << sum << endl;
    return 0;
  }
  s.remove_if([](int x) { return x % 10 == 0; });
  if (s.size() >= 1) {
    cout << (sum - s.front()) << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

	int d;
	int step;
	int i;
	int area;

	while(scanf("%d",&d)!=EOF){
		area=0;
		step=600/d;
		for(i=0;i<step;i++)area=area+ d*(i*d)*(i*d);
		printf("%d\n",area);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};int dy[4] = {0,-1,0,1};
using Graph = vector<vector<int> >;

int main() {
    string s,t;cin >> s >> t;
    bool ok = true;
    for(int i=0;i<s.size();i++){
	if(s[i]!= t[i]) ok = false;
    }
    if(ok) cout <<"Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(ll i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    if(b - a < k*2){
        for(ll i=a;i<=b;i++){
            cout << i << endl;
        }
        return 0;
    }
    vector<ll> v;
    for(ll i=a;i<a+k;i++){
        v.pb(i);
    }
    for(ll i=b;i>b-k;i--){
        v.pb(i);
    }
    sort(v.begin(),v.end());
    rep(i,v.size()){
        cout << v[i] << endl;
    }
}

Measured memory_bytes: 256
program Restoran;
uses crt;
var
N,x,y:Integer;
function harga:integer;
begin
harga:=x-y;
end;
begin
clrscr;
readln(N);
x:=800*N;
y:=(N div 15)*200;
if (1<=N) and (N<=100) then
writeln(harga);
end.

Measured memory_bytes: 128
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define mp     make_pair
#define cont   continue
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 1e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

vector<ll>dp(MAXN,MINF);
ll a[MAXN],b[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
ll n,w,k,cnt,sum,ans,mx,mn=MINF;
bool y;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}


void solve(){
	cin>>n>>w;
	dp[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
        sum+=b[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=sum-b[i];j>=0;j--){
            dp[j+b[i]]=min(dp[j+b[i]],dp[j]+a[i]);
        }
    }
    for(int i=0;i<=sum;i++)if(dp[i]<=w)mx=max(mx,i*1ll);
    cout<<mx;
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




Measured memory_bytes: 3456
import sys                                                          
a,b,c,k = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
s = 0                                                               
if k > 0:                                                           
    s += min(k, a)                                                  
    k -= a                                                          
if k > 0:                                                           
    k -= b                                                          
if k > 0:                                                           
    s -= k                                                          
print(s)                                                            

Measured memory_bytes: 9120
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	lli n, T, ans;
	cin >> n >> T;
	ans = T;
	vector<lli> t(n);
	rep(i,n) cin >> t[i];
	rep(j,n-1){
		ans += Min(T, t[j+1] - t[j]);
	}
	cout << ans << endl;
	return 0;
}


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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int H, W;
    cin >> H >> W;

    vector<string> maze(H);
    rep(i,H) cin >> maze[i];

    int num = 0;
    rep(i, H){
        rep(j, W){
            if(maze[i][j] == '.') num++;
        }
    }

    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[0][0] = 1;
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));

    while(!que.empty()){
        pair<int, int> current_pos = que.front();
        que.pop();
        int x = current_pos.first;
        int y = current_pos.second;

        rep(i, 4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || H <= nx || ny < 0 || W <= ny) continue;
            if(maze[nx][ny] == '#') continue;
            if(dist[nx][ny] == -1){
                que.push(make_pair(nx, ny));
                dist[nx][ny] = dist[x][y] + 1;
            }
        }
    }
    if(dist[H-1][W-1] == -1) cout << -1 << endl;
    else cout << num - dist[H-1][W-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Test int T;cin>>T;while(T--)
#define ls lower_bound
#define up upper_bound
#define bs binary_search
#define S second
#define F first
#define vi vector<int>  
#define pii pair<int,int>
#define vpi vector<pii>
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define m_n(v) *min_element(all(v))
#define m_x(v) *max_element(all(v))
/* 
#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
*/
int power(int x, int y,int mod){
    int res = 1;
    while (y)
    {
        if (y & 1)
        res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res;
}
int modInverse(int a, int m){
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int binomial(int n,int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
/*vector<int> prime;
void sieve(){
    bool arr[300000]={0};
    prime.pb(2);
    for(int i=3;i<300000;i+=2){
        if(arr[i])continue;
        for(int j=i*i;j<300000;j+=i) arr[j]=1;
        prime.pb(i);
    }
}*/
const int mod=1e9+7;
const int y=1e6+2;
int32_t main() {
    IOS;
    int n;
    cin>>n;
    vi v(n);
    for(auto &i:v) cin>>i;
    map<int,int> mp;
    for(auto i:v) mp[i]++;
    bool vis[y]={0};
    for(auto i:mp)
    {
        for(int j=2*i.F;j<=y;j+=i.F)
        vis[j]=true;
    }
    int ans=0;
    for(auto i:mp)
    {
        if(i.S == 1 and vis[i.F] == false) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 18244
#include "bits/stdc++.h"

using namespace std;

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

  string S;
  int count;
  bool flag=true;


  cin>>S;
  
  if(S[0]=='A'){
      for(int i=2;i<S.size()-1;i++){
          if(S[i]=='C'){
              count++;
          }else if(S[i]>='A' && S[i]<='Z'){
              flag=false;
              break;
          }
      }
      if(S[1]>='A' && S[1]<='Z'){
          flag=false;
      }
      if(S[S.size()-1]>='A' && S[S.size()-1]<='Z'){
          flag=false;
      }
      if(count==1 && flag){
          cout<<"AC"<<endl;
      }else{
          cout<<"WA"<<endl;
      }
  }else{
      cout<<"WA"<<endl;
  }
  
  return 0;
}

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

int main(){
    using namespace std;
    size_t N, D;
    cin >> N >> D;
    vector<vector<long>> X(N, vector<long>(D));
    for(auto& i : X)for(auto& j : i)cin >> j;
    unsigned long ans{0};
    for(auto& i : X)for(auto& j : X){
        long a{0};
        for(unsigned long k = 0; k < D; ++k)a += (i[k] - j[k]) * (i[k] - j[k]);
        long l{0}, r{100000000};
        while(l + 1 < r){
            auto m = (l + r) / 2;
            (m * m > a ? r : l) = m;
        }
        if(l * l == a)++ans;
    }
    cout << (ans - N) / 2 << endl;
    return 0;
}

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

void changeMin(ll& a, ll b)
{
    if(a > b)a = b;
} 

int N;
long long h[110000];

// DP テーブル
long long dp[110000];
const long long INF = 1LL << 60;
int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            changeMin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
    system("pause");
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9



int main(){
  string S;
  cin >> S;
  ll ans = 0;
  int preB = 0;
  REP(i, S.size()){
    if(S[i] == 'B'){
      preB++;
    }
    else{
      ans += preB;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int a;
int b;
char s[101][101];

int main() {
	cin >> a >> b;
	for(int i = 1; i <= a; i++)
		for(int j = 1; j <= b; j++)
			cin >> s[i][j];
	for(int i = 1; i <= a; i++)
		for(int j = 1; j <= b; j++)
			if(s[i][j] == '#')
				if(s[i - 1][j] != '#' && s[i + 1][j] != '#' && s[i][j - 1] != '#' && s[i][j + 1] != '#')
					{ puts("No"); return 0;}
	puts("Yes");
	return 0;
}

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

// n進数 bit 列加算
void add(vector <int> &bits, int x){
    const int n = 2; 
    bits[bits.size()-1] += x;
    for(int i = bits.size() -1 ; i >= 0; i--){
        while(bits[i] >= n){
            bits[i] -= n;
            if(i != 0) bits[i-1] += 1;
        }
    }
}

void printBits(vector <int> &bits){
    for(int i = 0; i < bits.size(); i++){
        cout << bits[i];
    }
    cout << endl;
}

long long calc(vector <int> &bits, string s){

    long long sum = 0;
    int l = 0;
    for(int i = 0; i < bits.size(); i++){
        if(bits[i] == 1){
            string sub = s.substr(l, i+1-l);
            sum += stol(sub);
            l = i+1;
        }
    }

    string sub = s.substr(l);
    sum += stol(sub);

    //cout << sum << endl;
    return sum;
}

int main(){
    
    string s;
    cin >> s;

    if(s.length() == 1){
        cout << s << endl;
        return 0;
    }
    vector <int> bits(s.length() - 1);
    int bmax = 1;
    for(int i = 0; i < bits.size(); i++){
        bmax = bmax * 2;
    }

    long long sum = 0;
    for(int i = 0; i < bmax; i++){
        sum += calc(bits, s);
        //printBits(bits);
        add(bits, 1);
    }

    cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<arr[k-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,a[100005];
int calc(int x){
	if(x<=0) return 0;
	return (x-1)/(m-1)+1;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int ans=1e9;
	for(int i=1;i<=n;i++){
		if(a[i]==1){
			for(int p=max(i-m+1,1);p<=i;p++){
				int tot=1+calc(p-1)+calc(n-(p+m-1));
				ans=min(ans,tot);
			}
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		String lines = sc.nextLine();
		
		while (lines.equals("0 0") == false) {
			String[] xy = lines.split(" ");
			
			int[][] map = new int[Integer.parseInt(xy[0])][Integer.parseInt(xy[1])];

			for (int i = 0; i < map.length; i++) {
				String line = sc.nextLine();

				for (int j = 0; j < map[0].length; j++) {
					switch (line.charAt(j)) {
					case '>':
						map[i][j] = 1;
						break;
					case '<':
						map[i][j] = 2;
						break;
					case 'v':
						map[i][j] = 3;
						break;
					case '^':
						map[i][j] = 4;
						break;
					case '.':
						map[i][j] = 0;
						break;
					}
				}
			}
			
			int x = 0;
			int y = 0;
			
			boolean goal = false;
			while (goal == false) {
				int nx = x;
				int ny = y;
				
				switch (map[y][x]) {
				case 0:
					System.out.println(x + " " + y);
					goal = true;
					break;
				case 1:
					nx++;
					break;
				case 2:
					nx--;
					break;
				case 3:
					ny++;
					break;
				case 4:
					ny--;
					break;
				}
				
				map[y][x] = 5;
				x = nx;
				y = ny;
				
				if ((map[y][x] == 5) && (goal == false)) {
					System.out.println("LOOP");
					break;
				}
			}
			
			lines = sc.nextLine();
		}
	}
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> c( 5 );
	for( int i = 0; i < N; i++ ) {
		string s;
		cin >> s;
		if( s[0] == 'M' ) c[0]++;
		else if( s[0] == 'A' ) c[1]++;
		else if( s[0] == 'R' ) c[2]++;
		else if( s[0] == 'C' ) c[3]++;
		else if( s[0] == 'H' ) c[4]++;
	}

	long long ans = 0;
	int per[5] = { 0, 0, 1, 1, 1 };
	do {
		long long m = 1;
		for( int i = 0; i < 5; i++ ) {
			if( per[i] ) m *= c[i];
		}

		ans += m;
	} while( next_permutation( per, per + 5 ) );

	cout << ans << endl;
}


Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 20:56:06 2020

@author: liang
"""

N = int(input())
L = [int(x) for x in input().split()]

L.sort()
ans = 0
#print(L)
for i in range(N-2):
    #print("1:",i)
    p = i+2
    for j in range(i+1,N-1):
        #print("2",i,j)
        while p < N and L[p] < L[i] + L[j] :
            p += 1
            #print("up")
        #print(p)
        ans += len(L[j+1:p])
print(ans)

Measured memory_bytes: 74080
n=int(input())
p=list(map(int,input().split()))

c=0

for i in range(n-2):
    if p[i+1]>p[i] and p[i+1]<=p[i+2]:
        c+=1
    elif p[i+1]<=p[i] and p[i+1]>p[i+2]:
        c+=1
    elif p[i+1]>p[i] and p[i+1]>p[i+2] and p[i]==p[i+2]:
        c+=1

print(c)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int kisuu = (n + 1) / 2; 
		double ans = (double)kisuu * 1.0 / (double)n;
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 23508
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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 long long INF=1LL<<60;
//set<int>::iterator it;


int main(void){
    
    int a,o=0,e=0,i,n;
    cin>>n;
    for(i=0;i<n;i++){
    	cin>>a;
    	if(a%2==0)e++;
    	else o++;
	}
	if(o%2!=0)cout<<"NO"<<endl;
    else if(e==0&&o%2==0)cout<<"YES"<<endl;
    else if(e>=1&&o>=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    
    
	
	return 0;
}

Measured memory_bytes: 256
//2008dC
I;int parse(char *p){switch(*p){
	case 'F':return 0;
	case 'T':return 1;
	case '-':return !parse(p+1);
	case '(':{
		int x=0;
		p++;
		char *q=p;
		for(;;p++){
			if(*p=='(')x++;
			if(*p==')')x--;
			if(x==0&&*p!='-')break;
		}
		p++;
		switch(*p){
			case '*':return parse(q)&parse(p+1);
			case '+':return parse(q)|parse(p+1);
			case '-':return !parse(q)|parse(p+2);
		}
	}
}return (I>>(*p-97))&1;}
char p[1001],*q;main(){for(;scanf("%s",p),*p-'#';puts(I==2048?"YES":"NO")){
for(q=strchr(p,'=')+1,I=0;I<2048;I++)if(parse(p)!=parse(q))break;
}exit(0);}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    int a[n];
    fill(a, a + n, -1);
    for(int i = 0; i < m; i++)
    {
        int s, c;
        cin >> s >> c;
        s--;
        if(a[s] != -1 && a[s] != c)
        {
            cout << -1;
            return 0;
        }
        a[s] = c;
    }
    if(n > 1 && a[0] == 0)
    {
        cout << -1;
        return 0;
    }
    if(n == 1 && m == 0)
    {
        cout << 0;
        return 0;
    }
    for(int i = 0; i < n; i++)
    {
        if(a[i] == -1)
        {
            if(i == 0)
            {
                cout << 1;
            }
            else
            {
                cout << 0;
            }
        }
        else
        {
            cout << a[i];
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
	long long K;
	scanf("%lld", &K);
	printf("50\n");
	long long A[50];
	int phase = K % 50;
	long long N = K / 50 + 49;
	for(int i = 0; i < 50; i++) {
		if(i < phase) {
			A[i] = N + 51 - phase;
		} else {
			A[i] = N - phase;
		}
		printf("%lld", A[i]);
		printf( i < 50 - 1 ? " " : "\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int a,b,c,d;
  int ans;

  scanf(" %d %d %d %d",&a,&b,&c,&d);

  ans=max(a*b,c*d);

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  ll res = 0;
  ll sum = 0;
  int right = 0;
  for(int left = 0; left < n;left++){
    while(right < n && (sum+a[right]) == (sum^a[right])){
      sum += a[right]; right++;
    }
    res += right - left;
    if(left==right) right++;
    else sum -= a[left];
  }
  
  cout << res << endl;
  return 0;
}

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

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

#define mp make_pair
typedef pair<int,int> pii;

const int M_MAX = 1000010;
const int N = 4000;

pii fill(vector<vector<int>> &maze, int x, int y, int dir, int k, int s) {
  for (int i = 0; i < k; i++) {
    maze[y + i * dy[dir]][x + i * dx[dir]] = s++;
  }
  return mp(x + k * dx[dir], y + k * dy[dir]);
}

void make(vector<vector<int>> &maze) {
  pii now = mp(N / 2, N / 2);
  int k = 1;
  int num = 1;
  while(num <= M_MAX) {
    now = fill(maze, now.first, now.second, 0, k, num); num += k;
    now = fill(maze, now.first, now.second, 1, k, num); num += k;
    k++;
    now = fill(maze, now.first, now.second, 2, k, num); num += k;
    now = fill(maze, now.first, now.second, 3, k, num); num += k;
    k++;
  }
}

char isprime[M_MAX];

void era() {
  for (int i = 0; i < M_MAX; i++) {
    isprime[i] = 1;
  }
  isprime[0] = isprime[1] = 0;
  for (int i = 2; i < M_MAX; i++) {
    if (isprime[i]) {
      for (int j = i + i; j < M_MAX; j += i) {
        isprime[j] = 0;
      }
    }
  }
}

void solve(vector<vector<int>> &maze, int m, int n) {
  int sx, sy;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (maze[i][j] == n) {
        sx = j, sy = i;
      }
    }
  }
  vector<vector<int16_t>> dp(N, vector<int16_t>(N, -1));
  dp[sy][sx] = isprime[maze[sy][sx]];
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < N; j++) {
      if (maze[i][j] > m) continue;
      if (dp[i][j] == -1) continue;
      if (j >= 1) dp[i + 1][j - 1] = max(dp[i + 1][j - 1], (int16_t)(dp[i][j] + isprime[maze[i + 1][j - 1]]));
      dp[i + 1][j] = max(dp[i + 1][j], (int16_t)(dp[i][j] + isprime[maze[i + 1][j]]));
      if (j < N - 1) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], (int16_t)(dp[i][j] + isprime[maze[i + 1][j + 1]]));
    }
  }
  int ma = 0;
  int ma_ind = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (maze[i][j] > m) continue;
      if (ma <= dp[i][j] && isprime[maze[i][j]]) {
        if (ma < dp[i][j]) {
          ma = dp[i][j];
          ma_ind = maze[i][j];
        } else {
          if (ma_ind < maze[i][j]) ma_ind = maze[i][j];
        }
      }
    }
  }
  if (ma == 0) {
    cout << "0 0" << endl;
  } else {
    cout << ma << " " << ma_ind << endl;
  }
}

int main() {
  vector<vector<int>> maze(N, vector<int>(N, 0));
  make(maze);
  era();

  int n, m;
  while(cin >> m >> n, m != 0) {
    solve(maze, m, n);
  }
  
  return 0;
}



Measured memory_bytes: 97912