akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        HashMap<Integer,Integer> count = new HashMap<>();
        long sum = 0;
        for (int i = 0; i < N; i++) {
            int a = ni();
            sum += a;
            count.putIfAbsent(a,0);
            count.put(a,count.get(a) + 1);
        }
        int Q = ni();
        for (int i = 0; i < Q; i++) {
            int b = ni();
            int c = ni();
            if(count.containsKey(b)){
                sum += (c-b) * count.get(b);
                if(count.containsKey(c)){
                    count.put(c,count.get(c)+count.get(b));
                }else{
                    count.put(c,count.get(b));
                }
                count.remove(b);
            }
            out.println(sum);
        }
 
    }

 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 59992
/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
const int MOD=1000000007;
const int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}

ll raand()
{
	ll a=rand();
	a*=RAND_MAX;
	a+=rand();
    return a%(MOD-7);
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

pair<int,int> has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=MOD;
		h2*=bases[1];
		h2+=a-'a';
		h2%=MOD2;
	}
	return make_pair(h1,h2);
}

const int N=300010;
int n,t;
ll a,b,c,d;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	srand((long long)new char);
	for (int i=0;i<10;++i) bases.push_back(raand()+13893829);
	cin>>t;
	while (t--)
	{
		cin>>a>>b>>c>>d;
		if (d<b)
		{
			cout<<"No"<<en;
			continue;
		}
		if (a<b)
		{
			cout<<"No"<<en;
			continue;
		}
		ll gc=gcd(b,d);
		ll mo=a%gc;
		c++;
		ll c1=c;
		c1+=(mo-c%gc+gc)%gc;
		if (c1<b) cout<<"No"<<en;
		else cout<<"Yes"<<en;
	}
}


Measured memory_bytes: 256
N=int(input())

if N == 1:
  print(0)
  exit()

ans = 0
i = 1
while True:
  m = N//i-1
  q,r = divmod(N,m)
  if q == r:
    ans += m
  if m<N**.5:
    break
  i += 1
  
print(ans)

Measured memory_bytes: 9440
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		String S[] = new String[N];
		sc.nextLine();

		for (int i = 0; i < N; i++) {
			S[i] = sc.nextLine();
		}

		Arrays.sort(S);

		int cnt = 1;
		Map<String, Integer> map = new HashMap<>();

		for (int i = 0; i < N - 1; i++) {
			if (S[i].equals(S[i + 1])) {
				cnt++;
			} else {
				map.put(S[i], cnt);
				cnt = 1;
			}
		}

		if (S[N - 2].equals(S[N - 1])) {
			map.put(S[N - 1], cnt);
		} else {
			map.put(S[N - 2], cnt);
			map.put(S[N - 1], 1);
		}

		int maxcnt = 0;
		
		ArrayList<String> str = new ArrayList<>();

		for (String key : map.keySet()) {
			if (map.get(key) > maxcnt)
				maxcnt = map.get(key);
		}
		
		for (String key : map.keySet()) {
			if (map.get(key) == maxcnt)
				str.add(key);
		}
		
		Collections.sort(str);
		for (String s : str) {
			System.out.println(s);
		}

		sc.close();

	}
}

Measured memory_bytes: 177280
#include <stdio.h>

