akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE TypeApplications #-}
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List                      

main :: IO ()
main = do
  n <- readLn @Int
  as <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let iMinusAi = sortGroup $ zipWith (-) [1..n] as
  let jPlusAj = sortGroup $ zipWith (+) [1..n] as
  print $ go 0 iMinusAi jPlusAj
  where
    go cnt [] _ = cnt
    go cnt _ [] = cnt
    go cnt xs'@((i, x):xs) ys'@((j, y):ys)
      | i < j = go cnt xs ys'
      | i > j = go cnt xs' ys
      | otherwise = go (cnt + x * y) xs ys

sortGroup = map (\t -> (head t,length t)) . group . sort


Measured memory_bytes: 63092
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//三角形を何通り作れるか
int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;

    vector <int> l(n);
    
    REP(i,n)cin >> l[i];

    sort(l.begin(),l.end());
    
    int muri[n][n];
    REP(i,n)REP(j,n)muri[i][j] = -1;

    ll res = 0;

    for(int i = 0; i < n-2; ++i)
    {
      for(int j = i+1; j < n-1; ++j)
      {
        int cnt = 0;
        int offset;
        //kの開始位置をずらしたい
        if(j != i + 1)
        {
          offset = muri[i][j-1];
          cnt += (muri[i][j-1] - 1 - j);
        }
        else if(i != 0)
        {
          offset = muri[i-1][j];
          //cnt += max(0, (muri[i-1][j] - 1 - j));
          cnt += (muri[i-1][j] - 1 - j);
        }
        else
        {
          offset = j + 1;
        }
        for(int k = offset; k < n; ++k)
        {
          if(l[i] + l[j] <= l[k])
          {
            muri[i][j] = k;
            break;
          }
          //muriを使ってskip
          ++cnt;
        }
        if(muri[i][j] == -1)muri[i][j] = n;
        res += cnt;
      }
    }
    cout << res << endl;
    return 0;
}



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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , a , b , k;
int d , x;
bool used[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    cin >> k;
    for(int i = 0; i < n + 1; i++){
        used[i] = false;
    }
    for(int i = 0; i < k; i++){
        cin >> d;
        for(int j = 0; j < d; j++){
            cin >> x;
            used[x] = true;
        }
    }
    int ans = 0;
    for(int i = 1; i < n + 1; i++){
        if(!used[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
fun main(args : Array<String>){
    val alphabet = readLine()
    val answer =Alphabet(alphabet)
    println(answer.get_answer())
}

class Alphabet (input : String?){
    val omikuji = listOf(
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z"
    )
    val nyuryoku=input
    fun get_answer(): String {
        for (i  in 0..26){
            if (nyuryoku == omikuji[i]){
                return omikuji[i+1]
            }
        }
        return ""
    }
}

Measured memory_bytes: 32160
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=5e5+5;
set<int>s[26];
string str;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>str;
	for(int i=0;i<n;i++){
		s[str[i]-'a'].insert(i);
	}
	for(int i=0;i<26;i++)s[i].insert(n);
	cin>>m;
	while(m--){
		int op;
		cin>>op;
		if(op==1){
			int idx;char ch;
			cin>>idx>>ch;
			idx--;
			//if(str[idx]==ch)continue;
			s[str[idx]-'a'].erase(idx);
			s[ch-'a'].insert(idx);
			str[idx]=ch;
		}
		else{
			int l,r,ans=0;
			cin>>l>>r;
			l--;
			for(int i=0;i<26;i++){
				int t=*s[i].lower_bound(l);
				if(t<r)ans++;
			}
			cout<<ans<<endl;
		}
	}
	//cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 24220
import sys
import copy

N = int(input())
A = list(list(map(int, input().split())) for _ in range(N))

def fnc(M):
    m = list([True]*len(M) for _ in range(len(M)))
    for k in range(len(M)):
        for i in range(len(M)):
            for j in range(len(M)):
                if M[i][j] > M[i][k]+M[k][j]:
                    print(-1)
                    sys.exit()
                if M[i][j] == M[i][k]+M[k][j] and i != k and j != k:
                    m[i][j] = False
    return M,m

M,m = fnc(A)

ans = 0
for i in range(N):
    for j in range(N):
        if m[i][j]:
            ans += M[i][j]
        
print(ans//2)

Measured memory_bytes: 76204
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,k;
    char tmp;
    string s;
    cin >> n >> s >> k;
    tmp = s[k - 1];
    for(int i = 0;i < s.size();i++)
    {
        if(s[i] != tmp){s[i] = '*';}
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;

struct UnionFind {
	vector<int> data;

	UnionFind(int sz) { data.assign(sz, -1); }

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}

	bool same(int x, int y) { return find(x) == find(y); }

	int find(int k) {
		if (data[k] < 0) return k;
		return (data[k] = find(data[k]));
	}

	int size(int k) { return (-data[find(k)]); }
};

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	UnionFind U(N);
	vector<int> d(N);
	vector<int> ans(N);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		U.unite(A, B);
		d[A]++;
		d[B]++;
	}
	for (int i = 0; i < N; i++) {
		ans[i] = U.size(i) - 1 - d[i];
	}
	for (int i = 0; i < K; i++) {
		int C, D;
		cin >> C >> D;
		C--; D--;
		if (U.same(C, D)) {
			ans[C]--;
			ans[D]--;
		}
	}
	for (int i = 0; i < N; i++) cout << ans[i] << " ";
	cout << endl;
}

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

int main() {
  string S;
  int K;
  int64_t Q=998244353;
  cin>>S>>K;
  vector<int> p;
  int a=0,P=0,V=S.size();
  for(int i=0;i<V;i++){
    if(S.at(i)=='1'){
      a++;
      P++;
    }
    else{
      p.push_back(a);
      a=0;
    }
  }
  int N=p.size();
  K=min(K,V-N);
  vector<vector<vector<int64_t>>> dp(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  vector<vector<vector<int64_t>>> yr(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  vector<vector<vector<int64_t>>> tr(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  dp.at(0).at(0).at(0)=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=K;j++){
      yr.at(0).at(j).at(i)=dp.at(0).at(j).at(i);
      tr.at(j).at(0).at(i)=dp.at(j).at(0).at(i);
      for(int k=0;k<K;k++){
        yr.at(k+1).at(j).at(i)=(yr.at(k).at(j).at(i)+dp.at(k+1).at(j).at(i))%Q;
        tr.at(j).at(k+1).at(i)=(tr.at(j).at(k).at(i)+dp.at(j).at(k+1).at(i))%Q;
      }
    }
    int b=p.at(i);
    for(int j=0;j<=K;j++){
      for(int k=0;k<=j;k++){
        int64_t X=0,Y=0;
        if(k-b-1>=0){
          X=tr.at(j).at(k-b-1).at(i);
        }
        if(j-P+b-1>=0){
          Y=yr.at(j-P+b-1).at(k).at(i);
        }
        dp.at(j).at(k).at(i+1)=(tr.at(j).at(k).at(i)+yr.at(j).at(k).at(i)-dp.at(j).at(k).at(i)-X-Y+3*Q)%Q;
      }
    }
  }
  int64_t Z=0;
  for(int j=0;j<=K;j++){
    for(int i=j;i<=min(K,j+a);i++){
      Z+=dp.at(i).at(j).at(N);
      Z%=Q;
    }
  }
  cout<<Z<<endl;
}



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

int main(void) {
	char str[1001];
	int ans, pos;
	
	while (scanf("%s", str), strcmp(str, "0")) {
		ans = 0;
		pos = 0;
		
		while (str[pos] != '\0') {
			ans += str[pos] - '0';
			pos++;
		}
		
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 536
using System;
class Program
{
    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());
        int Ans = 0;
        int a = 0;
        int b = 0;
        int c = 1;

        for(int i = 0; i < 1000; i++)
        {
            a++;
            c = a;
            for (int j = 0; j < 9; j++)
            {
                c = c * a;
                if (c > Ans && c <= X)
                {
                    Ans = c;
                }
                if (c > X) { break; }
            }
        }

        Console.WriteLine(Ans);

    }
}

Measured memory_bytes: 11092
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n;
    cin >> n;
    
    vector<int> v(n);
    for (auto &x : v) cin >> x;
    sort(ALL(v));
    
    if (n % 3 == 0) {
        if ((v[0] ^ v[n/3]) != v[2*n/3]) return cout << "No\n", 0;
        for (int i =       1; i <   n/3; ++i) if (v[i] != v[i-1]) return cout << "No\n", 0;
        for (int i =   n/3+1; i < 2*n/3; ++i) if (v[i] != v[i-1]) return cout << "No\n", 0;
        for (int i = 2*n/3+1; i <   n  ; ++i) if (v[i] != v[i-1]) return cout << "No\n", 0;
    }
    else for (auto x : v) if (x) return cout << "No\n", 0;
    
    cout << "Yes\n";
    
    return 0;
}

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  a += b;
  if (a >= 10) {
    cout << "error" << endl;
  } else {
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	s := "Zabcdefghijklmnopqrstuvwxyz"
	var a [1 + 26]bool
	for i := 0; i < len(S); i++ {
		for j := 1; j < len(s); j++ {
			if S[i] == s[j] {
				a[j] = true
			}
		}
	}
	for i := 1; i < len(s); i++ {
		if !a[i] {
			fmt.Printf("%c\n", s[i])
			return
		}
	}
	fmt.Println("None")
}


Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

#define FUTAGO(x) ((x) ? "Yay!" : ":(")

int main() {
	vector<int>dp(1, 1);
	dp.reserve(1000000);
	vector<int>sel = { 100,101,102,103,104,105 };
	for (int i = 1; i <= 1000000; ++i) {
		int v = 0;
		for (int e : sel) {
			if (i - e >= 0 && dp[i - e]) {
				v = 1;
			}
		}
		dp.push_back(v);
	}
	int x;
	cin >> x;
	cout << dp[x] << endl;
	return 0;
}

Measured memory_bytes: 10112
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	string s;
	cin >> s;
	int ans = 0;
	REP (i,s.size()) {
		if (s[i] != 'A' && s[i] != 'G' && s[i] != 'C' && s[i] != 'T') continue;
		int tmp = 1;
		FOR (j,i+1,s.size()) {
			if (s[j] != 'A' && s[j] != 'G' && s[j] != 'C' && s[j] != 'T') break;
			tmp++;
		}
		ans = max(ans,tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	string p;
	cin >> p;
	int ans = 0;
	for (int i = p.size() - 2; i >= 0; i--) {
		if (i % 2 )continue;
		
		string t = p.substr(0, i);
		string r = t.substr(0, i / 2);
//		cout << t << endl;;
		if (r + r == t) {
			ans = t.size(); break;
		}


	}
	cout << ans << endl;


	return 0;

}




Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)

def main():
    X = int(input())
    n = 100
    i = 0
    while True:
        i += 1
        n = int(n*1.01)
        if X <= n:
            break
    print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63320
#include <iostream>
#include <cmath>
#include <string>

int main (){
	int a,b;
	std::string s;
	std::cin >> a >> b;
	
	if (a > b)
		s = ">";
	else if (a < b)
		s = "<";
	else
		s = "==";

	std::cout << "a " << s << " b" << std::endl;
	return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    ll a[n + 2] = {};
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll x = 1000, y = 0;
    for (int i = 1; i <= n; i++) {
        if (i == 1 && a[i] <= a[i + 1]) {
            ll z = x / a[i];
            x -= z * a[i];
            y += z;
        }
        else if (1 < i && ((a[i - 1] >= a[i] && a[i] < a[i + 1]) || (a[i - 1] > a[i] && a[i] <= a[i + 1]))) {
            ll z = x / a[i];
            x -= z * a[i];
            y += z;
        }
        if (i == n) {
            ll z = y;
            x += z * a[i];
            y -= z;
        }
        else if ((a[i - 1] <= a[i] && a[i] > a[i + 1]) || (a[i - 1] < a[i] && a[i] >= a[i + 1])) {
            ll z = y;
            x += z * a[i];
            y -= z;
        }
    }
    cout << x << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;

#define int long long

main()
{
	string s;
	cin >> s;
		
	int nr = 0;
	int p = 0;
	
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'A')
			p++;
		else
		{
			if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C')
			{
				nr += p;
				i++;
			}
			else
				p = 0;
		}
    }
	
	cout << nr;
}


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

using namespace std;



int main(){
  string S;
  int K;
  cin >> S >> K;
  rep(i, S.size()){
    if(S[i] != '1' || i == K-1){
      cout << S[i] << endl;
      break;
    }
  }
    
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

MOD = 2019  # type: int

def solve(L: int, R: int):
    mn = 2018
    for i in range(L, min(L + 2019, R + 1)):
        mn = min(mn, i % MOD)
    if mn == 0:
        ret = 0
    else:
        ret = float('inf')
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ret = min(ret, (i * j) % MOD)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()


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

using ll = long long int;

ll arr[200010] = {};

int main(void){
    int n;
    ll total = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        scanf("%lld",&arr[i]);
        total += arr[i];
    }
    
    ll a = 0,b = 1e15;
    
    for(int i = 0; i < n-1; i++){
        a += arr[i];
        b = min(abs((total-a)-a),b);
    }
    
    printf("%lld\n",b);
    
}


Measured memory_bytes: 1792
N, M, Q = map(int, input().split())
sum_v = [ [0] * 505 for _ in range(505) ]

for _ in range(M):
    l, r = map(int, input().split())
    sum_v[l][r] += 1

for i in range(1, N+1):
    for j in range(1, N+1):
        sum_v[i][j] += sum_v[i-1][j]
        sum_v[i][j] += sum_v[i][j-1]
        sum_v[i][j] -= sum_v[i-1][j-1]

for _ in range(Q):
    p, q = map(int, input().split())

    ans  = sum_v[q][q]
    ans -= sum_v[q][p-1]
    ans -= sum_v[p-1][q]
    ans += sum_v[p-1][p-1]

    print(ans)
 

Measured memory_bytes: 13344
num = gets.to_i
data = readline.chomp.split(" ").map(&:to_i)
selected = data.select { |d| d % 2 == 0 }

count = 0

selected.each do |d|
 if (d % 3 == 0) || (d % 5 == 0)
    count += 1
 end
end

puts  count == selected.count ? "APPROVED" : "DENIED"

Measured memory_bytes: 3836
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  if (n == 1) cout << "Hello World" << '\n';
  else {
    int a, b;
    cin >> a >> b;
    cout << a + b << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, m;
  cin >> n >> m;
  // x = 100 * (n - m) + 1900 * m
  // p = 1 / (2 ^ m)
  // y = x + (1 - p) * y
  // y = x / p
  // y = (2 ^ m) * (100 * (n - m) + 1900 * m)
  ans = (ll)pow(2, m) * (100 * (n - m) + 1900 * m);
  cout << ans << endl;
  return 0;
}



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] hands = new int[5];
		while ((hands[0] = sc.nextInt()) != 0) {
			// data input
			int counthandtypes = 0;
			boolean rock = false, scissors = false, paper = false;
			for (int i = 1; i < 5; i++) {
				hands[i] = sc.nextInt();
			}
			// count hand
			for (int j = 0; j < 5; j++) {
				switch (hands[j]) {
				case 1:
					if (rock == false) {
						rock = true;
						counthandtypes++;
					}
					break;
				case 2:
					if (scissors == false) {
						scissors = true;
						counthandtypes++;

					}
					break;
				case 3:
					if (paper == false) {
						paper = true;
						counthandtypes++;
					}
					break;
				}
			}
			// decide winner
			if (counthandtypes == 1 || counthandtypes == 3) {
				Arrays.fill(hands, 3);
			} else {
				if (scissors == true && paper == true) {
					for (int k = 0; k < 5; k++) {
						if(hands[k] == 2){
							hands[k] = 1;
						}else{
							hands[k] = 2;
						}
					}
				} else if (rock == true && paper == true) {
					for (int k = 0; k < 5; k++) {
						if(hands[k] == 1){
							hands[k] = 2;
						}else{
							hands[k] = 1;
						}
					}
				}
			}
			for(int l = 0;l < 5;l++){
				System.out.println(hands[l]);
			}
		}
	}
}

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

