akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int n = Integer.parseInt(strArr[0]);
            int m = Integer.parseInt(strArr[1]);
            boolean from[] = new boolean[n];
            boolean to[] = new boolean[n];
            for (int i = 0; i < m; i++) {
                strArr = br.readLine().split(" ");
                int tmp1 = Integer.parseInt(strArr[0]);
                int tmp2 = Integer.parseInt(strArr[1]);
                if (tmp1 == 1) {
                    from[tmp2 - 1] = true;
                }
                if (tmp2 == n) {
                    to[tmp1 - 1] = true;
                }
            }
            boolean flag = false;
            for (int i = 0; i < n; i++) {
                if (from[i] && to[i]) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                System.out.println("POSSIBLE");
            } else {
                System.out.println("IMPOSSIBLE");
            }
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}


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

#include <string>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  char s[255];
  int count = 0;
  for (int i = A; i <= B; i++) {
    sprintf(s, "%d", i);
    if (s[0] == s[4] && s[1] == s[3]) count++;
  }
  cout << count << endl;

}  // namespace std;


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int r;
  cin >> r;
  if(r<1200)cout << "ABC" << endl;
  else if(r<2800)cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define Rint register int
	#define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
	#define GO(x,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
	#define PII pair<int,int>
	#define MP make_pair
	typedef long long LL;
	typedef double DB;
	inline int read(){
		char c=getchar();int ans=0,f=1;
		while(c>'9'||c<'0'){ f^=(c=='-'); c=getchar(); }
		for(;c<='9'&&c>='0';c=getchar()) ans=ans*10+(c^48); return f?ans:-ans;
	}
	const int mod = 1e9 + 7;
	inline void inc(int &x,const int &y){ x+=y; if(x>=mod) x-=mod; }
	inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res; }
	#define FILE(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
}
using namespace my_std;

int n,a,b,ans;

int main(){
	a=read(),b=read(),n=read();
    printf("%d",(n/a)*b);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#define INF 0x3f3f3f3f
#define gcd(a,b) __gcd(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;

inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}

int main()
{
    ll n,i,j;
    ll a[100005]={0};
    ll sum=0;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);

    sum=sum+a[1]/2;
    if(a[1]%2==0)
        a[1]=0;
    else
        a[1]=1;

    for(i=2;i<=n;i++)
    {
        if(a[i]==0)
            continue;

        while(a[i]>=1 && a[i-1]>=1)
        {
            a[i]--;
            a[i-1]--;
            sum++;
        }
        sum=sum+a[i]/2;
        if(a[i]%2==0)
            a[i]=0;
        else
            a[i]=1;
    }

    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1024
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    answer = 0

    for i in range(1, N + 1):
        num = N // i
        answer += ((num * i) + i) * num // 2
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9208
x1,y1,x2,y2 = map(int,input().split())

"""
x3 = x2 - y2 + y1
y3 = y2 - x1 + x2
x4 = x3 - x2 + x1 = x2 - y2 + y1 - x2 + x1
y4 = y3 - y2 + y1 = y2 - x1 + x2 - y2 + y1
"""

x3 = x2 - y2 + y1
y3 = y2 - x1 + x2
x4 = x2 - y2 + y1 - x2 + x1
y4 = y2 - x1 + x2 - y2 + y1

print(x3,y3,x4,y4)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
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

int n;
int x[100050];
int y[100050];

void myinsert(set<pii>& s, priority_queue<pii>& q, int v, int i) {
	auto it = s.upper_bound(mp(v,i));
	if(it != s.end()) {
		int d = abs(it->F - v);
		q.push(mp(-d, it->S));
	}
	it--;
	if(it != s.end()) {
		int d = abs(it->F - v);
		q.push(mp(-d, it->S));
	}
}

ll prim() {
	set<pii> sx;
	set<pii> sy;
	set<int> s;
	rep(i,0,n) {
		sx.insert(mp(x[i],i));
		sy.insert(mp(y[i],i));
	}

	s.insert(0);
	sx.erase(mp(x[0],0));
	sy.erase(mp(y[0],0));
	priority_queue<pair<int, int> > Q;
	myinsert(sx, Q, x[0], 0);
	myinsert(sy, Q, y[0], 0);
	ll ret = 0;
	while(s.size() < n && !Q.empty()) {
		int d = -Q.top().F;
		int i = Q.top().S;
		Q.pop();
		if(s.find(i) != s.end()) {
			continue;
		} else {
			s.insert(i);
			ret += (ll)d;
			if(s.size() == n) {
				break;
			}
			sx.erase(mp(x[i],i));
			sy.erase(mp(y[i],i));
			myinsert(sx,Q,x[i],i);
			myinsert(sy,Q,y[i],i);
		}
	}
	return ret;
}