int main(void) {
    int n,k,x[100000],i,max,min,kari,ans = 999999999;
    scanf("%d %d",&n,&k);
    for (i = 0;i < n;i++) {
        scanf("%d",&x[i]);
    }
    for (i = 0;i < n - k + 1;i++) {
        min = x[i];
        max = x[i + k - 1];
        if (min >= 0) {
            kari = max;
        } else if (max <= 0) {
            kari = -min;
        } else {
            if (max >= min * -1) {
                kari = -min * 2 + max;
            } else {
                kari = max * 2 + -min;
            }
        }
        if (kari < ans) ans = kari;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
  long long N,D;
  cin >> N >> D;
  
  vector<vector<long long>>p(N,vector<long long>(2));
  
  for(int i=0;i<N;i++){
    cin >> p[i][0] >> p[i][1];
  }
  
  int ans = 0;
  
  for(int i=0;i<N;i++){
    double distance = sqrt(p[i][0] * p[i][0] + p[i][1] * p[i][1]);
    if(distance <= D) ans++;
  }

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


Measured memory_bytes: 14296
import Control.Monad
import Data.List
main = do
 [n,m]<-map read . words <$> getLine
 asbs <- replicateM m $ map (read::String-> Int) .words <$> getLine
 print $ length [[]|k<-[1..m], length(reach [1] (cut k asbs))<n]
 
next::Int->[[Int]]->[Int]
next v es = nub [b|[a,b]<-(es ++ map reverse es), a == v]
nexts::[Int]->[[Int]]->[Int]
nexts vs es = sort $ nub (vs ++ (concat [next v es|v <-vs]))
reach vs es
	|nexts vs es == nexts (nexts vs es) es = nexts vs es
    |otherwise = reach (nexts vs es) es
cut k es = (take (k-1) es) ++ (drop k es) 


Measured memory_bytes: 1020
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Numerics.BitOperations;

namespace ABC174
{
    class SolverD
    {
        static void Main()
        {
            SetOut(new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false});
            new SolverD().Solve();
            Out.Flush();
        }

        public void Solve()
        {
            var n = Get.Long();
            var cs = Get.Str().ToCharArray();

            long l = 0;
            long r = n-1;
            long ans = 0;
            while(l < r){
                while(cs[l] != 'W' && l < r){
                    l++;
                }
                while(cs[r] != 'R' && l < r){
                    r--;
                }
                if(l<r){
                    ans++;
                }
                l++;
                r--;
                // WriteLine($"l = {l}, r = {r}");
            }
            WriteLine(ans);
        }




        private static class Get
        {
            public static string Str() => ReadLine().Trim();
            public static int Int() => int.Parse(Str());
            public static long Long() => long.Parse(Str());
            public static double Double() => double.Parse(Str());
            public static string[] Strs() => Str().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            public static int[] Ints() => Strs().Select(int.Parse).ToArray();
            public static long[] Longs() => Strs().Select(long.Parse).ToArray();
            public static double[] Doubles() => Strs().Select(double.Parse).ToArray();
            static bool TypeEq<T,U>() => typeof(T).Equals(typeof(U));
            static T TypeConv<T,U>(U u) => (T)Convert.ChangeType(u, typeof(T));
            static T TypeConv<T>(string s) => TypeEq<T, int>() ?   TypeConv<T, int>(int.Parse(s))
                                        : TypeEq<T, long>() ?       TypeConv<T, long>(long.Parse(s))
                                        : TypeEq<T, double>() ?     TypeConv<T, double>(long.Parse(s))
                                        : TypeConv<T, string>(s);
            public static (T,U) Tuple<T,U>() {string[] strs = Strs(); T t = TypeConv<T>(strs[0]); U u = TypeConv<U>(strs[1]); return(t,u);}
            public static (T,U,V) Tuple<T,U,V>() {string[] strs = Strs(); T t = TypeConv<T>(strs[0]); U u = TypeConv<U>(strs[1]); V v = TypeConv<V>(strs[2]); return(t,u,v);}
        }
    }
}


Measured memory_bytes: 28696
#a = gets.split(" ").map{|x| x.to_i}
=begin
s = gets.chomp
if s == "Sunny"
  puts "Cloudy"
elsif s == "Rainy"
  puts "Sunny"
else
  puts "Rainy"
end
=end

s = gets.chomp.split("")

guusuu = 0
flag = 0
(s.size).times do |i|
  if guusuu == 0
    if s[i] == "L"
      flag = 1
      break;
    end
    guusuu = 1

  else
    if s[i] == "R"
      flag = 1
      break;
    end
    guusuu = 0
  end
end

if flag == 0
  puts "Yes"
else
  puts "No"
end


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << endl;}else{cout << "No" << endl;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << endl;}else{cout << "NO" << endl;}}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n,ans=0;
    cin>>n;
    stack<Pii> s;
    s.push(make_pair(n,10));
    while(!s.empty()){
        int now,count;
        tie(now,count)=s.top();
        s.pop();
        if(now==0) continue;
        if(now<count){
            ans+=now;
//            cout<<"+"<<now<<endl;
            continue;
        }
        ans += (now%count)*pow(2,(int)log10(now/count));
//        cout<<"+"<<now%count<<endl;
        s.push(make_pair(now/count,10));
        s.push(make_pair(now,count*10));
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
#ifdef KEV
#define debug(i) cerr << #i << ' ' << i << '\n'
#else
#define debug(i) 
#endif
using ll = long long;
const int maxn = 1<<19;
int n, k, a[maxn], pos[maxn];
struct sgt {
	int val[maxn<<1];
	void modify(int i, int v) {
		i += maxn;
		val[i] = v;
		for (;i>>=1;)
			val[i] = max(val[i<<1], val[i<<1|1]);
	}
	int query(int l, int r) {
		int res = 0;
		l = max(l, 1), r = min(r, n+1);
		l += maxn, r += maxn;
		for (;l < r;l>>=1, r>>=1) {
			if (l&1) res = max(res, val[l++]);
			if (r&1) res = max(res, val[--r]);
		}
		return res;
	}
}tree;
void bf(int l, int r) {
	bool c = true;
	while (c) {
		c = false;
		for (int j = l+1;j <= r;++j)
			if (abs(pos[j] - pos[j-1]) >= k && pos[j] < pos[j-1])
				c = true, swap(pos[j], pos[j-1]);//, swap(a[ pos[j] ], a[ pos[j-1] ]), c = true;
		for (int j = r;j >= l+1;--j)
			if (abs(pos[j] - pos[j-1]) >= k && pos[j] < pos[j-1])
				c = true, swap(pos[j], pos[j-1]);//, swap(a[ pos[j] ], a[ pos[j-1] ]), c = true;
	}
}
set<int> st;
void solve(int l, int r) {
	static int cp[maxn], pri[maxn];
	static vector<int> q[maxn];
	if (r <= l) return;
	if (r-l+1 <= 1000) 
		bf(l, r);
	else {
		int m = l + r >> 1;
		solve(l, m);
		solve(m+1, r);
		for (int i = l;i <= m;++i)
			tree.modify(pos[i], i), st.insert(pos[i]);//,cerr << "modify " << pos[i] << " : " << i << '\n';
		int lst = l-1;
		for (int i = m+1;i <= r;++i) {
			int p = tree.query(1, pos[i]);
			auto invalid = [&]() {
				auto it = st.lower_bound(pos[i]);
				return it != end(st) && *it - pos[i] < k;
			};
			while (lst < p || (lst < m && invalid())) {
				st.erase(pos[++lst]);
//				if (lst != l-1) st.erase(pos[lst]);
//				++lst;
			}
			debug(p) ;

			q[lst].pb(pos[i]);
			//if (l == 1 && r == 4) cerr << lst << '\n' << "P " << p << '\n';
		}
		for (int i = l;i <= m;++i)
			tree.modify(pos[i], 0);
		st.clear();

		int h = l;
		for (int i = l-1;i <= m;++i) {
			if (i != l-1) cp[h++] = pos[i];
			for (int u : q[i]) cp[h++] = u;
			q[i].clear();
		}
		copy(cp+l, cp+r+1, pos+l);
	}
}
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> k;
	for (int i = 1;i <= n;++i)
		cin >> a[i], pos[a[i]] = i;
	solve(1, n);
  
	for (int i = 1;i <= n;++i) a[pos[i]] = i;
	for (int i = 1;i <= n;++i)
		cout << a[i] << '\n';
}


