akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  while (s.length() < 15) s += 'o';
  int cnt = 0;
  for (char c : s) {
    if (c == 'o') ++cnt;
  }
  cout << (cnt >= 8 ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++) // for loop
#define RREP(x,l,u) for(ll x = l;x>=u;x--) // reverse for loop

/**
 *  debugging stuff
 */
string to_string(string s) {return s;}
string to_string(char c) {return string(1,c);}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

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

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL; 
typedef pair<ll,ll> PLL;
typedef vector<string> VS;

template <typename A, typename B> void in(A & a, B & b) { in(a); in(b); }
template <typename A, typename B, typename C> void in(A & a, B & b, C & c) { in(a); in(b); in(c); }

const ll inf = (ll)1e18 + 5;

string A, B, output = "";
VVLL memoize;

ll check_sequence(ll a, ll b) {

    if (a >= A.length()) return 0;
    if (b >= B.length()) return 0;

    if (memoize[a][b] != -1) return memoize[a][b];

    if (A[a] == B[b]) {
        memoize[a][b] = 1 + check_sequence(a+1,b+1);
    } else {
        memoize[a][b] = max(check_sequence(a+1,b), check_sequence(a,b+1));
    }

    return memoize[a][b];
}

string bt(ll a, ll b) {
    if (a >= A.length()) return "";
    if (b >= B.length()) return "";

    if (A[a] == B[b]) {
        return A[a] + bt(a+1,b+1);
    } else {
        if (check_sequence(a+1,b) > check_sequence(a,b+1)) {
            return bt(a+1,b);
        } else {
            return bt(a,b+1);
        }
    }
}

namespace SOLVE {	
	void main() {
		cin >> A >> B;

        memoize.clear();
        memoize.resize(A.length(), VLL(B.length(), -1));

        cout << bt(0,0) << endl;
	}
}

signed main() {
	ll t;
	t = 1;
    // cin >> t;
	REP(i,0,t) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main () {
  int a; cin >> a;
  string s; cin >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
}


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

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m = 0, s = 0; cin>>n;
	while (n--){
		int x; cin>>x;
		s+=x;
		m = max(x, m);
	}
	if (s-m >m) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll d[310][310];
ll A[310][310];
bool use[310][310];
void warshall_floyd(int n) {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

void check(int n) {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == k || j == k) continue;
				if (d[i][j] == d[i][k] + d[k][j]) use[i][j] = false;
			}
		}
	}
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
			d[i][j] = A[i][j];
		}
	}
	warshall_floyd(N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			use[i][j] = true;
			if (A[i][j] != d[i][j]) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	check(N);
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (use[i][j]) ans += d[i][j];
		}
	}
	cout << ans / 2 << endl;
}


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

const int maxn =2e6+5;
int a[maxn];
int book[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int N,K;cin>>N>>K;
    for(int i=0;i<K;i++)
    {
        int t;cin>>t;
        int k;
        for(int i=0;i<t;i++)
            {
                cin>>k;book[k]++;
            }
    }
    int sum=0;
    for(int i=1;i<=N;i++)
        if(!book[i]) sum++;
    cout<<sum<<endl;
    return 0;
}


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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

