akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i, n)       for (int i = 0; i < (int)(n); i++)
#define         pi              3.14159265359
#define         nl              printf("\n")
#define         gcd(a,b)        __gcd(a,b)
#define         yes             cout<<"Yes"<<"\n"
#define         no              cout<<"No"<<"\n"
#define         pf              printf
#define         sf              scanf
const int N = 2e5+5;
typedef long long int ll;
int i,j,temp,f=0;
int main()
{
   int a,b;cin>>a>>b;
   if(b==100)
    b=101;
    while(a--)
        b*=100;
   cout<<b<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	ll a;
	cin >> h >> n;
	ll sum = 0;
	rep(i, n) {
		ll a;
		cin >> a;
		sum += a;
	}
	if (sum >= h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	double n, m, a, b, cnt = 0, ans = 1; cin >> n >> m;
	printf("%.10f\n", n / m);
	cin >> n; return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> vi;
	for(int i=0;i<n;i++)
	{
		int a;cin>>a;vi.push_back(a);
	}
	int sum = 1;
	for(int i=1;i<n;i++)
	{
		int k = vi[i];bool isok = true;
		for(int j=0;j<i;j++)
		{
			if(vi[j]>k)isok = false;
		}
		sum+=isok;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

def solve(f):
    q = f.read_int()

    res = []
    for _ in xrange(q):
        a, b = f.read_int_list()
        if a*b == 1:
            res.append("0")
            continue
        sq = isqrt(a*b-1)
        ans = sq*2
        if (a*b-1)/sq == sq: ans -= 1
        if a <= sq: ans -= 1
        if b <= sq: ans -= 1
        res.append(str(ans))

    return "\n".join(res)


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6036
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	double dp[3000][3000]={};
	int n; cin>>n;
	double p[3000];
	dp[0][0]=1;
	for(int i=1; i<=n; i++) cin>>p[i];
	for(int i=0; i<n; i++){
		for(int j=0; j<=i; j++){
			dp[i+1][j]+=dp[i][j]*(1-p[i+1]);
			dp[i+1][j+1]+=dp[i][j]*p[i+1];
		}
	}
	double ans=0;
	for(int i=(n+1)/2; i<=n; i++){
		ans+=dp[n][i];
	}
	printf("%.10lf\n", ans);
	return 0;
}

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

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

    while (1) {
        int E;
        cin >> E;
        if (!E) break;
        int M = 1000000007;
        for (int z = 0; z <= 100; z++) {
            for (int y = 0; y <= 1000; y++) {
                if (E - z * z * z - y * y < 0) break;
                int x = E - z * z * z - y * y;
                M = min(x + y + z, M);
            }
        }
        cout << M << endl;
    }
}


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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                int l = 0;
                while (l < s.size() && s[l]-'0' != i)
                    l++;
                l++;
                if (l >= s.size())
                    break;
                while (l < s.size() && s[l]-'0' != j)
                    l++;
                l++;
                if (l >= s.size())
                    break;
                while (l < s.size () && s[l]-'0' != k)
                    l++;
                if (l < s.size())
                    ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	int count = 1;
	int misi = a;

	if(b == 1){
		cout << 0 << endl;
		return 0;
	}

	while(misi < b){
		misi += a;
		misi -= 1;
		count++;
	}


	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
x = list(map(int,input().split()))

ans = 100000000000
for i in range(N-K+1):
    dist = min(abs(x[i]),abs(x[i+K-1])) + abs(x[i+K-1] - x[i])
    if(dist < ans):
        ans = dist

print(ans)



Measured memory_bytes: 14224
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n;

  cin >> n;

  if (n <= 999)
    puts("ABC");
  else
    puts("ABD");
  
  return 0;
}


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

const long long int MOD = 1e9 + 7;