int main() {
    int64_t N, M;
    cin >> N >> M;
    vector<int64_t> A(N);
    
    map<int64_t,int64_t> m;
    
    for ( int64_t i = 0; i < N; ++i){
        cin >> A.at(i);
        m[A.at(i)] = m[A.at(i)] + 1;
    }
    
    vector<int64_t> B(M), C(M);
    for ( int64_t i = 0; i < M; ++i){
        cin >> B.at(i) >> C.at(i);
        m[C.at(i)] = m[C.at(i)] + B.at(i);
    }
    
    
    vector<int64_t> v;
    vector<int64_t> n;
    int64_t value, num;
    for ( auto p: m ){
        value = p.first;
        num = p.second;
        v.push_back(value);
        n.push_back(num);
        //cout << "val " << value << " num " << num << endl;;
    }
    
    int64_t num_all = 0;
    int64_t val_all = 0;
    for ( int64_t i = v.size() - 1; i >= 0; --i){
        value = v[i];
        num = n[i];
        if ( num_all + num >= N ){
            val_all = val_all + value * ( N - num_all ) ;
            break;
        } else {
            val_all = val_all + value * num;
            num_all = num_all + num;
        }
        //cout << "i " <<  i << " val " <<  val_all << " num " << num_all << endl;
    }
    
    cout << val_all << endl;
    
    return 0;
}


