akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long ll;

int main() {
  ll inf = 1LL << 60;
  int N;
  cin >> N;
  vector<ll> hs;
  ll h;
  ll dp[N];
  for (int i = 0; i < N; ++i) {
    cin >> h;
    hs.push_back(h);
    dp[i] = inf;
  }
  dp[0] = 0;

  for (int i = 0; i < N - 1; ++i) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(hs[i] - hs[i + 1]));
    if (!(i == N - 2)) {
      dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i] - hs[i + 2]));      
    }
  }

  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1912
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

int dp[1<<20], z[5][5][5][5];
int n, f[5][5];
int s;

int rec(int at) {
    if(at==5) return dp[s>>5];
    if((s&(1<<at))==0) return rec(at+1);
    int ans=1<<30;
    rep(xe, 5) for(int ye=at; ye<5; ye++) {
        s ^= z[0][xe][at][ye];
        ans = min(ans, rec(at+1)+1);
        s ^= z[0][xe][at][ye];
    }
    return ans;
}

int main() {
    rep(xe, 5) rep(xs, xe+1) rep(ye, 5) rep(ys, ye+1) {
        for(int x=xs; x<=xe; x++) for(int y=ys; y<=ye; y++) {
            z[xs][xe][ys][ye] |= 1<<(x*5+y);
        }
    }
    rep(ix, 20) rep(d, 1<<ix) {
        int b=1<<ix|d, xe=ix/5, ye=ix%5;
        dp[b] = 1<<30;
        rep(xs, xe+1) rep(ys, ye+1) dp[b]=min(dp[b], dp[b^z[xs][xe][ys][ye]]+1);
    }
    for(;;) {
        scanf("%d", &n);
        if(n==0) return 0;
        memset(f, 0, sizeof(f));
        rep(i, n) rep(j, n) scanf("%d", f[i]+j);
        s = 0;
        rep(i, n) rep(j, n) s|=f[i][j]<<(i*5+j);
        int ans = n<5 ? dp[s] : rec(0);
        rep(i, ans) printf("myon");
        putchar('\n');
    }
}

Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    int x, t;
    cin >> x >> t;
    int ans = (x >= t)? (x - t) : 0;
    cout << ans << endl;
    return 0;
}

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

#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }

template<class T>
void print(const T &x) { cout << x << endl; }

template<class T, class... A>
void print(const T &first, const A &... rest) {
    cout << first << " ";
    print(rest...);
}

struct PreMain {
    PreMain() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    map<int, int> mp;
    REP(i, N) {
        int a;
        cin >> a;
        mp[a]++;
    }

    if (mp[0] == N){
        print("Yes");
        return 0;
    }

    if (N % 3 != 0) {
        print("No");
        return 0;
    }

    vector<int> vec;
    for (auto x: mp){
        REP(i, x.second / (N/3)) {
            vec.emplace_back(x.first);
        }
    }

