akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<set>
#include<queue>
using namespace std;
int main()
{
    string str1,str2;
    cin>>str1>>str2;
    int len1=str1.length();
    str1+=str1;
    int fla=0;
    for(int i=0;i<len1;i++)
    {
       int flag=1;
       int l1=i;
       int l2=0;
       while(l2<len1)
       {
           if(str1[l1]!=str2[l2])
           {
               flag=0;
               break;
           }
           l1++,l2++;
       }
       if(flag)
       {
           fla=1;
           break;
       }
    }
    if(fla)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define PI 3.141592653589793238
#define mod 1000000007
#define endl '\n'
#define fastio; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

void solve()
{
    int x;
    cin>>x;
    int a,b;
    for(int i=-500;i<=500;i++)
    {
        for(int j=-500;j<=500;j++)
        {
            if((ll)i*i*i*i*i-(ll)j*j*j*j*j==x)
            {
                a=i,b=j;break;
            }
        }
    }
    cout<<a<<" "<<b<<endl;

}

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


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

array<const char*, 4> vs {{
  "dream",
  "dreamer",
  "erase",
  "eraser"
}};

int main() {
  static char S[100010]; cin >> S;
  static bool dp[100010];
  dp[0] = 1;
  const auto n = strlen(S);
  rep(i, n) {
    if(dp[i]) {
      for(auto const& e: vs) {
        const auto m = strlen(e);
        bool ok = 1;
        rep(k, m) {
          ok &= e[k] == S[i + k];
        }
        if(ok) {
          dp[i + m] = 1;
        }
      }
    }
  }
  puts(dp[n] ? "YES" : "NO");
}

Measured memory_bytes: 512
let nil = -1

type node = {
  mutable parent : int;
  mutable left : int;
  mutable right : int;
  mutable depth : int;
  mutable height : int;
}

let make () = { parent = nil; left = nil; right = nil; depth = nil; height = nil }

let search_root t n =
  let rec doit i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else doit (i + 1) in
  doit 0

let set_depth t root =
  let rec doit i d =
    if i = nil then ()
    else begin
      t.(i).depth <- d;
      doit t.(i).left (d + 1);
      doit t.(i).right (d + 1)
    end in
  doit root 0

let set_height t root =
  let rec doit i =
    t.(i).height <- max
      (if t.(i).left = nil then 0 else doit t.(i).left + 1)
      (if t.(i).right = nil then 0 else doit t.(i).right + 1);
    t.(i).height in
  let _ = doit root in
  ()

let print t =
  let sibling i =
    if t.(i).parent = nil then nil
    else if t.(t.(i).parent).left <> i && t.(t.(i).parent).left <> nil then t.(t.(i).parent).left
    else if t.(t.(i).parent).right <> i && t.(t.(i).parent).right <> nil then t.(t.(i).parent).right
    else nil in
  let degree i = (if t.(i).left <> nil then 1 else 0) + (if t.(i).right <> nil then 1 else 0) in
  t |> Array.iteri (fun i _ ->
    "node " ^ string_of_int i
    ^ ": parent = " ^ string_of_int t.(i).parent
    ^ ", sibling = " ^ string_of_int (sibling i)
    ^ ", degree = " ^ string_of_int (degree i)
    ^ ", depth = " ^ string_of_int t.(i).depth
    ^ ", height = " ^ string_of_int t.(i).height
    ^ (if t.(i).parent = nil then ", root"
       else if t.(i).left = nil && t.(i).right = nil then ", leaf"
       else ", internal node")
    ^ "\n"
    |> print_string)

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> make ()) in
  for _ = 0 to n - 1 do
    let (id, l, r) = Scanf.scanf "%d %d %d\n" (fun id l r -> (id, l, r)) in
    t.(id).left <- l;
    t.(id).right <- r;
    if l <> nil then t.(l).parent <- id;
    if r <> nil then t.(r).parent <- id;
  done;
  let root = search_root t n in
  set_depth t root;
  set_height t root;
  print t