Measured memory_bytes: 18332
#include <bits/stdc++.h>
#define int long long 
using namespace std;

signed main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for( int i = 0; i < N; i++ ) cin >> S.at(i);
  sort(S.begin(), S.end());
  for( int i = 0; i < N; i++ ) cout << S.at(i);
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int x, a, b; cin >> x >> a >> b;
	if (a < b) {
		if (x < b - a)cout << "dangerous" << "\n";
		else cout << "safe" << "\n";
	}
	else cout << "delicious" << "\n";

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  char turn = 'a';
  while(true){
    switch(turn){
      case 'a':
        if(sa.size() == 0){
          cout << "A" << endl;
          return 0;
        }
        turn = sa.at(0);
        sa = sa.substr(1,sa.size()-1);
        break;
      case 'b':
        if(sb.size() == 0){
          cout << "B" << endl;
          return 0;
        }
        turn = sb.at(0);
        sb = sb.substr(1,sb.size()-1);
        break;
      case 'c':
        if(sc.size() == 0){
          cout << "C" << endl;
          return 0;
        }
        turn = sc.at(0);
        sc = sc.substr(1,sc.size()-1);
        break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
/*
 *  Author :: Kattu37
 */

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortallr(x) sort(allr(x))
#define PI 3.1415926535897932384626
#define mod 1000000007

typedef pair<int, int>  pii;
typedef pair<ll, ll>  pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pll>   vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;

void solve()
{
	ll n, x, t;
	cin >> n >> x >> t;

	cout << (ll)ceil((double)n / x)*t << "\n";
}

int main(void)
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}

	return 0;
}