    if (vec.size() == 3 && ((vec[0] ^ vec[1]) == vec[2])) {
        print("Yes");
    } else {
        print("No");
    }


    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
//#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
int main()
{
    Hello
    int n;
    cin >> n;
    vector<int> v1, v2;
    for(int i = 0, x, y; i < n; i++){
        cin >> x >> y;
        v1.push_back(x);
        v2.push_back(y);
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    if(n % 2)
        cout << v2[n/2] - v1[n/2] + 1;
    else {
        int i = n/2;
        cout << (v2[i] + v2[i - 1]) - (v1[i] + v1[i - 1]) + 1;
    }
    return 0;
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int h , w;
   cin >> h >> w;
   vector<int> str(2*w);
	for (int i = 0; i < (2*w); i++) cin >> str.at(i);
  	for (int i = 1; i <= h; i++){
      int count = 0;
      for (int j = 0; j < str.size() ; j++){
      if (str.at(j)==i) count++;
    }
  	cout << count << endl;
    }
}
      

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n; cin >>s;
    int cnt=1;
    char tmp = s[0];
    rep(i,1,n){
        if(tmp != s[i]){
            cnt++;
            tmp = s[i];
        }
    }
    cout << cnt << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	ll n,x;cin>>n>>x;
	vector<ll> l( n, 0 );
	REP(i, n) cin >> l[i];

	ll cnt = 1;
	ll d = 0;
	REP(i,n)
	{
		d += l[i];
		if( d > x ) break;
		++cnt;
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int h, w, a, b, i, j;
	scanf("%d%d%d%d", &h, &w, &b, &a);
	for(i=0; i<a; i++){
		for(j=0; j<b; j++) putchar('0');
		for(; j<w; j++) putchar('1');
		putchar(10);
	}
	for(; i<h; i++){
		for(j=0; j<b; j++) putchar('1');
		for(; j<w; j++) putchar('0');
		putchar(10);
	}
}



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

using namespace std;

const int INF = 1e9 + 7;
const int N = (int)2e5 + 3;

typedef long long ll;
typedef long double ld;

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

int n, m, used[101], used2[101];
char a[101][101], ans[101][101];
int main(){
  cin >> n >> m;
  for (int i = 1; i <= n; ++i){
    int ok = 1;
    for (int j = 1; j <= m; ++j){
      cin >> a[i][j];
      if (a[i][j] == '#') ok = 0;
    }
    if (ok){
      used[i] = 1;
    }
  }
  for (int i = 1; i <= m; ++i){
    int ok = 1;
    for (int j = 1; j <= n; ++j){
      if (a[j][i] == '#') ok = 0;
    }
    if (ok == 1){
      used2[i] = 1;
    }
  }
  //cout << "\n";
  for (int i = 1; i <= n; ++i){
    if (used[i]) continue;
    for (int j = 1; j <= m; ++j){
      if (used2[j]) continue;
      cout << a[i][j];
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int b[3][3];
int c[3][3];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    for (int m = 0; m < 3; ++m)
        for (int n = 0; n < 3; ++n)
            cin >> c[m][n];

    for (int i = 0; i <= 100; ++i)
    {
        for (int j = 0; j <= 100; ++j)
        {
            for (int k = 0; k <= 100; ++k)
            {
                int f[3] = {i, j, k};
                for (int m = 0; m < 3; ++m)
                    for (int n = 0; n < 3; ++n)
                        b[m][n] = c[m][n] - f[n];

                bool bad = false;
                for (int m = 0; m < 3; ++m)
                    for (int n = 0; n < 3; ++n)
                        if (b[m][n] != b[m][0])
                            bad = true;
                if (!bad)
                    return cout << "Yes", 0;
            }
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
edge = [[0 for i in range(n)] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    edge[a-1][b-1] = 1
    edge[b-1][a-1] = 1

def ok(l):
    return all([edge[l[i]-1][l[i+1]-1] for i in range(n-1)])
ans = 0
for x in itertools.permutations(range(2,n+1)):
    l = [1] + list(x)
    if ok(l):
        ans += 1
print(ans)

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

int search(vector<string> t,bitset<3> h){
  int ans=stoi(t.at(0));
  for(int i=0;i<3;i++){
    int b=stoi(t.at(3-i));
    if(h.test(i))
      ans=ans+b;
    else
      ans=ans-b;
  }  
  return ans;
}

string answer(vector<string> t,bitset<3> h){
  string To;
  for(int i=0;i<3;i++){
    if(h.test(i))
      To="+"+t.at(3-i)+To;
    else
      To="-"+t.at(3-i)+To;
  }
  To=t.at(0)+To+"=7";
  return To;
}

int main(){
  vector<char> tc;
  for(int i=0;i<4;i++){
    char k;
    cin>>k;
    tc.push_back(k);
  }
  vector<string> t(4);
  for(int i=0;i<4;i++){
    t.at(i)=tc.at(i);
  }
  for(int i=0;i<(1<<3);i++){
    bitset<3> h(i);
    int ans=0;
    ans=search(t,h);
    if(ans==7){
      cout<<answer(t,h)<<endl;
      break;
    }
  }
}

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

double dp[3005][3005];

int main(){
    int n;
    cin >> n;
    double p[n];
    rep(i, n){
        cin >> p[i];
    }

    dp[1][1] = p[0];
    dp[1][0] = 1-p[0];

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

Measured memory_bytes: 68992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        String s = sc.next();
        int count = 0;
        for (char c : s.toCharArray()) {
            if (c == '1') {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 10;

int a[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for(int i=0; i<n; i++)
		cin >> a[i];

	sort(a, a + n);

	int mn = 0, mx = 0;
	for(int i=0; i<n; i++){
		if(a[i] == a[0])mn++;
		if(a[i] == a[n - 1])mx++;
	}
	if(mn == n && mx == n){
		if(a[0] == n-1)return cout << "Yes\n", 0;
		if(a[0] * 2 <= n)return cout << "Yes\n", 0;
	}
	if(a[n - 1] != a[0] + 1)return cout << "No\n",0;
	if(mn + mx != n)return cout << "No\n", 0;
	
	if(a[n - 1] <= mn)return cout << "No\n", 0;

	int cnt = a[n - 1] - mn;
	if(cnt * 2 > mx)return cout << "No\n", 0;
	return cout << "Yes\n", 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

int A, B, C, D;

int main() {
    scanf("%d %d %d %d", &A, &B, &C, &D);
    if (B <= C || D <= A) {
        cout << 0 << endl;
        return 0;
    }
    cout << max(abs(max(A, C) - min(B, D)), 0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
  cin >> a >> b;
  int n = a.size();
  int m = b.size();
  vector<vector<int>> dp(n+1,vector<int>(m+1,-1));
  for(int i=0;i<=n;i++)
      dp[i][0] = 0;
  for(int i=0;i<=m;i++)
      dp[0][i] = 0;
  for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++)
      {
          if(a[i-1] == b[j-1])
              dp[i][j] = 1 + dp[i-1][j-1];
          else
              dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
      }
  int i = n,j=m;
  string str = "";
  while(i>0 && j >0)
  {
  	if(a[i-1] == b[j-1])
  	{
  		str += a[i-1]; 
  		i--;j--;
  	}	
  	else
  	{
  		if(dp[i-1][j]> dp[i][j-1])
  			i--;
  		else
  			j--;
  	}
  }
  	reverse(str.begin(),str.end());
  	cout << str;
  
}

Measured memory_bytes: 38488
#include <stdio.h>

int main(int argc, char const *argv[]) {
    int n;
    int min = 1000001;
    int max = -1000001;
    long long int sum=0;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        sum += a;
        if (a > max) {
            max = a;
        }
        if (a < min) {
            min = a;
        }
    }

    printf("%d %d %lld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 2084
import std.algorithm,
       std.string,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] HW = readln.chomp.split.to!(int[]);
  int H = HW[0],
      W = HW[1];
  string[] text = H.iota.map!(_ => readln.chomp).array;

  (W+2).iota.each!(_ => write("#")); writeln;

  foreach (line; text) {
    writefln("#%s#", line);
  }

  (W+2).iota.each!(_ => write("#")); writeln;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong X, Y;
  cin >> X >> Y;

  bool ok = false;
  for (int i = 0; i <= X; ++i) {
    ok |= i*2 + (X - i) * 4 == Y;
  }

  cout << (ok ? "Yes": "No") << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
//scanf("%d", &a)

int main() {
	int n;
	cin >> n;
	vector<string> fs(n);
	ll ans = 0;
	rep(i, n) {
		string s;
		cin>>s;
		sort(s.begin(), s.end());
		fs.at(i) = s;
	}
	sort(fs.begin(), fs.end());
	int count = 1;
	rep2(i, 1, n) {
		if (fs[i] != fs[i-1]) {
			count = 1;
		}
		else ++count;
		ans += count - 1;
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 5760
from collections import deque

n,q=[int(i) for i in input().split()]
que = deque()
for a in range(n):
    s = input().split()
    que.append((s[0], int(s[1])))

t = 0
done = []
while len(que) != 0:
    name, time = que.popleft()
    mi = min(q, time)
    t += mi
    time -= mi
    if time == 0:
        done.append((name, t))
    else:
        que.append((name, time))
for a in done:
    print(a[0], a[1])


Measured memory_bytes: 14336
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

        public Fast() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int arr[] = new int[10];
        int n = in.nextInt(), k = in.nextInt();
        for (int i = 0; i < k; i++) {
            arr[in.nextInt()] = 1;
        }
        l:
        for (int i = n; i <10000000; i++) {
            String str = "" + i;
            for (int j = 0; j < str.length(); j++) {
                if (arr[str.charAt(j) - '0'] == 1) {
                    continue l;
                }
            }
            System.out.println(i);
            return;
        }
    }
}






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

namespace ABC179A
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int l = S.Length;
            if (S[l-1].ToString() == "s") Console.WriteLine(S + "es");
            else Console.WriteLine(S + "s");
        }
    }
}


Measured memory_bytes: 25692
#include <stdio.h>
#include <math.h>

int main() {

  double a,b,c;
  double S,L2, L, h;

  scanf("%lf %lf %lf",&a,&b,&c);

  S = 0.5*a*b*sin(c*3.14159265359/180);
  L2 = a*a+b*b-2*a*b*cos(c*3.1415926359/180);
  L = sqrt(L2)+a+b;
  h = 2*S/a;

  printf("%.11lf\n%.11lf\n%.11lf\n",S ,L,h); 

  return 0;
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

using node = tuple<ll, int, int, int>;

const int MAX_X = (int)(1e3 + 5);
const int MAX_Y = (int)(1e3 + 5);
const int MAX_Z = (int)(1e3 + 5);
const int MAX_K = (int)(3e3 + 5);

int x, y, z, k;
ll a[MAX_X], b[MAX_Y], c[MAX_Z];

int main(void) {
  // Here your code !
  scanf("%d %d %d %d", &x, &y, &z, &k);

  for (int i = 0; i < x; ++i) {
    scanf("%lld", &(a[i]));
  }

  for (int i = 0; i < y; ++i) {
    scanf("%lld", &(b[i]));
  }

  for (int i = 0; i < z; ++i) {
    scanf("%lld", &(c[i]));
  }

  sort(a, a + x, greater<ll>());
  sort(b, b + y, greater<ll>());
  sort(c, c + z, greater<ll>());

  priority_queue<node> pq;
  pq.push(node(a[0] + b[0] + c[0], 0, 0, 0));

  set<node> visited;

  int cnt = 0;
  while (!pq.empty()) {
    node cur = pq.top();
    pq.pop();

    if (visited.find(cur) != visited.end()) continue;

    visited.insert(cur);

    ll cost = get<0>(cur);
    int ia = get<1>(cur);
    int ib = get<2>(cur);
    int ic = get<3>(cur);

    printf("%lld\n", cost);

    cnt += 1;

    if (cnt == k) {
      break;
    }

    if (ia + 1 < x) pq.push(node(cost - a[ia] + a[ia + 1], ia + 1, ib, ic));
    if (ib + 1 < y) pq.push(node(cost - b[ib] + b[ib + 1], ia, ib + 1, ic));
    if (ic + 1 < z) pq.push(node(cost - c[ic] + c[ic + 1], ia, ib, ic + 1));
  }

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  map<int, int> m;
  rep(i, n){
    int in;
    cin >> in;
    in /= 400;
    if(in > 8) in = 8;
    m[in]++;
  }
  int mn, mx;
  mn = mx = 0;
  for(auto p : m){
    if(p.first < 8){
      mn++;
      mx++;
    }else{
      if(mn == 0) mn++;
      mx += p.second;
    }
  }
  cout << mn << " " << mx << endl;
  return 0;
}

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

typedef long long int ll;
ll dp[105][100005];

int main()
{
	ll n,W;
	cin>>n>>W;
	ll wt[n],v[n];
	for(ll i=0;i<n;i++)
		cin>>wt[i]>>v[i];
	/*	for(ll i=0;i<=n;i++)
		{
		for(ll j=0;j<=W;j++)
		{
		if(j==0 || i==0)
		{
		dp[i][j]=0;
		}
		else if(wt[i-1]<=j)
		{
		dp[i][j]=max(dp[i-1][j-wt[i]]+v[i-1],dp[i-1][j]);
		}
		else
		{
		dp[i][j]=dp[i-1][j];
		}
		}
		}*/
	ll K[n+1][W+1];
	for (ll i = 0; i <= n; i++) 
	{
		for (ll w = 0; w <= W; w++) 
		{
			if (i == 0 || w == 0)
				K[i][w] = 0;
			else if (wt[i - 1] <= w)
				K[i][w] = max(
						v[i - 1] + K[i - 1][w - wt[i - 1]],
						K[i - 1][w]);
			else
				K[i][w] = K[i - 1][w];
		}
	}
	printf("%lld\n",K[n][W]);
}


Measured memory_bytes: 82420
#include <iostream>
#include <utility>
#include <vector>

int main(int argc, char *argv[]) {
  int n, k;
  std::cin >> n >> k;

  std::vector<std::pair<int, int>> s;
  for (int i = 0; i < k; ++i) {
    int l, r;
    std::cin >> l >> r;
    s.push_back(std::pair<int, int>(l, r));
  }

  int mod = 998244353;

  std::vector<long> dp(n + 1, 0);
  std::vector<long> dpsum(n + 1, 0);
  dp[1] = 1;
  dpsum[1] = 1;
  for (int i = 2; i <= n; ++i) {
    for (auto d : s) {
      long l = std::max(i - d.second, 1);
      long r = i - d.first;
      if (r < 1) {
        continue;
      }

      dp[i] += dpsum[r] - dpsum[l - 1];
      dp[i] %= mod;
    }

    dpsum[i] = dpsum[i - 1] + dp[i];
  }

  std::cout << dp[n] << std::endl;

  return 0;
}

Measured memory_bytes: 5944
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n>>m;
    cout<<(n*m)<<"\n";
    return 0;
}



Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
bool can[105][105];
struct edge{
  int to,cap,rev;
};
vector<edge> G[1005];
bool used[1005];
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});
}
int dfs(int v,int t,int f){
  if(v==t) return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}
int max_flow(int s,int t){
  int flow=0;
  while(1){
    for(int i=0;i<1005;i++) used[i]=false;
    int f=dfs(s,t,12345678);
    if(f==0) return flow;
    flow+=f;
  }
}
int main(){
  int x,y,k;
  cin>>x>>y>>k;
  for(int i=0;i<105;i++){
    for(int j=0;j<105;j++) can[i][j]=false;
  }
  for(int i=0;i<k;i++){
    int a,b;
    cin>>a>>b;
    can[a][b]=true;
  }
  int s=x+y,t=s+1;
  for(int i=0;i<x;i++) add_edge(s,i,1);
  for(int i=0;i<y;i++) add_edge(x+i,t,1);
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      if(can[i][j]){
        add_edge(i,x+j,1);
      }
    }
  }
  cout<<max_flow(s,t)<<endl;
}



Measured memory_bytes: 3392
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        long L = scan.nextLong();
        long[][] distance = new long[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(distance[i], Long.MAX_VALUE);
        }
        for (int i = 0; i < N; i++) {
            distance[i][i] = 0;
        }
        for (int i = 0; i < M; i++) {
            int from = scan.nextInt()-1;
            int to = scan.nextInt()-1;
            long d = scan.nextLong();
            if (d <= L) {
                distance[from][to] = d;
                distance[to][from] = d;
            }
        }
        int Q = scan.nextInt();
        int[][] query = new int[Q][2];
        for (int i = 0; i < Q; i++) {
            query[i][0] = scan.nextInt()-1;
            query[i][1] = scan.nextInt()-1;
        }
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    if (distance[i][k] == Long.MAX_VALUE || distance[k][j] == Long.MAX_VALUE) {
                        continue;
                    }
                    distance[i][j] = Math.min(distance[i][j],distance[i][k] + distance[k][j]);
                }
            }
        }
        long[][] count = new long[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(count[i], Long.MAX_VALUE);
        }
        for (int i = 0; i < N; i++) {
            count[i][i] = 0;
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (distance[i][j] <= L) {
                    count[i][j] = 1;
                }
            }
        }
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    if (count[i][k] == Long.MAX_VALUE || count[k][j] == Long.MAX_VALUE) {
                        continue;
                    }
                    count[i][j] = Math.min(count[i][j],count[i][k] + count[k][j]);
                }
            }
        }
        for (int i = 0; i < Q; i++) {
            int from = query[i][0];
            int to = query[i][1];
            long min_count = count[from][to];
            if (min_count == Long.MAX_VALUE) {
                System.out.println(-1);
                continue;
            }
            System.out.println(min_count-1);
        }
    }
}


