akhauriyash/Code-Regression huggingface dataset:
// Author : ps41

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll M = 1e9 + 7, N = 1e6 + 5;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), b(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n; i++) cin >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    ll lo = 0, hi = 99999999999999999;
    while (lo < hi)
    {
        ll mid = lo + (hi - lo) / 2;
        ll cnt = 0;
        for (ll i = 0; i < n; i++)
        {
            ll tmp = a[i] * b[i];
            if (tmp <= mid) continue;
            ll tmp2 = mid / b[i];
            cnt += a[i] - tmp2;
        }
        // cout << lo << " " << hi << " : " << cnt << "\n";
        if (cnt <= k)
        {
            hi = mid;
        }
        else
        {
            lo = mid + 1;
        }
    }
    cout << lo;
}

Measured memory_bytes: 6308
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b,c;
    while(cin>>a>>b>>c&&(a||b||c)){
        int n;
        cin>>n;
        
        vector<int> status(a+b+c,2);
        
        vector<int> va, vb, vc;
        rep(i,n){
            int x,y,z,r;
            cin>>x>>y>>z>>r;
            x--,y--,z--;
            if(r==1){
                status[x] = status[y] = status[z] = 1;
            }else{
                va.pb(x);
                vb.pb(y);
                vc.pb(z);
            }
        }
        
        rep(i,va.size()){
            if(status[vb[i]]==1&&status[vc[i]]==1)status[va[i]] = 0;
            if(status[vc[i]]==1&&status[va[i]]==1)status[vb[i]] = 0;
            if(status[va[i]]==1&&status[vb[i]]==1)status[vc[i]] = 0;
        }
        for(auto elm:status)cout<<elm<<endl;
    }
}



Measured memory_bytes: 3088
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] box = new int[n];
		boolean[] boxred = new boolean[n];
		
		boxred[0] = true;
		for (int i = 1; i < n; i++) {
			boxred[i] = false;
		}
		for (int i = 0; i < n; i++) {
			box[i] = 1;
		}
		

		for (int i = 0; i < m; i++) {
			int x = in.nextInt()-1;
			int y = in.nextInt()-1;
			if(boxred[x] == true){
				if(box[x] == 1){
					boxred[x] = false;
					boxred[y] = true;
				}else{
					boxred[y] = true;
				}
			}
			box[x]--;
			box[y]++;	
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if(boxred[i] == true){
				ans++;
			}
		}
		System.out.println(ans);
		in.close();
	}
	

}

Measured memory_bytes: 23768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int a= Integer.parseInt(s);
        s = sc.nextLine();
        int b= Integer.parseInt(s);
        s = sc.nextLine();
        int c= Integer.parseInt(s);
        s = sc.nextLine();
        int d= Integer.parseInt(s);

        int sum =0;

        if(a<b) { sum+=a;
        } else {
        	sum+=b;
        }
        if(c<d) { sum+=c;
        } else {
        	sum+=d;
        }

        System.out.println(sum);

	}

}


Measured memory_bytes: 21844
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	S, T := sc.nextStr(), sc.nextStr()
	A, B := sc.nextInt(), sc.nextInt()
	U := sc.nextStr()
	if S == U {
		fmt.Fprintln(wtr, A-1, B)
	} else if T == U {
		fmt.Fprintln(wtr, A, B-1)
	}
}


Measured memory_bytes: 640
use std::io;

fn main() {
    let mut tmp_str = String::new();
    io::stdin().read_line( &mut tmp_str ).expect( "No any input value" );
    let ary_size = tmp_str.trim().parse().expect( "failed trim function" );

    tmp_str = String::new();
    io::stdin().read_line( &mut tmp_str ).expect( "No any input value" );
    
    let mut numv: Vec<i32> = tmp_str.split_whitespace().
        filter_map( |k| k.parse().ok() ).collect::<Vec<i32>>();


    let mut cnt: i32 = 0;
    let mut flag: bool  = true;
    let mut tmp;

    while flag {
        flag = false;
        for j in ( 1..ary_size ).rev() {
            if numv[j-1 as usize] > numv[j as usize] {
                tmp = numv[j-1 as usize];
                numv[j-1 as usize] = numv[j as usize];
                numv[j as usize] = tmp;
                flag = true;
                cnt = cnt + 1;
            }
        }
    }

    printval( numv, cnt );
}

