akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007

int main(){
  int N,C,K;
  cin>>N>>C>>K;
  vector<int> T(N);
  for(int i=0;i<N;i++){
    cin>>T.at(i);
  }
  sort(T.begin(),T.end());

  int ans=0;
  int i=0;
  while(i<N){
    int k=upper_bound(T.begin(),T.end(),T.at(i)+K)-T.begin();
    if(k-i<=C){
      ans++;
      i=k;
    }else{
      ans++;
      i+=C;
    }
  }
  cout<<ans<<endl;
}


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

#define pb push_back
#define ff first
#define ss second

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

ll n, a, e, o, p;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> a, o += (a & 1);
	if ((p & 1) && !o)
		return cout << 0 << endl, 0;
	if (o)
		cout << (1LL << (n - 1)) << endl;
	else
		cout << (1LL << n) << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import(
  "fmt"
)

func main() {
  var N int
  fmt.Scan(&N)
  if N % 2 == 0 {
    fmt.Println(0.5)
  } else {
    fmt.Println(((float64(N)-float64(1))/float64(2)+float64(1))/float64(N))
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

string f(string s,char c){
    string ret = "";
    rep(i,s.size()){
        if(i < s.size() - 2 && s.substr(i,3) == "ABC"){
            ret += c;
            i += 2;
        }else ret += s[i];
    }
    return ret;
}

string g(string s,char c){
    string ret = "";
    rep(i,s.size()){
        if(s[i] == c)ret += "ABC";
        else ret += s[i];
    }
    return ret;
}

int main(void) {
    string s;
    cin >> s;
    rep(_,2500){
        if(s == "ABC"){
            cout << "Yes" << endl;
            return 0;
        }
        vi v(3,0);
        rep(i,s.size())v[s[i]-'A']++;
        bool c = true;
        if(!(v[0]&&v[1]&&v[2])){
            cout << "No" << endl;
            return 0;
        }
        string t;
        if(s.substr(0,3) == "ABC"){
            t = f(s,'A');
            if(s != g(t, 'A'))c = false;
        }else if(s.substr(s.size()-3,3) == "ABC"){
            t = f(s, 'C');
            if(s != g(t, 'C'))c = false;
        }else{
            t = f(s, 'B');
            if(s != g(t, 'B'))c = false;
        }
        if(c){
            s = t;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3244
from collections import Counter
a, b = [], []
N = int(input())
for i in range(N): a.append(input())
M = int(input())
for i in range(M): b.append(input())

c = Counter(a)
max0 = 0
for i in c.most_common(): max0 = max(max0, i[1]-b.count(i[0]))
print(max0)


Measured memory_bytes: 9352
#include <iostream>
using namespace std;
void ABC50(void);
void ABC52(void);
void ABC53(void);
void ABC54(void);
void ABC55(void);
void ABC56(void);
void ABC57(void);
void ABC58(void);
void ABC59(void);

int main(void){
    ABC52();
    return 0;
}

void ABC52(void){
    int a,b,c,d;
    cin >> a>>b>>c>>d;
    if(a*b>c*d)cout<<a*b<<endl;
    else cout<<c*d<<endl;
}


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

class Program
{
    public static void Main()
    {


        var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var L = line[0];
        var R = line[1];

        long ans = 2020;

        if(R - L > 2019)
        {
            ans = 0;
        }
        else
        {
            for(var i = L; i < R;i++)
            {
                for (var j = i + 1; j <= R; j++)
                {
                    if((i*j) % 2019 < ans)
                    {
                        ans = (i * j) % 2019;
                    }

                }

            }
        }

        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<ll> p(A);
	vector<ll> q(B);
	vector<ll> r(C);
	for (auto& temp : p)
	{
		cin >> temp;
	}
	for (auto& temp : q)
	{
		cin >> temp;
	}
	for (auto& temp : r)
	{
		cin >> temp;
	}

	sort(p.begin(), p.end(), greater<ll>());
	sort(q.begin(), q.end(), greater<ll>());
	sort(r.begin(), r.end(), greater<ll>());

	priority_queue<ll, vector<ll>, greater<ll>> pq;
	auto ans = 0ll;
	for (auto i = 0; i < X; ++i)
	{
		pq.push(p[i]);
		ans += p[i];
	}
	for (auto i = 0; i < Y; ++i)
	{
		pq.push(q[i]);
		ans += q[i];
	}

	for (auto i = 0; i < C; ++i)
	{
		if (pq.empty())
		{
			break;
		}
		auto t = pq.top();
		if (t > r[i])
		{
			break;
		}
		pq.pop();

		ans += r[i];
		ans -= t;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int N;
  double sum=0,ans,m,ave;
  cin>>N;
  double a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum+=a[i];
  }
  
  ave=sum/N;
  
  m=a[0];
  
  for(int i=0;i<N;i++){
    if(m>abs(a[i]-ave)){
      m=abs(a[i]-ave);
      ans=i;
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  vector<string>s(N);
  for(int i=0;i<N;i++)cin>>s[i];
  map<string,int>m;
  for(int i=0;i<N;i++)m[s[i]]++;
  vector<pair<int,string>>p;
  for(auto it:m)p.push_back({it.second,it.first});
  sort(rng(p));
  int Max=(*max_element(rng(p))).first;
  for(auto it:p){
    if(it.first<Max)continue;
    cout<<it.second<<endl;
  }
  return 0;
}


Measured memory_bytes: 29552
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        a-=d;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3636
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
for i in range(n):
  rightsmallcnt = 0
  for j in range(i+1, n):
    if a[i] > a[j]:
      rightsmallcnt += 1
  allsmallcnt = 0
  for j in range(n):
    if a[i] > a[j]:
      allsmallcnt += 1
  cnt += rightsmallcnt * k + allsmallcnt * (((k-1)**2+(k-1))//2)
print(cnt % (10**9+7))

Measured memory_bytes: 42220
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var result = 0L;
            for (long i = 1; i <= N; i++)
            {
                if ((i % 3) != 0 && (i % 5) != 0) result += i;
            }
            Console.WriteLine(result);
        }
    }
}


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

int main() {

	string s; cin>>s;
	int i,n=s.size();
	for(i=0;i<n;i++) {
		if((i%2==0 && s[i]=='L') || (i%2!=0 && s[i]=='R')) {
			cout<<"No"<<endl; break;
		}
	}
	if(i==n) cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
      int n,k;
      cin >> n >> k;
      vector<ll> v(n);
      rep(i,n)cin >> v[i];
      int ans = 0;
      for(int l=0;l<=k;l++){
            for(int r=0;r<=k-l;r++){
                  if(r+l>n)break;
                  int d = k-l-r;
                  int sum = 0;
                  vector<ll> s;
                  for(int i=0;i<l;i++){
                        sum += v[i];
                        s.push_back(v[i]);
                  }
                  for(int i=n-r;i<n;i++){
                        sum += v[i];
                        s.push_back(v[i]);
                  }
                  sort(ALL(s));
                  for(int i=0;i<d;i++){
                        if(i>=s.size())break;
                        if(s[i]>0)break;
                        sum -= s[i];
                  }
                  ans = max(ans,sum);
            }
      }
      cout << ans << endl;
      return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	for (int i = 1; i <= 1e7; i++) {
		if ((a * i) % b == c) {
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){

    int N;
    scanf("%d", &N);

    int i;
    int a[100+1] = {0};
    for( i = 1; i <= N; i++ ){
        scanf("%d", &a[i]);
        if( a[i] % 2 == 0 ){

            if( a[i] % 3 != 0 && a[i] % 5 != 0 ){
                //flag++;
                printf("DENIED\n");
                //exit(0);
                return 0;
            }
        }
    }

    printf("APPROVED\n");

    return 0;
}
                


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int D=scan.nextInt();
		if(D==22)
		{
			System.out.println("Christmas Eve Eve Eve ");
		}
		else if(D==23)
		{
			System.out.println("Christmas Eve Eve");
		}
		else if(D==24)
		{
			System.out.println("Christmas Eve");
		}
		else if(D==25)
		{
			System.out.println("Christmas");
		}
	}

}


Measured memory_bytes: 35560
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;

int main()
{
	//ios::sync_with_stdio(false);
	int s = 0, w = 0;
	cin >> s >> w;
	if(w >= s)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;
    return 0;
}















Measured memory_bytes: 3632
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Sentou
	var N, T int
	fmt.Scanf("%d %d", &N, &T)

	sc.Split(bufio.ScanWords)
	t := make([]int, N)
	for i := 0; i < N; i++ {
		t[i] = nextInt()
	}

	var ans int = T
	for i := 0; i < N-1; i++ {
		if t[i]+T <= t[i+1] {
			ans += T
		} else {
			ans += t[i+1] - t[i]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5936
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
    int N; cin >> N;
    vector<double> v(N, 0.0);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    long double ans = (v[0] + v[1]) / 2.0;
    for (int i = 2; i < N; ++i) ans = (ans + v[i]) / 2.0;
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
long long dp[3020][3020][5];
long long a[3020][3020];
int main()
{
    int r,c,k;
    cin>>r>>c>>k;
    for(int i=0;i<k;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        a[x][y]=z;
    }
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            if(j==1)
            {
                dp[i][j][3]=dp[i-1][1][3]+a[i][j];
                dp[i][j][2]=dp[i-1][1][3]+a[i][j];
                dp[i][j][1]=dp[i-1][1][3]+a[i][j];
                dp[i][j][0]=dp[i-1][1][3];
                continue ;
            }
            dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][3]);
            for(int k=1;k<=3;k++)
            {
                dp[i][j][k]=max(dp[i][j-1][k],dp[i][j-1][k-1]+a[i][j]);
                dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][3]+a[i][j]);
            }

        }
    }
    cout<<dp[r][c][3]<<endl;
    return 0;
}

Measured memory_bytes: 428220
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

//Unionfind ,Disjointset


//親の番号を格納する　親の場合-（その集合のサイズ）
vector<int> Parent;
    //作るときはParentの値を全て-１にする
void UF(int n){
    Parent = vector<int>(n,-1);
}
    //Aがどのグループに属するか
int root(int A){
    if(Parent[A] < 0)return A;
    return Parent[A]=root(Parent[A]);
}
    //自分のグループの頂点数
int size(int A){
    return -Parent[root(A)];
}
    //AとBをくっつける
int connect(int A,int B){
        //AとBを直接ではなくAのrootとBのrootをくっつける
    A = root(A);
    B = root(B);
    if(A==B){
        return false;//すでにくっついている
    }
    if(size(A)<size(B)) swap(A,B);
        //Aのサイズ更新
    //Parent[A]+=Parent[B];
        //Bの親をAに変更する
    Parent[B]=A;

    return true;
}


set_t s;

int main(){
    int n,m;
    cin >>n>>m;
    UF(n);
    rep(i,m){
        int x,y,z;
        cin >> x>>y>>z;
        x--;y--;
        connect(x,y);
    }
    int ans=0;
    rep(i,n){
        //cout<<Parent[i]<<" "<<root(i)<<endl;
        if(Parent[i]==-1){
            ans++;
        }else if(s.find(root(i))!=s.end()){
            s.insert(root(i));
           
        }else{
            continue;
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>

using namespace std;

const int MAXN=1e3+10;

int main()
{
	int n;
	cin>>n;
	int a[MAXN],b[MAXN];
	int sum=0;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		sum+=b[i]+1-a[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		sc.close();
		
		for(Integer i = 1 ; i <= n ; i++){
			//3??§?????????????????´???
			if(i%3==0){
				System.out.print(" " + i.toString());
			}
			else{	//3??§????????????????????´??????3??????????????¢???
				int x = i;
				while(x > 0){
					if(x%10==3){
						System.out.print(" " + i.toString());
						break;
					}
					x = x/10;
				}				
			}
		}
System.out.println();
	}
}

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

int main() {
    long long n;
    cin >> n ;
    string s;
    while (n > 0) {
        n--;
        s.push_back(char(n % 26 + 97));
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
/**
 * Title: A - We Love Golf
 * Url: https://atcoder.jp/contests/abc165/tasks/abc165_a
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {

    int k, a, b;
    cin >> k;
    cin >> a >> b;
    bool flag = false;
    for(int i=a; i<=b; i++) {
        if(i%k==0) flag = true;
    }
    if(flag) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  bool flag = true;
  for (int i = 0; i < s.size() - 1; ++i)
    if (s[i] == s[i + 1])
      flag = false;
  if (flag)
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;

  return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	cout << N-K+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n; cin >> n; int y = 0;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i * j == n) {
				y = 1;
				goto skip;
			}
		}
	}
skip:
	if (y == 1)
		cout << "Yes" << endl;
	if (y == 0)
		cout << "No" << endl;
}

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

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[51], goal_state, next;
	register int i, j;
	int n, answer, free_day, k;

	while ( scanf( "%d", &n ) && n )
	{
		memset( free_days, 0, sizeof(free_days) );
		memset( dp, 0, sizeof(dp) );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		for ( i = 1; i <= 30; i++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) next |= dp[j];
			if ( next == goal_state )
			{
				answer = i;
				break;
			}
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) dp[j] |= next;
		}

		printf( "%d\n", answer );
	}

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 100005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if((a*100+b*10+c)%4)
        puts("NO");
    else
        puts("YES");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep(ri, 2) {
        {
            int cnt = 0;
            rep(i, n) {
                if(s[i] == 'R') cnt++;
                else {
                    ans[i] += cnt / 2;
                    ans[i - 1] += (cnt + 1) / 2;
                    cnt = 0;
                }
            }
        }
        reverse(ans.begin(), ans.end());
        reverse(s.begin(), s.end());
        rep(i, n) {
            if(s[i] == 'L') s[i] = 'R';
            else s[i] = 'L';
        }
    }
    rep(i, n) {
        cout << ans[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 3840
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    
    int ab = Math.abs(b - a);
    int bc = Math.abs(c - b);
    int ca = Math.abs(a - c);
    
    if (ca <= d) {
      System.out.println("Yes");
      return;
    }
    
    if (ab <= d && bc <= d) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23636
#include <cstdio>
#include <cstdlib>

int N;
int list[399999];
int cmp(const void *ka,const void *kb) {
	int a=*(int *)ka;
	int b=*(int *)kb;
	return a-b;
}
int main() {
	scanf("%d",&N);
	for(int i=0;i<N*3;i++) scanf("%d",&list[i]);
	qsort(list,N*3,sizeof(int),cmp);
	long long sol=0;
	for(int i=N;i<N*3;i+=2) sol+=list[i];
	printf("%lld\n",sol);
	return 0;
}


Measured memory_bytes: 2556
class COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()

    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod
mod = 10**9 + 7
h,w,a,b = map(int,input().split())
C = COMB_MOD(max_n=2*10**5)
ans = 0
for i in range(h-a):
    ans = (ans + C.comb(b-1+i,i)*C.comb(h-1-i+w-1-b,h-1-i))%mod
print(ans)

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

// 2つの整数の場合
long long GetLeastCommonMultiple(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return a / n * b;
}

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

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

	// 3つ以上の整数の場合
	long long tmp = t[0];
	for (int i = 1; i < n; i++) {

		tmp = GetLeastCommonMultiple(tmp, t[i]);

	}

	cout << tmp << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const ll mod=998244353;
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
   	ll n,k;cin>>n>>k;
	ll dp[2*n+1];
	memset(dp,0,sizeof(dp));
	dp[0]=0;dp[1]=1;
	vector<pair<ll,ll>> v(k);
	for(int i=0;i<k;i++)
	{
		cin>>v[i].fi>>v[i].se;
	}
	for(ll i=1;i<=n;i++)
	{
		if(i>2)
		{
			dp[i]+=dp[i-1];dp[i]%=mod;
		}
		ll cur=dp[i];
		rep(j,k)
		{
			ll l=v[j].fi;ll r=v[j].se;
			dp[i+l]+=cur;
			dp[i+l]%=mod;
			dp[i+r+1]-=cur;
			dp[i+r+1]+=mod;
			dp[i+r+1]%=mod;
		}
	}
	cout<<dp[n]<<'\n';
	return 0;	
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



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

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

    int H, W;
    cin >> H >> W;

    vector<vector<int> > c(10, vector<int>(10));

    for(int i = 0; i < 10; i++)
        for(int j = 0; j < 10; j++)
            cin >> c[i][j];

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int k = 0; k < 10; k++) {
                c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
            }
        }
    }

    int ans = 0;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int A;
            cin >> A;
            if(A == -1) continue;
            ans += c[A][1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc166/tasks/abc166_d
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  ll x;
  cin >> x;
  auto as = make_v<ll>(0);
  int t=0;
  // as.push_back(0);
  while(true) {
    ll last = pow(t, 5);
    as.push_back(last);
    for (int i = 0; i < as.size() - 1; ++i) {
      if (last - as[i] == x) {
        debug(as);
        cout << t << " " << (i) << endl;
        return 0;
      } else if (last + as[i] == x){
        debug(as);
        cout << t << " " << (i)*-1 << endl;
        return 0;
      }
    }
    t++;
  }

  return 0;
}


Measured memory_bytes: 4092
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(T s) {
    return cast(int)s.length;
}

struct P {
    string name;
    int x;
    int t;
    int opCmp(in P p) const {
        return (x == p.x ? t - p.t : x - p.x);
    }
}

void main() {
    int N; readf("%d\n", &N);
    auto w = new RedBlackTree!(P, "a < b");
    auto nw = new RedBlackTree!(P, "a < b");

    P[string] m;
    void insert(in string name, int x, int t, bool output) {
        auto c = P(name, x, t);
        m[name] = c;
        bool flag;
        if (c < (w.empty ? P("", int.max, int.min) : w.front)) {
            nw.insert(c);
            flag = true;
        } else {
            w.insert(c);
            if (output)
                writeln(name ~ " is working hard now.");
        }
        int n = w.size + nw.size;
        int w_count = n / 5;
        if (w_count > w.size) {
            w.insert(nw.back);
            if (output) {
                if (name != nw.back.name) {
                    writeln(name ~ " is not working now.");
                }
                writeln(nw.back.name ~ " is working hard now.");
            }
            nw.removeBack;
        } else if (w_count < w.size) {
            nw.insert(w.front);
            if (output) {
                writeln(w.front.name ~ " is not working now.");
            }
            w.removeFront;
        } else {
            if (flag && output) {
                writeln(name ~ " is not working now.");
            }
        }
    }

    void remove(in string name, int t) {
        assert(name in m);
        auto c = m[name];
        int n = w.size + nw.size - 1;
        int w_count = n / 5;
        if (c in w) {
            w.removeKey(c);
            if (w_count > w.size) {
                w.insert(nw.back);
                //writeln(name ~ " is not working now.");
                writeln(nw.back.name ~ " is working hard now.");
                nw.removeBack;
            }
        } else if (c in nw) {
            nw.removeKey(c);
            if (w_count < w.size) {
                nw.insert(w.front);
                writeln(w.front.name ~ " is not working now."); 
                w.removeFront;
            }
        }
    }

    foreach (int t; 0 .. N) {
        string name; int x; readf("%s %d\n", &name, &x);
        insert(name, x, t, false);
    }

    int M; readf("%d\n", &M);
    foreach (int t; N .. N + M) {
        string op, name; readf("%s ", &op);
        if (op == "+") {
            int x; readf("%s %d\n", &name, &x);
            insert(name, x, t, true);
        } else {
            readf("%s\n", &name);
            remove(name, t);
        }
    }
}

Measured memory_bytes: 14916
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e9+18
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=105;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
#define ub upper_bound
#define pie 3.14159265359
#define mod 1000000007
 ll dp[102][1000005],c[100005],b[100005];
int main()
{   // fastio;
	ll  n,k,i,j;
	cin>>n>>k;
	ll  a[n];
	for(i=0;i<n;i++)
   {
   	cin>>a[i];

   }
  
  for(i=0;i<=k;i++)
  {
  	
  	if(i<=a[0]){
  		dp[1][i]=1;
  		c[i]=1;
  	}
  	else{
  		dp[1][i]=0;
  		c[i]=0;
  	}
  	if(i>=1)
  		c[i]=(c[i-1]%mod+c[i]%mod)%mod;

  }
  for(i=2;i<=n;i++)
  {
    
  	for(j=0;j<=k;j++){
  	if(i%2==0)
  	{
  		if(j==0){
  			b[j]=dp[i][j]=dp[i-1][j];

  		}
  		else
  		{
  			ll m=j-a[i-1]-1;
  			if(m<0)
  				b[j]=dp[i][j]=c[j];
  			else
  					b[j]=dp[i][j]=(c[j]-c[m]+mod)%mod;
         if(j>=1)
         	b[j]=(b[j-1]%mod+b[j]%mod)%mod;
  		}

  	}
  	else
  	{
  		if(j==0){
  			c[j]=dp[i][j]=dp[i-1][j];

  		}
  		else
  		{
  			ll m=j-a[i-1]-1;
  			if(m<0)
  				c[j]=dp[i][j]=b[j];
  			else
  					c[j]=dp[i][j]=(b[j]-b[m]+mod)%mod;
         if(j>=1)
         	c[j]=(c[j-1]%mod+c[j]%mod)%mod;
  		}


  	}
  }
  }

cout<<dp[n][k];
 
}

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

int main(){
  
  int A,B; cin >> A >> B;
  
  if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
    cout << "Possible" << endl;
  }
  
  else{
    cout << "Impossible" << endl;
  }
  
  return 0;
  
}

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

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

  int t=n;
  int f=0;

  while(true){
    f += t%10;
    t = t/10;
    if(t <= 0) break;
  }

  if(n%f == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
    int a,b,x=1,y=0,z=1,w=0;
    scanf("%2d%2d" ,&a,&b);
    if(a>=1 && a<=12)
        y=1;
    if(b>=1 && b<=12)
        w=1;
    if(y==w && y==1)
        cout << "AMBIGUOUS";
    else if(y==w && y==0)
        cout << "NA";
    else if(y==1)
        cout << "MMYY";
    else
        cout << "YYMM";
    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<int> retval;
		retval.reserve(num);

		for (int i = 0; i < num; ++i)
		{
			std::getline(stream, buf, delim);
			retval.push_back(std::stoi(buf));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;

	int num = GetValue<1>(stream)[0];
	std::vector<int> values = GetValue(stream, num, ' ');
	bool flag = true;
	int count = 0;

	while (flag)
	{
		flag = false;

		for (int i = num - 1; i > 0; --i)
		{
			if (values[i] < values[i - 1])
			{
				flag = true;
				++count;
				std::swap(values[i], values[i - 1]);
			}
		}
	}

	std::cout << values[0];
	for (size_t i = 1; i < values.size(); ++i)
	{
		std::cout << ' ' << values[i];
	}

	std::cout << '\n' << count << std::endl;
}



Measured memory_bytes: 3192
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int i[] = new int[3];
        i[0] = sc.nextInt();
        i[1] = sc.nextInt();
        i[2] = sc.nextInt();
        Arrays.sort(i);
        int k = i[2] - i[1];
        i[1] += k;
        i[0] += k;
        int j = (i[1] - i[0]) % 2 == 0 ? (i[1] - i[0]) / 2 : (i[1] - i[0] + 3) / 2;
        System.out.println(k + j);
    }
}

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

#define all(c) c.begin(), c.end()
using ll = long long;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = (int) 1e9;
  for (int i = 0; i < n; i++) {
    int x = a[i];
    int cnt = 0;
    while (x % 2 == 0) {
      x /= 2;
      cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
fun main (args : Array<String>) {
    val (n, k) = readLine()!!.split(" ")
    var N : Int = n.toInt()
    val K : Int = k.toInt()

    var cnt : Int = 0

    while (N >= K) {
        N = N / K
        cnt++
    }

    cnt++

    println("${cnt}")

}

Measured memory_bytes: 37868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main() {
    int x;
    cin>>x;
 
    int n500, n5;
 
    n500 = x/500;
    n5 = (x - 500*n500)/5;
 
    int ans;
    ans = n500*1000 + n5*5;
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = int(input())
mod = 10 ** 9 + 7

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

can_do = int(S / 3)
ans = 0
#i + 1個に分ける
for i in range(can_do):
  now = S - 3 * (i + 1)
  ans += cmb(now + i, i, p)
  ans %= mod
  #print(ans)
print(ans % mod)  
  



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int ret;
int to[100010];

int main() {
	cin >> N;
	rep(i, N) {
		int x;
		scanf("%d", &x);
		--x;
		to[i] = x;
	}
	rep(i, N) {
		if (to[to[i]] == i) ++ret;
	}
	cout << ret / 2 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#define it register int
#define ct const int
#define il inline
typedef long long ll;
using namespace std;
const int N=1000005;
int h[N],nxt[N],adj[N],t,fa[N],sz[N],id[N],V,n,x,d;
ll a[N],f[N],ans;
il ll Min(const ll p,const ll q){return p<q?p:q;}
il ll Max(const ll p,const ll q){return p>q?p:q;}
il void add(ct u,ct v){nxt[++t]=h[u],h[u]=t,adj[t]=v;}
il int dfs(ct x){
	sz[x]=1;
	for(it i=h[x];i;i=nxt[i]) dfs(adj[i]),sz[x]+=sz[adj[i]],a[x]+=a[adj[i]];
}
il bool cmp(ct p,ct q){return a[p]*sz[q]<a[q]*sz[p];}
int main(){ 
	scanf("%d%d%d%lld",&n,&x,&d,&a[1]);it i,j,k;
	for(i=2;i<=n;++i) scanf("%lld%d",&a[i],&fa[i]),id[i]=i;id[1]=1;//add(fa[i],i)
	//dfs(1);
	for(i=n;i;--i) ++sz[i],sz[fa[i]]+=sz[i],a[fa[i]]+=a[i];
	ct lim=(n<d?n:d),V=n*n*n;
	for(i=1;i<=V;++i) f[i]=1e18;
	for(i=1;i<=n;++i) for(j=1;j<=lim;++j) for(k=V;k>=sz[i];--k) f[k]=Min(f[k],f[k-sz[i]]+a[i]);
	std::sort(id+1,id+1+n,cmp);
	for(i=0;i<=V;++i)
		if(f[i]<=x){
			register ll s=i,lst=x-f[i];
			for(j=1;j<=n&&id[j]>1;++j){
				const ll now=min(d-lim+0ll,lst/a[id[j]]);
				lst-=a[id[j]]*now,s+=now*sz[id[j]]; 
			}
			ans=Max(ans,s+lst/a[1]*sz[1]);
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2728
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve() {
	int ans = 0;

	bool V[MAX];
	for (int i = 0; i < n; i++) {
		B[i] = A[i];
		V[i] = false;
	}
	sort(B, B + n);
	for (int i = 0; i < n; i++) T[B[i]] = i;
	for (int i = 0; i < n; i++) {
		if (V[i]) continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while (1) {
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m, v);
			S += v;
			cur = T[v];
			if (V[cur]) break;
		}
		ans += min(S + (an - 2)*m, m + S + (an + 1)*s);
	}

	return ans;
}

int main() {
	cin >> n;
	s = VMAX;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		s = min(s, A[i]);
	}
	int ans = solve();
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3176
function main()
  
  N = parse(Int, readline())
  K = parse(Int, readline())
  X = parse(Int, readline())
  Y = parse(Int, readline())
  
  count = 1
  
  ans = 0
  
  for i in 1:N
    
    if count <= K
      
      ans +=X
      
    else
      
      ans += Y
      
    end
    
    count += 1
    
  end
  
  println(ans)
  
end
  
main()

Measured memory_bytes: 108128
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
/*
int main(){
	ll n,x;
	cin>>n>>x;
	vi in(n);
	rep(i,n)cin>>in[i];
	if(n>2001)return 0;
	ll out=inf;
	loop(i,1,n+1){
		ll sum=(n+i)*x;
		rep(j,i)sum+=in[n-1-j];
		for(int j=n-1;j>=0;j--){
			ll dis;
			if(j-i>=0)dis=in[j]-in[j-i];
			else dis=in[j];
			sum+=dis*((n-j-1)/i+2)*((n-j-1)/i+2);
		}
		out=min(out,sum);
	}
	
	cout<<out<<endl;
}
*/
/*
int main(){
	int n,m;
	cin>>n>>m;
	string s;
	cin>>s;
	vvi G(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	vi f(n);
	rep(i,n){
		int a[2]={0};
		rep(j,G[i].size())a['A'==s[G[i][j]]]=1;
		if(a[0]+a[1]==2)f[i]=1;
	}
	vvi tG(n);
	rep(i,n)rep(j,G[i].size())
		if(f[i]&&f[G[i][j]]){
			tG[i].pb(G[i][j]);
			tG[G[i][j]].pb(i);
		}
	bool h=true;
	rep(i,n)if(f[i]){
		int a[2]={0};
		rep(j,tG[i].size())a['A'==s[tG[i][j]]]=1;
		if(a[0]+a[1]!=2)h=false;
	}
	if(h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
*/

signed main(){
	int n,x;
	cin>>n>>x;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	rep(i,n-1)in[i+1]+=in[i];
	rep(i,n)if(in[i]>x){
		cout<<i<<endl;
		return 0;
	}
	if(in[n-1]==x)cout<<n<<endl;
	else cout<<n-1<<endl;
}










Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int W,H,N;
    cin>>W>>H>>N;
    int xs=0,xe=W,ys=0,ye=H;
    REP(i,N){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1)xs=max(xs,x);
        if(a==2)xe=min(xe,x);
        if(a==3)ys=max(ys,y);
        if(a==4)ye=min(ye,y);
    }
    if(xs>=xe||ys>=ye)cout<<0<<endl;
    else cout<<(xe-xs)*(ye-ys)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define ff first
#define sc second
#define pb push_back
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005
// bool prime[1000000]; // 10**6
// lli pri[100000],x=0;
/*void sieve()
{
  msb(prime);
  prime[0]=prime[1]=false;
  for(int p=2;p*p<=1000000;p++)
  {
    if(prime[p])
    {
      for(int i=p*2;i<=1000000;i+=p)
        prime[i]=false;
      // a[x++]=p;
    }
  }
} */

int main()
{
    fio;
    int t,n,i;
    cin >> n;
    int a[n+1], cnt = 0;
    f(i,1,n+1)
    {
        cin >> a[i];
        if((i&1) && (a[i]&1))
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3552
using System;

class Atcoder92
{
    public static void Main()
    {
        int r = int.Parse(Console.ReadLine());

        if (r < 1200)
            Console.WriteLine("ABC");
        else if (r >= 1200 && r < 2800)
            Console.WriteLine("ARC");
        else
            Console.WriteLine("AGC");
    }
}

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

public class Main {

	public static void main(String[] args) {

		//		new Main().dPA();
		new Main().dPA2();

	}

	private void dPA() {
		Scanner scanner = null;
		int numDay = 0;

		try {
			scanner = new Scanner(System.in);
			numDay = scanner.nextInt();
			int[][] dayArray = new int[numDay][3];
			int[][] koufukuArray = new int[numDay][3];

			for (int i = 0; i < numDay; i++) {
				dayArray[i][0] = scanner.nextInt();
				dayArray[i][1] = scanner.nextInt();
				dayArray[i][2] = scanner.nextInt();
			}

			koufukuArray[0][0] = dayArray[0][0];
			koufukuArray[0][1] = dayArray[0][1];
			koufukuArray[0][2] = dayArray[0][2];
			for (int i = 1; i < dayArray.length; i++) {
				Arrays.fill(koufukuArray[i], Integer.MIN_VALUE);
				for (int j = 0; j < 3; j++) {
					for (int k = 0; k < 3; k++) {
						if (j == k) {
							continue;
						}
						koufukuArray[i][j] = Math.max(dayArray[i][j] + koufukuArray[i - 1][k], koufukuArray[i][j]);
					}
				}
			}

			int koufuku = 0;
			for (int i = 0; i < 3; i++) {
				koufuku = Math.max(koufukuArray[koufukuArray.length - 1][i], koufuku);
			}

			System.out.println(koufuku);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void dPA2() {
		Scanner scanner = null;
		int numDay = 0;

		try {
			scanner = new Scanner(System.in);
			numDay = scanner.nextInt();
			int[][] dayArray = new int[numDay][3];
			int[][] koufukuArray = new int[numDay][3];

			for (int i = 0; i < numDay; i++) {
				dayArray[i][0] = scanner.nextInt();
				dayArray[i][1] = scanner.nextInt();
				dayArray[i][2] = scanner.nextInt();
			}

			koufukuArray[0][0] = dayArray[0][0];
			koufukuArray[0][1] = dayArray[0][1];
			koufukuArray[0][2] = dayArray[0][2];

			for (int i = 1; i < dayArray.length; i++) {
				Arrays.fill(koufukuArray[i], Integer.MIN_VALUE);
				for (int j = 0; j < 3; j++) {
					for (int k = 0; k < 3; k++) {
						if (j == k) {
							continue;
						}
						koufukuArray[i][j] = Math.max(dayArray[i][j] + koufukuArray[i - 1][k], koufukuArray[i][j]);
					}
				}
			}

			int max = 0;
			for (int i = 0; i < 3; i++) {
				max = Math.max(koufukuArray[koufukuArray.length - 1][i], max);
			}

			System.out.println(max);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 102520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,x,y,z,a,b,c,k,i,i1,w,ind,mini;
    cin>>x>>y>>z>>k;
    vector<ll>v1,v2,v3;
    for (i=0;i<x;i++){
        cin>>w;
        v1.push_back(w);
    }
    sort(v1.begin(),v1.end(),greater<ll>());
    for (i=0;i<y;i++){
        cin>>w;
        v2.push_back(w);
    }
    sort(v2.begin(),v2.end(),greater<ll>());
    for (i=0;i<z;i++){
        cin>>w;
        v3.push_back(w);
    }
    sort(v3.begin(),v3.end(),greater<ll>());
    a=0;
    b=0;
    c=0;
    set<pair<ll,pair<ll,ll> > >s;
    priority_queue<pair<ll,pair<ll,pair<ll,ll> > > >pq;
    pq.push({v1[0]+v2[0]+v3[0],{0,{0,0}}});
    for (i=0;i<k;i++){
        cout<<pq.top().first<<'\n';
        a=pq.top().second.first;
        b=pq.top().second.second.first;
        c=pq.top().second.second.second;
        //cout<<a<<' '<<b<<' '<<c<<'\n';
        pq.pop();
        if (a!=x-1&&s.find({a+1,{b,c}})==s.end()){
            s.insert({a+1,{b,c}});
            pq.push({v1[a+1]+v2[b]+v3[c],{a+1,{b,c}}});
        }
        if (b!=y-1&&s.find({a,{b+1,c}})==s.end()){
            s.insert({a,{b+1,c}});
            pq.push({v1[a]+v2[b+1]+v3[c],{a,{b+1,c}}});
        }
        if (c!=z-1&&s.find({a,{b,c+1}})==s.end()){
            s.insert({a,{b,c+1}});
            pq.push({v1[a]+v2[b]+v3[c+1],{a,{b,c+1}}});
        }
        
    }
}


Measured memory_bytes: 1024