akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define MAX_N 100010
struct UF {
	int par[MAX_N],rank[MAX_N];
	
	void init(int n){
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}
	
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = par[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

ll siz[MAX_N];

int main(){
	ll n, m;
	cin>>n>>m;
	UF uf;
	uf.init(n);
	rep(i, m){
		ll a, b;
		cin>>a>>b;
		a--; b--;
		uf.unite(a, b);
	}
	rep(i, n) siz[uf.find(i)]++;
	ll x = min(siz[uf.find(0)], siz[uf.find(1)]);
	ll y = n-x;
	cout<<x*(x-1)/2+y*(y-1)/2-m<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
using namespace std;
int main() {
    
    int h, w;
    cin >> h >> w;
    string s;
    for (int i = 1; i <= h; i++) {
        cin >> s;
        cout << s << '\n' << s << '\n';
    }
    
    return 0;
}




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

int main() {
  string S, T;
  cin >> S >> T;
  int cnt = 0;
  rep(i, S.size()) {
    if(S.at(i) != T.at(i)) cnt++;
  }
  cout << cnt << endl;
}
  

Measured memory_bytes: 3844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b;
    cin >> a >> b;
    if (a > 9 || b > 9) {
        cout << -1 << endl;
    } else {
        cout << a*b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
////*24-AUG-19*///
//Why do we fall?//
// So we can learn to pick ourself up!//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;

typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(b.fi==a.fi)return (a.se>b.se);
    return (b.fi>a.fi);
}
signed main()
{
    fastio;
    R(h);R(n);
    vector<pair<int,int>>v;
    fr(i,1,n+1)
    {
        R(x);R(y);
        v.pb({x,y});
    }
    int dp[h+1];
    fr(i,1,h+1)
    {
        dp[i]=inf;
    }
    fr(i,1,h+1)
    {
        fr(j,0,n)
        {

            if(v[j].fi>=i)
            {
                dp[i]=min(dp[i],v[j].se);
            }
            else
            {
                dp[i]=min(dp[i],dp[i-v[j].fi]+v[j].se);
            }
        }

    }
    cout<<dp[h]<<endl;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a * b > c * d)
        cout << a * b << endl;
    else if (a * b < c * d)
        cout << c * d << endl;
    else
        cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
#define N 100015
struct edge{int to,nxxt;}e[N*20];
int n,a[N][2],head[N<<1],cnt=1,js,ls[N],rs[N],rt,s[N],rv[N],tot,b[N];
int dfn[N<<1],low[N<<1],f[N<<1],cn,an;
bool inq[N<<1];
stack<int>st;
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
inline int op(int x){return x<=n?x+n:x-n;}
void bt(int &o,int l,int r)
{
	o=++js;
	if(l==r)return;int mid=(l+r)>>1;
	bt(ls[o],l,mid);bt(rs[o],mid+1,r);
}
void dfs(int ind,int l,int r)
{
	if(l==r){ins(ind,op(b[l]));return;}int mid=(l+r)>>1;
	ins(ind,ls[ind]);ins(ind,rs[ind]);
	dfs(ls[ind],l,mid);dfs(rs[ind],mid+1,r);
}
void ade(int ind,int l,int r,int al,int ar,int x)
{
	if(al<=l&&r<=ar){ins(x,ind);return;}
	int mid=(l+r)>>1;
	if(al<=mid)ade(ls[ind],l,mid,al,ar,x);
	if(ar>mid)ade(rs[ind],mid+1,r,al,ar,x);
}
void tarjan(int x)
{
	dfn[x]=low[x]=++cn;inq[x]=1;st.push(x);
	for(int i=head[x];i;i=e[i].nxxt)
	{
		int j=e[i].to;
		if(!dfn[j]){tarjan(j);low[x]=min(low[x],low[j]);}
		else if(inq[j])low[x]=min(low[x],dfn[j]);
	}
	if(low[x]==dfn[x])
	{
		an++;
		while(!st.empty()&&st.top()!=x)
		{
			inq[st.top()]=0;f[st.top()]=an;st.pop();
		}inq[x]=0;f[x]=an;st.pop();
	}
}
inline bool che(int x)
{
	cnt=1;memset(head,0,sizeof(head));
	dfs(rt,1,2*n);
	for(int i=1;i<=2*n;i++)
	{
		int l=1,r=i-1,mid,tas=i;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(s[b[i]]-s[b[mid]]<x)tas=mid,r=mid-1;
			else l=mid+1;
		}
		if(tas<i)ade(rt,1,2*n,tas,i-1,b[i]);
		l=i+1,r=2*n,tas=i;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(s[b[mid]]-s[b[i]]<x)tas=mid,l=mid+1;
			else r=mid-1;
		}
		if(tas>i)ade(rt,1,2*n,i+1,tas,b[i]);
	}cn=an=0;
	for(register int i=1;i<=js;i++)dfn[i]=low[i]=inq[i]=f[i]=0;
	while(!st.empty())st.pop();
	for(int i=1;i<=js;i++)if(!dfn[i])tarjan(i);
	for(int i=1;i<=n;i++)if(f[i]==f[i+n])return false;
	return true;
}
inline bool cmp(int x,int y){return s[x]<s[y];}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i][0],&a[i][1]),s[i]=a[i][0],s[i+n]=a[i][1];
	for(int i=1;i<=2*n;i++)b[i]=i;
	sort(b+1,b+1+2*n,cmp);
	js=2*n;bt(rt,1,2*n);
	int l=0,r=1e9,mid,ans;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(che(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}printf("%d\n",ans);
}


