akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
struct edge
{
	ll x,y;
	bool operator<(const edge&z)const
	{
		return x>z.x||(x==z.x&&y<z.y);
	}
}h,v;
struct edge2
{
	ll x,y,z;
}e[400005];
ll n,i,x,y,z,tot=0,ev[3][400005],dsu[200005],dis[400005],pre[400005],ans=0,fx,fy;
const ll inf=1e18;
priority_queue<edge>q;
vector<edge>s[400005];
ll getf(ll p){return dsu[p]==p?p:dsu[p]=getf(dsu[p]);}
bool cmp(edge2 a,edge2 b)
{
	if(a.z!=b.z)return a.z<b.z;
	if(a.x!=b.x)return a.x<b.x;
	return a.y<b.y;
}
int main()
{
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		dsu[i]=i;
		q.push((edge){0,n+i});
		pre[i]=i;pre[n+i]=n+i;
		dis[i]=inf;dis[n+i]=0; 
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		s[i].push_back((edge){n+i,x});
		s[n+i].push_back((edge){i,x});
		ev[0][i]=i;ev[1][i]=n+i;ev[2][i]=x;
	}
	for(i=1;i<n;i++)
	{
		scanf("%lld%lld%lld",&x,&y,&z);
		s[x].push_back((edge){y,z});
		s[y].push_back((edge){x,z});
		ev[0][n+i]=x;ev[1][n+i]=y;ev[2][n+i]=z;
	}
	while(!q.empty())
	{
		h=q.top();
		q.pop();
		if(h.x>dis[h.y])continue;
		for(i=0;i<s[h.y].size();i++)
		{
			v=s[h.y][i];
			if(dis[v.x]>dis[h.y]+v.y)
			{
				dis[v.x]=dis[h.y]+v.y;
				pre[v.x]=pre[h.y];
				q.push((edge){dis[v.x],v.x});
			}
		}
	}
	for(i=1;i<=2*n-1;i++)e[i]=(edge2){pre[ev[0][i]]-n,pre[ev[1][i]]-n,ev[2][i]+dis[ev[0][i]]+dis[ev[1][i]]};
	sort(e+1,e+2*n,cmp);
	for(i=1;i<=2*n-1;i++)
	{
		fx=getf(e[i].x);fy=getf(e[i].y);
		if(fx==fy)continue;
		ans+=e[i].z;
		dsu[fx]=fy;
	}
	printf("%lld\n",ans);
	return 0; 
} 

Measured memory_bytes: 69868
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		int a[]=new int[n];
		long b[]=new long[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextLong();
		}
		
		long c[]=new long[100001];
		
		for(int i=0;i<n;i++) {
			c[a[i]]+=b[i];
		}
		
		int ans=0;
		while(k>0) {
			ans++;
			k-=c[ans];
		}
		System.out.println(ans);
	}
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  char x, y;
  cin >> x >> y;
  if(x > y) cout << ">" << endl;
  else if(x < y) cout << "<" << endl;
  else cout << "=" << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
k, n = map(int, input().split())

def calc_x(K, N):
	return (pow(K, N+1)-K) // (K-1)
