akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

long long int a[51],b[51];

ll burger(ll c,ll d){
  if(c==0) return 1;
  else if(d==1) return 0;
  else if(d>1 && d<=(1+a[c-1])) return burger(c-1,d-1);
  else if(d==(2+a[c-1])) return b[c-1]+1;
  else if(d>(2+a[c-1]) && d<=(2+2*a[c-1])) return b[c-1]+1+burger(c-1,d-2-a[c-1]);
  else if(d==(3+2*a[c-1])) return 2*b[c-1]+1;
}
int main(){
  a[1]=5;b[1]=3;
  a[0]=1;b[0]=1;
  for(int i=2;i<51;i++){
    a[i]=a[i-1]*2+3;
    b[i]=b[i-1]*2+1;
  }
  ll n,x;
  cin>>n>>x;
  ll ans=burger(n,x);
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    map<string,bool> dic;
    
    for(int i=0;i<n;i++){
        string m,s;
        cin>>m>>s;
        
        if(m=="insert") dic[s]=true;
        else if(m=="find"){
            if(dic.count(s)) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 36480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    rep(i, 0, s.size())
    {
        if (s[i] != t[i])
            ++ans;
    }
    cout << ans << endl;
}
int main()
{
    func();
}

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

int main()
{
   int n;
   cin>>n;
   int wa=1;
   for(int i=0;i<8;i++){
       if(n<wa*2){
           break;
       }
       else{
           wa=wa*2;
       }
   }
    cout<<wa;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	int i, j;
	vector<int>d(n);
	for (i = 0; i < n; i++)
	{
		cin >> d.at(i);
	}
	int sum = 0;
	for (i = 0; i < n-1; i++)
	{
		for (j = i+1; j < n; j++)
		{
			sum += (d.at(i) * d.at(j));
		}
	}
	cout << sum << endl;
	
}

Measured memory_bytes: 3612
#include <stdio.h>

int T[105];
int P[105];
int X[105];

int main() {

	int N,M;

	scanf("%d",&N);

	int i, j;

	for (i = 0; i < N; i++) {
		scanf(" %d",&T[i]);
	}
	scanf("%d",&M);

	for (i = 0; i < M; i++) {
		scanf("%d %d",&P[i],&X[i]);
	}

	for (i = 0; i < M; i++) {
		int sum = 0;
		for (j = 0; j < N; j++) {
			if (j == P[i] - 1) { sum += X[i]; }
			else { sum += T[j]; }
		}
		printf("%d\n",sum);
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n,cnt=0,Mcnt=-INF;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	vector<ll>bucket(pow(10,5)+10);
	for (ll i = 0; i < n; i++) {
		if(a[i]+1 < pow(10,5))bucket[a[i] + 1]++;
		bucket[a[i]]++;
		if(0 < a[i]-1)bucket[a[i] - 1]++;
	}
	cout << *max_element(all(bucket)) << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,0,n) cin>>a[i];
  ll ans=a[0];
  rep(i,1,n){
    ans=gcd(ans,a[i]);
  }
  cout<<ans;
}

Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Unit Converter
public class Main{

	void run(){
		Map<String, Integer> ref = new HashMap<String, Integer>();
		ref.put("yotta", 24); ref.put("zetta", 21); ref.put("exa", 18); ref.put("peta", 15); ref.put("tera", 12);
		ref.put("giga", 9); ref.put("mega", 6); ref.put("kilo", 3); ref.put("hecto", 2); ref.put("deca", 1);
		ref.put("deci", -1); ref.put("centi", -2); ref.put("milli", -3); ref.put("micro", -6); ref.put("nano", -9);
		ref.put("pico", -12); ref.put("femto", -15); ref.put("ato", -18); ref.put("zepto", -21); ref.put("yocto", -24);
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt(); sc.nextLine();
		while(T--!=0){
			String[] t = sc.nextLine().split(" ");
			char[] s = null;
			int p = 0, K = 0;
			String w = "";
			if(t[0].contains(".")){
				p = t[0].indexOf('.')-1;
				t[0] = t[0].substring(0, p+1)+t[0].substring(p+2);
//				t[0].replaceAll("\\.", "");
//				System.out.println("T:"+t[0]);
				s = t[0].toCharArray();
			}
			else{
				p = t[0].length()-1;
				s = t[0].toCharArray();
			}
			if(t.length==2){
				w = t[1];
			}
			else{
				w = t[2]; p+=ref.get(t[1]);
			}
			int k = 0;
			while(s[k]=='0')k++;
			K = s.length-k;
			int exp = k<p?p-k:p-k;
			StringBuilder res = new StringBuilder();
			res.append(s[k]+"");
			if(K>1){
				res.append(".");
				for(int i=k+1;i<s.length;i++)res.append(s[i]);
			}
			System.out.println(res.toString()+" * 10^"+exp+" "+w);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		if(s.equals("Sunny")) {
			System.out.println("Cloudy");
		}else if(s.equals("Cloudy")) {
			System.out.println("Rainy");
		}else if(s.equals("Rainy")) {
			System.out.println("Sunny");
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int> W(N); 
  int S=0;
  for(int i=0; i<N; i++){
    cin>>W[i];
    S+=W[i];
  }
  int L=0; int Ans=10001;
  for(int i=0; i<N; i++){
    L+=W[i]; S-=W[i];
    if(abs(L-S)<Ans)
      Ans=abs(L-S);
  }
  cout<<Ans<<endl;
}


Measured memory_bytes: 3576
#include <iostream>
using namespace std;
int main()
{
    int cnt = 0, val, n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> val;
        if ((i % 2) == 1 && (val % 2) == 1)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define pb push_back
#define mp make_pair
#define M (ll) (1e5+7)
#define INF (3e18)
typedef vector < vector<pll> > vvpll;
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0);
//    freopen("zotiland.gir","r",stdin);
//    freopen("zotiland.cik","w",stdout);
    string s;cin>>s;
    ll n=s.size();
    for(ll i=0;i<n;i+=2)
        if(s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }
    for(ll i=1;i<n;i+=2)
        if(s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 256
class Dice
    @numbers = []

    def initialize numbers
        @numbers = numbers
    end

    def roll direction
        old = @numbers.dup
        case direction
        when "N"
            @numbers[0] = old[1]
            @numbers[1] = old[5] 
            @numbers[5] = old[4]
            @numbers[4] = old[0]
            @numbers[2] = old[2]
            @numbers[3] = old[3]
        when "E"
            @numbers[3] = old[5]
            @numbers[0] = old[3] 
            @numbers[2] = old[0]
            @numbers[5] = old[2]
            @numbers[1] = old[1]
            @numbers[4] = old[4]
        when "S"
            @numbers[0] = old[4]
            @numbers[1] = old[0] 
            @numbers[5] = old[1]
            @numbers[4] = old[5]
            @numbers[2] = old[2]
            @numbers[3] = old[3]
        when "W"
            @numbers[3] = old[0]
            @numbers[0] = old[2] 
            @numbers[2] = old[5]
            @numbers[5] = old[3]
            @numbers[1] = old[1]
            @numbers[4] = old[4]
        end
    end

    def top
        @numbers[0]
    end
    
    def right t, f
        case @numbers.index(f)
        when 0 then roll "S"
        when 2 then roll "W"; roll "S"
        when 3 then roll "E"; roll "S"
        when 4 then roll "S"; roll "S"
        when 5 then roll "N"
        end

        case @numbers.index(t)
        when 2 then roll "W"
        when 3 then roll "E"
        when 5 then roll "E"; roll "E"
        end

        @numbers[2]
    end
end

numbers = gets.chomp.split.map(&:to_i)
dice = Dice.new(numbers)
n_question = gets.chomp.to_i
n_question.times{
    top, front = gets.chomp.split.map(&:to_i)
    puts dice.right(top, front)
}

Measured memory_bytes: 8752
/**
*    created: 31.07.2020 11:19:43
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int 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++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    cout << ((v.size() % 2) ? v.size() : v.size() - 1) << endl;
    return 0;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int a,b,c;
    cin >> a >>b >> c;
    int sum = a + b + c;
    if(a == sum-a || b == sum-b || c == sum - c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
    int n, val;
    cin >> n;
    unordered_map<int, int> table;
    for (int i = 0; i < n; i++) {
        scanf("%d", &val);
        table[val]++;
    }
    int cnt = 0;
    for (auto it = table.begin(); it != table.end(); it++) {
        if (it->second > it->first) {
            cnt += it->second - it->first;
        }
        else if (it->second < it->first) {
            cnt += it->second;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4260
import java.util.*;

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

	public static void main(String[] args){
		StringBuffer sb = new StringBuffer();
		while(scan.hasNext()){
			int w = scan.nextInt();
			int i = 1;
			sb.setLength(0);
			while(i <= 512){
				if((w & i) == i){
					sb.append(i).append(' ');
				}
				i = i << 1;
			}
			String s = sb.toString().trim();
			System.out.printf("%s\n", s);
		}
	}
}

Measured memory_bytes: 26520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e15;

using Weight=int;
struct Edge{
  int src,dst;
  Weight weight;
  Edge():src(0),dst(0),weight(0){}
  Edge(int s,int d,Weight w):src(s),dst(d),weight(w){}
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

vector<int> Dij(Graph&g,int s){
    using state = pair<int,int>;
    priority_queue<state,vector<state>,greater<state>> pq;
    vector<int> dis(g.size(),INF);
    dis[s]=0;
    pq.push(state(0,s));
    while(!pq.empty()){
      int d=pq.top().first;
      int v=pq.top().second;
      pq.pop();
      if(dis[v]<d)continue;
      rep(i,g[v].size()){
        Edge &e=g[v][i];
        if(dis[e.dst]>dis[v]+e.weight){
          dis[e.dst]=dis[v]+e.weight;
          pq.push(state(dis[e.dst],e.dst));
        }
      }
    }
    return dis;
}


signed main(){
  int n,k;
  while(cin>>n>>k){
    if(n==0&&k==0)break;
    Graph g(n+1);
    rep(i,k){
      int f;cin>>f;
      if(f==0){
        int a,b;cin>>a>>b;
        a--;b--;
        vector<int> ans=Dij(g,a);
        cout<<(ans[b]==INF?-1:ans[b])<<endl;
      }else{
        int c,d,e;cin>>c>>d>>e;
        c--;d--;
        g[c].emplace_back(c,d,e);
        g[d].emplace_back(d,c,e);
      }
    }
  }

 return 0;
}



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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int main() {
	vector<vector <int> > a(3,vector<int>(3));
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	vector<int> b(n);
	rep(i,n) cin >> b[i];
	bool bingo[3][3];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			bingo[i][j] = false;
			for(int k=0; k<n; k++){
				if(a[i][j]==b[k]){
					bingo[i][j] = true;
				}
			}
		}
	}
	string ans = "No";
	for(int i=0; i<3; i++){
		if(bingo[0][i] && bingo[1][i] && bingo[2][i]) ans = "Yes";
	}
	for(int i=0; i<3; i++){
		if(bingo[i][0] && bingo[i][1] && bingo[i][2]) ans = "Yes";
	}
	if(bingo[0][0] && bingo[1][1] && bingo[2][2]) ans = "Yes";
	if(bingo[0][2] && bingo[1][1] && bingo[2][0]) ans = "Yes";
	cout << ans << endl;

}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetInput_int();
            Swap_array(input, 0, 1);
            Swap_array(input, 0,2);
            for(int i=0;i<input.Length;i++)
            {
                Console.Write(input[i]);
                if (i != 2)
                {
                    Console.Write(' ');
                }
            }
            
        }

        #region input
        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        #endregion
    }
}

Measured memory_bytes: 11092
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N;
int F[101][10];
LL P[101][11];

LL ans = -INF;

void solve(){
	//bit全探索
	for(int bit=1;bit<(2<<9);bit++){
		//店iと、joisinoお姉ちゃんの店のか、ぶった営業時間帯の数
		vector<LL> overlap(N+1,0);
		for(int b=0;b<10;b++){
			//bitのiビット目が立っているなら営業すると決める
			if((bit>>b)&1){
				for(int i=1;i<=N;i++){
					if(F[i][b]) overlap[i]++;
				}
			}
		}
		LL profit = 0;
		for(int i=1;i<=N;i++){
			profit += P[i][overlap[i]];
		}
		ans = max(ans,profit);
	}
}
 
int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
    	for(int j=0;j<10;j++){
    		cin >> F[i][j];
    	}
    }
    for(int i=1;i<=N;i++){
    	for(int j=0;j<=10;j++){
    		cin >> P[i][j];
    	}
    }
 
    solve();

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

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

struct st {
    int c;
    int s;
    int f;
};

int main() {
    int n;
    cin >> n;
    struct st stis[n-1];
    for(int i = 0; i < n - 1; i++) {
        struct st sti;
        int c, s, f;
        cin >> sti.c >> sti.s >> sti.f;
        stis[i] = sti;
        //if(sum < s) sum = s;
        //if(sum % f != 0) sum += f - (sum % f);
        //sum += c;
    }
    for(int i = 0; i < n; i++) {
        int sum = 0;
        for(int j = i; j < n - 1; j++) {
            if(sum < stis[j].s) sum = stis[j].s;
            if(sum % stis[j].f != 0) sum += stis[j].f - (sum % stis[j].f);
            sum += stis[j].c;
        }
        cout << sum << endl;
    }
    
    return 0;
}


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

const int mod=1000000007;

int main() {
    int n;
    cin >> n;
    vector<int>A(n);
    for (int i=0; i<n; i++){
        cin >> A[i];
    }
    int ans=0; 
    int x=0;
    for (int i=0; i<n; i++){
        ans=(ans+(long long)x*A[i])%mod;
        x=(x+A[i])%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3876
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let kx: Vec<isize> = read_vec();
    let k = kx[0];
    let x = kx[1];

    let ans = if (500 * k) >= x {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
long N, K, i; cin >> N >> K; long A=0, M, p[N]; 
for(i=0; i<N; i++){ cin >> p[i]; }
for(i=0; i<K; i++){ A+=p[i]; }
for(i=K, M=A; i<N; i++){ A=A+p[i]-p[i-K]; M=max(M, A); }
long double L=(M+K)/2.0;
cout << setprecision(15) << L << "\n";
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct BIT{
private:
  vector<ll> vec;
  ll n;
public:
  BIT(ll siz){
    n=siz;
    vec.resize(n+3,0);
  }
  void add(ll ps,ll x){
    ps++;
    while(ps<=n){
      vec[ps]+=x;
      ps+=ps&(-ps);
    }
  }
  ll sum(ll ps){
    ps++;
    ll res=0;
    while(ps>0){
      res+=vec[ps];
      ps-=ps&(-ps);
    }
    return res;
  }
};
ll tento_0(vector<ll> vec){
  ll n=vec.size(),res=0;
  BIT b(n+5);
  for(int i=1;i<=n;i++){
    ll val=vec[i-1];
    res+=b.sum(n+3)-b.sum(val);
    b.add(val,1);
  }
  return res;
}
ll f[2005][2005]={0},g[2005][2005]={0},dp[2005][2005]={0};
int main(){
  ll n;
  cin>>n;
  vector<ll> black,white;
  vector<P> bp,wp;
  for(int i=1;i<=2*n;i++){
    char c;
    ll num;
    cin>>c>>num;
    if(c=='B') {
      black.push_back(num);
      bp.push_back(P(num,i));
    }
    else {
      white.push_back(num);
      wp.push_back(P(num,i));
    }
  }
  sort(bp.begin(),bp.end());
  sort(wp.begin(),wp.end());
  vector<ll> bs,ws;
  for(int i=0;i<n;i++){
    bs.push_back(bp[i].second);
    ws.push_back(wp[i].second);
  }
  ll ans=tento_0(black)+tento_0(white);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(bs[j]<ws[i]){
        f[i][0]++;
        f[i][j+1]--;
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(ws[i]<bs[j]){
        g[0][j]++;
        g[i+1][j]--;
      }
    }
  }
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++) {
      if(j>0) f[i][j]+=f[i][j-1];
      if(i>0) g[i][j]+=g[i-1][j];
    }
  }
  for(int i=0;i<2005;i++){
    for(int j=0;j<2005;j++) dp[i][j]=174417441744;
  }
  dp[0][0]=0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(i<n){
        dp[i+1][j]=min(dp[i+1][j],dp[i][j]+f[i][j]);
      }
      if(j<n){
        dp[i][j+1]=min(dp[i][j+1],dp[i][j]+g[i][j]);
      }
    }
  }
  cout<<ans+dp[n][n]<<endl;
}


Measured memory_bytes: 94592
import * as fs from "fs"

const process = (n: number, h: number[]): string => {
  const costs = []
  for (let i = 0; i < n; i++) {
    costs.push(99999)
  }
  costs[0] = 0

  for (let i = 0; i < n; i++) {
    // i => 移動前の足場
    // 一個移動する場合のコスト
    if (i + 1 < n) {
      const move1 = costs[i] + Math.abs(h[i] - h[i + 1])
      costs[i + 1] = move1 < costs[i + 1] ? move1 : costs[i + 1]
    }
    // 二個移動する場合のコスト
    if (i + 2 < n) {
      costs[i + 2] = costs[i] + Math.abs(h[i] - h[i + 2])
    }
  }
  return costs[n - 1] + ""
}

const Main = (input: string): string => {
  const aa: string[][] = input.split("\n").map((e) => e.split(" "))
  const na0: number = aa[0].map((e) => parseInt(e))[0]
  const na1: number[] = aa[1].map((e) => parseInt(e))

  const res = process(na0, na1) + ""
  console.log(res)
  return res
}
Main(fs.readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 27684
#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;
  vector<int> l(n);
  rep(i, n) cin >> l.at(i);

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x = l.at(i);
    for (int j = i + 1; j < n; ++j) {
      int y = l.at(j);
      for (int k = j + 1; k < n; ++k) {
        int z = l.at(k);
        if (x == y || y == z || z == x) continue;
        if (x + y <= z || y + z <= x || z + x <= y) continue;
        ++ans;
      }
    }
  }

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

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

int main() {
    int a, b;

    while(true){
        cin >> a >> b;
        if(a == 0 && b == 0){
            break;
        }
        if(a > b){
            cout << b << " " << a << endl;
        }
        else{
            cout << a << " " << b << endl;
        }
    }

}


Measured memory_bytes: 3080
// AtCoder Beginner Contest 135
// D - Digits Parade
// https://atcoder.jp/contests/abc135/tasks/abc135_d
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define MOD 1000000007

ll dp[100006][13];

int main()
{
    string S;
    cin >> S;
    int N = S.size();

    rep(i, N) {
        int digit = (S[i]=='?') ? -1 : (S[i]-'0');

        for (int j = 0; j <= 9; j++) {
            if (digit==-1 || digit==j) {
                for (int m = 0; m < 13; m++) {
                    ll s = i==0 ? (m==0?1:0) : dp[i-1][m];
                    int k = (m*10+j)%13;
                    dp[i][k] += s;
                    dp[i][k] %= MOD;
                }
            }
        }
        // rep(q,13) cout << dp[i][q] <<" ";
        // cout << endl;
    }

    cout << dp[N-1][5] << endl;
}


Measured memory_bytes: 10704
// C - Write and Erase
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	map<int,int> F;
	rp(i, 0, N){
		int a; scanf("%d",&a);
		F[a]++;
	}
	int ans = 0;
	for(auto f:F) ans += f.second%2? 1:0;
	cout<< ans <<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int m; cin>>m;
	ll d=0LL, s=0LL;
	rep(i,m){
		ll a,b; cin>>a>>b;
		d+=b; s+=a*b;
	}
	cout<<d-1+(s-1)/9<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e7+5;
int n,len,q;
string ans;
map<string,int>p;
int vis[15];
void dfs(int x) {
    if(x==n) {
        memset(vis,0,sizeof(vis)),q=0;
        for(int j=0; j<n; j++) {
            if(!vis[ans[j]-'a'])
                ans[j]=(q+'a'),q++;
            vis[ans[j]-'a']++;
        }
        p[ans]=1;
        return ;
    }
    for(int i=0; i<=10; i++) {
        if(i>x)
            continue;
        ans+=(char)(i+'a');
        dfs(x+1);
        ans.pop_back();
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin>>n;
    dfs(0);
    for(auto i:p)
        cout<<i.first<<endl;
}


Measured memory_bytes: 14208
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	int N, X; cin >> N >> X;
	VLL m(N);
	int sum = 0,ans=0;
	for (int i = 0;i < N;i++) cin >> m[i];
	sort(all(m));
	for (int i = 0;i < N;i++) {
		if (sum + m[i] <= X) {
			sum += m[i];
			ans++;
		}
		else break;
	}
	for (int i = 0;;i++) {
		if (sum + m[0] <= X) {
			sum += m[0];
			ans++;
		}
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    sc.next();
    char[] s = sc.next().toCharArray();

    int count = 0;
    char tmp = ' ';
    for(int i = 0; i < s.length; i++){
      if(tmp != s[i]){
        count++;
        tmp = s[i];
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 26408
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
const int MOD=1e9+7;
ll N, ans = 1;
ll bai(ll a,ll b){
	for (ll i = 1; i <= b; i++) {
		if ((a*i)%b == 0)return a * i;
	}
}
int main(void) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		ll n;
		cin >> n;
		if (ans < n)swap(ans, n);
		ans = bai(ans, n);
	}
	cout << ans << endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
// #define PI 3.1415926535897932384626433832795
#define PI acos(-1.0)
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
// int __unset(int b, int i) {return b&(!(1<<i));}
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

// map<char, int> m;
// bool cmp(char a, char b) {
// 	return m[a]<m[b];
// }
int mod=1000000007;
void dfs(int p, int u, vii& dp, vector<vi>& adjlist, vi& vis) {
	vis[u]=1;
	int w=1,b=1;
	for(int i = 0; i < adjlist[u].size(); i++) {
		int v = adjlist[u][i];
		if(v==p) continue;
		if(!vis[v]) dfs(u, v, dp, adjlist, vis);
		w=(w*(dp[v].ff+dp[v].ss))%mod;
		b=(b*(dp[v].ss))%mod;
	}
	dp[u]={b,w};
}
int32_t main(void) {
	IOS;
	int n; cin>>n;
	vector<vi> adjlist(n);
	for(int i = 0; i < n-1; i++) {
		int u,v; cin>>u>>v; u--; v--;
		adjlist[u].pb(v); adjlist[v].pb(u);
	}
	vii dp(n, {0,0}); vi vis(n,0);
	dfs(0, 0, dp, adjlist, vis);
	cout<<(dp[0].ff+dp[0].ss)%mod<<endl;
   	time();
	return 0;
}

Measured memory_bytes: 16384
#include <iostream>
#include <vector>
#include <string>
#include <set>


using namespace std;

long long N;
string S;

using ll = long long int;
using vsi = vector<set<ll>>;

vsi step1() {
  vsi hoge(N);

  for (ll i = 0; i < N; i++) {
    if (S[i] == 'L') {
      hoge[i-1].insert(i);
    } else {
      hoge[i+1].insert(i);
    }
  }

  return hoge;
}

vsi mult(const vsi &a, const vsi &b) {
  vsi res(N);

  for (ll i = 0; i < N; i++) {
    for (ll k : b[i]) {
      for (ll l : a[k]) {
        res[i].insert(l);
      }
    }
  }
  return res;
}

vsi construct(const vsi &s, int k) {
  if (k == 1) {
    return s;
  }

  if (k % 2 == 0) {
    vsi tmp = construct(s, k/2);
    return mult(tmp, tmp);
  } else {
    vsi tmp = construct(s, k/2);
    vsi hoge= mult(s, tmp);
    return mult(hoge, tmp);
  }
}

int main() {
  cin >> S;
  N = S.size();

  vsi s1 = step1();
  vsi cs = construct(s1, 100000);

  cout << cs[0].size();
  for (int i = 1; i < N; i++) {
    cout << " " << cs[i].size();
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 28528
// @gaurav_512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'
 
ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//
 
 
void solve()
{
	int n, W;
	cin>>n>>W;
	vi w(n), v(n);
	fi(n)cin>>w[i]>>v[i];
	int V = 0;
	for(int i:v)	V+=i;
	vector<vector<ll>>dp(n+1,vl(V+1,1000000000005));
	for(int i=0; i<=n; i++)
		dp[i][0] = 0;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=V; j++)
		{
			if(v[i-1] > j){
				dp[i][j]=dp[i-1][j];
				continue;
			}
			dp[i][j] = min(dp[i-1][j], w[i-1]+dp[i-1][j-v[i-1]]);
		}
	}
	int ans = 0;
	for(int i=V; i>=0; i--)
	{
		if(dp[n][i]<=W)
		{
			ans = i;
			break;
		}
	}
	cout<<ans<<'\n';
}
int main()

{
	fastio;
//    int T;
//    cin>>T;
//    while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 83152
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<int>v(N + 1);
	for (int i = 1; i <= N; i++)cin >> v[i];
	vector<int>ans;
	while (v.size() > 1) {
		for (int i = v.size() - 1; i; i--) {
			if (v[i] == i) {
				ans.push_back(i);
				v.erase(v.begin() + i);
				break;
			}
			if (i == 1) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	for (auto i : ans)cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define ABS(X) ((X)<0?-(X):(X))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
    int n;
    int h,m;
    double angleH, angleM, dAngle;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%02d:%02d",&h, &m);
        //printf("%d, %d\n", h, m);
        angleM = 360*m/60.0;
        angleH = 360*h/12.0 + (360/12)*m/60.0;
        dAngle = ABS(angleM - angleH);
        dAngle = MIN(dAngle, 360.0-dAngle);
        if (dAngle < 30){
            puts("alert");
        } else if (dAngle < 90){
            puts("warning");
        } else {
            puts("safe");
        }
    }
    
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define INF 1010101010
#define MOD 1000000007

int H, W;

int main() {
    cin >> H >> W;
    string r;

    for (int i = 0; i < H; i++) {
        cin >> r;
        cout << r << endl;
        cout << r << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ull;
//typedef boost::multiprecision::cpp_int bigint;

vector<bool> check(ll N, VLL A, VLL B) {
	ull a = 0;
	for (ll n = 0; n < N; n++) {
		a = a * MOD + A[n];
	}
	ull t = 1;
	for (ll n = 0; n < N-1; n++)t *= MOD;
	vector<bool> flags(N, false);
	ull b = 0;
	for (ll n = 0; n < N; n++) {
		b = b*MOD + B[n];
	}
	for (ll n = 0; n < N; n++) {
		if (a == b)flags[n] = (flags[n] | true);
		a -= A[n] * t;
		a *= MOD;
		a += A[n + N];
	}
	b = 0;
	for (ll n = 0; n < N; n++) {
		b = b * MOD + (1-B[n]);
	}
	for (ll n = 0; n < N; n++) {
		if (a == b)flags[n] = (flags[n] | true);
		a -= A[n] * t;
		a *= MOD;
		a += A[n + N];
	}
	return flags;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N;
	cin >> N;
	VLL A(2*N);
	VLL B(N);
	for (ll n = 0; n < N; n++) {
		cin >> A[n];
		A[N + n] = A[n];
	}
	for (ll n = 0; n < N; n++)cin >> B[n];
	vector<bool> flags(N, true);
	//各ビットごと
	for (ll b = 0; b < 30; b++) {
		VLL AA(2 * N);
		VLL BB(N);
		for (ll n = 0; n < N; n++) {
			AA[n] = ((ll)1 << b) & A[n];
			AA[N + n] = ((ll)1 << b) & A[N + n];
			BB[n] = ((ll)1 << b) & B[n];
			AA[n] = (AA[n] >> b);
			AA[N + n] = (AA[N + n] >> b);
			BB[n] = (BB[n] >> b);
		}
		vector<bool> res = check(N, AA, BB);
		for (ll n = 0; n < N; n++) {
			flags[n] = flags[n] & res[n];
		}
	}
	for (ll n = 0; n < N; n++) {
		if (flags[n]) {
			cout << n << " ";
			ll x = B[0] ^ A[n];
			cout << x << "\n";
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

//a,b x
int main(){
	ll N; cin>>N;
    vector<ll> A(N+1,0);
	for(int i=2;i<=N;i++){
		ll tmp=i;
		ll j=2;
		while(j<=i){
			if(tmp%j==0){
				A[j]++;
				tmp/=j;
			}
			else j++;

			if(tmp==1) break;
		}
	}
	ll ans=1;
	for(int i=2;i<=N;i++) ans=(ans*(A[i]+1))%MOD;
	cout<<ans;
}

Measured memory_bytes: 256
//abc094_b.cpp
//Sat Apr 21 20:27:33 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	int n;
	int m;
	int x;
	cin >> n >> m >> x;

	int tozero = 0;
	int ton = 0;

	int a[m];
	for (int i=0;i<m;i++){
		cin >> a[i];
		if (a[i] < x){
			tozero++;
		}else{
			ton++;
		}
	}

	if (tozero < ton){
		cout << tozero << endl;
	}else {
		cout << ton << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
// const ll mod = 998244353ll;
const ll mod = 2000000011;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k, l, r;
ll x[500005], y[500005], z[500005];
string s;

void solve(){
    cin >> n >> s;
    ll r = 0, g = 0, b = 0;
    for(ll i=0;i<n;i++){
        if(s[i] == 'R')r++;
        if(s[i] == 'G')g++;
        if(s[i] == 'B')b++;
    }
    ll ans = r * g * b;
    for(ll i=0;i<n;i++){
        for(ll j=0;;j++){
            if(i - j < 0 || i + j >= n)break;
            if(s[i-j] != s[i] && s[i] != s[i+j] && s[i-j] != s[i+j])ans--;
        }
    }
    p(ans);
    return;
}


int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;

    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    
    // solve();
    return 0;

}
















Measured memory_bytes: 3660
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class pair {
        int a, b;

        pair(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) throws Exception {
        FastReader in = new FastReader();
        int n=in.nextInt(),h=in.nextInt(),w=in.nextInt();
        int mat[][]=new int[n][2];
        long ans=0;
        for (int i = 0; i < mat.length; i++) {
            int a=in.nextInt();
            int b=in.nextInt();
            mat[i][0]=a;
            mat[i][1]=b;
            ans+=Math.min(a/h,b/w);
        }
        System.out.println(ans);

    }
}

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

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

    long long sum = 0;

    long long a;
    cin >> a;

    for(long long i = 0; i <= a; i ++){
        if(i % 3 == 0 || i % 5 == 0){}else{
            sum += i;
        }
    }
    cout << sum;
}


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

int main()
{
    long sec;

    cin >> sec;

    if (sec >= 0 && sec <= 86400) {
        cout << sec / 3600 << ":" << (sec % 3600) / 60 << ":" << sec % 60 << endl;
    }
    
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 h,a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int N,K;
	cin>>N>>K;
	vi A(N);
	rep(i,0,N){
		cin>>A[i];
	}
	rep(cnt,0,K){
		vi B(N+1);
		rep(i,0,N){
			int st,ed;
			st=max((int)(i-A[i]),0);
			ed=min((int)(i+A[i]+1),N);
			B[st]++;
			B[ed]--;
		}
		rep(i,0,N){
			B[i+1]+=B[i];
		}
		if(A==B) break;
		A=B;
		B[N]=0;
	}
	rep(i,0,N){
		cout<<A[i]<<' ';
	}
	return 0;
}


Measured memory_bytes: 5560