int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	rep(i,0,n) {
		cin >> x[i] >> y[i];
	}
	ll ret = prim();
	cout << ret << '\n';
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    set<int> st;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (st.count(a)) st.erase(a);
        else st.insert(a);
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 4864
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.out

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>

using namespace std;

#define INF (1<<29)
#define PRINT(A) {for (auto it=A.begin(); it != A.end(); ++it) {cout << *it << ' ';} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define BIT_LENGTH(N) floor(log2(N)) + 1
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define RREP(I, N) for (int I = N-1; I >= 0 ; --I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RREPP(I, A, B) for (int I = A; I > (B); --I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef map<int, int> MII;
typedef set<int> SI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

VI bitSums;

void add(int index, int value) {
    int i = index + 1;
    while (i < bitSums.size()) {
        bitSums[i] += value;
        i += (i & -i);
    }
}

int sum(int end) {
    int res = 0;
    int i = end+1;
    while (i != 0) {
        res += bitSums[i];
        i -= (i & -i);
    }
    return res;    
}

int range_sum(int start, int end) {        
    return sum(end) - sum(start-1);
}


int main() {
    int N, Q;
    cin >> N >> Q;
    VI C;
    VVI queries;
    REP(i, N) {
        int n;
        cin >> n;
        C.push_back(n);
    }
    REP(i, Q) {
        int l, r;
        cin >> l >> r;
        queries.push_back({i, l, r});
    }

    VI D(N, INF);
    unordered_map<int, int> last_index;
    REP(i, N) {
        if (last_index.find(C[i]) != last_index.end()) { //found
            D[last_index[C[i]]] = i;
        }
        last_index[C[i]] = i;
    }

    sort(queries.begin(), queries.end(), [](VI n1, VI n2) { return n1[2] < n2[2]; });
    bitSums = vector<int>(N+1, 0);
    unordered_map<int, int> goods;
    int right_most = 0;
    
    VI ans(Q, 0);
    for (auto query: queries) {
        int index, l, r;
        index = query[0];
        l = query[1] - 1;
        r = query[2] - 1;
        // cout << "R:" << r << endl;
        REPP(i, right_most, r+1) {
            // cout << "I:" << i << endl;
            if (D[i] > r) { // D[i] is good
                // cout << "GOOD:" << D[i] << endl;
                if (goods.find(C[i]) != goods.end()) { // already in good sets
                    add(goods[C[i]], -1);
                }
                goods[C[i]] = i;
                add(i, 1);
            }
        }
        // PRINT(bitSums);
        right_most = r + 1;
        ans[index] = range_sum(l, r);
        // break;
    }

    for (auto a: ans) {
        cout << a << endl;
    }

    return 0;
}

Measured memory_bytes: 78384
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define N 200010
#define gc getchar()
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
int a[N],b[N],gl[N];
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
inline int check(int x,int k)
{
	for(int i=1;i<=k;i++) b[i]=(a[i]>=x);
//	debug(x)sp,debug(k)ln;for(int i=1;i<=k;i++) cerr<<b[i];cerr ln;
	for(int i=2;i<k;i++)
		gl[i]=(b[i]!=b[i-1]&&b[i]!=b[i+1]);
	for(int i=0,n=k/2+1;i<n;i++)
	{
		if(!gl[n-i]) return b[n-i];
		if(!gl[n+i]) return b[n+i];
	}
	return 0;
}
int main()
{
	int n=inn(),k=2*n-1;
	for(int i=1;i<=k;i++) a[i]=inn();
	int L=1,R=k,mid=(L+R)>>1;
	while(L<=R)
	{
		if(check(mid,k)) L=mid+1;//is one
		else R=mid-1;mid=(L+R)>>1;
	}
	return !printf("%d\n",R);
}

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if ((A + B) - (C + D) == 0)
		cout << "Balanced" << endl;
	else if ((A + B) - (C + D) <= 0)
		cout << "Right" << endl;
	else if ((A + B) - (C + D) >= 0)
		cout << "Left" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	int ret=0;
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		ret+=min(p,b-p);
	}ret*=2;
	printf("%d\n",ret);
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Brick Break
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int k = 0, nxta = 1;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);

    if (ai == nxta) k++, nxta++;
  }

  printf("%d\n", (k == 0) ? -1 : n - k);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i;
	int a[20000];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	int sum=0;
	for(i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			for(int f=j+1;f<n;f++)
			{
				if(a[i]<a[j]+a[f]&&a[j]<a[i]+a[f]&&a[f]<a[i]+a[j])
				sum++;
			}
		}
	}
	printf("%d",sum);
} 

