akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

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

    int x = (1<<k)-1;
    while(x < (1<<n)) {
        cout << x << ':';
        rep(i, n) if(x>>i&1) {
            cout << ' ' << i;
        }
        cout << '\n';
        int y = x&-x;
        int z = (x+y)&x;
        x = ((~z&x)/y>>1) + x + y;
    }
}


Measured memory_bytes: 3220
import std.stdio;
import std.string;
import std.array;
import std.algorithm;
import std.conv;

void main(){
    int N = readln().chomp().to!int();
    string[] input = readln().split();
    int[] nums;
    int count = 0;
    foreach(string s; input){ nums ~= s.to!int(); }
    for(int i = 0; i < N; i++){
        int mini = i;
        for(int j = i+1; j < N; j++){
            if(nums[j] < nums[mini]){
                mini = j;
            }
        }
        if(i != mini){
            swap(nums[i], nums[mini]);
            count++;
        }
    }
    writeln(nums.map!(a => to!string(a)).join(" "), "\n", count);
}

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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,k;
int h[125252], s[125252], p[125252], l[125252];
int m[125];
int children[125][125];

ll arr[125][125252];
ll beg[125252];

ll tmp[125252];

int di[125252];
ll dv[125252];

void lk(int w, ll *v, ll a, ll n, ll *ret){
  REP(i,w+1)ret[i] = v[i];
  int s = 0, t = 0;
  REP(i,w+1){
    ll v = ret[i] - i*a;
    while(s<t && dv[t-1] <= v)t--;
    di[t] = i;
    dv[t] = v;
    t++;
    ret[i] = dv[s] + i*a;
    if(di[s] == i-n)s++;
  }
}

void dfs(int p, int w, ll *iv){
  // use s[p], max h[p]
  lk(w, iv, s[p], h[p], arr[p]);
  // children
  REP(i,m[p]){
    int c = children[p][i];
    dfs(c, w-l[c], iv);
    iv = arr[c];
    ll adv = (ll)l[c] * s[p];
    lk(w, iv, s[p], h[p]-l[c], tmp);
    REP(i,w+1-l[c])CHMAX(arr[p][i+l[c]], tmp[i]+adv);
  }
}

int main(){
  while(true){
    scanf("%d%d", &n, &k);
    if(n==0 && k==0)break;
    REP(i,n)scanf("%d",h+i);
    REP(i,n)scanf("%d",s+i);
    FOR(i,1,n)scanf("%d",p+i), p[i]--;
    FOR(i,1,n)scanf("%d",l+i);
    REP(i,n)m[i] = 0;
    FOR(i,1,n)children[p[i]][m[p[i]]++] = i;
    REP(i,n)sort(children[i], children[i]+m[i], [&](int a,int b){
      return l[a] < l[b];
    });
    dfs(0, k, beg);
    printf("%lld\n", arr[0][k]);
  }
  return 0;
}



Measured memory_bytes: 83656
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	xList := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xList[i])
	}
	//　集会の位置をpとする
	// sum (p - xList[i])^2 がコストになる。これの最小を求めたい
	// 展開すると sum (p^2 - 2p*xList[i] + xList[i]^2)
	// これの最小値は p^2 * N - 2p*sum(xList) + sum(xList[i]^2)
	// これって二次関数では？ S=sum(xList) , Z=sum(xList^2)とすると
	// Np^2 -2Sp + Z
	// N(p^2 - 2S/N p) + Z
	// N(p - S/N)^2 - N * (S/N)^2 + Z
	// よって pはS/Nに最も近い整数ということになる。

	var p int
	S := sumArray(xList)
	Z := prodSumArray(xList)

	p_correct := float64(S) / float64(n)
	p_upper := int(math.Ceil(p_correct))
	p_under := int(math.Floor(p_correct))

	p = p_upper
	result1 := n*int(math.Pow(float64(p), 2.0)) - 2*S*p + Z
	p = p_under
	result2 := n*int(math.Pow(float64(p), 2.0)) - 2*S*p + Z
	result := int(math.Min(float64(result1), float64(result2)))
	fmt.Println(result)
}

func prodSumArray(a []int) int {
	sum := 0
	for _, x := range a {
		sum += int(math.Pow(float64(x), float64(2)))
	}
	return sum
}

func sumArray(a []int) int {
	sum := 0
	for _, x := range a {
		sum += x
	}
	return sum
}


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

using namespace std;

#define ll long long int

int main()
{  
	string s;int n,i;
	cin>>n>>s;
	if(n%2==0)
	{
		for(i=0;i<(n/2);i++)
		{
			if(s.at(i)==s.at((n/2)+i))
			continue;
			else
			{
				cout<<"No";
				exit(0);
			}
		}
		cout<<"Yes";
	}
	else
	cout<<"No";
	
	return 0;
    
}

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

using namespace std;

#define maxN 100010
#define stdCache -1
typedef long long ll;
typedef pair<int, ll> pi;

int n;
int k;
int h[maxN];
ll cache[maxN];

