akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
bool comp(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
	return (a.second>b.second);
}
int main()
{
 	speed_up
    ll n,m,x,y,idx=0,j,flag=0,sum=0;cin>>n>>m;
    ll a[n];for(ll i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
	vector<pair<ll,ll>> v;
	for(ll i=0;i<m;i++)
	{
		cin>>x>>y;
		v.pb(make_pair(x,y));
	}
	sort(v.begin(),v.end(),comp);
	for(ll i=0;i<m;i++)
	{
		ll b1=v[i].first,c1=v[i].second;
		for(j=idx;(j<idx+b1 &&j<n);j++)
		{
			if(a[j]<=c1) a[j]=c1;
			if(a[j]>c1 && j<=idx+b1-1) {
			flag=1;break;}
		}
		idx=j;
		if(j==n) flag=1;
		if(flag) break;
	}
	for(ll i=0;i<n;i++) sum+=a[i];
	cout<<sum;
	 
    
     
	
	
	
	
	
	
 return 0;
}

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

int main(){
	int a, b, ans;
	while (true)
	{
		cin >> a;
		if(cin.eof()){
			break;
		}
		cin >> b;
		int sum = a + b;
		ans = 0;
		while(sum >= 1)
		{
			sum /= 10;
			ans += 1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3000
#include <stdio.h>
#include <string.h>
#include <set>

int main()
{
	int N, M;
	static int H[100000];
	static std::set<int> edge[100000];

	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}
	for (int i = 0; i < M; i++) {
		int A, B;
		scanf("%d%d", &A, &B);
		A--;
		B--;
		edge[A].insert(B);
		edge[B].insert(A);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		bool ok = true;
		for (int child : edge[i]) {
			if (H[child] >= H[i]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			ans++;
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 17776
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()

    println(pana2020a(n))
}

private fun pana2020a(n: Int): String {
    val k = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
    return k.split(", ").get(n - 1)

}

Measured memory_bytes: 35968
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        Long L = scan.nextLong();
        Long M = scan.nextLong();
        Long N = scan.nextLong();
        System.out.println(L/(M+N)*M + Math.min(L%(M+N), M));
    }
}


Measured memory_bytes: 23764
#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d%d%d", &a,&b,&c);
    if( a==b && b==c && a==c ){
        printf("No\n");
    } else if( a!=b && b!=c && c!=a ){
        printf("No\n");
    } else {
        printf("Yes\n");        
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
int n;
string s;
string res;
bool solve(bool f,bool sec){
  //true->sheep, false->wolf
  bool last=false;
  bool nxt=sec;
  bool bef=f;
  bool cur=sec;
  bool hoge;
  string ans;
  if(f&&sec){
    if(s[0]=='o')last=true;
  }
  else if(f&&(!sec)){
    if(s[0]=='x')last=true;
  }
  else if((!f)&&sec){
    if(s[0]=='x')last=true;
  }
  else{
    if(s[0]=='o')last=true;
  }
  if(f){
    ans+='S';
  }
  else{
    ans+='W';
  }
  rep1(i,n-1){
    if(cur){
      ans+='S';
    }
    else{
      ans+='W';
    }
    if(s[i]=='o'&&cur){
      nxt=bef;
      bef=cur;
      cur=nxt;
    }
    else if(s[i]=='x'&&!cur){
      nxt=bef;
      bef=cur;
      cur=nxt;
    }
    else if(s[i]=='x'&&cur){
      nxt=!bef;
      bef=cur;
      cur=nxt;
    }
    else if(s[i]=='o'&&!cur){
      nxt=!bef;
      bef=cur;
      cur=nxt;
    }
  }
  if(f==nxt){
    if(last&&ans[n-1]=='S'){
      res=ans;
      return true;
    }
    else if(!last&&ans[n-1]=='W'){
      res=ans;
      return true;
    }
  }
  return false;
}
signed main(){
  cin>>n;
  cin>>s;
  bool flag=false;
  flag=flag||solve(true,true);
  //if(flag)goto FINE;
  flag=flag||solve(false,true);
  //if(flag)goto FINE;
  flag=flag||solve(true,false);
  //if(flag)goto FINE;
  flag=flag||solve(false,false);
  //FINE:
	if(flag){
    cout<<res<<endl;
  }
  else{
    cout<<"-1"<<endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

using namespace std;

int main()
{

    int K;
    int X;

    cin >> K;
    cin >> X;

    if (K * 500 >= X)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << 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;

using ll = long long;
const ll MOD = 998244353;

int main() {
    string S, T, ans = "No\n";
    cin >> S >> T;
    int n = S.size();
    rep(i, n) {
        //cout << S << endl;
        if (S == T) ans = "Yes\n";
        S = S[n - 1] + S.substr(0, n - 1);
    }
    cout << ans;
}

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

using namespace std;

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        
        vector<vector<int> > v(N, vector<int>(N, 0));

        for(int i = 0; i < N; ++i) 
            for(int j = 0; j < N; ++j)
                cin >> v[i][j];

        vector<vector<int> > cnt(N, vector<int>(N, 0));

        for(int i = 0; i < N; ++i) {
            int minpos = 0;
            for(int j = 0; j < N; ++j) if(v[i][minpos] > v[i][j]) minpos = j;
            for(int j = 0; j < N; ++j) if(v[i][j] == v[i][minpos]) cnt[i][j]++;
        }
        
        for(int j = 0; j < N; ++j) {
            int maxpos = 0;
            for(int i = 0; i < N; ++i) if(v[maxpos][j] < v[i][j]) maxpos = i;
            for(int i = 0; i < N; ++i) if(v[i][j] == v[maxpos][j]) cnt[i][j]++;
        }

        int res = 0;
        for(int i = 0; i < N; ++i) 
            for(int j = 0; j < N; ++j) 
                if(cnt[i][j] == 2) res = v[i][j];

        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005;
int f[20][20],n,m;
char s[20][20];

int L(int x,int y){
	int res=0;
	rep(i,1,y)
		if(s[x][i]=='#')res++;
	return res;
}

int U(int x,int y){
	int res=0;
	rep(i,1,x)
		if(s[i][y]=='#')res++;
	return res;
}

int main(){
	read(n),read(m);
	rep(i,1,n)scanf("%s",s[i]+1);
	f[1][1]=1;
	rep(i,1,n)rep(j,1,m)
		if(i+j>=2){
			if(f[i-1][j]&&L(i,j-1)==0)
				f[i][j]=1;
			if(f[i][j-1]&&U(i-1,j)==0)
				f[i][j]=1;
		}
	if(f[n][m])puts("Possible");
	else puts("Impossible");
	return 0;
}


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

int main(){
    int n, a = 0;
    string s;

    cin >> n;

    for (int i = 0; i < n;i++){
        cin >> s;

        if(s=="Y"){
            cout << "Four" << endl;
            a = 1;
            break;
        }
    }
    
    if(a==0)
        cout << "Three" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

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

using namespace std;

typedef long long ll;

int main()
{
  int a, b;
  cin >> a >> b;
  if (a <= 8 && b <= 8)
  {
    cout << "Yay!" << endl;
  }
  else
  {
    cout << ":(" << endl;
  }
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != S[S.size()-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i; i < (S.size()-1)/2; i++) {
        if (S[i] != S[(S.size()-1)/2-1-i]) {
           cout << "No" << endl;
           return 0;
        }

    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    vector<string> road(h);
    rep(i,h) {
        cin >> road[i];
    }
    int res = 0;
    function<int(int,int)> solve =[&] (int sh, int sw) {
        vector<vector<int>> mp(h,vector<int>(w,50000));
        mp[sh][sw] = 0;
        int mx = 0;
        queue<pair<int,int>> que;
        que.emplace(sh,sw);
        while(!que.empty()) {
            auto now = que.front();
            que.pop();
            int hh = now.first;
            int ww = now.second;
            chmax(mx, mp[hh][ww]);
            if (hh > 0 && road[hh-1][ww] == '.' && mp[hh][ww] + 1 < mp[hh-1][ww]) {
                mp[hh-1][ww] = mp[hh][ww] + 1;
                que.emplace(hh-1,ww);
            }
            if (hh < h-1 && road[hh+1][ww] == '.' && mp[hh][ww] + 1 < mp[hh+1][ww]) {
                mp[hh+1][ww] = mp[hh][ww] + 1;
                que.emplace(hh+1,ww);
            }
            if (ww > 0 && road[hh][ww-1] == '.' && mp[hh][ww] + 1 < mp[hh][ww-1]) {
                mp[hh][ww-1] = mp[hh][ww] + 1;
                que.emplace(hh,ww-1);
            }
            if (ww < w-1 && road[hh][ww+1] == '.' && mp[hh][ww] + 1 < mp[hh][ww+1]) {
                mp[hh][ww+1] = mp[hh][ww] + 1;
                que.emplace(hh,ww+1);
            }
        }
        return mx;
    };
    rep(i,h) {
        rep(j,w) {
            if(road[i][j] != '.')continue;
            chmax(res, solve(i,j));
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<unordered_set>
#include<cmath>
#include<tuple>
#include<numeric>
#include<iterator>
#include<set>
#include<unordered_map>
#include<map>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<fstream>


#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define foru(i , a , b) for(ll i = a ; i < b ; i++)
#define ford(i , a , b) for(ll i = a ; i >= b ; i--)
#define dbg(a) cerr << #a << ": " << a << "\n";
#define ain(a , n) for(ll i = 0 ; i < n ; i++) cin >> a[i]
#define aout(a , n) for(ll i = 0 ; i < n ; i++) cout << a[i] << " "
#define M 1000000007
#define mp make_pair
#define mt make_tuple
#define cend cout << "\n"
#define all(x) x.begin() , x.end()
#define aout2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cout << a[i][j] << " ";} cout << endl;}
#define ain2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cin >> a[i][j];}}
#define ff first
#define ss second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <char> vch;
typedef vector <string> vs;

/*----------------------------- # --- MATH ALGORITHMS --- # -----------------------------*/

template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
template <class T> bool rev(T a , T b){return a > b;}
template <class T> ll maxpower(T a , T b){ll ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}


/*----------------------------- # --- MAIN CODE --- # -----------------------------*/

int main(){
    fastio;
#ifndef ONLINE_JUDGE
    freopen("testcase.txt" , "r" , stdin);
    freopen("error.txt" , "w" , stderr);
    freopen("output.txt" , "w" , stdout);
#endif
    double r;cin>>r;
    cout << 2* 3.14159265*r;
//    ll n , m; cin >> n >> m;
}
























Measured memory_bytes: 3780
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define amen ;
#define vec vector
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef double d;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;
typedef unsigned int ui;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    vector <int> cnt(m+1, 0);
    for (int i = 0; i < n; i++)
    {
        int k;
        cin >> k;
        while (k--)
        {
            int x;
            cin >> x;
            cnt[x]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= m; i++)
    {
        ans += (cnt[i] == n);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: String
    }

    let mut ans = 0;
    let n: Vec<u32>  = n.chars().map(|n| n.to_digit(10).unwrap()).collect();

    for i in n.iter() {
        ans += i;
    }

    if ans % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

const int MAXN = 100000 + 10;

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == '1') ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int x, a, b;

	cin>>x>>a>>b;

	if(b<=a){
		cout<<"delicious"<<endl;
	}else if(b<=a+x){
		cout<<"safe"<<endl;
	}else{
		cout<<"dangerous"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int count=0,i=0;
  int H[10000],W[10000];
  while(true){
    cin >> H[i] >> W[i];
    if(H[i]==0 && W[i]==0)
      break;
    count++;
    i++;
    }
  for(int l=0;l<count;l++){
    for(int k=0;k<H[l];k++){
      for(int j=0;j<W[l];j++)
        printf("#");
      printf("\n");
     }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	ll n;
	cin>>n;
	ll count=0;
	if(n%2==0)
	{
		
		ll x=10;
		while(n>=x)
		{
			count+=(n/x);
			x*=5;
		}
	}
	cout<<count;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = n / (a + b) * a;
  ans += min(a, n % (a + b));
  cout << ans << endl;



  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int n,i,j;
   long total=0;

   scanf("%d",&n);
   int taste[n];

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

   for(i=0;i<n;i++)
      for(j=i+1;j<n;j++){
         total+=taste[i]*taste[j];
      }

   printf("%ld\n",total);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N, count = 0;
	cin >> N;
	Graph G(N, vector<int>(N - 1, 0));
	FOR(i,0,N){
		FOR(j,0,N-1){
			int A;
			cin >> A;
			--A;
			G.at(i).at(j) = A;
		}
	}
	while (1)
	{
		vector<int> check;
		FOR(i,0,N){
			if(G.at(i).size()==0)
				continue;
			if(G.at(G.at(i).at(0)).size()==0)
				continue;
			if (G.at(G.at(i).at(0)).at(0) == i)
			{
				check.push_back(i);
				continue;
			}
		}
		if (check.size() == 0)
			{
				cout << -1 << endl;
				return 0;
		}
		FOR(i,0,check.size()){
			G.at(check.at(i)).erase(G.at(check.at(i)).begin());
		}
		bool r = true;
		FOR(i, 0, N)
		{
			if(G.at(i).size()!=0){
				r = false;
				break;
			}
		}
		count++;
		if(r){
			cout << count << endl;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 7164
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	vector<int> e(n);
	vector<int> w(n);
	if (s[0] == 'W') w[0]++;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'W') w[i]++;
		w[i] += w[i - 1];
		
	}
	//rep(i, n) pf(w[i]);
	if (s[n - 1] == 'E') e[n - 1]++;
	for (int i = n - 2; i >= 0; i--) {
		if (s[i] == 'E') e[i]++;
		e[i] += e[i + 1];
		
	}
	int ans = 1001001;
	rep(i, n) {
		ans = min(ans, e[i] + w[i] - 1);
	}
	cout << ans << endl;

	return 0;
}

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

int ans = 0;
int sm[200002];
int tt[200002];
int s[100000],t[100000],c[100000];

int main(){
  int n,C;

  cin>>n>>C;

  for(int i=0;i<n;i++)
    cin>>s[i]>>t[i]>>c[i];

  for(int i=1;i<=C;i++){
    for(int j=0;j<200002;j++) tt[j]=0;
    for(int j=0;j<n;j++)
      if(c[j]==i){
        tt[s[j]*2-1]++;
        tt[t[j]*2]--;
      }
    for(int j=1;j<200002;j++) tt[j]+=tt[j-1];
    for(int j=0;j<200002;j++) if(tt[j]>0) sm[j]++;
  }

  for(int i=0;i<200002;i++)
    ans = max(ans,sm[i]);

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 2944
from itertools import product

h, w, k = map(int, input().split())
mod = 10 ** 9 + 7

dp = [[0] * (w + 1) for _ in range(h + 1)]
for i in range(w + 1):
    dp[0][i] = 1 if i == 1 else 0


def check_valid_bridge(bridge):
    for i in range(1, w-1):
        if bridge[i-1] and bridge[i]:
            return False
    return True

for t in range(1, h + 1):
    for i in range(1, w + 1):
        X, Y, Z = 0, 0, 0
        if w != 1:
            p = product([True, False], repeat=w-1)            
            for bridge in p:
                if check_valid_bridge(bridge):
                    if i > 1 and bridge[i-2]:
                        X += 1
                    elif i < w and bridge[i-1]:
                        Y += 1
                    elif (i == 1 and not bridge[i-1]) or (i == w and not bridge[i-2]) or (1 < i < w and not bridge[i-2] and not bridge[i-1]):
                        Z += 1
        else:
            Z = 1
        # print(f"{X} {Y} {Z}")
        pattern_1 = dp[t-1][i-1] * X if i > 1 else 0
        pattern_2 = dp[t-1][i+1] * Y if i < w else 0
        pattern_3 = dp[t-1][i] * Z
        dp[t][i] = (pattern_1 + pattern_2 + pattern_3) % mod

# for line in dp:
#     print(*line)
print(dp[h][k])


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

int main(int argc, char *argv[]) {
  std::string s;
  std::cin >> s;
  std::cout << std::min(std::count(s.begin(), s.end(), '0'),
                        std::count(s.begin(), s.end(), '1')) * 2
            << std::endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	if(N==1)
	{
		printf("1\n");
	}
   else	if(N>=2&&N<4)
   {
		printf("2\n");
   }
   else	if(N>=4&&8>N)
	{
	printf("4\n");
	}
   else	if(N>=8&&N<16)
	{
	printf("8\n");
	}
   else	if(N>=16&&N<32)
   {
		printf("16\n");
   }
   else	if(64>N&&N>=32)
   {
		printf("32\n");
   }
   else	if(64<=N&&N<=100)
   {
		printf("64\n");
   }
   return 0;
}


Measured memory_bytes: 128
s = input()

while 1:
    if len(s)<=7:
        if s=='dream' or s=='dreamer' or s=='erase' or s=='eraser':
            print('YES')
            break
    
    elif s[-5:]=='dream':
        s = s[:-5]
        continue
    
    elif s[-7:]=='dreamer':
        s = s[:-7]
        continue
    
    elif s[-5:]=='erase':
        s = s[:-5]
        continue
    
    elif s[-6:]=='eraser':
        s = s[:-6]
        continue
    
    else:
        print('NO')
        break

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    long long int ans = 0;
    for(int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        ans += tmp - 1;
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar
int a[1000005];
inline int read()
{
	int res=0,f=0;
	char c;c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){res=res*10+c-48;c=gc();}
	if(f)return -res;
	return res;
}
int main()
{
	int n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int l=read(),r=read();
		a[l]++;a[r+1]--;
	}
	int x=0,ans=0;
	for(int i=1;i<=n;i++)
	{
		x+=a[i];
		if(x==m)ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 640
using System;

namespace Range {
    class Program {
        static void Main(string[] args) {
            string[] N = Console.ReadLine().Split(' ');
            int a = int.Parse(N[0]);
            int b = int.Parse(N[1]);
            int c = int.Parse(N[2]);

            if(a < b && b < c) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 8860
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    if (n / 100 == 7 || (n % 100) / 10 == 7 || n % 10 == 7)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 998244353;

ll sum[NMAX << 2] , lazy[NMAX << 2] , f[NMAX];

void push_up(int rt){	sum[rt] = (sum[rt << 1] + sum[rt << 1 | 1])%MOD;}
void push_down(int rt , int L , int R)
{
	if(lazy[rt])
	{
		lazy[rt << 1] = lazy[rt << 1 | 1] = lazy[rt];

		sum[rt << 1] = lazy[rt] * L %MOD;
		sum[rt << 1 | 1] = lazy[rt] * R % MOD;
		lazy[rt] = 0;
	}
}
void update(int L , int R , int c , int l , int r , int rt)
{
	if(L <= l && r <= R)
	{	
		sum[rt] = ((f[r] - f[l - 1] + MOD)%MOD)*c%MOD;
		lazy[rt] = c;
		return;
	}
	int mid = (l + r)>>1;
	push_down(rt , (f[mid] - f[l - 1] + MOD)%MOD , (f[r] - f[mid] + MOD)%MOD);
	if(L <= mid) update(L , R , c , l , mid , rt << 1);
	if(R > mid)	update(L , R , c , mid + 1, r ,rt << 1|1);
	push_up(rt);
}

ll query(int L , int R , int l , int r , int rt)
{
	if(L <= l && r <= R)	return sum[rt];
	int mid = (l + r) >> 1;
	push_down(rt , (f[mid] - f[l - 1] + MOD)%MOD , (f[r] - f[mid] + MOD)%MOD);
	ll ans = 0;
	if(L <= mid) ans = (ans + query(L , R , l , mid , rt << 1))%MOD;
	if(R > mid)	ans = (ans + query(L , R , mid + 1, r ,rt << 1|1))%MOD;
	push_up(rt);
	return ans;
}

int main(int argc, char const *argv[])
{
	int n , q;
	scanf("%d%d",&n,&q);
	f[1] = 1;
	for(register int i = 2;i <= n;i++)	f[i] =((f[i - 1] << 1) + (f[i - 1] << 3) + 1)%MOD;
	update(1 , n , 1 , 1 , n , 1);
	while(q--)
	{
		int l , r , d;
		scanf("%d%d%d",&l , &r , &d);
		update(n - r + 1 , n - l + 1 , d, 1 , n , 1);
		printf("%lld\n",sum[1]);
	}
	return 0;
}

Measured memory_bytes: 13576
MOD = 10 ** 9 + 7
N, M = list(map(int, input().split()))
A = sorted(map(int, input().split()), reverse=True) + [-1]
B = sorted(map(int, input().split()), reverse=True) + [-1]

def solve():
    su = 1
    h, w = 0, 0
    for i, n in enumerate(range(N*M, 0, -1)):
        #print("h={}, w={}, i={}, n={}, su={}".format(h, w, i, n, su))
        if su == 0:
            return su
        nh, nw = h, w
        if A[h] >= n:
            nh = h + 1
        if B[w] >= n:
            nw = w + 1
        if A[h] == B[w] and B[w] == n:
            #print(1)
            pass
        elif A[h] == n:
            #print(2)
            su = (su * nw) % MOD
        elif B[w] == n:
            #print(3)
            su = (su * nh) % MOD
        else:
            #print(4)
            su = (su * ((nh * nw - i) % MOD)) % MOD
        h = nh
        w = nw
    return su
        
            
if any(any(x1 == x2 for x1, x2 in zip(X, X[1:])) for X in [A, B]):
    print(0)
else:
    print(solve())


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    int cnt = 0;
    rep(i, 0, N) {
        if (A[i] < 0) cnt++;
    }
    int ans = 0;
    if (cnt % 2) {
        int neg_mx = -INF, pos_mn = INF;
        rep(i, 0, N) {
            if (A[i] <= 0) chmax(neg_mx, A[i]);
            if (A[i] >= 0) chmin(pos_mn, A[i]);
        }
        ans -= min(abs(neg_mx), abs(pos_mn)) * 2;
    }
    rep(i, 0, N) ans += abs(A[i]);
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll nCr(int n, int r)
{
    ll ans = 1;
    for (int i = n; i > n - r; --i)
    {
        ans = ans * i;
    }
    for (int i = 1; i < r + 1; ++i)
    {
        ans = ans / i;
    }
    return ans;
}

int main()
{
    int K;
    vector<int> check(5);
    for (int i = 0; i < 5;i++)
    {
        cin >> check[i];
    }
    cin >> K;
    bool ok = true;
    for (int i = 0; i < 5;i++)
    {
        for (int j = i + 1; j < 5;j++)
        {
            if(abs(check[i] - check[j]) > K){
                ok = false;
                break;
            }
        }
    }
    if(ok){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cctype>
using namespace std;
int main(){
  string s,type;

  while(cin>> s >> type, type!="X" ){
    int st=0;
    vector<string> v;
    for( int i=0;i<(int)s.length();i++ ){
      if( isupper(s[i]) ){
	s[i] = tolower(s[i]);
	if( i>0 )
	  v.push_back( s.substr(st,i-st) );
	st = i;
      }
      if( s[i]=='_' ){
	v.push_back( s.substr(st, i-st) );
	st = i+1;
      }
      if( i==s.length()-1 ){
	v.push_back( s.substr(st) ); break;
      }

    }

    //#define DEBUG
#ifdef DEBUG
    cout << endl;
    cout << s << " => " << type << endl;
    for( int i=0;i<v.size();i++ )
      cout << " [" << v[i] << "]";
    cout << endl;
    cout << "[";
#endif
    for( int i=0;i<v.size();i++ ){
      if( (type=="L"&&i>0) || type=="U" ){
	v[i][0] = toupper(v[i][0]);
      }
      if( type=="D" && i>0 )
	cout << "_";
      cout << v[i];
    }
    cout
#ifdef DEBUG
     << "]"
#endif
    << endl;

  }
  return 0;
}

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

using namespace std;

int main() {
int N;
cin >> N;
int L[100];
for (int i = 0; i < N; ++i) cin >> L[i];
sort(L, L + N, greater<int>());
int L_max = L[0];
int L_sum = 0;
for(int j=1; j<N; j++){
    L_sum += L[j];
}
if(L_max < L_sum){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}
return 0;








}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  int N;
  long long ans = 1;
  char S[100001];
  map<char, int> M;
  cin >> N;
  scanf("%s", S);
  for(int i = 0; i < N; i++){
    if(M.count(S[i])){
      M.at(S[i])++;
    }else{
      M[S[i]] = 1;
    }
  }
  for(auto p : M){
    ans *= (p.second+1);
    if(ans > 1000000007) ans %= 1000000007;
  }
  ans--;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

struct Link {
    int src;
    int dst;
    int64_t cost;

    bool operator<(const Link& rhs) const {
        return cost < rhs.cost;
    }
};

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

    vector<Link> links;
    links.reserve(n * n);
    for (auto i : irange(0, n)) {
        for (auto j : irange(0, n)) {
            int64_t cost;
            cin >> cost;
            links.push_back(Link{i, j, cost});
        }
    }

    auto sorted_links = links;

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

    vector<vector<int64_t>> costs(n, vector<int64_t>(n, -1));
    for (int i = 0; i < n; ++i) {
        costs[i][i] = 0;
    }

    int64_t total = 0;
    for (int i = 0; i < sorted_links.size(); ++i) {
        const auto& link = sorted_links[i];
        if (link.src <= link.dst) {
            continue;
        }

        if (costs[link.src][link.dst] >= 0 && link.cost > costs[link.src][link.dst]) {
            cout << "-1" << endl;
            return 0;
        }

        if (costs[link.src][link.dst] >= 0 && link.cost == costs[link.src][link.dst]) {
            continue;
        }

        total += link.cost;
        for (int i = 0; i < n; ++i) {
            if (costs[link.src][i] < 0) {
                continue;
            }

            for (int j = 0; j < n; ++j) {
                if (costs[link.dst][j] < 0) {
                    continue;
                }

                auto cost = costs[link.src][i] + link.cost + costs[link.dst][j];
                if (costs[i][j] >= 0 && cost >= costs[i][j]) {
                    continue;
                }

                costs[i][j] = cost;
                costs[j][i] = cost;
            }
        }
    }

    cout << total << endl;
}


Measured memory_bytes: 3840
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n;
    public static void main(String[] args) {
        while(read()){
            System.out.println(solve(n));
        }

    }
    static boolean read(){
        if(!sc.hasNext())return false;
        n = sc.nextInt();
        return true;
    }

    static long solve(int in){
        if(in == 1)return 1;
        return solve(in - 1)*in;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
struct unionfind {

    int par[200005];
    int rank[200005];

    void init (int N) {
        for(int i=0; i<N; i++) {
            par[i]=i;
            rank[i]=0;
        }
    }

    int  root(int x) {
        if(par[x]==x) {
            return x;
        }
        else {
            return par[x]=root(par[x]);
        }
    }

    void unite (int x, int y) {
        x=root(x);
        y=root(y);
        if(x==y) return;
        if(rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y) {
        return root(x)==root(y);
    }
};

int main() {
    int n, q, a, b,ans=0;
    cin >> n >> q;
    map<int,int> m;
    unionfind tree;
    tree.init(n);
    for(int i=0; i<q; i++) {
        cin >> a >> b;
        tree.unite(a,b);
    }
    for(int i=0; i<n; i++){
        m[tree.root(i)]++;
    }
    for(int i=0; i<n ;i++){
        if(m.count(i)){
            ans=max(ans,m[i]);
        }
    }
    cout << ans;
}

Measured memory_bytes: 14360
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int X,N;
    cin >> X >> N;
    if(N==0){
        cout << X << endl;
        return 0;
    }
    vector<int> p(N);
    for(int i=0;i<N;i++) cin >> p.at(i);
    sort(p.begin(), p.end());
    int minp=0;
    int maxp=200;
    int minid,maxid;
    for(int i=0;i<N;i++){
        if (p.at(i)<=X){
            if(minp<p.at(i)){
                minp = p.at(i);
                minid = i;
            }
        }else{
            if(maxp>p.at(i)){
                maxp = p.at(i);
                maxid = i;
            }
        }
    }
    if ((X!=minp) && (X!=maxp)){
        cout << X << endl;
        return 0;
    }else if(X==minp){
        for(int i=1;i<N+2;i++){
            if (X-i>=0){
                if(minid<=0){
                    cout << X-i << endl;
                    return 0;
                }else{
                    if (X-i==p.at(minid-1)){
                        minid--;
                    }else{
                        cout << X-i << endl;
                        return 0;
                    }
                }
            }
            if (X+i<=101){
                if(maxid>=N){
                    cout << X+i << endl;
                    return 0;
                }else{
                    if (X+i==p.at(maxid)){
                        maxid++;
                    }else{
                        cout << X+i << endl;
                        return 0;
                    }
                }
            }
        }
    }else if(X==maxp){
        for(int i=1;i<N+2;i++){
            if (X-i>=0){
                if(minid<=-1){
                    cout << X-i << endl;
                    return 0;
                }else{
                    if (X-i==p.at(minid)){
                        minid--;
                    }else{
                        cout << X-i << endl;
                        return 0;
                    }
                }
            }
            if (X+i<=101){
                if(maxid>=N-1){
                    cout << X+i << endl;
                    return 0;
                }else{
                    if (X+i==p.at(maxid+1)){
                        maxid++;
                    }else{
                        cout << X+i << endl;
                        return 0;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        int[] d = new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = sc.nextInt();
        }

        Arrays.sort(d);

        int center = N / 2;

        System.out.println(d[center] - d[center - 1]);
    }
}


Measured memory_bytes: 61196
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstr(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC098C_Attention();

#if 1
int main()
{
	ABC098C_Attention();
	fflush(stdout);
	return 0;
}
#endif

static void ABC098C_Attention()
{
	int N;
	get1int(N);

	auto people = new char[N + 1];
	memset(people, 0, sizeof(char) * (N + 1));

	getstr(people);

	auto east = new int[N];
	east[0] = 0;
	auto west = new int[N];
	west[N - 1] = 0;
	for (int i = 0; i < (N - 1); i++) {
		if (people[i] == 'W') {
			east[i + 1] = east[i] + 1;
		}
		else {
			east[i + 1] = east[i];
		}
	}
	for(int i = N - 1; i > 0; i--) {
		if (people[i] == 'E') {
			west[i - 1] = west[i] + 1;
		}
		else {
			west[i - 1] = west[i];
		}
	}

	int min = 300001;
	for (int i = 0; i < N; i++) {
		min = tp_min(min, east[i] + west[i]);
	}

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

	delete[] people;
	delete[] east;
	delete[] west;
}


Measured memory_bytes: 2944
#include<stdio.h>
#include<stdlib.h>

int main(){
  long long int a,b,c,d;
  long long int ans;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  ans=a*c;
  long long int ans2=a*d;
  long long int ans3=b*c;
  long long int ans4=b*d;
  if(ans2>ans){
    ans=ans2;        
  }
  if(ans3>ans){
    ans=ans3;
  }
  if(ans4>ans){
    ans=ans4;
  }
  printf("%lld",ans);
}

Measured memory_bytes: 1732
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iomanip>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a*b==15) cout<<"*"<<endl;
	if(a+b==15) cout<<"+"<<endl;
	if(a*b!=15&&a+b!=15) cout<<"x"<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/abc173/tasks/abc173_e
ll mod = 1e9+7;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0;i<n;i++){
        cin >> a[i];
    }
    sort(all(a));
    ll l = 0, r = n-1;
    ll ans = 1;
    if(k & 1){
        if(a[n-1] < 0){
            ans = 1;
            for(int i = n-1;i>=n-k;i--){
                ans *= a[i];
                ans %= mod;
            }
            if(ans < 0)
                cout << ans + mod;
            else 
                cout << ans;
            return 0;
        }
        r--;
        k--;
    }

    while(k){
        ll lv = a[l] * a[l+1];
        ll rv = a[r] * a[r-1];
        if(lv < rv)
            r -= 2;
        else 
            l += 2;
        k -= 2;
    }
    ans = 1;
    for(int i = 0;i<l;i++){
        ans *= a[i];
        ans %= mod;
    }
    for(int i = r+1;i<n;i++){
        ans *= a[i];
        ans %= mod;
    }
    if(ans < 0) 
        cout << ans + mod;
    else 
        cout << ans;

	return 0;
}


Measured memory_bytes: 4692
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#define maxn 510
#define ll long long

using namespace std;

int n;
ll a[maxn][maxn], primes[2020];
bool st[1000010];
int cnt;

void getprimes()
{
	for (int i = 2; i <= 10000; i ++ )
	{
		if (!st[i]) primes[++cnt] = i;
		for (int j = 1; primes[j] * i <= 10000; j ++ )
		{
			st[primes[j] * i] = 1;
			if (i % primes[j] == 0) break;
		}
	}
}

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

ll lcm(ll a, ll b)
{
	if (!a || !b) return a + b;
	return a / gcd(a, b) * b;
}

int main()
{
	getprimes();
	scanf("%d", &n);
	
	if (n == 2)
	{
		puts("2 3");
		puts("5 4");
		return 0;
	}
	
	for (int i = 1; i <= n; i ++ )
		for (int j = (i + 1 & 1) + 1; j <= n; j += 2)
			a[i][j] = primes[(i + j) / 2] * primes[n + (i - j) / 2 + (n + 1) / 2];
	
	for (int i = 1; i <= n; i ++ )
		for (int j = ((i & 1) + 1); j <= n; j += 2)
			a[i][j] = lcm(lcm(a[i][j - 1], a[i - 1][j]), lcm(a[i + 1][j], a[i][j + 1])) + 1;
	
	for (int i = 1; i <= n; i ++ )
	{
		for (int j = 1; j <= n; j ++ ) cout << a[i][j] << ' ';
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 5120
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
a = []
b = []
c = []
for p in P:
    if p <= A:
        a.append(p)
    elif A + 1 <= p <= B:
        b.append(p)
    else:
        c.append(p)

print(min(len(a),len(b),len(c)))

Measured memory_bytes: 3064