akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll=long long;

int cnt_digits(ll N) {
    int digits=0;

    while (N > 0) {
        N/=10;
        digits++;
    }

    return digits;
}

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

    int ans = cnt_digits(N);

    for (ll A=1LL; A*A<=N; ++A) {
        if (N%A != 0) continue;
        const ll B=N/A;

        const int cur = max(cnt_digits(A), cnt_digits(B));

        if (ans > cur) {
            ans = cur;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=1;i<n;i++)
int main()
{
  int k,x,count;cin>>k>>x;
  
  if(x-k>-1000000 and x+k<1000000){
        count=2*k-1;    
    for (int i = 1; i <= count; i++) {
      cout<<x-k+i<<' ';
    }
  }

}


Measured memory_bytes: 256
n,m=map(int,input().split())
c=list(map(int,input().split()))
dp=[[10001]*m for i in range(n)] #dp[value][i_coin]
dp.insert(0,[0]*m)
for i in range(m):
  for v in range(1,n+1):
    if i==0:
      dp[v][i]=v//c[i] if v%c[i]==0 else 10001
      continue
    if v<c[i]:
        dp[v][i]=dp[v][i-1]
    else:
      dp[v][i]=min(dp[v][i-1],dp[v-c[i]][i]+1)
print(dp[n][m-1])


Measured memory_bytes: 47288
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e5+11,INF=~0u>>2;
map<int,int> mp;
int n,ans;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i){
		int tmp=read();
		if(mp[tmp]==0) mp[tmp]=1,ans++;
		else mp[tmp]=0,ans--;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4992
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars
    };
    let mut c = vec![0; 4];
    for s_i in s.iter() {
        c[match s_i {
            'N' => 0,
            'W' => 1,
            'S' => 2,
            'E' => 3,
            _ => unreachable!(),
        }] += 1;
    }
    let ans = !((c[0] > 0 && c[2] == 0)
        || (c[0] == 0 && c[2] > 0)
        || (c[1] > 0 && c[3] == 0)
        || (c[1] == 0 && c[3] > 0));
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define SIZE 10005
vector< ll > dp[SIZE];
ll height[SIZE];
ll n;
vector< pair< ll , ll > > graph[SIZE];
ll dfs(ll u , ll i){
	if(dp[u][i] >= 0)
		return dp[u][i];
	dp[u][i] = graph[u][i].second;
	ll to = graph[u][i].first;
	int j = 0;
	for(auto it : graph[to]){
		if(it.first == u){
			j++;continue;}
		dp[u][i] = max(dp[u][i], dfs(to,j) + graph[u][i].second);
		j++;
	}
	return dp[u][i];
}
void solve(){
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < (int)graph[i].size() ; j++)
		{
				if(dp[i][j] >= 0) continue;
				dp[i][j] = dfs(i , j); 
		}
	}
	for(int i = 0 ; i < n ; i++){
		height[i]  =0;
		for(int j = 0 ; j < (int)dp[i].size() ; j++){
			height[i] = max(height[i] , dp[i][j]);
		}	
	}
} 
int main(){
	dhoom;

	cin >> n;
	for(int i = 0 ; i < n - 1 ;i++){
		ll x , y , wt;
		cin >> x >> y >> wt;
		graph[x].push_back({y,wt});
		graph[y].push_back({x,wt});		
	}
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < (int)graph[i].size() ; j++)
			dp[i].push_back(-1);
	}
	solve();
	for(int i = 0 ;i < n ;i++)
		cout << height[i] << endl;
    return 0;
}




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

int main(){
  int e1, e2, e3, e4;
  cin>>e1>>e2>>e3>>e4;

  if(e1 == e2 == e3 == e4 || e1 == e2 && e3 == e4 || e1 == e3 && e2 == e4 || e1 == e4 && e2 == e3) cout<<"yes"<<endl;
  else cout<<"no"<<endl;

  return 0;
}



Measured memory_bytes: 3096
import bisect
N,Q=map(int,input().split())
S=input()
ar=[]
al=[]
ans=[]
for i in range(N-1):
    if S[i]=="A":
        if S[i+1]=="C":
            al.append(i+1)
            ar.append(i+2)
for _ in range(Q):
    l,r=map(int,input().split())
    L=bisect.bisect_left(al,l)
    R=bisect.bisect_right(ar,r)
    ans.append(R-L)
for i in range(Q):
    print(ans[i])

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