ll pos(ll x) {
    return x < 0 ? -x : x;
}

ll dp(int i);

ll getK(int x) {
    ll retV = -1;
    for (int i = 1; i<=k && x+i < n; i++) {
        ll v = pos(h[x]-h[x+i]) + dp(x+i);
        if (retV == -1 || v < retV) {
            retV = v;
        }
    }
    return retV;
}

ll dp(int i) {
    if (cache[i] != stdCache) return cache[i];
    if (i == n-1) return 0;
    if (i >= n) return 999999999;
    return cache[i] = getK(i);
}

int main() {
    cin >> n >> k;
    for (int i = 0; i<n; i++) {
        cin >> h[i];
        cache[i] = stdCache;
    }
    h[n] = 999999999;
    h[n+1] = 999999999;
    cout << dp(0) << endl;
    return 0;
}

Measured memory_bytes: 7680
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut cnt = 0;

    for i in 0..s.len() {
        if s[i] != t[i] {
            cnt += 1;
        }
    }

    echo!(cnt);
}


Measured memory_bytes: 3956
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
 
using namespace std;
 
int n,mn;

int dsm(int a){
    int da=a,db=10,dc[10],sm=0;
    for(int i=0;i<7;i++){
        dc[i]=da;
        da/=db;
        da*=db;
        
        if(i>0)sm+=(dc[i-1]-dc[i])*100/db;
        db*=10;
        
    }
    return sm;
    
}

int main(){
    scanf("%d",&n);
    
    for(int i=1;i<n;i++){
        if(i==1)mn=dsm(i)+dsm(n-i);
        else mn=min(mn,dsm(i)+dsm(n-i));
    }
    printf("%d\n",mn);
}

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

void main_()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> Xs;
    Xs.reserve(M);
    copy_n(istream_iterator<ll>(cin), M, back_inserter(Xs));

    if (N >= M) {
        cout << 0 << endl;
        return;
    }

    sort(begin(Xs), end(Xs));
    vector<ll> diffs;
    diffs.reserve(M);
    adjacent_difference(begin(Xs), end(Xs), back_inserter(diffs));

    nth_element(begin(diffs) + 1, begin(diffs) + M - N + 1, end(diffs));
    auto ans = accumulate(begin(diffs) + 1, begin(diffs) + M - N + 1, 0LL);
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

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

		while((str=br.readLine()) != null){
			char cArray[] = str.toCharArray();
			int nArray[] = new int[cArray.length];
			int result=0;

			for(int i=0; i<cArray.length; i++){
				nArray[i] = Numbering(cArray[i]);
			}

			for(int i=0; i<nArray.length; i++){
				if((i>0) && nArray[i-1]<nArray[i]){
					nArray[i-1] *= -1;
				}
			}

			for(int i:nArray){
				result += i;
			}

			System.out.println(result);
		}
	}

	static int Numbering(char c){
		int n=0;

		switch (c){
		case 'I':
			n=1;
			break;
		case 'V':
			n=5;
			break;
		case 'X':
			n=10;
			break;
		case 'L':
			n=50;
			break;
		case 'C':
			n=100;
			break;
		case 'D':
			n=500;
			break;
		case 'M':
			n=1000;
		}
		return n;
	}
}

Measured memory_bytes: 16892
#include <stdio.h>

