akhauriyash/Code-Regression huggingface dataset:
using System;
 
namespace _135C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] read = Console.ReadLine().Split();
            long a = long.Parse(read[0]);
            long b = long.Parse(read[1]);
            long c = long.Parse(read[2]);
            bool res = true;
            if(a+b>=c)res = false;
            else if(4*a*b >= (c-a-b)*(c-a-b)) res = false;
            else res = true;
            Console.WriteLine(res?"Yes":"No");
        }
    }
}

Measured memory_bytes: 11092
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());

    let (n, m) = (it.next().unwrap(), it.next().unwrap());

    let mut v: Vec<u32> = Vec::with_capacity(n);
    for _ in 0..n {
        v.push(0);
    }
    //    println!("{}", v.len());
    for _ in 0..m {
        let mut buf = String::new();
        stdin.read_line(&mut buf).ok();
        let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
        let (a, b) = (it.next().unwrap(), it.next().unwrap());
        v[a - 1] += 1;
        v[b - 1] += 1;
    }
    //    println!("{}", v.len());

    for i in 0..v.len() {
        println!("{}", v[i]);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

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

  int N;
  cin >> N;

  int count = 0;
  for (int i = 1; i <= N; i++) {
    int x = i;
    int dig = 0;
    while (x > 0) {
      x /= 10;
      dig++;
    }
    if (dig % 2 == 1) count++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit((10 ** 6))
input = sys.stdin.readline
N, M, P = map(int, input().split())
INF = float('inf')
G = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a, b, c = a - 1, b - 1, c - P
    G[a].append((b, -c))
dist = [INF] * N
dist[0] = 0
for i in range(N):
    for e in range(N):
        for w, c in G[e]:
            if dist[e] != INF and dist[w] > dist[e] + c:
                dist[w] = dist[e] + c

ans = -dist[N - 1]
is_negative = [False] * N
for i in range(N):
    for e in range(N):
        for w, c in G[e]:
            if dist[e] != INF and dist[w] > dist[e] + c:
                dist[w] = dist[e] + c
                is_negative[w] = True

            if is_negative[e]:
                is_negative[w] = True

if is_negative[N - 1]:
    print(-1)
else:
    print(max(ans, 0))


Measured memory_bytes: 52956
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename A, typename B>
std::ostream& operator<<(std::ostream& os, std::pair<A, B>& v) {
    return os << "(" << v.first << " " << v.second << ")";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& v) {
    os << "[ "; for (auto &i: v) os << i << " "; return os << "]";
}

template <typename T>
void eout(const char *s, T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, T1 H, T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(args...)      std::cerr << "DBG:"; eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

#define INF    	          2147483647
#define LNF               9223372036854775807LL

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

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

    //inn(t); repr(tc, 1, t + 1)
    (void) solve();

    return 0;
}

int solve() {
    inn(n); inn(d);
    int x[n][d]; rep(i, n) rep(j, d) in(x[i][j]);

    int ans = 0;
    rep(i, n) {
        repr(j, i + 1, n) {
            int dist = 0;
            rep(k, d) {
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            int m = (int) sqrt(dist);
            if (m*m == dist) ++ans;
        }
    }
    out(ans);
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    for(int i=0;i<tx-sx;i++){
        cout<<'R';
    }
    for(int i=0;i<ty-sy;i++){
        cout<<'U';
    }
    for(int i=0;i<tx-sx;i++){
        cout<<'L';
    }
    for(int i=0;i<ty-sy;i++){
        cout<<'D';
    }
    cout<<'L';
    for(int i=0;i<=ty-sy;i++){
        cout<<'U';
    }
    for(int i=0;i<=tx-sx;i++){
        cout<<'R';
    }
    cout<<'D';
    cout<<'R';
    for(int i=0;i<=ty-sy;i++){
        cout<<'D';
    }
    for(int i=0;i<=tx-sx;i++){
        cout<<'L';
    }
    cout<<'U'<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdint.h>
int main(void)
{
    int is_good[100001];
    for (int i = 0; i < 100001; i++)
    {
        is_good[i] = 1;
    }
    int N, M;
    scanf("%i %i", &N, &M);
    int height[100000];
    for (int i = 1; i <= N; i++)
    {
        scanf("%i", &height[i]);
    }
    for (int i = 1; i <= M; i++)
    {
        int A, B;
        scanf("%i %i", &A, &B);
        if (height[A] >= height[B])
        {
            is_good[B] = 0;
        }
        if (height[A] <= height[B])
        {
            is_good[A] = 0;
        }
    }
    int sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (is_good[i])
        {
            sum++;
        }
    }
    printf("%i\n", sum);
    return 0;
}

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

#define int long long
#define endl  '\n'
const int mod = 1e9 + 7;
// Tushar Goyal : Chalie Shuru karte hai

void solve()
{
	int h, w;
	cin >> h >> w;
	string mat[h];

	for (int i = 0 ; i < h ; i++)
	{
		cin >> mat[i];
	}

	// for (int i = 0 ; i < h ; i++)
	// {
	// 	for (auto c : mat[i])cout << c << " ";
	// 	cout << endl;
	// }

	vector<vector<int>> dp(h, vector<int>(w, 0));

	dp[0][0] = 1;
	// filling first row
	for (int i = 1; i < w ; i++)
	{
		if (mat[0][i] == '.')dp[0][i] += dp[0][i - 1];
		else dp[0][i] = 0;
		dp[0][i] %= mod;
	}

	// filling first column
	for (int i = 1 ; i < h ; i++)
	{
		if (mat[i][0] == '.')dp[i][0] += dp[i - 1][0];
		else dp[i][0] = 0;
		dp[i][0] %= mod;
	}

	for (int i = 1 ; i < h ; i++)
	{
		for (int j = 1 ; j < w; j++)
		{
			if (mat[i][j] == '#')dp[i][j] = 0;
			else dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= mod;
		}
	}

	cout << dp[h - 1][w - 1] << endl;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int a=0,b=0;
  
  for(int i=0;i<s.size();i++){
    
    if(s[i] == 'S'){
       a++;
    }
    
    else{
      b++;
      if(a>0){
        a--;
        b--;
      }
      
    }
    
    
    
  }
     cout << a + b << endl;
}


Measured memory_bytes: 640
// ABC152B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
using namespace std; //std::を省略できる
int main()
{
	int a, b;
	cin >> a >> b;
	if (a>=b) // bが小さい時
	{
		for (int i = 0; i < a; i++)
		{
			cout << b;
		}
		cout << endl;
	}
	else {
		// aが小さい時
		for (int i = 0; i < b; i++)
		{
			cout << a;
		}
		cout << endl;
	}
}


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

//グローバル変数の宣言
string line = "";

int kaibun(int start, int goal){
    int output = 0;  //output = 1>>回文でない output= 0>>回文
    int n = 0; //文字列の長さを取得
    int i;
    n = goal - start + 1;
    // for(i=0;i<n;i++){
    //     cout<<line[start+i];
    // }
    // cout<<endl;

    for (i=0;i< (n/2);i++){
        if (line[start + i] != line[goal - i] ){
            output = 1;
        }
    }
    return output;
}

int main(void){
    int output=0,n;
    cin >> line;
    n = line.size();
    output += kaibun(0,n-1);
    output += kaibun(0,(n-1)/2 -1);
    output += kaibun((n+3)/2 -1 , n-1);
    if (output == 0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, vector<long long> x, vector<long long> y){
	ll res = 1000;
	rep(i,N) {
		rep(j,N) {
			long long cx = x[i]-x[j], cy = y[i]-y[j];
			// cout << i << " " << j << " " << cx << " " << cy << endl;
			long long c = 0;
			rep(k,N) {
				rep(l,N) {
					if (k != l && x[k]-x[l] == cx && y[k]-y[l] == cy) c++;
				}
			}
			res = min(res, N-c);
		}
	}	
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> y(N-1+1);
	vector<long long> x(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
	}
	solve(N, x, y);
	return 0;
}



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

using namespace std;

int main(void) {
	int N;
	cin >> N;

	int a, b, c, i;
	vector<string> res;
	for (i = 0; i < N; i++) {
		cin >> a >> b >> c;

		int aj = a * a;
		int bj = b * b;
		int cj = c * c;

		if (aj < bj) {
			if (bj < cj) {
				if (cj == aj + bj) {
					res.push_back("YES");
				}
				else {
					res.push_back("NO");
				}
			}
			else {
				if (bj == aj + cj) {
					res.push_back("YES");
				}
				else {
					res.push_back("NO");
				}
			}
		}
		else {
			if (aj < cj) {
				if (cj == aj + bj) {
					res.push_back("YES");
				}
				else {
					res.push_back("NO");
				}
			}
			else {
				if (aj == bj + cj) {
					res.push_back("YES");
				}
				else {
					res.push_back("NO");
				}
			}
		}
	}

	for (i = 0; i < res.size(); i++) {
		cout << res[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3064
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] -= 1

P = [-1]*N
P[0] = 0

cnt = 0
NOW = 0
while True:
    NOW = A[NOW]
    cnt += 1
    if P[NOW] == -1:
        P[NOW] = cnt
        if cnt == K:
            print(NOW+1)
            exit()
    else:
        L = cnt - P[NOW]
        for i in range(P[NOW],P[NOW]+L):
            if K % L != i % L:
                continue
            for k,v in enumerate(P):
                if v == i:
                    print(k+1)
                    exit()

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

int main(){
//srandom((unsigned long)time(NULL));
long long n;
cin>>n;
vector<long long> a;
long long sum=0;
for(long long i=0;i<n+1;i++){
    long long x;
    cin>>x;
    sum+=x;
    a.emplace_back(x);
}
vector<long long> b;
for(long long i=0;i<n;i++){
    long long x;
    cin>>x;
    b.emplace_back(x);
}
long long cnt=0;
for(long long i=n-1;i>=0;i--){
//Biについて後ろからみていく
   if(a[i+1]>=b[i] && b[i]>=0){
       a[i+1]-=b[i];
       cnt+=b[i];
       b[i]=0;
   }
   if(b[i]>a[i+1] && a[i+1]>=0){
      cnt+=a[i+1];
       b[i]-=a[i+1];
        a[i+1]=0;
   }
   if(a[i]>=b[i] && b[i]>=0){
       a[i]-=b[i];
       cnt+=b[i];
       b[i]=0;
   }
   if(b[i]>a[i] && a[i]>=0){
       b[i]-=a[i];
       cnt+=a[i];
       a[i]=0;
   }
   //cout<<"cnt="<<cnt<<endl;
}
cout<<cnt<<endl;

return 0;
}

Measured memory_bytes: 2548
n = int(input())
a = list(map(int, input().strip().split()))
s = 0
for i in range(n):
	s += a[i]
mn = abs(a[0] * n - s)
ans = 0
for i in range(1, n):
	if (abs(a[i] * n - s) < mn):
		mn = abs(a[i] * n - s)
		ans = i
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

#ifdef LOCAL
clock_t timer = clock();
#endif

ll dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int N, W;
	cin >> N >> W;
	int w[N], v[N];
	for(int i = 0; i < N; i++){
		cin >> w[i] >> v[i];
	}
	for(int i = 0; i < N; i++){
		for(int j = W - w[i]; j >= 0; j--){
			dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
		}
	}
	ll ans = 0;
	for(int i = 0; i <= W; i++){
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
#ifdef LOCAL
        cout << "Total Time: " << (double)(clock() - timer) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
from functools import lru_cache

def solve(n,a,b,c,d):
    @lru_cache(None)
    def rec(cur):
        if cur == 0:    return 0
        if cur == 1:    return d
        ret = cur * d
        p,q = divmod(cur, 2)
        if q == 0:  ret = min(ret, rec(p) + a)
        if q == 1:  ret = min(ret, rec(p) + a + d, rec(p + 1) + a + d)
        p,q = divmod(cur, 3)
        if q == 0:  ret = min(ret, rec(p) + b)
        if q == 1:  ret = min(ret, rec(p) + b + d)
        if q == 2:  ret = min(ret, rec(p) + b + d * 2, rec(p + 1) + b + d)
        p,q = divmod(cur, 5)
        if q == 0:  ret = min(ret, rec(p) + c)
        if q == 1:  ret = min(ret, rec(p) + c + d)
        if q == 2:  ret = min(ret, rec(p) + c + d * 2)
        if q == 3:  ret = min(ret, rec(p) + c + d * 3, rec(p + 1) + c + d * 2)
        if q == 4:  ret = min(ret, rec(p) + c + d * 4, rec(p + 1) + c + d)
        return ret

    return rec(n)

for _ in range(int(input())):
    n,a,b,c,d = map(int,input().split())
    print(solve(n,a,b,c,d))

Measured memory_bytes: 136460
#include<bits/stdc++.h>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	int x, n, max_value = 10000, cnt = 0;
	cin >> x >> n;
	vector<int> v(101, 0);
	for(int i = 0; i < n; ++i)  {
		int y; 
		cin >> y;
		++v[y];
		}
	for(int i = 0; i <= 101; ++i) {
		if(!v[i]) {
			if(max_value > abs(x - i)) {
				max_value = abs(x - i);
				cnt = i;
				}
			}
		}
		cout << cnt << endl;
 }

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
	solve();
	return 0;
}
 
 
 
 
 
 


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

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

		bool map[100][100] = { false };
		REP(i, N) {
			int x, y;
			cin >> x >> y;
			map[y-1][x-1] = true;
		}

		int S, T;
		cin >> S >> T;
		int ans[100][100] = {};

		int cnt = 0;
		REP(i, H-T+1) {
			REP(j, W-S+1) {
				FOR(k, i, i+T) {
					FOR(l, j, j+S) {
						if(map[k][l]) ans[i][j]++;
					}
				}
				cnt = cnt > ans[i][j] ? cnt : ans[i][j];
			}
		}
//		REP(i, H) {
//			REP(j, W)
//				cout << ans[i][j] << ' ';
//			cout << endl;
//		}

		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  if (s.size() % 2) {
    cout << "No" << '\n';
    return;
  }
  for (int i = 0; i < s.size(); i++) {
    if ((i % 2 == 0 && s[i] != 'h') || (i % 2 && s[i] != 'i')) {
      cout << "No" << '\n';
      return;
    }
  }
  cout << "Yes" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3488
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int A = Integer.parseInt(in.nextLine());
		int B = Integer.parseInt(in.nextLine());
		int C = Integer.parseInt(in.nextLine());
		int D = Integer.parseInt(in.nextLine());
		in.close();
		int result = Math.min(A, B) + Math.min(C, D);
		System.out.println(result);

	}

}

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

#define REP(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e9

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

typedef long long ll;

using namespace std;

#define ChangeToInt(str) (int)str - 48 

int main(int argc, char const *argv[])
{
    char S[20];
    REP(i,20){S[i] = 'z';}
    int ans = INF;
    cin >> S;

    int i = 2;
    while (S[i] != 0)
    {
        int a,b,c;

        a = ChangeToInt(S[i-2]);
        b = ChangeToInt(S[i-1]);
        c = ChangeToInt(S[i]);

        int tmp = abs(753 - (a * 100 + b * 10 + c));

        if(ans > tmp) ans = tmp;
        i++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
// macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    let (n, k, q) = readl!(usize, usize, usize);
    let a = readlvec!(i64);

    let mut b = a.clone();
    b.sort();
    b.dedup();
    let mut fv = vec![false; n];
    let mut ans = 1_000_000_000_000;
    for rm in b {
        debug!(rm);
        let mut ta = Vec::new();
        let mut l = 0;
        let mut r = 0;
        while l < n {
            let mut v = Vec::new();
            while r < n && !fv[r] {
                v.push(a[r]);
                r += 1;
            }
            if k <= v.len() {
                v.sort();
                for &e in v.iter().take(v.len()-k+1) {
                    ta.push(e);
                }
            }
            if l == r {
                l += 1;
                r += 1;
            } else {
                l = r;
            }
        }
        debug!(ta);
        if ta.len() > q-1 {
            ta.sort();
            debug!(ta[q-1]-ta[0]);
            ans = min(ans, ta[q-1]-ta[0]);
        }
        for (i, _) in a.iter().enumerate().filter(|&(_, &e)| e == rm) {
            fv[i] = true;
        }
    }
    printfln!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

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

long long pow(const long long &v, const long long &n, const long long &mod)
{
    long long ret = 1;
    long long num = n;
    long long now = v;
    
    while (num > 0)
    {
        if (num & 1)
        {
            ret = ret * now % mod;
        }
        now = now * now % mod;
        num = num >> 1;
    }
    
    return ret;
}

int main() {

    
    ll p;
    cin >> p;
    ll mod = p;
    
    vector<ll> v(p);
    for (int i = 0; i < p; ++i)
    {
        cin >> v[i];
    }
    
    vector<ll> fac = vector<long long>(p + 1, 1);
    vector<ll> inv = vector<long long>(p + 1, 1);
    
    for (int i = 1; i <= p; ++i)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = pow(fac[i], mod - 2, mod);
    }
    
    vector<ll> vb(p);
    
    vector<ll> powp(p + 1);
    
    for (int i = 0; i < p; ++i)
    {
        powp[i] = pow(p - 1, i, p);
    }
    
    for (int i = 0; i < p; ++i)
    {
        if (v[i])
        {
            vb[0] += 1ll;
            vb[0] %= mod;
            ll iii = i;
            
            vector<ll> pp(p);
            ll ppp = 1;
            for (int j = 0; j < p; ++j)
            {
                pp[j] = ppp;
                ppp *= i;
                ppp %= mod;
            }
            
            for (int j = 0; j < p; ++j)
            {
                ll ii = powp[p - 1 - j];
                vb[j] -= (ii * ((fac[p - 1] * inv[j] % mod * inv[p - 1 - j] % mod) * pp[p - 1 - j] % mod) % mod);
                vb[j] += mod;
                vb[j] %= mod;
                iii *= i;
                iii %= mod;
            }
        }
    }
    
    for (int i = 0; i < p; ++i)
    {
        cout << vb[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 
typedef struct _card {
    int number;
    char suit;
} CARD;
 
CARD A[100000], I[100000];
char inputs[1000000];
char *ptr = inputs;
 
void exchange(CARD *a, CARD *b);
int Partition(CARD A[], int p, int r);
void Quicksort(CARD A[], int p, int r);
 
int nextInt(void) {
    int v = 0;
    while (*ptr < '0' || *ptr > '9') ++ptr;
    while (*ptr >= '0' && *ptr <= '9') {
        v = v * 10 + (int)(*ptr - '0');
        ++ptr;
    }
    return v;
}
 
char nextSuit(void) {
    while (*ptr < 'A' || *ptr > 'Z') ++ptr;
    return *ptr;
}
 
int main(void) {
    int n;
    int stable = 1;
    int i, j, c, d;
     
    fread(inputs, sizeof(char), 1000000, stdin);
     
    n = nextInt();
     
    for (i = 0; i < n; ++i) {
        A[i].suit = nextSuit();
        A[i].number = nextInt();
        I[i] = A[i];
    }
     
    Quicksort(A, 0, n - 1);
     
    for (i = 0; i < n; ++i) {
        if (i == 0) {
            c = 0;
        } else if (A[i].number != A[i - 1].number) {
            c = 0;
        } else {
            ++c;
        }
        d = 0;
        for (j = 0; j < n; ++j) {
            if (I[j].number == A[i].number) {
                if (c == d) {
                    if (I[j].suit != A[i].suit) {
                        stable = 0;
                    }
                    break;
                }
                ++d;
            }
        }
        if (stable == 0) {
            break;
        }
    }
     
    if (stable == 1) {
        puts("Stable");
    } else {
        puts("Not stable");
    }
     
    for (i = 0; i < n; ++i) {
        printf("%c %d\n", A[i].suit, A[i].number);
    }
     
    return 0;
}
 
void exchange(CARD *a, CARD *b) {
    CARD t = *a;
    *a = *b;
    *b = t;
}
 
int Partition(CARD A[], int p, int r) {
    CARD x = A[r];
    int i = p - 1;
    int j;
    for (j = p; j < r; ++j) {
        if (A[j].number <= x.number) {
            ++i;
            exchange(&A[i], &A[j]);
        }
    }
    exchange(&A[i + 1], &A[r]);
    return i + 1;
}
 
void Quicksort(CARD A[], int p, int r) {
    int q;
    if (p < r) {
        q = Partition(A, p, r);
        Quicksort(A, p, q - 1);
        Quicksort(A, q + 1, r);
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int m;cin>>m;

  out(48-m);

  return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = collections.Counter(a)

ans = sum(a)

for i in range(q):
    b,c = map(int, input().split())
    B = dic[b]
    ans = ans + (c-b) * B
    print(ans)
    dic[b] = 0
    dic[c] = dic[c] + B

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

bool solve(int i, int m, const vector<int> &A) {
  if (m == 0) return true;
  if (i >= A.size()) return false;
  return solve(i + 1, m, A) || solve(i + 1, m - A.at(i), A);
}
int main() {
  int n, q, m;
  cin >> n;
  vector<int> A(n);
  for (size_t i = 0; i < n; i++) {
    cin >> A.at(i);
  }
  cin >> q;

  for (size_t i = 0; i < q; i++) {
    cin >> m;
    if (solve(0, m, A)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}


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

int main(){
    int N;
    long long K;
    cin >> N >> K;
    vector<int> edge[N+1];
    int a, b;
    rep(i, N-1){
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> par[N+1];
    vector<int> chl[N+1];
    bool check[N+1];
    fill_n(check, N+1, true);
    queue<int> que;
    que.push(1);
    check[1] = false;
    while(!que.empty()){
        int i = que.front();
        rep(j, edge[i].size()){
            int k = edge[i][j];
            if(check[k]){
                check[k] = false;
                chl[i].push_back(k);
                que.push(k);
                par[k].push_back(i);
            }
        }
        que.pop();
    }
    long long ans = K;
    long long MOD = 1e9 + 7;
    queue<int> que2;
    que2.push(1);
    while(!que2.empty()){
        int i = que2.front();
        long long c = chl[i].size();
        long long p = par[i].size();
        rep(j, c){
            ans *= K-1-p-j;
            ans %= MOD;
            int k = chl[i][j];
            que2.push(k);
        }
        que2.pop();
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(vector<T> v)
{
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}



int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, a, b, ev;
    cin >> n >> m;
    vector<int> deg(n, 0);

    rep(i, m)
    {
        cin >> a >> b;
        a--, b--;
        deg[a]++, deg[b]++;
    }

    ev = 0;
    rep(i, n) if (deg[i]  % 2 == 0) ev++;
    
    cout << ( (ev == n) ? "YES" : "NO") << rt;

    return 0;
}


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

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

  queue<long long> L;
  for (int i = 1; i <= 9; i++) {
    L.push(i);
  }

  long long ans;
  for (int i = 0; i < K; i++) {
    ans = L.front();
    L.pop();
    if (ans % 10 != 0) L.push(10 * ans + (ans % 10) -1);
    L.push(10 * ans + (ans % 10));
    if (ans % 10 != 9) L.push(10 * ans + (ans % 10) +1);
  }

  cout << ans << endl;
}

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

int a[3003] , pr[3003];
int dp[3003][3003];


int f(int i, int j) {
  if (dp[i][j]) 
    return dp[i][j];
  int r;
  if (i == j) 
    r = a[i];
  else if (i + 1 == j) 
    r = max(a[i], a[j]);
    
  else
    r = max(  min(f(i+1, j-1), f(i+2, j)) + a[i], min(f(i, j-2), f(i+1, j-1)) + a[j]);
  dp[i][j] = r;
  return r;
}


main()
{
	int n , sum = 0;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		scanf("%lld" , &a[i]);
		pr[i] = pr[i-1] + a[i];
		sum += a[i];
	}
	
	cout << f(1 , n) * 2 - sum << endl;
	
}


Measured memory_bytes: 70144
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ




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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  int m = n*3 ;
  vector<ll> vec(m) ;
  ll ans = 0 ;
  REP(i,m){
    cin >> vec.at(i) ;
  }
  sort(ALL(vec)) ;
  reverse(ALL(vec)) ;
  
  REP(i,n){
    ans += vec.at(i*2+1) ;
  }
  
  cout <<ans <<endl ;
    
    
    
  
  
  
  return 0 ;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
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 gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

const int MAX = 210000;
int Q;
ll type[MAX], a[MAX], b[MAX];

int main(){
  cin >> Q;

  ll sum = 0;
  priority_queue<ll> zen;//前半は降順
  priority_queue<ll, vector<ll>, greater<ll>> kou;//後半は昇順
  ll zensum = 0, kousum = 0;

    for (int i = 0; i < Q; ++i) {
        cin >> type[i]; //クエリタイプ判定
        if (type[i] == 1) { //更新クエリなら
            cin >> a[i] >> b[i];
            sum += b[i]; //bを足しこむ

            if (zen.size() > kou.size()) { //前半の数値の数の方が多ければ
              //後半の処理をする
              int t = zen.top();//一番上の数字を取り出す
                if (a[i] >= t) { //クエリで取得した数字が前半のtopの数字以上なら
                    kou.push(a[i]); kousum += a[i]; //後半のqueueにpushしてkousumに足す
                }
                else {//クエリで取得した数字がtopの数字未満なら
                    zen.pop(); zensum -= t; //前半をpopしてzensumからtを引く
                    zen.push(a[i]); zensum += a[i];//前半にpushする
                    kou.push(t); kousum += t;//後半にtをpushする（=前半から移し替える）
                }
            }
            else {
                //前半と後半の数が同じなら
                if (zen.empty()) zen.push(a[i]), zensum += a[i];//一番最初のクエリなら前半にpushして終了
                else {//それ以降
                    int t = kou.top(); //後半のtopを取得
                    if (a[i] <= t) { //クエリで取得した数字がt以下なら
                        zen.push(a[i]); zensum += a[i];//前半にpush
                    }
                    else { //クエリで取得した数字がtより大きければ
                        kou.pop(); kousum -= t; //後半からtをpopする
                        kou.push(a[i]); kousum += a[i]; //クエリで取得した数を後半にpush
                        zen.push(t); zensum += t; //前半にtをpushする
                    }
                }
            }
        }//求値クエリなら
        else {
            long long x = zen.top(); //前半のtopを取得（中央値）
            long long res = (x * (int)zen.size() - zensum) + (kousum - x * (int)kou.size()) + sum;
            cout << x << " " << res << endl;
        }
    }
  return 0;
}

Measured memory_bytes: 8564
#include<bits/stdc++.h>
using namespace std;
#define int long long
int memo[2222][10];
vector<int> v[10];
int dfs(int b,int c){
  //cout<<b<<" "<<c<<endl;
  if(c==10) return 0;
  if(~memo[b][c]) return memo[b][c];
  int res=dfs(b,c+1),tmp=0;
  for(int i=0;i<(int)v[c].size();i++){
    if(b-(i+1)<0) break;
    tmp+=v[c][i];
    res=max(res,(tmp+i*(i+1))+dfs(b-(i+1),c+1));
  }
  //cout<<b<<" "<<c<<" "<<res<<endl;
  return memo[b][c]=res;
}
signed main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    int c,g;
    cin>>c>>g;
    v[g-1].push_back(c);
  }
  for(int i=0;i<10;i++) sort(v[i].rbegin(),v[i].rend());
  /*
  for(int i=0;i<10;i++){
    cout<<i<<":";
    for(int j=0;j<(int)v[i].size();j++) cout<<v[i][j]<<" ";
    cout<<endl;
  }
  */
  memset(memo,-1,sizeof(memo));
  cout<<dfs(k,0)<<endl;
  return 0;
}

Measured memory_bytes: 3328
a,b=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
ans=0
if sum(L)<b:
  print(a-1)
elif sum(L)==b:
  print(a)
else:
  for i in range(a):
    ans+=L[i]
    if ans>b:
      print(i)
      exit()

Measured memory_bytes: 9100
import java.util.*;

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

    int[] A = new int [N];
    for(int n = 0; n < N; n++) {
      A[n] = sc.nextInt();
      sum = sum + A[n];
    }

    if(sum >= H) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 49604
#include<iostream>
#include<cmath>

int main(){
    int X;
    std::cin >> X;
    int maxVal = 1;
    for(int b = 2; b <= std::sqrt(X); b++){
        int tmp = b;
        while(tmp <= X){
            tmp *= b;
        }
        maxVal = std::max(maxVal, tmp / b);
    }

    std::cout << maxVal << std::endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline

n = int(input())
c = list(input())

red = deque()
white = deque()

for i in range(n):
    if c[i] == "W":
        white.append(i)
    else:
        red.append(i)

s = 0

while len(white) > 0 and len(red) > 0:
    w = white.popleft()
    r = red.pop()
    if w < r:
        s += 1
    else:
        break

print(s)
    

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

#define N 200010
int n, a[N], b[N];

bool ok() {
	for (int i = 1; i <= n; ++i) {
		int tot = 0;
		for (int j = i; j <= n; j += i) {
			tot = tot + b[j];
			tot %= 2;
		}
		if (tot ^ a[i]) return 0;
	}
	return 1;
}

int main() {
	while (scanf("%d", &n) != EOF) {
		for (int i = 1; i <= n; ++i) scanf("%d", a + i);
		for (int i = n; i >= 1; --i) {
			int now = 0;
			for (int j = i + i; j <= n; j += i) {
				now += b[j];
				now %= 2;
			}
			b[i] = now ^ a[i];
		}
		if (ok()) {
			vector <int> vec;
			for (int i = 1; i <= n; ++i) if (b[i]) vec.push_back(i);
			int sze = (int)vec.size();
			printf("%d\n", sze);
			for (int i = 0; i < sze; ++i) printf("%d%c", vec[i], " \n"[i == sze - 1]);
		} else puts("-1");
	}
	return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>

int main()
{
    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;

    int ans = 0;
    std::set<char> types;
    for (int i = 1; i < N; i++)
    {
        std::string back = S.substr(i, N - i);
        types.emplace(S[i - 1]);

        int cnt = 0;
        for (auto& c : types)
        {
            for (int k = 0; k < (int)back.size(); k++)
            {
                if (c == back[k])
                {
                    cnt++;
                    break;
                }
            }
            ans = std::max(cnt, ans);
        }
    }

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N, i, r=0, b=0;
  cin >> N;
  char s[N];
  for(i=0; i<N; i++) cin >> s[i];
  for(i=0; i<N; i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'B') b++;
  }
  if(r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int MAXN = 1e3 + 1;
const ll INF = 1e18;
const ld pi = acos(-1);

int n, m;
char c[MAXN][MAXN];

int main() {

    faster();

    cin >> n >> m;
 
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> c[i][j];
        }
    } 

    if(c[0][0] != '#'){
        cout << "Impossible";
        return 0;
    }

    int x = 0, y = 0;
    c[x][y] = '.';

    for(int i = 0; i < n + m - 2; ++i){
        if(y + 1 < m && c[x][y + 1] == '#')
            y++;
        else if(x + 1 < n && c[x + 1][y] == '#')
            x++;
        c[x][y] = '.';
    } 


    if(x != n - 1 || y != m - 1){
        cout << "Impossible";
        return 0;
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(c[i][j] == '#'){
                cout << "Impossible";
                return 0;
            }
        }
    } 

    cout << "Possible";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    string s,t;
    cin >> s >> t;
    for(int i=0;i<n;i++){
        cout << s.at(i) << t.at(i) ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
int lcm(int a, int b)
{
  return a / __gcd(a, b) * b;
}
void solve()
{
  int n;
  cin >> n;
  int a[n], ans = 0;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n; j++)
    {
      for (int k = j + 1; k < n; k++)
      {
        if (a[i]!=a[j]&&a[j]!=a[k]&&a[i] + a[j] > a[k])
        {
         //
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc;
  tc = 1;
  //cin >> tc;
  while (tc--)
  {
    solve();
  }

  return 0;
}

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

enum COLOR{
  BLACK,
  WHITE,
  NONE
};

ll N;
vector<vector<pair<ll, ll>>> G;
vector<COLOR> color;

void dfs(ll u, ll sum_w){
  for(ll i = 0; i < (ll)G[u].size(); i++){
    pair<ll, ll> _v = G[u][i];
    ll v = _v.first;
    ll w = _v.second;
    if(color[v] != NONE) continue;
    if((sum_w + w) % 2LL == 0LL){
      color[v] = BLACK;
    }else{
      color[v] = WHITE;
    }
    dfs(v, (sum_w + w) % 2LL);
  }
}

int main(void){
  ll N; cin >> N;
  G = vector<vector<pair<ll, ll>>>(N); // (dest, weight)
  color = vector<COLOR>(N,NONE);
  for(ll i = 1; i < N; i++){
    ll u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    G[u].push_back(make_pair(v,w));
    G[v].push_back(make_pair(u,w));
  }
  color[0] = BLACK;

  dfs(0, 0);

  for(ll i = 0; i < (ll)color.size(); i++){
    cout << color[i] << endl;
  }
}


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


typedef unsigned long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
const int N=10005, mxN=(1<<20)+5;
int mod=998244353 ;

ll mul(ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add(ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)
        ans=mul(ans,b);
    return ans;
}
ll fac(ll n)
{
    ll ans=1;
    while(n)
    {
        ans=mul(ans,n--);
    }
    return  ans;
}
ll ncr(ll n, ll r)
{
    ll ans=fac(n);
    ll m=mul(fac(r),fac(n-r));
    ans=mul(ans,fastpow(m,mod-2));
    return ans;
}
    ll l,r;
ll co(ll x)
{
    ll c=r/x;
    c-=(l-1)/x;
        return c;

}

int main()
{
    FIO
    cin>>l>>r;
    ll a,b;
    cin>>a>>b;
    ll ans=r-l+1;
   // cout<<ans<<endl;
    ans-=co(a)+co(b)-co(a*b/__gcd(a,b));
    cout<<ans;

    return 0;
}


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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

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

	cin >> s >> w;

	for (int i = 0; i < s.size(); i += w)
		cout << s[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<long long int>> vec(n,vector<long long int>(2));
  for(int i=0;i<n;i++){
    cin >> vec.at(i).at(0) >> vec.at(i).at(1);
  }
  sort(vec.begin(),vec.end());
  long long int ans = 0;
  for(int i=0;i<n;i++){
    if (m > vec.at(i).at(1)){
      m -= vec.at(i).at(1);
      ans += vec.at(i).at(0) * vec.at(i).at(1);
    }
    else{
      ans += vec.at(i).at(0)*m;
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

bool match(char c, char h) { return c == '?' || h == '?' || c == h; }

bool ok[3][3][5000];

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        string s[3];
        cin >> s[0] >> s[1] >> s[2];
        memset(ok, true, sizeof ok);
        for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                        for (int k = 0; k < s[i].size(); k++) {
                                for (int t = k, r = 0; t < s[i].size() && r < s[j].size(); t++, r++) {
                                        ok[i][j][k] &= match(s[i][t], s[j][r]);
                                }
                        }
                }
        }
        int ans = 6000;
        for (int i = 0; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                        if (i == j) {
                                continue;
                        }
                        for (int k = 0; k < 3; k++) {
                                if (k == i || k == j) {
                                        continue;
                                }
                                for (int fr = 0; fr <= 4000; fr++) {
                                        for (int se = fr; se <= 4000; se++) {
                                                if (ok[i][j][fr] && ok[j][k][se - fr] && ok[i][k][se]) {
                                                        ans = min(ans,
                                                            max({ (int)s[i].size(), fr + (int)s[j].size(), se + (int)s[k].size() }));
                                                }
                                        }
                                }
                        }
                }
        }
        cout << ans << '\n';
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    unsigned int N, H, max, ret=0;
    
    std::cin >> N >> H;
    max = H;
    ret++;
    
   for(int i=1; i<N; i++) {
       std::cin >> H;
       if(max <= H){
           ret++;
           max = H;
       }
   }
        
    std::cout << ret << std::endl;
    
    return 0;
    
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

def two(x):
    i=0
    while True:
        if x%2==0:
            x=x//2
            i+=1
        else:
            break

    return(i)

ANS=0
for i in range(N):
    ANS+=two(A[i])

print(ANS)


Measured memory_bytes: 4148
c = [list(map(int, input().split())) for _ in range(3)]

if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1] and c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]:
    print('Yes')
else:
    print('No')
    


Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ans = 0;
    for(int i = 1; i <= N; i++){
      ans += i;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int vis[100005];
int f[100],u[100],ans[100];
void findfic(void)
{

}
int main()
{
  //  ios::sync_with_stdio(false);
    /*cout << 4e5;
    ll n;
    cin >> n;
    if(n%2)
        cout << 0 << endl;
    else{

    }*/
    ll n,k;
    cin >> n >> k;

    int ans=1;

        ll r=1;
        while(r*k<=n){
            r*=k;
            ans++;
        }
        cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256