Measured memory_bytes: 53760
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include<vector>
#include<cstring>
#include<set>
#include <cstdio>
#include<queue>
#include<map>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define endl '\n'
#define forup(i,a,n) for( int i =a; i < n; i++)
#define llforup(i,a,n) for( ll i =a; i < n; i++)
#define fordown(i,a,n) for( int i =a; i >= n; i--)
#define fornot(i,a,n) for( int i=a;!n;i++)
#define mod  (ll)(1e9+7)
#define ifempty(a)  if(!a)
using namespace std;
typedef long long ll;
inline int readnum() 
{
 int p, data = 0;char ch = 0;
 while ((ch != ' - ') && ch<'0' || ch>'9') ch = getchar();//相当于正则表达式的搜索，跳过不需要的字符
 if (ch == '- ')p = -1, ch = getchar();
 else p = 1;
 while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();//搜索需要的字符
 return data * p;
}
//E-mail 374656045@qq.com
int w[1001];
int v[1001];
int ans[10001];//标答用的是结构体，我们要少用结构体，结构体中存在空洞，检测空洞需要时间
bool path[101][1001];
class solve {
private:int N, W;
public:
	solve()
	{
		cin >> N >> W;
		forup(i, 1, N + 1)
			cin >> v[i] >> w[i];
		forup(i, 1, N + 1)//完全背包转移方程的解释是：已经选或不选前j个物品后，再选或不选当前的物品。状态转移等于信息滚雪球，注意层间滚和同层滚的区别
			for (int j = 0; j + w[i]<=W; j++)//同层转移对应同层可以执行不限次操作的情景。完全背包中ans[j] + v[i]中ans[j]包含了是否选择前j个同层物品的信息，而01背包没有这样的信息
				if (ans[j + w[i]] < ans[j] + v[i])//注意更新的方向决定了是完全背包还是01背包,更新的方向会决定是层间转移还是同层转移
					ans[j + w[i]] = ans[j] + v[i];//选第i种或者不选第i种
		cout << ans[W] << endl;
	}
};
int main(void)
{
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	solve solution;
#ifdef DEBUG
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
#endif
	return 0;
	
}



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