Measured memory_bytes: 3704
#include <stdio.h>

int euclid(int a, int b){//a > b
	int c;
	while(1){
		c = a % b;
		if(c == 0){
			return b;
		}
		a = b;
		b = c;
	}
}

int main(void){
	
	
	int n, k;
	scanf("%d%d", &n, &k);
	int max = 0;
	int gcd;
	for(int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		if(max < a){
			max = a;
		}
		if(i == 0){
			gcd = a;
		}else if(gcd > a){
			gcd = euclid(gcd, a);
		}else{
			gcd = euclid(a, gcd);
		}
	}
	if(max < k){
		printf("IMPOSSIBLE\n");
		return 0;
	}
	if(k % gcd == 0){
		printf("POSSIBLE\n");
	}else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}
/*
kが最大値より大きい場合は不可能。
kがすべての数の最大公約数の倍数でなければ不可能。
*/

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

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

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

	string s;
	set<char>st;
	cin >> s;
	for (auto i : s) {
		st.insert(i);
	}
	if (st.size() == s.size()){
		cout << "yes\n";
	}
	else {
		cout << "no\n";
	}
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);
    auto a = iota(n).map!(i => readln.chomp.to!int).array;

    a.sort();

    foreach (i ; 0 .. n) {
        if (a[i] % 2) {
            writeln("first");
            return;
        }
    }

    writeln("second");
}