Measured memory_bytes: 95876
from itertools import accumulate
import numpy as np

def parse(f):
    N = int(next(f))
    A = np.array(list(map(int, next(f).split())))
    B = np.array(list(map(int, next(f).split())))
    return A, B

def test(A, B):
    d = (A - B).astype(np.int64)
    shorts = d[d < 0]
    short = -np.sum(shorts)
    n = len(shorts)
    suffs = np.array(list(accumulate(sorted(d[d > 0], reverse=True))))
    if n == 0:
        print(0)
        return
    for i, b in enumerate(suffs > short):
        if b:
            print(i + n + 1)
            break
    else:
        print(-1)

import sys
test(*parse(sys.stdin))

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

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    string s, ans = "";
    int cnt[26] = {0}, pos = 26;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length()) {
        cnt[s[i] - 'a']++;
    }

    REP(i, 26) {
        if (cnt[i] == 0) {
            pos = i;
            ans = 'a' + i;
            break;
        }
    }

    if (pos == 26) {
        ans = "None";
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n, k = wi()
v = wi()
v = deque(v)
pq = []
po = 0
cnt = 0
qwerty = min(n + 1, k + 1)
for i in range(qwerty):
    if i != 0:
        heappush(pq, v[i - 1])
    for j in range(qwerty - i):
        if j != 0:
            heappush(pq, v[-j])
        while k - i - j - cnt > 0:
            if pq != []:
                po = 0
                po = heappop(pq)
                if po < 0:
                    cnt += 1
                    tmpli.append(po)
                else:
                    heappush(pq, po)
                    cnt = 0
                    break
            else:
                break
        cnt = 0
        ans = max(ans, sum(pq))
        for bb in tmpli:
            heappush(pq, bb)
        tmpli = []
    pq = []
    for g in range(i + 1):
        if g != 0:
            heappush(pq, v[g - 1])

print(ans)

Measured memory_bytes: 6480
#include <stdio.h>

int main(void)
{
    int N;
    int min,max,ret;
    int i;
    scanf("%d",&N);

    // 探索範囲下限
    min = N / 1.1;
    for(i=min;i<=N;i++){
        if((int)(i*1.08) == N){
            printf("%d\n",i);
            return 0;
        }
    }
    printf(":(\n");
    return 0;
}


Measured memory_bytes: 1728
#include "bits/stdc++.h"
using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long Int;
typedef vector<int> VI;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const Int LINF = INF * (Int) INF;
const int MAX = 100007; 

const int MOD = 998244353;

int main(int argc, char* argv[])
{
	// freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);
    
    int n;
    cin >> n;
    if ((n & (n - 1)) == 0)
    {
        cout << "No" << endl;
        return 0;
    }
    if (n % 4 == 3)
    {
        cout << "Yes" << endl;
        FOR(i,0,2 * n - 1)
        {
            cout << i + 1 << ' ' << i + 2 << endl;
        }
        return 0;
    }
    if (n % 4 == 1)
    {
        n -= 2;
        cout << "Yes" << endl;
        FOR(i,0,n - 1)
        {
            cout << i + 1 << ' ' << i + 2 << endl;
        }
        cout << n << ' ' << n + 3 << endl;
        FOR(i,0,n - 1)
        {
            cout << i + n + 3 << ' ' << i + n + 4 << endl;
        }
        n += 2;
        cout << n << ' ' << n - 1 << endl;
        cout << n - 1 << ' ' << 1 << endl;
        cout << 1 << ' ' << 2 * n << endl;
        cout << 2 * n << ' ' << 2 * n - 1 << endl;
        return 0;
    }
    if (n % 4 == 2)
    {
        int N = n;
        n -= 3;
        VI p;
        FOR(i,0,n)
            p.push_back(i);
        swap(p[1], p[2]);
        cout << "Yes" << endl;
        FOR(i,0,SZ(p) - 1)
        {
            cout << p[i] + 1 << ' ' << p[i + 1] + 1 << endl;
        }
        cout << p[n - 1] + 1 << ' ' << p[0] + N + 1 << endl;
        FOR(i,0,n - 1)
        {
            cout << p[i] + N + 1 << ' ' << p[i + 1] + N + 1 << endl;
        }
        n += 2;
        cout << n << ' ' << n - 1 << endl;
        cout << n - 1 << ' ' << 1 << endl;
        cout << 1 << ' ' << N + n << endl;
        cout << N + n << ' ' << N + n - 1 << endl;
        n += 1;
        cout << n << ' ' << n - 2 << endl;
        cout << 3 << ' ' << 2 * n << endl;
        return 0;
    }
    int a, b;
    FOR(i,0,20)
        if (n & (1 << i))
        {
            a = (1 << i);
            b = n - a;
        }
    VI p;
    p.push_back(a - 1);
    p.push_back(b - 1);
    FOR(i,0,n - 1)
        if (i != a - 1 && i != b - 1)
            p.push_back(i);
    int N = n;
    cout << "Yes" << endl;
    FOR(i,0,SZ(p) - 1)
    {
        cout << p[i] + 1 << ' ' << p[i + 1] + 1 << endl;
    }
    cout << p.back() + 1 << ' ' << p[0] + N + 1 << endl;
    FOR(i,0,SZ(p) - 1)
    {
        cout << p[i] + N + 1 << ' ' << p[i + 1] + N + 1 << endl;
    }
    cout << N << ' ' << a << endl;
    cout << b << ' ' << 2 * N << endl;

    // cerr << 1.0 * clock() / CLOCKS_PER_SEC << ' ' << eval(res) << endl;
}

Measured memory_bytes: 3320
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  cout << n*(n+1)/2 << endl;

}

