akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N; cin>>N;
  ll C; cin>>C;
  ll x[N], v[N];
  for(int i=0;i<N;++i) cin>>x[i]>>v[i];
  pqueue<pair<ll, int> > que;
  ll sum = 0;

  // 最初に時計回り
  que.push(mp(0, N));
  for(int i=N-1;i>=0;--i) {
    sum += v[i];
    que.push(mp(sum-(C-x[i]), i));
  }
  ll ans = 0;
  sum = 0;
  for(int i=0;i<N;++i) {
    sum += v[i];
    ans = max(ans, sum-x[i]);
    while(que.top().se<=i) que.pop();
    ans = max(ans, sum-2*x[i]+que.top().fi);
  }
  while(!que.empty()) que.pop();

  // 最初に反時計回り
  sum = 0;
  que.push(mp(0, -1));
  for(int i=0;i<N;++i) {
    sum += v[i];
    que.push(mp(sum-x[i], i));
  }
  sum = 0;
  for(int i=N-1;i>=0;--i) {
    sum += v[i];
    ans = max(ans, sum-(C-x[i]));
    while(que.top().se>=i) que.pop();
    ans = max(ans, sum-2*(C-x[i])+que.top().fi);
  }
  
  cout<<ans<<endl;
}



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

class Increase {
public:
  int n, flowMax = 1000000;
  vector<map<int, int>> p;
  vector<int> parent;
  vector<int> stack;

  Increase(int n, vector<map<int, int>> &p) : n(n), p(p) { parent.resize(n); }

  int dfs(int id, int from, int flow) {
    if (parent[id] != id)
      return 0;
    stack.push_back(id);
    parent[id] = from;
    if (id == n - 1)
      return flow;
    for (auto &v : p[id])
      if (v.second > 0) {
        int next = dfs(v.first, id, min(flow, v.second));
        if (next > 0)
          return next;
      }
    return 0;
  }

  int solve() {
    int ret = 0, flow;
    for (int i = 0; i < n; i++)
      parent[i] = i;

    while ((flow = dfs(0, -1, flowMax)) > 0) {
      int now = n - 1;
      ret += flow;
      while (parent[now] >= 0) {
        p[parent[now]][now] -= flow;
        p[now][parent[now]] += flow;
        now = parent[now];
      }
      for (auto &v : stack)
        parent[v] = v;
      stack.clear();
    }
    return ret;
  }
};

bool solve() {
  int n, m;
  cin >> n >> m;
  if (n == 0)
    return false;
  vector<map<int, int>> p(n + m + 2);
  int base = n + 1;
  int sink = n + m + 1;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    p[a][base] = 1;
    p[b][base] = 1;
    p[base++][sink] = 1;
  }

  Increase flow(n + m + 2, p);
  int f = 0;
  int maxp = 1;
  for (; true; maxp++) {
    for (int i = 0; i < n; i++)
      flow.p[0][i + 1] += 1;
    f += flow.solve();
    if (f == m) {
      break;
    }
  }
  flow = Increase(n + m + 2, p);
  f = 0;
  int minp = 0;
  for (; true; minp++) {
    for (int i = 0; i < n; i++)
      flow.p[0][i + 1] += 1;
    f += flow.solve();
    if (f != n * (minp + 1)) {
      break;
    }
  }
  cout << minp << " " << maxp << endl;

  return true;
}

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


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

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    ld pi = 3.14159265358979323846;
    ld thetaA = (60*H+M)*(2*pi)/(12*60);
    ld thetaB = (M*(2*pi))/60;
    ld theta = abs(thetaA-thetaB);
    if (theta > pi) {
        theta = 2*pi - theta;
    }
    ld ans = sqrt(pow(A*sin(theta),2)+pow(B-A*cos(theta),2));
    cout << fixed << setprecision(12);
    cout << ans << endl;
}

Measured memory_bytes: 4124
#include <iostream>