void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 3708
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


a = inp()
print(a + a**2 + a**3)


Measured memory_bytes: 68992
while True:
    L = input()
    if L == "0":
        break

    table = [["+" for i in range(3)] for j in range(3)]
    for i in range(3):
        table[0][i] = L[i]

    L = input()
    for i in range(3):
        table[1][i] = L[i]

    L = input()
    for i in range(3):
        table[2][i] = L[i]

    ans = "NA"
    for i in range(3):
        if table[0][i] == table[1][i] and table[1][i] == table[2][i] and table[0][i] != "+":
            ans = table[0][i]
            break
        if table[i][0] == table[i][1] and table[i][1] == table[i][2] and table[i][0] != "+":
            ans = table[i][0]
            break
    if table[0][0] == table[1][1] and table[1][1] == table[2][2] and table[0][0] != "+":
        ans = table[0][0]
    if table[2][0] == table[1][1] and table[1][1] == table[0][2] and table[2][0] != "+":
        ans = table[2][0]
    print(ans)



Measured memory_bytes: 5576
# -*- coding: utf-8 -*-
import sys
import collections

def main():
	N = int(input())
	S = input()
	tmp = list(S)
	
	strings = collections.Counter(tmp)
	
	ans = 1
	for key in strings:
		ans = ans * (strings[key] + 1)
	
	ans = (ans-1) % (1000000007)
	
	print(ans)
			
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 4340
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 
int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(a+b>c+d){
        cout<<"Left"<<endl;
    }
    else if(c+d>a+b){
        cout<<"Right"<<endl;
    }
    else{
        cout<<"Balanced"<<endl;
    }




}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    static void getAns(string s)
    {
        var ans = 1;
        if (s == "RRR") ans = 3;
        else if (s == "RRS" | s == "SRR") ans = 2;
        else if (s == "SSS") ans = 0;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 25864
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------

n,x,y = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7

ans=[0]*(n)

for a in range(1,n):
	for b in range(a+1,n+1):
		k = min(b-a, abs(x-a)+1+abs(y-b))
		ans[k]+=1
#		p(ans,a,b,k)
#	p("---")

for i in range(1,n):
	print(ans[i])



Measured memory_bytes: 3444
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
  int n;
  cin >> n;
  int c[n];
  REP(i, n) cin >> c[i];
  sort(c, c+n);
  int a = 0, b = 0;
  REP(i, n){
    if(i % 2 == 0) a += c[n-i-1];
    else b += c[n-i-1];
  }
  cout << a-b << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
import itertools
# main
q = int(input())
for a in range(q):
    X = input()
    Y = input()
    cost = [0]
    for c in Y:
        for i in range(len(cost) - 1, -1, -1):
            index = X.find(c, cost[i]) + 1
            if index:
                if i + 1 < len(cost):
                    cost[i + 1] = min(cost[i + 1], index)
                else:
                    cost.append(index)
    print(len(cost) - 1)

Measured memory_bytes: 7724
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; ++index)
#define RFOR(index, start, end) for(int index = start; index > end; --index)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); ++itr)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); ++itr)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
	deque<int> b;
	bool reversed = false;
	int n;
	cin >> n;
	FOR(i, 0, n) {
		int x;
		scanf("%d", &x);
		if (!reversed) {
			b.push_back(x);
		}
		else {
			b.push_front(x);
		}
		reversed = !reversed;
	}
	if (reversed) {
		reverse(b.begin(), b.end());
	}
	for (int x : b) {
		cout << x << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2944
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;

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

		List<int> kc = new List<int>();

		List<int> gc = new List<int>();

		for (int i = 0; i < 1000001; i++)
		{
			kc.Add(0);
			gc.Add(0);
		}

		HashSet<int> vs = new HashSet<int>();

		for (int i = 0; i < N; i++)
		{
			vs.Add(v[i]);
			if (i % 2 == 0)
			{
				gc[v[i]]++;
			}
			else
			{
				kc[v[i]]++;
			}
		}

		if (vs.Count() == 1)
		{
			Console.WriteLine(N / 2);
			return;
		}
		int gcm = gc.Max();
		int kcm = kc.Max();

		int gind = gc.IndexOf(gcm);
		int kind = kc.IndexOf(kcm);
		if(gind != kind)
        {
			Console.WriteLine(N - gcm -kcm);
			return;
		}
		gc[gind] = 0;
		kc[kind] = 0;

		int gcm2 = gc.Max();
		int kcm2 = kc.Max();

		if(gcm2 < kcm2)
        {
			Console.WriteLine(N - gcm - kcm2);
		}
        else
        {
			Console.WriteLine(N - gcm2 - kcm);
		}
	}
	static class NC
    {
		public static  int num { get; set; }
		public static int count { get; set; }
    }

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Lcm(long a, long b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Gcd(long a, long b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 50992
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
happy = 0
for i in range(n-1):
  if a[i] <= x:
    x -= a[i]
    happy += 1
  else:
    break
happy += 1 if x == a[n - 1] else 0
print(happy)


Measured memory_bytes: 8980
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def lcm(m, n):
    return m//gcd(m, n)*n

MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for x in a[1:]:
    l = lcm(x, l)

l %= MOD

ans = 0
for x in a:
    ans += l*pow(x, MOD-2, MOD)%MOD
print(ans%MOD)


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

// グローバル変数
int n;

// 関数プロトタイプ
void input();
void solve();
int check(int, int);

int main(void)
{
    input();
    solve();  
}

// 標準入力
void input() {
    cin >> n;
}

void solve() {
    int div = 1;
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        int div_cur = check(i, 0);
        if(div < max(div, div_cur) || i==2) {
            div = div_cur;
            ans = i;
        }
    }
        cout << ans << endl;
}

int check(int cur, int res) {
    if(cur%2 == 0) {
        return check(cur / 2, res + 1);
    } else {
        return res;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll A,B;
  cin>>A>>B;
  if(A+B==3){cout<<3<<endl;}
  if(A+B==4){cout<<2<<endl;}
  if(A+B==5){cout<<1<<endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	int N, x;
	cin >> N >> x;
	vi ans(2 * N, 0);
	vector<int> used(2 * N, 0);
	if (x == 1 || x == 2 * N - 1){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
		if (N == 2){
			ans[1] = 1;
			ans[2] = 2;
			ans[3] = 3;
		}
		else{
			if (x == 2 * N - 2){
				ans[N] = x + 1;
				used[x + 1] = 1;
				ans[N + 1] = x;
				used[x] = 1;
				ans[N - 1] = x - 1;
				used[x - 1] = 1;
				ans[N + 2] = x - 2;
				used[x - 2] = 1;
			}
			else{
				ans[N] = x - 1;
				used[x - 1] = 1;
				ans[N + 1] = x;
				used[x] = 1;
				ans[N - 1] = x + 1;
				used[x + 1] = 1;
				ans[N + 2] = x + 2;
				used[x + 2] = 1;
			}
			int y = 1;
			int pos = 1;
			while (1){
				if (ans[pos] != 0){
					pos += 4;
				}
				if (used[y] == 1){
					y += 4;
				}
				if (pos > 2 * N - 1){
					break;
				}
				ans[pos] = y;
				y++;
				pos++;
				if (pos > 2 * N - 1 || y > 2*N-1){
					break;
				}
			}
		}
		for (int i = 1; i <= 2 * N - 1; i++){
			cout << ans[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
ll dp[100][100010];

void solve()
{
	int n, k; cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i <= a[0]; ++i)
		dp[0][i] = 1;
	for (int pos = 1; pos < n; ++pos)
	{
		for (int candy = 0; candy <= k; ++candy)
		{
			dp[pos][candy] += dp[pos-1][candy];
			dp[pos][min(k+1, candy+a[pos]+1)] -= dp[pos-1][candy];
		}
		for (int candy = 0; candy <= k; ++candy)
		{
			if (candy) dp[pos][candy] += dp[pos][candy-1];
			dp[pos][candy] = (dp[pos][candy] % MOD + MOD ) %MOD;
		}
	}
	cout << dp[n-1][k];
}

//  ---------------------Template---------------------------
void InputSetup()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
}

int main(void)
{
	auto start = chrono::high_resolution_clock::now();

	InputSetup();
	solve();

	auto finish = chrono::high_resolution_clock::now();
	cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
}
//  ---------------------Template---------------------------

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
using namespace std;
int main()
{ string k;
 cin>>k;
 if((int)k.length()%2!=0)
 {
 cout<<"No";
 goto end;
 }
   
 for(int i=0;i<(int)k.length();i++)
 {if(i%2==0)
 {if(k[i]=='h')
   continue;
  else
  {
  cout<<"No";
  goto end;
  }
 }
  if(i%2!=0)
 {if(k[i]=='i')
   continue;
  else
  {
  cout<<"No";
  goto end;
  }
 }
  
 }


cout<<"Yes";
 end:;


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

static int32_t N;

static int32_t dfs(string str)
{
	if (stol(str) > N)
		return 0;

	int32_t cnt3 = 0, cnt5 = 0, cnt7 = 0;
	for (size_t i = 0; i < str.size(); i++) {
		switch (str[i]) {
		case '3':
			cnt3++;
			break;
		case '5':
			cnt5++;
			break;
		case '7':
			cnt7++;
			break;
		}
	}

	int32_t res = (cnt3 > 0 && cnt5 > 0 && cnt7 > 0) ? 1 : 0;

	res += dfs(str + "3");
	res += dfs(str + "5");
	res += dfs(str + "7");

	return res;
}

int main()
{
	cin >> N;

	cout << dfs("0") << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

def factorize(n: int):
    d = Counter()
    m= 2
    
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
            
        m += 1
        
    if n > 1:
        d[n] += 1
        
    return d


# 各階乗での素因数リストを出す。
n = ni()
divs = Counter()
for i in range(2,n+1):
    divs += factorize(i)
    


ans = 0
# 4,4,2以上を満たすペアを探す
gteq4 = []
lt4gteq2 = []
for k,v in divs.items():
    if v >= 4:
        gteq4.append(k)
    elif 2 <= v < 4:
        lt4gteq2.append(k)
        

# 4,4,4以上のみ
len_gteq4 = len(gteq4)
if len_gteq4 >= 3:
    ans += (len_gteq4*(len_gteq4-1)*(len_gteq4-2) // 6) * 3

# 4,4,2or3のみ
len_lt4gteq2 = len(lt4gteq2)
if len_gteq4 >= 2 and len_lt4gteq2 >= 1:
    ans += (len_gteq4*(len_gteq4-1)//2) * len_lt4gteq2
    
    
# 2,24以上を満たすペアを探す
gteq24 = []
gteq2 = []
for k,v in divs.items():
    if v >= 24:
        gteq24.append(k)
    if v >= 2:
        gteq2.append(k)
        
ans += (len(gteq24) * len(gteq2) - len(gteq24))


# 4,14以上を満たすペアを探す
gteq14 = []
for k,v in divs.items():
    if v >= 14:
        gteq14.append(k)

ans += (len(gteq14) * len(gteq4) - len(gteq14))


# 74以上のものを探す
gteq74 = []
for k,v in divs.items():
    if v >= 74:
        gteq74.append(k)
        
ans += len(gteq74)
        
print(ans)

Measured memory_bytes: 3316
m, d = map(int, input().split())
ans = 0
for i in range(4, m + 1):
    for j in range(22, d + 1):
        if str(j)[0] != "1" and str(j)[1] != "1":
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
print(ans)



Measured memory_bytes: 39280