akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int H, W, N;
    cin >> H >> W >> N;
    int m = max(H, W);
    int ans = 0;
    int tmp = 0;
    while(true){
        tmp += m;
        ans++;
        if (tmp >= N) break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc058.contest.atcoder.jp/tasks/arc058_b>
問題文============================================================
 縦 H マス、横 W マスのマス目があります。
 いろはちゃんは、今一番左上のマス目にいます。
 そして、右か下に1マス移動することを繰り返し、一番右下のマス目へと移動します。
 ただし、下から A 個以内、かつ左から B 個以内のマス目へは移動することは出来ません。
 
 移動する方法は何通りあるか求めてください。
 なお、答えは非常に大きくなることがあるので、答えは 10^9+7 で割ったあまりを出力してください。
=================================================================

解説=============================================================

================================================================
*/

const ll MAX_N = 2e5 + 10;
const ll MOD = 1e9+7;
ll Inv[MAX_N];
ll fact[MAX_N];
ll factInv[MAX_N];
void Inv_init(){
    Inv[1] = 1;
    for(int i = 2; i < MAX_N; i++) {
        Inv[i] = Inv[MOD%i] * (MOD - MOD/i) % MOD;
    }
}
void fact_init(){
    fact[0] = fact[1] = factInv[0] = factInv[1] = 1;
    for(int i = 2; i < MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        factInv[i] = (factInv[i-1] * Inv[i])%MOD;
    }
}

// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}
ll nCr(int n,int r) {
    if(n < r) return 0;
    return (fact[n] * (factInv[r] * factInv[n-r] % MOD)) % MOD;
}

void init(){
    Inv_init();
    fact_init();
}

ll calc(int x1, int y1, int x2, int y2) {
    int dx = x2 - x1, dy = y2 - y1;
    return nCr(dx + dy, dx);
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    init();
    int H,W,A,B; cin >> H >> W >> A >> B;
    ll ans = 0;
    for(int i = 1; i <= H - A;i++){
        ans += (calc(1,1,i,B)*calc(i,B+1,H,W))%MOD; ans%=MOD;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a;
    char s[10];
    
    scanf("%d", &a);
    scanf("%s", &s);
    
    if (a>=3200) {
        printf("%s", s);
    }else{
        printf("red");
    }
    return 0;
}

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

#define  F  first
#define  S  second
#define  mp make_pair
typedef long long int ll;
const int N = 2e5+6,inf = 1e9+7;

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

    int n,x;cin>>n>>x;
    int Arr[n+2];
    for(int i=1;i<=n;i++)
        cin>>Arr[i];
    sort(Arr+1,Arr+n+1);
    int Cnt = 0;
    for(int i=1;i<=n;i++)
    {
        if( x>=Arr[i] )x-=Arr[i],Cnt++;
        else x = 0;
    }
    if(x)Cnt--;
    cout<<max(0,Cnt)<< "\n";























    return 0;
}


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

using namespace std;

int main()
{
    string N;   cin >> N;
    
    if (((N[0] == N[1]) && (N[1] ==N[2])) || ((N[1] == N[2]) && (N[2] == N[3]))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

int main()
{
  int a, b, k;

  cin >> a >> b >> k;
  for (int i = 0; i < k; i++)
  {
    if (a + i <= b)
      cout << a + i << endl;
  }
  for (int i = 0; i < k; i++)
  {
    if (b - k + i + 1 >= a + k)
      cout << b - k + i + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
ll ds(ll Q){
        ll sum=0;
        ll dig;
        while(Q){
        dig = Q % 10;
        sum = sum + dig;
        Q = Q / 10;
        }
        return sum;
    }

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    long double x;
    vector<ll> aa;

    ll Q,N,K;
    long double a, b;
    string S;
    cin  >>N>>S;
    ll flag=0;
    ll t1=0;
    ll t2=0;
  	
    ll Q1=Q;

    ll temp=0;
    ll pl=1;

for(i=0;i<N;i++){
    for(j=1;j<N;j++){
        if(i+2*j<N && S[i]!=S[i+j] && S[i]!=S[i+2*j] && S[i+2*j]!=S[i+j]){
            temp++;
        }
    }
}
ans=std::count(S.cbegin(), S.cend(), 'R')*std::count(S.cbegin(), S.cend(), 'G')*std::count(S.cbegin(), S.cend(), 'B');
ans=ans-temp;
    cout<< ans << endl;

    return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template<class T> void sort3a(T& a,T& b,T& c) {if (a>b) swap(a,b); if (b>c) swap(b,c); if (a>b) swap(a,b);}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    string cf2016 = "CODEFESTIVAL2016";
    string S; cin >>S;
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] != cf2016[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
using namespace std;

int I, X, C, M;

void prefix(char x){
  if(x == 'i') I += 1;
  if(x == 'x') X += 10;
  if(x == 'c') C += 100;
  if(x == 'm') M += 1000;
}

int main(){
  int cs, n1, n2;
  string s1, s2, ans;
  cin >> cs;
  while(cs--){
    n1 = 0, n2 = 0;
    cin >> s1 >> s2;
    
    for(int i = s1.size()-1 ; i >= 0 ; i--){
      if(!isdigit(s1[i])) prefix(s1[i]);
      else if(s1[i+1] == 'i') I *= (s1[i]-'0');
      else if(s1[i+1] == 'x') X *= (s1[i]-'0');
      else if(s1[i+1] == 'c') C *= (s1[i]-'0');
      else if(s1[i+1] == 'm') M *= (s1[i]-'0');    
    }
    
    n1 = I + X + C + M;
    I = 0, X = 0, C = 0, M = 0;
    
    for(int i = s2.size()-1 ; i >= 0 ; i--){
      if(!isdigit(s2[i])) prefix(s2[i]);
      else if(s2[i+1] == 'i') I *= (s2[i]-'0');
      else if(s2[i+1] == 'x') X *= (s2[i]-'0');
      else if(s2[i+1] == 'c') C *= (s2[i]-'0');
      else if(s2[i+1] == 'm') M *= (s2[i]-'0');    
    }
    
    n2 = I + X + C + M;
    I = 0, X = 0, C = 0, M = 0;
    
    int sum;
    sum = n1 + n2;
    ans = "";
    
    if(sum >= 1000){
      if(sum / 1000 != 1) ans += (sum / 1000)+'0';
      ans += 'm';
      sum -= (sum / 1000) * 1000;
    }
    if(sum >= 100){
      if(sum / 100 != 1) ans += (sum / 100)+'0';
      ans += 'c';
      sum -= (sum / 100) * 100;
    }
   if(sum >= 10){
      if(sum / 10 != 1) ans += (sum / 10)+'0';
      ans += 'x';
      sum -= (sum / 10) * 10;
    }
   if(sum >= 1){
      if(sum != 1) ans += sum+'0';
      ans += 'i';
   } 
   cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = list(map(int,input().split()))
    ans = max(0, a-2*b)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
# imos法
# 長さNの1次元配列において、「ある連続する区間に、ある数vを足す」という操作をK回繰り返した結果を高速で求める
# 電球の届く範囲をMax,Minで求めた
# 累積和  from itertools import accumulate
    
# 初期入力
    
import sys
input = sys.stdin.readline
N,K = (int(i) for i in input().split())
A = list(map(int, input().split()))       
l =0
r =N
#操作数が電球の数より多いとき
if N <=K:
    A=[N]*N
# imos法
else:
    for j in range(K):
        B =[0]*(N+1)
        for i in range(N):
            index =A[i]
            l =max(i -index,0)
            r =min(i +index +1,N) 
            B[l] +=1 
            B[r] -=1
        #累積和(imos法) 
        from itertools import accumulate
        del B[-1]
        A =list(accumulate(B))
        if sum(A) ==N*N:
            print(*A)
            sys.exit(0)
    
print(*A)

Measured memory_bytes: 184900
#include <stdio.h>

int main(){
    int data[3];
    int i,j;
    int tmp;
    
    scanf("%d %d %d",&data[0],&data[1],&data[2]);
    
    for ( i = 0; i < 2; i++){
        
        for ( j = 2; j > i; j--){
            if ( data[j] < data[j-1] ){
                tmp = data[j];
                data[j] = data[j-1];
                data[j-1] = tmp;
            }
        }
    }
    printf("%d %d %d\n",data[0],data[1],data[2]);
    return 0;
}

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

bool good(int n){
	if(n % 2 == 0) return false;
	int cnt = 0;
	for(int i = 1; i < n / 2; i++){
		if(n % i == 0) cnt++;
	}
	return cnt + 1 == 8;
}
int main(){
	int n, ans = 0; cin>>n;
	for(int i = 1; i <= n; i++){
		if(good(i)){
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
ll a[100010];
ll ans[100010];

int main(void) {
	cin >> N;
	rep(i, N) cin >> a[i];
	set<ll> se;
	rep(i, N) se.insert(a[i]);
	/*
	ll ma = 0, maidx;
	rep(i, N) {
		if(ma < a[i]) ma = a[i], maidx = i;
	}
	*/

	// map<ll, vector<int>> ma;
	map<ll, pair<int, int>> ma; // ma[i] := 石の数がiのものの中で最小のidxがi, そのような山の数がse
	// rep(i, N) ma[a[i]].pb(i);
	
	rep(i, N) {
		if(ma.count(a[i]) == 0) ma[a[i]].fi = i, ma[a[i]].se = 1;
		else ma[a[i]].se++;
	}
	/*
	for(auto u : ma) {
		cout << u.fi << " " << u.se.fi << " " << u.se.se << endl;
	}
	*/

	vector<int> v;
	for(auto u : se) v.pb(u);
	sort(all(v)); reverse(all(v));
	rep(i, v.size()) {
		// printf("i %d\n", i);
		ll now = v[i], next = v[i + 1];
		ll sa = now - next;
		// sort(all(ma[now]));
		// ans[ma[now].front()] += sa * ma[now].size();
		ans[ma[now].fi] += sa * ma[now].se; //　答えを加える

		// for(auto u : ma[now]) ma[next].pb(u);
		chmin(ma[next].fi, ma[now].fi);
		ma[next].se += ma[now].se;
		// ma[now].clear();
		ma[now].se = ma[now].se = 0;
		/*
		printf("\n");
		for(auto u : ma) {
			cout << u.fi << " " << u.se.fi << " " << u.se.se << endl;
		}
		printf("\n");
		*/
	}
	// ans[0] += N;
	rep(i, N) {
		printf("%lld\n", ans[i]);
	}

	return 0;
}

Measured memory_bytes: 14072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int D, G;
    cin >> D >> G;
    G /= 100;
    int p[D], c[D];
    for(int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    int ans = inf;
    for(int bit = 0; bit < (1 << D); ++bit) {
        vector<int> S;
        for(int i = 0; i < D; ++i) {
            if(bit & (1 << i)) {  // i が bit に入るかどうか
                S.push_back(i);
            }
        }

        int score = 0, solved = 0;
        bool used[D];

        for(int i = 0; i < D; i++) used[i] = false;
        for(int i = 0; i < S.size(); i++) {
            used[S[i]] = true;
            score += c[S[i]] + p[S[i]] * (S[i] + 1);
            solved += p[S[i]];
        }
        int tmp = D;
        while(score < G && tmp > 0) {
            tmp--;
            if(used[tmp]) continue;
            solved += min(p[tmp], (G - score + tmp) / (tmp + 1));
            score += (tmp + 1) * min(p[tmp], (G - score + tmp) / (tmp + 1));
        }
        if(score >= G) ans = min(ans, solved);
    }
    cout << ans << "\n";
    return 0;
}


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

ans = 0
while (1):
   b = [x % 2 for x in a]
   ans += b.count(0)
   if (0 not in b):
      break

   a = [int(a[i]/2) if b[i]==0 else a[i] for i in range(n)]

print(ans)


Measured memory_bytes: 4148
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Jan 20 21:07:06 2019
//
package main

import "fmt"

func all0(slice []int) bool {
	for _, a := range slice {
		if a != 0 {
			return false
		}
	}
	return true
}

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	ans := 0
	for i := 0; i < 100; i++ {
		if all0(arr) {
			break
		}

		not0 := false
		for j := range arr {
			if arr[j] == 0 {
				if not0 {
					ans++
				}
				not0 = false
			} else {
				not0 = true
				arr[j]--
			}
		}
		if not0 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
N,M=map(int,input().split())
KA=[0]*N
count=[0]*(M+1)
for i in range(N):
  KA[i]=list(map(int,input().split()))
for i in range(N):
  for j in range(1,len(KA[i])):
    count[KA[i][j]]+=1
ans=0
for i in range(1,M+1):
  if count[i]==N :
    ans+=1
print(ans)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  int c = 1;
  cin >> a >> b;
  while(a > 0){
    if(c < b)
      c *= 2;
    else
      c += b;
    a--;
  }
  cout << c << endl;
}
      
    


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
#include <stack>
#include<set>
#include<cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <string.h>
#include<iterator>
#include <map>
using namespace std;
// bool cmp(long long a, long long b){
//     return a > b;
// }
int  arr[3500];
string str[10];
char str_arr[5][5];
int matr[25][25], saved_matr[5][5], ish_matr[5][5];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long t, ch, i, curr, p = 1, x, y, weight, j, k = 0, n, m = 1, ch1, ans = 0;
    long long a, b;
    int fl, fl1, fl2, fl3;
    long long s;
//    cin >> t;
    long long f, size_f, size_s, weight1, weight2;
    long long sum, k_min, k_max;
//    for (auto test_case = 0; test_case < t; test_case++) {
//    }
    long long d;
    cin >> d >> t >> s;
    if (t * s >= d)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	if (n == 0)
	{
		cout << 1 << endl;
	}
	else if (n == 1)
	{
		cout << 2 << endl;
	}
	else if (n == 2)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
	cin>>n>>d;
	 vector<vector<double>> mv(n);
	for(int r=0;r<n;r++){
	for(int i=0;i<d;i++){
		double t;
		cin>>t;
		mv[r].emplace_back(t);
	}
	}
	int tot=0;
	for(int i=0;i<n;i++){
		
		for(int j=i+1;j<n;j++){
			double dissum=0;
			for(int z=0;z<d;z++){
				dissum+=pow(mv[i][z]-mv[j][z],2);
			}
			double finans=sqrt(dissum);
			if(floor(finans)==ceil(finans)){
				tot++;
			}
		}
	}
	cout<<tot<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[101];

void insertionSort(int* A,int N)
{
	for(int k=0;k<N-1;k++) printf("%d ",A[k]);
	printf("%d\n",A[N-1]);
	for(int i=1;i<N;i++){
		int v=A[i];
		int j=i-1;
		while(j>=0&&A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		for(int k=0;k<N-1;k++) printf("%d ",A[k]);
		printf("%d\n",A[N-1]);
	}
	
	return;
}

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

Measured memory_bytes: 1028
#include <stdio.h>
#include <math.h>
#include <string.h>

int main()
{
  char ss[11];
  long long int nn, order, sum = 0;
  scanf("%s", ss);
  nn = strlen(ss);
  for(int bit = 0;bit < (1 << (nn - 1));bit++)
  {
    order = 1;
    sum += ss[nn - 1] - '0';
    for(int ii = 1;ii < nn;ii++)
    {
      if(bit & (1 << (ii - 1)))
      {
        sum += (ss[nn - 1 - ii] - '0');
        order = 1;
      }
      else
      {
        sum += (ss[nn - 1 - ii] - '0') * pow(10, order);
        order++;
      }
    }
  }
  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  cout << (n + 2 - 1) / 2 << endl;
  return 0;
}


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

typedef long long ll;

struct edge { int to, cap, rev; };

const int MAX_V = 100000;

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, 1e9);
        if (f == 0) return flow;
        flow += f;
    }
}

int main() {
    int N;
    cin >> N;
    int red = 2 * N, blue = 2 * N + 1;
    vector<int> a(N), b(N), c(N), d(N);
    rep(i, N) {
        cin >> a[i] >> b[i];
        add_edge(red, i, 1);
    }
    rep(i, N) {
        cin >> c[i] >> d[i];
        add_edge(i + N, blue, 1);
    }
    rep(i, N) {
        rep(j, N) {
            if (a[i] < c[j] && b[i] < d[j]) {
                add_edge(i, j + N, 1);
            }
        }
    }
    cout << max_flow(red, blue) << "\n";
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int N, M, K;
    cin >> N >> M >> K;

    for (int x = 0; x <= N; x++) {
        for (int y = 0; y <= M; y++) {
            if (K == x*M + y*N - 2*x*y) {
                cout << "Yes" << endl;
                return;
            }
        }
    }

    cout << "No" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N;
    string S;
    cin >> N >> S;
    if(N % 2 != 0) {
        printf("No\n");
        return 0;
    }

    if(S.substr(0, N / 2) == S.substr(N / 2, N / 2)) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    #define       pb(a)             push_back((a))
    #define       mp(a,b)           make_pair((a),(b))
    #define       REP(a,b)          for(ll i=(a);i<(b);i++)
    #define       REP2(a,b)         for(ll j=(a);j<(b);j++)
    #define       REPE(a,b,c,d)     REP(a,b)for(ll j=(c);j<(d);j++)
    #define       REPV(a,b,c)       for(ll (a)=b;(a)<(c);(a)++)
    #define       IREP(a,b)         for(ll i=(a);i>=(b);i--)
    #define       IREP2(a,b)        for(ll j=(a);j>=(b);j--)
    #define       IREPV(a,b,c)      for(ll (a)=b;(a)>=(c);(a)--)
    #define       all(v)            (v).begin(),(v).end()
    #define       Trvs(c)           for (auto &it :c)
    #define       INF               INT_MAX
    #define       sz(x)             x.size()
    #define       flash             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define       F                 first
    #define       S                 second
    #define       MOD               1000000007

    using         ll     = long long;
    using         vll    = vector<ll>;
    using         vvll   = vector<vll>;
    using         pll    = pair<ll, ll>;
    using         vpll   = vector<pll>;
    using         vvpll  = vector<vpll>;
     


void solve(){
	ll n,k; cin >> n>> k;
	vll a(n,0); REP(0,n)cin>> a[i];
	map<ll,double> mp;
	REP(1,1001){
		mp[i] = double(double(i)*(i+1)/2)/double(i);
	}
	vector<double> arr;
	REP(0,n){
		arr.pb(mp[a[i]]);
	}
	double sum=0,glo =0;
	REP(0,k){
		sum+=arr[i];
	}
	glo = sum;
	REP(1,n){
		arr[i] += arr[i-1];
	}
	REP(k,n){
		sum = arr[i] - arr[i-k];
		if(sum > glo )glo = sum;
	}
	cout<<setprecision(10)<<glo;
}
	

     
    	
int main(){
    	flash
    	
    	// ll t;cin>>t;while(t--)
    	solve();
    	return 0;
    } 	

Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std;
const int uchiha=1e3+5;
int arr[4][4];
int main(){
for(int i=1;i<=3;i++)
    for(int j=1;j<=3;j++)
    cin>>arr[i][j];
if(arr[1][2]-arr[1][1]==arr[2][2]-arr[2][1]&&arr[3][2]-arr[3][1]==arr[2][2]-arr[2][1]&&
   arr[1][3]-arr[1][2]==arr[2][3]-arr[2][2]&&arr[3][3]-arr[3][2]==arr[2][3]-arr[2][2])
   cout<<"Yes";
else
    cout<<"No";
}

Measured memory_bytes: 256
x = int(input())
a = [list(map(int,input().split())) for i in range(x)]
ans = 0
for i in range(x):
    for j in range(x):
        if i!=j:
            ans += ((abs(a[i][0]-a[j][0])**2+abs(a[i][1]-a[j][1])**2))**0.5
print(ans/x)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
ll n,k,a[100010],ans=INF;
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-k+1;i++){
        ll l=a[i],r=a[i+k-1];
        if(l*r>0) ans=min(ans,max(abs(l),abs(r)));
        else ans=min(ans,abs(l)+abs(r)+min(abs(l),abs(r)));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll n,m,k,a=0,b=0;
    int ans=0;
    ll A[200005],B[200005];
    cin>>n>>m>>k;
    REP(i,n) cin>>A[i];
    REP(i,m){
        cin>>B[i];
        b+=B[i];
        if(b<=k) ans++;
    }
    int i=0,j=m-1;

    while(i<=n-1 && a+A[i]<=k){

        a+=A[i];
        while(j>=0 && b>k-a){
            b-=B[j];
            j--;
        }
        ans=max(ans,i+j+2);
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
void solve()
{
    int n,k;cin>>n>>k;
    int h[n];REP(i,n)cin>>h[i];
    vector<ll>dp(n,INF);dp[0]=0;
    REP(i,n)
        rep(j,1,k+1)
            if(i+j<n)dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    cout<<dp[n-1]<<endl;
}

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

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//#define _debug
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back
//#define _online_judge

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, //data type
        null_type, //
        less<int>, //
        rb_tree_tag, //red-black tree
        tree_order_statistics_node_update> new_data_set;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = static_cast<const int>(1e6 + 5);
const int MOD = 1000000007;


int main (){
	FASTIO
#ifdef _online_judge
	freopen("input.txt" , "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

    string s;cin >> s;
    int siz = s.size();
    int cnt1=0,cnt2=0;
    string s1,s2;
    FOR(i,0,siz){

        if(i%2 == 0){
            s1 += "0";
            s2 += "1";
        }else{
            s1 += "1";
            s2 += "0";
        }
    }
    FOR(i,0,siz){

        if(s[i] != s1[i]){
            cnt1++;
        }
        if(s[i] != s2[i]){
            cnt2++;
        }
    }
    cout << min(cnt1,cnt2);
    return 0;
}


Measured memory_bytes: 720
member = list(map(int, input().split()))

def check_odd():
    for m in member:
        if m % 2 != 0:
            return True
    return False

def check_number():
    num = member[2]
    for i in range(2):
        if num != member[i]:
            return True
    return False

if check_number():
    count = 0
    while True:
        if check_odd():
            break
        else:
            a = member[1] // 2 + member[2] // 2
            b = member[0] // 2 + member[2] // 2
            c = member[0] // 2 + member[1] // 2
            member = [a, b, c]
        count += 1
    print(count)
else:
    if check_odd():
        print(0)
    else:
        print(-1)

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

int main(){
  int N;
  cin>>N;
  map<int,int> m;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    if(m.count(x)){
      m.at(x)++;
    }else{
      m[x]=0;
    }
  }
  
  int sum=0;
  for(auto i:m){
    sum+=i.second;
  }
  
  cout<<N-2*(sum/2+sum%2)<<endl;
}
  

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		String newStr;

		newStr = String.valueOf(S.toCharArray()[K - 1]).toLowerCase();

		for (int i = 0; i < N; i++) {
			if (i == K - 1) {
				System.out.print(newStr);
			} else {
				System.out.print(S.toCharArray()[i]);
			}
		}

		System.out.println();
	}
}


Measured memory_bytes: 21716
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int[] p = new int[N + 1];

        for(int i=1; i<=N; i++){
            p[i] = sc.nextInt();
        }

        int ans = 0;
        int x = 0;
        if(p[1]==1){
            ans += 1;
            x += 1;
        }
        for(int i=2; i<N; i++){
            if(p[i]==i){
                ans += 1;
                x += 1;
                if(p[i-1]==i-1 && x==2){
                    ans -= 1;
                    x = 0;
                }
            }
            else{
                x = 0;
            }
        }
        if(p[N]==N){
            ans += 1;
            x += 1;
            if(x==2){
                ans -= 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50640
#include <iostream>
#include <cstdio>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int n; cin >> n;
  int a = n % 10;
  if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) cout << "hon" << endl;
  else if (a == 3) cout << "bon" << endl;
  else cout << "pon" << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[10001];
		a[0] = 1;
		for(int i=1;i<10001;i++){
			a[i] = a[i-1] + i;
		}
		while (sc.hasNext()) {
			int n=sc.nextInt();
			System.out.println(a[n]);
		}
		sc.close();
	}
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if (n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  ll ans = power(10, n, MOD) - 2 * power(9, n, MOD) + power(8, n, MOD) + MOD * 2;
  ans %= MOD;
  
  cout << ans << '\n';
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

template<typename T>
struct SegmentTree{
    int n;
    T e; //単位元
    vector<T> v;
    function<T(T,T)> operation;
    function<T(T,T)> update;
    //区間[a,b)に対してのクエリ 今は[l,r)を見ている
    T _query(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return e;
        if(a<=l && r<=b) return v[k];
        else{
            T c1=_query(a,b,2*k+1,l,(l+r)/2);
            T c2=_query(a,b,2*k+2,(l+r)/2,r);
            return operation(c1,c2);
        }
    }
public:
    SegmentTree(size_t _n,T _e,function<T(T,T)> _operation,function<T(T,T)> _update):e(_e),operation(_operation),update(_update){
        n=1;
        while(n<_n){
            n*=2;
        }
        v=vector<T>(2*n-1,e);
    }
    void change(int i,T x){
        i+=n-1;
        v[i]=update(v[i],x);
        while(i>0){
            i=(i-1)/2;
            v[i]=operation(v[i*2+1],v[i*2+2]);
        }
    }
    T query(int a,int b){
        return _query(a,b,0,0,n);
    }
    T operator[](int i){
        return v[i+n-1];
    }
};


signed main(){
    int n; cin >> n;
    string s; cin >> s;
    SegmentTree<ll> seg(n,0,[](ll a,ll b){return a|b;},[](ll a,ll b){return b;});
    
    rep(i,n) seg.change(i,1ull<<(s[i]-'a'));
    
    int q; cin >> q;
    rep(i,q){
        int x; cin >> x;
        if(x==1){
            int a; cin >> a;
            a--;
            char b; cin >> b;
            seg.change(a,1ull<<(b-'a'));
        }else{
            int a,b; cin >> a >> b;
            a--; b--;
            ll bit =seg.query(a,b+1);
            cout <<  __builtin_popcount(bit) << endl;
        }
    }
}


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

long long gcd(int m, int n){
    long long tmp;
    while(m%n != 0){
        tmp = n;
        n = m%n;
        m = tmp;
    }
    return n;
}

int main(void){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long ans = b-(a-1);
    // 1からbまでのcの倍数の個数から、
    // 1からa-1までのcの倍数の個数を引くと、
    // aからbまでのcの倍数の個数になる
    ans -= (b/c) - ( (a-1)/c );
    ans -= (b/d) - ( (a-1)/d );

    long long GCD = gcd(c,d);
    GCD = c*d/GCD;
    ans += (b/GCD) - ( (a-1)/GCD );

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[110],b[110];
int main()
{
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		cin>>b[i];
	}
	a[1]=a[2]=b[1];
	for(int i=2;i<=n-1;i++)
	{
		if(b[i]>=b[i-1])
		{
			a[i+1]=b[i];
		}
		if(b[i]<b[i-1])
		{
			a[i]=a[i+1]=b[i];
		}
		
	}
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	LL K,A,B;
	cin >> K >> A >> B;
	
	
	if(A+1 >= B) cout << 1+K << endl;
	else{
		LL k = K - A+1;
		LL ans = A;
		if(k%2 == 1){
			ans++;
			k--;
		}
		ans += (B-A)*(k/2);
		cout << ans << endl;
	}

	return 0;
}

/*

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



return 0;
}
*/

/*

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



return 0;
}
*/

/*

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(9);



return 0;
}
*/

/*

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(9);



return 0;
}
*/

/*

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(9);



return 0;
}
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    cout << ((k <= a) ? k : (k <= (a + b) ? a : a - (k - (a + b)))) << endl;
    return 0;
}

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

using namespace std;

int main(void){

  int n,r;
  while(cin >> n >> r,n|r){
    vector<int>a(n);
    for(int i=0;i<n;i++)a[i]=i;

    while(r--){
      int p,c;
      cin >> p >> c;
      vector<int>t=a;
      for(int i=n-p-c+1;i<=n-p;i++)t[i+p-1]=a[i];
      for(int i=n-p+1;i<n;i++)t[i-c]=a[i];
      a=t;
    }
    cout << a[n-1]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        boolean yes = false;
        int count = 0;
        for(int i = 0; i < n; i++){
            int d1 = Integer.parseInt(sc.next());
            int d2 = Integer.parseInt(sc.next());
            if(d1 == d2){
                count++;
                if(count == 3){
                    yes = true;
                }
            }else{
                count = 0;
            }
        }
    
        System.out.println(yes ? "Yes" : "No");
    }
}

Measured memory_bytes: 35604
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

n_way = 0
0.upto(a) do |n_500|
  0.upto(b) do |n_100|
    0.upto(c) do |n_50|
      n_way += 1 if 500*n_500 + 100*n_100 + 50*n_50 == x
    end
  end
end
puts n_way


Measured memory_bytes: 3836
def rot(s):
    x=""
    for c in s:
        tmp = ord(c)-ord("a")
        if "a"<=c<="z":
            x += chr((tmp+1) % 26 + ord("a"))
        else:
            x += c
    return x
    
while True:
    try:
        s = raw_input()
        f = False
        for i in range(26):
            for word in s.split():
                if word=="the" or word=="this" or word=="that":
                    f=True
                    break
            if f: break
            else: s=rot(s)
        print s
    except:
        break

Measured memory_bytes: 4236
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

#define INF 1e9

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

  int ans = INF;
  int n = s.length();
  for(int i = 0; i < n-1; i++){
    if(s[i] != s[i+1]) ans = min(ans, max(i+1, n-i-1));
  }

  if(ans == INF) ans = n;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{long long j=1000,k=0;
long long n;
cin >> n;
int a[n];
for (int i=0;i<n;i++)
    cin >> a[i];
int l=0;
int y;
 for (int i=1;i<n;i++)
{
    if (a[i-1]<a[i])
    {
        k+=j/a[i-1];
    j=j%a[i-1];
    l=i-1;
  //  cout << 1 ;

    //y=a[i-1];
    }
     if (a[i]>a[i-1])
    {
        j+=k*a[i];
   // cout << j << endl;
        k=0;
    }

} int m=1;
for (int i=l;i<n;i++)
{
    m=max(m,a[i]);
}
j+=k*m;
cout << j <<endl;
    return 0;
}


Measured memory_bytes: 3096
N = gets.to_i
L = gets.chomp.split.map(&:to_i)
ans = 0

(0..N-1).each do |a|
  (0..N-1).each do |b|
    (0..N-1).each do |c|
x = L[a] 
y = L[b]
z = L[c]
if x != y && y != z && x != z && 2*[x,y,z].max<x+y+z
  ans += 1
end
end
end
end

puts ans/6


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

vector<ll>a;
vector<ll>f;
ll n,k;
bool ch(ll x){
    ll cnt=0;
    for (int i = 0; i < n; ++i) {
        ll d=a[i]*f[i]-x;
        if(d<=0)continue;
        else {
            cnt+=(d-1)/f[i]+1;
        }
    }
    if(cnt>k)return false;
     return true;
}

int main(){
    cin >>n>>k;
    a.resize(n);
    f.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >>f[i];
    }
    sort(all(a));
    sort(all(f));
    reverse(all(f));
    ll ng=-INFll/2;
    ll ok=INFll/2;
    while(abs(ok-ng)>1){
        ll md=(ok+ng)/2;
        if(ch(md))ok=md;
        else ng=md;
//        cout <<ok <<" "<<ng<<endl;
    }
    ok=max(0LL,ok);
    cout<<ok<<endl;
    return 0;
}



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

int main(){
  	char b;
    cin >> b;
  	if(b == 'A'){
      	cout << 'T' << endl;
    }
  	else if(b == 'T'){cout << 'A' << endl;}
  	else if(b == 'G'){cout << 'C' << endl;}
  	else if(b == 'C'){cout << 'G' << endl;}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();

			int[]a = new int[N];

			int count = 0;
			long goukei = 0;

			int num = 0;
			long co = 0;
			for(int i = 1;i<=N;i++) {
				goukei+=(long)i;
				if(goukei-N>=0) {
					co=goukei-N;
					num = i;
					count++;
					//System.out.println(co+" "+num+" "+count);
					break;
				}
			}

			if(co==0) {
				for(int i = 1;i<=num;i++) {
					System.out.println(i);
				}
			}else {
				for(int i = 1;i<=num;i++) {
					if(i==co)continue;
					System.out.println(i);

				}
			}

		}


	}



}


Measured memory_bytes: 76468
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int M = nextInt();

		int[][] AB = new int[N][2];
		for(int i=0;i<N;i++) {
			AB[i] = nextIntArray(2);
		}
		Arrays.sort(AB,(a1,a2)->Integer.compare(a2[1],a1[1]));
		Arrays.sort(AB,(a1,a2)->Integer.compare(a1[0],a2[0]));

		List<Integer> list = new ArrayList<Integer>(N);
		long sum = 0;
		int AB_i = 0;
		for(int l=1;l<=M;l++) {
			int Search_l = -1;
			while(AB_i<N&&AB[AB_i][0]==l) {
				int Insert_i = Search(list ,AB[AB_i][1],Search_l);
				if(M<Insert_i)break;// 候補外となるため挿入する必要なし
				list.add(Insert_i,AB[AB_i][1]);
				AB_i++;
			}

			if(list.size()>0) {
				sum+=list.get(0);
				list.remove(0);
			}
		}

		out.println(sum);
	}

	//二部探索
	static int Search(List<Integer> list, int k, int Search_l) {
		int l = Search_l;
		int r = list.size();
		while(r - l > 1) {
			int mid = (r + l) / 2;
			if(list.get(mid) <= k) r = mid;
			else l = mid;
		}
		return r;
	}


	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);
	}
}

Measured memory_bytes: 64204
#include <stdio.h>

int main()
{
    int a, b, sum, multi;
    scanf("%d%d", &a, &b);
    sum = a + b;
    multi = a * b;
    if(sum == 15 ){
        printf("+", sum);
    }
    else if(multi == 15){
        printf("*", multi);
    }
    else{
        printf("x");
    }


    return 0;
}



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

#define fordebug int hoge;cin>>hoge;

#define DEKAI 1000000007
#define floot10 cout<<fixed<<setprecision(15)
#define all(v) v.begin(),v.end()
double PI = acos(-1);

signed main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  a--,b--,c--,d--;
  string s;
  cin>>s;
  string ans="Yes";
  
  //まずは、一人だけの時辿り着けるか考える
  //間に石が２個 並んでたら無理
  //a-c
  for(int i=a+1;i<=c;i++){
    if(s[i]=='#'&&s[i-1]=='#'){
      ans="No";
    }
  }

  //b-d
  for(int i=b+1;i<d;i++){
    if(s[i]=='#'&&s[i-1]=='#'){
      ans="No";
    }
  }

  //追い越し必要？
  if(b<c&&d<c){
    //マスが3つ連続で空いてないとダメ！
    //追い越せるのはb-dの間
    bool check=false;
    for(int i=b+1;i<=d+1;i++){
      if(s[i-2]=='.'&&s[i-1]=='.'&&s[i]=='.'){
        check=true;
      }
    }
    if(check==false){//falseのままだったら、追い越せないのでNO
      ans="No";
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3676
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;
        for (int i=0;i<n;i++){
            long x = sc.nextLong();
            long y = sc.nextLong();
            if (true){
                if (Math.sqrt(x*x+y*y)<=d)ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 48676
#include<stdio.h>
int main()
{
    long long a,b,n;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(n>1&&b>=a||n==1&&a==b)
    {
        printf("%lld",(n-2)*(b-a)+1);
    }
    else
    {
        printf("0");
    }
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
int a, b;
int main(){
	scanf("%d %d", &a, &b);
	for(int i = 1; i <= 3; i++)
		if(a * b * i % 2) return !printf("Yes\n");
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){

    int n,w,h;
    cin>>w>>h>>n;
    int x,y;
    cin>>x>>y;
    int ans = 0;
    for(int i = 1;i < n;i++){
        int X,Y;
        cin>>X>>Y;
        if((X-x)*(Y-y)>0)ans += max(abs(X-x),abs(Y-y));
        else ans += abs(X-x) + abs(Y-y);
        x = X,y = Y;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1160
N, M = list(map(int,input().split()))
A = sorted(list(map(int,input().split())), reverse=True)
b = []

b.append(A.pop(0)//2)
for i in range(1,M):
    if A == []:
        b.append(b.pop(0)//2)
    else:
        if A[0] > b[0]:
            b.append(A.pop(0)//2)
        else:
            b.append(b.pop(0)//2)

print(sum(A)+sum(b))

Measured memory_bytes: 20084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
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


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >

const int MAX = 1e4+5;
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;cin>>n;
	bitset<MAX> B;
	B[0] = 1;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		B = B | (B<<a) ;
	}	
	int ans =0 ;
	for(int i=0;i<MAX;i++){
		if((i%10) ==0)continue;
		if(B[i])ans = max(ans, i);
	}
	cout<<ans;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int h=sc.nextInt();
    int n=sc.nextInt();
    int a[]=new int[n];
    int total=0;
    for (int i=0;i<n;i++) {
      a[i]=sc.nextInt();
      total+=a[i];
    }

    if (h-total<=0) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }


  }
}


Measured memory_bytes: 51292