Measured memory_bytes: 256
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
using 		namespace __gnu_pbds; 
using 		namespace std;
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopitr(vec) for(auto it=vec.begin();it!=vec.end();it++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	v(pi) vector<ll>pi
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	vp(pi) vector<pair<ll,ll>>pi
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	mi(lol) map<ll,ll>lol
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())


ll gcd (ll a, ll b) { return b ? gcd (b, a % b) : a; }
ll lcm (ll a, ll b) { return a / gcd(a, b) * b; }

//code start from here 

int main() {
	fast;
	read(a)
	readarr(arr,a-1);
	map<ll,ll>mp;
	loop(j,0,a-1){
		mp[arr[j]]++;
	}
	loop(j,1,a+1){
		cout<<mp[j]<<" ";
	}
	return 0;
}

//ends here 

Measured memory_bytes: 17724
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const size_t SIZE = 1e5 + 10;
ll dp[SIZE][3];

int main() {
    ll N, K;
    cin >> N >> K;
    ll r, s, p;
    cin >> r >> s >> p;
    string T;
    cin >> T;

    auto point = [&](char a, char b) {
        if(a == 'r' && b == 's') return r;
        if(a == 's' && b == 'p') return s;
        if(a == 'p' && b == 'r') return p;
        return (ll)0;
    };

    char cl[] = { 'r', 's', 'p', };

    ll ans = 0;
    for(ll k = 0; k < K; k++) {
        ll idx = k;
        for(; idx < N; idx += K) {
            if(idx < K) {
                for(ll j = 0; j < 3; j++) dp[idx][j] = point(cl[j], T[idx]);
            } else {
                for(ll j = 0; j < 3; j++) {
                    ll j1 = (j + 1) % 3;
                    ll j2 = (j + 2) % 3;
                    chmax(dp[idx][j], 
                          dp[idx - K][j1] + point(cl[j], T[idx]),
                          dp[idx - K][j2] + point(cl[j], T[idx]));
                }
            }
        }
        idx -= K;
        ans += var_max(dp[idx][0], dp[idx][1], dp[idx][2]);
    }

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


Measured memory_bytes: 2768
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int a[m], cntodd = 0;
	for(int i = 0; i < m; i++) {
		cin >> a[i];
		if(a[i] & 1) cntodd++;
	}
	if(m == 1) {
		cout << a[0] << endl;
		if(a[0] == 1 or a[0] == 2) {
			cout << 1 << endl << a[0] << endl;
		}
		else {
			cout << 2 << endl;
			cout << 1 << ' ' << a[0] - 1 << endl;
		}
		return 0;
	}
	if(cntodd > 2) {
		cout << "Impossible" << endl;
		return 0;
	}
	for(int i = 0; i < m; i++) {
		if(a[i] & 1) {
			if(!(a[0] & 1)) swap(a[i], a[0]);
			else swap(a[i], a[m - 1]);
		}
	}
	for(int i = 0; i < m; i++) cout << a[i] << ' ';
	cout << endl;
	if(a[0] == 1) cout << m - 1 << endl;
	else cout << m << endl;
	if(a[0] != 1) cout << a[0] - 1 << ' ';
	for(int i = 1; i < m - 1; i++) cout << a[i] << ' ';
	cout << a[m - 1] + 1 << endl;
	return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
 
using namespace std;
 
void Main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
 
    int total = abs(0 - A[0]);
    for (int i = 1; i < N; ++i) {
        total += abs(A[i - 1] - A[i]);
    }
    total += abs(A[N - 1] - 0);
 
    for (int i = 0; i < N; ++i) {
        if (i == 0) {
            cout << total - abs(A[i] - 0) - abs(A[i] - A[i + 1]) + abs(0 - A[i + 1]) << endl;
        }
        else if (i == N - 1) {
            cout << total - abs(A[i] - A[i - 1]) - abs(A[i] - 0) + abs(A[i - 1] - 0) << endl;
        }
        else {
            cout << total - abs(A[i] - A[i - 1]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]) << endl;
        }
    }
}
 