using namespace std;

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

	vector<long long> a(n,0),b(n,0),c(n,0);

	for(int i=1;i<=n;i++)
		cin >> a[i-1];
	for(int i=1;i<=n;i++)
		cin >> b[i-1];
	for(int i=1;i<=n;i++)
		cin >> c[i-1];

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());

	long long ans = 0;

	for(int i=1;i<=n;i++)
	{
		ans+=((lower_bound(a.begin(),a.end(),b[i-1])-a.begin())*(c.end()-upper_bound(c.begin(),c.end(),b[i-1])));
	}

	cout << ans << endl;
}

Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main(void){
  ll X,K,D;
  cin >> X >> K >> D;
  if(X<0){
    X *= -1;
  }
  int cake = 0;
  ll ans = 100000000000;
  if(K>X/D){
    cake = 1;
  }
  if(cake == 0){
    ans = X - (K*D);
  }
  else{
    ll nokori = K -(X/D);
    if(nokori%2==0){
      ans = X%D;
    }
    else{
      ans = D-(X%D);
    }
  }
  if(ans<0){
    ans *= -1;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main() {
	int n, m, x;
	int left = 0, right = 0;
	cin >> n >> m >> x;
	for (int i = 0; i < m; i++) {
		int a; cin >> a;
		if (a < x)left += 1;
		else right += 1;
	}
	cout << min(left, right) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			int[] a = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(p => p).ToArray();
			int sum = 0;
			foreach (var i in a) {
				sum += i;
			}
			//System.Diagnostics.Debug.WriteLine($"{a[m - 1]} * 4 * {m} < {sum}");
			if (a[m - 1] * 4 * m >= sum) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}


			Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


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

int main() {
  int N;
  int K;
  cin>>N;
  cin>>K;
  int ans;
  int S=1;
  for(int i=0;i<1000000000000;++i){
    if(N>=S){
      S*=K;
      ans+=1;
    }
    else{
      break;
    }
  }
  cout <<ans<<endl;
      
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n,k;cin>>n>>k;

  ll num=k;
  ll ans=0;
  while(n){
    n/=num;
    ans++;
  }
  out(ans);


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <unordered_map>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;
 
const ll Mod = pow(10,9)+7;
 
// k^{M-2} == k^{-1}
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % Mod;
        x = x*x % Mod;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;

    ll val1 = 1; // ifac(a - b)
    for(ll i = 0; i < a - b ; i ++){
        val1 *= mpow(i+1, Mod-2);
        val1 %= Mod;
    }
    ll val2 = 1; // ifac(b)
    for(ll i = 0; i < b ; i ++){
        val2 *= mpow(i+1, Mod-2);
        val2 %= Mod;
    }
    ll val3 = 1; // fac(a)
    for(ll i = 0; i < a ; i ++){
        val3 *= (i + 1);
        val3 %= Mod;
    }

    ll tmp = val1 * val2 % Mod;
    return tmp * val3 % Mod;
}
 
int main()
{
    ll N,M;
    cin >> M >> N;
    std::unordered_map<ll, ll> soinsuu;

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    /*fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }*/

    // 割る数の初期値
    ll a = 2;
    ll copyN = N;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (copyN >= a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (copyN % a == 0) {
            try{
                soinsuu[a] = soinsuu[a] + 1;
            }
            catch(std::out_of_range&) {
                soinsuu[a] = 0;
            }
            copyN /= a;
        } else {
            a++;
        }
    }

    ll result = 1;

    for(auto itr = soinsuu.begin(); itr != soinsuu.end(); ++itr) {
        result *= comb(M + itr->second - 1, itr->second);
        result %= Mod;
    }

    cout << result;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string;

struct Team {
	string name;
	int win;
	int lose;
	int order;
	int opCmp(ref const Team t) const {
		if (win != t.win) return t.win - win;
		else if (lose != t.lose) return lose - t.lose;
		else return order - t.order;
	}
}

void main(){
	string[] s;
	int n, win, lose;
	while (readf("%d\n", &n), n) {
		Team[] t;
		foreach (i; 0..n) {
			s = readln.split;
			win = lose = 0;
			foreach (a; s[1..$]) {
				if (a == "0") win++;
				if (a == "1") lose++;
			}
			t ~= Team(s[0] ,win, lose, i);
		}
		t.sort;
		foreach (i; t) {
			writeln(i.name);
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int maxn = 55;
const ll mod = 1e9 + 7;
int n;
ll k;

struct matrix {
public:
    int n, m;
    vector<vector<ll> > x;
};

matrix multiply(matrix a, matrix b) {
    matrix ab;
    ab.n = a.n;
    ab.m = b.m;
    for(int i=0;i<ab.n;i++) {
        vector<ll> x;
        for(int j=0;j<ab.m;j++) {
            x.pb(0);
            for(int k=0;k<n;k++) {
                x.back() += a.x[i][k] * b.x[k][j];
                x.back() %= mod;
            }
        }
        ab.x.pb(x);
    }
    return ab;
}

matrix power(matrix a, ll k) {
    if(k == 1) return a;
    else {
        if(k % 2 == 0) {
            matrix half = power(a, k/2);
            return multiply(half, half);
        }
        else {
            return multiply(a, power(a, k-1));
        }
    }
}

int main() {
    cin>>n>>k;
    matrix a;
    a.n = a.m = n;
    for(int i=0;i<n;i++) {
        vector<ll>x(n);
        for(int j=0;j<n;j++) {
            cin>>x[j];
        }
        a.x.pb(x);
    }
    matrix result = power(a, k);

    ll sum = 0LL;
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            sum += result.x[i][j];
            sum %= mod;
        }
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 2816
<?php
list($n, $m) = explode(" ", fgets(STDIN));
$array = array_fill(0, $m, 0);
for($i=0; $i<$n; $i++){
	$likes = explode(" ", fgets(STDIN));
	$likes_2 = array_splice($likes, 1);
	foreach ($likes_2 as $like) {
		$array[$like-1] +=1;
	}
}
$answer = 0;
foreach ($array as $key => $value) {
	if($value==$n){
		$answer+=1;
	}
}
echo $answer . "\n";
// var_dump($array);
// echo $n . "\n";

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == s[2]){
        print("Yes");
    }else{
        print("No");
    }
}


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

//#define DEBUG_SHOW(x) cout<<(#x)<<" = "<<(x)<<endl
#define DEBUG_SHOW(x) 

using namespace std;
inline int max(int a, int b);
int main(){
	int n;
	string s[110];
	int m;
	string t[110];
	cin >> n;
  	DEBUG_SHOW(n);
	for(int i = 0; i < n; i++){
		cin >> s[i];
	  	DEBUG_SHOW(s[i]);
	}
	cin >> m;
  	DEBUG_SHOW(n);
	for(int i = 0; i < m; i++){
		cin >> t[i];
	  	DEBUG_SHOW(t[i]);
	}
	
	int ans = 0;
	for(int j = 0; j < n; j++){
		int tmpAns = 0;
		for(int i = 0; i < n; i++){
//			if(i == j) continue;
			// 青いカードはプラス
			if(s[j] == s[i]) ++tmpAns;
		}
		for(int i = 0; i < m; i++){
			// 赤いカードはマイナス
			if(s[j] == t[i]) --tmpAns;
		}
		ans = max(ans, tmpAns);
		DEBUG_SHOW(ans);
		DEBUG_SHOW(tmpAns);
	}
	cout << ans << endl;
	return 0;
}
inline int max(int a, int b){
	return a > b? a: b;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

bool ab[100000],ac[100000],bc[100000];

bool match(char c1,char c2){
  return (c1=='?' || c2=='?' || c1 == c2);
}

int main() {
  int M=2000;
  string a,b,c;
  cin >> a >> b >> c;
  int A=a.size(),B=b.size(),C=c.size();
  rep(i,A) rep(j,B) if (!match(a[i],b[j])) ab[i-j+50000]=true;
  rep(i,A) rep(j,C) if (!match(a[i],c[j])) ac[i-j+50000]=true;
  rep(i,B) rep(j,C) if (!match(b[i],c[j])) bc[i-j+50000]=true;
  int ans=3*M;
  for(int i=-2*M;i<=2*M;i++) for(int j=-2*M;j<=2*M;j++){
    if (!ab[i+50000] && !ac[j+50000] && !bc[j-i+50000]){
      int L=min(0,min(i,j));
      int R=max(A,max(B+i,C+j));
      ans=min(ans,R-L);
    }
  }
  cout << ans << endl;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a == b){
    cout << c << endl;
  }
  
  else if(b == c){
    cout << a << endl;
  }
  
  else{
    cout << b << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

string s,t;

int main(){
	cin>>s;
	sort(s.begin(),s.end());
	t=s;
	t.erase(unique(t.begin(),t.end()),t.end());
	for(int i=0;i<t.size();i++){
		if((upper_bound(s.begin(),s.end(),t[i])-lower_bound(s.begin(),s.end(),t[i]))%2==1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

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

using namespace std;

#define TRUE 1
#define FALSE 0

int palindrome(string s, int n) {
    int i, j, flag = 0;
    if(n < 3) {
        if(s[0] == s[n-1]) return TRUE;
        else return FALSE;
    } else {
        for(i = 0, j = n-1; i < n/2, j > n/2; i++, j--) {
            if(s[i] == s[j]) flag++;
        }
        if(flag == i) return TRUE;
        else return FALSE;
    }
}

int main() {
    string s;
    cin >> s;
    int n = s.length();

    string s1, s2;
    int n1, n2;
    s1 = s.substr(0, ((n-1)/2));
    n1 = s1.length();
    s2 = s.substr(((n+3)/2-1), (n-((n+3)/2)+1));
    n2 = s2.length();
    if(palindrome(s, n) == 1 && palindrome(s1, n1) == 1 && palindrome(s2, n2) == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    //cout << s1 << endl << s2 << endl;
    return 0;
}

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

using namespace std;

int main(){
    int n,d,ans,c,k;
    cin>>n>>d;
    c=(n+d)-(n-d)+1;
    if(n%c==0){
      cout<<n/c<<endl;
    }
    else{
        cout<<n/c+1<<endl;
    }
    return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n, a, min = 10000, max = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a);
		if(a > max) max = a;
		if(a < min) min = a;
	}
	printf("%d", max - min);
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int n; cin >> n;
    vector<int> a(n);
    vector<int> vec(1e6+10, 0);
    rep(i, n) {
        int x; cin >> x;
        vec[x]++;
        a[i] = x;
    }
    int ans = 0;
    rep(i, n) {
        int x = a[i];
        vec[x]--;
        bool flag = true;
        for (int j = 1; j*j <= x; j++) {
            if (x%j == 0) {
                if (vec[j]>0 || vec[x/j]>0){
                    flag = false;
                    break;
                }
            }
        }
        if (flag) ans++;
        vec[x]++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8008
object Main extends App {
  val src = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt).toList)

  for (List(rows, elems) <- src if rows != 0)
    println(src.take(rows).toList
      .transpose.map(_.sum).zip(Stream from 1)
      .sortWith((tup1, tup2) => tup1._1 > tup2._1)
      .map{ case (num, idx) => idx }.mkString(" "))
}



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

int main(int argc, char const *argv[])
{
	double n,m,d;
	cin>>n>>m>>d;
	double ans=(n-d)/(n*n);
	if (d!=0.0)
	{
		ans*=2.0;
	}
	printf("%.10f\n", ans*(m-1.0));
	return 0;
}


Measured memory_bytes: 256
open Batteries
(* charのカウント *)
let count_char target str =
  let rec count lst =
    match lst with
    | [] -> 0
    | first :: rest -> if first = target then 1 + count rest else count rest
  in let explode s = List.init (String.length s) (String.get s)
  in count @@ explode str
(* 文字列をcharのlistにする *)
let explode s = List.init (String.length s) (String.get s)
let n = read_int ()
let s = read_line ()
let s2 = s |> explode |> Array.of_list

let r = count_char 'R' s
let g = count_char 'G' s
let b = count_char 'B' s
let rgb = r * g * b
let rec loop i ans2 =
  let rec loop2 j ans =
    if i >= n - 1 then ans else
    let k = 2 * j - i in
    if k >= n then ans else
    if (s2.(i) <> s2.(j)) && (s2.(j) <> s2.(k)) && (s2.(i) <> s2.(k)) then loop2 (j+1) (ans+1)
    else loop2 (j+1) ans
  in if i >= n-2 then ans2 else
  loop (i+1) (ans2 + loop2 (i+1) 0)

let _ = Printf.printf "%d\n" (rgb-(loop 0 0))


Measured memory_bytes: 5824
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep2(i,a,n) for(int i = (a);i < (n);i++)
#define rep(i,n) rep2(i,0,n)
#define INF (1LL << 60)
#define vec vector

int main(void){
    ll n,k;
    cin >> n >> k;
    ll a[n+5];
    rep(i,n)cin >> a[i];
    
    vector<ll> sum(n+5,0);
    sum[k-1] = 1;
    for(int i = k;i < n;i++){
        if(a[i] > a[i-k])cout << "Yes";
        else cout << "No";
        cout << endl;
    }
}

Measured memory_bytes: 6420
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    s = input()
    count = 0
    ws = [0] * n
    es = [0] * n

    for i in range(0, n):
        if s[i] == 'W':
            ws[i] = ws[i - 1] + 1
            es[i] = es[i - 1]
        else:
            es[i] = es[i - 1] + 1
            ws[i] = ws[i - 1]

    for i in range(len(s) - 1):
        if i == 0:
            count = es[-1] - es[1]
        else:
            count = min(count, (ws[i]) + (es[-1] - es[i + 1]))

    print(count)


Measured memory_bytes: 17552
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#define csanf scanf

ll l[100];
int main(){
	ll n;cin>>n;
	l[0]=2;
	l[1]=1;
	for(int i=2;i<=n;i++){
		l[i]=l[i-1]+l[i-2];
	}
	cout<<l[n]<<endl;
}

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

int k, n;

void solve() {
  
}

int main() {
  cin >> k >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  A.push_back(A[0]+k);
  int l = 0;
  for (int i = 0; i < n; i++) {
    l = max(l, A[i+1]-A[i]);
  }
  int tot = k-l;
  cout << tot << endl;
}


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

int n, m, x;
vector<int> price(12);
vector<vector<int>> level(12, vector<int> (12));

int check(int bit) {
  vector<int> understand(m);
  int p = 0;
  rep(i, n) {
    if(bit & (1 << i)) {
//      cout << i << "check" << endl;
      p += price[i];
//      cout << p << " " ;
      rep(j, m) {
        understand[j] += level[i][j];
//        cout << understand[j] << " ";
      }
    }
  }
  
  rep(i, m) {
    if(understand[i] < x) return -1;
  }
  
  return p; 
}



int main() {
  cin >> n >> m >> x;
  int minprice = 2000000000;
  
  rep(i, n) {
    cin >> price[i];
    rep(j, m) {
      cin >> level[i][j];
    }
  }

  
  rep(i, pow(2,n)) {
    int p = check(i);
//    cout << p << endl;
    if(p != -1) {
      minprice = min(p, minprice);
    }
  }
  
  if(minprice == 2000000000) cout << -1 << endl;
  else cout << minprice << endl;
  return 0;
}


Measured memory_bytes: 4112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int M, D;
	cin >> M >> D;

	Int ans = 0;
	Int d1;
	Int d2;
	for (Int i = 1; i <=M ; i++) {
		for (Int j = 10; j <=D; j++) {
			d1 = j % 10;
			d2 = j/ 10 % 10;
			if ((d1>=2)&&(d2>=2)&&(d1 * d2 == i))ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int x,y,z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
using namespace std;
int a[100500];
int main()
{int n,k,ans=0;
 cin>>n>>k;
 for(int i=0;i<n;i++)
 cin>>a[i];
 for(int i=0;i<n;i++)
 ans+=a[i];
 sort(a,a+n);
 int c=k-ans;
 int z=c/a[0];
 cout<<n+z<<endl;
 system("pause");
 return 0;
}

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

int main() {
  int N, L; cin >> N >> L;
  int a[201]={0};
  int mindif=(int)(1<<30);
  vector<int> S(N+1, 0);
  for(int i = 1; i <= N; ++i) {
    a[i] = L + i - 1;
    S[i] = S[i-1] + a[i];
  }
  for(int i = 1; i <= N; ++i) {
    mindif = min(mindif, abs(a[i]));
  }
  int ans = (S[N] < 0) ? S[N] + mindif : S[N] - mindif;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int h, w; cin >> h >> w;
    rep(i,h)rep(j,w) {
        string s; cin >> s;
        if (s == "snuke") {
            cout << char(j+'A') << i+1 << endl;
        }
    }
}

Measured memory_bytes: 3544
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class Nomura_A
    {
        public static void Main(string[] args)
        {
            //var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long start_hour = inputLongArray[0];
            long start_min = inputLongArray[1];

            long end_hour = inputLongArray[2];
            long end_min = inputLongArray[3];


            long k = inputLongArray[4];//min

            DateTime start_date = new DateTime(2020, 5, 30, (int)start_hour, (int)start_min,0);
            DateTime end_date = new DateTime(2020, 5, 30, (int)end_hour, (int)end_min, 0);

            TimeSpan ts1 = end_date - start_date;

            int resulu_minutes = (int)ts1.TotalMinutes - (int)k;

            string result = resulu_minutes.ToString();

            Console.WriteLine(result);

            Console.Out.Flush();

        }

    }
}

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

int main() {

    map<char,int> m[50];
    int n;

    cin >> n;

    set<char> se[50];
    set<char> all_set;

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

        for(int k=0; k<s.size(); k++){
            m[i][s[k]]++;
            se[i].insert(s[k]);
            all_set.insert(s[k]);
        }

    }

    string ans = "";

    for(set<char>::iterator itr = all_set.begin(); itr != all_set.end(); itr++){

        int al_min = 500;

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

            if(se[i].find(*itr) == se[i].end()){
                al_min = 0;
                break;
            }

            al_min = min(al_min,m[i][*itr]);

        }

        for(int i=0; i<al_min; i++){

            ans.push_back(*itr);

        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
a,b,c,d=map(int,input().split())
import fractions
e=(c*d)//(fractions.gcd(c,d))
cc=b//c-a//c
dd=b//d-a//d
cd=b//e-a//e

if a%c==0:
  cc+=1
if a%d==0:
  dd+=1
if a%e==0:
  cd+=1

print(b-a+1-(cc+dd-cd))

Measured memory_bytes: 5044
IDENTIFICATION DIVISION.
PROGRAM-ID. 174B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(20).
01 N          PIC 9(06).
01 D          PIC 9(06).
01 I          PIC 9(06)      COMP.
01 X          PIC S9(06).
01 Y          PIC S9(06).
01 K          PIC 9(11)V9(7) COMP.
01 CNT        PIC 9(06) COMP.
01 OUT        PIC Z(5)9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO N D.
*>
  MOVE ZERO TO CNT.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    ACCEPT INP
    UNSTRING INP DELIMITED BY ' '
        INTO X Y
*>
    COMPUTE K = (X * X + Y * Y) ** 0.5
    IF (K <= D)
      ADD 1 TO CNT
    END-IF
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 4484
import java.io.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[][] data = new String[8][8];
		for(int y=0; y<8; y++){
			line = in.readLine();
			for(int x=0; x<8; x++){
				data[y][x] = line.substring(x, x+1);
			}
		}
		
		System.out.println(90);
		for(int x=0; x<8; x++){
			for(int y=0; y<8; y++){
				System.out.print(data[7-y][x]);
			}
			System.out.println();
		}
		
		System.out.println(180);
		for(int y=0; y<8; y++){
			for(int x=0; x<8; x++){
				System.out.print(data[7-y][7-x]);
			}
			System.out.println();
		}
		
		System.out.println(270);
		for(int x=0; x<8; x++){
			for(int y=0; y<8; y++){
				System.out.print(data[y][7-x]);
			}
			System.out.println();
		}
	}
}

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

bool isPrime(int x) {
  bool ans = true;
  for(int i=2; i<x; i++){
    if(x%i == 0) {
      ans = false;
      break;
    }
  }
  return ans;
}

int main() {
  int X;
  cin>>X;
  bool a = false;
  while(!a){
    if(isPrime(X)){
      cout<<X<<endl;
      a=true;
    }
    X++;
  }
}

Measured memory_bytes: 3624
N = list(map(int,list(input())))

if N[0] + N[1] + N[2] + N[3] == 7:
    print("{0}+{1}+{2}+{3}=7".format(N[0],N[1],N[2],N[3]))
elif N[0] + N[1] + N[2] - N[3] == 7:
    print("{0}+{1}+{2}-{3}=7".format(N[0],N[1],N[2],N[3]))
elif N[0] + N[1] - N[2] + N[3] == 7:
    print("{0}+{1}-{2}+{3}=7".format(N[0],N[1],N[2],N[3]))
elif N[0] + N[1] - N[2] - N[3] == 7:
    print("{0}+{1}-{2}-{3}=7".format(N[0],N[1],N[2],N[3]))
elif N[0] - N[1] + N[2] + N[3] == 7:
    print("{0}-{1}+{2}+{3}=7".format(N[0],N[1],N[2],N[3]))
elif N[0] - N[1] + N[2] - N[3] == 7:
    print("{0}-{1}+{2}-{3}=7".format(N[0],N[1],N[2],N[3]))
elif N[0] - N[1] - N[2] + N[3] == 7:
    print("{0}-{1}-{2}+{3}=7".format(N[0],N[1],N[2],N[3]))
elif N[0] - N[1] - N[2] - N[3] == 7:
    print("{0}-{1}-{2}-{3}=7".format(N[0],N[1],N[2],N[3]))

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

int main(){
  int r;
  cin >> r;
  if(r < 1200) puts("ABC");
  else if(r < 2800) puts("ARC");
  else puts("AGC");
  return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
keta = int(math.log10(n))+1

num_list = []

def append_number(n):
    numbers = []
    for s in [3,5,7]:
        numbers.append(str(n)+str(s))
    return numbers

def make_numbers(n_list,keta):
    if keta == 0:
        return n_list
    else:
        append_numbers = []
        for n in n_list:
            for s in append_number(n):
                append_numbers.append(s)
            num_list.append(n)
        return(make_numbers(append_numbers,keta-1))

make_numbers(["3","5","7"],keta)

ans = 0
for i in num_list:
    if int(i) <= n and ("3" in i) and ("5" in i) and ("7" in i):
        ans += 1
print(ans)



Measured memory_bytes: 51036
a,b,h,m = gets.chomp.split.map(&:to_f)
h_d = 30 * (h + (m/60))
m_d = 6 * m
d = [(h_d - m_d).abs, 360 - (h_d - m_d).abs].min
r2 = a ** 2 + b ** 2 - 2 * a * b * Math.cos(d * Math::PI / 180)
puts Math.sqrt(r2)

Measured memory_bytes: 14736
#include<algorithm>
#include<cstdio>
#include<utility>
#include<vector>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 1e5;
int n;
vector<int> a;
vector<P> ans;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int b;
        scanf("%d", &b);
        a.emplace_back(b);
    }
    sort(a.begin(), a.end());

    vector<int>::iterator c = upper_bound(a.begin(), a.end(), 0);
    if (c == a.begin()) c++;
    if (c == a.end()) c--;
    vector<int>::iterator b = prev(c);
    ans.emplace_back(*c, *b);
    int d = *c - *b;
    a.erase(c); 
    a.erase(b); 
    while (!a.empty()) {
        if (a.back() > 0) {
            int e = ans.back().first;
            ans.back().first= ans.back().second;
            ans.back().second = e;
            d = -d;
        }
        if (a.back() >= d) {
            ans.emplace_back(a.back(), d);
            d = a.back() - d;
        }
        else {
            ans.emplace_back(d, a.back());
            d = d - a.back();
        }
        a.pop_back();
    }

    printf("%d\n", d);
    for (int i = 0; i < n - 1; i++) {
        printf("%d %d\n", ans[i].first, ans[i].second);
    }
    return 0;
}


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

#define mod 1000000007
#define pb push_back
#define ep emplace_back
#define fr first
#define sc second
#define linf  (1ll << 60)
#define inf (((1 << 30) - 1) << 1)
const double eps = 0.000000001;
#define leps 1e-18
#define mkp make_pair
#define pnode Node*
#define mpi unordered_map<int, int>
std::random_device rd;
std::mt19937 mt(rd());
using namespace std;

int binpow(int a, int u) {
    int ans = 1;

    while (u) {
        if (u & 1) {
            ans = (1ll * ans * a) % mod;
            u--;
        } else {
            a = (1ll * a * a) % mod;
            u >>= 1;
        }
    }
    return ans;
}

long long h(int n, int x) {
    int lsb = __builtin_ctz(n);
    if ((x & n) > (1 << lsb)) return 0;

    int u = 0;
    int mask = (x & ((1 << lsb) - 1)) ^((1 << lsb) - 1);

    u = 1 << (__builtin_popcount(mask));

    if (x & (1 << lsb)) {
        return u;
    }

    return u + 1;
}

long long g(int n, int x) {
    if (n == 0)
        return 1;
    int lsb = __builtin_ctz(n);
    int d = n - n ^(1 << lsb);
    if (d == 0) return h(n, x);
    return h(x, n) + g(d, x);
}

long long f(int l, int r) {
    if (l == 0 && r == 0) return 1;
    if (l == r) return 0;
    if (l % 2 == 0 && r % 2 == 0) return 3 * f(l >> 1, r >> 1);
    if (l % 2 == 1) return f(l + 1, r) + 2 * (g(l, r) - g(l, l));
    if (r % 2 == 1) return f(l, r - 1) + 2 * (g(r - 1, r) - g(r - 1, l));
}

void solve() {
    int L, R;
    cin >> L >> R;
    cout << f(L, R) << endl;
}

int main() {

    string s;
    cin >> s;

    int n = s.length() - 1;

    int ans = 0;

    int N = n;

    int ones = 0;

    for (int i = 0; i <= n; i++) {
        if (s[i] == '1') {
            ans = (ans + (1ll * binpow(3, N) * binpow(2, ones) % mod)) % mod;
            ones++;
        }
        N--;
    }

    ans = (ans + binpow(2, ones)) % mod;

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
using namespace std;
const int MAXSANG = 100000;
 
int snt[MAXSANG+1];
 
void sangnt()
{
    long i,j;
    for (i=1; i<=MAXSANG; i++)
        snt[i]=1;
    snt[1]=0;
    i=2;
    while (i<=sqrt(MAXSANG))
    {
        while (snt[i]==0)
            i++;
        for (j=2; j<=MAXSANG/i; j++)
            snt[i*j]=0;
        i++;
    }
}
 
int main()
{
    sangnt();
    int f[100005];
    f[2]=0;
    for(int i=3;i<=100000;i++){
        if((snt[i])&&(snt[(i+1)/2]))
            f[i]=f[i-1]+1;
        else
            f[i]=f[i-1];
    }
    int q;
    cin>>q;
    for(int i=1;i<=q;i++){
        int l,r;
        cin>>l>>r;
        cout<<f[r]-f[l-1]<<endl;
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int x[N],bk[17][N];
int main()
{
	int n,l,q;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",x+i);
	scanf("%d%d",&l,&q);
	int pre=0;
	for(int i=0;i<n;i++)
	{
		while(x[i]-x[pre]>l)
			pre++;
		bk[0][i]=pre;
	}
	for(int i=1;i<17;i++)
		for(int j=0;j<=n;j++)
			bk[i][j]=bk[i-1][bk[i-1][j]];
	for(;q--;)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		if(a==b)
		{
			puts("0");
			continue;
		}
		if(a>b)
			swap(a,b);
		int ret=0;
		for(int i=16;i>=0;i--)
		{
			if(bk[i][b]>a)
			{
				ret+=1<<i;
				b=bk[i][b];
			}
		}
		printf("%d\n",ret+1);
	}
	return 0;
}


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

int main(void){
    int i,j,N;
    int s[6];
    int check = 0;

    N = 6;
    for(i = 0; i < N; i++)
    {
        scanf("%d", &s[i]);
    }
    for(i = 0; i< N && check == 0; i++)
    {
        for(j = 0; j < N && check == 0; j++)
        {
            if (s[j]-s[i] > s[5]) {
                check = -1;
                printf(":(");
            } 
        }
    }
    if (check == 0) {
        printf("Yay!");
    }
    return 0;
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
  }
  cout << 1 + (n - 2) / (k - 1) << '\n';
  return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;
const lli INF = 1ll << 63;

lli n,x;
lli a[e5];
lli ans;


int main(){
  cin >> n >> x;
  for(lli i = 0;i < n;i++) cin >> a[i];
  sort(a,a+n);
  lli i = 0;
  while((i < n) && x >= a[i]) x -= a[i],ans++,i++;
  if(i == n && x > 0) ans--;
  cout << ans << endl;




}


Measured memory_bytes: 256
n=int(input())
a= list(input())
b= list(input())
c= list(input())

ans = 0
for i in range(n):
    ans += len({a[i], b[i], c[i]}) - 1

print(ans)
    
        
        

'''
west
east
wait

{'w', 'e', 'w'}
{'w', 'e'}
len → 2 
1文字は使って良い -1


'''

Measured memory_bytes: 3060
import collections
import itertools

N, M = map(int, input().split())
a, b = list(zip(*[map(int, input().split()) for _ in range(M)]))

paths = collections.defaultdict(list)
for i in range(M):
    paths[a[i] - 1].append(b[i] - 1)
    paths[b[i] - 1].append(a[i] - 1)

ans = 0
for perm in itertools.permutations(range(N)):
    if perm[0] != 0:
        continue

    for i in range(1, N):
        if perm[i] not in paths[perm[i - 1]]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 9464
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	string s;
	vll cnt(2, 0);
	bool flg = false, flg2 = false;

	in(s);

	rep (i, 0, s.size()) {
		if (s[i] == '0') {
			cnt[0]++;
		}
		else {
			cnt[1]++;
		}
	}


	outn(min(cnt[0],cnt[1])*2);
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
  int i,j,n,m;
  char c,s[5]={'S','H','C','D','\0'};
  static int card[4][13];
  scanf("%d\n",&n);

  for(i=0;i<n;i++){
    scanf("%c %d\n",&c,&m);
    for(j=0;j<4;j++)
      if(s[j]==c)
        card[j][m-1]=1;
  }
  
  for(i=0;i<4;i++)
    for(j=0;j<13;j++)
      if(card[i][j]==0)
        printf("%c %d\n",s[i],j+1);

  return 0;
}
    



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

long long f[200000],cnt[200000];

long long getf(long long u)
{
	return f[u]==u?u:f[u]=getf(f[u]);
}

void merge(long long u,long long v)
{
	long long f1,f2;
	f1=getf(u),f2=getf(v);
	
	if(f1!=f2)
		f[f2]=f1;
}

signed main()
{
	ios::sync_with_stdio(0);
	
	long long n,m,i,u,v,mx=0;
	cin >>n >> m;
	
	for(i=1; i<=n; i++)
		f[i]=i;
		
	for(i=1; i<=m; i++)
	{ 
		cin >> u >> v;
		merge(u,v);	 
	} 
		
	for(i=1; i<=n; i++)
		cnt[getf(i)]++;
		
	for(i=1; i<=n; i++)
		mx=max(mx,cnt[i]);
		
	cout << mx << endl;
	
	return 0;
}

Measured memory_bytes: 6564
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let a: i64 = read();
    let b: i64 = read();

    if a*b%2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>x(n),y(n),p(n); 
  rep(i,n) cin >> x[i] >> y[i] >> p[i]; 
  vector<ll>ans(n+1,1e18);
  
  vector<vector<ll>> distx(1<<n,vector<ll>(n));
  vector<vector<ll>> disty(1<<n,vector<ll>(n));
  for(int bit=0;bit<(1<<n);bit++){
    rep(i,n){
      distx[bit][i]=abs(x[i]);
      disty[bit][i]=abs(y[i]);
      rep(j,n){
        if(bit&(1<<j)){
          distx[bit][i]=min(distx[bit][i],abs(x[i]-x[j]));
          disty[bit][i]=min(disty[bit][i],abs(y[i]-y[j]));
        }
      }
    }
  }
  for(int bit=0;bit<(1<<n);++bit){
    int cnt = __builtin_popcount(bit);
    for(int i=bit;i>=0;--i){
      i&=bit;//bitで表せる選び方の部分集合i
      ll cost = 0;
      rep(j,n){
        if(!(bit&(1<<j))){
          // bitに含まれる場合は距離0
          cost += min(distx[i][j],disty[bit-i][j])*p[j];
        }
      }
      ans[cnt]=min(ans[cnt],cost);
    }
  }
  rep(i,n+1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 12956
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll y[20000005];
ll a[10000005];
ll dp[20005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
string s[2000005];
P p[2000005];
char c[55][55];
int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c[i][j];
		}
	}
	int count = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (c[i][j] == '#') {
				for (int k = 0; k < 4; k++) {
					int newi = i + dy[k];
					int newj = j + dx[k];
					if (newi >= 0 && newi < h && newj >= 0 && newj < w) {
						if (c[newi][newj] == '#') {
							count++;
						}
					}
				}
				if (count < 2) {
					cout << "No" << endl;
					return 0;
				}
				count = 1;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 16640
a,b,c,n;main(t){for(scanf("%d",&n);n--;puts(a*a-b*b-c*c?"NO":"YES"))scanf("%d%d%d",&a,&b,&c),b>a&&(t=a,a=b,b=t),c>a&&(t=a,a=c,c=t);exit(0);}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
using llong = long long;
using ullong = unsigned long long;

int main() {
  int N,M;
  cin >> N >> M;
  int maxL = 0 , minR = N;
  for(int i=0;i<M;++i){
    int L,R;
    cin >> L >> R;
    if( L > maxL ) maxL = L;
    if( R < minR ) minR = R;
  }
  if( minR - maxL + 1 <= 0 ){
    cout << 0 << endl;
  }else{
    cout << minR - maxL + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll k, a, b;
  cin >> k >> a >> b;
  
  ll bisket=1, money=0;
  rep(i, k) {
    if(money) {bisket+=b; money--;}
    else if(i<k-1 and a+2<b and bisket>=a) {bisket-=a; money++;} 
    else bisket++;
  }
  cout << bisket << newl;
  return 0;
}

Measured memory_bytes: 3652
import collections

def main():
    N = int(input())
    D = [int(_) for _ in input().split()]
    M = int(input())
    T = [int(_) for _ in input().split()]
    Dd = collections.Counter(D)
 
    if N < M:
        print("NO")
        return

    for i in range(M):
        target = T[i]
        if Dd[target] >= 1:
            Dd[target] = Dd[target] - 1
        else:
            print("NO")
            return
    
    print("YES")


if __name__ == "__main__":
    main()

Measured memory_bytes: 41692
N = int(input())
Hs = list(map(int, input().split()))

ans = 0
count = 0
for i in range(N-1):
  if Hs[i] >= Hs[i+1]:
    count += 1
  else:
    ans = max(ans, count)
    count = 0

ans = max(ans, count)    
    
print(ans)

Measured memory_bytes: 14252
N = int(input())
n = list(map(int, input().split()))
f = 0
for i in n:
  if i % 2 == 0:
    if i % 3 != 0 and i % 5 != 0:
      f = 1
      break
if f == 0:
  print('APPROVED')
else:
  print('DENIED')

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

int main(){
  int A,B;
  cin >> A >> B;
  int C;
  C = (A+B) / 2;
  if((A+B) % 2 == 0 ){
    cout << C;
  }else{
    cout << "IMPOSSIBLE" ;
  }
  
}


Measured memory_bytes: 256