Measured memory_bytes: 3528
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int w = sc.nextInt();
			if (w < 0) break;
			int yen = 1150;
			if (w > 30) { yen += (w - 30) * 160; w = 30; }
			if (w > 20) { yen += (w - 20) * 140; w = 20; }
			if (w > 10) { yen += (w - 10) * 125; w = 10; }
			System.out.println(4280 - yen);
		}
	}
}

Measured memory_bytes: 19112
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;
  set<int> s;
  rep(i,N) {
    int d; cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 256
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
arr3=list(map(int,input().split()))
arrall=arr1+arr2+arr3
num=[]
for i in range(4):
    num.append(arrall.count(i+1))
num.sort()
if num == [1,1,2,2] :
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
n = int(input())
a_ls = []
for i in range(n):
    a_ls.append(int(input()))

s_a_ls = sorted(a_ls)
max_val = s_a_ls[-1]

for item in a_ls:
    if item == max_val:
        print(s_a_ls[-2])
    else:
        print(max_val)


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

int main() {
    int a, b, cnt = 0, plug = 1;
    cin >> a >> b;

    while(plug < b) {
        plug--;
        plug += a;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
  int N, M;
  cin >> N>>M;
  
  vector<vector<char>> vec(N, vector<char>(M));
  
  vector<bool> goodx(N, false),goody(M, false);
  
  for (int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> vec.at(i).at(j);
    }
  } 
  
  for (int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(vec.at(i).at(j) == '#'){
        goodx.at(i) = true;
        goody.at(j) = true;
      }
    }
  }  

  for (int i=0;i<N;i++){
    if (goodx.at(i)){
      for(int j=0;j<M;j++){
        if (goody.at(j)){
          cout << vec.at(i).at(j);
        }
      }
    cout << endl;
    }    
  }  
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n,m;
ll f[100005];

int main(){
	scanf("%d%d",&n,&m);
	fore(_,0,n){
		ll w,v;
		scanf("%lld%lld",&w,&v);
		for(int j=m;j>=w;--j)f[j]=max(f[j],f[j-w]+v);
	}
	printf("%lld\n",f[m]);
	return 0;
}

Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	static class Pair implements Comparable<Pair>{
		String left;
		String right;
		long score;
		Pair(String l , String r, long s){
			left = l;
			right = r;
			score = s;
		}
		boolean isPalindrome(String str){
			for(int i = 0 ; i < str.length() ; ++i){
				char ci = str.charAt(i);
				char cj = str.charAt(str.length() - i - 1);
				if(ci != cj){
					return false;
				}
			}
			return true;
		}
		boolean isPalindrome(){
			if(left != null){
				return isPalindrome(left);
			}
			return isPalindrome(right);
		}
		@Override
		public int hashCode() {
			int h = (left != null ? left.hashCode() : 0);
			h = h * 31;
			h += (right != null ? right.hashCode() : 0);
			return h;
		}
		@Override
		public boolean equals(Object obj) {
			Pair o = (Pair)obj;
			if(left != null && o.left != null){
				return left.equals(o.left);
			}
			if(right != null && o.right != null){
				return right.equals(o.right);
			}
			return false;
		}
		@Override
		public int compareTo(Pair o) {
			return Long.compare(score, o.score);
		}
		
		public Pair adj(String str){
			int N = str.length();
			if(left != null){
				for(int i = 0; i < Math.min(left.length(), N) ; ++i){
					if(left.charAt(i) != str.charAt(N - 1 - i)){
						return null;
					}
				}
				if(left.length() <= N){
					return new Pair(null, str.substring(0, N - left.length()), 0);
				}else{
					return new Pair(left.substring(N), null, 0);					
				}
			}else{
				for(int i = 0; i < Math.min(right.length(), N) ; ++i){
					if(str.charAt(i) != right.charAt(right.length() - 1 - i)){
						return null;
					}
				}
				if(right.length() <= N){
					return new Pair(str.substring(right.length()), null, 0);					
				}else{
					return new Pair(null,right.substring(0, right.length() - N), 0);
				}
			}
//			return null;
		}
		@Override
		public String toString() {
			return left + " " + right;
		}
	}
	static long solve(String S[] , long C[]){
		PriorityQueue<Pair> q = new PriorityQueue<Pair>();
		Map<Pair, Long> vis = new HashMap<Pair, Long>();
		for(int i = 0 ; i < S.length ; ++i){
			Pair pi = new Pair(S[i] , null , C[i]);
			q.add(pi);
			vis.put(pi, C[i]);
		}
		while(!q.isEmpty()){
			Pair cp = q.poll();
//			System.out.println(cp);
			if(cp.isPalindrome()){
				return cp.score;
			}			
			for(int i = 0 ; i < S.length ; ++i){
				String si = S[i];
				long ci = C[i];
				Pair adj = cp.adj(si);
				if(adj == null){
					continue;
				}
//				System.out.println(" " + adj+" (" + si + ")");
				adj.score = cp.score + ci;
				if(!vis.containsKey(adj)){
					vis.put(adj, adj.score);
					q.add(adj);
				}else{
					long cost = vis.get(adj);
					if(adj.score < cost){
						vis.put(adj, adj.score);
						q.add(adj);						
					}
				}
			}
		}
		return -1;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S[] = new String[N];
		long C[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			S[i] = sc.next();
			C[i] = sc.nextLong();
		}
		long ret = solve(S , C);
		System.out.println(ret);
	}
}


