akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

class UnionFind {
    // 各ノードが根である時の高さ
    // ノードが根でないときは意味をなさない
    vector<int> rank;
    // 各ノードが属する木の根
    // findSetするときのみ更新される
    vector<int> p;
    // 二つの根を結合
    void link(int rx, int ry) {
        if (rx == ry) return;
        if (rank[rx] > rank[ry]) p[ry] = rx;
        else p[rx] = ry;
        if (rank[rx] == rank[ry]) rank[ry]++;
    }
public:
    //　根を作成
    // その木の高さは0
    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }
    // 初期化
    // 入力サイズ分のノードを確保
    // それらのノードをそれぞれ根とする木を作成
    // ノードの値は 0 ~ size-1
    UnionFind(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        rep(i,size) makeSet(i);
    }
    // あるノードの属する木の根を返す
    // 根を探す過程で途中のノードの親も更新
    int findSet(int x) {
        if (x != p[x]) p[x] = findSet(p[x]);
        return p[x];
    }
    // 二つのノードが同じ木にあるか判定
    bool same(int x, int y) {return findSet(x) == findSet(y);}
    // 二つのノードの属する木を結合
    void unite(int x, int y) {link(findSet(x), findSet(y));}
};

struct Edge {
    int from, to, cost;
    Edge(int f,int t, int c) {
        from = f;
        to = t;
        cost = c;
    }
    bool operator <(const Edge &e) const {return (cost < e.cost);}
    bool operator >(const Edge &e) const {return (cost > e.cost);}
};

ll kruskal(int v, const vector<Edge> &e) {
    UnionFind tree(v);
    ll ans = 0;
    for (auto edge: e) {
        if (!tree.same(edge.from, edge.to)) {
            ans += edge.cost;
            tree.unite(edge.from, edge.to);
        }
    }
    return ans;
}