int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

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

int main() {
 char c;
 cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
	}else{ 
     cout << "consonant" <<endl;
  }
}

Measured memory_bytes: 3576
#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;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int n, k;
	cin >> n >> k;
	vector <int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(all(a));
	int res = 0;
	for (int i = 0; i < k; i++) res += a[i];
	cout << res;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	string S;
	cin>>S;
	
	int t=0,s=0;
	
	for(int i=0;i<S.size();i++){
		if(S[i]=='S'){
			s++;
		}
		else{
			if(s==0){
				t++;
			}
			else{
				s--;
			}
		}
	}
	
	cout<<s+t<<endl;
	
	return 0;
}


Measured memory_bytes: 640
N, X =  [int(e) for e in input().split()]
lst = [int(e) for e in input().split()]
cnt = 0
for i in range(N+1):
  if i == 0:
    num = 0
  else:
    num = num + lst[i-1]
  if num <= X:
    cnt += 1
print(cnt)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    List<Integer> targetList = new ArrayList<Integer>();

    createNumsList(targetList);
    bubbleSort(targetList);

    printResult(targetList);
  }

  private static void createNumsList(List<Integer> targetList) {
    Scanner sc = new Scanner(System.in);
    for (int i = 0; i < 3; i++) {
      targetList.add(sc.nextInt());
    }
  }

  private static void bubbleSort(List<Integer> targetList) {
    boolean swapped = false;
    for (int i = 0; i < 3; i++) {
      for (int j = i+1; j < 3; j++) {
        if (targetList.get(i) > targetList.get(j)) {
          swap(targetList, i, j);
        }
      }
    }
  }

  private static void swap(List<Integer> targetList, int x, int y) {
    int temp = targetList.get(x);
    targetList.set(x, targetList.get(y));
    targetList.set(y, temp);
  }

  private static void printResult(List<Integer> targetList) {
    int sizeOfList = targetList.size();
    for (int i = 0; i < sizeOfList; i++) {
      System.out.print(targetList.get(i));
      if (i != sizeOfList-1) {
        System.out.print(" ");
      }
    }
    System.out.println();
  }
}

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

void solve()
{
	int a,b,c;
	cin >> a >> b >> c;
	if (a+b+c == 17){
		cout<<"YES\n";
	}else{
		cout<<"NO\n";
	}
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	solve();
	return 0;
}

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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            string[] numst = Console.ReadLine().Split(' ');
            long[] nums = new long[numst.Length];
            for(long i = 0;i < nums.Length;i++) { nums[i] = long.Parse(numst[i]); }

            Dictionary<long, long> dic = new Dictionary<long, long>();
            for(long i = 0;i < nums.Length;i++)
            {
                if (dic.ContainsKey(nums[i])) dic[nums[i]]++;
                else dic.Add(nums[i], 1);
            }

            long sum = 0;
            Dictionary<long, long> scores = new Dictionary<long, long>();
            foreach (var  num in dic.Keys) { scores.Add(num, dic[num] * (dic[num] - 1) / 2); sum += scores[num]; }

            Dictionary<long, long> sums = new Dictionary<long, long>();
            foreach(var num in dic.Keys) { sums.Add(num, sum - scores[num]); }

            Dictionary<long, long> subscore = new Dictionary<long, long>();
            foreach(var num in dic.Keys) { subscore.Add(num,(dic[num] - 1 )* (dic[num] - 2)/2); }

            for(long i = 0;i < nums.Length;i++)
            {
                Console.WriteLine(sums[nums[i]] + subscore[nums[i]]);
            }
        }
    }
}


Measured memory_bytes: 53844
A,B,K = map(int,input().split())
answer = []
for i in range(A,A+K):
    if i > B: break
    answer.append(i)