Measured memory_bytes: 2376
/* 
 * Project: AtCoder Beginners Contest 156 C - Rally
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/08
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int n;
vector<int> x;

void solve() {

    sort(x.begin(), x.end());
    int sum = INT_MAX;
    for (int i=x[0];i<=x[n-1];i++) {
        int current_sum = 0;
        for (int j=0;j<n;j++) {
            current_sum += (x[j] - i) * (x[j] - i);
        }
        if (current_sum < sum) {
            sum = current_sum;
        }
    }
    printf("%d\n", sum);
    return;
}

int main() {

    scanf("%d", &n);
    for (int i=0;i<n;i++) {
        int temp;
        scanf("%d", &temp);
        x.push_back(temp);
    }

    solve();

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

int n,m;
int a[125252];

int main(){
	scanf("%d%d",&n,&m);
	REP(i,n)scanf("%d",a+i);
	ll sum = 0;
	REP(i,n)sum+=a[i];
	priority_queue<int> Q;
	REP(i,n)Q.push(a[i]);
	while(m--){
		int x = Q.top(); Q.pop();
		int y = x / 2;
		sum -= (x-y);
		Q.push(y);
	}
	printf("%lld\n",sum);
	return 0;
}

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

set<int> dp[12][12];

bool digit(char c){
  if( c - '0'< 0 || c-'0' > 9)return false;
  return true;
}

int stoi(string s){
  int res,tmp;

  res = 0;
  tmp = 1;
  for(int i=s.size()-1;i>=0;i--){
    res += (s[i]-'0') * tmp;
    tmp *= 10;
  }
  return res;
}  

set<int> cal(set<int> a,set<int> b,char o){
  set<int> res;
  set<int>::iterator i,j;
  res.clear();

  if(a.empty() || b.empty())return res;

  if(o=='+'){
    for(i=a.begin();i!=a.end();i++){
      for(j=b.begin();j!=b.end();j++){
	res.insert((*i) + (*j));
      }
    }
  }else if(o=='-'){
    for(i=a.begin();i!=a.end();i++){
      for(j=b.begin();j!=b.end();j++){
	res.insert((*i) - (*j));
      }
    }
  }else if(o=='*'){
    for(i=a.begin();i!=a.end();i++){
      for(j=b.begin();j!=b.end();j++){
	res.insert((*i) * (*j));
      }
    }
  }else if(o=='/'){
    for(i=a.begin();i!=a.end();i++){
      for(j=b.begin();j!=b.end();j++){
	if((*j))res.insert((*i) / (*j));
      }
    }
  }
  return res;
}

set<int> parse(string s){
  string tmp;
  set<int> ans[12];
  char op[12];
  int pos,cnt,check;

  pos = 0;
  cnt = 0;

  while(1){
    if(s[pos] == '('){
      tmp.clear();
      pos++;
      check = 1;
      while(1){
	if(s[pos] == '(')check++;
	if(s[pos] == ')')check--;
	if(!check)break;
	tmp.push_back(s[pos]);
	pos++;
      }
      ans[cnt].clear();
      ans[cnt] = parse(tmp);
      pos++;
    }else if(digit(s[pos])){
      tmp.clear();
      while(pos<(int)s.size() && digit(s[pos])){
	tmp.push_back(s[pos]);
	pos++;
      }
      ans[cnt].clear();
      ans[cnt].insert(stoi(tmp));
    }
    if(pos==(int)s.size())break;

    op[cnt] = s[pos];
    cnt++;
    pos++;
  }

  for(int i=0;i<=cnt;i++)dp[i][i] = ans[i];
      
  for(int i=1;i<=cnt;i++){
    for(int j=0;j+i<=cnt;j++){
      dp[j][j+i].clear();
      for(int k=j;k<j+i;k++){
	set<int> hoge;
	hoge = cal(dp[j][k],dp[k+1][j+i],op[k]);
	set<int>::iterator ite;
	for(ite=hoge.begin();ite!=hoge.end();ite++)dp[j][j+i].insert(*ite);
      }
    }
  }

  return dp[0][cnt];
}


int main(){
  string str;
  set<int> s;

  while(1){
    cin >> str;
    if(str == "#")break;

    s = parse(str);
    cout << s.size() << endl;    
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);// int　整数型

            string S = Console.ReadLine();// string　文字型

            string[] answer = new string[N];

            for (int i = 0; i < N; i++)
            {
                answer[i] = S.Substring(i,1);//入力文字をバラバラにする
            }
            int pos = K - 1;//配列の添字は０から始まる　１文字目→０　２文字目→１
            if (answer[pos]=="A")
            {
                answer[pos] = "a";
            }
            if (answer[pos]=="B")
            {
                answer[pos] = "b";
            }
            if (answer[pos]=="C")
            {
                answer[pos] = "c";
            }
            for (int i = 0; i < N; i++)
            {
                Console.Write(answer[i]);
            }
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
    int N,i,j,k,p=0,l;
    scanf("%d",&N);
    int ara[N];
    int even[N];
    for(k=0;k<N;k++){
        scanf("%d",&ara[k]);
    }
    for(i=0;i<N;i++){
        if(ara[i]%2==0){
            even[p]=ara[i];
             p++;
        }
    }
    for(l=0;l<p;l++){
        if(even[l]%3==0 || even[l]%5==0){
            j=1;
        }
        else{
            j=0;
            break;
        }
    }
    if(j){
        printf("APPROVED");
    }
    else{
        printf("DENIED");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
	int n, p[10], index, i;

	scanf("%d", &n);		
	for(i=0; i<n; i++){
		scanf("%d", &p[i]);
	}

	int max = p[0];	
	index = 0;
	for(i=1; i<n; i++){
		if(max < p[i]){
			index = i;	max = p[i];
		}
	}
	p[index] = p[index]/2;

	int s=0;
	for(i=0; i<n; i++){
		s += p[i];
	}
	printf("%d\n", s);
	return 0;
}

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

typedef pair<long long, long long> data_t;

int main(){
  int K,S;
  cin>>K>>S;
  int count=0;
  for(int x=0;x<=K;x++){
    for(int y=0;y<=K;y++){
      int z=S-y-x;
      if(z<=K&&z>=0)
        count++;
    }
  }
  cout<<count<<endl;
}


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

int main() {
	string s, a, b;
	cin >> s;
	while (1) {
		s.erase(s.begin() + s.size() - 1);
		if (s.size() % 2 == 0) {
			string a = s.substr(0, s.size() / 2);
			string b = s.substr(s.size() / 2, s.size());
			if (a == b) {
				break;
			}
		}
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N; cin >> N;
  vi arr(N);
  rep(i,N) cin >> arr[i];
  
  sort(rall(arr));
  bool possible = true;

  rep(i,N) {
    if (arr[i] != N-1 - i) {
      possible = false;
      break;
    }
    ++i;
    if (i < N && arr[i] != arr[i-1]) {
      possible = false;
      break;
    }
  }

  int ans = possible ? 1 : 0;
  if (possible) {
    rep(i,N/2) {
      (ans *= 2) %= MOD;
    }
  }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int mod=1e9+7;
struct node{
    node *l,*r;
    int a,b;
    int tag;
    LL sum;
    node(int _a,int _b):a(_a),b(_b),l(NULL),r(NULL),tag(0),sum(0){}
}*X,*Y;
void build(node *n){
    if(n->a==n->b)return ;
    int mid=(n->a+n->b)/2;
    n->l=new node(n->a,mid);
    n->r=new node(mid+1,n->b);
    build(n->l);
    build(n->r);
}
LL sum(node *n){
    return n->tag?0:n->sum;
}
void pull(node *n){
    n->sum=(sum(n->l)+sum(n->r))%mod;
}
void push(node *n){
    if(n->tag){
        n->l->tag=1;
        n->r->tag=1;
        n->tag=0;
    }
}
void revise(node *n,int k,int x){
    if(n->a==n->b){
        //printf("%d\n",n->a);
        n->sum=x;
        n->tag=0;
        return ;
    }
    push(n);
    int mid=(n->a+n->b)/2;
    if(k<=mid)revise(n->l,k,x);
    else revise(n->r,k,x);
    pull(n);
}
LL query(node *n,int l,int r){
    if(n->a>=l&&n->b<=r){
  //      printf("?%d %lld\n",n->a,sum(n));
        return sum(n);
    }
    if(n->b<l||n->a>r)return 0;
    push(n);
    LL res=(query(n->l,l,r)+query(n->r,l,r))%mod;
    pull(n);
    return res;
}
int main(){
    LL n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    LL s[100005];
    s[0]=-1e18-1;
    for(int i = 1;i<=n;i++)
        scanf("%lld",&s[i]);
    X = new node(0,n);
    Y = new node(0,n);
    build(X),build(Y);
    revise(X,0,1);
    revise(Y,0,1);
   // printf("%lld %lld\n",sum(X),sum(Y));
    for(int i = 1;i<=n;i++){
        int A=upper_bound(s,s+n+1,s[i]-b)-s-1;
        int B=upper_bound(s,s+n+1,s[i]-a)-s-1;
        LL suma=query(X,0,A),sumb=query(Y,0,B);
      //  printf("%lld %d %lld %d\n",suma,A,sumb,B);
        if(s[i]-s[i-1]<a){
            X->tag=1;
        }
        if(s[i]-s[i-1]<b){
            Y->tag=1;
        }
        revise(X,i-1,sumb);
        revise(Y,i-1,suma);
    }
    printf("%lld\n",(sum(X)+sum(Y))%mod);
}

Measured memory_bytes: 21760
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define rep(i, s, n) for(int i = s;i<n;i++)
#define repe(i, s, n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<int> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

bool isSorted(vi p) {
    for (int i = 0; i < p.size() - 1; ++i) {
        if (p[i] > p[i + 1]) {
            return false;
        }
    }
    return true;
}

int main(void) {
    int n;
    cin >> n;
    vi p(n);

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

    bool can_asc = false;

    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            int temp_p_i = p[i];
            int temp_p_j = p[j];
            p[i] = temp_p_j;
            p[j] = temp_p_i;
            if (isSorted(p)) {
                can_asc = true;
            }
            p[i] = temp_p_i;
            p[j] = temp_p_j;
        }
    }
    if (can_asc) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
s=array(5,0)
N.times do|i|
  s_=get_nsp
  case s_[0]
  when "M" then
      s[0]+=1
  when "A" then
      s[1]+=1
  when "R" then
      s[2]+=1
  when "C" then
      s[3]+=1
  when "H" then
      s[4]+=1
  end
end
ans=0
3.times do|i|
  (i+1).upto(3) do|j|
      (j+1).upto(4) do|k|
          ans+=s[i]*s[j]*s[k]
      end
  end
end
puts ans

Measured memory_bytes: 3836
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
if len(c) == 3:
    x, y, z = c.keys()
    ans = (c[x] == c[y] == c[z]) and (x ^ y == z)
elif len(c) == 2:
    ans = (0 in c) and (c[0] * 3 == N)
elif len(c) == 1:
    ans = 0 in c
else:
    ans = False
print('Yes' if ans else 'No')


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

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

int main() {
	int n;

	while( 1 ) {
		cin >> n;
		if( n == 0 ) break;
		vector<int> s( n );
		int sum = 0;
		REP( i, n ) {
			cin >> s[i];
			sum += s[i];
		}
		sort( ALL( s ) );
		sum -= s[0];
		sum -= s[n - 1];

		cout << sum / ( n - 2 ) << endl;
	}

}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  long long asum = 0, bsum = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    asum += (long long)a.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> b.at(i);
    bsum += (long long)b.at(i);
  }
  
  bool ok = true;
  if(asum < bsum) ok = false;
  if(!ok) cout << -1 << endl;
  else{
    int ans = 0;
    for(int i = 0; i < n; i++) a.at(i) -= b.at(i);
    sort(a.begin(), a.end());
    long long sum = 0;
    for(int i = 0; i < n; i++){
      if(a.at(i) >= 0) break;
      sum += (long long) a.at(i);
      ans++;
    }
    for(int i = n-1; i >= 0; i--){
      if(sum >= 0) break;
      sum += a.at(i);
      ans++;
    }
    
    cout << ans << endl;
  }
}

Measured memory_bytes: 1024
import java.math.BigInteger

fun main(args: Array<String>) {
    val (n, h, w) = readLine()!!.split(" ").map { it.toInt() }
    println((1..n).count {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        a >= h && b >= w
    })
}

Measured memory_bytes: 38192
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)

int main(){
	fast
	long long n;
	cin>>n;
	long long s1=0;
	int i=1;
	for(;;i++){
		s1=s1+(long long)pow(26,i);
		if(s1>=n)
		 break;
	}
	
		string s="";
		//i-=1;
		n-=1;
		for(int j=1;j<i;j++)
		 n=n-(long long)pow(26,j);
		 
		
		for(int j=1;j<=i;j++){
			s1=(long long)pow(26,i-j);
			long long int k=0;
			for(;k<=26;k++){
				if(k*s1>n)
				 break;
			}
			s=s+char(int('a')+k-1);
			//if(k*s1>n)
			 k-=1;
			 
			n=n-k*s1;
		}
		cout<<s;
	
}


Measured memory_bytes: 4072
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> P;
int A[200006];
int a[200006];
signed main(){
	int N;cin>>N;
	int n=N*2-1;
	rep(i,n)cin>>A[i];
	
	int lb=1,ub=n;
	while(ub-lb>1){
		int mi=(ub+lb)/2;
		rep(i,n){
			if(A[i]>=mi)a[i]=1;
			else a[i]=0;
		}
		
			vector<P>V;
			int now=a[0],cnt=0;
			rep(i,n){
				if(now==a[i])cnt++;
				else{
					V.push_back(P(now,cnt));
					now=a[i];cnt=1;
					}
				}
			V.push_back(P(now,cnt));
			
			stack<P>S;cnt=0;
			S.push(P(1^a[0],0));
			rep(i,V.size()){
				if(V[i].second==1)cnt++;
				else{
					if(cnt&1){
						P p=S.top();S.pop();
						p.second+=cnt+V[i].second;
						S.push(p);
						cnt=0;
						}
					else{
						P p=S.top();S.pop();
						p.second+=cnt/2;
						S.push(p);
						P p2=V[i];
						p2.second+=cnt/2;
						S.push(p2);
						cnt=0;
						}	
					}
				}
				
			if(cnt&1)S.push(P(a[n-1],cnt));
			else{
				S.push(P(a[n-1],cnt/2));
				S.push(P(1^a[n-1],cnt/2));
				}	
			int sum=0;
			int col=0;
			while(sum<N){
				P p3=S.top();S.pop();
				col=p3.first;
				sum+=p3.second;
				}	
			
			if(col)lb=mi;
			else ub=mi;	
		}
		cout<<lb<<endl;
	}


Measured memory_bytes: 11740
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int W, H, N; {int[] a = in.ii(); W = a[0]; H = a[1]; N = a[2];}
        boolean[][] color = new boolean[W][H];
        int ans = W*H;
        for(int i = 0; i < N; i++){
            int x, y, a; {int[] b = in.ii(); x = b[0]; y = b[1]; a = b[2];}
            int jn = a == 1 ? x : W;
            int kn = a == 3 ? y : H;
            for(int j = a == 2 ? x : 0; j < jn; j++){
                for(int k = a == 4 ? y : 0; k < kn; k++){
                    if(!color[j][k]){
                        ans--;
                        color[j][k] = true;
                    }
                }
            }
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 21460
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		System.out.println((double)r*2*Math.PI);
 
	}
 
}

Measured memory_bytes: 35908
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int size=min(s.size(),t.size());
  sort(s.begin(),s.end());sort(t.rbegin(),t.rend());
  for(int i=0;i<size;i++){
    if(s.at(i)>t.at(i)){
      cout <<"No"<<endl;
      return 0;
    }
    else if(s.at(i)<t.at(i)){
      cout <<"Yes"<<endl;
      return 0;
    }
  }
  if(s.size()>=t.size()){
    cout <<"No"<<endl;
    return 0;
  }
  else{
    cout <<"Yes"<<endl;
  }
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    double r;
    double pi = 3.14159265;
    cin >> r;
    cout << (2 * r * pi) << endl;
    return 0;
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    for (int i = 0; i < b; i++) {
        cout << a;
    }

    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> vec(N);
  for(int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int i=0; i<N; i++) {
    cout << vec.at(i);
  }
}

Measured memory_bytes: 256
/*
 * @Description: 
 * @Version: 1.0
 * @Autor: goatzyq
 * @Date: 2020-08-20 12:07:17
 * @LastEditors: goatzyq
 * @LastEditTime: 2020-08-20 15:13:07
 */
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using db = double;
using vi = vector<int>;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi head
#define se second
#define SZ(x) ((int)(x).size())
#define debug(x) cout << #x <<'	' << x <<endl
const int inf = 0x3f3f3f3f;
const db eps = 1e-8;
const int mod = 1e9+7;
ll qpow(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b&1)ret = ret*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ret;
}