def lexico(K, N, X):
	#print(K, N, X)
	global ans
	if X == 0:
		return
	q = (calc_x(K, N-1)+1)
	if N > 1:
		ans.append((X//q) + 1)
	else:
		ans.append((X//q))
	lexico(K, N-1, (X-1)%q)

if k == 1:
	print(*[1 for _ in range((n+1)//2)])
elif n == 1:
	print((k+1)//2)
elif k%2 == 0:
	ans = [k//2] + [k] * (n-1)
	print(*ans)
else:
	if n%2 == 1:
		cur, i = 1, n
	else:
		cur, i = 0, n
	while cur <= i:
		i -= 1
		cur += pow(k, n-i)
	ans = [(k+1)//2] * i
	ind = (cur-i) // 2
	lexico(k, n-i, ind)
	print(*ans)

Measured memory_bytes: 12364
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    double x1, x2;
    double y1, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    double distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

    cout << setprecision(12) << distance << endl;
   
    return (0);
}    

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

#define MAXN 100*1000 + 5
const int mod = 1000*1000*1000 + 7;

int fact[MAXN];

int mul(int a, int b) {
	int ans = (1LL * a * b) % mod;
	while(ans < 0) ans += mod;
	while(ans >= mod) ans -= mod;
	return ans;
}

int mpow(int a, int n) {
	if(n == 0) return 1;
	int x = mpow(a, n/2);
	x = mul(x, x);
	if(n % 2) x = mul(a, x);
	return x;
}

int binomial(int n, int k) {
	return mul(fact[n], mul(mpow(fact[n-k], mod-2), mpow(fact[k], mod-2)));
}

void add_self(int& a, int b) {
	a += b;
	while(a >= mod) a -= mod;
}

void sub_self(int& a, int b) {
	a -= b;
	while(a < 0) a += mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	fact[0] = 1;
	for(int i = 1; i < MAXN; i++) {
		fact[i] = mul(i, fact[i-1]);
	}
	
	int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	for(int& x : arr) cin >> x;
	sort(arr.begin(), arr.end());
	
	int ans = 0;
	
	for(int i = k-1; i < n; i++) {
		add_self(ans, mul(arr[i], binomial(i, k-1)));
	}
	
	for(int i = n-k; i >= 0; i--) {
		sub_self(ans, mul(arr[i], binomial(n - i - 1, k-1)));
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    string str;
    getline(cin,str);
    if(str == "ABC")
    {
        cout<<"ARC";
    }
    else if(str == "ARC")
    {
        cout<<"ABC";
    }
	// your code goes here
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<ll> ans(n);
	priority_queue<pair<int,pii>> pq;
	rep(i,n){
		pq.push(mp(a.at(i),mp(1,i)));
	}
	while(pq.size() > 1){
		pair<int,pii> b = pq.top();pq.pop();
		pair<int,pii> c = pq.top();pq.pop();
		if(b.second.second < c.second.second){
			ans.at(b.second.second) += (ll)(b.first - c.first) * b.second.first;
			b.second.first += c.second.first;
			b.first = c.first;
			pq.push(b);
		}
		else{
			ans.at(b.second.second) += (ll)(b.first - c.first) * b.second.first;
			c.second.first += b.second.first;
			pq.push(c);
		}
	}
	ans.at(0) += (ll)pq.top().first * pq.top().second.first;
	rep(i,n) cout << ans.at(i) << endl;
}


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


def F(x):
    a = str(x[0])
    b = str(x[1])
    return max(len(a), len(b))


def make_divisors(n):
    divisors = [(1, n)]
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append((i, n // i))
    return divisors


print(F(make_divisors(N)[-1]))

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

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

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

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

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  /* C[i] に i の出現数を記録する */
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  /* C[i] に i 以下の数の出現数を記録する*/
  for(i=1;i<=VMAX;i++){
    C[i] = C[i] + C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

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

  printf("\n");

  return 0;
}



Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  int m;
  cin>>n>>m;
  vector<vector<int>> g(n);
  vector<int> deg(n);
  rep(i,m) {
    int x,y;
    cin>>x>>y;
    g[x-1].push_back(y-1);
    deg[y-1]++;
  }
  queue<int> q;
  const int inf = 1e6;
  vector<int> dp(n,-inf);
  rep(i,n) {
    if(deg[i]==0) {
      q.push(i);
      dp[i]=0;
    }
  }
  while(!q.empty()) {
    int x = q.front();
    q.pop();
    for(auto&y : g[x]) {
      dp[y]=max(dp[x]+1,dp[y]);
      deg[y]--;
      if(deg[y]==0) {
        q.push(y);
      }
    }
  }
  int ans=0;
  rep(i,n) {
    ans=max(ans,dp[i]);
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

int main(){
    ll n, m; cin >> n >> m;
    map<ll, ll> mp;
    REP(i, 0, n){
        ll a; cin >> a;
        mp[a]++;
    }
    REP(i, 0, m){
        ll b, c; cin >> b >> c;
        mp[c] += b;
    }
    ll sum = 0;
    for(auto i = mp.rbegin(), e = mp.rend(); i != e && n > 0; ++i){
        //cout << i->first << " " << i->second << endl;
        sum += i->first * min(i->second, n);
        //cout << sum << endl;
        n -= i->second;
    }
    cout << sum << endl;
}

Measured memory_bytes: 12800
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var col []int

func dfs(u, c int, n [][]int) bool {
	col[u] = c
	for i, v := range n[u] {
		if v == 0 || v == inf {
			continue
		}
		var d int
		if c == 1 {
			d = 2
		} else {
			d = 1
		}
		if col[i] != 0 {
			if col[i] != d {
				return false
			}
			continue
		}
		if !dfs(i, d, n) {
			return false
		}
	}
	return true
}

const inf = 1001001001

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	n := make([][]int, N)
	for i := 0; i < N; i++ {
		n[i] = make([]int, N)
		for j := 0; j < N; j++ {
			if i == j {
				continue
			}
			n[i][j] = inf
		}
	}
	for i := 0; i < N; i++ {
		s := getString()
		for j, v := range s {
			if v == '1' {
				n[i][j] = 1
			}
		}
	}

	col = make([]int, N)
	check := dfs(0, 1, n)

	if !check {
		out(-1)
		return
	}

	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if n[i][j] > n[i][k]+n[k][j] {
					n[i][j] = n[i][k] + n[k][j]
				}
			}
		}
	}

	ans := 0
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			ans = max(ans, n[i][j]+1)
		}
	}
	out(ans)
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    long long sum=0;
    for(int i=1;i<=t;i++)
    {
        if(i%3==0||i%5==0)
            continue;
        else sum+=i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    int a[] = new int[300000];

    s = r.readLine();
    int n = s.length();
    for(int i = 0; i < n; i++)
    {
      a[i] = (s.charAt(i) == 'B' ? 1 : 0);
    }

    for(int i = n - 1; i >= 0; i--)
    {
      if(a[i] == 1)
      {
        n--;
      }
      else
      {
        break;
      }
    }

    if(n <= 1)
    {
      System.out.println(0);
      System.exit(0);
    }

    long z = 0;
    for(int i = n - 2; i >= 0; i--)
    {
      if(a[i] == 1)
      {
        //System.out.println(n - i - 1);
        z += n - i - 1;
        n--;
      }
    }

    System.out.println(z);

  }

}

Measured memory_bytes: 38244
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=2e5+100;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    set<int>s;
    int y;
    for (int i=0;i<x;i++){
        cin>>y;
        s.insert(y);
    }
    if (s.size()==x)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 9600
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

N = int(input())
A = [0]*N
for i in range(N):
	A[i] = int(input())

ans = A[0] - 1
A[0] = 1

cnt = 1
# yobi = 1

for i in range(1, N):
	now = A[i]

	if now > cnt:
		if now == cnt + 1: ## 0 ni nattyau
			cnt += 1
		else: ## now >= cnt + 2
			ans += now // (cnt + 1)
			if now % (cnt + 1) == 0:
				ans -= 1

print(ans)


Measured memory_bytes: 46424
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define repeat(i, n, m) for(int i = n; i < (m); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
inline T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
inline T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	vector<ll> a(2), b(2);
	rep(i, 2)scanf("%lld", &a[i]);
	rep(i, 2)scanf("%lld", &b[i]);
	ll ans = -LINF;
	rep(i, 2) {
		rep(j, 2) {
			chmax(ans, a[i] * b[j]);
		}
	}
	printf("%lld\n", ans);

	Please AC;
}

Measured memory_bytes: 3828
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DMatchMatching {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, M;
	    in >> N >> M;
	    vector<int> A(M);
	    REP(i,0,M) in >> A[i];

	    const vector<int> cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

	    vector<string> dp(N+1, ""); // dp[num of rest sticks] = max num

	    RREP(i,0,N+1) {
	        if (i != N && dp[i].empty()) continue;
	        for (int a : A) {
	            if (i - cost[a] < 0) continue;
	            string candidate = dp[i] + to_string(a);
	            if (dp[i - cost[a]].size() <= candidate.size() && dp[i - cost[a]] < candidate || dp[i - cost[a]].size() < candidate.size()) {
//                    debug(i);
//                    debug(a);
//	                debug(dp[i]);
//	                debug(candidate);
//	                debug(i - cost[a]);
                    dp[i - cost[a]] = candidate;
	            }
	        }
	    }

	    out << dp[0] << "\n";
	}
};


int main() {
	DMatchMatching solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 32896
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            
            var k = cin.nextInt();
            var a = cin.nextInt();
            var b = cin.nextInt();

            var now = 0;
            var i = 1;
            while (true)
            {
                now = i * k;
                if(a <= now && now <= b)
                {
                    Console.WriteLine("OK");
                    return;
                }
                if(now > b)
                {
                    Console.WriteLine("NG");
                    return;
                }
                i++;
            }


        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27480
h, w = map(int, input().split())
d = {}
for i in range(h):
  for c in input():
    if c in d:
      d[c] += 1
    else:
      d[c] = 1
m = ((w + 1)// 2) * ((h + 1) // 2)
ans = "Yes"
if len(d.keys()) > m:
  ans = "No"
oc = 0
fc = 0
for key in d:
  oc += d[key] % 2
  fc += d[key] // 4
if oc > 1 or fc < (w//2) * (h//2):
  ans = "No"
print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
#define int long long
#define vbe(sdk) sdk.begin(), sdk.end()
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; ++i)
#define rloop(i, a, b) for (int i = a; i >= b; --i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int>>
#define vll vector<int>
#define mint map<int, int>
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int, int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;

void solve()
{
   int n;
   cin>>n;
   int a[n];
   loop(i,0,n)
   {
       cin>>a[i];
   }
   int cnt=0;
   loop(i,0,n)
   {
       loop(j,i+1,n)
       {
           loop(k,j+1,n)
           {
               if( ((a[i]+a[j])>a[k] && (a[i]+a[k])>a[j] &&  (a[k]+a[j])>a[i] ) && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]) {
               cnt++;
            //    cout<<i+1<<" "<<j+1<<" "<<k+1<<"\n";
               }
           }
       }
   }
   cout<<cnt<<"\n";
}
signed main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3672
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
		long startCpuTime = threadMXBean.getCurrentThreadCpuTime(), stopCpuTime = 0;

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\0545-input.txt"));

		while (scan.hasNext()) {

			int w = scan.nextInt();
			int h = scan.nextInt();
			if (w == 0 && h == 0)
				break;
			Map m = new Map();
			System.out.println(m.count(w, h));
			// stopCpuTime = threadMXBean.getCurrentThreadCpuTime();

		}

		scan.close();
		// stopCpuTime = threadMXBean.getCurrentThreadCpuTime();
		// System.out.println("CPU=" + (stopCpuTime - startCpuTime) / 1000000);

		System.exit(0);
	}
}

class Map {
	int W, H;
	int Nor = 1, Est = 0;

	public int count(int w, int h) {
		W = w;
		H = h;
		sav = new int[w + 1][h + 1][2];
		return (this.root(1, 2, Nor) + this.root(2, 1, Est)) % 100000;
	}

	int[][][] sav;

	private int root(int x, int y, int d) {
		if (x >= W - 1 && y >= H - 1)
			return 1;
		if (sav[x][y][d] > 0)
			return sav[x][y][d];
		int r = 0;
		if (d == Nor) {
			if (y < H)
				r += root(x, y + 1, Nor);
			if (x < W - 1)
				r += root(x + 2, y, Est);
		} else {
			if (y < H - 1)
				r += root(x, y + 2, Nor);
			if (x < W)
				r += root(x + 1, y, Est);
		}
		r %= 100000;
		sav[x][y][d] = r;
		return r;
	}
}

Measured memory_bytes: 26976
/* Coached by Dukkha */
#include <stdio.h>
#include <stdlib.h>

#define N 100000
#define C 30

struct P {
	int s, t, c;
} pp[N];

int compare(const void *a, const void *b) {
	struct P *p = (struct P *) a;
	struct P *q = (struct P *) b;

	return p->s - q->s;
}

int main() {
	static int tt[C], cc[C];
	int n, c, i, h, ans;

	scanf("%d%d", &n, &c);
	for (i = 0; i < n; i++) {
		struct P *p = &pp[i];

		scanf("%d%d%d", &p->s, &p->t, &p->c);
	}
	qsort(pp, n, sizeof *pp, compare);
	for (i = 0; i < n; i++) {
		struct P *p = &pp[i];

		for (h = 0; h < c; h++)
			if (cc[h] == p->c) {
				tt[h] = p->t;
				break;
			}
		if (h < c)
			continue;
		for (h = 0; h < c; h++)
			if (tt[h] < p->s) {
				tt[h] = p->t;
				cc[h] = p->c;
				break;
			}
	}
	ans = 0;
	for (h = 0; h < c; h++)
		if (cc[h])
			ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2556
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

ll MOD = 1e9+7;
ll dp[10001];
int main() {
  int n, w;
  cin >> n >> w;
  int a[n];
  int sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a+n, greater<int>());
  dp[0] = 1;
  ll ans = 0;
  if (sum <= w) ans = 1;
  REP(i, n) {
    sum -= a[i];
    //REP(j, w+1) cout << dp[j] << " ";cout << endl;
    //cout << ans << " " << sum << " " << w-a[i]+1 << " " << w-sum << endl;
    for (int j=max(0,w-sum-a[i]+1); j<=w-sum; ++j) {
      ans = (ans + dp[j]) % MOD;
    }
    for (int j=w-a[i]; j>=0; --j) {
      dp[j+a[i]] = (dp[j+a[i]] + dp[j]) % MOD;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long int
#define ull                 unsigned long long int
#define ld                  long double
#define fi                  first
#define se                  second
#define pb                  push_back
#define pbb                 pop_back
#define mp                  make_pair
#define pii     	        pair<int,int>
#define all(x)              x.begin(), x.end()
#define uniq(x)             x.erase(unique(x.begin(),x.end()),x.end())
#define mem(array, value)   memset(array, value, sizeof(array))
#define PI      	        2*acos(0.0)
#define EPS     	        1e-8
#define line                cout << "\n==========\n"
#define fastRead 	        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define trace(...)          __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " , ";
    __f(comma + 1, args...);
}

const int INF = 1e9+9;

int ara[500];

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

    string s;
    cin >> s;
    bool flag = true;
    for (int i = 0; s[i]; i++){
        if (isupper(s[i])){
            ara[s[i] - '0']++;
        }
        else{
            flag = false;
        }
    }
    for (char ch = 'A'; ch <= 'Z'; ch++){
        if (ara[ch - '0'] != 2 && ara[ch - '0'] > 0){
            flag = false;
            break;
        }
    }
    if (flag){
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,k,n,map[15][15],mat[200][200],mmm[200][200];

void swap (int* x,int* y){
	int z;
	z=*x;
	*x=*y;
	*y=z;
}

int main(){
	for(i=0;i<100;i++){
		mmm[i][i]=1;
		if(i%10>0)mmm[i-1][i]=1;
		if(i%10<9)mmm[i+1][i]=1;
		if(i>9)mmm[i-10][i]=1;
		if(i<90)mmm[i+10][i]=1;
	}

	for(scanf("%d",&n);n>0;n--){

		for(i=0;i<100;i++){
			for(j=0;j<100;j++){
				mat[i][j]=mmm[i][j];
			}
			scanf("%d",&mat[i][100]);
		}

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

			if(mat[i][i]==0){
				for(j=i+1;j<100;j++){
					if(mat[j][i]==1){
						for(k=i;k<=100;k++){
							swap(&mat[i][k],&mat[j][k]);
						}
						break;
					}
				}
			}

			for(j=0;j<100;j++){
				if(j!=i && mat[j][i]==1){
					for(k=i;k<=100;k++){
						if(mat[i][k]==1)mat[j][k]=!mat[j][k];
					}
				}
			}

		}

		for(i=0;i<100;i++){
			printf("%d%s",mat[i][100],(i%10==9)?"\n":" ");
		}

	}
	return 0;
}

Measured memory_bytes: 760
//Distinct or Not

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    int ans=0;
    rep(i,1,n+1){
        int s=n/i;
        ans+=s*(s+1)/2*i;
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 3010
ll f[N][N], n, ans = 0;
char str[N];
int main() {
    scanf("%lld%s", &n, str + 1);
    f[1][1] = 1;
    for (int i = 2; i <= n; i++) {
        if (str[i - 1] == '<') {
            f[i][1] = 0;
            for (int j = 2; j <= i; j++)
                f[i][j] = (f[i][j - 1] + f[i - 1][j - 1]) % mod;
        } else {
            f[i][i] = 0;
            for (int j = i - 1; j; j--)
                f[i][j] = (f[i][j + 1] + f[i - 1][j]) % mod;
        }
    }
    for (int i = 1; i <= n; ++i) ans = (ans + f[n][i]) % mod;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 69120
s = input()
d = []
d.append("AKIHABARA")

d.append("AKIHABAR")
d.append("AKIHABRA")
d.append("AKIHBARA")
d.append("KIHABARA")

d.append("AKIHABR")
d.append("AKIHBRA")
d.append("AKIHBAR")
d.append("KIHBARA")
d.append("KIHABRA")
d.append("KIHBAR")

d.append("AKIHBR")
d.append("KIHABR")
d.append("KIHBAR")
d.append("KIHBRA")

d.append("KIHBR")
if s in d:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll term1=(A1-B1)*T1;
    ll term2=(A2-B2)*T2;
    if(term1<0){
        term1*=-1;
        term2*=-1;
    }

    if(term1+term2==0){
        cout << "infinity" << endl;
    }else if(term1+term2>0){
        cout << 0 << endl;
    }else{
        ll ans=2*(term2/(term1+term2)-1)+1;
        if(term2%(term1+term2)==0){
            ans--;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS
import qualified Test.QuickCheck as QC

-- 愚直解
naive :: Integer -> Integer -> Integer -> Integer
naive x k d = minimum $ map abs $ iterate (concatMap oneStep) [x] !! fromInteger k
-- iterate (\m -> m >>= oneStep) (pure x) !! fromInteger k
{- do
  let loop 0 t = pure t
      loop i t = do
        u <- oneStep t
        loop (i - 1) u
  loop k x
-}
  where
    oneStep :: Integer -> [Integer]
    oneStep t = [t - d, t + d]

solve :: Int64 -> Int64 -> Int64 -> Int64
solve x k d = let (q,r) = abs x `quotRem` d
              in if q <= k then
                   if even (k - q) then
                     r
                   else
                     abs (r - d)
                 else
                   abs x - k * d

main = do
  [x,k,d] <- map fromInteger . unfoldr (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine
  print $ solve x k d

prop :: Int64 -> QC.Positive Int64 -> QC.Property
prop x (QC.Positive d) = QC.forAll (QC.choose (1,15)) $ \k -> d >= 1 QC.==> toInteger (solve x k d) QC.=== naive (toInteger x) (toInteger k) (toInteger d)


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

int main(){
  int N;cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  /*int ans=0;
  for(int i=1;i<N;i++){
    int X=A.at(i)-A.at(i-1);
    if(X>ans) ans=X;
  }
  cout<<ans<<endl;*/
  cout<<A.at(N-1)-A.at(0)<<endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3025;
char s[MAXN], t[MAXN], ans[MAXN];
int dp[MAXN][MAXN];
int main(){
	scanf("%s", s + 1);
	scanf("%s", t + 1);
	int n = strlen(s + 1);
	int m = strlen(t + 1);
	for(int i = n; i >= 1; i--){
		for(int j = m; j >= 1; j--){
			if(s[i] == t[j]) dp[i][j] = dp[i + 1][j + 1] + 1;
			else dp[i][j] = max(dp[i][j + 1], dp[i + 1][j]);
		}
	}
	int l = 1, r = 1;
	while(l <= n && r <= m){
		if(s[l] == t[r]){
			printf("%c",s[l]);
			l++;
			r++;
		}else if(dp[l][r] == dp[l + 1][r]) l++;
		else r++;
	} 
	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
 
#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x, min(y,z))
#define max1(x,y,z) max(x, max(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;
 
 
 
int32_t main()
{
        IOS;

        int L;
        cin>>L;

        if (L == 1) {
                double ans = (double)1/(double)27;
                cout<<fixed<<setprecision(10)<<ans<<endl;
                return 0;
        }
        if (L == 2) {
                double ans = (double)8/(double)27;
                cout<<fixed<<setprecision(10)<<ans<<endl;
                return 0;
        }
        if (true) {
                double x = (double)L/(double)3;
                double ans = x*x*x;
                cout<<fixed<<setprecision(10)<<ans<<endl;
        } else if (L%3 == 1) {
                double ans = (L/3*(L+1)/3*L/3);
                cout<<fixed<<setprecision(10)<<ans<<endl;
        } else {
                double ans = (L/3*(L+1)/3*(L+1)/3);
                cout<<fixed<<setprecision(10)<<ans<<endl;
        }
        





        
 
 
 
            
 
 
 
      
 
 
        
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    const int maxN = 2 * (int)1e5 + 10;
    int pref[maxN];
    string s;
    int n;
    int main() {
        //freopen("input.txt", "r", stdin);
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        srand(239);
        cin >> s;
        n = s.size();
        for (int i = 0; i < n; i++) {
            if (i > 0) pref[i] = pref[i - 1];
            if (s[i] == 'W') pref[i]++;
        }
        pref[n] = pref[n - 1];
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'B') {
                ans += pref[n] - pref[i];
            }
        }
        cout << ans;
        return 0;
    }

Measured memory_bytes: 1300
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces

# 大きい数用


def modPow(a, n, p):
    if n == 1:
        return a
    if n % 2 == 1:
        return (a * (modPow(a, n // 2, p) ** 2)) % p
    else:
        return (modPow(a, n // 2, p) ** 2) % p


def modInverse(a, p):
    # calculates the modular multiplicative of a mod m.
    # (assuming p is prime).
    return modPow(a, p - 2, p)


def modBinomial(n, k, p):
    # calculates C(n,k) mod p (assuming p is prime).

    numerator = 1  # n * (n-1) * ... * (n-k+1)
    for i in range(k):
        numerator = (numerator * (n - i)) % p

    denominator = 1  # k!
    for i in range(1, k + 1):
        denominator = (denominator * i) % p

    # numerator / denominator mod p.
    return (numerator * modInverse(denominator, p)) % p


r1, c1, r2, c2 = na()
mod = 10 ** 9 + 7
print((modBinomial(r2 + c2 + 2, r2 + 1, mod) + modBinomial(r1 + c1, r1, mod) -
       modBinomial(r1 + c2 + 1, r1, mod) - modBinomial(r2 + c1 + 1, c1, mod)) % mod)


Measured memory_bytes: 38640
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		List<Integer> listH = new ArrayList<Integer>();
		List<Integer> listW = new ArrayList<Integer>();
		for(;;){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			listH.add(H);
			listW.add(W);
		}

		for(int i = 0; i < listH.size(); i++){
			for(int j = 0; j < listH.get(i); j++){
				StringBuffer sb = new StringBuffer();
				for(int k = 0; k < listW.get(i); k++){
					if(j == 0 || j == listH.get(i) - 1 || k == 0 || k == listW.get(i) - 1){
						sb.append("#");
					} else{
						sb.append(".");
					}
				}
				sb.append("\n");
				String str = sb.toString();
				System.out.print(str);
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 28844
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

long long dp[(int) (1e5+1)];
long long nums[(int) (1e4+1)];

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

    int nums[stones];
    for (int i = 0; i < stones; i++) {
        cin >> nums[i];

        dp[i + 1] = INT_MAX;
    }

    dp[0] = 0;

    for (int i = 0; i < stones; i++) {
        for (int j : {i + 1, i + 2}) {
            if (j < stones) {
                dp[j] = min(dp[j], abs(nums[i] - nums[j]) + dp[i]);
            }
        }
    }

    cout << dp[stones - 1];

    return 0;
}


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

using namespace std;
typedef long long ll;
vector<ll> v;

void dfs(ll d,ll s,ll u){
  if(d==18)return;
  if(s&&u!=d)v.push_back(s);
  dfs(d+1,s*10+2,u);
  dfs(d+1,s*10+8,u+1);
}


ll dfs1(ll s,ll d,ll id){
  if(s==1)return d;
  if(s<v[id]||id==v.size())return -1;
  
  ll res=-1;
  
  if(s%v[id]==0)res=max(res,dfs1(s/v[id],d+1,id));
  
  res=max(res,dfs1(s,d,id+1));

  return res;
}

int main(){
  
  dfs(0,0,0);
  sort(v.begin(),v.end());
  ll n;
  cin>>n;
  if(n==1){cout<<-1<<endl;return 0;}
  cout<<dfs1(n,0,0)<<endl; 

  return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\


int main()
{
    IOS;
    //fileRead
    int tc = 1;
    //cin>>tc;
    while(tc--)
    {
        int n; cin>>n;
        int a[n]; for0(i,n) cin>>a[i];
        
        sort(a,a+n);
        
        int ans=0;
        for0(i,n){
            forab(j,i+1,n-1){
                forab(k,j+1,n-1){
                    if(a[i]==a[j] or a[j]==a[k] or a[k]==a[i]) continue;
                    if(a[i]+a[j]>a[k]) ans++;
                }
            }
        }
        
        cout<<ans;
    }
}

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

int main(){
    long K;
    cin >> K;
    cout << 50 << endl;
    long nums[50];
    for(int i = 0; i < 50; i++){
        nums[i] = K / 50 + 49;
    }
    for(int i = 0; i < K % 50; i++){
        nums[i] += 51;
        for(int j = 0; j < 50; j++){
            nums[j]--;
        }
    }
    string ans_string = "";
    for(int i = 0; i < 50; i++){
        ans_string += to_string(nums[i]) + " ";
    }
    ans_string.pop_back();
    cout << ans_string << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AOJ.intro
{
    namespace ITP_1_5_A
    {
        static public class StructuredProgram
        {
            static public void Main()
            {
                while (true)
                {
                    int[] size = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), delegate(string value)
                    {
                        return int.Parse(value);
                    });
                    int H = size[0];
                    int W = size[1];
                    if (H == 0 && W == 0) break;
                    for (int i = 0; i < H; i++)
                    {
                        for (int j = 0; j < W; j++)
                        {
                            Console.Write("#");
                        }
                        Console.WriteLine();
                    }
                    Console.WriteLine();
                }
            }

        }
    }
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,Y;
    string S;
    cin >> N>>Y;

    bool flag = false;

    ll x = -1, y = -1, z = -1;

    REP(i,N+1){
        REP(j,N+1){
            if(9*i+4*j==Y/1000-N){
                ll k = N - i - j;
                if(k<0||k>N){
                    continue;
                }
                if(10000*i+5000*j+1000*k==Y){
                    flag = true;
                    x = i;
                    y = j;
                    z = k;
                    break;
                }
            }
        }
        if(flag){
            break;
        }
    }

    cout << x << " " << y << " " << z << endl;

}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
 
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] a = new int[n];
      	int sum = 0;
      	int sumF1 = 0;
      	int[] x = new int[n];
      	for(int i = 0; i < n; i++){
        	a[i] = sc.nextInt();
          	sum += a[i];
          	if((i+1) % 2 == 0){
            	sumF1 += a[i];
            }
        }
      	x[0] = sum - 2 * sumF1;
      	System.out.print(x[0]);
      	for(int i = 1; i < n; i ++){
        	x[i] = 2 * a[i-1] -x[i-1];
          	System.out.print(" " + x[i]);
        }
      	
      	
    
    }
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

    ll a, b, k;
    cin >> a >> b >> k;
    if (a >= k) {
        cout << a - k << " " << b;
    } else {
        cout << "0 " << max(0LL, b - (k - a));
    }
}

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

int main(){
  int ans=-1,a,b;
  cin >> a >> b;
  for(int i=1;i<=100000;i++){
    double j = i;
    if(floor(j * 0.08)== a && floor(j*0.10) == b){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define cin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define ull unsigned long long
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rf1(i,a,n) for(int i=a;i>n;i--)
#define cases() int q;cin>>q;while(q--)
#define ld long double
#define cout(a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";
#define inf 1e9;
#define mod 1000000007;
#define PI 3.14159265358979323846264338327950L
using namespace std;

int main(){
    ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int n;
cin>>n ;
vector<ull> a(n);
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a.begin(),a.end());
ull ans=1;
if(a[0]==0){
    cout<<"0"<<endl;
    return 0;
}
for(int i=0;i<n;i++){
    ull temp=ans;
    ans*=a[i];
    if(temp!=ans/a[i]){
        cout<<"-1"<<endl;
        return 0;
    }
    if(ans>1000000000000000000){
        cout<<"-1"<<endl;
        return 0;
    }
}
cout<<ans<<endl;
 return 0;
 }


Measured memory_bytes: 4008
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
struct Edge
{
	int a, b;
	int color;
};
Edge edges[100010];

struct Node
{
	std::vector<int> connects;
	std::vector<int> edges;
	bool isVisited;
};
Node nodes[100010];

void doSearch()
{
	std::queue<int> q;
	q.push(1);
	nodes[1].isVisited = true;
	
	int curNode;
	while (!q.empty())
	{
		curNode = q.front();
		q.pop();
		
		int skipColor = -1;
		for (int i = 0 ; i < nodes[curNode].edges.size() ; i++)
		{
			int curEdge = nodes[curNode].edges[i];
			if (edges[curEdge].color != -1)
			{
				skipColor = edges[curEdge].color;
				break;
			}
		}
		
		int newColor = 1;
		if (newColor == skipColor)
			newColor++;
		
		for (int i = 0 ; i < nodes[curNode].edges.size() ; i++)
		{
			int curEdge = nodes[curNode].edges[i];
			if (edges[curEdge].color != -1)
				continue;
			
			edges[curEdge].color = newColor;
			int newNode;
			if (edges[curEdge].a == curNode)
				newNode = edges[curEdge].b;
			else
				newNode = edges[curEdge].a;
				
			if (nodes[newNode].isVisited == false)
			{
				nodes[newNode].isVisited = true;
				q.push(newNode);				
			}
			
			newColor++;
			if (newColor == skipColor)
				newColor++;
		}
	}
}

int main()
{
	scanf("%d", &n);
	
	for (int i = 0 ; i < n - 1 ; i++)
	{
		scanf("%d%d", &(edges[i].a), &(edges[i].b));
		edges[i].color = -1;
		int va = edges[i].a;
		int vb = edges[i].b;
		
		nodes[va].connects.push_back(vb);
		nodes[va].edges.push_back(i);
		nodes[vb].connects.push_back(va);
		nodes[vb].edges.push_back(i);
	}
	
	for (int i = 1 ; i <= n ; i++)
		nodes[i].isVisited = false;
	
	//start from node 1
	doSearch();
	
	int maxColor = -1;
	for (int i = 0 ; i < n - 1 ; i++)
	{
		if (maxColor < edges[i].color)
			maxColor = edges[i].color;
	}
	printf("%d\n", maxColor);
	
	for (int i = 0 ; i < n - 1 ; i++)
	{
		printf("%d\n", edges[i].color);
	}
	
	return 0;
}


Measured memory_bytes: 13568