for i in range(B,B-K,-1):
    if i < A: break
    answer.append(i)

answer = list(set(answer))
answer.sort()
for i in range(len(answer)):
    print(str(answer[i]))


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long int

int n,m,q;
int abcd[50][4];
int retu[10];

int next(){
  int tmp=n-1;
  while(retu[tmp]==m && tmp>=0){
    tmp--;}
  if(tmp<0) return 0;
  retu[tmp]++;
  for(int i=tmp+1;i<n;i++){
    retu[i]=retu[tmp];}
  return 1;
}

ll check(){
  ll sum=0;
  for(int i=0;i<q;i++){
    if(retu[abcd[i][1]-1]-retu[abcd[i][0]-1]==abcd[i][2]) sum+=abcd[i][3];
  }
  return sum;
}

int main(){
  scanf("%d%d%d",&n,&m,&q);
  for(int i=0;i<q;i++){
    scanf("%d%d%d%d",&abcd[i][0],&abcd[i][1],&abcd[i][2],&abcd[i][3]);}

  for(int i=0;i<n;i++){
    retu[i]=1;}
  ll max=check();
  while(next()){
    ll tmp=check();
    //printf("%lld\n",tmp);
    if(max<tmp) max=tmp;}
  printf("%lld\n",max);
  
  
  return 0;
}


Measured memory_bytes: 1728
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, K = (int(i) for i in input().split())
    H = [0] + [int(i) for i in input().split()]
    if N == K:
        return print(0)
    elif K == 0:
        ans = 0
        for i in range(N):
            ans += max(H[i+1] - H[i], 0)
        return print(ans)

    dp = [[10**10]*(N-K+1) for i in range(N+1)]
    dp[0][0] = 0
    for i, h in enumerate(H):
        if i == 0:
            continue
        dp[i][1] = h
    for i in range(1, N+1):
        for j in range(1, N-K+1):
            for x in range(1, i):
                dp[i][j] = min(dp[i][j], dp[x][j-1] + max(0, H[i] - H[x]))
    ans = 10**10
    for i in range(N+1):
        # print(dp[i])
        ans = min(ans, dp[i][N-K])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42460
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] first = new int[n];
        int[] second = new int[n];
        int[] tmp = new int[n];
        
        for(int i = 0; i < n; i++) {
            int val = sc.nextInt();
            if(i==0) first[i] = val;
            else first[i] = first[i-1] + val;
        }
        for(int i = 0; i < n; i++) tmp[i] = sc.nextInt();
        for(int i = n-1; i >= 0; i--) {
            int val = tmp[i];
            if(i==n-1) second[i] = val;
            else second[i] = second[i+1] + val;
        }
        int res = 0;
        for(int i = 0; i < n; i++) {
            int max = Math.max(res, first[i]+second[i]);
            res = max;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35948
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h, h+n);

    int mi = 1e9+1;
    for (int i = 0; i <= n - k; i++) {
        mi = min(mi, h[i+k-1] - h[i]);
    }

    cout << mi << endl;

    return 0;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        d.merge(a, b);
    }
    cout << (sz(d.groups())-1) << endl;
    return 0;
}


Measured memory_bytes: 9012
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
h,w = LI()
y,x = LI()
print(h*w-h*x-w*y+y*x)
#B
"""
n,m,c = LI()
b = LI()
a = LIR(n)
ans = 0
for i in range(n):
    d = c
    for k in range(m):
        d += b[k]*a[i][k]
    if d > 0:
        ans += 1
print(ans)
"""


#C

"""
n,m = LI()
v = LIR(n)
v.sort(key = lambda x:x[0])
ans = 0
k = 0
for a,b in v:
    if k+b >= m:
        ans += (m-k)*a
        print(ans)
        quit()
    ans += b*a
    k += b
"""
#D
#a,b = LI()

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 39892
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), dp(n + 1);
  ll ans = 0LL;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i] = 1000LL;
  }
  dp[n] = 1000LL;
  for (int i = 0; i < n; i++) {
    ll x = 0LL;
    for (int j = 0; j <= i; j++) {
      x = max(x, dp[j]);
    }
    for (int j = i + 1; j <= n; j++) {
      dp[j] = max(dp[j], x % a[i] + x / a[i] * a[j - 1]);
    }
  }
  for (int i = 0; i <= n; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}

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