int main() {
	int a;

	std::cin >> a;


	std::vector<long long int> vec(a);

	long long int sum = 0;

	for (int i = 0; i < a; i++) {
		std::cin >> vec[i];
		sum += vec[i];
	}

	long long int c = 0;

	for (int i = 0; i < a; i++) {
		sum -= vec[i];
		c = ((c % MOD) +  ( (vec[i] % MOD) * (sum % MOD) ) % MOD) % MOD;
	}


	std::cout << c << std::endl;

}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
int main(){
  double a,b,h,m;	cin >> a >> b >> h >> m;
  
  printf("%.10f",sqrt(a*a+b*b-2*a*b*cos((30*h+0.5*m-6*m)/360*2*M_PI)));
  
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if((a+b)%2 == 1) {
        cout << (a+b)/2+1 << endl;
    } else {
        cout << (a+b)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3520
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  char str[256];
  char f[4]={'m','c','x','i'};
  int n;
  for(scanf("%d\n",&n);n--;){
    int c;
    int ans[2]={0,0};
    for(int i=0;i<2;i++){
      int tmp=0;
      while((c=getchar())!=' '&&c!='\n'){
	if(isdigit(c)){
	  tmp*=10;
	  tmp+=c-'0';
	}else{
	  if(tmp==0) tmp=1;
	  switch(c){
	  case 'm':
	    tmp*=1000;
	    break;
	  case 'c':
	    tmp*=100;
	    break;
	  case 'x':
	    tmp*=10;
	    break;
	  case 'i':
	    //tmp*=1;
	    break;
	  }
	  ans[i]+=tmp;
	  tmp=0;
	}
      }
    }
    //printf("%d %d\n",ans[0],ans[1]);
    int a=ans[0]+ans[1];
    int s[4];
    for(int i=0;i<4;i++){
      s[i]=a%10;
      a/=10;
    }
    for(int i=0;i<4;i++){
      if(s[3-i]!=0){
	if(s[3-i]==1)
	  printf("%c",f[i]);
	else
	  printf("%d%c",s[3-i],f[i]);
      }
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll p[10];
ll q[10];
ll index[10];
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> q[i];
	}

	for (int i = 0; i < n; i++) {
		index[i] = i + 1;
	}
	int x, y;
		int count = 1;
	do {
		int check = 0;
		int check2 = 0;
		for (int i = 0; i < n; i++) {
			if (p[i] == index[i]) {
				check++;
			}
		}
		for (int i = 0; i < n; i++) {
			if (q[i] == index[i]) {
				check2++;
			}
		}
		if (check == n) {
			x = count;
		}
		if (check2 == n) {
			y = count;
		}

		count++;
	} while (next_permutation(index, index + n));
	cout << abs(x - y) << endl;
	return 0;
}


Measured memory_bytes: 3556
#!/usr/bin/ruby
#encoding: utf-8

n = gets.to_i
tasks = Array.new
n.times do
  a,b = gets.split.map(&:to_i)
  tasks.push([a,b])
end

#p tasks
tasks.sort_by!{|a| a[1]}

sum = 0
(0..tasks.size-1).each do |i|
  sum += tasks[i][0]
  if sum > tasks[i][1]
    puts "No"
    exit
  end
end

puts "Yes"

Measured memory_bytes: 22520
#!/usr/bin/env python3
import sys


def solve(N: int, H: int, a: "List[int]", b: "List[int]"):
    from math import ceil
    c = sorted([(bb, False) for bb in b] + [(aa, True) for aa in a], reverse=True)
    ans = 0
    for cc, f in c:
        if f:
            return ans + ceil(H / cc)
        ans += 1
        H -= cc
        if H <= 0:
            return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    print(solve(N, H, a, b))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 101464
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
row = [-1] * (N - 2)
col = [-1] * (N - 2)
a = b = N - 2
ans = (N - 2)**2
for _ in range(Q):
    t, x = map(int, input().split())
    x -= 2
    if t == 1:
        if col[x] == -1:
            ans -= b
        else:
            ans -= col[x]
        a = min(a, x)
        for i in range(x, N - 2):
            if col[i] != -1:
                break
            col[i] = b
    else:
        if row[x] == -1:
            ans -= a
        else:
            ans -= row[x]
        b = min(b, x)
        for i in range(x, N - 2):
            if row[i] != -1:
                break
            row[i] = a
print(ans)


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    vi a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    out(a[n - 1]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h> //per fare input output con scanf and printf
#include<stdlib.h> //per fare qsort e bsearch
#include<string.h> // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali
#include<math.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<map>
 
using namespace std;
 
#define REP(n) for(int i = 0; i < (n); i++)
#define endl '\n'
#define ld long double
#define ll long long int
#define vi vector <int> 
#define pi pair <int, int>
#define make(type, x) type (x); cin>>(x)
#define print(x) cout<<x<<endl
#define binary(v, el) binary_search((v).begin(), (v).end(), (el))

int main(){
  string s; cin >> s;
  int flag = 1;
  for (int i=0; i<3; i++){
    if (s[i] == s[i+1]) flag = 0;
  }
  if (flag) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a;
	int sum = 0;
	int pos = 0;
	a.push_back(0);
	for (int i = 0; i < n; ++i) {
		int ai;
		cin >> ai;
		a.push_back(ai);
		sum += abs(ai - pos);
		pos = ai;
	}
	sum += abs(pos);
	a.push_back(0);

	int mindis;
	for (int i = 0; i < n; ++i) {
		int ndis = sum;
		ndis -= abs(a[i + 1] - a[i]);
		ndis -= abs(a[i + 2] - a[i+1]);
		ndis += abs(a[i + 2] - a[i]);
		cout << ndis << endl;
	}
	return 0;
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
#define I64 "%I64d"
#define RAN(v)v.begin(),v.end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
template<class T>
inline void upd1(T&a,T b){a>b?a=b:0;}
template<class T>
inline void upd2(T&a,T b){a<b?a=b:0;}
struct ano{
	operator ll(){
		ll x=0,y=0,c=getchar();
		while(c<48)
			y=c==45,c=getchar();
		while(c>47)
			x=x*10+c-48,c=getchar();
		return y?-x:x;
	}
}buf;
char s[100000];
int main(){
	scanf("%s",s);
	puts(memcmp(s,"YAKI",4)?"No":"Yes");
}

Measured memory_bytes: 256
S = input()
cnt = [0] * 3
abc = ["a","b","c"]
for i in range(3):
	cnt[i] = S.count(abc[i])
if abs(cnt[0] - cnt[1]) <= 1 and abs(cnt[1] - cnt[2]) <= 1 and abs(cnt[2] - cnt[0]) <= 1:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i, x, y;
	cin >> n;
	
	bool ok = 0;
	int cnt = 0;
	fo(i, 0, n) {
		cin >> x >> y;
		if(x == y)
		cnt++;
		else
		cnt = 0;
		ok |= (cnt == 3);
	}
	cout << (ok ? "Yes" : "No");
}


Measured memory_bytes: 3648
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n,a,b;cin>>n>>a>>b;
	int d=abs(a-b);
		if(d%2==0)cout<<"Alice"<<endl;
		else cout<<"Borys"<<endl;
	
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n= readLine()!!.toInt()
    var numList = readLine()!!.split(' ').map { it.toLong() }
    numList=numList.sorted()
    var tmp:Long=0
    var count=0
    for (e in numList){
        if(e<=tmp) {
            break
        }
        tmp=e
        count++
    }
    if (count==numList.size){
        println("YES")
    }else{
        println("NO")
    }
}


Measured memory_bytes: 79332
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
const long long INF = 1LL<<60;


int main(){	
	int N;
	cin >> N;
	string w;
	cin >> w;
	int cnt = 1;
	for(int i = 0; i < N-1; i++){
		if(w[i] != w[i+1]){
		cnt++;
		}
	}
		cout << cnt << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
long mod=1e9+7;
long dp[64][2][2];
long L,R;
main()
{
	cin>>L>>R;
	long ans=0;
	for(int k=1;k<=62;k++)
	{
		dp[62-k][L<=1L<<k-1][(1L<<k)-1<=R]=1L<<k>L&&R>=1L<<k-1;
	}
	for(int i=0;i<=60;i++)
	{
		int x=L>>60-i&1;
		int y=R>>60-i&1;
		for(int xl=0;xl<2;xl++)for(int yl=0;yl<2;yl++)
		{
			int limx=xl?0:x;
			int limy=yl?1:y;
			for(int yy=0;yy<=limy;yy++)for(int xx=limx;xx<=yy;xx++)
			{
				(dp[i+1][xl||xx>limx][yl||yy<limy]+=dp[i][xl][yl])%=mod;
			}
		}
	}
	for(int i=0;i<4;i++)(ans+=dp[61][i/2][i%2])%=mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

ll dp[2][305][305];

int main(){
    ll N,K; cin >> N >> K;
    vl h(N+1); rep(i,N) cin >> h[i+1];
    h[0] = 0;
    rep(j,K+1) rep(k,N+1) dp[0][j][k] = linf;
    dp[0][0][0] = 0;
    REP(i,1,N+1){
        rep(j,K+1) rep(k,i+1) dp[1][j][k] = linf;
        rep(j,K+1){
            rep(k,i){
                chmin(dp[1][j][i], dp[0][j][k] + max(0LL, h[i] - h[k]));
                chmin(dp[1][j+1][k], dp[0][j][k]);
            }
        }
        swap(dp[0], dp[1]);
    }
    ll ans = linf;
    rep(j,K+1) rep(k,N+1) chmin(ans, dp[0][j][k]);
    cout << ans << "\n";
}

Measured memory_bytes: 5056
import numpy as np
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n, t = imap()
a = iarr()
b = []
minv = a[0]
for i in a:
    minv = min(i, minv)
    b.append(i - minv)
b.sort(reverse=True)
ans = 0
while b[ans]==b[0]: ans+=1
print(ans)

Measured memory_bytes: 23456
#include <stdio.h>

int main()
{
	int i, N, t, A[100000];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &t);
		A[t] = i;
	}

	for (i = 1; i <= N; i++) {
		printf("%d ", A[i]);
	}
}


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

#define debug(x) cerr<<#x<<'='<<x<<' '
#define f first
#define s second

typedef long long ll;
typedef pair<int,int> pi;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll h,n,sum=0;
	cin >> h >> n;
	for (int i = 0; i < n; ++i) {
		ll x; cin >> x;
		sum += x;
	}
	if (sum >= h) cout << "Yes";
	else cout << "No";
    return 0;
}


Measured memory_bytes: 384
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    ll F[100][10];
    ll P[100][11];
    rep(i, N) {
        rep(j, 10) {
            cin >> F[i][j];
        }
    }
    rep(i, N) {
        rep(j, 11) {
            cin >> P[i][j];
        }
    }
    vector<ll> counts(N, 0);
    ll ma = -MOD;
    for(ll i = 1; i < (ll)pow(2,10); i++) {
        rep(j, N) counts[j] = 0;
        rep(j, 10) {
            if (i >> j & 1 == 1) {
                rep(k, N) {
                    counts[k] += F[k][j]; 
                }
            }
        }
        ll sum = 0;
        rep(j, N) {
            sum += P[j][counts[j]];
        }
        ma = max(ma, sum);
    }
    print(ma);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int x[5];
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for(int i = 0; i < 5; ++i) {
        if(x[i] == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3568
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int A;
    FOR (i, 1, 6) {
        cin >> A;
        if (A == 0) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <iomanip>
#include <limits>
#include <cmath>
#include <numeric>
#include <queue>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}

int main() {
    const double PI = 3.14159265358979323846;
    double a, b, x;
    cin >> a >> b >> x;
    double ans;

    if(x == a * a * b) {
        ans = 0;
    } else if(2 * x > a * a * b) {
        ans = 180.0 * atan((2.0 * (a * a * b - x)) / (a * a * a)) / PI;
    } else {
        ans = 180.0 * atan((a * b * b)/(2*x)) / PI;
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

char a[20], b[20];

int main() {
    int aa, bb;
    scanf("%d%d", &aa, &bb);
    for (int i = 0; i < bb; i++) a[i] = '0' + aa;
    for (int i = 0; i < aa; i++) b[i] = '0' + bb;
    printf("%s\n", strcmp(a, b) < 0 ? a : b);
}


Measured memory_bytes: 128
Scanf.scanf "%s %s" (fun s t ->
    let n = String.length s in
    let m = String.length t in
    let diff a b =
        let rec loop i acc =
            if i = m then acc else
                let acc = if a.[i] = b.[i] then acc else acc + 1 in
                loop (i + 1) acc
        in
        loop 0 0
    in
    let rec loop i acc =
        if i + m > n then acc else loop (i + 1) (min acc (diff (String.sub s i m) t))
    in
    loop 0 max_int |> Printf.printf "%d\n"
)

Measured memory_bytes: 4024
#include <stdio.h>

typedef struct{
  int id;
  int left;
  int right;
  int parent;
} leaf;

leaf T[25];

void Inorder(int);
void Preorder(int);
void Postorder(int);


int main(){

  int num,i,j;
  int k,v;
  scanf("%d",&num);
 //?????????                                                                                                                                    
  for(i=0;i<num;i++) T[i].parent = -1;


  for(i=0;i<num;i++){
    scanf("%d",&v);
    T[v].id = v;
    scanf("%d%d",&T[v].left,&T[v].right);
    T[T[v].left].parent = T[v].id;
    T[T[v].right].parent = T[v].id;
  }

 //??????                                                                                                                                      
  for(i=0;T[i].parent != -1;i++);
  puts("Preorder");
  Preorder(i);
  puts("");
  puts("Inorder");
  Inorder(i);
  puts("");
  puts("Postorder");
  Postorder(i);
  puts("");
  return 0;
}

void Preorder(int x){
  printf(" %d",T[x].id);
  if(T[x].left != -1) Preorder(T[x].left);
  if(T[x].right != -1) Preorder(T[x].right);
}
void Inorder(int x){
  if(T[x].left != -1) Inorder(T[x].left);
  printf(" %d",T[x].id);
  if(T[x].right != -1) Inorder(T[x].right);
}
void Postorder(int x){
  if(T[x].left != -1) Postorder(T[x].left);
  if(T[x].right != -1) Postorder(T[x].right);
  printf(" %d",T[x].id);
}

Measured memory_bytes: 612
n, m = gets.split(" ").map(&:to_i)

x = Array.new(n, 0)
zero = nil
m.times do
  i, j = gets.split(" ").map(&:to_i)
  x[i-1] = x[i-1] == 0 || x[i-1] == j ? j : -1;
  if i == 1
    if j == 0 && n != 1
      zero = true
    else
      zero = false
    end
  end
end

if x.find{|a| a == -1}
  print "-1\n"
elsif zero
  print "-1\n"
else
  if zero.nil? && n != 1
    x[0] = 1
  end
  print "#{x.map(&:to_s).join("").to_i}\n"
end

Measured memory_bytes: 1916
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

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

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,s1;
    cin>>s>>s1;
    int a=stoi(s+s1);
    int i=1;
    while(i<=1000){
    	if((i*i)==a){
    		cout<<"Yes"<<endl;
    		return 0;
    	}
    	i++;
    }
    cout<<"No"<<endl;
  }

Measured memory_bytes: 3624
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    string ans;
    string sorw;
    bool flag = true;
    
    for(int i = 1; i <=4  ; i++){
        if(i ==1){
            ans = "WW";
        }else if(i == 2){
            ans = "WS";
        }else if(i == 3){
            ans = "SW";
        }else if(i == 4){
            ans = "SS";
        }
        for(int j = 0 ; j < n ; j++){
            if(ans[j] == 'W' && ans[j+1] == 'W' && s[j] == 'o'){
                sorw = 'S';
            }else if(ans[j] == 'W' && ans[j+1] == 'W' && s[j] == 'x'){
                sorw = 'W';
            }else if(ans[j] == 'W' && ans[j+1] == 'S' && s[j] == 'o'){
                sorw = 'W';
            }else if(ans[j] == 'W' && ans[j+1] == 'S' && s[j] == 'x'){
                sorw = 'S';
            }else if(ans[j] == 'S' && ans[j+1] == 'W' && s[j] == 'o'){
                sorw = 'W';
            }else if(ans[j] == 'S' && ans[j+1] == 'W' && s[j] == 'x'){
                sorw = 'S';
            }else if(ans[j] == 'S' && ans[j+1] == 'S' && s[j] == 'o'){
                sorw = 'S';
            }else if(ans[j] == 'S' && ans[j+1] == 'S' && s[j] == 'x'){
                sorw = 'W';
            }
            
            ans += sorw;
            }
            if(ans[0] == ans[ans.size()-2] && ans[1] == ans[ans.size()-1]){
                //cout << "Break!" << endl;
                flag = false;
                ans = ans.substr(1);
                ans = ans.erase(ans.size()-1,1);
                break;
            }
    }
    if(flag){
        cout << "-1" << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int a;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a;
        ans+=min(2*a,2*(k-a));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;
    FOR(i, 0, n) {
        int v = a[i], j;
        for (j = i - 1; j >= 0 && a[j] >= v; --j) {
            a[j + 1] = a[j];
        }
        a[j + 1] = v;
        FOR(j, 0, n)cout << a[j] << ENDL(j, n);
    }
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <cstddef>
#include <numeric>

using usize = std::size_t;

int main() {
	usize n;
	std::cin >> n;
	std::vector<long long> a(n);
	for (auto &e : a) std::cin >> e;
	
	const long long one = 1LL * n * (n + 1) / 2;
	const long long sum = std::accumulate(a.begin(), a.end(), 0LL);
	
	if (sum % one) {
		std::cout << "NO" << '\n';
		return 0;
	}
	
	const long long k = sum / one;
	std::vector<long long> d(n);
	for (usize i = 0; i < n; i++) {
		d[i] = a[(i + 1) % n] - a[i] - k;
	}
	
	bool ans = true;
	for (const auto &x : d) {
		ans &= ((x <= 0) and (-x % n == 0));
	}
	
	std::cout << (ans ? "YES" : "NO") << '\n';
	
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<P> d(n);
  rep(i, n) cin >> d[i].first >> d[i].second;
  rep(i, n-2) if(d[i].first == d[i].second && d[i+1].first == d[i+1].second && d[i+2].first == d[i+2].second) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3604
import sys
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N, K = map(int, readline().split())
    h = np.array(read().split(), np.int64)
    dp = np.zeros(N, np.int64)

    for i in range(1, N):
        left = max(0, i - K)
        dp[i] = (dp[left:i] + np.abs(h[left:i] - h[i])).min()

    print(dp[-1])


if __name__ == '__main__':
    main()

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

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

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  //return (x*y)/gcd(x,y);
  return x / gcd(x, y) * y;
}

int main() {
  int n;
  cin >> n;
  //vector<ULL> v(n);
  ULL ans = 1;
  ULL t;
  REP(i, n) {
    cin >> t;
    ans = lcm(ans, t);
    eprintf("t,ans:%llu,%llu\n", t,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)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;

const int MAX_N = 100010;
ll A[MAX_N];

int main() {
    ll N;//問題数
    ll M;//ジャッジ人数
    ll V;//選ぶ問題数
    ll P;//上位P問
    cin >> N >> M >> V >> P;
    rep(i,N) cin >> A[i];
    sort(A, A+N);
    reverse(A, A+N);
    ll l = 0;
    ll r = N;
    ll c = (l + r) / 2;
    while(r - l > 1) {
        ll sum = 0;
        for(int i = P-1; i < c; ++i) {
            sum += A[c]+M - A[i];
        }
        if(c <= P-1) {
            l = c;
        } else if(A[c]+M < A[P-1] || M*V > (P-1)*M + sum + M + (N-c-1)*M) {
            r = c;
        } else {
            l = c;
        }
        c = (l + r) / 2;
    }
    cout << l+1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int k;
	cin >> k;

	if(k%2 == 0){
		cout << k/2*k/2 << "\n";
	}else{
		cout << (k/2 +1)*(k/2) << "\n";
	}



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &x:a) cin >> x;
    vector<vector<ll>> dp(n+1, vector<ll>(3, -1e+18)); // dp[n個目まで][いくつ飛ばしたか];
    int base = (n%2==0?1:2);
    int lim = 2;
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        // 通常移動
        dp[i][0] = (i >= 2?dp[i-2][0]:0);
        dp[i][0] += a[i];
        // 一回だけ飛ばした奴
        if(i >= 1){
            dp[i][1] = (i >= 2?dp[i-2][1]:0);
            dp[i][1] += a[i];
        }
        // ニ回飛ばした奴
        if(i >= 2){
            dp[i][2] = (i >= 2?dp[i-2][2]:0);
            dp[i][2] += a[i];
        }


        // 一つ飛ばす
        if(i >= 1){
            dp[i][1] = max(dp[i][1], (i >= 3?dp[i-3][0]:0)+a[i]);
        }
        if(i >= 2){
            dp[i][2] = max(dp[i][2], (i >= 3?dp[i-3][1]:0)+a[i]);
        }

        // 二つ飛ばす
        if(i >= 2){
           dp[i][2] = max(dp[i][2], (i >= 4?dp[i-4][0]:0)+a[i]);
        }
    }
    ll ans = -1e+18;
    for(int j=0;j<=base;j++){
        ans = max(ans, dp[n-1-(base-j)][j]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 14880
N=int(input())
A=list(map(int,input().split()))
C=[0]*(N+1)
D=[i for i in range(N+1)]
ans=0

for i in range(N):
    if A[i]>N:
        ans+=1
    else:
        C[A[i]]+=1

for i in range(N+1):
    if C[i]==0:
        continue
    elif C[i]>=D[i]:
        ans+=C[i]-D[i]
    else:
        ans+=C[i]

print(ans)

Measured memory_bytes: 14268
#include "bits/stdc++.h"
using namespace std;


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

	int64_t x;
	if (b > n) {
		x = n;
	} else {
		x = b - 1;
	}

	int64_t ans = (a * x / b) - a * (x / b);

	cout << ans << endl;
}

Measured memory_bytes: 3628
import sys
N = int(input())
L = list(map(int,input().split()))

counter = 0
L = sorted(L,reverse=True)
#print(L)

first = 0

while first < len(L) - 2:
  second = first + 1
  while second < len(L) - 1:
    third = second + 1
    while third < len(L):
      if first != second and first != third and second != third:
        if L[first] != L[second] and L[second] != L[third] and L[first] < L[second]+L[third]:
          counter += 1
          #print(L[first],L[second],L[third])
      third += 1
    second += 1
  first += 1

print(counter)

Measured memory_bytes: 67840
from sys import stdin
n = int(input())
s = stdin.readline()
r = 0
g = 0 
b = 0
for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1
count1 = r*g*b
count2 = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        if 2*j-i<=n-1:
            if (s[i] != s[j])and(s[i] != s[2*j-i])and(s[j] != s[2*j-i]):
               count2 += 1
print(count1-count2)

Measured memory_bytes: 9248
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int K=stdIn.nextInt();
		Deque <Long> Q=new ArrayDeque<Long>();
		for(int i=1;i<=9;i++){
			Q.add((long)i);
		}
		for(int i=0;i<K;i++){
			long x=Q.poll();
			if(i==K-1){
				System.out.println(x);
				System.exit(0);
			}
			if(x%10!=0)
				Q.add(x*10+(x%10-1));
			Q.add(x*10+(x%10));
			if(x%10!=9)
				Q.add(x*10+(x%10+1));
		}
	}
}


Measured memory_bytes: 30036
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl; 


ll max_ll(ll a,ll b,ll c){
	return max(a,max(b,c));
}

ll min_ll(ll a,ll b,ll c){
	return min(a,min(b,c));
}


bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second==b.second)
		return a.first<b.first;
    return (a.second < b.second); 
}

long long binexpmod(long long a, long long b){
    long long res =1;
    while(b>0){
        if(b&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b>>=1;
    }
    return(res);
}


ll lcm(ll a,ll b){
	ll x=__gcd(a,b);
	a/=x;
	b/=x;
	ll sum=a*b*x;
	return sum;
}

const ll INF= 1e18L;
void solve(){
    ll n,res=0;
	cin>>n;
    ll W;
    cin>>W;
    vi w(n),v(n);
    ll val_sum=0;
    rep(i,n){
        cin>>w[i]>>v[i];
        val_sum+=v[i];
    }
    vi dp_val(val_sum+1,INF);
    // i'th value is the min weight it can handel with i'th value
    dp_val[0]=0;
    rep(i,n){
        for(ll j=val_sum-v[i]; j>=0;j--){
            dp_val[j+v[i]] = min(dp_val[j+v[i]],dp_val[j]+w[i]);
        }
    }
	rep1(i,val_sum){
        if(dp_val[i]<=W){
            res = max(res,i);
        }
    }
    cout<<res;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll S, W;
  cin >> S >> W;
  if (W >= S) {
    cout << "unsafe" << "\n";
  }
  else {
    cout << "safe" << "\n";
  }
}


Measured memory_bytes: 3632