int main() {
    fast_io
    int n;
    cin >> n;
    vector<P> x, y;
    int xtmp, ytmp;
    rep(i,n) {
        cin >> xtmp >> ytmp;
        x.emplace_back(xtmp, i);
        y.emplace_back(ytmp, i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    auto cost = [](int a, int b) {return abs(a - b);};

    vector<Edge> e;
    rep(i,n-1) {
        e.emplace_back(x[i].second, x[i+1].second, cost(x[i].first, x[i+1].first));
        e.emplace_back(y[i].second, y[i+1].second, cost(y[i].first, y[i+1].first));
    }

    sort(e.begin(), e.end());
    cout << kruskal(n, e) << endl;


    return 0;
}

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

int main() {
    int n = 0, t = 0;
    scanf("%d %d\n", &n, &t);
    int c_i = 0, t_i = 0;
    int ans = 10000;
    for (int i=0; i<n; i++) {
        scanf("%d %d\n", &c_i, &t_i);
        if (t_i <= t) {
            if (c_i < ans) {
                ans = c_i;
            }
        }
    }
    if (ans == 10000) printf("TLE\n");
    else printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
    double x1,x2,y1,y2,x,y,z;
    cin>>x1>>y1>>x2>>y2;
    x=x2-x1;
    y=y2-y1;
    x *=x;
    y *=y;
    z=sqrt(x+y);
    printf("%lf\n",z);
    return 0;
}

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

static int compar(const void* pa, const void* pb)
{
	const int *a = pa;
	const int *b = pb;

	return *a - *b;
}
int main(void)
{
	int n;
	int a[100001];
	int i;
	int before = 0;
	int sum = 0, count = 0;

	scanf("%d", &n);

	for (i = 0; i < n; ++i){
		scanf("%d", a + i);
	}
	a[n] = INT_MAX;
	qsort(a, n, sizeof(int), compar);
	for (i = 0; i <= n; ++i){
		if (before < a[i]){
			sum += count < before ? count : (count - before);
			count = 0;
		}
		++count;
		before = a[i];
	}
	printf("%d\n", sum);
	return 0;
}


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

using namespace std;

int n;

int digit_sum(int v)
{
  int ret = 0;
  while (v > 0) {
    ret += v % 10;
    v /= 10;
  }
  return ret;
}

int main()
{
  cin >> n;
  int m = INT_MAX;
  for (int i = 1; i <= n/2; ++i) {
    m = min(m, digit_sum(i) + digit_sum(n - i));
  }
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
dp=[99]*5000000
dp[0]=0
for i in range(n):
    for j in range(8):
        dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
        dp[i+9**j]=min(dp[i+9**j],dp[i]+1)
print(dp[n])

Measured memory_bytes: 42100
#include <iostream>
#include <vector>
#include <string>
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define rep(i,N) FOR(i,0,N)

using namespace std;


int main() {
    int N, M;

    cin >> N;
    vector<string> red(N);
    rep(i, N){
        cin >> red.at(i);
    }

    cin >> M;
    vector<string> blue(M);
    rep(i, M){
        cin >> blue.at(i);
    }

    vector<int> cnt;
    string word;

    rep(i,N){
        if (red.at(i) != "done"){
            int plus=1;
            int minus=0;
            word = red.at(i);
            FOR(j,i+1,N){
                if (red.at(j)==word){
                    red.at(j)="done";
                    plus++;
                }
            }
            rep(k,M){
                if(blue.at(k)==word){
                    minus++;
                }
            }
            cnt.push_back(plus-minus);
        }
    }

    int max=0;

    rep(l,cnt.size()){
        if(max<cnt.at(l)){
            max = cnt.at(l);
        }
    }

    if(max>0){
        cout << max;
    }else{
        cout << 0;
    }

    return 0;
}


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

using namespace std;

const long long INF = 1e9;

long long dp[10001];

int main(void)
{
    int health;
    int magics_count;
    vector<int> damages;
    vector<int> costs;

    for(int i = 0; i <= 10001; i++){
        dp[i] = INF;
    }

    cin >> health >> magics_count;

    for(int i = 0; i < magics_count; i++){
        int d, c;
        cin >> d >> c;
        damages.push_back(d);
        costs.push_back(c);

    }

    dp[0] = 0;
    for(int dmg = 0; dmg <= health; dmg++){
        for(int m = 0; m < magics_count; m++){
            int reach_damage = min(dmg + damages[m], health);
            dp[reach_damage] = min(dp[reach_damage], dp[dmg] + costs[m]);
        }
    }

    cout << dp[health] << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define long long long
template<class T> inline signed size(const T& t) { return t.size(); }

signed main() {
    int N; cin >> N;
    vector<long> A(N); for(int l = 0; l < N; l++) cin >> A[l];
    vector<long> vs;
    map<long, int> vm;
    {
        set<long> s0 = {0};
        for(int l = 0, l_M = size(A); l < l_M; l++) s0.insert(A[l]);
        for(auto& sv0: s0) vs.push_back(sv0);
        for(int l = 0, l_M = size(s0); l < l_M; l++) vm[vs[l]] = l;
    }

    int s = size(vs);
    vector<int> g(s);
    for(int i = 0; i < N; i++) g[vm[A[i]]]++;
    for(int j = s-1-1; j >= 0; j--) g[j] += g[j+1];
    if(0) { //dbg
        for(int l = 0, l_M = size(vs); l < l_M; l++) cout << (l ? " " : "") << vs[l];
        cout << '\n';
        for(int l = 0, l_M = size(g); l < l_M; l++) cout << (l ? " " : "") << g[l];
        cout << '\n';
    }

    long now = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] <= now) {
            cout << 0 << '\n';
        } else {
            long a = 0;
            for(int k = vm[now]+1; k <= vm[A[i]]; k++) {
                a += g[k] * (vs[k] - vs[k-1]);
                if(0) { //dbg
                    cout << k << ' ' << a << '\n';
                }
            }
            cout << a << '\n';
            now = A[i];
        }
    }
    return 0;
}


Measured memory_bytes: 13560
x, y = map(int, input().split())
for i in range(0, 101):
    for j in range(0, 101):
        if i + j == x and i*2 + j * 4 == y:
            print('Yes')
            exit()
print('No')
# print('Yes' if y%2 == 0 and x >= y//2 and  y // 4 - (y%4) //2 <= x else 'No')


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

using namespace::std;

int main() {
	vector<int> dishes(5); 
	cin >> dishes[0];
	cin >> dishes[1];
	cin >> dishes[2];
	cin >> dishes[3];
	cin >> dishes[4];

	int ans = 0;
	int max_diff=0;
	for (int i = 0; i < dishes.size(); i++) {
		int time;
		if (dishes[i] % 10 == 0) {
			time = dishes[i];
		}
		else {
			time = dishes[i] + (10 - dishes[i] % 10);
		}

		max_diff = max(max_diff, time - dishes[i]);
		ans += time;
	}
	ans = ans - max_diff;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int main(){
  int n,even=0,odd=0;
  cin>>n;
  rep(i,n){
    int a;
    cin>>a;
    if(a%2) odd++; //奇数
    else even++; //偶数
  }

  int ans=pow(3,n)-pow(2,even);
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
vector<int>a(200009, 0);
vector<int>g[200009];
bool vis[200009];
void dfs(int v, int val){
  a[v]=val;
  vis[v]=true;
  for(int i=0;i<g[v].size();i++){
    if(!vis[g[v][i]])dfs(g[v][i], a[v]+a[g[v][i]]);
  }
}
int main(){
  int n, q;
  cin>>n>>q;
  memset(vis, false, sizeof(vis));
  for(int i=0;i<n-1;i++){
    int x, y;
    cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for(int i=0;i<q;i++){
    int x, y;
    cin>>x>>y;
    a[x]+=y;
  }
  for(int i=1;i<n;i++){
    if(!vis[i])dfs(i, a[i]);
    vis[i]=true;
  }
  for(int i=1;i<=n;i++)cout<<a[i]<<" ";
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, m;
  cin >> n >> m;
  vector<ll> x(n), y(m);
  for(ll i = 0; i < n; i++) cin >> x[i];
  for(ll i = 0; i < m; i++) cin >> y[i];


  ll X = 0;
  for(ll i = 1; i < n; i++){
    X = (X + (x[i]-x[i-1]) * i * (n-i)) % mod;
  }

  ll Y = 0;
  for(ll i = 1; i < m; i++){
    Y = (Y + (y[i]-y[i-1]) * i * (m-i)) % mod;
  }
  cout << (X * Y) % mod << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

const int MAX = 1e6+10;
ll fac[MAX],inv[MAX],finv[MAX];

void init() {
    fac[0] = 1, fac[1] = 1;
	inv[0] = 0, inv[1] = 1;
    finv[0] = 1, finv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(int n, int r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
} 

int main() {
	init();
	ll x,y;
	cin >> x >> y;
	if((x+y)%3 != 0 || x>y*2 || y>x*2){
		cout << 0 << endl;
	}else{
		cout << nCr((x+y)/3,x-(x+y)/3) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <set>
#include <vector>

using namespace std;

const int MAX_N = 1e5 + 5;

int forb [MAX_N];
int fc [MAX_N];
set<int> alive;
set<pair<int, int>> forb_cnts;

void del (int u) {
  alive.erase(u);
  forb_cnts.erase(make_pair(fc[forb[u]], forb[u]));
  fc[forb[u]]--;
  if (fc[forb[u]] > 0) {
    forb_cnts.insert(make_pair(fc[forb[u]], forb[u]));
  }
}

int cur_forb;
int special () {
  if ((int) alive.size() == 3) {
    int u = *alive.begin();
    int v = *next(alive.begin());
    int w = *alive.rbegin();

    if (forb[u] == v && forb[v] == u && forb[w] != u && forb[w] != v) {
      return min(u, v) == cur_forb ? max(u, v) : min(u, v);
    }
    swap(u, w);
    if (forb[u] == v && forb[v] == u && forb[w] != u && forb[w] != v) {
      return min(u, v) == cur_forb ? max(u, v) : min(u, v);
    }
    swap(u, w);
    swap(v, w);
    if (forb[u] == v && forb[v] == u && forb[w] != u && forb[w] != v) {
      return min(u, v) == cur_forb ? max(u, v) : min(u, v);
    }
  }
  
  if ((int) forb_cnts.size() == 2) {
    pair<int, int> fst = *forb_cnts.begin();
    pair<int, int> snd = *forb_cnts.rbegin();

    swap(fst, snd);

    if (snd.first == 1) {
      if (alive.count(fst.second)) return fst.second;
      else if (fst.first == 1 && alive.count(snd.second)) return snd.second;
    }
  }
  return 0;
}

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

  for (int i = 1; i <= n; i++) {
    cin >> forb[i];
    fc[forb[i]]++;
  }

  if (n == 2) {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i <= n; i++) {
    if (fc[i] > 0) {
      forb_cnts.insert(make_pair(fc[i], i));
    }
  }

  for (int i = 1; i <= n; i++) {
    alive.insert(i);
  }

  vector<int> ans;

  for (int i = 1; i <= n; i++) {
    auto it = alive.begin();
    int to_del = special();
    if (to_del != 0 && to_del == cur_forb) {
      cerr << " ===== ERROR 2 ===== " << endl;
      exit(0);
    }
    if (to_del == 0) {
      while (*it == cur_forb) {
        it++;
        if (it == alive.end()) {
          cerr << " ====== ERROR ======= " << endl;
          exit(0);
        }
      }
      to_del = *it;
    }
    cur_forb = forb[to_del];
    cout << to_del << " ";
    del(to_del);
  }
  cout << endl;
}


Measured memory_bytes: 11008
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const b = args[0][0]
	if (b === 'A') console.log('T')
	else if (b === 'C') console.log('G')
	else if (b === 'G') console.log('C')
	else console.log('A')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Test int T;cin>>T;while(T--)
#define ls lower_bound
#define up upper_bound
#define bs binary_search
#define S second
#define F first
#define vi vector<int>  
#define pii pair<int,int>
#define vpi vector<pii>
#define vvi vector<vi>
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define m_n(v) *min_element(all(v))
#define m_x(v) *max_element(all(v))
#define ___(a) for(auto &i:a) cin>>i
/* 
#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
*/
int power(int x, int y,int mod){
    int res = 1;
    while (y)
    {
        if (y & 1)
        res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res;
}
int modInverse(int a, int m){
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int binomial(int n,int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
/*
vector<int> prime;
void sieve(){
    bool arr[300000]={0};
    prime.pb(2);
    for(int i=3;i<300000;i+=2){
        if(arr[i])continue;
        for(int j=i*i;j<300000;j+=i) arr[j]=1;
        prime.pb(i);
    }
}*/
//const int N=1e18+2;
const int mod = 1e9+7;
const int N= 1e5+9;

int32_t main() {
    IOS;
    int n;
    cin>>n;
    int ans = 1;
    for(int i=2;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            ans+=j;
        }
        ans+=i;
    }
    cout<<ans;
    return 0;
}

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



int main() {
 //入力を受け取る
  //Aiを小さいほうから足す
  //足したものがNより大きければｰ1、少なければN-足したもの
  int N,M;
  cin>>N>>M;
  vector<int>A(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i);}
  int work=0;
  for(int i=0;i<M;i++){
    work+=A.at(i);}
  if(work>N){cout<<-1<<endl;}
  else{cout<<N-work<<endl;}
  return 0;}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=100009;
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	string st;
	cin >> st;
	for(int i=0;i<st.size();i++)cout << 'x';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
map<int,int>d;
inline int read()
{
    char ch=getchar();
    int x=0,q=1;
    while(ch>'9' || ch<'0')q=ch==45?-1:q,ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return x*q;
}
inline int solve(int x)
{
    if(d[x]!=0)
        return d[x];
    else
    return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main(){
    d[0]=1; 
    d[1]=2; 
    int n;
    n=read(); 
    int ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  int n;
  cin>>n;
  char x;
  set<char> y;
  rep(i,0,n){
    cin>>x;y.insert(x);
  }
  if(y.size()==3) cout<<"Three\n";
  else cout<<"Four\n";
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using mat = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


// 二部マッチング：構造体--------------------------------------
// 二部グラフ。容量が全て1である最大流問題に帰着できる。
// がここではsupersourceとsupersinkを追加する必要はない
// verifyはここ <http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A&lang=jp>

struct Bipartite_Matching {
  int V;                 // 頂点数
  vector<vector<int>> G; // グラフの隣接リスト表現
  vector<int> match;     // マッチングのペア
  vector<bool> used;     // DFSで既に調べたかのフラグ

  Bipartite_Matching(int n) : V(n), G(n), match(n, -1), used(n, false) {}

  // uとvを結ぶ辺をグラフに追加する
  void add_edge(int u, int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  // 増加パスをDFSで探す
  bool dfs(int v){
    used[v] = true;
    for (int i=0; i<G[v].size(); i++){
      int u = G[v][i], w = match[u];
      if (w < 0 || !used[w] && dfs(w)){
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }

  // 二部グラフの最大マッチングを求める
  int bipartite_matching() {
    int res = 0;
    match.assign(match.size(), -1);
    for (int v=0; v<V; v++){
      if (match[v] < 0){
        used.assign(used.size(), false);
        if (dfs(v)) res++;
      }
    }
    return res;
  }
};


int main() {
  int N; cin >>N;
  Bipartite_Matching bm(2*N);
  vector<pair<int,int>> red(N); rep(i, N) cin >>red[i].first >>red[i].second;
  rep(j, N){
    int blue = N+j;
    int c,d; cin >>c >>d;
    rep(i, N){
      if (red[i].first < c && red[i].second < d) bm.add_edge(i, blue);
    }
  }
  int res = bm.bipartite_matching();
  cout <<res <<endl;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

N = int(input())
ans = N // 1.08

if math.floor(ans * 1.08) == N:
    print(int(ans))
elif math.floor((ans + 1) * 1.08) == N:
    print(int(ans + 1))
else:
    print(":(")


Measured memory_bytes: 6988
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int m1 = stdIn.nextInt();
        int d1 = stdIn.nextInt();
        int m2 = stdIn.nextInt();
        int d2 = stdIn.nextInt();
        //int x = stdIn.nextInt();
        //int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        //boolean flag = true;
        //for(int i = 0; i < s.length(); i++){
        //}
        
        if(m1 == m2){
            System.out.println(0);
        }else{
            System.out.println(1);
        }
        
        //System.out.println();
        //System.out.print();
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
	int n,k,i,j;
	cin>>n;
	int sum=0;
	vector<int> v;
	for(i=0;i<n;i++)
	{
		cin>>k;
		v.push_back(k);
		sum+=k;
	}
	sum/=n;
	int a1=0,a2=0;
	for(i=0;i<n;i++)
	{
		a1+=(abs(v[i]-sum))*(abs(v[i]-sum));
		a2+=(abs(v[i]-sum-1))*(abs(v[i]-sum-1));
	}
	int ans=min(a1,a2);
	cout<<ans<<endl;

  return 0;
}


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

int main() {
  int n;
  vector<string> f;

  while(cin >> n, n) {
    for(int i = 0; i < n; i++) {
      string F;
      cin >> F;
      f.push_back(F);
    }

    int cnt = 0;
    if(n > 1) {
      for(int i = 0; i < n-1; i++) {
        if((f[i] == "lu" && f[i+1] == "ru")
           || (f[i] == "ru" && f[i+1] == "lu")) cnt++;
        else if((f[i] == "ld" && f[i+1] == "rd")
                || (f[i] == "rd" && f[i+1] == "ld")) cnt++;
      }
    }
    cout << cnt << endl;
    f.clear();
  }
  return 0;
}


Measured memory_bytes: 3140
import math

n = int(input())

nlist = []
for _ in range(n):
    nlist.append(int(input()))

ans = 0

for l in nlist:
    if l == 1:
        continue
    flag = 1
    for i in range(2, int(math.sqrt(l)) + 1):
        if l % i == 0:
            flag = 0
            break
    if flag:
        ans += 1

print(ans)



Measured memory_bytes: 6012
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
const ll M=998244353;
const int maxn=(2e6)+10;
int mx,n,m,dis[maxn],ans,b[maxn];
char s[maxn],t[maxn];
ll mi[maxn],iv,tmp,T;
ll ksm(ll x,int y) {
	ll res=1;
	while (y) {
		if (y&1) res=res*x%mod;
		y>>=1; x=x*x%mod;
	} return res;
}
queue<int> q;
int in[maxn],head[maxn];
int nxt[maxn];
int to[maxn],tot;
void add(int x,int y) {
	in[y]++;
	tot++; nxt[tot]=head[x];
	head[x]=tot; to[tot]=y;
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	scanf("%s",t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	mi[0]=1;
	iv=ksm(M,mod-2);
	for (int i=1;i<=max(n,m);i++)
		mi[i]=mi[i-1]*M%mod;
	for (int i=1;i<=n;i++) b[i]=i;
	mx=n;
	for (int i=1;;i++) {
		for (int j=1;j<=n;j++)
			s[n*i+j]=s[j],b[n*i+j]=j;
		mx=max(mx,n*i+n);
		if (mx>=n+m) break;
	}
	b[mx+1]=1;
	for (int i=1;i<=m;i++) {
		T=(T+mi[i]*s[i])%mod;
		tmp=(tmp+mi[i]*t[i])%mod;
	}
	for (int i=1;i+m-1<=mx;i++) {
		if (T==tmp) add(b[i],b[i+m]);
		T-=M*s[i]%mod;
		if (T<0) T+=mod;
		T=T*iv%mod;
		T+=mi[m]*s[i+m]%mod;
		if (T>=mod) T-=mod;
	}
	for (int i=1;i<=n;i++) if (!in[i]) q.push(i);
	int cnt=n;
	while (!q.empty()) {
		int u=q.front();
		q.pop(); cnt--;
		ans=max(ans,dis[u]);
		for (int i=head[u],v;i;i=nxt[i]) {
			v=to[i];
			in[v]--;
			dis[v]=max(dis[v],dis[u]+1);
			if (!in[v]) q.push(v);
		}	
	}
	if (cnt) ans=-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 39168
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  a = a * a;
  cout << a - b << "\n";
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  ll A,B;
  cin >> A >> B;
  for(int i = 1;i <= 3;i++){
    if(i != A && i != B){
      cout << i << endl;
    }
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

int N;

int main() {
    cin >> N;
    cout << (N +1)/2 << endl;    
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void){
	int a[4], b[4], i, j, h, bl;
	while (scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		scanf("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]);
		h = bl = 0;
		for (i = 0; i < 4; i++){
			if (a[i] == b[i]) h++;
		}
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (i != j)
					if (a[i] == b[j]) bl++;
			}
		}
		printf("%d %d\n", h, bl);
	}
	return 0;
}

Measured memory_bytes: 596
pub fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let st: Vec<String> = buf.split_whitespace().map(|w| w.to_string()).collect();
    buf.clear();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut ab: Vec<i32> = buf.split_whitespace().map(|w| w.parse().unwrap()).collect();
    buf.clear();
    std::io::stdin().read_line(&mut buf).unwrap();
    let u: String = buf.trim().to_string();
    if st[0] == u {
        ab[0] -= 1;
    } else {
        ab[1] -= 1;
    }
    println!("{} {}", ab[0], ab[1]);
}

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

int main(){
  string s;
  cin >> s;
  
  int count = 0;
  
  if(s[0] == '1') ++count;
  if(s[1] == '1') ++count;
  if(s[2] == '1') ++count;
  
  cout << count << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T>
T gcd(T a, T b){
    if(b == 0){ return a;}
    else {
        return gcd(b, a % b);
    }
}
template<typename T>
T gcdAll(std::vector<T> & vals){
    int size = vals.size();
    T gcdVal = vals[0];
    for(int i = 1 ; i < size; i++){
        gcdVal = gcd(std::max(vals[i], gcdVal), std::min(vals[i], gcdVal));
    }
    return gcdVal;
}

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    ll val = gcdAll(A);

    cout << val << endl;

    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i, m){
        cin >> x[i];
    }

    if(n >= m){
        cout << 0;
        return 0;
    }

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

    vector<int> v(m-1);
    for(int i=0; i<m-1; i++){
        v[i] = x[i+1] - x[i];
    }
    sort(v.begin(), v.end());

    int ans = 0;
    rep(i, m-n){
        ans += v[i];
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
inline int re(){
	char c;
	int w=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')w=-1;
	int res = c-'0';
	while((c=getchar())>='0'&&c<='9')res = res*10+c-'0';
	return res*w;
}
int k,b,c;
int main(){
	
	scanf("%d",&k);
	for(int i=1;i<=k;++i)printf("ACL");
	
	return 0;
}

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

int isSqr(int x){
  int i=0;
  while(i*i<=x){
    if(i*i==x)return 1;
    i++;
  }
  return 0;
}

int dim2(int* x,int* y,int d){
  int sum=0;
  for(int i=0;i<d;i++){
    sum+=(x[i]-y[i])*(x[i]-y[i]);
  }
  return sum;
}

int main(){
  int n,d,i,j,cnt=0;
  cin>>n>>d;
  int x[n][d];
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      cin>>x[i][j];
    }
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(isSqr(dim2(x[i],x[j],d)))cnt++;
    }
  }
  cout<<cnt;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);
  vvvll A(2, vvll(N, vll(N)));
  REP(i,N) REP(j,N) IN(A[0][i][j]);

  vvvll A_sum(2, vvll(N, vll(N, 0)));
  REP(i,N) A_sum[0][i][i] = 1;

  while(K>0){
    if(K&1){
      REP(i,N) REP(j,N){
        A_sum[1][i][j] = 0;
        REP(k,N) A_sum[1][i][j] = (A_sum[1][i][j]+A_sum[0][i][k]*A[0][k][j])%MOD;
      }
      swap(A_sum[0], A_sum[1]);
    }

    REP(i,N) REP(j,N){
      A[1][i][j] = 0;
      REP(k,N) A[1][i][j] = (A[1][i][j]+A[0][i][k]*A[0][k][j])%MOD;
    }
    swap(A[0], A[1]);
    K>>=1;
  }

  ll ans = 0;
  REP(i,N) REP(j,N){
    ans += A_sum[0][i][j];
    ans %= MOD;
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
p = [0 for _ in range(10**5+1)]
for ai in a:
  p[ai] += 1
s = sum(a)

q = int(input())
for i in range(q):
  b,c = map(int,input().split())
  s += p[b]*(c-b)
  print(s)
  p[c] += p[b]
  p[b] = 0

Measured memory_bytes: 83444
N = int(input())
A = list(map(int, input().split()))

def max_pair(Asc):
    m1 = 0
    while Asc:
        m2 = Asc.pop()
        if m1 == m2:
            return m1
        m1 = m2

    return 0

A.sort()
print(max_pair(A) * max_pair(A))


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

bool isPrime(long long n){
    if(n<=1)return false;
    for(int i=2;i<=1001000;i++){
        if(n%i==0)return false;
    }
    return true;
}

int main(){
    long long n;
    cin >> n;
    long long f[1001001];
    for(int i=0;i<1001001;i++)f[i]=0;

    long long a = n;
    long long ans = 0;

    for(int i=2;i<=1001000;i++){
        if(a%i==0){
            for(int j=1;;j++){
                f[i]++;
                a = a/i;
                if(a%i!=0)break;
            }
        }
    }

    for(int i=0;i<1001001;i++){
        for(int j=1;;j++){
            if(f[i]<j)break;
            else{
                ans++;
                f[i]-=j;
            }
        }
    }

    if(isPrime(a))ans++;

    cout << ans << endl;


}

Measured memory_bytes: 11456
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#define MAX_N 200007
typedef long long ll;

int N;
ll res = 1e17;
ll a[MAX_N], sum[MAX_N];

int main ()
{
    scanf("%d", &N);
    for (int i = 1;i <= N; ++i) scanf("%lld", a + i), sum[i] = sum[i - 1] + a[i];
    for (int i = 2;i <= N - 2; ++i) {
        ll ans1 = 0, ans2 = 1e17, ans3 = 0, ans4 = 1e17;
        ll tmp1, tmp2;
        int l = 1, r = i, mid, ans5 = 0;
        while (l <= r) {
            mid = l + r >> 1;
            tmp1 = sum[mid], tmp2 = sum[i] - sum[mid];
            if (tmp1 < tmp2) std::swap(tmp1, tmp2);
            if (tmp1 - tmp2 < ans2 - ans1) {
                ans1 = tmp2, ans2 = tmp1;
                ans5 = mid;
            }
            if (sum[mid] - sum[i] + sum[mid] > 0) r = mid - 1;
            else l = mid + 1;
        }
        l = i, r = N, mid;int ans6 = 0;
        while (l <= r) {
            mid = l + r >> 1;
            tmp1 = sum[mid] - sum[i], tmp2 = sum[N] - sum[mid];
            if (tmp1 < tmp2) std::swap(tmp1, tmp2);
            if (tmp1 - tmp2 < ans4 - ans3) ans3 = tmp2, ans4 = tmp1, ans6 = mid;
            if (sum[mid] - sum[i] > sum[N] - sum[mid]) r = mid - 1;
            else l = mid + 1;
        }
        tmp1 = std::max(ans1, std::max(ans2, std::max(ans3, ans4)));
        tmp2 = std::min(ans1, std::min(ans2, std::min(ans3, ans4)));
        res = std::min(res, tmp1 - tmp2);
    }
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
#define ll long long
const int N = 1e5 +5;
ll a[N];
ll b[N];
bool ok(ll x,ll m,ll v,ll p,ll n){

    memcpy(b,a,sizeof a);
    for(int i = x;i <= n;++i){
        if(!v) break;
        b[i] += m;
        v --;
    }
    for(int i = 1;i <= p-1;++i){
        if(!v) break;
        b[i] += m;
        v --;
    }
    ll d = v * m;
    if(d == 0){
        return b[x] >= b[p];
    }
    else{
        for(int i = p;i < x;++i){
            if(b[i] - b[x] > 0) return 0;
            ll po = b[x] - b[i];
            po = min(po,m);
            d -= po;
            if(d <= 0) break;
        }
        if(d > 0) return 0;
        return 1;
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	ll n,m,v,p;
	cin >> n >> m >> v>>p;
	for(int i = 1;i <= n;++i){
		cin >> a[i];
	}
    sort(a + 1,a + n + 1,greater<ll>());
    int l = p ,r = n;
    while(l < r){
        int mid = l + r + 1 >> 1;
        if(ok(mid,m,v,p,n)) l = mid;
        else r = mid - 1;
    }
    cout<<l;
			
    return 0;


}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
s = sys.stdin.readlines()
N, M = map(int, s[0].split())
if M > 0:
    a_set = set(map(int, s[1:]))
else:
    a_set = set()

# DP
dp = [0] * (N + 1)
# def case 0, 1
dp[0] = 1
dp[1] = 1 if 1 not in a_set else 0
divisor = 10 ** 9 + 7
 
for i in range(2, N + 1):
    if i in a_set:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1]) % divisor
print(dp[N])

Measured memory_bytes: 19084
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100009];
long long ans=0,ans1=0;
vector<int> v1,v2,v3;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
    if(a[i]%4==0)
        ans++;
    else if(a[i]%2==0)
        ans1++;
    }
if(ans1%2!=0)
    ans1--;
if(ans>=(n-ans1)/2)
    cout<<"Yes";
else
    cout<<"No";

}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int x[100100], y[100100];

vector<int> G[100100];

int calc(int v, int prev) {
    int g = 0;
    for (int u : G[v]) {
        if (u == prev)
            continue;
        g ^= (calc(u, v) + 1);
    }
    return g;
}

bool solve() {
    for (int i = 0; i < n-1; i++) {
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }

    return (calc(0, -1) > 0);
}

void input() {
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
}

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

    input();
    cout << (solve()?"Alice":"Bob") << endl;
}


Measured memory_bytes: 14584
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vll h(n);
    rep(i, n) cin >> h[i];
    h[0]--;
    repf(i,1,n){
        if (h[i]<h[i-1]){
            cout << "No" << endl;
            return 0;
        }
        if (h[i]==h[i-1])
            continue;
        h[i]--;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
// CODE by Kazhybay Askar

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC    optimize("Ofast")
//#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define mp     make_pair
#define cont   continue
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 1e3  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

void freopen(){
    freopen("A.in","r",stdin);
    freopen("A.out","w",stdout);
}
char b[MAXN][MAXN];
ll n,a[MAXN][MAXN];


void solve(){
    ll m,k,cnt=1;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>b[i][j];
            if(b[i][j]=='#')a[i][j]=cnt++;
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]!=0 && a[i][j+1]==0)a[i][j+1]=a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=m;j>=1;j--){
            if(a[i][j]!=0 && a[i][j-1]==0)a[i][j-1]=a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]!=0 && a[i+1][j]==0)a[i+1][j]=a[i][j];
        }
    }
    for(int i=n;i>=1;i--){
        for(int j=1;j<=m;j++){
            if(a[i][j]!=0 && a[i-1][j]==0)a[i-1][j]=a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
}

int main(){
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}




Measured memory_bytes: 6656
var
  i,j,n:longint;
  a:array[0..100] of string;
  t:string;
procedure kp(l,r:longint);
var
  i,j:longint;
  m,t:string;
begin
  i:=l;j:=r;m:=a[(l+r) div 2];
  while i<j do
  begin
    while a[i]<m do inc(i);
    while a[j]>m do dec(j);
    if i<=j then
    begin
      t:=a[i];a[i]:=a[j];a[j]:=t;
      inc(i);dec(j);
    end;
  end;
  if l<j then kp(l,j);
  if i<r then kp(i,r);
end;
begin
  readln(n);
  for i:=1 to n do readln(a[i]);
  kp(1,n);
  for i:=1 to n do write(a[i]);
  writeln;
end.

Measured memory_bytes: 128
A = [[0 for _ in range(3)] for _ in range(3)]
B = [[False for _ in range(3)] for _ in range(3)]
b = []

for i in range(3):
    A[i][0],A[i][1],A[i][2] = map(int,input().split())

N = int(input())

for i in range(N):
    b.append(int(input()))

for i in range(3):
    for j in range(3):
        for k in range(N):
            if b[k]==A[i][j]:
                B[i][j]=True

judge = False

count3=0
count4=0

for i in range(3):
    count1=0
    count2=0
    
    if B[i][i]==True:
        count3 += 1
        if count3==3:
            judge=True
            break
        
    if B[2-i][i]==True:
        count4 +=1
        if count4==3:
            judge=True
            break
    
    for j in range(3):
        if B[i][j]==True:
            count1 += 1
            if count1 == 3:
                judge = True
                break
            
        if B[j][i]==True:
            count2 += 1
            if count2 == 3:
                judge = True
                break
if judge==True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
//16-1 ?§??????????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;

    int min = 101;
    if(A<min) min = A;
    if(B<min) min = B;
    if(C<min) min = C;
    if(D<min) min = D;
    int ans = A+B+C+D-min;

    min = 101;
    if(E<min) min = E;
    if(F<min) min = F;
    ans += E+F-min;

    cout << ans << endl;

    return 0;
}


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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int64_t ans = INT64_MAX;
    for (int i = 0; i <= max(x, y) * 2; i++) {
        int cnt_a = i / 2;
        int cnt_b = i / 2;
        int a_needed = max(x - cnt_a, 0);
        int b_needed = max(y - cnt_b, 0);
        int64_t total = a * a_needed + b * b_needed + c * i;
        ans = min(ans, total);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3536
package main

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

var (
	BufferSize = 10 * 10 * 10 * 10 * 10 * 10 * 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	l := scanInt(sc)
	r := scanInt(sc)

	min := 2020
	for i := l; i < r; i++ {
		for j := l + 1; j <= r; j++ {
			mod := (i * j) % 2019
			if mod < min {
				min = mod
			}
			if min == 0 {
				fmt.Printf("%d\n", min)
				return
			}
		}
	}

	fmt.Printf("%d\n", min)
}


Measured memory_bytes: 4992