int main(){

    int64_t N;
    cin >> N;
    vector<int64_t> A(N);

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    vector<int64_t> C(N,0);

    for (int i = 0; i < N; i++) {
        C.at(A.at(i)-1)++;
    }

    int64_t sumComb = 0;
    for (int i = 0; i < N; i++) {
        sumComb += C.at(i)*(C.at(i)-1)/2;
    }
    for(int i=0;i<N;i++){
        cout << sumComb -C.at(A.at(i)-1) + 1 << endl;
    }
}


Measured memory_bytes: 5760
A, B = map(int, input().split())
S = input()
jdg = True
for i, s in enumerate(S):
    if i != A and s not in '0123456789':
        jdg = False
        break
    if i == A and s != '-':
        jdg = False
print('Yes' if jdg else 'No')

Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,c=0;
    double td,tx,ty;
    cin >> n >> d;
    while(n--){
        cin >> tx >> ty;
        td = sqrt(tx*tx + ty*ty);
        if(td<=d){
            c++;
               
        }
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3688
D, G = map(int, input().split())
P, C = [], []

for _ in range(D):
    p, c = map(int, input().split())
    P.append(p); C.append(c)

ans = float('inf')

for bit in range(2**D):
    is_solve = [ 0 for _ in range(D) ]
    score, solve_num = 0, 0
    # i 番目の bit が立っている => 100(i+1)点をつけられた p_i 問を全完する
    for i in range(D):
        if (bit >> i) & 1:
            score += (100 * (i+1) * P[i] + C[i])
            solve_num += P[i]
            is_solve[i] += P[i]

    for i in range(D-1, -1, -1):
        if score >= G:
            break

        while is_solve[i] < P[i]:
            score += 100*(i+1)
            solve_num += 1
            is_solve[i] += 1
            if score >= G:
                break

    ans = min(ans, solve_num)

print(ans)



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

using namespace std;
typedef long long ll;

/*
par   : 親ノード
chs   : 自分を根とする木のノード数
d     : 自分を根とする木の深さ
root  : 自分の属する木のrootを返す
unite : 二つの木をマージする
isSame: 二つのノードが同一の木に属するか判定する
nodes : 自身が属する木のノード数
*/

struct UnionFind{
    vector<ll> par;
    vector<ll> chs;
    vector<ll> d;
    UnionFind(ll N){
        par.resize(N);
        chs.resize(N);
        d.resize(N);
        for(int i=0;i<N;i++) par[i] = i;
        for(int i=0;i<N;i++) chs[i] = 1;
        for(int i=0;i<N;i++) d[i] = 1;
    }
    ll root(ll n){
        if(par[n] == n) return n;
        return root(par[n]);
    }
    void unite(ll a, ll b){
        ll ra = root(a);
        ll rb = root(b);
        if(ra == rb) return;
        if(d[ra] >= d[rb]){
            par[rb] = ra;
            chs[ra] += chs[rb];
            d[ra] = max(d[ra], d[rb] + 1);
        }else{
            par[ra] = rb;
            chs[rb] += chs[ra];
        }
    }
    bool isSame(ll a,ll b){
        return root(a) == root(b);
    }
    ll nodes(ll n){
        return chs[root(n)];
    }
};

ll N,M;
ll A[100001];
ll B[100001];
deque<ll> v;

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >> b;
        A[i] = a-1, B[i] = b-1;
    }
    UnionFind uf = UnionFind(N);
    ll ans = N * (N-1) / 2;
    for(int i=M-1;i>=0;i--){
        v.push_front(ans);
        if(uf.root(A[i]) != uf.root(B[i])){
            ans -= uf.nodes(A[i]) * uf.nodes(B[i]);
        }
        uf.unite(A[i],B[i]);
    }
    for(int i=0;i<M;i++) cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 6016
import math

N = int(input())
a = list(map(int, input().split(' ')))
a.insert(0, -1)
#print(a)

mid = math.floor(N / 2)
#print(mid)