Measured memory_bytes: 15616
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

string S;

int main(){
  cin >> S;
  int res = 100000;
  for(int i = 0; i < S.length() - 2; i++){
    int now = 100 * (S[i] - '0') + 10 * (S[i+1] - '0') + S[i+2] - '0';
    if(abs(now - 753) < abs(res - 753)){
      res = now;
    }
  }
  cout << abs(res - 753) << endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <unordered_set>

int main() {
  std::unordered_set<std::int_fast32_t> set;
  for (std::int_fast32_t i = 0; i < 3; ++i) {
    std::int_fast32_t a;
    std::cin >> a;
    set.insert(a);
  }
  std::cout << set.size() << std::endl;
  return 0;
}

Measured memory_bytes: 256
import sys

sys.path.append("/home/contestant/.local/lib/python3.8/site-packages")


import networkx as nx

R, C = [int(x) for x in input().split()]
grid = [list(input()) for r in range(R)]


def pack(r, c):
    return r * C + c


graph = nx.Graph()
top_nodes = set()  # top half of the bipartite graph
for r in range(R):
    for c in range(C):
        if r + 1 < R and grid[r][c] == grid[r + 1][c] == ".":
            u, v = pack(r, c), pack(r + 1, c)
            graph.add_edge(u, v)
            if (r + c) % 2 == 0:
                top_nodes.add(v)
            else:
                top_nodes.add(u)
        if c + 1 < C and grid[r][c] == grid[r][c + 1] == ".":
            u, v = pack(r, c), pack(r, c + 1)
            graph.add_edge(u, v)
            if (r + c) % 2 == 0:
                top_nodes.add(v)
            else:
                top_nodes.add(u)


matching = nx.bipartite.maximum_matching(graph, top_nodes=top_nodes)

count = 0
for u, v in matching.items():
    if u > v:
        assert matching[v] == u
        r1, c1 = divmod(u, C)
        r2, c2 = divmod(v, C)
        if r1 == r2:
            if c1 > c2:
                c1, c2 = c2, c1
            grid[r1][c1], grid[r2][c2] = ">", "<"
        elif c1 == c2:
            if r1 > r2:
                r1, r2 = r2, r1
            grid[r1][c1] = "v"
            grid[r2][c2] = "^"
        count += 1

print(count)
for row in grid:
    print("".join(row))



Measured memory_bytes: 133148
function Main(input) {
  var ab = input.split(" ");
  ab[0] = parseInt(ab[0]);
  ab[0] = parseInt(ab[0]);
  if(ab[0]==1){
    ab[0]=14;
  }
  if(ab[1]==1){
    ab[1]=14;
  }
  if (ab[0] > ab[1]) {
    process.stdout.write("Alice");
  } else if (ab[0] < ab[1]) {
    process.stdout.write("Bob");
  } else {
    process.stdout.write("Draw");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 6904
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007



using namespace std;

int main()
{
  int k,x;
  cin>>k>>x;
  if(k*500>=x)cout<<"Yes";
  else cout<<"No";


  return 0 ;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    bool used[1000000] = {};
    std::vector<int> ans;
    for (int i = 2; i <= 55555; i++) {
        if (used[i]) continue;
        if (i % 5 == 1) ans.push_back(i);
        int w = i;
        while (w <= 555555) {
            used[w] = true;
            w += i;
        }
    }
    for (int i = 0; i < n; i++) std::cout << ans[i] << " \n"[i == n - 1];
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct edge{
  ll to,cost;
};
const ll MAX_V=200100;
const ll Inf=1e18;
vector<vector<edge>>E(MAX_V);
ll d[MAX_V];
void dijkstra(ll s){
  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>que;
  fill_n(d,MAX_V,Inf);
  d[s] = 0;
  que.push(pair<ll,ll>(0,s));
  while(!que.empty()){
    pair<ll,ll> p = que.top();
    que.pop();
    ll v = p.second;
    if(d[v] < p.first)continue;
    for(int j = 0;j < E[v].size();j++){
      edge t = E[v][j];
      if(d[t.to] > d[v] + t.cost){
	d[t.to] = d[v] + t.cost;
	que.push(pair<ll,ll>(d[t.to],t.to));
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    E[i].pb({a-1,1});
  }
  dijkstra(0);
  if(d[1] == Inf)cout<<-1<<endl;
  else cout<<d[1]<<endl;
  return 0;
}



Measured memory_bytes: 9600
//Radhe Radhe
#include<bits/stdc++.h>//157B
#define ll long long
#define fixed cout.setf(ios::fixed);
#define rep1    for( i=0; i<n; i++)
#define Precise cout.precision(7);
using namespace std;

int main()
{
    ll n,i,j;
    string s,t,u,uu,v,vv;
    cin>>s;
    t=s;
    reverse(s.begin(),s.end());
    //cout<<s<<" "<<t<<endl;
    if(s==t)
    {
        u=s.substr(0,(s.size()-1)/2);
        uu=u;
        reverse(u.begin(),u.end());
        v=s.substr((s.size()+3)/2-1,(s.size()-1)/2);
        vv=v;
        reverse(v.begin(),v.end());
        if(u==uu&&v==vv)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;

    }
        else
            cout<<"No"<<endl;
    return 0;
}





Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define rint register int
using namespace std;
int n,sum=0;
char a[100005];
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  scanf("%d",&n); sum=n;
  scanf("%s",a+1);
  for(int i=1;i<=n;i++)
    if(a[i]==a[i-1])
      sum--;
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 384
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

xmax = max(x)
ymin = min(y)

if xmax >= ymin or xmax >= Y or ymin <= X:
    print('War')
else:
    print('No War')

Measured memory_bytes: 3060
#include <iostream>
#include <regex>
#include <vector>

using namespace std;



int main(int argc, const char * argv[]) {
    string str;
    cin >> str;
    
    
    int yy[4];
    std::regex regex(R"((\d+)\/(\d+)\/(\d+))");
    std::smatch match;

    if (std::regex_search(str, match, regex))
    {
        int i = 0;
        for (auto m : match)
        {
            yy[i] = atoi(m.str().c_str());
            i++;
            if (i >= 4) { break;}
        }
        
//        cout << yy[1] << " " << yy[2] << " " <<yy[3] <<  endl;
        if (yy[2] >= 5){
            cout << "TBD" << endl;
        }else{
            cout << "Heisei" << endl;
        }
    }
    

    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  ll a,b,c,res = 0;
  cin >> a >> b >> c;
  if(a+b >= c-1)cout << b+c << endl;
  else cout << min(a+b+1,c)+b << endl;
  
  


  

  return 0;
}

Measured memory_bytes: 256
import itertools

n,m,x=list(map(int,input().split()))
C,li=[],[] 
ans=[]
for i in range(n):
  c,*A=list(map(int,input().split()))
  C.append(c)
  li.append(A)
  
for i in itertools.product([0,1],repeat=n):
  money=sum([y*z for (y,z) in zip(C,i)])
  U=[0 for _ in range(m)]
  for k,j in enumerate(i):
    if j:
      U=[x+y for (x,y) in zip(U,li[k])]
  if sum([u >= x for u in U]) == m:
    ans.append(money)
    
if ans == []:
  print("-1")
else:
  print(min(ans))

Measured memory_bytes: 9244
#include <iostream>
#include <map>
#include <queue>
#include <string>

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

using namespace std;

char get_color(char c1, char c2) {
    if ((c1 == 'r' && c2 == 'g') || (c1 == 'g' && c2 == 'r'))
        return 'b';
    else if ((c1 == 'g' && c2 == 'b') || (c1 == 'b' && c2 == 'g'))
        return 'r';
    else
        return 'g';
}

bool is_finish(string s) {
    rep(i, s.size()) if (s[0] != s[i]) return false;
    return true;
}

string s;
void solve() {
    queue<string> worm;
    map<string, int> dict;

    int ans = -1;
    worm.push(s);
    while (worm.size()) {
        string t = worm.front();
        int now = dict[t];
        worm.pop();
        if (is_finish(t)) {
            ans = now;
            break;
        }

        rep(i, t.size() - 1) {
            if (t[i] != t[i + 1]) {
                string next = t;
                next[i] = next[i + 1] = get_color(t[i], t[i + 1]);
                if (dict.count(next) == 0) {
                    // cout << t << " -> " << next << endl;
                    worm.push(next);
                    dict[next] = now + 1;
                }
            }
        }
    }
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
}

int main() {
    while (cin >> s) {
        if (s == "0") break;
        solve();
    }
}

Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int a, p;
    cin >> a >> p;
    p += a*3;
    cout << p/2 << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

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

Measured memory_bytes: 3656
function main(arg) {
  let a = parseInt(arg, 10);
  let counter = 0;
  while (true) {
    counter = counter + 1000;
    if (a <= counter) {
      console.log(counter - a);
      break;
    }
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main(`3000`);
// https://atcoder.jp/contests/abc173/tasks/abc173_a


Measured memory_bytes: 29664
use std::io::Read;

fn heihou(n:usize)->usize{
    let mut i = 1;
    while i*i<n{
        i = i + 1;
    }
    return i;
}

fn calc_point(n:usize)->(usize,usize,usize,usize){
    let hi = heihou(n);
    let sabun = hi * hi - n;
    if sabun < hi {
        return (1,hi,hi,sabun)
    }
    let sabun2 = hi* (hi-1) -n ;
    return (1,hi,hi-1,sabun2)
}

fn main() {
    let inputstr = {
        let mut inputstr = String::new();
        std::io::stdin().read_to_string(&mut inputstr).unwrap();
        inputstr
    };
    let mut inputiter= inputstr.split_whitespace();
    let s =  inputiter.next().unwrap().parse::<usize>().unwrap();
    let p = calc_point(s);
    println!("{} {} {} {} {} {}",0,0,p.0,p.1,p.2,p.3);

}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> vvll;
typedef pair<ll ,ll> pii;
typedef pair<string ,ll> psi;
typedef pair<ll,string > pis;
typedef pair<ll , vll> plv;

#define REP(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define REPR(i,a,b) for(ll i=ll(a);i>=ll(b);--i)
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()

template <typename T> T absolute(T a,T b){ return a>=0?a:-a; }
template <typename T> T sqr(T a){return a*a;}

ll read(){
    ll res,f=1;register char ch;
    while((ch=getchar())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getchar())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}

int main(){
    ll n,cnt=0;
    scanf("%lld",&n);
    ll a[n];ll maxi=0;
    REP(i,0,n-1){
        scanf("%lld",&a[i]);
        if(a[i]>=maxi)cnt++;
        maxi=max(maxi,a[i]);
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-07-24 15:42:24
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , L , trieInd , nxt[MAXN][2] , H[MAXN] , cnt[MAXN];

void insert(string s){
    int cur = 0;
    for(int i = 0 ; i < SZ(s) ; i++){
        int x = s[i] - 48;
        if(nxt[cur][x] == 0)    nxt[cur][x] = ++trieInd , H[trieInd] = H[cur] + 1;
        cur = nxt[cur][x];
    }
}

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

    cin >> n >> L;
    for(int i = 0 ; i < n ; i++){
        string s;
        cin >> s;
        insert(s);
    }
    for(int i = 0 ; i <= trieInd ; i++){
        if(H[i] == L)   continue;
        if(nxt[i][0] == 0)  cnt[__builtin_ctzll(L - H[i])] ^= 1;
        if(nxt[i][1] == 0)  cnt[__builtin_ctzll(L - H[i])] ^= 1;
    }
    int ans = 0;
    for(int i = 0 ; i < MAXN ; i++) ans |= cnt[i];
    if(ans) cout << "Alice" << endl;
    else    cout << "Bob" << endl;

    return 0;
}
/*

*/


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

int main(){
	for(int i = 0;i < 9;++i){
		for(int j = 0;j < 9;++j){
			cout << i + 1 << 'x' << j + 1 << '=' << (i + 1) * (j + 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) A(N + 1);
    READVEC(A);
    VEC(int) S(N);
    READVEC(S);

    lint ret = 0;
    FOR(i, 0, N) {
        int eat = min(S[i], A[i]);
        ret += eat;
        S[i] -= eat;
        A[i] -= eat;
        eat = min(A[i + 1], S[i]);
        ret += eat;
        A[i + 1] -= eat;
    }

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
const int INF=(1<<30)-1;
char s[200001];
int cnt=0,p=INF,q=-1;
inline int min(int a,int b){return a>b?b:a;}
inline int max(int a,int b){return a>b?a:b;}
inline bool isdigit(char a){return (a>='A'&&a<='Z');}
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(register int i=0;i<len;i++)
	{
		if(s[i]=='A') p=min(p,i);
		if(s[i]=='Z') q=max(q,i);
	}
	for(register int i=p;i<=q;i++) if(isdigit(s[i])) cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

#define N 100

int min(int x,int y){
  if(x > y) return y;
  else return x;
}

int main()
{
  int n,i,p[N+1],dp[N+1][N+1],l,j,k,dmy;
  scanf("%d",&n);
  for(i = 0; i < n;i++){
    scanf("%d%d",&p[i],&dmy);
  }
  p[n] = dmy;

  for(i = 1; i <= n; i++) dp[i][i] = 0;

  for(l = 2;l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;
      dp[i][j] = 1000000000;
      for(k = i; k <= j - 1; k++){
	dp[i][j] = min(dp[i][j],dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",dp[1][n]);
  return 0;
}
  



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=1e6+10;
int a[N];

int main(){
	int i,j,k,n;
	string s;
	getline(cin,s);
	cout<<s[0]<<s.size()-2<<s[s.size()-1];
	return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, d, x;
	cin >> n >> d >> x;
	REP(i, n) {
		int a;
		cin >> a;
		x += (d +a-1)/ a;
	}
	cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main()
{
    typedef queue<int> ls;

    int n;
    cin >> n;

    vector<ls> Q(n);

    int q;
    cin >> q;

    while (q)
    {
        int query, t;
        cin >> query >> t;
        ls &l = Q.at(t);
        if (query == 0)
        {
            //整数xを今の末尾に代入
            int x;
            cin >> x;
            l.push(x);
        }
        if (query == 1)
        {
            //次に取り出される要素(First In First Out)つまり先頭を報告
            int begin = l.front();
            //空なら何もしない
            //empty()は？
            if (!l.empty())
            {
                cout << begin << endl;
            }
        }
        if (query == 2)
        {
            //取り出された要素を削除つまり先頭のイテレーターを末尾ので方へずらす
            //先頭の要素を削除
            // int &begin = l.front();
            //空なら何もしない
            if (!l.empty())
            {
                // ls::iterator it = l.begin(); //先頭の要素を指す
                // l.erase(it);
                l.pop();
            }
        }
        q--;
    }
}


Measured memory_bytes: 4368
#include<stdio.h>
int main()
{
	int a,i,j,n[9],s[9];
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
		{
			a=i*j;
			n[i]=i;
			s[j]=j;
			printf("%dx%d=%d\n",n[i],s[j],a);
		}
		return 0;
}

Measured memory_bytes: 524
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [0] * m
for i in range(m):
    ab[i] = list(map(int, input().split()))
check = [1] * n

for i in range(m):
    #低かったほうのチェックリストを0にしていく
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        check[ab[i][0]-1] = 0
        check[ab[i][1] - 1] = 0
    elif h[ab[i][0] - 1] < h[ab[i][1]-1]:
        check[ab[i][0] - 1] = 0
    else:
        check[ab[i][1]-1] = 0
print(sum(check))


Measured memory_bytes: 32012
#include<stdio.h>
int main(void)
{
	int n,a,x,y,z;
	scanf("%d %d",&n,&a);
	x=n%500;
	y=x-a;
	z=n-a;
	if(y<=0 || z<=0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println((s.nextInt()+s.nextInt())%24);


    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
#define rep1(i,n) for(int i=1;i<=int(n);++i)

int n,k,c;
vector<int> make_dp(string s){
    vector<int> dp(n+2);
    rep1(i,n+1){
        if (s[i] == 'o') {
            if (i-c-1 < 0) dp[i] = 1;
            else dp[i] = dp[i-c-1] + 1;
        } else {
            dp[i] = dp[i-1];
        }
    }
    return dp;
}

int main(void){
    cin >> n >> k >> c;
    string s;
    cin >> s;
    if (n == k) {
        rep1(i,n){
            cout << i << endl;
        }
        return 0;
    }
    s = "x" + s + "x";
    auto stepL = make_dp(s);

    string rs = s;
    reverse(all(rs));
    auto stepR = make_dp(rs);
    reverse(all(stepR));

    set<int> res;
    rep1(i,n) {
        if (s[i] == 'o') {
            res.insert(i);
        }
    }
    if (c == 0) {
        if ((int)res.size() == k) {
            for (int d : res) {
                cout << d << endl;
            }
        }
        return 0;
    }
    rep1(i,n+c+1){
        int l = max(0,i-c-1);
        int r = min(n+1,i);
        if (stepL[l] + stepR[r] >= k) {
            while (res.upper_bound(l) != res.end()) {
                if (*res.upper_bound(l) < r) {
                    res.erase(res.upper_bound(l));
                } else {
                    break;
                }
            }
        }
    }
    for (int d : res) {
        cout << d << endl;
    }
    return 0;
}


Measured memory_bytes: 11584
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();

    handle.read_line(&mut buf).unwrap();
    let mut info: Vec<i64> = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
    let mut total = 0;
    if info[0] >= info[2] -1 {
        total += info[2];
        info[2] = 0;
    } else {
        total += info[0];
        info[2] -= info[0];
    }
    if info[1] >= info[2] -1 {
        total += info[2];
        total += info[1];
    } else {
        total += info[1] * 2;
        total += 1;
    }
    println!("{}", total);
}


Measured memory_bytes: 4352
import bisect
N = int(input())
A = list(map(int,input().split()))
if N == 2:
  print(max(A)-min(A))
  print(*A)
  exit()
A.sort()
#print(A)
plus = []
minus = []
for i in range(N):
  if A[i] < 0:
    minus.append(A[i])
  else:
    plus.append(A[i])
minus.sort()
plus.sort()
if len(plus) == 0:
  plus.append(minus.pop(-1))
elif len(minus) == 0:
  minus.append(plus.pop(0))
#print(plus)
#print(minus)
tmp = plus[-1]
tmp2 = minus[-1]
ans = []
cnt = 0
for i in range(len(plus)-1):
  ans.append([tmp2,plus[i]])
  tmp2 -= plus[i]
minus[-1] = tmp2
for i in range(len(minus)):
  ans.append([tmp,minus[i]])
  tmp -= minus[i]
print(tmp)
for i in range(N-1):
  print(*ans[i])
  

Measured memory_bytes: 23224
n = int(input())
a = list(map(int, input().split()))
sum = 0
a.append(max(a))

for i in range (n):
  if a[i + 1] < a[i]:
    sum += a[i] - a[i + 1]
    a[i + 1] = a[i]
    
print(sum)

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

int main() {
  int N; cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; ++i) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  cout << d[N/2] - d[N/2-1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll llINF=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i,n) cin >> p[i].second >> p[i].first;
  sort(p.begin(), p.end());
  ll t = 0;
  rep(i,n) {
    t += p[i].second;
    if (t > p[i].first) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 4828
fn solve() {
    let n = read();
    let v: Vec<char> = read::<String>().chars().collect();
    let mut red_num = 0;
    // R数え
    for i in 0..n {
        if v[i] == 'R' {
            red_num += 1;
        }
    }
    // Rの個数までのWかぞえ
    let mut res = 0;
    for i in 0..red_num {
        if v[i] == 'W' {
            res += 1;
        }
    }
    println!("{}", res);
}

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

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 3 4");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3 2 3");
            //5
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int P = wkArr[0];
        int Q = wkArr[1];
        int R = wkArr[2];

        var Kouho = new List<int>();
        Kouho.Add(P + Q);
        Kouho.Add(P + R);
        Kouho.Add(Q + R);
        Console.WriteLine(Kouho.Min());
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define out(a) cout<<a<<" "
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int ctoi(const 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 -1;
    }
}

int main() {
    string s;
    int n,mod;
    mod=1000000007;
    cin >> s;
    n=s.size();
    vector<vector<int>> dp(100005,vector<int>(13));
    dp[0][0]=1;
    for (int i=1;i<=n;i++){
        if (s[i-1]=='?'){
            rep(j,13)rep(k,10){
                dp[i][(j*10+k)%13]+=dp[i-1][j];
                dp[i][(j*10+k)%13]%=mod;
            }
        }else{
            int num=ctoi(s[i-1]);
            rep(j,13){
                dp[i][(j*10+num)%13]+=dp[i-1][j];
                dp[i][(j*10+num)%13]%=mod;
            }
        }
    }
cout << dp[n][5] << endl;
return 0;
}

Measured memory_bytes: 8960
#include "bits/stdc++.h"
using namespace std;
int st[100];
int ptr=0;
int pop(void) {
	return st[--ptr];
}
void push(int op) {
	st[ptr++]=op;
}
int main() {
	char s[10];
	while(scanf("%s",s)!=EOF) {
		if(isdigit(s[0])) {
			int op;
			sscanf(s,"%d",&op);
			push(op);
		}else {
			int op2=pop(),op1=pop();
			switch(s[0]) {
			case '+':push(op1+op2);break;
			case '-':push(op1-op2);break;
			case '*':push(op1*op2);break;
			}
		}
	}
	printf("%d\n",pop());
}

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

int main(int argc, char **argv){
	int **array;
	int n;
	
	while(1){
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		
		array = (int **)calloc(n+1, sizeof(int));
		for(int i = 0; i <= n; i++){
			array[i] = (int *)calloc(n+1, sizeof(int));
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				scanf("%d", &array[i][j]);
				
				array[i][n] += array[i][j];
			}
		}
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j < n; j++){
				array[n][i] += array[j][i];
			}
			array[n][n] += array[n][i];
		}
		array[n][n] /= 4;
		
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				printf("%5d", array[i][j]);
			}
			printf("\n");
		}
		
		for(int i = 0; i <= n; i++){
			free(array[i]);
		}
		free(array);
	}
	
	
	return 0;
}

Measured memory_bytes: 0
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const ll N = 61, P = 1e18 + 7;
int n, k, num1[N], num2[N], n1, n2;
ll ans, f[N][N * N], g[N][N * N]; 
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); k = read();
	for (int i = 1; i <= n; i++){
		int x = read();
		if (x >= k) num1[++n1] = x - k;
			else num2[++n2] = k - x;
	}
	f[0][0] = 1; g[0][0] = 1;
	int sum1 = 0, sum2 = 0;
	for (int i = 1; i <= n1; i++){
		for (int j = 0; j <= sum1; j++){
			f[i][j + num1[i]] = (f[i][j + num1[i]] + f[i - 1][j]) % P;
			f[i][j] = (f[i][j] + f[i - 1][j]) % P;
		}
		sum1 += num1[i];
	}
	for (int i = 1; i <= n2; i++){
		for (int j = 0; j <= sum2; j++){
			g[i][j + num2[i]] = (g[i][j + num2[i]] + g[i - 1][j]) % P;
			g[i][j] = (g[i][j] + g[i - 1][j]) % P;
		}
		sum2 += num2[i];
	}
	for (int i = 0; i <= min(sum1, sum2); i++)
		ans = (ans + f[n1][i] * g[n2][i]) % P;
	ans = (ans - 1 + P) % P;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 896
import java.util.*;

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

    int result = 0 ;

    for(int i = 0 ; i < N ; i ++){
      if( i < K ){
        result = result + X;
      }else{
        result = result + Y;
      }
    }
    System.out.println(result);

  }
}


Measured memory_bytes: 23636
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>

typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N,K;
	cin >> N >> K;
	ll ans = 0;
	for (ll i = K; i <= N + 1; i++)
	{
		ll farst = i * (i - 1) / 2;
		ll last = i * (2 * N - i + 1) / 2;
		ll add = last - farst + 1;
		ans = (ans + add)%mod;
	}

		cout << ans << endl;
	
	
	
	return 0;

}

Measured memory_bytes: 3656
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int[] a = new int[N+1];
		for(int i = 1; i <= N; i++) a[i] = sc.nextInt();
		
		long[][] dp = new long[N+1][21];
		
		dp[1][a[1]] = 1;
		
		for(int i = 2; i < N; i++){
			for(int j = 0; j <= 20; j++){
				if(j + a[i] >= 0 && j + a[i] <= 20)
					dp[i][j + a[i]] += dp[i-1][j];
				if(j - a[i] >= 0 && j - a[i] <= 20)
					dp[i][j - a[i]] += dp[i-1][j];
			}
		}
		
		System.out.println(dp[N-1][a[N]]);
	}
}


class Queue{
	int n;
	int p, q, r;
	public Queue(int n, int p, int q, int r){
		this.n = n;
		this.p = p;
		this.q = q;
		this.r = r;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}



Measured memory_bytes: 24432
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	for (int i = M / N; i > 0; i--) {
		int n = M / i;
		if (n * i == M) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3520
ls = [[[0 for i in range(10)] for j in range(3)]for s in range(4)]
n = int(input())
for g in range(0,n):
    b,f,r,v = map(int,input().split())
    ls[b-1][f-1][r-1] += v
for k in range(0,4):
    if k == 0:
        pass
    else:
        print("####################")
    for z in range(0,3):
        lis = ""
        for s in range(0,10):
            lis += " "+str(ls[k][z][s])
        print(lis)

Measured memory_bytes: 7732
#include<stdio.h>
int main(void)
{
    int S=0;
    int h,m,s;
    scanf("%d",&S);
    h=(int)S/3600;
    m=(int)(S%3600)/60;
    s=(int)(S-h*3600-m*60);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int[] num = new int[11];
		for(int i = 0; i < 3; i++)
			num[GetInt()]++;
		Console.WriteLine((num[5] == 2) && (num[7] == 1) ? "YES" : "NO");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

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

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

ll n;
ll l[MAXX];

int main()
{
    _FastIO;

    ll x , k , d;
    cin >> x >> k >> d;
    x = abs(x);
    ll p = x / d;
    if(p >= k){
        x -= (k * d);
       k = 0;
    }
    else{
        x %= d;
        k -= p;
    }
    if(!k){
        cout << x << endl;
        return 0;
    }
    if(k % 2){
        cout << abs(x - d) << endl;
        return 0;
    }
    cout << x << endl;
    return 0;
}
	

Measured memory_bytes: 3648