const int maxn = 3e5+100;
struct Edge{
	int to,nxt;
	Edge(){}
	Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxn*2];
int head[maxn],num;
void addedge(int a,int b){
	edge[num] = Edge(b,head[a]);
	head[a] = num++;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
    if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
    return *ci++;
}
inline int getint() {
    int A = 0;
    if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
    return A;
}
int mxdep[maxn],son[maxn],sz[maxn];
int dfn[maxn],dfx[maxn],n,k;
int dp[maxn];
int *f[maxn];
void init(int u,int fa){
	mxdep[u] = 0;son[u] = 0;sz[u] = 1;
	for(int e=head[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(v == fa) continue;
		init(v,u);
		mxdep[u] = max(mxdep[u],mxdep[v] + 1);
		sz[u] += sz[v];
		if(!son[u] || mxdep[v] > mxdep[son[u]])
			son[u] = v;
	}
}
void pre(int u,int fa){
	dfx[dfn[u] = ++*dfn] = u;
	f[u] = dp + dfn[u];
	if(son[u]) pre(son[u],u);
	for(int e=head[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(v==fa || v==son[u]) continue;
		pre(v,u);
	}
}
int g[maxn],h[maxn],ans;
void dfs(int u,int fa){
	if(son[u]) dfs(son[u],u);
	f[u][0] = son[u] ? sz[son[u]] : 0;
	int m = min(k,mxdep[u]);
	for(int e=head[u];~e;e=edge[e].nxt){
		int v = edge[e].to;
		if(v==son[u] || v==fa) continue;
		dfs(v,u);
		int len = min(k,mxdep[v] + 1);
		g[0] = sz[v];
		rep(i,1,len+1) g[i] = f[v][i-1];
		rep(i,0,len+1) h[i] = f[u][i];
		rep(i,0,len+1)
			f[u][i] = min(g[i]+h[min(i,k-i)],g[min(i,k-i)] + h[i]);	
		rep(i,0,len+1) if(k-i>len && k-i<=m) f[u][k-i] += g[i];
		rep(i,len+1,k-len) if(i<=m) f[u][i] += g[len];
		rep(i,1,m+1) f[u][i] = min(f[u][i],f[u][i-1]);
	}
	ans = min(ans,n - sz[u] + f[u][min(k,m)]);
}
void solve(){
	memset(head,-1, sizeof(head));num = 0;
	n = getint();k = getint();ans = n;
	rep(i,1,n) {
		int x = getint(),y = getint();
		addedge(x,y);
		addedge(y,x);
	} 	
	init(1,0);
	*dfn = 0;
	pre(1,0);
	dfs(1,0);
	printf("%d\n", ans);
}
int main(){
//	freopen("in.txt", "r", stdin);
	// int t;
	// t = getint();while(t--)
    solve();
	return 0;
}

Measured memory_bytes: 5052
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int a, b, ab;

void solve(string res, int nab, int na, int nb){
  if(nab == ab){
    pri(res);
    return;
  }

  if(na == 5 && nb < 4)return;
  if(nb == 5 && na < 4)return;

  if(na < a)solve(res + "A", nab + 1, na + 1, nb);
  if(nb < b)solve(res + "B", nab + 1, na, nb + 1);
  return;
}
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    scanf("%d%d", &a, &b);
    ab = a + b;
    solve("", 0, 0, 0);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3200
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> A >> B;
  if (B%A==0) cout << A+B << endl;
  else cout << B-A << endl;


}


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

int main()
{
    int x,y;
    for(int i=1;;i++){
        cin>>x>>y;
        if(x==0&y==0)break;
        if(x>y){
            cout<<y<<" "<<x<<endl;
        }else{
            cout<<x<<" "<<y<<endl;
        }
    }
}


Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C044
{
    class Program
    {
        static Dictionary<int,long> Calc(List<int> list)
        {
            Dictionary<int, long> dic = new Dictionary<int, long>();

            int size = list.Count;
            int sum = list.Sum();

            long[,] n=new long[size, sum+1];

            for (int i = 0; i < size; i++)
            {
                int a = list[i];
                if (i == 0)
                {
                    n[0, a] = 1;
                    n[0, 0] = 1;
                }
                else
                {
                    for (int j = 0; j < a; j++)
                    {
                        n[i, j] = n[i - 1, j];
                    }
                    for (int j = a; j <= sum; j++)
                    {
                        n[i, j] = n[i - 1, j] + n[i - 1, j - a];
                    }
                }
            }

            if (sum == 0)
            {
                dic.Add(0, 1);
            }
            else
            {
                for (int i = 0; i <= sum; i++)
                {
                    dic.Add(i, n[size - 1, i]);
                }
            }
            return dic;
        }

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int A = int.Parse(s[1]);
            string[] s1 = Console.ReadLine().Split(' ');

            List<int> high = new List<int>();
            List<int> low = new List<int>();
            int counterA = 0;
            for (int i = 0; i < s1.Length; i++)
            {
                int x = int.Parse(s1[i]);
                if (x < A) low.Add(A - x);
                else if (x > A) high.Add(x - A);
                else counterA++;
            }

            low.Sort(); high.Sort();
            long nA = (long)Math.Pow(2, counterA);

            var dicL = Calc(low);
            var dicH = Calc(high);
            int m = Math.Min(dicL.Count, dicH.Count);
            long counter = 0;
            for(int i = 0; i < m; i++)
            {
                counter += dicL[i] * dicH[i] * nA;
            }
            Console.WriteLine(counter-1);
        }
    }
}