template<class T>
inline bool change_max(T&a, const T&b){
  if(b > a){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool change_min(T&a, const T&b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

template<class T>
inline void readv(vector<T>&v){
  if(v.empty()){
    cerr << "void readv(vector<T>&v) v.empty()\n";
  }
  for(auto&&e:v){
    cin >> e;
  }
}

int main(){
  int n; cin >> n;
  vector<int>a(n+1);
  vector<int>b(n);
  readv(a);
  readv(b);
  ll sum = 0;
  for(int i = 0; i < n; ++i){
    if(a[i] >= b[i]){
      sum += b[i];
    } else {
      sum += a[i];
      b[i] -= a[i];
      if(b[i] >= a[i+1]){
	sum += a[i+1];	
	a[i+1] = 0;
      } else {
	sum += b[i];
	a[i+1] -= b[i];
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
import math
N = int(input())
step_list = list(map(int, input().split()))

dp_table = [math.inf] * N
dp_table[0] = 0

for i in range(1, N):
    if i <= 1:
        dp_table[i] = dp_table[i-1] + abs(step_list[i-1] - step_list[i])
    else:
        dp_table[i] = min(dp_table[i-1] + abs(step_list[i-1] - step_list[i]),
                          dp_table[i-2] + abs(step_list[i-2] - step_list[i]))

print(dp_table[N-1])


Measured memory_bytes: 20616
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
    if (!y)
        return x;
    return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}
bool solve(int a,int b,int c,int k)
{
    if(b>a && c>b)
        return true;
    if(k<=0)
        return false;

    return solve(a * 2, b, c, k - 1) || solve(a, b*2, c, k - 1) || solve(a, b, c*2, k - 1);

}
int main(int argc, char *argv[])
{
#ifdef LOCAL
    auto start = chrono::high_resolution_clock::now();
#endif
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    int k;
    cin >> a >> b >> c;
    cin >> k;

    if(solve(a,b,c,k))
        cout << "Yes";
    else
        cout << "No";


#ifdef LOCAL
    auto end = chrono::high_resolution_clock::now();
    double time_taken =
        chrono::duration_cast<chrono::nanoseconds>(end - start).count();

    time_taken *= 1e-9;

    cerr << "\nTime taken by program is : " << fixed
         << time_taken << setprecision(9);
    cerr << " sec" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  vll a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  vll dp_a(n + 1, 0), dp_b(n + 1, 0), dp_c(n + 1, 0);
  for(ll i = 0;i < n;i++)
  {
    dp_a[i + 1] = max(dp_b[i], dp_c[i]) + a[i];
    dp_b[i + 1] = max(dp_a[i], dp_c[i]) + b[i];
    dp_c[i + 1] = max(dp_a[i], dp_b[i]) + c[i];
  }
  fin(max(dp_a[n], max(dp_b[n], dp_c[n])));
  return;
}

//前処理
int main()
{
  int ti = clock();
  srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC); // 実行時間計測
  return 0;
}

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

int p[200100];

void sieve() {
    memset(p, 1, sizeof(p));
    p[0] = p[1] = 0;
    for (int i = 2; i * i <= 200000; i++) {
        if (p[i]) {
            for (int j = i * i; j <= 200000; j += i) p[j] = 0;
        }
    }
}

int main() {
    int x;
    scanf("%d", &x);
    sieve();
    while (1) {
        if (!p[x]) x++;
        else {
            printf("%d\n", x);
            return 0;
        }
    }
}


Measured memory_bytes: 896
from scipy.sparse.csgraph import dijkstra
import numpy as np
n=int(input())
a=[0]+[int(j)for j in input().split()]
graph=np.zeros((n+2,n+2),dtype=np.int64)
start,goal=0,n+1
for i,j in enumerate(a[1:],1):
    if j>=0:
        graph[start,i]=j
    else:
        graph[i,goal]=-j
for i in range(1,n+1):
    for j in range(2*i,n+1,i):
        graph[j,i]=10**18
def max_flow(graph):
    flow=0
    while True:
        dist,pred=dijkstra(graph,indices=start,return_predecessors=True,unweighted=True)
        if dist[goal]==np.inf:
            return flow
        path=[]
        v=goal
        while True:
            path.append((pred[v],v))
            v=pred[v]
            if v==start:
                break
        add_flow=min(graph[x][y] for x,y in path)
        for x,y in path:
            graph[x][y]-=add_flow
            graph[y][x]+=add_flow
        flow+=add_flow
print(sum(i for i in a if i>0)-max_flow(graph))

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

int main(){
  int N, K; cin >> N >> K;
  vector<int> H(N + 1);
  for(int i = 1; i <= N; i++){
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  long long ans = 0;
  for(int i = 1; i <= N - K; i++){
    ans += H[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		// Scanner sc = new Scanner(new File("in4.txt"));
		int N = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		int max = 0;
		for (int i = 0; i < N; i++) {
			int n = sc.nextInt();
			list.add(n);			
			if (n > max)
				max = n;
		}

		List<Integer> primes = new ArrayList<Integer>();
		primes.add(2);
		for (int i = 3; i * i <= max; i++) {
			boolean is_prime = true;
			for (int p : primes)
				if (i % p == 0) {
					is_prime = false;
					break;
				}
			if (is_prime)
				primes.add(i);
		}
		
		int ans = 0;
		for (int n : list) {
			boolean is_prime = true;
//			for (int i = 2; i * i < n; i++)
			for (int i : primes)
				if (n != i && n % i == 0)
					is_prime = false;
			if (is_prime) {
				ans++;
			}
		}
		System.out.println(ans);		
		
	}
}

Measured memory_bytes: 38960
#include<bits/stdc++.h>
using namespace std;
bool isprime(int n){
	int m = sqrt(n);
	for(int i = 2; i <= m; i++){
		if(n % i == 0) return 0;
	}
	return 1;
}
int main(){
	int n;
	cin >> n;
	int k = 11;
	while(n){
		if(isprime(k) && k % 10 == 1){
			cout << k << ' ';
			n--;
		}
		k += 10;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N+1);
    rep(i, 1, N+1) cin >> A[i];
    vector<ll> acc(N+1, 0);
    rep(i, 1, N+1) acc[i] = acc[i-1] + A[i];  
    rep(i, 1, N+1) acc[i] = (acc[i] - i) % K;
    map<ll,ll> mp;
    ll ans = 0;
    rep(i, 0, N+1){
        ans += mp[acc[i]];
        mp[acc[i]]++;
        if(i - K + 1 >= 0) mp[acc[i-K+1]]--;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
inline int ri() {
	int r; cin >> r; return r;
}


int main()
{
	ll x;
	cin >> x;
	ll cur = 100;
	int cnt = 0;
	while(cur < x) {
		cur = cur + (cur / 100);
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999;
#define atcoder 1000000007;

using namespace std;

int main(){

	string s;
	int cnt = 0, ans = 0, str,a=0;

	cin >> s;
	str = s.length();

	REP(i, str) {
		if (s[i] == 'A') {
			cnt = i;
			break;
		}
	}

	FOR(i,cnt, str) {
		if (s[i] == 'Z') {
			ans = i;
		}
	}
	
	cout << ans - cnt +1 << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <map>
#include <string>
using namespace std;
int main(){
  int n;
  set<string> st;
  map<string,int> mp;
  string str;
  cin >> n;
  for(int i = 0;i<n;i++){
    cin >> str;
    st.insert(str);
    if(mp.find(str)!=mp.end()) mp[str]++;
    else mp[str]=1;
  }
  int m;
  cin >> m;
  for(int i = 0;i<m;i++){
    cin >> str;
    st.insert(str);
    if(mp.find(str)!=mp.end()) mp[str]--;
    else mp[str]=-1;
  }
  int ans = 0;
  for(auto itr = st.begin();itr!=st.end();itr++){
    ans = max(ans,mp[*itr]);
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10**9)

INF = 110110110
_INFL = -INF * INF

N = int(input())
A = list(map(int, input().split()))

ans = [0] * N

for a in A:
    ans[a-1] += 1

for a in ans:
    print(a)


Measured memory_bytes: 32228
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

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

  const int N_MAX = 510;
  const int M_MAX = 200010;

  int N,M,Q;
  cin>>N>>M>>Q;
  vector<int> L(M_MAX,0),R(M_MAX,0);
  
  int X[N_MAX][N_MAX],C[N_MAX][N_MAX];
  fill(X[0],X[N_MAX-1],0);
  fill(C[0],C[N_MAX-1],0);

  FOR(i,1,M+1) {
    cin>>L[i]>>R[i];
    ++X[L[i]][R[i]];
  }
  FOR(i,1,N+1)
    FOR(j,1,N+1) C[i][j] = C[i][j-1] + X[i][j];

  REP(i,Q) {
    int p,q;
    cin>>p>>q;
    int sum = 0;
    FOR(j,p,q+1) sum += C[j][q] - C[j][p-1];
    cout << sum << endl;
  }

  return 0;
}

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

using i64 = long long int;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }

    i64 ans = 0, left = 0, right = 0, prev_right = 0, acc_xor = v[0], acc_sum = v[0];
    while(left < n){
        if(right < n && acc_xor == acc_sum){
            right++;
            acc_xor ^= v[right];
            acc_sum += v[right];
        }else{
            ans += (right - left + 1) * (right - left) / 2;
            if(left < prev_right)ans -= (prev_right - left + 1) * (prev_right - left) / 2;
            acc_xor ^= v[left];
            acc_sum -= v[left];
            left++;
            prev_right = right;
        }
    }

    cout << ans << endl;

    return 0;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<std::pair<std::string, int64_t>> st(n);
  std::cin >> st;
  std::string x;
  std::cin >> x;

  int64_t ans = 0;
  bool flag = false;

  for (int64_t i = 0; i < n; i++) {
    if (flag) {
      ans += st[i].second;
    } else {
      if (st[i].first == x) {
        flag = true;
      }
    }
  }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
    int n;
    scanf("%d",&n);
    int w[100];
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
    int sum = 0;
    for(i=0;i<n;i++){
        sum += w[i];
    } 
    int t ;
    int s1=0,s2=0;
    int ssa=88888;
    for(t=0;t<n-1;t++){
        s1 = 0, s2 = 0;
        for(i=0;i<=t;i++){
            s1 += w[i];
        }
        s2 = sum - s1;
        //printf("s1 = %d, s2 = %d\n",s1,s2);
        if(ssa > abs(s1-s2)){
        ssa = abs(s1-s2);
        }
    }

    //printf("%d\n",ssa);
    printf("%d\n",ssa);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = {}
for _ in range(n):
    c = input()
    if c not in a:
        a[c] = 0
    a[c] += 1

v0 = -1
b = []
for k, v in sorted(a.items(), key=lambda x: -x[1]):
    if v0 < v:
        v0 = v
    if v0 == v:
        b.append(k)

for i in sorted(b):
    print(i)

Measured memory_bytes: 121304
/*||>>>> Praveen Ojha <<<<>>>> 07 July 2019 <<<<>>>> 17:46:25 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=2020;
bool cnti[N];
int32_t main(){__
	int l,r;
	cin>>l>>r;
	int mini=((l%2019)*(r%2019))%2019;
	for(int i=l;i<=r;i++){
		if(!cnti[i%2019])
		cnti[i%2019]=true;
		else
		break;
	}
	vi tt;
	for(int i=0;i<2019;i++){
		if(cnti[i])
			tt.push_back(i);
	}
	for(int i=0;i<sz(tt);i++){
		for(int j=i+1;j<sz(tt);j++){
			mini=min(mini,(tt[i]*tt[j])%2019);
		}
	}
	cout<<mini<<"\n";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll INF = ll(1e18)+1;

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while (l+1 < r) {
    ll x = (l+r)/2;
    bool ok = [&]{
      ll tot = 0;
      rep(i,n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) r = c; else l = c;
          }
          tot += n-r;
        } else {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) l = c; else r = c;
          }
          tot += r;
        }
        if (a[i]*a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok) l = x; else r = x;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef long double LD;
//#define int ll
#define double LD
#define pb push_back
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define loop(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define mem(a, b) memset(a, b, sizeof a)
#define append push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define print(x) cout << (x) << endl
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const double PI=acos(-1);
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;

mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.
 
void solve();
 
signed main(){
    FAST_IO;
    PRECISION(10);
 
    int t = 1;
    //cin>> t;
    FOR(testcase,1,t+1){
        // printf("Case #%lld: ",testcase); 
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}   
 
void solve(){
    char c;
    cin>> c;
    c++;
    cout<< c << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-2, -1};
int dx[4] = {-1, -2};

const int MAX = 1000050;
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 
const int MAX_N = 10050;
int n, m;
int cost[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int a[10];
string dp[MAX_N];

void chmax(string& a, string b) {
	if(a.size() < b.size()) {
		a = b;
		return;
	} else if (a.size() > b.size()) {
		return;
	}

	rep(i,0,sz(a)) {
		if(a[i] < b[i]) {
			a = b;
			return;
		} else if (a[i] > b[i]) {
			return;
		}
	}
}

int main(void) {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> m;
	rep(i,0,m) {
		cin >> a[i];
	}

	rep(i,0,MAX_N) {
		dp[i] = "";	
	}
	dp[0] = "0";

	for(int i = 0; i <= n; ++i) {
		if(dp[i] == "") continue;
		for(int j = 0; j < m; ++j) {
			int idx = i+cost[a[j]];
			if(idx > n) continue;
			string num = dp[i] + string(1,(char)(a[j]+'0'));
			chmax(dp[idx], num);
		}
	}
	//rep(i,0,n+1) {
	//	cout << i << " : " << dp[i] << endl;
	//}
	cout << dp[n].substr(1) << endl;
	return 0;
}


Measured memory_bytes: 31232
def main():
    from collections import Counter as ct
    n,m=map(int,input().split())
    a=[list(map(int,input().split())) for _ in [0]*n]
    ret=n
    for _ in range(m):
        ans=[]
        for i in range(n):
            ans.append(a[i][0])
        j,k=ct(ans).most_common()[0]
        ret=min(k,ret)
        for i in range(n):
            a[i].remove(j)
    print(ret)
main()

Measured memory_bytes: 4648
from collections import defaultdict
from bisect import bisect_left


def main():
	s = input()
	n = len(s)
	s = s + s
	t = input()
	if set(t) - set(s):
		print(-1)
		exit()
	d = defaultdict(list)
	for i in range(2 * n):
		d[s[i]] += [i]
	cur = ncnt = 0

	for c in t:
		x = d[c][bisect_left(d[c], cur)]
		if x < n:
			cur = x + 1
		else:
			cur = x - n + 1
			ncnt += 1
	print(ncnt*n + cur)


if __name__ == "__main__":
	main()


Measured memory_bytes: 12200
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    string S; cin >> S;
    int s1 = stoi(S.substr(0,2));
    int s2 = stoi(S.substr(2, 2));

    int cnt1 = 0, cnt2 = 0;
    if (s1 <= 0 || s1 > 12) cnt1++;
    if (s2 <= 0 || s2 > 12) cnt2++;

    if (cnt1 == 1 && cnt2 == 1) {
        cout << "NA\n";
    } else if (cnt1 == 1) {
        cout << "YYMM\n";
    } else if (cnt2 == 1) {
        cout << "MMYY\n";
    } else {
        cout << "AMBIGUOUS\n";
    }
}

Measured memory_bytes: 256
x=int(input())
if 400<= x <=599:
    print(8)
elif 600<=x<=799:
    print(7)
elif 800<=x<=999:
    print(6)
elif 1000<=x<=1199:
    print(5)
elif 1200<=x<=1399:
    print(4)
elif 1400<=x<=1599:
    print(3)
elif 1600<=x<=1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9180
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last) {
      out << ",";
    }
  }
  out << "]";
  return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i] << endl;
  }
  return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << "{" << p.first << "," << p.second << "}";
  return out;
}

static const int MAX_N = 100000, MAX_W = 10000;
int n, k, w[MAX_N];

//積載量pのトラックk台に積める荷物の最大数
int query(int p) {
  int went = 0, put = 0, i = 0;
  while (went < k && i < n) {
    while (put + w[i] <= p && i < n) {
      put += w[i];
      i++;
    }
    if (put == 0) {
      return i;
    }
    put = 0;
    went++;
  }
  return i;
}

void solve() {
  scanf("%d %d", &n, &k);
  rep(i,0,n)
  {
    scanf("%d", &w[i]);
  }
  //v = query(p)
  //積載量pの元で積める荷物の数vが初めてnと等しくなるときのpを探す
  //(L, R]
  //vの最大値はMAX_N * MAX_W = 10^5 * 10^4 = 10^9
  int L = 0, R = MAX_N * MAX_W + MAX_W, C = L + (R - L) / 2;
  while (R - L > 1) {
    C = L + (R - L) / 2;
    if (query(C) < n) {  //右側に答え
      L = C;
    } else if (query(C) == n) {  //左側に答え
      R = C;
    }
  }
  printf("%d\n", R);  //閉区間側に答え
}
int main() {
  solve();
  return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

ll n, k;

int main()
{
    cin >> n >> k;
    if(!n){
        cout << 0 << endl;
        return 0;
    }
    if(n < k) cout << min(n, k-n) << endl;
    else cout << min(n%k, k-(n%k)) << endl;

    return 0;
}


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

void push(int);
int pop(void);

int si[100],top=0;

int main(){
  int x,y;
  char s[100];

  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){

      push(pop()+pop());

    }

    else if ( s[0] == '-' ){
      x=pop();
      y=pop();

      push(y-x);
      
    }
    
    else if ( s[0] == '*' ){

      push(pop()*pop());
      
    }

    else {
      x=atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int x){
  top++;
  si[top] = x;
}

int pop(void){
  top--;
  return si[top+1];
}



Measured memory_bytes: 2052
#include<iostream>
#include<cstdio>
#include<cstring>

typedef long long ll;

const int N=3033;

ll qpow(ll a,ll b,ll MOD){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}

int n,MOD;

int f[N][N],C[N][N];

int ans;

int main()
{
	scanf("%d%d",&n,&MOD);

	f[0][0]=1;
	for(int i=1;i<N;i++)
		for(int j=0;j<N;j++)
			f[i][j]=((ll)f[i-1][j]*j+f[i-1][j-1]+f[i-1][j])%MOD;
	for(int i=0;i<N;i++)C[i][0]=1;
	for(int i=1;i<N;i++)
		for(int j=1;j<N;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;

	int tmp=qpow(2,n,MOD-1);
	ans=qpow(2,tmp,MOD);

	for(int cnt=1;cnt<=n;cnt++)
	{
		int sum=0;

		int u=qpow(2,n-cnt,MOD-1);
		int v=qpow(2,n-cnt,MOD);

		for(int z=0;z<=cnt;z++)
		{
			int res=f[cnt][z];

			res=(ll)res*qpow(v,z,MOD)%MOD*qpow(2,u,MOD)%MOD;

//			for(int x=0;x<=cnt;x++)
//			{
//				int fk=str[x][z]*qpow(v,z,MOD)%MOD*qpow(2,u,MOD)%MOD;
//				fk=(ll)fk*C[cnt][x]%MOD;
//				res=(res+fk)%MOD;
//			}

			sum=(sum+res)%MOD;
		}

//		printf("cnt = %d , sum = %d\n",cnt,sum);

		sum=(ll)sum*C[n][cnt]%MOD;

		if(cnt&1)ans=(ans-sum)%MOD;
		else ans=(ans+sum)%MOD;
	}

	ans=(ans+MOD)%MOD;
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 72192
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;



int main() {
    string s, t;
    cin>>s;
    cin>>t;
    if(s.size()==t.size()-1&&s.size()<=10) {
        t.pop_back();
        if(s==t) printf("Yes\n");
        else printf("No\n");
    }
    else printf("No\n");
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int K, ans;
int main() {
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	scanf("%d", &K);
	printf("%d\n", a[K - 1]);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  string ans = "No";
  int price;
  for(int i = 0; i * 4 <= N; i++){
    if((N - i * 4) % 7 == 0){
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const LL INF = 1e14;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  VI a(n);
  INPUT(a);
  SORT(a);
  int ans = 0;
  REP(i, n-1)
  {
    x -= a[i];
    if (x >= 0) ans++;
    else break;
  }
  if (x == a.back()) ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)

signed main(){
  int h,w;
  cin>>h>>w;
  char s,t;
  cin>>s>>t;
  char a[52][52];
  lp(i,52) lp(j,52) a[i][j]='.';
  int sx,sy;
  lp(i,h){
    lp(j,w){
      cin>>a[j+1][i+1];
      if(a[j+1][i+1]==s){
	sy=i+1;sx=j+1;
      }
    }
  }
  queue<pair<int,pair<int,int> > > q;
  int dp[55][55];
  lp(i,55) lp(j,55) dp[i][j]=INF;
  q.push({0,{sx,sy}});
  int ans=INF;
  while(!q.empty()){
    int cnt=q.front().first;
    int x=q.front().second.first;
    int y=q.front().second.second;
    q.pop();
    if(dp[x][y]<=cnt) continue;
    dp[x][y]=cnt;
    //cout<<x<<y<<endl;
    if(a[x][y]=='.') continue;
    if('A'<=a[x][y]&&a[x][y]<='Z'){
      //cout<<a[x][y]<<" "<<cnt<<endl;
      if(a[x][y]==t){
	ans=min(ans,cnt);
	continue;
      }
      if(a[x-2][y]=='-') q.push({cnt+1,{x-2,y}});
      if(a[x+2][y]=='-') q.push({cnt+1,{x+2,y}});
      if(a[x][y-2]=='|') q.push({cnt+1,{x,y-2}});
      if(a[x][y+2]=='|') q.push({cnt+1,{x,y+2}});
    }
    else if(a[x][y]=='o'){
      for(int i=-1;i<2;i++){
	for(int j=-1;j<2;j++){
	  if('A'<=a[x+i][y+j]&&a[x+i][y+j]<='Z'){
	    q.push({cnt,{x+i,y+j}});
	  }
	}
      }
    }
    else{
      if(a[x][y]=='-'){
	q.push({cnt,{x+1,y}});
	q.push({cnt,{x-1,y}});
      }
      else{
	q.push({cnt,{x,y+1}});
	q.push({cnt,{x,y-1}});
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

/*
7 7 A D
ooo.ooo
oAo-oBo
ooo.ooo
.|...|.
ooo.ooo
oCo-oDo
ooo.ooo

 */



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

int main(){
  int n, y;
  cin >> n >> y;
  for (int i = 0; i < n+1; i++)
    for (int j = 0; j < n+1-i; j++)
      if (10000*i + 5000*j + 1000*(n-i-j) == y && n-i-j >= 0)
      {
        cout << i << " " << j << " " << n-i-j << endl;
        return 0;
      }

  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
struct node{
	int x,note=0x3f;
}a[100005]; 
int main(){
	int n,ans=1;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].x;
	}
	a[1].note=2;
	for(int i=2;i<=n;i++){
		if(a[i-1].note==0){
			if(a[i].x>a[i-1].x) a[i].note=2,ans++;
			else a[i].note=0;
		}else if(a[i-1].note==1){
			if(a[i].x>=a[i-1].x) a[i].note=1;
			else a[i].note=2,ans++;
		}else if(a[i-1].note==2){
			if(a[i].x<a[i-1].x) a[i].note=0;
			else if(a[i].x==a[i-1].x) a[i].note=2;
			else a[i].note=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	printf("%d\n",max(max(a+b,a-b),a*b));
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (k, n) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }

    var diffMax = 0

    for (i in 1..n-1) {
        val diff = aa[i] - aa[i-1]
        if (diff > diffMax) {
            diffMax = diff
        }
    }

    val diff = k - aa.last() + aa.first()
    if (diff > diffMax) {
        diffMax = diff
    }

    println(k-diffMax)
}

Measured memory_bytes: 82864
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::min;
fn main() {
    input! { n, x, a: [usize; n] };
    let mut ans = a.iter().sum::<usize>();
    let mut ma = a.clone();
    for i in 1..n {
        for j in 0..n {
            ma[j] = min(ma[j], a[(n + j - i) % n]);
        }
        ans = min(ans, ma.iter().sum::<usize>() + x * i);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
int n,t[2],a[5][100010],to[100010];
char buffer[10000010],*hed,*tal;
inline char Getchar(){
	return *hed++;
}
inline int rd(){
	register int x=0;
	char c;
	do c=Getchar();
	while(!isdigit(c));
	do{
		x=(x<<1)+(x<<3)+(c^48);
		c=Getchar();
	}while(isdigit(c));
	return x;
}
inline int abs(int x){
	return x>=0?x:-x;
}
int main(){
	int len=fread(buffer,1,10000000,stdin);
	hed=buffer,tal=buffer+len;
	n=rd();
	for(int i=1;i<=3;i++)
		for(int j=1;j<=n;j++)
			a[i][j]=rd();
	for(register int i=1;i<=n;i++){
		to[i]=a[2][i]/3+1;
		if(!((a[1][i]-a[2][i]==-1&&a[2][i]-a[3][i]==-1&&a[1][i]%3==1)||(a[1][i]-a[2][i]==1&&a[2][i]-a[3][i]==1&&!(a[1][i]%3)))||(abs(i-to[i])&1)){
			puts("No");
			return 0;
		}
		t[i&1]^=(a[1][i]>a[2][i]);
	}
	for(register int i=1;i<=n;i++){
		while(to[i]!=i){
			t[i&1^1]^=1;
			swap(to[i],to[to[i]]);
		}
	}
	puts(t[0]||t[1]?"No":"Yes");
	return 0;
}

Measured memory_bytes: 5376