int main(void){
  int i;
  int scr = 0;
  char str[4];
  
  scanf("%s",str);
  for(i = 0;i < 4; ++i){
    if(str[i] == '+')	++scr;
    else if(str[i] == '-')	--scr;
  }
  printf("%d\n",scr);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>

#define rep(i,n) for(int i = 0; i != n; i++)

using namespace std;

int main(){
	int N;
	vector<int> L;
	cin >> N;
	rep(i,2*N){
		int temp; cin >> temp;
		L.push_back(temp);
	}

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

	int res = 0;
	rep(i,N){
		int l1 = L[2*i];
		res += l1;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;


int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	int A, B;

	cin >> A >> B;

	int cost = 0;
	if (A<6) {
		//no
	}
	else if (A<13) {
		cost = B/2;
	}
	else {
		cost = B;
	}

	cout << cost << endl;
	

	return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M; cin >> N >> M;
    Graph g; rep(i, N){vector<ll> tmp; g.push_back(tmp);}
    map<ll, map<ll, ll>> m;

    rep(i, M){
        ll l, r, d; cin >> l >> r >> d; l--; r--;
        m[l][r] = d; // 2個目の場所-1個目の場所が距離
        m[r][l] = -d;
    }

    set<ll> not_visited; rep(i, N){not_visited.insert(i);}
    map<ll, ll> coords;

    bool flag = true;
    while (not_visited.size() > 0 && flag){
        ll start_ind = *not_visited.begin(); not_visited.erase(start_ind);
        stack<int> q; q.push(start_ind); coords[start_ind] = 0;

        while (q.size() > 0 && flag){
            ll ind = q.top();
            q.pop();
            for (auto a: m[ind]){
                if (coords.find(a.first) != coords.end()){ // エッジがある時
                    if (m[ind][a.first] != (coords[a.first] - coords[ind])){flag = false; break;}
                } else {
                    coords[a.first] = coords[ind] + m[ind][a.first];
                }

                if (not_visited.find(a.first) != not_visited.end()){
                    q.push(a.first);
                    not_visited.erase(a.first);
                }
            }
        }
    }
    string ans = flag ? "Yes" : "No";
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 44400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin>>a>>b;
	if((a>=1 and a<=9) and (b>=1 and b<=9)) cout<<a*b<<"\n";
	else cout<<"-1\n";
	return 0;
}

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

int main(){
    LL h,w;
    cin >> h >> w;
    LL odd = ((h + 1) / 2) * ((w + 1) / 2);
    LL even = (h / 2) * (w / 2);
    if(even == 0) odd = 1;

    cerr << odd << " " << even << endl;

    cout << odd + even << endl;

    return 0;
}

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

int main () {

  int H , W ;

  while (1) {

  cin >> H >> W ;

  if ( H == 0 && W == 0) break;

   for ( int i = 0; i < H ; i++){

     for ( int j = 0; j < W ; j++) {

      cout << "#";

     }

     cout << endl;

   }

   cout << "\n";

  }

  return 0;

}

Measured memory_bytes: 1152
#include <stdio.h>

int main() {
    
    int S,h,min,m,s;
    
    scanf("%d",&S);
    s = S % 60;
    min = (S - s) / 60;
    m = min % 60;
    h = (min - m) / 60;
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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++)
int main() {
  string A;
  cin >> A;
  cout << A.at(0) << A.at(1) << A.at(2) << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long n,x;
    cin >> n;
    long long a[n];

    for(int i=0;i<n;i++){
        cin >> x;
        a[i]=x;
    }
    sort(a,a+n);
    x=1;
    for(int i=0;i<n;i++){
        if(a[i]==0){
            cout << "0" << endl;
            return 0;
        }
        if(a[i]>1000000000000000000/x){
            cout << "-1" << endl;
            return 0;
        }
        x=x*a[i];
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 4408
number=int(input())
day = input()

if number ==0:
  print(day)
else:
  alphabet=list("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")
  myIter =iter(day)
  out=list()
  for x in myIter:
    pos = alphabet.index(x)
    out.append(alphabet[pos + number])
    
  print(''.join(out))


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

 #define int long long
 #define pa pair<int,int>
 #define ll long long
  #define  mp make_pair
  #define  pb push_back


using namespace std;
const int inf=1000000007;


int solve_min(vector<pa> &ve,int n,int l){
	int ans=0;
	int pos=0;
	int it=0;
	int ma=0;
	while(1){
		while(it!=n && ve[it].first<=pos){
			ma=max(ma,ve[it].second);
			it++;
		}
		ans++;
		pos=ma;
		if(pos==l) return ans;
	}
}

int solve_max(vector<pa> &ve,int n,int l){
	vector<pa> V(2*n);
	for(int i=0;i<n;i++)V[i]=mp(ve[i].first,1);
	for(int i=0;i<n;i++)V[i+n]=mp(ve[i].second,-1);
	V.pb(mp(inf*2000000000ll,100));
	sort(V.begin(),V.end());
	int cnt=0;
	int ans=inf;
	for(int i=0;i<2*n;i++){
		cnt+=V[i].second;
		if(V[i].first==l) break;
		if(V[i].first!=V[i+1].first)ans=min(ans,cnt);
	}
	return n+1-ans;
}

 signed main(){
 	

    	       cin.tie(0);
   			ios::sync_with_stdio(false);
int n,l;
 	cin>>n>>l;

 	vector<pa> ve(n);
 	for(int i=0;i<n;i++)cin>>ve[i].first>>ve[i].second;
 	sort(ve.begin(),ve.end());
 	cout<<solve_min(ve,n,l)<<" "<<solve_max(ve,n,l)<<endl;
 	
 	return 0;

  }


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	map<int,int> M;
	cin>>N;
	FOR(i,N) {
		cin>>x;
		M[x]++;
	}
	vector<pair<int,int>> V;
	FORR(m,M) V.push_back(m);
	
	if(V.size()==1) {
		if(V[0].first==0) _P("Yes\n");
		else _P("No\n");
	}
	else if(V.size()==2) {
		if(V[0].first==0 && V[0].second*2==V[1].second) _P("Yes\n");
		else _P("No\n");
	}
	else if(V.size()==3) {
		if(((V[0].first^V[1].first)==V[2].first) && V[0].second==V[1].second && V[0].second==V[2].second) _P("Yes\n");
		else _P("No\n");
	}
	else {
		_P("No\n");
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4988
#include<bits/stdc++.h>
using namespace std;
const int N=1<<21;
#define mod 1000000007;
int n;
long long int dp[22][N];
int arr[22][22];

long long int sol(int p, int msk){
      //cout<<p<<' ';
      if(p==n)return 1;
      if(dp[p][msk]!=-1)return dp[p][msk];
      long long int ans=0;
      for(int i=0; i<n; i++){
            if( (!(msk & (1<<(i)))) && arr[p][i]==1){
                  long long int m=(msk| (1<<i));
                  ans+=(sol(p+1, m));
                  ans%=mod;
            }
      }
      //cout<<p<<' '<<msk<<" "<<ans<<'\n';
      return dp[p][msk]=ans;
} 

int main(){
      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
      cin>>n;
      int msk=0;
      for(int i=0; i<n; i++)
            for(int j=0; j<n; j++){
                  cin>>arr[i][j];
            }
      memset(dp, -1, sizeof(dp));
      cout<<sol(0, 0)<<'\n';
}

Measured memory_bytes: 364092
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#include <unordered_map>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	long long n, m;
	cin >> n >> m;
	if (n >= m) swap(n, m);
	if (n == 1) {
		if (m == 1) {
			cout << 1 << endl;
			return 0;
		}
		m -= 2LL;
		cout << m << endl;
		return 0;
	}
	n -= 2LL;
	m -= 2LL;
	cout << n * m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	long int N;
	scanf("%d",&N);
	char S[N+1];
	scanf("%s",S);
	int ans=N;
	int i,j;
	int count;
	for(i=0;i<N;i++){
		if(S[i] =='E')	count++;
	}
	for(i=0;i<N;i++){
		if(S[i] =='E')	count--;
		if(S[i-1] =='W')	count++;
		if(count <= ans)	ans=count;
	}
	
	printf("%d",ans);
	return 0;}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int INF = 1 << 24;

typedef unsigned long long ull;

int main(){
    int n;
    while(std::cin >> n, n){
        std::vector<int> v[2];
        v[1] = std::vector<int>(n);

        REP(i, n){
            int j;
            std::cin >> j;
            v[0].push_back(j);
        }
        std::sort(v[0].begin(), v[0].end());

        std::vector<int> _v;
        FOR(i, 1, 2*n+1){
            _v.push_back(i);
        }

        std::set_difference(_v.begin(), _v.end(), v[0].begin(), v[0].end(), v[1].begin());

        // REP(j, 2){
        //     std::cout << "vector" << (j?"b":"a") << std::endl;
        //     for(auto i : v[j]){
        //         std::cout << i << std::endl;
        //     }
        // }

        int prev_card = 0;
        while(!v[0].empty() && !v[1].empty()){
            //std::cout << prev_card << std::endl;
            REP(i, 2){
                if(prev_card == 0){
                    prev_card = v[i][0];
                    v[i].erase(v[i].begin());
                }else{
                    bool can = false;
                    REP(j, v[i].size()){
                        if(prev_card < v[i][j]){
                            can = true;
                            prev_card = v[i][j];
                            v[i].erase(v[i].begin() + j);
                            break;
                        }
                    }
                    if(!can){
                        prev_card = 0;
                    }
                }

                if(v[i].empty()){break;}
            }
        }

        REP(j, 2){
            std::cout << v[!j].size() << std::endl;
        }
    }
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,x,max,min;
    long long sum;
    scanf("%d %d",&n,&x);
    max = min = sum = x;
    while (--n > 0) {
        scanf("%d",&x);
        if(x > max) max = x;
        if(x < min) min = x;
        sum += x;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2112
mod=10**9+7
s=input()
n=len(s)
dp=[2*[0]for _ in range(n)]
dp[0]=[1,2]
for i in range(1,n):
  if s[i]=="1":
    dp[i][0]=dp[i-1][0]*3+dp[i-1][1]
    dp[i][1]=dp[i-1][1]*2
  else:
    dp[i][0]=dp[i-1][0]*3
    dp[i][1]=dp[i-1][1]
  dp[i][0]%=mod
  dp[i][1]%=mod
print(sum(dp[n-1])%mod)

Measured memory_bytes: 19700
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

#define debug() fprintf(stderr, "#%d\n", __LINE__);

template<typename T>
using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>;

struct Tree {
   Tree(Int n)
      : ps(n, -1) {}
   std::vector<Int> ps;
   Int root(Int x) {
      if( ps[x] == -1 ) return x;
      return ps[x] = root(ps[x]);
   }
   void connect(Int parent, Int child) {
      parent = root(parent), child = root(child);
      if( parent == child ) return;
      ps[root(child)] = root(parent);
   }
};

int main() {
   Int v, e, r;
   std::cin >> v >> e >> r;
   std::vector<Int> ss(e), ts(e), ws(e);
   rep(i, e) std::cin >> ss[i] >> ts[i] >> ws[i];
   std::vector<RQ<std::pair<Int,Int>>> qs(v);
   std::vector<Int> os(v);
   rep(i, e) {
      Int s = ss[i], t = ts[i], w = ws[i];
      qs[t].emplace(w, s);
   }
   std::vector<Int> xs(v);
   xs[r] = 2;
   Tree tree(v);
   bool fail = false;
   Int res = 0;
   rep(i, v) {
      Int a = tree.root(i);
      assert( xs[a] == 0 or xs[a] == 2 );
      guard( xs[a] == 0 );
      std::vector<std::pair<Int,Int>> ps(v);// p->i (cost, p)
      std::vector<Int> ys;
      while( xs[a] != 2 ) {
         ys.emplace_back(a);
         xs[a] = 1;
         if( qs[a].empty() ) {
            fail = true;
            break;
         }
         Int w, p;
         do {
            std::tie(w, p) = qs[a].top(); qs[a].pop();
            w += os[a];
            p = tree.root(p);
         } while( tree.root(a) == tree.root(p) );
         ps[a] = std::make_pair(w, p);
         res += w;
         if( xs[p] != 1 ) {
            a = p;
         }
         else {
            Int nr = a;
            Int b = a;
            do {
               if( qs[nr].size() < qs[b].size() ) nr = b;
               b = ps[b].second;
            } while( b != a );
            os[nr] -= ps[nr].first;
            b = a;
            do {
               if( nr != b ) {
                  tree.connect(nr, b);
                  while( not qs[b].empty() ) {
                     Int w2, p2; std::tie(w2, p2) = qs[b].top(); qs[b].pop();
                     Int nw = w2 + os[b] - ps[b].first - os[nr];
                     p2 = tree.root(p2);
                     qs[nr].emplace(nw, p2);
                  }
               }
               b = ps[b].second;
            } while( b != a );
            a = nr;
         }
      }
      if( fail ) break;
      for(Int y : ys) {
         xs[y] = 2;
      }
   }
   printf("%ld\n", res);
}



Measured memory_bytes: 3352
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    long long sum_=0;
    long long amount=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum_+=(long long) A[i];
        amount+=(long long)i+1;
    }
    string ans ="YES";
    if(sum_%amount!=0){
        cout << "NO" <<endl;
        return 0;
    }
    long long num = sum_/amount;
    for(int i=0; i<N; i++){
        int diff=A[(i+1)%N]-A[i];
        if(num-diff >= 0 && abs(num-diff)%N==0)continue;
        else{
            ans="NO";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
h,w,k=map(int,input().split())
c=[input() for _ in range(h)]


ans=0
for x2 in range(2**(h+w)):
  x=format(x2, 'b')
  x=(h+w-len(x))*'0'+x
  co=0
  for i in range(h):
    if x[i]=='0':
      for j in range(w):
        if x[h+j]=='0' and c[i][j]=='#':
          co+=1
  if co==k:
    ans+=1
print(ans)

Measured memory_bytes: 9204
def solve(string):
    s = int(string)
    limit = 1000000
    i = 2
 
    d = {s: 1}
    m = s
    while i < limit:
        if m % 2 == 0:
            m = m // 2
        else:
            m = m*3 + 1
 
        if m in d:
            break
        else:
            d[m] = 1
 
        i += 1
 
    return i
 
 
if __name__ == "__main__":
    print(solve(input()))

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

#define cst() int __t;scanf("%d",&__t);while(__t--)
#define rep(i,s,e) for(int i=s;i<e;++i)
#define repb(i,s,e) for(int i=s;i<=e;++i)
#define lep(i,s,e) for(int i=s;i>e;--i)
#define lepb(i,s,e) for(int i=s;i>=e;--i)
#define mst(a,b) memset(a,b,sizeof(a))
#define mcpy(des,sor) memcpy(des,sor,sizeof(sor))
#define pow2(x) ((x)*(x))
#define pt(x) cout<<#x<<"="<<x<<endl;


#define maxn 100006

typedef long long ll;
const int inf = 0x3f3f3f3f;

typedef pair<int,int> pii;

int main()
{
	int n,a[maxn],ma,mi,si,sa;
	cin>>n;
	ma=0;mi=n;
	repb(i,1,n)
	{
		cin>>a[i];
		ma=max(ma,a[i]);
		mi=min(mi,a[i]);
	}
	if(mi==ma)
	{
		if(a[1]==n-1||2*a[1]<=n)puts("Yes");
		else puts("No");
	}
	else if(mi+1==ma)
	{
		si=sa=0;
		repb(i,1,n)if(a[i]==mi)++si; else ++sa;
		if(2*mi-si+2<=n&&ma-si>0)puts("Yes");
		else puts("No");
	}
	else puts("No");
}


Measured memory_bytes: 640
"""
dfsでとき直し114
7,5,3がそれぞれ1回以上現れる

3-3-3
   -5
   -7
 -5-3
   -5
   -7
 -7-3
   -5
   -7
とかそういうヤツ

3 33 35 37 5 
"""

import sys
sys.setrecursionlimit(100000)

cnt = 0
num = "0"
X = int(input())
def dfs(num,is3,is5,is7):
    # print(num,is3 and is5 and is7)
    global cnt
    if is3 and is5 and is7:
        cnt += 1 
    N = "357"
    for n in N:
        if int(num+n) > X: continue #終了条件
        if n == "3":
            dfs(num+n,True,is5,is7)
        elif n == "5":
            dfs(num+n,is3,True,is7)
        elif n == "7":
            dfs(num+n,is3,is5,True)


dfs("0",0,0,0)
print(cnt)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

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

  sort(a.begin(), a.end(), greater<int>());

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      ans += a[i];
    } else {
      ans -= a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    int a0, a1;
    cin >> a0 >> a1;

    ll r0 = 0, r1 = max(a0, a1), r2;
    ll s = a0;

    for (int i = 2; i < n; i++) {
        int a;
        cin >> a;

        if (i & 1) {
            r2 = max(r0 + a, s);
        } else {
            r2 = max(r0 + a, r1);
            s += a;
        }
        r0 = r1;
        r1 = r2;
    }

    cout << r1 << endl;

    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#define MAXQ 50
using namespace std;

typedef long long int lli;

int N, M, Q, A[MAXQ], B[MAXQ], C[MAXQ], D[MAXQ], ans;
int arr[10];
void dfs(int idx, int v){
    if(idx == N){
        int score = 0;
        for(int j = 0; j < Q; ++j){
            if(arr[B[j] - 1] - arr[A[j] - 1] == C[j])
                score += D[j];
        }
        ans = max(ans, score);
        return;
    }
    for(int j = v; j <= M; ++j){
        arr[idx] = j;
        dfs(idx + 1, j);
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M >> Q;
    for(int j = 0; j < Q; ++j){
        cin >> A[j] >> B[j] >> C[j] >> D[j];
    }
    dfs(0, 1);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    h = [set()]
    for c in S:
        h.append(h[-1] | set(c))
    t = [set()]
    for c in reversed(S):
        t.append(t[-1] | set(c))
    return max(len(hh & tt) for hh, tt in zip(h, reversed(t)))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    print(solve(N, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9180
ary_1 = gets.split(" ").map(&:to_i)
ary_2 = gets.split(" ").map(&:to_i)
ary_3 = gets.split(" ").map(&:to_i)

if ary_1[1] - ary_1[0] == ary_2[1] - ary_2[0] && ary_1[1] - ary_1[0] == ary_3[1] - ary_3[0] && ary_1[2] - ary_1[0] == ary_2[2] - ary_2[0] && ary_1[2] - ary_1[0] == ary_3[2] - ary_3[0]
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);

#ifdef BUGGY
	bool DEBUG = 1;
#endif
#ifndef BUGGY
	bool DEBUG = 0;
#endif

set<string> st;

int main()
{
	int N;
	scanf("%d", &N);

	string T = "";
	int ans = 1;

	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;

		if (st.find(S) != st.end()) {
			// cout << i << "\n";
			ans = 0;
		}
		if (i != 0) {
			if (T[T.size() - 1] != S[0]) {
			// cout << ">" << i << "\n";

				ans = 0;
			}
		}
		T = S;

		st.insert(S);

	}

	if (ans) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/

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

using namespace std;


int main(void){

    long long h, w;
    cin >> h >> w;
    
    if(h==2 && w==2) {
        cout << 1 << endl;
        return 0;
    }
    
    long long min_delta = h * w;
    for(long long i=1; i<h-1; i++) {
        long long square1 = i*w;
        long long square2 = (h-i) * ((w/2) + (w%2));
        long long square3 = (h-i) * (w/2);
        long long max = std::max({square1, square2, square3});
        long long min = std::min({square1, square2, square3});
        if(min_delta>max-min) {
            min_delta = max-min;
//            cout << min_delta << " " << square1 << " " << square2 << " " << square3 << endl;
        }
        
//        cout << square1 << " " << square2 << " " << square3 << " " << min_delta << endl;
        
        square2 = ((h-i)/2+(h-i)%2) * w;
        square3 = ((h-i)/2) * w;
        max = std::max({square1, square2, square3});
        min = std::min({square1, square2, square3});
        
//        cout << square1 << " " << square2 << " " << square3 << " " << min_delta << endl;
        
        if(min_delta>max-min) {
            min_delta = max-min;
//            cout << min_delta << "check2" <<  endl;
        }
    }
    
    

    for(long long i=1; i<w-1; i++) {
        long long square1 = i*h;
        long long square2 = (w-i) * ((h/2) + (h%2));
        long long square3 = (w-i) * (h/2);
        long long max = std::max({square1, square2, square3});
        long long min = std::min({square1, square2, square3});
        if(min_delta>max-min) min_delta = max-min;
        
//        cout << square1 << " " << square2 << " " << square3 << " " << min_delta << endl;
        
        square2 = ((w-i)/2+(w-i)%2) * h;
        square3 = ((w-i)/2) * h;
        max = std::max({square1, square2, square3});
        min = std::min({square1, square2, square3});

//        cout << square1 << " " << square2 << " " << square3 << " " << min_delta << endl;

        if(min_delta>max-min) min_delta = max-min;
    }

    cout << min_delta << endl;
    
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();

    let mut edges = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let (u, v, w) = i.read3::<usize, usize, usize>();
        let (u, v, w) = (u - 1, v - 1, w);

        edges[u].push((v, w));
        edges[v].push((u, w));
    }
    let start = edges
        .iter()
        .enumerate()
        .filter(|&(_u, vws)| vws.len() == 1)
        .map(|(u, _)| u)
        .next()
        .unwrap();
    let mut ds = vec![None; n];
    let mut q = vec![start];
    ds[start] = Some(0);


    while let Some(u) = q.pop() {
        let d = ds[u].unwrap();
        for &(v, w) in &edges[u] {
            if ds[v].is_none() {
                ds[v] = Some(d + w);
                q.push(v);
            }
        }
    }
    for d in ds {
        writeln!(o, "{}", d.unwrap() % 2).unwrap();
    }
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 16636
N = gets.to_i
kisu_cnt = 0
n_list = gets.split("\s").map {|s|s.to_i}
n_list.each do |n|
  if n%2 == 1 then
    kisu_cnt += 1
  end
end

if kisu_cnt%2 == 0 then
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 8452
import java.util.*;

public class Main {
	private static class Keiro {
		public int c, t;

		public Keiro(String[] tokens) {
			this.c = Integer.parseInt(tokens[0]);
			this.t = Integer.parseInt(tokens[1]);
		}
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int T = Integer.parseInt(tokens[1]);
		List<Keiro> keiros = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			tokens = in.nextLine().split(" ");
			keiros.add(new Keiro(tokens));
		}
		Collections.sort(keiros, new Comparator<Keiro>() {
			@Override
			public int compare(Keiro o1, Keiro o2) {
				if (o1.c < o2.c) {
					return -1;
				} else if (o1.c > o2.c) {
					return 1;
				} else {
					return 0;
				}
			}
		});
		int cost = -1;
		for (int i = 0; i < N; ++i) {
			Keiro keiro = keiros.get(i);
			if (keiro.t <= T) {
				cost = keiro.c;
				break;
			}
		}
		if (cost < 0) {
			System.out.println("TLE");
		} else {
			System.out.println(cost);
		}

		in.close();
	}
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        int A, B, C;

        Scanner scanner = new Scanner(System.in);
        A = scanner.nextInt();
        B = scanner.nextInt();
        C = scanner.nextInt();

        if (C <= (B / A)) {
            System.out.println(C);
        } else {
            System.out.println(B / A);
        }


    }
}


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

char name[15];
ll ne[8];

int main()
{
	int n;
	cin >> n;
	for(int z = 1;z <= n;z++){
		scanf("%s", name+1);
		char x = name[1];
		if(x == 'M') ne[1]++;
		if(x == 'A') ne[2]++;
		if(x == 'R') ne[3]++;
		if(x == 'C') ne[4]++;
		if(x == 'H') ne[5]++;
	}
	ll ans;
	ll a = ne[1]*ne[2]*ne[3];
	ll b = ne[1]*ne[2]*ne[4];
	ll c = ne[1]*ne[2]*ne[5];
	ll d = ne[1]*ne[3]*ne[4];
	ll e = ne[1]*ne[3]*ne[5];
	ll f = ne[1]*ne[4]*ne[5];
	ll g = ne[2]*ne[3]*ne[4];
	ll h = ne[2]*ne[3]*ne[5];
	ll i = ne[2]*ne[4]*ne[5];
	ll j = ne[3]*ne[4]*ne[5];
	ans = a+b+c+d+e+f+g+h+i+j;
	cout << ans << endl;
	return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    string s,t;
    cin >> N >> s >> t;
    REP(i,N) {
        bool flag = true;
        REP(j,N-i) if(s[i+j] != t[j]) flag = false;
        if (flag) {
            FOR(j,N-i,N) s.push_back(t[j]);
            cout << s.size() << endl;
            return 0;
        }
    }

    cout << (s+t).size() << endl;
    return 0;
}


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

int main() {
  int N, A, min, count;
  cin >> N;
  
   for(int i = 0; i < N; i++) {
     cin >> A;
     count =0;
     while(A % 2 == 0) {
       A /= 2;
       count++;
     }
     if(i==0) {
       min = count;
     }
     else {
       if(min>count){
         min = count;
       }
     }
   }
  cout << min << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n;
   cin>>n;
   vector<int> l(n);
   rep(i, n) cin>>l[i];

   sort(l.begin(), l.end());
   int cnt=0;
   rep(i, n) for(int j=i+1; j<n; j++) for(int k=j+1; k<n; k++)
      if(l[i]!=l[j] && l[j]!=l[k] && l[i]!=l[k]) if(l[i]+l[j]>l[k])
         cnt++;

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


Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.ArrayList;

class Main {
    public static void main(String... args) {
        Scanner IN   = new Scanner(System.in);
        int H = IN.nextInt();
        int W = IN.nextInt();
        ArrayList<String> a = new ArrayList<String>();
        int b[] = new int[W];
        for (int i = 0; i < H; i++) {
            String x = IN.next();
            if (x.indexOf("#") >= 0) {
                a.add(x);
                for (int j = 0; j < W; j++) {
                    if (x.charAt(j) == '#') {
                        b[j]++;
                    }
                }
            }
        }
        for (int i = 0; i < a.size(); i++) {
            for (int j = 0; j < W; j++) {
                if (b[j] > 0) {
                    System.out.print(a.get(i).charAt(j));
                }
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 25684
#include <iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<set>
#include<algorithm>
#include<iomanip>
typedef long long ll;
using namespace std;

int main()
{
    string S1,S2;
    cin>>S1>>S2;
    int Sol=0;
    for(int i=0;i<S1.length();i++)
    {
        if(S1[i]!=S2[i])Sol++;
    }


    cout<<Sol<<endl;


    return 0;
}



Measured memory_bytes: 3904
N = int(input())
a = list(map(int,input().split()))
dic = {}
for i in a:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1

L = []
for i in dic.keys():
    if dic[i] >= i:
       L.append(dic[i]-i)
    else:
       L.append(dic[i])

print(sum(L))


Measured memory_bytes: 17784
fun main(args: Array<String>) {
    var (X, Y) = readLine()!!.split(" ").map { it.toLong() }

    var count = 1
    while (true) {
        if (X * 2 <= Y) {
            X *= 2
            count++
        } else {
            break
        }
    }
    println(count)
}


Measured memory_bytes: 37912
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[10];
    int t,i,j,k;
    cin>>s;
    j=0;
    for(i=0;i<strlen(s);i++)
    {
        if(s[i]=='1')
        j++;
    }
    cout<<j;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[200010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[200010];
    rep(i, N) cin >> A[i];
    rep(i, N) cnt[A[i]]++;
    set<int> st;
    rep(i, N) st.insert(A[i]);
    vector<int> v;
    rep(i, 200010) if(cnt[i] > 0) v.push_back(cnt[i]);
    sort(v.begin(), v.end(),greater<int>());
    int ans = 0;
    int kind = st.size();
    while(kind > K) {
        ans += v.back(); v.pop_back();
        kind--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12408
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int sqrt_(int x) {
	int ok = 0, ng = mod;
	while (ng - ok > 1) {
		int mid = (ok + ng) / 2;
		if (mid * mid <= x)ok = mid;
		else ng = mid;
	}
	return ok;
}
signed main() {
	int s; cin >> s;
	int d = sqrt_(s);
	int a_b = s / d;
	int b_c = s - d * (s / d);
	int b = 1;
	for (int i = 1; i * i <= b_c; i++) {
		if (a_b >= i)b = max(b, i);
		if (a_b >= (b_c / i))b = max(b, (b_c) / i);
	}
	int a = a_b - b;
	int c = b_c / b;
	cout << "0 0 " << c + d << " " << a << " " << c << " " << a + b << endl;
}

Measured memory_bytes: 256
n,l = map(int,input().split())
isMina = False
isPlu = False
ans = []
for i in range(1,n+1):
  ans.append(l+i-1)
  if l+i-1 < 0:
    isMina = True
  elif i+i-1 > 0:
    isPlu = True
print(sum(ans)-min(ans) if not isMina else sum(ans)-max(ans) if not isPlu else sum(ans))

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int cnt =1;
  while(a>0 &&c>0){
    if(cnt%2==1)c-=b;
    else a-=d;
    cnt++;
  }
  if(cnt%2==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using i64 = long long;

std::vector<std::deque<int>> g;
std::vector<i64> c, r;

void dfs(int v, int p) {
    static int pos = 0;
    r[v] = c[pos++];
    for (int to : g[v]) {
        if (to == p) continue;
        dfs(to, v);
    }
}

bool cmp(i64 a1,i64 a2){
    return a1>a2;
}

int main() {
    int n;
    std::cin >> n;
    g.resize(n); c.resize(n); r.resize(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        std::cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 0; i < n; i++) std::cin >> c[i];
    std::sort(c.begin(), c.end(), cmp);
    dfs(0, -1);
    std::cout << std::accumulate(c.begin() + 1, c.end(), 0ll) << std::endl;
    for (int i = 0; i < n; i++) std::cout << r[i] << " ";
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF  int(1e6+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	int k;
	cin >> k;
	int ans = 0;
	while (g - r <= 0) {
		g *= 2;
		ans++;
		if (ans > 8)break;
	}
	while (b - g <= 0) {
		b *= 2;
		ans++;
		if (ans > 8)break;
	}
	if (ans <= k)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
  int n;
  cin >> n;
  set<string> items;
  rep(i, n) {
    string s;
    cin >> s;
    items.insert(s);
  }
  cout << items.size() << '\n';
  return 0;
}

Measured memory_bytes: 19184