int main()
{
  ll a, b, k; cin >> a >> b >> k;
  ll x = max(0LL, a-k);
  ll y = max(0LL, b - max(0LL, k-a));
  printf("%lld %lld\n", x, y);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
LL n, a, b;
LL all;
int hi[1000000 + 20];
LL isok(int index, LL sum) {
    LL be = 0, en = sum;
    while (be <= en) {
        LL mid = (be + en) >> 1;
        if (a * mid + (sum - mid) * b >= hi[index]) en = mid - 1;
        else be = mid + 1;
    }
    return be;
}
bool check(LL sum) {
    LL need = 0;
    for (int i = 1; i <= n; ++i) {
        need += isok(i, sum);
        if (need > sum) return false;
    }
    return true;
}
void work() {
    cin >> n >> a >> b;
    for (int i = 1; i <= n; ++i) {
        cin >> hi[i];
        all += hi[i];
    }
    if (n == 1) {
        cout << (hi[1] + a - 1) / a << endl;
        return;
    }
    LL be = 0, en = 1e9;
    while (be <= en) {
        LL mid = (be + en) >> 1;
        if (check(mid)) en = mid - 1;
        else be = mid + 1;
    }
    cout << be << endl;
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


Measured memory_bytes: 640
// Problem : A - Round One
// Contest : AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_a
// Memory Limit : 1024.000000MB 
// Time Limit : 2000.000000milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define all(a) a.begin(),a.end()
#define vl vector<ll>


/*#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}*/


//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

using namespace __gnu_pbds;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>x>>y;
	cout<<6-x-y;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++) {
    cin >> s.at(i);
  }

  int M;
  cin >> M;
  vector<string> t(M);
  for(int i=0;i<M;i++) {
    cin >> t.at(i);
  }
  
  int ans=0;
  
  vector<int> x(N);
  for(int i=0;i<N;i++) {
    
    for(int j=0;j<N;j++) {
      if(s.at(i)==s.at(j)) x.at(i)++;
    }
    
    for(int j=0;j<M;j++) {
      if(s.at(i)==t.at(j)) x.at(i)--;
    }

  if(x.at(i)>ans) ans=x.at(i);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main() {

  int i,H,N[251];

  scanf("%d",&H);

  for(i = 1; i <= H; i++) {
    scanf("%d",&N[i]);
  }

  for(i = 1; i <= H; i++) {
    printf("node %d: key = %d, ",i,N[i]);
    if(i != 1) printf("parent key = %d, ",N[i/2]);
    if(2 * i <= H) printf("left key = %d, ",N[2*i]);
    else {
      printf("\n");
      continue;
    }
    if((2 * i + 1) <= H) printf("right key = %d, ",N[2*i+1]);
      printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		sc.close();
	}
}



Measured memory_bytes: 26204
#include <bits/stdc++.h>
using namespace std;
const int MAXH=25;
const int MAXW=25;
int main(){
	int h,w;cin>>h>>w;
	char chess[MAXH][MAXW];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			cin>>chess[i][j];
		}
	const int dr[]={0,-1,0,1};
	const int dc[]={-1,0,1,0};
	int maxm=0;
	for(int i=0;i<h*w;i++){
		if(chess[i/w][i%w]=='#')continue;
		for(int j=i;j<h*w;j++){
			if(chess[j/w][j%w]=='#')continue;
			// i=10;j=4;
			queue<int> q;
			q.push(i);
			int height[MAXH][MAXW];
			memset(height,0,sizeof(height));
			height[i/w][i%w]=1;
			int desr=j/w;int desc=j%w;
			while(!q.empty()){
				int u=q.front();q.pop();
				
				int ur=u/w;int uc=u%w;
				// cerr<<ur<<" "<<uc<<endl;
				if(ur==desr && uc==desc){
					break;
				}
				for(int ii=0;ii<4;ii++){
					int nr=ur+dr[ii];
					int nc=uc+dc[ii];
					if(nr<0 || nr>=h || nc<0 || nc>=w)continue;
					if(height[nr][nc])continue;
					if(chess[nr][nc]=='#')continue;
					////cerr<<"nest mo"<<nr<<" "<<nc<<endl;
					////cerr<<chess[nr][nc]<<endl;
					height[nr][nc]=height[ur][uc]+1;
					q.push(nr*w+nc);
				}
			}
			maxm=max(maxm,height[desr][desc]-1);
			////cerr<<maxm<<endl;
			
		}
	}
	cout<<maxm<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int A[1000000],n;

int binarySearch(int key){
  int unchi = 0;
  int right = n;
  int mid;

  while(unchi < right){
    mid = (unchi + right) / 2;
    if(key == A[mid])return 1;
    if(key > A[mid])unchi = mid + 1;
    else if(key < A[mid])right = mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum = 0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d", &k);
    if(binarySearch(k))sum++;
  }
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
int main()  
{     
    ll h,a,b;
    cin>>a>>b>>h    ;
    cout<<h*(a+b)/2;
}   

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, X; cin >> N >> X;
    vector<int> L(N, 0);
    for (int i = 0; i < N; ++i) cin >> L[i];
    vector<int> D(N + 1, 0);
    int cnt = 0;
    for (int i = 1; i < N + 1; ++i) {
        D[i] = D[i - 1] + L[i - 1];
        if (D[i] <= X) cnt++;
    }
    printf("%d\n", cnt + 1);
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vector<pll> a(n+1);
  for(ll i=1;i<=n;i++) {
    cin >> a[i].first;
    a[i].second=i;
  }
  sort(a.begin(),a.end());
  ll mn=inf;
  vec ans(n+1);
  for(ll i=n;i;i--) {
    mn=min(mn,a[i].second);
    ans[mn]+=abs(a[i].first-a[i-1].first)*(n-i+1);
  }
  for(ll i=1;i<=n;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 3456
using System;

class MyClass
{
    static string Repeat(string str, int repeat)
    {
        string str2 = "";
        for (int i = 0; i < repeat; i++)
        {
            str2 += str;
        }
        return str2;
    }

    static void Main(string[] args)
    {
        string str;
        while ((str = Console.ReadLine()) != "0 0")
        {
            int h = int.Parse(str.Split(' ')[0]);
            int w = int.Parse(str.Split(' ')[1]);
            for (int i = 0; i < h; i++)
            {
                Console.WriteLine(Repeat("#", w));
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 5640
import heapq

H, W = map(int, input().split())
graph = []
wall = []

for _ in range(10):
  graph.append(list(map(int, input().split())))

for _ in range(H):
  wall += list(map(int, input().split()))

def dijkstra(s):
  INF = 10**5
  hq = [(0, s)]
  heapq.heapify(hq)
  cost = [INF] * 10
  cost[s] = 0
  while hq:
    c, v = heapq.heappop(hq)
    if c > cost[v]:
      continue
    for u, d in enumerate(graph[v]):
      tmp = d + cost[v]
      if tmp < cost[u]:
        cost[u] = tmp
        heapq.heappush(hq, (tmp, u))
  return cost[1]

mincost = [0]*10
for i in range(10):
  mincost[i] = dijkstra(i)

ans = 0
for x in wall:
  if x == -1 or x == 1:
    continue
  else:
    ans += mincost[x]

print(ans)

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;

int main() {
    int n, k;
    string s;

    cin >> n >> k >> s;
    k--;
    s[k] = s[k] + 0x20;

    cout << s << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define DEBUG false

void dfs(vector<int> v, int n, int u){
	
	if(n == 0) {
		rep(i, v.size()){
			cout << v[i];
			if(i != v.size()-1) cout << " ";
		}
		cout << endl;
		return;
	}
	for(int i = min(n, u); i > 0; i--){
		vector<int> tmp(v);
		tmp.push_back(i);
		dfs(tmp, n-i, i);
	}
	
	return;
}

int main(){

	int n;
	while(cin >> n, n){
		
		vector<int> null;
		dfs(null, n, n);
		
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3004
a = gets.split("")
array = a.uniq
count = [0, 0]

4.times do |i|
  if a[i] == array[0]
    count[0] += 1
  end

  if a[i] == array[1]
    count[1] += 1
  end
end

if count[0] == 2 && count[1] == 2
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    long n, a, b;
    cin >> n >> a >> b;
    long ans = 0;
    long x, xn;
    cin >> x;
    for(int i=1; i<n; i++){
        cin >> xn;
        ans += min(b,(xn-x)*a);
        x = xn;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
def main():
    input = sys.stdin.readline
    h, w = map(int, input().split())
    s = np.array([list(input().rstrip()) for _ in range(h)])
    t = np.zeros((h+2, w+2))
    t[1:-1, 1:-1][s == "."] = 1
    row = np.zeros((h+2, w+2))
    col = np.zeros((w+2, h+2))
    for i in range(1, h+1):
        idx = np.where(t[i] == 0)[0]
        dif = np.diff(idx)
        row[i, idx[:-1]+1] += dif-1
        row[i, idx[1:]] -= dif-1
        row[i] = np.cumsum(row[i])
    t = t.T
    for i in range(1, w+1):
        idx = np.where(t[i] == 0)[0]
        dif = np.diff(idx)
        col[i, idx[:-1]] += dif-2
        col[i, idx[1:]] -= dif-2
        col[i] = np.cumsum(col[i])
    col = col.T
    cost = np.add(row, col)
    print(int(np.max(cost)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 173108
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let _n: usize = input();
    let m: usize = input();
    let mut py: Vec<(usize, usize, usize)> = (0..m).map(|i| (input(), input(), i)).collect();
    py.sort_by_key(|&(p, y, _)| (p, y));

    let mut ans = vec![];
    let mut i = 0;
    while i < m {
        let cur = py[i].0;
        let mut j = 1;
        while i < m && py[i].0 == cur {
            let (p, _, x) = py[i];
            let s = format!("{:06}{:06}", p, j);
            ans.push((x, s));
            i += 1;
            j += 1;
        }
    }
    ans.sort();

    with_stdout_lock(|mut w| {
        for a in &ans {
            writeln!(w, "{}", a.1).unwrap();
        }
    });
}


Measured memory_bytes: 15496
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    ll N, M;
    cin >> N >> M;
    ll sum = 0;
    if(N == 1 and M == 1){
        puts("1");
        return 0;
    }
    if(N == 1 and M != 1){
        cout << M - 2 << endl;
        return 0;
    }
    if(N != 1 and M == 1){
        cout << N - 2 << endl;
        return 0;
    }
    cout << (N - 2) * (M - 2) << endl;

}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define lowbit(x) (x&(-x))
const int inf = 0x3f3f3f3f;
typedef long long ll;
const int N = 1e5 + 10;
typedef pair<int, int> P;
const int up = 20;
const int mod = 1e9 + 7;
int dp[N],n,k,a[N];
int main()
{
	scanf("%d%d", &n,&k);
	for (int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		dp[i] = inf;
	}
	dp[1] = 0;
	for (int i = 2; i <= n; i++){
		for (int j = 1; j <= k; j++){
			if (i - j >= 1) dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
			else break;
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

int main()
{
	int n, i;
	
	cin >> n;
	
	for(i = 1; i <= n; i++)
	{
		if(i % 3 == 0)
		    cout << " " << i;
		else if(i % 10 == 3 || i / 10 == 3 || i % 100 / 10 == 3 || i / 100 == 3 || i % 1000 / 100 == 3 || i % 1000 == 3 || i / 1000 == 3)
		    cout << " " << i;
	}
	cout << endl;
	
	return 0;
}

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

int prime[55556];

int main() {
    int N, m = 2, k;
    cin >> N;

    for (int i = 0; i < 55556; i++) prime[i] = 1;
    prime[0] = prime[1] = 0;
    while (m <= 55555) {
        k = 2 * m;
        while (k <= 55555) {
            prime[k] = 0;
            k += m;
        }
        if (m % 5 != 1) prime[m] = 0;
        m++;
    }
    int count = 0, idx = 0;
    while (count < N) {
        for (int i = idx; i < 555556; i++) {
            if (prime[i] == 1) {
                cout << i << " ";
                idx = i + 1;
                break;
            }
        }
        count++;
    }
    cout << endl;

    return 0;

}

Measured memory_bytes: 512
a,b = [int(i) for i in input().split()]
a_ = []
b_ = []
for i in range(1,a+1):
    if a%i == 0:
        a_.append(i)

for i in range(1,b+1):
    if b%i == 0:
        b_.append(i)

for i in a_[::-1]:
    if i in b_:
        m = i
        break


print(a*b//m)



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if ( ((- X + 2 * Y) % 3 != 0) || ((2 * X - Y) % 3 != 0) ) {
			System.out.println(0);
		} else {
			int n = (- X + 2 * Y) / 3;
			int m = (2 * X - Y) / 3;
			COMinit();
			System.out.println(COM(n + m, n));
		}
	}

	static int MAX = 1000000;
	static int MOD = 1000000007;
	static long[] fac = new long[MAX];
	static long[] finv = new long[MAX];
	static long[] inv = new long[MAX];

	public static void COMinit() {
		fac[0] = 1L;
		fac[1] = 1L;
		finv[0] = 1L;
		finv[1] = 1L;
		inv[1] = 1L;
		for (int i = 2; i < MAX; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

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

Measured memory_bytes: 75800
def solve():
    S = input()
    n = len(S) - 1
    ieS = S[0]
    for i in range(n):
        ieS += '*'
        ieS += S[i+1]
    ans = 0
    for i in range(2 ** n):
        eS = ieS
        for j in range(n):
            if (i >> j) & 1:
                eS = eS[:(j+1)*2-1] + '+' + eS[(j+1)*2:]
        ans += eval(eS.replace('*', ''))
    print(ans)





if __name__ == '__main__':
    solve()


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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()

#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long long

#define int8_t signed char
#define int16_t signed short
#define int32_t signed int
#define int64_t signed long long



using namespace std;
// #define PI 3.14159265358979323846
// cout << fixed << setprecision(20);

int main(int argc, char const* argv[])
{
    int L = 0;
    int R = 0;
    int d = 0;

    cin >> L >> R >> d;
    int num = L;
    int count = 0;
    while (num <= R) {
        if (num % d == 0) {
            ++count;
        }
        ++num;
    }
    cout << count << endl;


    return 0;
}




Measured memory_bytes: 3560
//
//  main.cpp
//  ProblemSolving
//
//  Created by Mac mini on 1/7/20.
//  Copyright © 2020 Mac mini. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
using namespace std;
long long int  dp[51][51][1000];
int x[52], n, a;

long long int call(int idx, int cnt, int amount) {
	if(idx >= n) {
		if((double)amount / cnt == a)
			return 1;
		return 0;
	}

	if(dp[idx][cnt][amount] != -1) return dp[idx][cnt][amount];

	long long int  ret1 = 0, ret2 = 0;

	ret1 = call(idx + 1, cnt + 1, amount + x[idx]);
	ret2 = call(idx + 1, cnt, amount);

	dp[idx][cnt][amount] = ret1 + ret2;

	return dp[idx][cnt][amount];
}

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

	for(int i = 0; i < n; i++){
		cin >> x[i];
	}

	memset(dp, -1, sizeof(dp));

	cout << call(0, 0, 0) << "\n";

}


Measured memory_bytes: 23876
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }
#define N 10
#define H 10
#define W 10

const lli INF = 1e9;
lli h, w;
vector<vector<lli>> c(H, vector<lli>(W));

void warshal_floyd(int n){
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
}

int main(void){
    cin >> h >> w;
    rep(i, H) rep(j, W) cin >> c[i][j];
    warshal_floyd(N);
    lli ans = 0;
    rep(i, h) rep(j, w) {
        int a;
        cin >> a;
        if(a == -1) continue;
        ans += c[a][1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder sb=new StringBuilder(sc.nextLine());
		int last=sb.lastIndexOf("Z");
		int first=sb.indexOf("A");
		System.out.println(last-first+1);
	}
}

Measured memory_bytes: 28236
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int M = scanner.nextInt();
        
        int count = 0;
        for (int i = 0 ; i < N ; i++) {
            for (int j = i + 1 ; j < N ; j++) {
                count++;
            }
        }

        for (int i = 0 ; i < M ; i++) {
            for (int j = i + 1 ; j < M ; j++) {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21844
l,r=map(int,input().split())
if r-l+1<=2019:
	modlist=[]
	lst=list(range(l,r+1))
	for i in range(len(lst)):
		for j in range(i+1,len(lst)):
			q,mod = divmod(lst[i]*lst[j],2019)
			modlist.append(mod)
	print(min(modlist))
else:
	print(0)

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

int main(){
    string ss, t;
    cin >> ss >> t;
    reverse(ss.begin(), ss.end());
    ll i = 0;
    while(i < ss.size() - t.size() + 1){
        bool flag = true;
        rep(j, 0, t.size()){
            if(ss[i+j] != t[t.size()-j-1] && ss[i+j] != '?'){
                flag = false;
                break;
            }
        }
        if(flag){
            rep(j, 0, t.size()){
                ss[i+j] = t[t.size()-j-1];
            }
            reverse(ss.begin(), ss.end());
            rep(j, 0, ss.size()){
                if(ss[j] == '?') ss[j] = 'a';
            }
            cout << ss << endl;
            return 0;
        }
        i++;
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
n, x = list(map(int, input().split(' ')))

ss = list(map(int, input().split(' ')))
    
r = x
count = 0    
for s in sorted(ss):
    if r - s < 0:
        break
    else:
        n -= 1
        r -= s
        count += 1
if r > 0 and n <= 0:
    count -= 1
print(count)        
    


Measured memory_bytes: 3060
import java.io.PrintWriter;
import java.util.*;

public class Main {

    long INF = 1L << 60;

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Long> m = new ArrayList<>(), p = new ArrayList<>();
        PriorityQueue<Long> q = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            long x = sc.nextLong();
            if (x < 0) {
                m.add(x);
            } else {
                p.add(x);
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        String[] ans = new String[n - 1];
        long max = -1;

        if (m.size() > 0 && p.size() > 0) {
            long cp = p.get(0);
            long cm = m.get(0);
            int lenp = p.size();
            int lenm = m.size();
            int cnt = 0;

            for (int i = 1; i < lenm; i++) {
                ans[cnt] = cp + " " + m.get(i);
                cp -= m.get(i);
                cnt++;
            }
            for (int i = 1; i < lenp; i++) {
                ans[cnt] = cm + " " + p.get(i);
                cm -= p.get(i);
                cnt++;
            }
            ans[cnt] = cp + " " + cm;
            max = cp - cm;
        } else {
            if (p.size() > 0) {
                Collections.sort(p);
                if (n > 2) {
                    long v = p.get(0) - p.get(1);
                    ans[0] = p.get(0) + " " + p.get(1);
                    for (int i = 2; i < n - 1; i++) {
                        ans[i - 1] = v + " " + p.get(i);
                        v = v - p.get(i);
                    }
                    ans[n - 2] = p.get(n - 1) + " " + v;
                    max = p.get(n - 1) - v;
                } else {
                    ans[0] = p.get(1) + " " + p.get(0);
                    max = p.get(1) - p.get(0);
                }
            } else {
                Collections.sort(m, Collections.reverseOrder());
                long v = m.get(0) - m.get(1);
                ans[0] = m.get(0) + " " + m.get(1);
                for (int i = 2; i < n; i++) {
                    ans[i - 1] = v + " " + m.get(i);
                    v -= m.get(i);
                }
                max = v;
            }
        }

        out.println(max);
        for (int i = 0; i < n - 1; i++) {
            out.println(ans[i]);
        }
        out.flush();
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 73864
h, w = map(int, input().split())
div1 = 0
div2 = 0
if h%3==0 or w%3==0:
	print("0")
else:
	div1 = min(h, w)
	def div2(h, w):
		m = h*w
		for l in range(1, w):
			s = [l*h, (w-l)*(h-h//2), (w-l)*(h//2)]
			m = min(m, max(s)-min(s))
		return m
	div2 = min(div2(h, w), div2(w, h))
	print(min(div1, div2))


Measured memory_bytes: 42460
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int a[10];
int main() {
  int n;
  scanf("%d", &n);
  int ret = 0, cnt = 0;
  for (int i = 0; i < n; ++i) {
    int x, k;
    scanf("%d", &x);
    if (x >= 3200) {
      ++cnt;
      continue;
    }
    for (k = 1; k <= 8; ++k) {
      if (x < 400 * k) break;
    }
    a[k]++;
  }
  for (int k = 1; k <= 8; ++k) {
    if (a[k]) ++ret;
  }
  printf("%d %d\n", max(1, ret), ret + cnt);
  return 0;
}


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

#define int             long long
#define INF             1e18
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)

const int MOD = 1e9 + 7;
int fe(int a[], int n)
{
    vector<int> dp (n + 1, 0);
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++)
    {
        int one = abs(a[i] - a[i - 1]) + dp[i - 1];
        int two = abs(a[i] - a[i - 2]) + dp[i - 2];
        dp[i] = min(one, two);
    }
    return dp[n - 1];
}

int f(int step , int a[], int n)
{
    if (step == n - 1)
        return 0;

    int oneStep = abs(a[step] - a[step + 1]) + f(step + 1, a, n);
    int twoStep = INF;
    if (step + 2 < n)
        twoStep = abs(a[step] - a[step + 2]) + f(step + 2, a, n);

    return min(oneStep, twoStep);
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    // cout << f(0, a, n) << endl;
    cout << fe(a, n);


    return 0;
}


Measured memory_bytes: 4748
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <vector>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

struct Dice {
	int top, front, right, left, back, bottom;

	void toN() {
		swap(top, front);
		swap(front, bottom);
		swap(bottom, back);
	}

	void toS() {
		swap(top, back);
		swap(back, bottom);
		swap(bottom, front);
	}

	void toE() {
		swap(top, left);
		swap(left, bottom);
		swap(bottom, right);
	}

	void toW() {
		swap(top, right);
		swap(right, bottom);
		swap(bottom, left);
	}

	bool rotateTo(int toTop, int toFront) {
		if (top == toFront) {
			toS();
		} else if (front == toFront) {
			// noop
		} else if (right == toFront) {
			toW();
			toS();
		} else if (left == toFront) {
			toE();
			toS();
		} else if (back == toFront) {
			toS();
			toS();
		} else if (bottom == toFront) {
			toN();
		} else {
			return false;
		}
		if (top == toTop) {
			// noop
		} else if (right == toTop) {
			toW();
		} else if (left == toTop) {
			toE();
		} else if (back == toTop) {
			return false;
		} else if (bottom == toTop) {
			toE();
			toE();
		} else {
			return false;
		}
		return true;
	}
};

istream& operator>>(istream& in, Dice& dice) {
	in >> dice.top >> dice.front >> dice.right
		>> dice.left >> dice.back >> dice.bottom;
	return in;
}

bool operator==(const Dice& a, const Dice& b) {
	return a.top == b.top && a.front == b.front && a.right == b.right
		&& a.left == b.left && a.back == b.back && a.bottom == b.bottom;
}

int main() {

	Dice a, b;
	cin >> a >> b;

	a.rotateTo(b.top, b.front);

	cout << (a == b ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 3112