int main(int argc, char const *argv[])
{

    int a, b, c;

    std::cin >> a >> b >> c;

    if (a > b)
    {
        int temp;
        temp = a;
        a = b;
        b = temp;
    }

    if (b > c)
    {
        int temp;
        temp = b;
        b = c;
        c = temp;
    }

    if (a > b)
    {
        int temp;
        temp = a;
        a = b;
        b = temp;
    }

    std::cout << a << " " << b << " " << c << std::endl;

    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

struct edge{
    int e1, e2, color;
    edge(){
        //nothing to do
    }
    edge(int a, int b){
        e1 = a; e2 = b;
    }
    int get_to(int from){
        return e1!=from ? e1 : e2;
    }
};

vector<edge> edge_list;
vector<vector<edge*>> graph;
vector<bool> checked;
int color_max = 0;

using intpair = pair<int, int>;

void bfs(){
    queue<intpair> q;
    q.push(intpair(0,-1));
    
    while(!q.empty()){
        int now = q.front().first;
        int prev_color = q.front().second;
        q.pop();
        
        int color = 0;
        for(edge* e : graph[now]){
            if(checked[e->get_to(now)]) continue;
            if(++color==prev_color) color++;
            e->color = color;
            q.push(intpair(e->get_to(now),color));
        }
        
        color_max = max(color_max,color);
        checked[now] = true;
    }
}

signed main(){
    int N; cin >> N;
    
    edge_list = vector<edge>(N-1);
    graph = vector<vector<edge*>>(N,vector<edge*>(0));
    checked = vector<bool>(N,false);
    
    rep(i,N-1){
        int a,b; cin >> a >> b;
        edge_list[i] = edge(--a,--b);
        graph[a].push_back(&edge_list[i]);
        graph[b].push_back(&edge_list[i]);
    }
    
    bfs();
    
    cout << color_max << endl;
    rep(i,N-1) cout << edge_list[i].color << endl;
    return 0;
}

Measured memory_bytes: 8988
import java.util.Arrays;
import java.util.Scanner;
 
class Main {
	public static void main(String[]args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int count = 0 ;
		int arr[][] = new int[n][m]; 
		
		for(int i = 0 ; i<n ; i++) {
			for(int j = 0 ; j< m ; j++) {
				arr[i][j] = scan.nextInt();
			}
		}
		
		for(int i = 0 ; i<n-1 ; i++) {
			
			for(int j = i+1 ; j< n ; j++) {
				int sum = 0 ; 
				for(int k = 0 ;k< m ; k++) {
					sum+=Math.pow(Math.abs(arr[i][k] - arr[j][k]),2);
				}
				if(Math.sqrt(sum) - (int)Math.sqrt(sum) == 0) {
					count++;
				}
			}
		
		}
		System.out.print(count);
		
		
		
		
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define maxs 2020202
#define mkp make_pair
#define inf LONG_LONG_MAX
#define ll long long
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
vector< pair<ll,ll> >ed[maxs];
ll dis[maxs],n,m;
bool vis[maxs];

void Bellman_Ford(){
    fill(dis,dis+1+n,LONG_LONG_MAX);
    mme(vis,0);
    dis[1]=0;
    int sz;
    ll v,w;

    for(int k=1;k<n;k++){//无环
        for(int i=1;i<=n;i++){
           sz = ed[i].size();
           for(int j=0;j<sz;j++){

                v=ed[i][j].first,w = ed[i][j].second;
                if(dis[i]==LONG_LONG_MAX)
                    continue;
                if(dis[v]>dis[i]+w)
                    dis[v]=dis[i]+w;
           }
        }
    }

    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            sz = ed[i].size();
            for(int j=0;j<sz;j++){
                v=ed[i][j].first,w=ed[i][j].second;
                if(dis[i]==inf) continue;

                if(dis[v]>dis[i]+w){
                    vis[v]=1;
                    dis[v]=dis[i]+w;
                }
                if(vis[i]){
                    vis[v]=1;
                }
            }
        }
    }

    if(vis[n])
    puts("inf");
    else
        printf("%lld\n",-dis[n]);
}

int main()
{
    while(~scanf("%lld%lld",&n,&m))
    {
        ll u,v,w;
        for(int i=0;i<=n;i++) ed[i].clear();

        for(int i=1;i<=m;i++){
            scanf("%lld%lld%lld",&u,&v,&w);
            ed[u].push_back(mkp(v,-w));
        }
        Bellman_Ford();
    }
    return 0;
}

Measured memory_bytes: 51072
def main():
    a, b = map(int, input().split())
    if a == b:
        ans = 'Draw'
    elif a == 1:
        ans = 'Alice'
    elif b == 1:
        ans = 'Bob'
    elif a > b:
        ans = 'Alice'
    elif a < b:
        ans = 'Bob'
    print(ans)


if __name__ == "__main__":
    main()


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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define in(type,a) type a;cin >> a
using ll = long long;

int main() {
    in(int, a);
    in(int, b);
    in(int, t);
    cout << b*(t/a) << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
sysread = sys.stdin.readline

import math
def run():
    X = int(input())
    s = int(X ** (1/5))
    for A in range(s+1):
        B = -((-A**5 + X)**(1/5))
        if abs(round(B) - B) < 1e-6:
            print(A, int(B))
            return None
    for A in range(s+1, X+1):
        B = (A ** 5 - X) ** (1 / 5)
        if abs(round(B) - B) < 1e-8:
            print(A, int(B))
            return None


if __name__ == "__main__":
    run()

Measured memory_bytes: 9476
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        ss: [chars; h],
    }
    let mut ss = ss;
    for i in 0..h {
        ss[i].insert(0,'.');
        ss[i].push('.');
    }
    ss.insert(0,vec!['.';w+2]);
    ss.push(vec!['.';w+2]);
    let mut res = true;
    for i in 1..h+1 {
        for j in 1..w+1 {
            if ss[i][j] == '#' {
                if ss[i-1][j] == '.' &&
                   ss[i+1][j] == '.' &&
                   ss[i][j-1] == '.' &&
                   ss[i][j+1] == '.' {
                       res = false;
                }
            }
        }
    }
    println!("{}", if res {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    string n;
    cin>>n;
    for (int i=0;i<n.size();i++)
    {
        if (n[i]=='7')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";




}

Measured memory_bytes: 3652
N, A, B, C = map(int, input().split())
li = [int(input()) for _ in range(N)]


def dfs(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return float('inf')
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+li[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+li[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+li[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
//素数判定
bool prime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main()
{
ll ans=0,n,m;

cin >> n>>m;


vector<int> soin;
double sqrtNum = sqrt(m);
for (int i = 1; i <= sqrtNum; i++){
    if(m%i==0){soin.push_back(i);soin.push_back(m/i);}
}
sort(soin.begin(), soin.end());
/* for (int i = 0; i < soin.size(); ++i) {
    cout << soin[i] << " ";
}cout  << endl; */

rep(i,soin.size()){
    if(n<=soin[i]){ans=soin[i];break;}
}
ans=m/ans;
cout << ans << 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;
using P =pair<int, int>;

int main(){
  string s,t;
  cin>>s>>t;
  bool same =true;
  for(int i=0;i<(int)s.length();i++){
    if(s[i]!=t[i]){
      same=false;
    }
  }
  if(same){cout<<"Yes"<<endl;
  }else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 3596
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    dd = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

    while True:
        h,w = LI()
        if h == 0 and w == 0:
            break

        a = [S() for _ in range(h)]

        rs = set()
        r = ''
        rm = -1

        for i in range(h):
            for j in range(w):
                for di,dj in dd:
                    tr = a[i][j]
                    for k in range(1,401):
                        ni = (i+di*k) % h
                        nj = (j+dj*k) % w
                        if ni == i and nj == j:
                            break
                        c = a[ni][nj]
                        tr += c
                        l = len(tr)
                        if tr in rs and (l > rm or (l==rm and r > tr)):
                            r = tr
                            rm = l
                        rs.add(tr)

        if r == '':
            rr.append(0)
        else:
            rr.append(r)


    return '\n'.join(map(str, rr))


print(main())




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

int main(){
	int n,k,q;
	cin>>n>>k>>q;
	int correct[n+1]={0};
	int total = q;
	while(q--){
		int a;
		cin>>a;
		correct[a]++;
	}
	for(int i=1; i<=n; i++){
		int score = k-(total-correct[i]);
		if(score<=0) cout<<"No"<<'\n';
		else cout<<"Yes"<<'\n';
	}
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,vi> g;
unordered_map<ll,ll> vis;

const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 1e5+10;
bool imp = false;

void solve() {

    ll a[5];
    for(ll i=0;i<5;i++)
        cin>>a[i];
    for(ll i=0;i<5;i++){
            if(a[i]==0)
                cout<<i+1<<endl;
    }

}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    fio
    int t=1;
    if(imp) cin>>t;
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }

}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var s = ReadLine();
        var t = ReadLine();
        var dics = new Dictionary<char, char>();
        var dict = new Dictionary<char, char>();
        for(var i = 0; i < s.Length; i++)
        {
            if (!dics.ContainsKey(s[i]))
                dics[s[i]] = t[i];
            else if(dics[s[i]]!=t[i])
            {
                WriteLine("No");
                return;
            }
            if (!dict.ContainsKey(t[i]))
                dict[t[i]] = s[i];
            else if(dict[t[i]]!=s[i])
            {
                WriteLine("No");
                return;
            }
        }
        WriteLine("Yes");
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

int N;

class Node{
    public:
    int counter = 0;
    int add = 0;//この頂点より下はこの値が加算される。
    //int *link;
    vector<int> link;

    void linking(int i){
        link.push_back(i);
    }
};

Node tree[200000];

//毎回すべての木を捜査すると間に合わないっていうことだと思う。
void countup(int p,int x){
    tree[p].counter += x;
    if(tree[p].link.empty()){
        return;
    }
    //自分自身のカウンターを増加させる。
    for(int i=0;i<tree[p].link.size();i++){
        countup(tree[p].link[i],x);
    }
}

void sumup(int pos,int x){
    //ここの木より下にはこの値を足す。
    x += tree[pos].add;
    //自分自身をこの値にする。
    tree[pos].counter = x;

    if(tree[pos].link.empty()){
        //ここが葉なら終了
        return;
    }

    for(int i=0;i<tree[pos].link.size();i++){
        sumup(tree[pos].link[i],x);
    }
}

int main(void){
    int Q,a,b;
    cin >> N >> Q;
    for(int i=0;i<N-1;i++){
        cin >> a >> b;
        //Node番号a-1からb-1への単方向リンク
        tree[a-1].linking(b-1);
    }
    int p,x;
    for(int i=0;i<Q;i++){
        cin >> p >> x;
        tree[p-1].add += x;
        //countup(p-1,x);
    }
    sumup(0,0);
    
    for(int i=0;i<N;i++){
        cout << tree[i].counter << " ";
    }
    cout << endl;
}

Measured memory_bytes: 24320
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    char a, b;
    cin >> a >> b;
    if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
        cout << 'H' << endl;
    } else {
        cout << 'D' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,k;
            cin>>n;
            if(n==1)
            {
                cout<<"a"<<endl;
                return 0;
            }
            vector<pair<string,int> > v,v2;
            v.pb({"a",1});
            string s;
            for(i=2;i<=n;++i)
            {
                v2.clear();
                for(j=0;j<v.size();++j)
                {
                    for(k=0;k<v[j].s;++k)
                    {
                        s=v[j].f;
                        s+=(char)('a'+k);
                        v2.pb({s,v[j].s});
                    }
                    s=v[j].f;
                    s+=(char)('a'+k);
                    v2.pb({s,v[j].s+1});
                }
                v=v2;
            }

            for(auto it:v)
                cout<<it.f<<endl;
        }
        return 0;
    }


Measured memory_bytes: 11940
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int main(){
     int N,M;
     int count = 0;
     vector<int> K,map;
     vector<vector<int>> A;
     cin >> N >> M;
     map.resize(M+1);
     for(int i = 0; i <= M; i++){
          map[i] = 0;
     }
     K.resize(N);
     A.resize(N);
     for(int i = 0; i < N; i++){
          cin >> K[i];
          A[i].resize(K[i]);
          for(int j = 0; j < K[i]; j++){
               cin >> A[i][j];
               map[A[i][j]]++;
          }
     }
     for(int i = 0; i <= M; i++){
          if(map[i] == N){
               count++;
          }
     }
     cout << count << endl;
     return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B, C;
    cin >> A >> B >> C;
    //C = pow(2, 10);
    /*for(ll i = 2; i < 1000000000; i += 2){
        A = 2;
        B = 2;
        C = i;*/
    if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    if(A == B && B == C){
       cout << -1 << endl;
    }
    else {
        ll ans = 0;
        while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
            ll a = (B + C) / 2;
            ll b = (A + C) / 2;
            ll c = (A + B) / 2;
            A = a;
            B = b;
            C = c;
            ++ans;
            if(ans > 10000){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << ans << endl;/*
        if(m < ans){
            m = ans;
            m0 = i;
        }*/
    }/*
    }
    cout << m << endl;
    cout << m0 << endl;*/
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
e_ls = [0]
w_ls = [0]
cnt = 0
for _s in s[:-1]:
    if _s == "E":
        cnt += 1
    e_ls.append(cnt)

cnt = 0
for _s in s[::-1][:-1]:
    if _s == "W":
        cnt += 1
    w_ls.append(cnt)
w_ls.reverse()

print(n - max([e + w for e, w in zip(e_ls, w_ls)]) - 1)

Measured memory_bytes: 78016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


struct  Combination{
  vector<ll> con;
  vector<ll> coni;
  ll n;
  ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
  }

  Combination(ll input){
    n=input;
    con.push_back(1);
    coni.push_back(1);
    rep(i,n){
      con.push_back(con[i]*(i+1)%MOD);
      coni.push_back(coni[i] * mpow(i+1,MOD-2) % MOD);
    }
  }
  
  ll comb(ll N, ll k){
    if(N == 0 && k == 1)return 1;
    if(N < k || k < 0)return 0;
    ll tmp=con[N]*coni[k]%MOD;
    return tmp*coni[N-k]%MOD;
  }
};


void solve(long long N, long long K){
  Combination cm(N);
  ll ans=0;
  ll X=N-K+1;
  repf(i,1,K+1){
    if(i>X){op(0)continue;}
    ans=cm.comb(X,i);
    ans*=cm.comb(K-1,i-1);
    ans%=MOD;
    op(ans);
    ans=0;
  }
  return;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 998244353;


void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
// BIT //
const int MAXN=2*1e5+10;
vector<int> bit(MAXN,0);
int sump(int idx) {
    int ret = 0;
    for (++idx; idx > 0; idx -= idx & -idx)
        ret += bit[idx];
    return ret;
}

int sum(int l, int r) {
    return sump(r) - sump(l - 1);
}

void upd(int idx, int delta) {
    for (++idx; idx < MAXN; idx += idx & -idx)
        bit[idx] += delta;
}
/////-----//////
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll genRand(ll B) {
    return (ull)rng() % B;
}
///--//
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */
    char c; cin>>c;
    if(isupper(c)) cout<<"A";
    else cout<<"a";

}








Measured memory_bytes: 3836
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      while(N > 0){
        string S;
        cin >> S;
        if(S == "Y"){
          cout << "Four" << endl;
          break;
        }
        N--;
      }
      if(N == 0){
        cout << "Three" << endl;
      }
    }

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

using namespace std;
typedef long long ll;

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

  int n; cin >> n;

  if (n % 10 == 9) {
    cout << "Yes" << "\n";
    return 0;
  }

  n /= 10;
  if (n % 10 == 9) cout << "Yes" << "\n";
  else cout << "No" << "\n";
}


Measured memory_bytes: 3488
n, k = map(int, input().split())
a = list(map(int, input().split()))
# s = 1
# for i in range(k):
#     s *= a[i]
# # s = sum(a[:k])
# pre = s
for i in range(1,n-k+1):
    if a[i+k-1]/a[i-1]>1:
        print("Yes")
    else:
        print("No")





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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    std::vector<ll> x(n);
    rep(i, n) {
        cin >> x[i];
    }

    std::vector<ll> v;
    for (ll i = *min_element(ALL(x)); i <= *max_element(ALL(x)); ++i) {
        ll sum = 0;
        rep(j, n) {
            sum += pow((x[j]-i), 2);
        }
        v.push_back(sum);
    }

    cout << *min_element(ALL(v)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define STR_LENGTH (100)

int isKaibun(char *p, int length) {
	int top = 0, btm = length - 1;

	for (int i = 0; i < length / 2; i++) {
		if (p[i] != p[btm - i]) {
			return 0;
		}
	}
	return 1;
}
int main(int argc, char* argv[])
{
	//ABC159 B
	char s[STR_LENGTH + 1];
	int l;
	int idx; // 後半文字列の開始位置
	
	//N M 偶数奇数
	scanf("%s", &s[0]);

	l = strlen(s);

	if (isKaibun(s, l) == 0) {
		printf("No");
		return 0;
	}

	if (isKaibun(s, (l-1) / 2) == 0) {
		printf("No");
		return 0;
	}

	if (isKaibun(&s[((l + 3) / 2) - 1], l - ((l + 3) / 2) + 1) == 0) {
		printf("No");
		return 0;
	}

	printf("Yes");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a;
  cin >> a;
  if (a % 10 == 9 || a / 10 == 9)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3432
#include <iostream>
#include <string>

using namespace std;

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  int a[N], ans[H][W];
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }

  int p=0;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if(a[p]>0){
        a[p]--;
      }else{
        p++;
        a[p]--;
      }
      ans[i][j] = p + 1;
    }
    i++;
    if(i >= H) break;
    for (int j = W - 1; j >= 0; j--){
      if(a[p]>0){
        a[p]--;
      }else{
        p++;
        a[p]--;
      }
      ans[i][j] = p + 1;
    }
  }
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      printf("%d ", ans[i][j]);
    }
    printf("\n");
  }
  
  
}


Measured memory_bytes: 3832
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			Set<Integer> set = new HashSet<>();
			set.add(a);
			set.add(b);
			set.add(c);
			System.out.println(set.size() == 2 ? "Yes" : "No");
		}

	}

}