Measured memory_bytes: 13408
#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 main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[100010];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    int r = a[0];
    rep(i, n) {
        if(abs(a[n - 1] - a[i] * 2) < abs(a[n - 1] - r * 2)) {
            r = a[i];
        }
    }
    cout << a[n - 1] << " " << r << endl;

    return 0;
}


Measured memory_bytes: 4016
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

int N;
vector<int>A;
vector<vector<int>>tree;
vector<int>depth;

int localmax(vector<int>v) {
	int maxv = 0;
	rep(i, v.size())maxv = max(maxv, v[i]);
	int sumv = 0;
	rep(i, v.size())sumv += v[i];
	return min(sumv-maxv, sumv / 2);
}

int solve(const int node) {
	if (tree[node].size() == 1) {

		if (depth[node] == 0) {//root is a leaf
			const int x = solve(tree[node][0]);
			if (x == -1) {
				return -1;
			}
			if (x == A[node])return 0;
			return -1;
		}

		//leaf
		return A[node];
	}

	int childsum = 0;
	vector<int>v;
	for (int x : tree[node])if (depth[x] > depth[node]) {
		const int y = solve(x);
		if (y == -1) {
			return -1;
		}
		if (y > 0)v.push_back(y);
		childsum += y;
	}
	const int count = localmax(v);
	if (!(childsum - count <= A[node] && A[node] <= childsum)) {
		return -1;
	}
	const int local = childsum - A[node];
	return A[node] - local;
}

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

	cin >> N;
	A = vector<int>(N);
	rep(i, N)cin >> A[i];
	tree = vector<vector<int>>(N);
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}

	depth = vector<int>(N, -1);
	stack<pair<int,int>>dfs;
	dfs.push(make_pair(0,0));
	while (!dfs.empty()) {
		auto x = dfs.top();
		dfs.pop();
		if (depth[x.first] != -1)continue;
		depth[x.first] = x.second;
		for (int y : tree[x.first]) {
			dfs.push(make_pair(y, x.second + 1));
		}
	}

	const int ans = solve(0);
	cout << (ans == 0 ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 20388
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
int main(void){
    char a ;
    cin >> a ;
    if(a - 'a' >= 0 ){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
n = input()

for _ in xrange(n):
	h = input()
	up = 0
	down = 0
	wall = map(int,raw_input().split())
	now = wall[0]
	for var in wall[1:]:
		if var > now and var - now > up:
			up = var - now
		elif var < now and now - var > down:
			down = now - var
		now = var
		
	print up,down

Measured memory_bytes: 6248
#include<stdio.h>

int main()
{
   int d, s, i, sum;

   while(scanf("%d", &d)!=EOF){

      sum = 0;

      for(i=1; i*d<=600-d; i++){
         s = d*(i*d)*(i*d);
         sum = sum + s;
      }

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

   }

   return 0;
}

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

int main() {
    int K;
    cin >> K;
    if (K % 2 == 1) cout << ((K + 1)/2)*(K/2);
    else cout << (K/2)*(K/2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vecint l(n);
  for(auto&&e:l)cin>>e;
  sort(ALL(l));
  int cnt = 0;
  REP(i,n)REP(j,i)REP(k,j) {
    if (l[i] == l[j] || l[j] == l[k]) continue;
    if (l[i] < l[j] + l[k]) ++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;

struct node{
    int key;
    node *right,*left,*parent;
};
node *root,*nil;
node *find(node *u,int k){
    while(u!=nil && k!=u->key){
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}

void insert(int k){
    node *y=nil;
    node *x=root;
    node *z;
    
    z=(node *)malloc(sizeof(node));
    z->key =k;
    z->left = nil;
    z->right = nil;
    
    while(x!=nil){
        y=x;
        if(z->key < x->key){
            x= x->left;
        }else{
            x = x->right;
        }
    }
    z->parent =y;
    if(y==nil){
        root=z;
    }else{
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void inorder(node *u){
    if(u==nil)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(node *u){
    if(u==nil)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
int main(){
    int n,x;
    string  com;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>com;
        if(com[0]=='f'){
            cin>>x;
            node *t=find(root,x);
            if(t != nil)cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
        else if(com=="insert"){
            cin>>x;
            insert(x);
        }else if(com=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 21896
#include <stdio.h>

/* �l�����ւ���֐� */
void swap (long long int *x, long long int *y) {
  long long int temp;    // �l���ꎞ�ۑ�����ϐ�

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivot�����߁A
* �S�f�[�^��pivot�����ڂɐU�蕪���A
* pivot�̓Y������Ԃ�
***/
long long int partition (long long int array[],long long int left,long long int right) {
  long long int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // �擪�v�f��pivot�Ƃ���

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivot��菬�������̂����ցA�傫�����̂��E��
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivot���X�V

  return j;
}

/* �N�C�b�N�\�[�g */
void quick_sort (long long int array[],long long int left,long long int right) {
  long long int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivot�����ɍċA�I�ɃN�C�b�N�\�[�g
    quick_sort(array, pivot+1, right);
  }
}

int 
main(){
	long long int K,N,Hi[300100];
	long long int All,i;
	All=0;
	scanf("%lld%lld",&N,&K);
	

	for(i=0;i<N;i++){
		scanf("%lld",Hi+i);
	}
	if(K>=N){
		printf("0\n");
		return 0;
	}
	if(K!=0)quick_sort(Hi,0,N-1);
	
	
	for(i=0;i<N-K;i++){
		All+=Hi[i];
	}
	printf("%lld\n",All);
		
 return 0;
}

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

int main(void)
{
	string s, t;
	cin >> s;
	cin >> t;
	
	int count = 0;
	for(int i = 0; i < 3; ++i){
		if(s[i] == t[i]){
			++count;
		}
	}
	
	cout << count << endl;
	return 0;
}

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

ll dp[85][2][2];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    dp[0][0][0] = 1000;
    dp[0][0][1] = 0;
    dp[0][1][0] = 1000;
    dp[0][1][1] = 0;
    rep(i,n){
        ll a;
        cin >> a;
        ll mon1 = dp[i][0][0] + dp[i][0][1] * a;
        ll stk1 = 0;
        dp[i+1][0][0] = mon1;
        dp[i+1][0][1] = 0;
        ll mon2 = dp[i][1][0] + dp[i][1][1] * a;
        ll stk2 = 0;
        chmax(dp[i+1][0][0], mon2);
        mon1 = dp[i][0][0] - (dp[i][0][0] / a) * a;
        stk1 = dp[i][0][1] + dp[i][0][0] / a;
        dp[i+1][1][0] = mon1;
        dp[i+1][1][1] = stk1;
        mon2 = dp[i][1][0] - (dp[i][1][0] / a) * a;
        stk2 = dp[i][1][1] + dp[i][1][0] / a;
        if(stk1 < stk2){
            dp[i+1][1][0] = mon2;
            dp[i+1][1][1] = stk2;
        }
        if(stk1 == stk2) chmax(dp[i+1][1][0], mon2);
    }
    ll ans = max(dp[n][0][0], dp[n][1][0]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
let rec power ( * ) one m = function
  | 0 -> one
  | n when n mod 2 = 0 ->
      power ( * ) one (m * m) (n / 2)
  | n ->
      m * power ( * ) one m (n - 1)

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Array.sort compare as_;
  if
    n mod 2 = 0 && as_ = Array.init n (fun i -> (i + 1) - i mod 2) ||
    n mod 2 = 1 && as_ = Array.init n (fun i -> (i + 1) - (i + 1) mod 2)
  then Printf.printf "%d\n" @@ power (fun n m -> n * m mod 1000000007) 1 2 (n / 2)
  else print_endline "0"

Measured memory_bytes: 6144
import sys
from operator import itemgetter
input = sys.stdin.readline

def main():
    N = int(input())
    tasks = [tuple(map(int, input().split())) for _ in range(N)]
    tasks.sort(key=itemgetter(1))
    start = 0

    for task in tasks:
        if start + task[0] > task[1]:
            print('No')
            return
        start += task[0]

    print('Yes')
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 31868
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    immutable string[7] W = [
        "Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday",
        "Saturday",
        "Sunday"];
    immutable int[12] D = [0,31,29,31,30,31,30,31,31,30,31,30];
    foreach(s;stdin.byLine())
    {
        auto md = s.split().map!(to!int);
        immutable m=md[0],d=md[1];
        if(m==0 && d==0) break;
        W[(D[0..m].reduce!"a+b"()+d+2)%7].writeln();
    }
}

Measured memory_bytes: 1072
n,t=map(int,input().split())
ct=[]
c=[]
for i in range(n):
    ct.append(list(map(int,input().split())))
    if ct[i][1]<=t:
        c.append(ct[i][0])
if c==[]:
    print('TLE')
else:
    print(min(c))

Measured memory_bytes: 3064