fn printval( numv: Vec<i32>, cnt: i32 ) {
    let ary_size = numv.len();

    for i in 0..ary_size {
        if i == ary_size-1 {
            println!( "{}", numv[i] );
        } else {
            print!( "{} ", numv[i] );
        }
    }
    println!( "{}", cnt );
}



Measured memory_bytes: 5032
import java.util.Scanner;

public class Main{
	public static double expect(double[][] x){
		double sum = 0;
		for(int i = 0; i < x.length; i++){
			sum += x[i][1];
		}
		double result = 0;
		for(int i = 0; i < x.length; i++){
			result += x[i][0]*x[i][1]/sum;
		}
		return result;
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		int T = stdIn.nextInt();
		double max = 0;
		for(int i = 0; i < T; i++){
			int n = stdIn.nextInt(), m = stdIn.nextInt();
			double[][] p = new double[m][2];
			for(int j = 0; j < m; j++){
				p[j][0] = stdIn.nextDouble();
				p[j][1] = stdIn.nextDouble();
			}
			double key = expect(p);
			if( key > max ){
				max = key;
			}
		}
		int n = stdIn.nextInt(), m = stdIn.nextInt();
		double[][] p = new double[m][2];
		for(int j = 0; j < m; j++){
			p[j][0] = stdIn.nextDouble();
			p[j][1] = stdIn.nextDouble();
		}
		double key = expect(p);
		if( max-key >= 0.0000001 ){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 13000
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>
# include <algorithm>
# include <iomanip>


using namespace std;


long double distance(int x1, int y1, int x2, int y2) {
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}


int main() {
    int n; cin >> n;
    vector<int> x(n), y(n);
    for (int i=0; i<n; i++) cin >> x[i] >> y[i];

    vector<int> z(n); for(int i=0; i<n; i++) z[i] = i;

    long double ans = 0.0;
    long long   dnm = 0;

    do {
        long double _ans = 0.0;
        for (int j=0; j<n-1; j++) {
            int _i = z[j];
            int _j = z[j+1];
            _ans += distance(x[_i], y[_i], x[_j], y[_j]);
        }
        ans += _ans;
        dnm++;
    } while (next_permutation(z.begin(), z.end()));

    cout << setprecision(12) << ans / dnm << endl;
    return 0;
}



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

int main(){
  string s;
  cin >> s;
  int a_ans = 0, z_ans = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'A'){
      a_ans = i;
      break;
    }
  }
  for(int i = s.size(); i >= 0; i--){
    if(s[i] == 'Z'){
      z_ans = i;
      break;
    }
  }
  
  cout << z_ans - a_ans + 1 << endl;
  return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int X, Y; cin >> X >> Y;
    int ans = 0;
    if(X == 1 && Y == 1) ans += 400000;
    ans += max(0, 300000 - 100000*(X-1));
    ans += max(0, 300000 - 100000*(Y-1));
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int a[10001];
int main()
{
   int n,sum = 0,des,cost = 0,cost1 = 0;
   cin >> n;
   for(int i = 0; i < n; i++){
       cin >> a[i];
       sum += a[i];
     }
     des = ceil(float(sum) / n);
     int des1 = floor(float(sum) / n);

   for(int i = 0; i < n; i++){
        cost += (abs(a[i] - des) * abs(a[i] - des));
   }
   for(int i = 0; i < n; i++){
        cost1 += (abs(a[i] - des1) * abs(a[i] - des1));
   }
   cout << min(cost,cost1) << endl;
   return 0;
}


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

int64_t mod = 998244353 ;

vector<int> getprime(int n){
    vector<int> p(0) ;
    vector<bool> table(n+1,0) ;
    for (int i = 2; i <= n; i++)
    {
        if (table.at(i) == 0)
        {
            p.push_back(i) ;
            for (size_t j = 2; j < n/i ; j++)
            {
                table.at(i*j) = 1 ;
            }
            
        }
        
    }
    return p ;
}

int main(){
    int64_t n ;
    cin >> n ;
    vector<int64_t> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    int64_t m = 1000 ;
    int64_t k = 0 ;
    for (size_t i = 0; i < n-1; i++)
    {
        if (a.at(i) < a.at(i+1))
        {
            int64_t buy = m/a.at(i) ;
            k += buy ;
            m -= buy * a.at(i) ;
        }else if (a.at(i) > a.at(i+1))
        {
            m += k * a.at(i) ;
            k = 0 ;
        }
        
        
    }
    m += k * a.at(n-1) ;
    cout << m << endl ;
}

Measured memory_bytes: 3596
/**********************************************************
* @Author: 			   Maple
* @Date:   			   2020-03-01 21:11:32
* @Last Modified by:   Maple
* @Last Modified time: 2020-03-01 21:30:44
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

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

const int maxn=500099;
char str[maxn];
int sum[30][maxn],n,q;

void update(int i,int j,int k){
	while(j<=n){
		sum[i][j]+=k;
		j+=lowbit(j);
	}
	return;
}

int getsum(int i,int j){
	int res=0;
	while(j>0){
		res+=sum[i][j];
		j-=lowbit(j);
	}
	return res;
}


int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("in.in","r",stdin);
	// #endif
	CSE(sum,0);
	cin>>n;
	cin>>str+1;
	cin>>q;
	for(int i=1;i<=n;i++){
		int k=str[i]-'a';
		update(k,i,1);
	}
	while(q--){
		int d;
		scanf("%d",&d);
		if(d==1){
			int i;
			char c;
			getchar();
			scanf("%d %c",&i,&c);
			int k1=str[i]-'a';
			int k2=c-'a';
			str[i]=c;
			update(k1,i,-1);
			update(k2,i,1);
		}
		else{
			int l,r;
			scanf("%d%d",&l,&r);
			int ans=0;
			for(int i=0;i<26;i++){
				if(getsum(i,r)-getsum(i,l-1)>0)
					ans++;
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 59392
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll a,b,c,d,e,f;

int main(){
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;

    double nodo = -1;
    ll ans1,ans2;

    for(ll i=0;i<=((f+a-1)/a);i++){
        ll ai = a*i;
        ll fi = f-ai;
        for(ll j=0;j<=((fi+b-1)/b);j++){
            ll bj = b*j;
            ll fj = fi-bj;
            for(ll k=0;k<=((fj+c-1)/c);k++){
                ll ck = c*k;
                ll fk = fj-ck;
                for(ll l=0;l<=((fk+d-1)/d);l++){
                    ll dl = d*l;

                    ll sum = ai + bj + ck + dl;
                    ll w = ai + bj;
                    ll s = ck + dl;

                    if(w==0 || sum > f) continue;
                    ll u = (w/100)*e;
                    if(s > u) continue;

                    double t = 100.0 * s / (double)(w + s);
                    //cout << Double(t) << endl;
                    //cerr << i << " " << j << " " << k << " " << l << endl;
                    if(t > nodo){
                        nodo = t;
                        ans1 = w+s;
                        ans2 = s;
                    }
                }
            }
        }
    }

    cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int i,j,k,v;
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int array[] = new int[n];

		for(i=0;i<n;i++)array[i] = in.nextInt();

	for(i=0;i<n;i++){
		v = array[i];
		j = i-1;
		while(j>=0 && array[j]>v){
			array[j+1] = array[j];
			j--;
		array[j+1] = v;
		}
	    for(k = 0;k<n-1;k++)System.out.print(array[k]+" ");
	    if(i<(n-1))System.out.println(array[k]);
	    else System.out.println(array[k]);
	}
	}

}

Measured memory_bytes: 32928
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    int x;
    cin >> x;

    int a = floor(x / 500);

    x = x - a * 500;

    int b = floor(x / 5);
    int res = floor(a * 1000 + b * 5);

    cout << fixed << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n;
    cin>>n;
    dvec a(n);
    rep(i,n)cin>>a[i];
    double ans=0;
    rep(i,n)ans+=1./a[i];
    cout<<1./ans;
}

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

int main()
{
    int n;
    cin >> n;
    int x;
    int cnt = 0;
    int minx = 100100100;
    rep(i, n) {
        cin >> x;
        if (x <= minx) cnt++;
        minx = min(minx, x);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <deque>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int main(void) {
    string N;
    cin >> N;
    deque<char> str(N.size());
    int i = 0;
    for (auto a : N) {
        str[i] = a;
        i++;
    }
    while (str.size() >1)    {
        if (str.front() != str.back()) {
            cout << "No" << endl;
            return 0;
        }
        str.pop_front();
        str.pop_back();
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DMitsui solver = new DMitsui();
        solver.solve(1, in, out);
        out.close();
    }

    static class DMitsui {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int num = in.nextInt();
            String s = in.next();
            int res = 0;
            for (int i = 0; i < 1000; i++) {
                if (search(i, s)) {
                    res++;
                }
            }
            out.println(res);
        }

        public static boolean search(int num, String s) {
            String x1 = Integer.toString(num / 100);
            String x2 = Integer.toString((num / 10) % 10);
            String x3 = Integer.toString(num % 10);
            if (!s.contains(x1)) {
                return false;
            } else {
                s = s.substring(s.indexOf(x1) + 1);
                if (!s.contains(x2)) {
                    return false;
                } else {
                    s = s.substring(s.indexOf(x2) + 1);
                    if (!s.contains(x3)) {
                        return false;
                    } else {
                        return true;
                    }
                }
            }

        }

    }
}



Measured memory_bytes: 61396
#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds1;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

void solve(){
    int n;
    cin>>n;
    vi a(n);
    int x = 0;
    loop(i,0,n) cin>>a[i], x^= a[i];
    vi ans(n);
    loop(i,0,n){
        ans[i] = x^a[i];
    }
    loop(i,0,n){
        cout<<ans[i]<<" ";
    }

}

int32_t main(){
    get_it_done(); 
    int tc=1;
    // cin >> tc;
    while (tc--){
        solve();        
    }
}


Measured memory_bytes: 6360
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
///////////////////////////////////////////////

ll dp[100000010];

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];

    rep(i,1e8+1) dp[i] = 1e9;
    dp[0] = 0;

    rep(i,h+1) rep(j,n) {
        if (i+a[j]<=1e8) chmin(dp[i+a[j]], dp[i]+b[j]);
    }

    ll ans = 1e9;
    repf(i,h,1e8+1) {
        chmin(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 781440
#include <iostream>
#include <string>

using namespace std;


int main() {
	using namespace std;

	int cnt = 0;
	string s;
	cin >> s;

	if (s[0] == '1')
	{
		cnt++;
	}
	if (s[1] == '1')
	{
		cnt++;
	}
	if (s[2] == '1')
	{
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    a = int(N/100)
    b = int(N/10)-a*10
    c = N - (a*100 + b*10)
    ans = c*100 + b*10 + a
    if ans == N:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
D = Counter(A)
res = []
for k, v in D.items():
    if v >= 2:
        for _ in range(v // 2):
            res.append(k)

if len(res) < 2:
    print(0)
else:
    res = sorted(res, reverse=True)
    print(res[0] * res[1])


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

int main(){
  int N;
  cin >> N;

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
   cin >> vec.at(i);
  }
  for (int i = 0; i < N; i++) {
   vec.at(i)-=1;
  }

  int i = 0;
  int count=0;
  int X=0;
  while (i < N && X!=1) {
    X=vec.at(X);
    count+=1;
    i++;
  }
  if (count>=N) count=-1;
  cout << count << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
int gcd(int x,int y){
	if(y==0)return x;
	return gcd(y,x%y);
}
int main()
{
    int a,b;
	cin >> a >> b;
	cout << gcd(a,b) << "\n";
    return 0;
}

Measured memory_bytes: 1164
N = int(input())
A = []
L = []
for i in range(N):
  a = int(input())
  A.append(a)
  tmp = []
  for i in range(a):
    tmp.append(list(map(int, input().split())))
  L.append(tmp)

ans = 0
for i in range(1, 2**N):
  tmp = [-1] * N
  flag = True
  d = []
  for j in range(N):
    if (i>>j) & 1:
      if tmp[j] == 0:
        flag = False
        break
      tmp[j] = 1
      l = L[j]
      for k in range(len(L[j])):
        p, t = l[k][0], l[k][1]
        if tmp[p-1] < 0:
          tmp[p-1] = t
        elif tmp[p-1] != t:
          flag = False
          break
      if flag == False:
        break
    else:
      d.append(j)
  for m in range(len(d)):
    n = d[m]
    if tmp[n] == 1:
      flag = False
      break
  if flag:
    ans = max(ans, tmp.count(1))
print(ans)

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

int main() {
   int n;
   cin >> n;
   if(n >= 30) {
      cout << "Yes" << endl;
      return 0;
   }
   cout << "No" << endl;
   return 0;
}

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

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

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//main
//------------------------------------------
bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}signed main(){
    // 入力
    int x;
    cin >> x;
    while(true){
        if (IsPrime(x))
        {
            cout << x;
            break;
        }
        x++;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int wq[100003][5],st[100003][5];
int dmc(int g,int h)
{
    if(st[g][h])return st[g][h];
    st[g][0]=wq[g][0]+max(dmc(g-1,1),dmc(g-1,2));
    st[g][1]=wq[g][1]+max(dmc(g-1,0),dmc(g-1,2));
    st[g][2]=wq[g][2]+max(dmc(g-1,0),dmc(g-1,1));
    return st[g][h];
}
int main()
{
    int g,t;
    scanf("%d",&t);
    for(g=0;g<t;g++)
        scanf("%d %d %d",&wq[g][0],&wq[g][1],&wq[g][2]);
    st[0][0]=wq[0][0], st[0][1]=wq[0][1], st[0][2]=wq[0][2];
    dmc(t-1,0);
    printf("%d\n",max(st[t-1][0],max(st[t-1][1],st[t-1][2])));
    return 0;
}


Measured memory_bytes: 11904
#include "iostream"
#include "string"
#include "cstring"
#include "cstdio"

using namespace std;

int main()
{
    int N, M;
    scanf("%d%d", &N, &M);
    char good[N + 1];
    int elevation[N+1] = {0};
    memset(good, 1, sizeof(good));

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

    while(M--)
    {
        int o1, o2;
        scanf("%d%d", &o1, &o2);
        if(elevation[o1] > elevation[o2])
            good[o2] = 0;
        else if(elevation[o1] < elevation[o2])
            good[o1] = 0;
        else
            good[o1] = good[o2] = 0;;
    }

    int count = 0;
    for(int i=1; i<=N; ++i)
    {
        if(good[i] == 1)
            count++;
    }
    printf("%d\n", count);

    return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int cnt[26] = {};
	for(auto i:s)cnt[i-'a']++;
	bool is = false;
	for(int i = 0;i<26;i++)
	{
		if(cnt[i]==0&&is==false)
		{
			is = true;
			s.push_back('a'+i);
			
		}
	}
	if(is)cout<<s<<endl;
	else
	{
		string t = s;
		if(next_permutation(s.begin(),s.end()))
		{
			for(int i = 0;i<s.size();i++)
			{
				cout<<s[i];
				if(s[i]!=t[i])break;
			}
			cout<<endl;

		}
		else
		{
			cout<<-1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
      cin >> H >> W;
      if(H==0&W==0) break;
      for(int i = 0 ; i<H ; i++){
            for(int j = 0 ; j<W ; j++){
              cout<<"#";
            }
            cout<<endl;
      }
      cout<<endl;
    }
}


Measured memory_bytes: 3088
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        k: usize
    }
    let mut b = b;
    let mut c = c;

    let mut ans = 0;
    while b <= a {
        b *= 2;
        ans += 1;
    }
    while c <= b {
        c *= 2;
        ans += 1;
    }

    if ans <= k {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2228
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	int a,b;
	cin >> a >> b;
	cout << a*b << endl;
}

Measured memory_bytes: 3664
#include<stdio.h>

int main(){
    int x, y, z, a;
    scanf("%d", &x);
    scanf("%d", &y);
    scanf("%d", &z);
    if (x > y) {
        a = x;
        x = y;
        y = a;
    }
    if (y > z) {
        a = y;
        y = z;
        z = a;
    }
    if (x > y) {
        a = x;
        x = y;
        y = a;
    }
    printf("%d %d %d\n", x, y, z);
    return 0;
}


Measured memory_bytes: 2084
#!/usr/bin/env python3
import sys
import itertools
import math


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):

    cpl = [ (i+1)*100*pp+cc for i,(pp,cc) in enumerate(zip(p,c)) ]

    min_n = float("inf")
    for tfl in itertools.product([True,False],repeat=D):
        cmp_total_n = sum(itertools.compress(p,tfl))
        cmp_total_p = sum(itertools.compress(cpl,tfl))
        if cmp_total_p < G:
            ntfl = [ not i for i in tfl ]
            max_i = max(itertools.compress([i for i in range(0,D)],ntfl))
            max_ip = 100*(max_i+1)

            additinal_n = int(math.ceil((G-cmp_total_p)/max_ip))
            if additinal_n < p[max_i]:
                min_n = min(min_n,cmp_total_n+additinal_n)
        else:
            min_n = min(min_n, cmp_total_n)

    print(min_n)



# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    p = [int()] * (D)  # type: "List[int]" 
    c = [int()] * (D)  # type: "List[int]" 
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long K, A, B;
    cin >> K >> A >> B;
    long long ret = 1; // number of biscuit
 
    if (
        B-A > 2 // 錬金したほうが得
        || K < A - 1 + 2// 錬金できるか　A枚のビスケット, -1 最初の一枚, +2 錬金に必要な回数
    ) {
        // A になるまでたたく
        K -= (A - 1);
        ret = A;
        
        // 回数限度まで錬金する
        int num = K / 2; // 錬金回数
        K -= num * 2; // 錬金後の残回数
        ret += num * (B - A);
 
        // 最後の調整
        ret += K;
    } else { // たたいた方が得
        ret += K;
    }
 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3624
// 2011/07/02 Tazoe

#include <iostream>
#include <string>
#include <map>
using namespace std;

int main()
{
	string frqW = "";
	int frqM = 0;
	string lenW = "";
	int lenM = 0;

	map<string, int> frq;

	while(true){
		string wrd;
		cin >> wrd;
		if(cin.eof())
			break;

		if(frq.find(wrd)==frq.end())
			frq[wrd] = 1;
		else
			frq[wrd]++;

		if(frq[wrd]>frqM){
			frqW = wrd;
			frqM = frq[wrd];
		}

		if(wrd.size()>lenM){
			lenW = wrd;
			lenM = wrd.size();
		}
	}

	cout << frqW << ' ' << lenW << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> N;
	vpll A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}
	sort(A.begin(), A.end());
	ll odd = 0;
	for (i = 0; i < N; i++) {
		if (abs(i - A[i].second) % 2 == 1) odd++;
	}
	cout << odd / 2;
}

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

int main(){
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const ll MOD = 1000000007ll;


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


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


ll getPow(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPow(x, e/2);
    return modProd(tmp, tmp);
  } else {
    ll tmp = getPow(x, e-1);
    return modProd(tmp, x);
  }
}


bool isEven(int x) {
  int tmp = ((x % 2) + 2) % 2;
  return tmp == 0;
}


bool isMultipleOfFour(int x) {
  return isEven(x) && isEven(x / 2);
}








const int MAXN = 51;
const int MAXSUM = 2501;


int N, A;
int ar[MAXN];
ll memo[MAXN][MAXSUM][MAXN];


void input() {
  cin >> N >> A;
  for (int i = 1 ; i <= N ; i++) {
    cin >> ar[i];
  }
}

void preprocess() {
}

void solve() {
  memo[0][0][0] = 1;
  for (int i = 1 ; i <= N ; i++) {
    memo[i][0][0] = 1;
    for (int s = 1 ; s < MAXSUM ; s++) {
      for (int c = 1 ; c <= N ; c++) {
        memo[i][s][c] = memo[i-1][s][c];
        if (s >= ar[i]) {
          memo[i][s][c] += memo[i-1][s-ar[i]][c-1];
        }
      }
    }
  }
  ll ans = 0;
  for (int mul = 1 ; mul * A < MAXSUM && mul <= N ; mul++) {
    ans += memo[N][mul*A][mul];
  }
  cout << ans;
}






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

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}


Measured memory_bytes: 50048
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
}
vector<int>v;
int mem[(int)1e5 + 10][3];
int solve(int k, int c)
{
	int& ret = mem[k][c];
	if (~ret)return ret;
	for (int i = 0; i < v.size(); i++)
	{
		if (k >= v[i])
		{
			if (solve(k - v[i], c % 2 + 1) == c)return ret=c;
		}
	}
	return ret= c % 2 + 1;
}
int main()
{
	Mohammed_Atef_Hassan
		clr(mem, -1);
		int n, k;
	cin >> n >> k;
	v = vector<int>(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	cout << (solve(k, 1) == 1 ? "First" : "Second") << finl;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

int p,q;
string a[11],b[11];
int cnt[3];
bool check(int x,int y,int z){
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<p;i++){
		bool flag=true;
		int c=0;
		for(int j=0;j<a[i].size();j++){
			if(a[i][j]=='.'){
				if(flag)c++;
			}else{
				if(flag && c!=cnt[0]*x+cnt[1]*y+cnt[2]*z)return false;
				flag=false;
			}
			if(a[i][j]=='{')cnt[0]++;
			if(a[i][j]=='(')cnt[1]++;
			if(a[i][j]=='[')cnt[2]++;
			if(a[i][j]=='}')cnt[0]--;
			if(a[i][j]==')')cnt[1]--;
			if(a[i][j]==']')cnt[2]--;
			if(cnt[0]<0 || cnt[1]<0 || cnt[2]<0)return false;
		}
	}
	if(cnt[0]!=0 || cnt[1]!=0 || cnt[2]!=0)return false;
	return true;
}

bool rcs[21][21][21];
int data[21];
bool flag[21];

int main(void){
	while(1){
		scanf("%d %d",&p,&q);
		if(p+q==0)break;
		for(int i=0;i<p;i++){
			cin >> a[i];
		}
		for(int i=1;i<=20;i++){
			for(int j=1;j<=20;j++){
				for(int k=1;k<=20;k++){
					rcs[i][j][k]=check(i,j,k);
					//if(rcs[i][j][k])printf("%d %d %d\n",i,j,k);
				}
			}
		}
		memset(cnt,0,sizeof(cnt));
		for(int i=0;i<q;i++){
			cin >> b[i];
			data[i]=-1;
			flag[i]=false;
			for(int j=1;j<=20;j++){
				for(int k=1;k<=20;k++){
					for(int l=1;l<=20;l++){
						if(rcs[j][k][l]){
							int spac=cnt[0]*j+cnt[1]*k+cnt[2]*l;
							if(data[i]==-1){
								data[i]=spac;
								flag[i]=true;
							}
							if(data[i]!=spac && data[i]!=-1){
								flag[i]=false;
							}
						}
					}
				}
			}
			if(cnt[0]+cnt[1]+cnt[2]==0){
				data[i]=0;
				flag[i]=true;
			}
			for(int j=0;j<b[i].size();j++){
				if(b[i][j]=='{')cnt[0]++;
				if(b[i][j]=='(')cnt[1]++;
				if(b[i][j]=='[')cnt[2]++;
				if(b[i][j]=='}')cnt[0]--;
				if(b[i][j]==')')cnt[1]--;
				if(b[i][j]==']')cnt[2]--;
			}
			if(flag[i])printf("%d",data[i]);
			else printf("-1");
			printf("%c",i==q-1?'\n':' ');
		}
	}
	return 0;
}

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

int main() {
    int a, b, c, tmp;
    cin >> a >> b >> c;
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    
    }
    if (b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

const ll LINF = 1ll << 60;

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

  ll N, A, B;
  cin >> N >> A >> B;

  if ((B - A) % 2ll == 0ll) {
    cout << (B - A) / 2ll << endl;
    return 0;
  } else {
    ll ans = LINF;
    { // left
      ll tmp = 0ll;
      tmp += A;
      tmp += (B - A) / 2ll;
      ans = min(ans, tmp);
    }
    { // right;
      ll tmp = 0ll;
      tmp += (N - B + 1);
      ll A_pos = A + (N - B + 1);
      tmp += (N - A_pos) / 2ll;
      ans = min(ans, tmp);
    }

    cout << ans << endl;
  }

  return 0;
};


Measured memory_bytes: 256