Measured memory_bytes: 24276
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var s = consoleReader.String;
            var K = consoleReader.Int;
            var hashset = new HashSet<string>();
            for (int i = 0; i < s.Length; i++)
                for (int j = Math.Min(s.Length - i, K); j > 0; j--)
                    hashset.Add(s.Substring(i, j));
            return hashset.OrderBy(ss => ss).Take(K).Last();
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }
#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

Measured memory_bytes: 13664
n,a,b = gets.split(' ').map(&:to_i)

#1からnの整数で、条件に合うものを探し配列にいれる
total = (1..n).find_all do |m|
  #2桁以上の数は、桁ごとに分ける
  if m >= 10
  	sum = m.to_s.chars.map(&:to_i).reduce(:+)
    sum.between?(a,b)
  else
    m.between?(a,b)
  end
end.inject(:+)


puts total

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

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

  vector<char> S(N);

  for (int i = 0; i < N; i++)
  {
    cin >> S.at(i);
  }

  int ans = 0;

  for (int i = 0; i < N - 2; i++)
  {
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C')
      ans++;
  }

  cout << ans << endl;
}


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


int main(){
  int n,m;
  cin >> n >> m;
  dsu ds(n);

  for(int i=0;i<m;++i){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    ds.merge(a,b);
  }
  int ans=0;
  for(int i=0;i<n;++i){
    if(!ds.same(0,i)){
      ds.merge(0,i);
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
vector<int> v[N];
int A[N];
bool cheak[N], visited[N];
int ans;
int dfs(int s) {
	int t = 0;
	for(int i = 0; i < v[s].size(); i++) {
		int d = v[s][i];
		if(!visited[d]) {
			t = max(t, dfs(d));
		}
		else {
			t = max(t, A[d]);
		}
	}
	visited[s] = true;
	A[s] = t + 1;
	return A[s];
}
int main() {
	int n, m;
	cin>>n>>m;
	rep(i, 0, m) {
		int a, b;
		cin>>a>>b;
		v[a].pb(b);
		cheak[b] = true;
	}
	for(int i = 1; i <= n; i++) {
		if(!cheak[i]) {
			ans = max(ans, dfs(i));
		}
	}
	cout<<ans - 1<<endl;
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <set>
#include <queue>
using namespace std;

//typedef long long signed int ll
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(),(obj).end()

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, L;
	cin >> N >> L;
	int low, high;
	low = L; high = L + N - 1;
	int sum = 0;
	REP(i, N) {
		sum += (L + i);
	}
	if (low <= 0 && 0 <= high) {
		cout << sum << endl;
		return 0;
	}
	if (low > 0) {
		cout << sum - low << endl;
		return 0;
	}
	if (high < 0) {
		cout << sum - high << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

signed main() {
  init();
  ll N, M, V, P;
  cin >> N >> M >> V >> P;
  vll A(N);
  cin >> A;
  RSORT(A);

  ll left = 0, right = N;
  while (right - left > 1) {
    ll center = (left + right) / 2;
    if (center < P) {
      left = center;
      continue;
    }

    ll after = A[center] + M;

    if (after < A[P - 1]) {
      right = center;
      continue;
    }

    ll num = ((P - 1) + 1 + N - (center + 1)) * M;
    rep2(i, P - 1, center) num += after - A[i];

    if (num < M * V)
      right = center;
    else
      left = center;
  }

  COUT(left + 1);
  return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	ll ans = 0;
	for (int i = 1; i <= N; i++)
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3660
"use strict";

function Main(input)
{
  input = input.split(" ");
  let result = "-1"

  if (
    input[0] >= 1 && input[0] <= 9 &&
    input[1] >= 1 && input[1] <= 9
  )
  {
    result = input[0] * input[1];
  }

  console.log(result)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long

const int N = 23333;
int n, p[N], a[N], b[N];

signed main(void) {
	read(n);
	rep (i, n) read(p[i]);
	rep (i, n) a[i] = b[n - i + 1] = (n + 1) * i;
	rep (i, n) a[p[i]] += i;
	rep (i, n) cout << a[i] << " \n"[i == n];
	rep (i, n) cout << b[i] << " \n"[i == n];
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

ll solve(ll a,ll b)
{
	if(a==b) return 0;
	if(abs(a)>abs(b)){
		swap(a,b);
		a*=-1,b*=-1;
	}
	ll res=0;
	if(b<0) res++;
	if(a<0) res++;
	res+=abs(b)-abs(a);
	return res;
}

int main()
{
	for(ll a,b;cin>>a>>b;)
		cout<<solve(a,b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k % 2 == 0) cout << a - b << endl;
	else cout << b - a << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  int upper = *max_element(a.begin(), a.end());
  int lower = 0;
  while (upper - lower > 1) {
    int mid = lower + (upper - lower) / 2;
    auto ok = [&](int x) {
      int cnt = 0;
      for (auto&& e : a) {
        cnt += (e - 1) / x;
      }
      return (cnt <= k);
    };
    if (ok(mid)) {
      upper = mid;
    } else {
      lower = mid;
    }
  }
  cout << upper << '\n';
  return 0;
}


Measured memory_bytes: 3980