akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int n;

 	scanf("%d",&n);
 	set<int>s;
 	for(int i=0,x;i<n;i++)scanf("%d",&x),s.insert(x);

 	if(sz(s)==n)printf("YES\n");
 	else	printf("NO\n");
 	
}		


Measured memory_bytes: 9600
#include<bits/stdc++.h>
        using namespace std;
        #define ll long long int   
        # define pi 3.141592653589793238
     
     
     
          int main()
            {
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

             
            ios_base::sync_with_stdio(false);
     
              cin.tie(NULL);
     
     
  
ll n,i,ans=0;
cin>>n;
if(n>=30)
cout<<"Yes"<<"\n";
else
cout<<"No"<<"\n";



return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define Mod 1000000007ll
#define Val(x) (((long long)x) % Mod)
#define maxn 70
using namespace std;
int dp[maxn][4];
int arr[maxn],sz;
int tem[maxn][4];
void dfs(int cur,bool valid,int &ans) {
	if(cur == 0 || valid) {
		if(valid)	arr[cur+1] = 0;
		for(int i=cur+1;i<=sz;i++) {
			tem[i][0] = tem[i][1] = tem[i][2] = tem[i][3] = 0;
			for(int a=0;a<=1;a++)
				for(int b=a;b<=1;b++) {
					int cin = (arr[i] ^ a ^ b) , cout = ((a & b) | (a & cin) | (b & cin));
					if(i == cur + 1)
						tem[i][cout * 2 + arr[i]] = Val(tem[i][cout * 2 + arr[i]] + dp[i-1][cin * 2] + dp[i-1][cin * 2 + 1]);
					else
						tem[i][cout * 2 + arr[i]] = Val(tem[i][cout * 2 + arr[i]] + tem[i-1][cin * 2 + arr[i-1]]);
				}
		}
		ans = Val(ans + tem[sz][arr[sz]]);
		if(valid)	arr[cur+1] = 1;
	}
	else {
		for(int i=0;i<=arr[cur];i++)
			dfs(cur-1,(i < arr[cur]),ans);
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	dp[0][0] = 1;
	for(int i=1;i<maxn;i++)
		for(int a=0;a<=1;a++)
			for(int b=a;b<=1;b++)
				for(int cin=0;cin<=1;cin++) {
					int val = (a ^ b ^ cin) , cout = ((a & b) | (a & cin) | (b & cin));
					dp[i][cout * 2 + val] = Val(dp[i][cout * 2 + val] + dp[i-1][cin * 2 + 0] + dp[i-1][cin * 2 + 1]);
				} 

	long long n;
	cin >> n;
	
	int cur = 1;
	while(n > 0) {
		arr[cur] = (n & 1);
		n >>= 1;
		cur++;
	}
	sz = cur - 1;
	int ans = 0;
	dfs(sz,false,ans);
	
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
#define mod 1000000007
#define max_index 10000000

ll modpow(ll n,ll m=mod-2){
  ll r=1;
  while(m){
    r=r*((m%2)?n:1)%mod,n=n*n%mod,m>>=1;
  }
  return r;
}

ll fact[max_index];//i! (mod)
ll inv[max_index];//i^(-1) (mod)
ll invfact[max_index];//i!^(-1) (mod)

void calc_fact_invfact(){
  if(fact[0]==0){
    fact[0]=inv[1]=invfact[0]=1;
    for(ll i=2;i<max_index;i++) inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    for(ll i=1;i<max_index;i++) fact[i] = fact[i-1]*i%mod,invfact[i]=invfact[i-1]*inv[i]%mod;
  }
}
ll nCk(int n,int k){
  if(n<k || k<0) return 0;
  else return fact[n]*invfact[k]%mod*invfact[n-k]%mod;
}

int main(){

  ll K;
  cin >> K;
  string s;
  cin >> s;

  ll len = s.length();
  ll ans=0;
  ll now;
  calc_fact_invfact();
  for(ll i=0;i<=K;i++){
    now=modpow(25,i)%mod;
    now=now*nCk(i+(len-1),len-1)%mod;
    now=now*modpow(26,K-i)%mod;
    now=(now+mod)%mod;
    ans=(ans+now+mod)%mod;
  }

  cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 238640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int a, p;

int main()
{
    cin >> a >> p;
    int ans = 0;
    ans = (a * 3 + p) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {
    jaldi

    int a;
    int b;
    int c;
    int k;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>k;
    while(b<=a && k>0) {
        b= b*2;
        k--;
    }
    while(k>0 && c<=b) {
        c*=2;
        k--;
    }

    if(a<b && b<c) {
        cout<<"Yes"<<'\n';
    }
    else {
        cout<<"No"<<'\n';
    }

}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main()
{
	int c, r;
	int sumr = 0;
	int sumc = 0;
	cin >> r >> c;
	int**tex = new int*[r + 1];
	for (int i = 0; i < r + 1; i++)
	{
		tex[i] = new int[c + 1];
	}
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> tex[i][j];
		}
	}
	for (int i = 0; i < r + 1; i++)
	{
		for (int j = 0; j < c + 1; j++)
		{
			if (j == c)
			{
				tex[i][j] = sumr;
				sumr = 0;
			}
			else
			{
				sumr = sumr + tex[i][j];
			}
		}
	}
	for (int j = 0; j < c + 1; j++)
	{
		for (int i = 0; i < r + 1; i++)
		{
			if (i == r)
			{
				tex[i][j] = sumc;
				sumc = 0;
			}
			else
			{
				sumc = sumc + tex[i][j];
			}
		}
	}
	for (int i = 0; i < r + 1; i++)
	{
		for (int j = 0; j < c + 1; j++)
		{
			if (j == c)
			{
				cout << tex[i][j] << endl;
			}
			else
			{
				cout << tex[i][j] << " ";
			}
		}
	}


	return 0;
}

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

using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
#define div divv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int ma = 1024 * 1024;
const ll mod = int(1e9) + 7;

int n, ans;
vector<pair<int, int> > pq;
string s;
void solve(vector<int> a) {
	int dp[4] = {0, 0, 0, 0}, dp1[4] = {0, 0, 0, 0};
	/*forn (i, sz(a))
		cout << a[i] << " ";
	cout << "\n";*/
	for (int i = 1; i < sz(a); i++) {
		forn (j, 4) {
			dp1[j] = 0;
		}
		dp1[0] = max(max(dp[0], dp[1]), max(dp[2], dp[3]));
		//if (a[i - 1])
		dp1[1] = max(dp[0], dp[2]) + 1;
		if (a[i - 1] > 1)
			dp1[1] = max(dp1[1], dp[1] + 1);
		dp1[1] = max(dp1[1], dp[0] + a[i - 1]);
		dp1[1] = max(dp1[1], dp[1] + a[i - 1] - 1);
		dp1[1] = max(dp1[1], dp[2] + 1);
		dp1[2] = max(dp[0], dp[2]) + a[i] - 1;
		if (a[i - 1] > 1)
			dp1[2] = max(dp1[2], dp[1] + a[i] - 1);
		dp1[3] = max(dp[0], dp[2]) + a[i];
		if (a[i - 1] > 1)
			dp1[3] = max(dp1[3], dp[1] + a[i]);
		forn (j, 4) dp[j] = dp1[j];
	}
	ans += max(max(dp1[0], dp1[1]), max(dp1[2], dp1[3]));
}

int main() {
	iostream::sync_with_stdio(0), cin.tie(0);
	cin >> n >> s;
	forn (i, n) {
		if (sz(pq) && pq[sz(pq) - 1].fi == int(s[i] - '0')) {
			pq[sz(pq) - 1].se++;
		} else {
			pq.push_back(mp(int(s[i] - '0'), 1));
		}
	}
	vector<int> c;
	int i0 = 0;
	if (pq[0].fi == 0) i0 = 1;
	for (int i = i0; i < sz(pq); i++) {
		if (pq[i].fi == 0 && pq[i].se > 1) {
			solve(c);
			c.resize(0);
			continue;
		}
		if (pq[i].fi == 1)
			c.push_back(pq[i].se);
	}
	solve(c);
	cout << ans << "\n";
}

Measured memory_bytes: 3352
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
ll dp[60];
main(){
    int N;
    string s[2];
    cin >> N >> s[0] >> s[1];
    int i,pre;
    if(N != 1 && s[0][0] == s[0][1]){
        i = 2;
        dp[1] = 6;
        pre = 0;
    }else{
        i = 1;
        dp[0] = 3;
        pre = 1;
    }
    for(;i < N;){
        if(pre){
            if(i+1 < N && s[0][i] == s[0][i+1]){
                dp[i] = dp[i-1] * 2 % MOD;
                dp[i+1] = dp[i-1] * 2 % MOD;
                i += 2;
                pre = 0;
            }else{
                dp[i] = dp[i-1] * 2 % MOD;
                i++;
                pre = 1;
            }
        }else{
            if(i+1 < N && s[0][i] == s[0][i+1]){
                dp[i] = dp[i-1] * 3 % MOD;
                dp[i+1] = dp[i-1] * 3 % MOD;
                i += 2;
                pre = 0;
            }else{
                dp[i] = dp[i-1];
                i++;
                pre = 1;
            }
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main(){

    int X,N,p[101];
    cin>>X>>N;

    if(N==0){
        cout<<X<<endl;
        return 0;
    }

    for(int i=0;i<N;i++)    cin>>p[i];

    int ans=X;

    for(int i=1;i<=105;i++){
        for(int j=0;j<N;j++){
            if(ans==p[j])   break;
            else if(j==N-1){
                cout<<ans<<endl;
                return 0;
            }            
        }
        if(i%2==0){
            ans+=i;
        }else{
            ans-=i;
        }
    }

    return 0;
}

Measured memory_bytes: 3532
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *A = map(int, read().split())

    ng = 0
    ok = 10 ** 9
    while ok - ng > 1:
        mid = (ok + ng) // 2
        res = 0
        for a in A:
            res += (a + mid - 1) // mid - 1
        if res <= K:
            ok = mid
        else:
            ng = mid

    print(ok)
    return


if __name__ == '__main__':
    main()


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

int main() {
    ll n,m,count=0;
    cin>>n>>m;
    ll ans=0;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];

    // 配列のインデックス indiecs = {0, 1, 2, 3, 4} を作成する。
    std::vector<size_t> indices(a.size());
    std::iota(indices.begin(), indices.end(), 0);

    // ソートする。
    std::sort(indices.begin(), indices.end(), [&a](size_t i1, size_t i2) {
        return a[i1] < a[i2];
    });

    rep(i,n) {
        int j=indices[i];
        if (count+b[j]>m) {
            ans+=a[j]*(m-count);
            cout<<ans<<endl;
            return 0;
        } else {
            ans+=a[j]*b[j];
            count+=b[j];
            if (count==m) {
                cout<<ans<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    char a; 
    cin>>a;
    if(a>='a' && a<='z'){
        cout<<'a'<<"\n";
    }else{
        cout<<"A\n";
    }
    return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int count = 0;
            for (int i = 0; i < s.Length / 2; i++)
            {
                if (s[i] != s[s.Length - i - 1])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
N,K=list(map(int,input().split()))
A=sorted(list(map(int,input().split())))

mod=10**9+7

def modinv(x):
    return pow(x,mod-2,mod)

comb=1
ans=0

for i in range(N-K+1):
    ans+=comb*A[K-1+i]
    ans-=comb*A[N-K-i]

    ans%=mod

    comb*=(K+i)*modinv(i+1)
    comb%=mod

print(ans)


Measured memory_bytes: 63344
from collections import Counter

def solver(N, A):
    cnt = Counter(A)
    x = 1
    if N%2 == 1:
        if cnt[0] != 1:
            return 0
        x = 2
    for i in range(x, N, 2):
        if cnt[i] != 2:
            return 0
    
    return pow(2, N//2, 10**9+7)

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

print(solver(N, A))

Measured memory_bytes: 20776
double x[100],y[100],t,u,a,b,s;
n,i,j,k,c;
main(m){
	for(;scanf("%d",&n),i=j=n;printf("%d\n",m)){
		for(m=1;i--;scanf("%lf,%lf",x+i,y+i));
		for(i=n;--i;)
			for(j=i-1;j--;)
				if((u=acos(hypot(x[j]-x[i],y[j]-y[i])/2))<9)
					for(s=1,t=atan2(y[j]-y[i],x[j]-x[i]);c=0,s+3;s-=2)
						for(a=x[i]+cos(t+s*u),b=y[i]+sin(t+s*u),k=n;k--;)
							hypot(a-x[k],b-y[k])<1.01&&++c>m?m=c:0;
	}
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  int acount=0;
  int bcount=0;
  for(int i=0;i<n;i++){
    if(s[i]=='a' && acount+bcount<a+b){
      acount++;
      cout<<"Yes"<<endl;
    }
    else if(s[i]=='b'&& acount+bcount<a+b && bcount<b){
      bcount++;
      cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  }
}
        

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{
ll x,y,z;
cin>>x>>y>>z;
if(y*z>=x)
{
    cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;


}



   
      
    
        



Measured memory_bytes: 3636
using System;

public class Problem
{
  public static void Main()
  {
    string[] s = Console.ReadLine().Split(' ');
	int a = int.Parse(s[0]);
    int b = int.Parse(s[1]);
    int c = int.Parse(s[2]);
    if (a + b == c || a + c == b || b + c == a)
      Console.WriteLine("Yes");
    else
      Console.WriteLine("No");
  }
}

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

struct Food {
	int n, p, q, r, c;
};

int main(void)
{
	int n, P, Q, R, C, t;
	Food f[1000];

	while (cin >> n, n)
	{
		for (int i = 0; i < n; ++i)	cin >> f[i].n >> f[i].p >> f[i].q >> f[i].r;
		cin >> P >> Q >> R >> C;
		for (int i = t = 0; i < n; ++i)
		{
			if (f[i].p <= P && f[i].q <= Q && f[i].r <= R && 4*f[i].p+9*f[i].q+4*f[i].r <= C)	++t, cout << f[i].n << endl;
		}
		if (t <= 0)	cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 884
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize
    };

    let mut s = vec![];
    for i in 1..=m {
        s.push(i);
    }

    for _ in 0..n {
        input! {
            k: usize,
            a: [usize; k]
        }
        let mut b = vec![];
        for ai in a.iter() {
            if s.contains(ai) {
                b.push(*ai);
            }
        }

        s = b;
    }

    println!("{}", s.iter().count())
}


Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
#include <vector>

using namespace std;

#define max 6

int main(void){
	int div[] = {1, 10, 100, 1000, 10000, 100000, 1000000 };
	//FILE *fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int t, num, lim, indx = -1, summax = 0;
		bool error = true, rejected = false;
		stringstream ss;
		vector<int> bits;	//ビット列を記憶させる
		vector< vector< int > > vs;

		cin >> t >> num;
		ss << num;
		if( !( t | num ) ) break;

		lim = ( 1 << ( ss.str().length() - 1 ) ) - 1;

		for(int i = 0; i <= lim; i++) {
//			cout << i << ": ";
			vector< int > v;
			int temp = 0;
			for(int j = 0; j < max; j++) {
				if( i & ( 1 << j ) ) {
//					cout << ( num % div[j + 1] ) / div[temp] << " ";
					v.push_back( ( num % div[j + 1] ) / div[temp] );
					temp = j + 1;
				}
			}
			v.push_back( num / div[temp] );
			vs.push_back( v );
		}

		for(int i = 0; i < vs.size(); i++) {
			int sum = 0;
			for(int j = 0; j < vs[i].size(); j++) {
				sum += vs[i][j];
			}
			if( sum <= t ) {
				error = false;
				if( sum == summax ) {
					rejected = true;
				} else if( sum > summax ) {
					indx = i;
					summax = sum;
					rejected = false;
				}
			}
		}

		if( error == true ) {
			cout << "error" << endl;
		} else if( rejected == true ) {
			cout << "rejected" << endl;
		} else {
			cout << summax;
			for(int i = vs[indx].size() - 1; i >= 0; i--)
				cout << " " << vs[indx][i];
			cout << endl;
		}


	}
	//while(1){}

	return 0;
}

Measured memory_bytes: 1244
using namespace std;
#include <bits/stdc++.h>
int n;
long long ans=0;
string a[100009];
int arr[10009];
int b[5]={'A','M','R','C','H'};
long long  ssss(int i,int j,long long s)
{
    if(i==5&&j==3)return s;
    if(j>3)return 0;
    if(i==5)return 0;
    long long d=0,f=0;
    if(j<3)
        if(arr[b[i]])
        d=ssss(i+1,j+1,(long long)s*(long long)arr[(int)b[(int)i]]);
    f=ssss(i+1,j,s);
    return d+f;
}
int main()
{
    memset(arr,0,sizeof(arr));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        //if(a[i][0]=='M'||a[i][0]=='A'||a[i][0]=='R'||a[i][0]=='C'||a[i][0]=='H')
         arr[a[i][0]]++;
    }
    ans=ssss(0,0,1);
    cout<<ans;
}


Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int nC2(int n) {
	return n * (n - 1) / 2;
}
int main(void) {
	int k;
	cin >> k;
	cout << nC2(k) - nC2(k / 2) - nC2(k - k / 2) << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
dx = (0, 0, 1, -1)
dy = (1, -1, 0, 0)
seen = [[False] * w for _ in range(h)]

numb = 0
numw = 0


def dfs(x, y):
    global numb, numw
    seen[x][y] = True
    if s[x][y] == '#':
        numb += 1
    else:
        numw += 1
    for di in range(4):
        nx = x + dx[di]
        ny = y + dy[di]
        if (nx < 0 or nx >= h or ny < 0 or ny >= w):
            continue
        if s[x][y] == s[nx][ny]:
            continue
        if seen[nx][ny]:
            continue
        dfs(nx, ny)


ans = 0
for x in range(h):
    for y in range(w):
        if seen[x][y]:
            continue
        if s[x][y] == '.':
            continue
        numb = 0
        numw = 0
        dfs(x, y)
        ans += numb * numw
print(ans)


Measured memory_bytes: 226864
unittest
{
	assert( [ "2", "3 1" ].parse.expand.solve == 2 );
	assert( [ "3", "2 7 4" ].parse.expand.solve == 5 );
	assert( [ "4", "20 18 2 18" ].parse.expand.solve == 18 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto alice = 0L;
	auto bob = 0L;
	
	as.sort!( ( a, b ) => b < a );
	
	foreach( i, a; as )
	{
		if( i % 2 == 0 ) alice += a;
		else             bob += a;
	}
	
	return alice - bob;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8')

const [N, K]: number[] = input.split('\n')[0].split(' ').map(Number)
let S: string = input.split('\n')[1]
let newS: string = ""
for (let i = 1; i <= N; i++) {
  if (i === K) {
    newS += (S[i - 1]).toLowerCase()
    continue;
  }
  newS += (S[i - 1])
}

console.log(newS)

Measured memory_bytes: 7372
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        n: usize,
    }
    let ans = 180 * (n - 2);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (int)1e9;
ll CaseN=1;
ll fast_power(ll a,ll b,ll mod){
	ll ans=1;
	while(b>0){
	if(b&1){
	ans=(a*ans)%mod;
	}
	b=b>>1;
	a=(a*a)%mod;
	}
	return ans;
	}


ll nCr(ll n ,ll r)
{
ll p= n;
r = min(r,n-r);
ll a =1;
ll b=1;	
while(r)
{
	a = a*p;
	b = b*r;
	
	ll g = __gcd(a,b);
	
	a = a/g;
	b = b/g;
	
	p--;
	r--;	
}	
return a;
	
}

ll dif(ll a,ll b)
{
ll ans=0ll;	
  while(a>0 || b>0)
  {
	  ll r1 = (a&1);
	  ll r2 = (b&1);
	  if(r1!=r2)
	  {
		ans++;  
	   }
	  a = a>>1;
	  b = b>>1;
  }
	
	
	return ans;
}



ll calc(ll n)
{
if(n==0)
{
return 0;	
}
if(n==1)
{
return 1;	
}	
ll p = n/2;
ll ans = calc(p) + n;

return ans;	
}


void solve()
{
	ll ans =0;
  vector<bool> d(13,false);
  ll n,k;
  cin>>n>>k;
  
  for(ll i=0;i<k;i++)
  {
	  ll x;
	 cin>>x;
	d[x]=true;  
  }
	 
	
	for(ll i=n;i<=100000;i++)
	 {
		 ll f=0;
		 ll z= i;
		 while(z>0)
		 {
			ll r= z%10;
			z/=10;
			if(d[r])
			{
			f=1;
			break;	
			}
		 }
		 if(f==0 )
		 {
			ans = i;
			break; 
			}		 
		 
	 }
  
  
  //cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
  cout<<ans<<endl;
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{	
	solve();	
	}
}


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


typedef struct{
	int t_d;	// タイムスタンプ、発見時刻
	int t_v;	// タイムスタンプ、完了時刻
	int parent;	// どの頂点からのものか
	int rinsetu_n;	// 隣接する頂点の数
	int *rinsetu;
}GRAPH_T;

GRAPH_T *GRAPH;

int TIME = 1;


void Dfs(int vertex)
{
	int n;
	int i;


	if(GRAPH[vertex].t_d != -1){
		return;
	}else
		GRAPH[vertex].t_d = TIME++;

	n = GRAPH[vertex].rinsetu_n;

	// 隣接頂点がなければ戻る
	if(n == 0){
		GRAPH[vertex].t_v = TIME++;
		return;
	}

	for(i = 0; i < n; i++)
		Dfs(GRAPH[vertex].rinsetu[i]);

	GRAPH[vertex].t_v = TIME++;
}


int main()
{
	int n;
	int id, kazu;
	int num;
	int flag = 0;
	int i, j;


	scanf("%d", &n);

	GRAPH = (GRAPH_T *)malloc(sizeof(GRAPH_T) * (n + 1));

	for(i = 0; i < n; i++)
		GRAPH[i].parent = -1;

	for(i = 0; i < n; i++){
		scanf("%d %d", &id, &kazu);
		GRAPH[id].t_d = -1;
		GRAPH[id].rinsetu_n = kazu;

		if(kazu != 0){
			GRAPH[id].rinsetu = (int *)malloc(sizeof(int) * kazu);
			for(j = 0; j < kazu; j++){
				scanf("%d", &num);
				GRAPH[id].rinsetu[j] = num;
				GRAPH[num].parent = id;
			}
		}
	}

	// rootを求める
	i = 0;
	while(++i <= n){
		if(GRAPH[i].parent == -1){
			flag = 1;
			Dfs(i);
		}
	}
	if(flag != 1)
		Dfs(1);

	for(i = 1; i <= n; i++)
		printf("%d %d %d\n", i, GRAPH[i].t_d, GRAPH[i].t_v);

	return 0;
}


Measured memory_bytes: 2056
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vi f(m+1);
    rep(_,n){
        int k;
        cin>>k;
        while(k--){
            int a;
            cin>>a;
            f[a]++;
        }
    }
    int ans=0;
    rep(i,m+1){
        if(f[i]==n)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N,M = [int(x) for x in input().split()]
di = 10**9 + 7
if(abs(N-M)>1):
    ans = 0
else:
    ans = 1
    if(N!=M):
        ans *= max(N,M)
    else:
        ans *= 2
    for i in range(1,min(N,M)+1):
        ans = (ans * i**2) % di
print(ans)


Measured memory_bytes: 3060
// C++11
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

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

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

  vector<int> G;
  G.push_back(1);
  int prev_g = 1;
  while (true) {
    int g = prev_g * 3 + 1;
    if (g > N) {
      break;
    }
    G.push_back(g);
    prev_g = g;
  }

  int m = G.size();
  int cnt = 0;

  for (int k = 0; k < m; k++) {
    int g = G[m-k-1];
    for (int i = g; i < N; i++) {
      int v = A[i];
      int j = i - g;
      while (j >= 0 && A[j] > v) {
        A[j+g] = A[j];
        j = j - g;
        cnt++;
      }
      A[j+g] = v;
    }
  }

  cout << m << endl;
  for (int i = 0; i < m; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << G[m-i-1];
  }
  cout << endl;
  cout << cnt << endl;
  for (int i = 0; i < N; i++) {
    cout << A[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 7008
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

木DP 数え上げ
----------------------------------------

そのノードを黒にしたときの、そのノード以下の塗り分けの総数 Node.b
そのノードを白にしたときの、そのノード以下の塗り分けの総数 Node.w

黒が続いてはいけないので、
Node.b は子ノードたちの Node.w の積
Node.w は子ノードたちの(Node.w + Node.b)の積


nd.b = prod(kid; nd.kids)(kid.w)
nd.w = prod(kid; nd.kids)(kid.w + kid.b)

求めるものは root.b + root.w

----------------------------------------

*/

const long mod = 1_000_000_007;

class Node{
	long _b, _w;
	int id;
	Node[] nodes;
	Node[] kids;
	Node parent;
	bool isVisited;
	this(int id){
		this.id = id;
	}
	void treefy(Node parent){
		this.parent = parent;
		foreach(nd; nodes) if(!parent || nd.id != parent.id) this.kids ~= nd, nd.treefy(this);
	}
	long black(){
		if(_b == 0){
			_b = 1;
			foreach(kid; kids) _b *= kid.white, _b %= mod;
		}
	 return _b;
	}
	long white(){
		if(_w == 0){
			_w = 1;
			foreach(kid; kids) _w *= (kid.white + kid.black) % mod, _w %= mod;
		}
		return _w;
	}
	override string toString(){
		return "id:" ~ id.to!string ~ " b:" ~ _b.to!string ~ " w:" ~ _w.to!string ~ " kids:" ~ kids.map!(x => x.id).to!string;
	}
}

void main(){
 int n = read.to!int;
 
 Node[] nodes;
 foreach(i; 0 .. n) nodes ~= new Node(i);
 
 foreach(i; 0 .. n - 1){
	 int x = read.to!int - 1;
	 int y = read.to!int - 1;
	 nodes[x].nodes ~= nodes[y];
	 nodes[y].nodes ~= nodes[x];
 }
 
 nodes[0].treefy(null);
	
	debug writeln("nodes:", nodes);
 
 ((nodes[0].black + nodes[0].white) % mod).writeln;
}


Measured memory_bytes: 36988
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<String> datasets = new ArrayList<>();
		String dataset;
		double x, y, ad_bc;

		try {
			while((dataset = br.readLine()) != null) {
				datasets.add(dataset);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		for(String eachLine : datasets) {
			String[] eachStr = eachLine.split(" ");
			int[] each = new int[eachStr.length];
			for(int i = 0; i < eachStr.length; i++) {
				each[i] = Integer.parseInt(eachStr[i]);
			}

			ad_bc = each[0] * each[4] - each[1] * each[3];
			x = (each[4] / ad_bc * each[2]) + (-each[1] / ad_bc * each[5]);
			y = (-each[3] / ad_bc * each[2]) + (each[0] / ad_bc * each[5]);

			BigDecimal bx = new BigDecimal(x);
			BigDecimal by = new BigDecimal(y);

			System.out.println(bx.setScale(3, BigDecimal.ROUND_HALF_UP) + " " + by.setScale(3, BigDecimal.ROUND_HALF_UP));
		}
	}
}

Measured memory_bytes: 24496
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let s: String = sc.input();
    let mut s: Vec<char> = s.chars().collect();

    let mut s_cnt = 0;
    let mut t_cnt = 0;
    for c in s {
        if c == 'S' {
            s_cnt += 1;
        } else if s_cnt > 0 {
            s_cnt -= 1;
        } else {
            t_cnt += 1;
        }
    }

    println!("{}", s_cnt + t_cnt);
}


Measured memory_bytes: 3020
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<ctime>
#include<cstdlib>
#include<numeric>
#include<typeinfo>
#include<cstdio>
#include<cctype>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
const int inf=1e8;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009

int main(void){
	string s;
	int a,b;
	stack<int> st;
	while(cin>>s){
		if(s=="+"){
			a=st.top();st.pop();
			b=st.top();st.pop();
			st.push(a+b);
		}else if(s=="-"){
			a=st.top();st.pop();
			b=st.top();st.pop();
			st.push(b-a);
		}else if(s=="*"){
			a=st.top();st.pop();
			b=st.top();st.pop();
			st.push(a*b);
		}else{
			st.push(atoi(s.c_str()));
		}
	}
	cout<<st.top()<<"\n";
}

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


int main(){
  int n,k;
  cin >> n >> k;
  long mod = INF;
  long a[n];
  int minus = 0, zero=0;
  rep(i,n){
    cin >> a[i];
    if(a[i]<0)minus++;
    else if(a[i]==0)zero++;
  }
  int plus=n-minus-zero;
  sort(a,a+n, greater<>());

  if(plus==0 && k%2==1){
    if(zero>0){
      cout << "0" << endl;
      return 0;
    }else{
      long ans = 1;
      rep(i,k){
        ans *= labs(a[i]);
        ans %= mod;
      }
      ans *= -1;
      cout << (ans+mod)%mod << endl;
      return 0;
    }
  }

  int ii=0,ri=0;
  long ans=1;
  while(k>1){
    if(a[ii]*a[ii+1] >= a[n-1-ri]*a[n-2-ri]){
      ans *= a[ii];
      ii++;
      k--;
    }else{
      ans *= (a[n-1-ri]*a[n-2-ri])%mod;
      ri += 2;
      k -= 2;
    }
    ans %= mod;
  }
  if(k){
    ans *= a[ii];
    while(ans<0){
      ans += mod;
    }
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
string s;
long long n,memo[1000001][2];
int val(int x){
    return min(x,10-x+1);
    if (x!=10) return x;
    return 1;
}
long long dp(int index,bool get){
    if (index>=n){
        if (get) return 1;
        return 0;
    }
    if (memo[index][get]!=-1) return memo[index][get];
    long long ans=1e18;
    int k=s[index]-'0';
    if (!get){
        if (k==9){
            ans=min(ans,dp(index+1,false)+2);
        }
        ans=min(ans,dp(index+1,false)+val(k));
        ans=min(ans,dp(index+1,true)+val(k+1));
    }
    else {
        //ans=min(ans,dp(index+1,false)+val(k)+1);
        ans=min(ans,dp(index+1,false)+val(10-k));
        ans=min(ans,dp(index+1,true)+val(10-(k+1)));
    }
    //cout<<index<<' '<<get<<' '<<ans<<'\n';
    return memo[index][get]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    n=s.size();
    memset(memo,-1,sizeof(memo));
    cout<<dp(0,false);
}

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

public class Main {
  Scanner sc = new Scanner(System.in);

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

  void run() {
    int n = ni();
    int a = ni();
    int[] x = new int[n];
    for (int i = 0; i < n; ++i) {
      x[i] = ni();
    }
    long[][] dp = new long[n + 1][2501];
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 2500; 0 <= j; --j) {
        for (int k = n; 0 <= k; --k) {
          if (dp[k][j] == 0) {
            continue;
          }
          int nk = k + 1;
          int nv = j + x[i];
          dp[nk][nv] += dp[k][j];
        }
      }
    }

    long cnt = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= 2500; ++j) {
        if (j / i == a && j % i == 0) {
          cnt += dp[i][j];
        }
      }
    }
    System.out.println(cnt);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

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

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

int N, K;
vector<int> u, v;

int main()
{
    cin >> N;
    vector<int> h(N);
    int ans = 0;
    cin >> h[0];
    ans = h[0];
    for (int i = 1; i < N; i++)
    {
        cin >> h[i];
        if (h[i] > h[i - 1])
            ans += h[i] - h[i - 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <numeric>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;
int dp2[5010];
int dp[5010][5010];

int main(){
  const int n = getInt();
  const int k = getInt();

  vector<int> a(n);
  REP(i,n){
    a[i] = getInt();
  }

  if(accumulate(a.begin(), a.end(), 0ll) < k) {
    printf("%d\n", n);
    return 0;
  }

  dp[n][0] = 1;
  for(int i = n - 1; i >= 0; i--){
    REP(j,k+1) if(dp[i + 1][j]) {
      dp[i][j] = 1;
      if(j + a[i] <= k) dp[i][j + a[i]] = 1;
    }
  }

  int ans = 0;
  dp2[0] = 1;
  REP(i,n){
    vector<int> t;
    REP(j,k+1) if(dp[i + 1][j]) t.push_back(j);
    // printf("t: "); REP(j,t.size()) printf("%d ",t[j]); puts("");

    bool need = false;
    REP(j,k) if(dp2[j]){
      if(j + a[i] >= k){
        need = true;
        break;
      }

      const int v = k - (j + a[i]);
      const auto p = lower_bound(t.begin(), t.end(), v);
      if(p != t.end()){
        if(j + *p < k){
          // printf("%d: %d %d\n", i, j, *p);
          need = true;
          break;
        }
      }
    }
    // printf("%d => %d(%d)\n", i, (int)need, a[i]);
    ans += need ? 0 : 1;

    for(int j = k; j >= 0; j--){
      if(dp2[j] && j + a[i] <= k)
        dp2[j + a[i]] = 1;
    }
    // REP(j,k+1) if(dp2[j]) printf("%d ", j); puts("");
  }

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

  return 0;
}


Measured memory_bytes: 98176
from itertools import permutations


def main():
    N = int(input())
    P = ''.join(input().split(' '))
    Q = ''.join(input().split(' '))
    p_rank = 1
    q_rank = 1
    for perm in permutations(map(str, range(1, N + 1)), N):
        perm_str = ''.join(perm)
        if perm_str < P:
            p_rank += 1
        if perm_str < Q:
            q_rank += 1
    print(abs(p_rank - q_rank))


if __name__ == '__main__':
    main()

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

main() {
    string S; cin >> S;
    rep(i,S.size()){
        if(S[i]=='1')cout << 9;
        else if(S[i]=='9')cout << 1;
        else cout << S[i];
    }
    cout << endl;

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair

ll n,m;
bool p[114514];

void solve() {
    ZERO(p);
    p[0] = true;
    vector<int> box(n,1);

    rep(i,m) {
        int x, y; scanf("%d%d",&x,&y);
        --x; --y;
        if(p[x]) p[y] = true;
        if(box[x] == 1) p[x] = false;
        box[x]--; box[y]++;
    }

    ll ans = 0;
    rep(i,n) ans += p[i];
    cout << ans << "\n";
}

int main() {
    while(cin>>n>>m) solve();
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

ll N, a[100000];

struct BIT {
	vector<ll> bit;
	int n;

	BIT(int a) {
		n = a;
		bit.resize(n + 1);
		for (int i = 0; i < n + 1; i++)bit[i] = 0;
	}

	ll sum(int i) {
		ll s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	
	void add(int i, int x) {
		while (i <= n) {
			bit[i] += x;
			i += i & -i;
		}
	}
	ll sum(int l, int r) {
		//[l, r)
		return sum(r - 1) - sum(l - 1);
	}
};

bool f(ll value){
	int geta = N + 1;
	BIT bit(N * 2 + 100);
	ll rtn = 0;
	int Sum = 0;
	bit.add(geta, 1);
	for (int i = 0; i < N; i++) {
		Sum += (a[i] <= value ? 1 : -1);
		rtn += bit.sum(1, Sum + geta);
		bit.add(Sum + geta, 1);
	}
	if (rtn > N*(N + 1) / 4)return true;
	return false;

}

int main() {
	
	cin >> N;
	for (int i = 0; i < N; i++)cin >> a[i];
	ll up = 1 << 30, lw = 0;

	while (up - 1 != lw) {
		ll mid = (up + lw) / 2;
		if (f(mid))up = mid;
		else lw = mid;
	}
	cout << up << endl;
	
	return 0;
}


Measured memory_bytes: 2560
import numpy as np

N = []

for i in range(5):
    N.append(int(input()))

f = []

for i in range(5):
    f.append([N[i]%10,i])

f.sort()
m = 0

for i in range(5):
    if f[i][0] > 0:
        m = f[i][1]
        break

ans = 0

for i in range(5):
    if i == m:
        ans += N[i]
    else:
        ans += int(10*np.ceil(N[i]/10))   
 
print(ans)

Measured memory_bytes: 12504
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, a, b) = (v[0], v[1], v[2]);
    if n == 1 && a != b {
        println!("{:?}", 0);
        return;
    }
    if a > b {
        println!("{:?}", 0);
        return;
    }
    let max_sum = a + b * (n - 1);
    let min_sum = b + a * (n - 1);
    println!("{:?}", max_sum - min_sum + 1);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int d,i,s=0;
    while(scanf("%d",&d)!=EOF){
        s=0;
        for(i=1;i<600/d;i++){
            s+=d*(i*d)*(i*d);
        }
        printf("%d\n",s);
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

int main(){
	map <char, int> mp;
	string S;
	cin >> S;
	for (char c : S){
		mp[c]++;
	}
	cout << ((mp['N'] > 0 ^ mp['S'] > 0 || mp['E'] > 0 ^ mp['W'] > 0)?"No":"Yes") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll arr[100100],n,ans,temp1,temp2,a,b,m,p,k;
int main()
{
    set<char> se;
    string s;
    cin>>s;
    n=s.length();
    for(int i=0;i<n;i++)
    {
        se.insert(s[i]);
    }
    if(se.size()==n)
        cout<<"yes";
    else
        cout<<"no";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  vector<int>a(n);
  for(int i = 0;i<n;i++){
    cin >> a[i];
  }
  int pos = 0;
  int time = 1;
  bool ok = 1;
  for(int i = 0;i<n;i++){
    pos += a[i];
    time ++;
    if(pos>x){ok = 0;break;}
  }
  if(!ok)cout << time-1;
  else cout << time;
  return 0;
}

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

int main(void){
    int A,B,flag=0;
    cin >> A >> B;
    for(int i=1;i<=1000;i++){
        if(i*8/100==A&&i*10/100==B){
            cout << i;
            flag++;
            break;
        }
    }
    if(!flag){
        cout << -1;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N, K;


signed main(void) {

   cin >> N >> K;
   if(N%K==0){
       cout << 0 << endl;
   }else{
       cout << 1 << endl;
   }

    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input().split()
    print(s[1]+s[0])





if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

int main() {
    int n, a;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        if (i % 2 == 1 && a % 2 == 1) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3640