Measured memory_bytes: 38104
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc;
	static PrintWriter out;
	public static void main(String[] args){
		sc = new FastScanner();
		out = new PrintWriter(System.out);
		out.println(solve());
		out.flush();
	}

	static int solve(){
		int N = sc.nextInt();
		int x = sc.nextInt();
		int[] matMap = new int[N];
		for(int i=0;i<N;i++){
			matMap[i] = sc.nextInt();
		}
		Arrays.sort(matMap);
		int count = 0;
		for(int i=0;i<N-1;i++){
			if(matMap[i]<=x){
				count++;
				x -= matMap[i];
			}else{
				break;
			}
		}
		if(x==matMap[N-1])count++;
		return count;
	}


}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define mod 1000000007
#define ll long long
#define f(i,n) for(int i=0;i<n;i++)
#define in(a,n) f(i,n){cin>>a[i];}
#define ou(a,n) f(i,n)cout<<a[i]<<" ";
#define sv(v) sort(v.begin(),v.end());
#define sa(a,n) sort(a,a+n);
int main()
{               int t=1;
               // cin>>t;
                while(t--)
                {
                    int n,k;
                    cin>>n>>k;
                    if(n==k) cout<<0<<endl;
                    else if(k==1) cout<<0<<endl;
                    else cout<<n-k<<endl;
                }
                return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    return 0;
}

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