M = 0
b = [0 for i in range(N)]
b.insert(0, -1)
for i in reversed(range(1, N + 1)):
    if i > mid:
        if a[i] == 0:
            b[i] = 0
        else:
            M += 1
            b[i] = 1
    else:
        num = 0
        for j in range(1, N // i + 1):
            num += b[j * i]
        if num % 2 == 0:
            if a[i] == 0:
                b[i] = 0
            else:
                M += 1
                b[i] = 1
        else:
            if a[i] == 0:
                M += 1
                b[i] = 1
            else:
                b[i] = 0

print(M)
for i in range(1, N + 1):
    if b[i] == 1:
        print(i, end=' ')

Measured memory_bytes: 7276
#include<iostream>
#include<algorithm>
#include<map>
#define fs first
#define sc second
using namespace std;
typedef long long ll;

int n;
pair<ll,int> p[300010],b[300010];
ll a[300010];
bool use[300010];

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

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i].fs;
    p[i] = make_pair(a[i],i);
    b[i].sc = i;
    use[i] = false;
  }
  sort(p,p+n); sort(b,b+n);

  int ans = 0;
  ll sum = 0;
  
  int id = 0, num = 0;
  for(int i=0;i<n;i++){
    if(!use[b[i].sc]){
      sum += a[b[i].sc];
      use[b[i].sc] = true;
      num++;
    }

    while(id < n && p[id].fs<=b[i].fs){
      if(!use[p[id].sc]){
	sum += p[id].fs;
	use[p[id].sc] = true;
	num++;
      }
      id++;
    }

    while(id<n){
      if(!use[p[id].sc]){
	if(sum+p[id].fs > (num+1)*b[i].fs)break;
	sum += p[id].fs;
	use[p[id].sc] = true;
	num++;
      }
      id++;
    }
    if(sum <= num*b[i].fs)ans = max(ans,num);

    sum -= a[b[i].sc]; num--;
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 13220
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

int x[10],y[10];

double dis (int i, int j){
    int dx = abs(x[i]-x[j]);
    int dy = abs(y[i]-y[j]);

    return  sqrt(dx*dx + dy*dy);
 }
 //あとで取る
 
 
int main(){
    int N,K;
    cin >> N >> K;

  
    int sum = 0;
    rep(i,N){
        int h;
        cin >> h;
        if(h >=K)sum +=1;
    }cout << sum << endl;


 
}

Measured memory_bytes: 3636
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
 
  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
//   typedef string str;
//   typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      // ifstream cin("max_02.txt");

      
    ll n;
    cin>>n;
    set<ll> a;
    if (n==2){
      cout<<"1\n";
      return 0;
    }
    a.insert(2);
    a.insert(n-1);
    a.insert(n);
    for (ll i = 2; i*i<=n-1;i++){
      if ((n-1)%i==0) {a.insert(i); a.insert((n-1)/i);}

    }
    // cout<<a.size()<<endl;
 
    for (ll i = 3;i*i<=n;i++){
      ll nn = n;
      while (nn%i==0) nn/=i;
      nn%=i;
      if (nn==1){a.insert(i);}
    }
    cout<<a.size()<<"\n";

}
  

Measured memory_bytes: 3192
N, M = map(int, input().split())


def factorial(n):
    res = 1
    for i in range(1, n+1):
        res *= i
        res %= (10**9 + 7)
    return res


if abs(N-M) == 1:
    ans = (factorial(N) * factorial(M)) % (10**9 + 7)
elif N == M:
    ans = (factorial(N) * factorial(M) * 2) % (10**9 + 7)
else:
    ans = 0
print(ans)


Measured memory_bytes: 3060
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,x=nii()
a=lnii()
a.sort()

a_sum=0
for i in range(n):
  a_sum+=a[i]
  if a_sum>x:
    print(i)
    exit()

if x>sum(a):
  print(n-1)
else:
  print(n)

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

//struct item {
//	int a, b, c, d;
//};
//
//int n, m, q;
//

ll A, B;
ll f(ll x) {
	return div_floor(A * x, B) - A * div_floor(x, B);
}

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;

	//cin >> n >> m >> q;
	//vector<item> arr(q);
	//for (int i = 0; i < q; ++i) {
	//	cin >> arr[i].a;
	//	cin >> arr[i].b;
	//	cin >> arr[i].c;
	//	cin >> arr[i].d;
	//}
	//sort(arr.begin(), arr.end(), [](const item& a, const item& b) {return a.d > b.d; });
	/*for (auto x : arr) {
		cout << x.a << " " << x.b << " " << x.c << " " << x.d << "\n";
	}*/
	
	ll n;
	cin >> A >> B >> n;
	
	if (n >= B) {
		cout << f(B - 1);
	}
	else {
		ll ans = 0;
		for (ll i = n; i >= 0; i -= B)
			ans = max(ans, f(i));
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3628
import sys
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]