using namespace std;

class UnionFind {
public:
    explicit UnionFind(int N) : root(N, -1), size(N, 1) {}
    int getRoot(int u){ return root[u] == -1 ? u : root[u] = getRoot(root[u]); }
    int getSize(int u){ return size[getRoot(u)]; }
    int same(int a, int b){
        return getRoot(a) == getRoot(b);
    }
    int merge(int a, int b){
        int u = getRoot(a);
        int v = getRoot(b);
        if(u != v){
            root[u] = v;
            size[v] += size[u];
        }
    }
private:
    vector<int> root;
    vector<int> size;
};

int main(){
    int N, M;
    while(cin >> N >> M){
        UnionFind uf(N+1);
        for(int i=0;i<M;i++){
            int x, y, z; cin >> x >> y >> z;
            uf.merge(x, y);
        }
        int res = 0;
        for(int i=1;i<=N;i++) if(uf.getRoot(i) == i) ++res;
        cout << res << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;


int main(){

int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b==c) cout<<"No"<<endl;
  else if(a!=b && b!=c && c!=a) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

# 最大値をとるインデックスを求めておく
k = max(range(N), key=lambda i: A[i])
ans = '\n'.join(
    str(
        max(A[:k] + A[k + 1:]) if i == k else
        A[k]
    )
    for i in range(N)
)

print(ans)


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

int main()
{
   int a,b,c,d,x,y;
   while(~scanf("%d%d%d%d",&a,&b,&c,&d))
   {
       x=a*b;
       y=c*d;
       if(x>=y)
        printf("%d\n",x);
       else
        printf("%d\n",y);
   }
    return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	vector<string>v(100);
	for (int i = 0; i < 100; i++) {
		v[i].resize(100, '.');
	}
	for (int i = 0; i < 100; i++) {
		if (i % 2) {
			for (int j = 1; j < 99; j++) {
				v[i][j] = '#';
			}
		}
		v[i][99] = '#';
	}
	int n = 1, m = 1;
	for (int i = 0; i < 100; i += 2) {
		for (int j = 1; j < 99; j += 2) {
			if (n != N) {
				v[i][j] = '#';
				n++;
			}
		}
	}
	for (int i = 99; i > 0; i -= 2) {
		for (int j = 98; j > 1; j -= 2) {
			if (m != M) {
				v[i][j] = '.';
				m++;
			}
		}
	}
	cout << 100 << " " << 100 << endl;
	for (auto i : v) {
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){
  int N, A, B;
  cin >> N >> A >> B;

  if (A * N < B)
    cout << A * N << endl;
  else
    cout << B << endl;

  return 0;
}


Measured memory_bytes: 256