ab.sort(key=lambda x: x[1])
now = 0 #現在時刻
for i in range(n):
    now = now + ab[i][0]
    if now > ab[i][1]:
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 53600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,n,m;
    cin >> n >> m >> k;
    if(m*k>=n){
        cout << "Yes\n";
    }
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3656
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >>n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
        cin >>arr[i];
    int ans = 0;
    for(int i = 1; i < n-1; i++){
        if((arr[i] > arr[i-1] && arr[i] < arr[i+1]) || (arr[i] < arr[i-1] && arr[i] > arr[i+1]))
            ans++;
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
 
int main(){
    char x;
    int b,c;
    while(1){
        c=0;
        while(1){
            scanf("%c",&x);
            if(x=='\n')break;
            b=x-'0';
            c=c+b;
        }
        if(c==0)break;
        cout << c << endl;
    }
}

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

typedef struct{
    int p;
    int b;
    int s;
    int d;
}node;

void calcDepth(node* nd,int id, int d){
    if(id<0)return;
    nd[id].d = d;
    calcDepth(nd,nd[id].b,d);
    calcDepth(nd,nd[id].s,d+1);
}

int main(){
    int i,j,n,id,k,tmp,c,forp;
    forp = 0;
    scanf("%d",&n);
    node* nd = (node*)malloc(sizeof(node)*n);
    for(i=0;i<n;i++){
        nd[i].p = -1;
        nd[i].b = -1;
        nd[i].s = -1;
        nd[i].b = -1;
    }
    for(i=0;i<n;i++){
        scanf("%d %d",&id,&k);
        if(k>0){
            scanf("%d",&c);
            nd[id].s = c;
            tmp = c;
            forp += tmp;
            for(j=0;j<k-1;j++){
                scanf("%d",&c);
                nd[tmp].p = id;
                nd[tmp].b = c;
                tmp = c;
                forp += tmp;
            }
            nd[tmp].p = id;
        }
    }
    int rootid = (n*(n-1)) / 2 - forp;
    calcDepth(nd,rootid,0);
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d,",i,nd[i].p,nd[i].d);
        if(nd[i].p<0)printf(" root,");
        else if(nd[i].s<0)printf(" leaf,");
        else printf(" internal node,");
        printf(" [");
        tmp = nd[i].s;
        if(tmp>=0){
            printf("%d",tmp);
            while(nd[tmp].b>=0){
                tmp = nd[tmp].b;
                printf(", %d",tmp);
            }
        }
        printf("]\n");
    }
    return 0;
}



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

public class Main
{

	public static void main(String[] args)
	{	Scanner s = new Scanner(System.in);
                int n = s.nextInt();
          //    int d = s.nextInt();
                int i=0,j=0,k=0,ans=0,ss=0,r=0;
                for(i=1;i<=n;i++){
                    if(i%2!=0){
                       r = i;
                       for(j=1;j<=n;j++){
                           if(r%j==0){
                              ss++;
                           }
                       }
                       if(ss==8){
                          ans++;
                       }
                       ss = 0;
                    }
                }
                System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main()
{
   int n, d;
   cin>>n;
   d=n%2;
   if (d==0)
   {
       cout<<n/2;
   }
   else 
   {
       cout<<(n/2)+ 1;
   }
    
    return 0;
}

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

using namespace std;

#define M 300001

int main(){
  int N,Q,q,in,c[M]={0};
  cin >> N >> Q;
  for(int i = 0 ; i < N ; i++){
    cin >> in;
    c[in] = in;
  }
  for(int i = 1 ; i < M ; i++){
    c[i] = max(c[i],c[i-1]);
  }
  while(Q--){
    cin >> q;
    int r = 0;
    for(int i = q-1 ; i < M ; i += q){
      r = max(r,c[i]%q);
    }
    cout << r << endl;
  }
  return 0;
}

Measured memory_bytes: 2340
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int max = a.Max();
        int min = a.Min();

        Console.WriteLine(max - min);
    }
}

Measured memory_bytes: 13396