akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
	int N;
	int A[210];
	int counter = 0;
	int end = 0;
	cin >> N;

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



			if (A[i] % 2 == 1) {
				++end;
				--counter;
				break;

			}
			if (A[i] % 2 == 0) {
				A[i] = A[i] / 2;
			}

		}
		++counter;


	}
	cout << counter;//答え
}


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

ll ans = 0;
int m[500][500];
char s[500][500];
ll bk = 0;
ll wh = 0;
int h, w;

void dfs(int x, int y, char be){
	if(x < 0 || y < 0 || x >= h || y >= w) return;
	if(m[x][y] == 1) return;
	if(be != s[x][y]){
		if(s[x][y] == '#'){
			bk++;
		}else{
			wh++;
		}
	}else{
		return;
	}
	m[x][y] = 1;
	//cout << x << y << " " << bk << wh << endl;
	dfs(x + 1, y, s[x][y]);
	dfs(x, y + 1, s[x][y]);
	dfs(x - 1, y, s[x][y]);
	dfs(x, y - 1, s[x][y]);
}

int main(void){

	cin >> h >> w;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			dfs(i, j, 'x');
			ans += bk * wh;
			//cout << bk << wh << endl;
			bk = 0;
			wh = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8704
n = int(input())
ans = int(1)
a = input().split(" ")

if "0" in a:
  ans = 0
else:
  for i in range(n):
    ans *= int(a[i])
    if ans > 10**18:
      print("-1")
      break
    
if ans <= 10**18:
  print(ans)

Measured memory_bytes: 19408
#include<iostream>
using namespace std;
int main()
{
  int a, b, c;
  cin >>a >>b >>c;
  if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a== 7 && b == 5 && c == 5)){
  cout << "YES" << endl;
  }
  else{
  cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int cnts[111][30];

int main() {
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++) {
        cnts[i][a[i] - 'a']++;
        cnts[i][b[i] - 'a']++;
        cnts[i][c[i] - 'a']++;
    }
    string s;
    for (int i = 0; i < n; i++) {
        int maxv = 0, idx = 0;
        for (int j = 0; j < 30; j++) {
            if (maxv < cnts[i][j]) {
                maxv = cnts[i][j];
                idx = j;
            }
        }
        s += (idx + 'a');
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != s[i]) ans++;
        if (b[i] != s[i]) ans++;
        if (c[i] != s[i]) ans++;
    }
    cout << ans << endl;
}

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

void fnInput(int64_t& rnNum)
{
  cin >> rnNum;
}

int fnDigitsCheck(int64_t nDivisor)
{
  int nDigitCnt = 0;
  while (nDivisor)
  {
    nDigitCnt++;
    nDivisor /= 10;
  }

  return nDigitCnt;
}

int fnMultiplCheck(int64_t nNum)
{
  int nMinDigit = fnDigitsCheck(nNum);

  for (int64_t n = 1; n * n <= nNum; n++)
  {
    if (nNum % n != 0)  continue;
    int64_t nOtr = nNum / n;
    nMinDigit = min(nMinDigit, fnDigitsCheck(nOtr));
  }
  return nMinDigit;
}

int main()
{
  int64_t nNum;
  
  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << endl;

  return 0;
}

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

#define int long long

#define F first
#define S second
#define all(x) (x).begin(), (x).end()

using namespace std;

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

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    int d[n], h[n];
    for(int i = 0; i < n; i++)
        cin >> h[i], d[i] = INT_MAX;
    d[0] = 0;
    for(int i = 1; i < n; i++)
        for(int j = i-1; j >= 0 && i-j <= k; j--)
            d[i] = min(d[i], d[j] + abs(h[i] - h[j]));
    cout << d[n-1];

    return 0;
}


Measured memory_bytes: 5184
def solve():
    N, K = map(int, input().split())
    mod = 10**9+7

    increments = []

    for i in range(N+1):
        increments.append(i)

    accumulation = [0]*(N+2)
    accumulationReverse = [0]*(N+2)

    for i in range(0, N+1):
        accumulation[i+1] = accumulation[i] + increments[i]
        accumulationReverse[i+1] = accumulationReverse[i] + increments[N-i]

    ans = 0

    for i in range(K, N+2):
        ans += accumulationReverse[i]-accumulation[i] + 1

    print(ans % mod)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 82384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ls(x) (son[x][0])
#define rs(x) (son[x][1])
#define lv(x) (val[x][0])
#define rv(x) (val[x][1])
#define pll pair<ll,ll>
#define MP make_pair
#define PB push_back
#define fi first
#define se second
const int N=1e6+5;
int son[N][2],val[N][2],fa[N],n;
ll pre[N],mv;
vector<pll >f[N];
bool cmp(pll a,pll b){return a.se<b.se;}
void dfs(int u)
{
    f[u].clear();int l=ls(u),r=rs(u);
    if(!l){f[u].PB(MP(0,0));return;}
    dfs(l),dfs(r);
    for(int i=0;i<f[l].size();i++)f[l][i].fi+=lv(u),f[l][i].se+=lv(u);
    for(int i=0;i<f[r].size();i++)f[r][i].fi+=rv(u),f[r][i].se+=rv(u);
    if(f[l].size()>f[r].size())swap(f[l],f[r]);
    sort(f[l].begin(),f[l].end(),cmp),sort(f[r].begin(),f[r].end());
    pre[0]=f[r][0].se;for(int i=1;i<f[r].size();i++)pre[i]=min(pre[i-1],f[r][i].se);
    for(int l1=0,r1=f[r].size()-1;l1<f[l].size();l1++)
    {
        while(r1>=0&&f[r][r1].fi+f[l][l1].se>mv)r1--;
        if(r1<0)break;f[u].PB(MP(f[l][l1].fi,pre[r1]));
    }
    sort(f[l].begin(),f[l].end()),sort(f[r].begin(),f[r].end(),cmp);
    pre[0]=f[r][0].fi;for(int i=1;i<f[r].size();i++)pre[i]=min(pre[i-1],f[r][i].fi);
    for(int l1=0,r1=f[r].size()-1;l1<f[l].size();l1++)
    {
        while(r1>=0&&f[r][r1].se+f[l][l1].fi>mv)r1--;
        if(r1<0)break;f[u].PB(MP(pre[r1],f[l][l1].se));
    }
}
bool cal(ll md){mv=md;dfs(1);return f[1].size()!=0;}
int main()
{
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        ls(x)?(rs(x)=i,rv(x)=y):(ls(x)=i,lv(x)=y);
    }
    ll l=0,r=1e10+1,mid,ans;
    while(l<=r){mid=l+r>>1;cal(mid)?(r=mid-1,ans=mid):l=mid+1;}
    printf("%lld\n",ans);
}


Measured memory_bytes: 49112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

// union-find
struct union_find {
    vector<int> data;

    union_find(int size) {data.resize(size,-1);}

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

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

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

int main() {
    int n, m; cin >> n >> m;
    union_find uf(n);
    int ans = n - 1;
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (uf.unite(a,b)) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3768
fn main() {
    proconio::input! {
        n: usize,
        m: i32,
        q: usize,
        abcd: [(usize,usize,i32,i32);q],
    }
    let mut e = vec![1i32;n+1];
    e[n]=m;
    println!("{}",f(n, m, &abcd, 2, &mut e));
}
fn f(n: usize, m: i32, abcd: &Vec<(usize,usize,i32,i32)>, i: usize, e: &mut Vec<i32>) -> i32 {
    let mut t=0;
    if i==n+1 {
        for &(a,b,c,d) in abcd {
            if e[b]-e[a]==c {
                t+=d;
            }
        }
    }
    else {
        for j in e[i-1]..m+1 {
            e[i]=j;
            t = std::cmp::max(t,f(n,m,abcd,i+1,e));
        }
    }
    t
}

Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>
#include <iomanip>

#define vec vector

using namespace std;

using ll = long long;
using vl = vector<long long>;
using vi = vector<int>;
using vvl = vector<vl>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using ld = long double;

int n;
vl a, h, dp_stree;

ll query(int l, int r)
{
    ll res = 0;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
    {
        if (l & 1)
            res = max(res, dp_stree[l++]);
        if (r & 1)
            res = max(res, dp_stree[--r]);
    }
    return res;
}

void update(int p, ll v)
{
    for (dp_stree[p += n] = v; p > 1; p >>= 1)
        dp_stree[p >> 1] = max(dp_stree[p], dp_stree[p ^ 1]);
}

int main()
{
    cin >> n;
    h = vl(n);
    a = vl(n);
    for (auto &e : h)
        cin >> e;
    for (auto &e : a)
        cin >> e;
    dp_stree = vl(2 * (n + 1), 0);
    for (int i = 0; i < n; i++)
    {
        ll m = query(1, h[i]);
        if (m + a[i] > query(h[i], h[i] + 1))
            update(h[i], m + a[i]);
    }
    cout << query(1, n + 1);
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
long long MOD=(long long)(1e9+7);
vector<int> graph[(int)(1e5+7)];
vector<vector<long long>>dp((int)1e5+7,vector<long long>(2,1));
int visited[(int)(1e5+7)];
void dfs(int v)
{

    for(auto j:graph[v])
    {
    if(!visited[j])
    {
    visited[j]=1;
    dfs(j);
    dp[v][0]=(((dp[j][1]+dp[j][0])%MOD)*(dp[v][0]))%MOD;
    dp[v][1]=(dp[v][1]*dp[j][0])%MOD;
    }
    }

}
int main()
{int n;
cin>>n;
//memset(dp,1,2*sizeof(int)*(1e5+7));

for(int i=0;i<n-1;i++)
{
    int x,y;
    cin>>x>>y;
graph[x].push_back(y);
graph[y].push_back(x);


}
visited[1]=1;
dfs(1);

cout<<(dp[1][1]+dp[1][0])%MOD<<endl;


}

Measured memory_bytes: 15744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  std::string str;
  std::cin >> str;
  
  std::vector<int> counts(N+1, 0);
  for (int i=0; i<N; i++) {
    if (str[i] == '.') counts[0]++;
  }
  
  for (int i=0; i<N; i++) {
    if (str[i] == '#') {
      counts[i+1] = counts[i] + 1;
    } else {
      counts[i+1] = counts[i] - 1;
    }
  }
  
  std::cout << *std::min_element(std::begin(counts), std::end(counts)) << std::endl;
}

Measured memory_bytes: 1412
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

int main(){
    bool **A;
    int i, j, k, l, n, u;
    scanf("%d", &n);
    A = malloc(sizeof(bool*) * n);
    for(l = 0; l < n; l++){
        A[l] = malloc(sizeof(bool) * n);
        for(k = 0; k < n; k++){
            A[l][k] = false;
        }
    }
    for(l = 0; l < n; l++){
        scanf("%d%d", &u, &k);
        for(j = 0; j < k; j++){
            scanf("%d", &i);
            A[u - 1][i - 1] = true;
        }
    }
    for(l = 0; l < n; l++){
        for(j = 0; j < n; j++){
            printf("%d", A[l][j]);
            if(j != n - 1){
                printf(" ");
            }
        }
        printf("\n");
    }
    for(l = 0; l < n; l++){
        free(A[l]);
    }
    free(A);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string ans = "APPROVED";
  rep(i, n) {
    int x;
    cin >> x;
    if (x % 2 == 0) {
      if (x % 3 != 0 && x % 5 != 0) ans = "DENIED";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#define PI acos(-1.0)
using namespace std;
int main(){
	long long r,d,x;
	cin >> r >>d >> x;
	int t = 10;
	while(t--){
		x = r * x - d;
		cout << x << endl;
	}
}

Measured memory_bytes: 1016
#include <stdio.h>
#include <iostream>

using namespace std;
const int mod = 1000000007;
int n,a[201001],jc[201001],t[201010],inv[201010],njc[201010],x;
inline int C(int N,int M) {
	if (M < 0||M > N)
		return 0;
	return (long long)jc[N]*njc[N-M]%mod*njc[M]%mod;
}
int main() {
	inv[1] = jc[0] = njc[0] = 1;
	for (int i = 2;i <= 110001; i++)
		inv[i] = 1LL*inv[mod%i]*(mod-mod/i)%mod;
	for (int i = 1;i <= 110101; i++) {
		jc[i] = (long long)jc[i-1]*i%mod;
		njc[i] = (long long)njc[i-1]*inv[i]%mod;
	}
	scanf("%d",&n);
	for (int i = 1;i <= n+1; i++) {
		scanf("%d",&a[i]);
		if (!t[a[i]])
			t[a[i]] = i;
		else
			x = n+1-(i-t[a[i]]+1);
	}
	for (int i = 1;i <= n+1; i++)
		printf("%d\n",(C(n+1,i)-C(x,i-1)+mod)%mod);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C,u,t;
	scanf("%d%d%d",&A,&B,&C);
	t=B;
	u=C;
	B=A;
	C=t;
	A=u;
	printf("%d %d %d",A,B,C);
	return 0;
}

Measured memory_bytes: 256
S = input()
flg = False

num = len(S)
if num == 2 and S == 'hi':
    flg = True
if num == 4 and S == 'hihi':
    flg = True
if num == 6 and S == 'hihihi':
    flg = True
if num == 8 and S == 'hihihihi':
    flg = True
if num == 10 and S == 'hihihihihi':
    flg = True

if flg == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s,t;
  cin >> s >> t;
  int ans = INF;
  int n = s.size();
  int m = t.size();
  rep(i,n-m+1){
    int c = 0;
    rep(j,m)if(s[i+j]!=t[j])c++;
    chmin(ans,c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
while True:
    s1,s2,s3=input().split()
    a=int(s1)
    b=int(s3)
    if s2=="?":
        break
    elif s2=="+":
        print(a+b)
    elif s2=="-":
        print(a-b)
    elif s2=="*":
        print(a*b)
    elif s2=="/":
        print(int(a/b))
    


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

using namespace std;

#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=b-1;i>=a;--i)
typedef long long ll;
/////////////////////

int const N = 61;

ll a, b, ans;
int p, pl1;

ll solveA(){
	ll ret = 1;
	per(i, 0, p){
		if((1LL << i) & a){
			continue;
		}
		ret += (1LL << i);
	}
	return ret;
}

ll solveB(){
	ll ret = (1LL << (pl1 + 1));
	return ret;
}

ll solveAB(){
	ll ret = 0;
	bool haveOne = false;
	rep(i, pl1+1, p) if( (1LL << i) & a) haveOne = true;
	int l = pl1+1;
	if(haveOne){
		l = 0;
		ret = 1;
	}
	per(i, l, p){
		if( !((1LL << i) & a) ) ret += (1LL << i);
	}

	return ret;
}

void solve(){
	a, b;
	cin >> a >> b;
	if(a == b){
		cout << 1 << endl;
		return;
	}
	p = -1;
	per(i, 0, N) if( ((1LL << i) & b) ^ ((1LL << i) & a)){
		p = i;
		break;
	}
	pl1 = -1;
	per(i, 0, p) if( (1LL << i) &  b){
		pl1 = i;
		break;
	}
	ans += solveA();
	ans += solveB();
	ans += solveAB();

	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	double T, X; cin >> T >> X;
	printf("%.10f", T / X);


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;


signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m), y(m);
    rep(i, 0, m){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    int ans = 0;
    vector<int> d(n, 1);
    bool f[100010];
    memset(f, false, sizeof(f));
    f[0] = true;
    rep(i, 0, m){
        if(f[x[i]]){
            if(d[x[i]] == 1) f[x[i]] = false;
            f[y[i]] = true;
        }
        d[x[i]]--;
        d[y[i]]++;
    }
    rep(i, 0, n){
        if(f[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2688
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <tuple>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const ll INF = 2147483647;
#define rep(i, n) rep3(i, 0, n)
#define rep2(i, n) rep3(i, 1, n+1)
#define rep3(i, x, n) for(ll i = x; i < (ll)(n); i++)

template<class T>
void printv(vector<T> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}
template<class T>
void printp(vector<pair<T,T>> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << (*it).first << "," << (*it).second << endl;
    }
    cout << endl;
}
template<class T>
void printp(map<T,T> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << (*it).first << "," << (*it).second << endl;
    }
    cout << endl;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int main() {
    int ans;
    cin>>ans;
    cout << (1000-ans%1000)%1000;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define   ll   long long int
#define   sz   300010

const ll md=1000000000+7;

using namespace std;


ll num[sz];

int main()
{

     ll n,m,a,b,i,j,k,p=1,y,d;


     cin>>n;

     for(i=1;i<=n;i++)
     {
         cin>>num[i];
     }

     ll s=0;


     for(i=0;i<=61;i++)
     {
         a=0;
         b=0;

         for(j=1;j<=n;j++)
         {
             if(num[j]%2==0)a++;
             else
                b++;

             num[j]/=2;
         }
        ll x=(p<<i)%md;


        s = (s%md+(x*(a%md*b%md)%md)%md)%md;

     }
     cout<<s<<endl;


    return 0;
}



Measured memory_bytes: 2560
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			char[] s = sc.next().toCharArray();
			Arrays.sort(s);
			String ss = new String(s);
			Integer cnt = map.get(ss);
			if (cnt == null) cnt = 0;
			map.put(ss, cnt + 1);
		}
		long ans = 0;
		for (long x: map.values()) {
			ans += x * (x - 1) / 2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 53296
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};


ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll N;
bool a[22][22];
ll female[22][1<<22];

int main(){
  cin >> N;
  rep(i, N)rep(j, N) cin >> a[i][j];
  female[0][(1<<N)-1] = 1;
  rep(i, N){
    ll comb = (1<<(N-i))-1;
    while(comb < (1 << N)){
      rep(j, N){
        if(a[i][j] && (comb>>j) & 1){
          female[i+1][comb & ~(1<<j)] += female[i][comb];
          female[i+1][comb & ~(1<<j)] %= MOD;
        }
      }
      ll x = comb & -comb, y = comb + x;
      comb = ((comb & ~y) / x >> 1) | y;
    }
  }
  cout << female[N][0] << endl;
}


Measured memory_bytes: 327936
#include<iostream>
using namespace std;
int main()
{
	int n,A[100];
	cin>>n;
	for(int i=0 ; i<n ; i++)
	{
		int a;
		cin>>a;
		A[i] = a;
	}
	for(int i=0 ; i<n ; i++)
	{
		cout<<A[i];
		if(i != n-1)
		{
			cout<<" ";
		}
	}
	cout<<endl;
	for(int i=1 ; i<n ; i++)
	{
		int c = A[i];
		int j = i-1;
		while(j >= 0 && A[j] > c)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = c;
		for(int k=0 ; k<n ; k++)
		{
			cout<<A[k];
			if(k != n-1)
		{
			cout<<" ";
		}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main()
{
	long long int h,w;
	cin>>h>>w;
	long long int ans = (h*w)/2;
	if((h*w)%2==1)
	{
		ans += 1;
	}
	if(h!=1&&w!=1)
	{
		cout<<ans<<endl;
	}
	else
	{
		cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import string
s = input()
k = string.ascii_letters
alist = [0]*26
for i in s:
    alist[ord(i)-ord("a")] = 1
c = -1
for i in range(26):
    if alist[i] == 0:
        c = i
        break    
if c == -1:
    print("None")
else:
    print(k[c])


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	vector<int>h(n);
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	int ans = 0;
	int temp_ans = 0;
	for(int i = 0; i < n - 1; i++){
		if(h[i] >= h[i+1]){
			temp_ans += 1;
			if(i == n - 2)ans = max(temp_ans, ans);
		}else if(h[i] < h[i + 1]){
			ans = max(temp_ans, ans);
			temp_ans = 0;

		}
	}
	cout << ans << endl;
}


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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

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

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int n, x;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> x;
        s.insert(x);
    }
    if (s.size() == n) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;
const int Mod = 1e9 + 7;
const int Maxn = 1.5 * 1e5;

int N, M;

ll PowMod(ll a, int b) {
    ll ret = 1;
    while (b) {
        if (b & 1) ret = ret * a % Mod;
        a = a * a % Mod;
        b >>= 1;
    }
    return ret;
}

ll f[Maxn + 5];
ll inv[Maxn + 5];

void Prepare() {
    f[0] = 1;
    for (int i = 1; i <= Maxn; ++i) {
        f[i] = f[i - 1] * i % Mod;
    }
    inv[0] = 1;
    inv[Maxn] = PowMod(f[Maxn], Mod - 2);
    for (int i = Maxn - 1; i > 0; --i) {
        inv[i] = inv[i + 1] * (i + 1) % Mod;
    }
}

ll F(int a, int b) {
    return f[a + b - 1] * inv[a - 1] % Mod * inv[b] % Mod;
}

int main() {
    scanf("%d %d", &N, &M);
    Prepare();
    int lim = sqrt(M);
    ll ans = 1;
    for (int i = 2;i <= lim; ++i) {
        if (M % i == 0) {
            int cnt = 0;
            while (M % i == 0) {
                M /= i, cnt++;
            }
            ans = ans * F(N, cnt) % Mod;
        }
    }
    if (M != 1) ans = ans * N % Mod;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

//-----------------//
  #define amin main
//-----------------//

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}



ll maxProfit(ll price[], ll n)
{
	ll cur = 1000;
	
	ll profit = 1000;


	ll j = 0;

	
	for (ll i = 1; i < n; i++)
	{
		// update local minimum if decreasing sequence is found
		if (price[i - 1] > price[i]) {
			j = i;
		}

		// sell shares if current element is peak
		// i.e. (previous <= current > next)
		if (price[i - 1] <= price[i] &&
			(i + 1 == n || price[i] > price[i + 1]))
		{
			ll no = profit/price[j];
			profit -= no*price[j];

			profit +=  no*price[i];
			//printf("Buy on day %d and sell on day %d\n", j + 1, i + 1);
		}
	}

	return profit;
}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n,k;
	cin>>n;
	ll arr[n];
	for(i=0;i<n;i++)
		cin>>arr[i];
	ll x = maxProfit(arr,n);
	cout<<x<<endl;

	


	


	
	

	
	


	
	return 0;
}

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

int main() {
  int H, W, count = 0;
  string S[50];
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    cin >> S[i];
  }
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(S[i].at(j) == '#') continue;
      if((i != 0) && (j != 0) && (S[i - 1].at(j - 1) == '#')) count++;
      if((i != 0) && (S[i - 1].at(j) == '#')) count++;
      if((i != 0) && (j != (W - 1)) && (S[i - 1].at(j + 1) == '#')) count++;
      if((j != 0) && (S[i].at(j - 1) == '#')) count++;
      if((j != (W - 1)) && (S[i].at(j + 1) == '#')) count++;
      if((i != (H - 1)) && (j != 0) && (S[i + 1].at(j - 1) == '#')) count++;
      if((i != (H - 1)) && (S[i + 1].at(j) == '#')) count++;
      if((i != (H - 1)) && (j != (W - 1)) && (S[i + 1].at(j + 1) == '#')) count++;
      if(count == 0) S[i].at(j) = '0';
      if(count == 1) S[i].at(j) = '1';
      if(count == 2) S[i].at(j) = '2';
      if(count == 3) S[i].at(j) = '3';
      if(count == 4) S[i].at(j) = '4';
      if(count == 5) S[i].at(j) = '5';
      if(count == 6) S[i].at(j) = '6';
      if(count == 7) S[i].at(j) = '7';
      if(count == 8) S[i].at(j) = '8';
      count = 0;
    }
    cout << S[i] << endl;
  }
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
b = 0
res = 0
for i in s:
    if i == 'B':
        b += 1
    else:
        res += b
print(res)

Measured memory_bytes: 44264
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    try(BufferedReader reader
        = new BufferedReader(new InputStreamReader(System.in))
    ){
      int a = Integer.parseInt(reader.readLine());
      int b = Integer.parseInt(reader.readLine());
      int h = Integer.parseInt(reader.readLine());
      
      System.out.println((a + b) * h / 2);
    }
  }
}

Measured memory_bytes: 21204
import java.util.*;
import java.io.*;

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        int x = nextInt();
        int n = nextInt();
        int[] p = nextIntArr(n);
        Set<Integer> has = new HashSet<>();
        for (int v : p) {
            has.add(v);
        }
        int diff = Integer.MAX_VALUE;
        int res = -1;
        for (int i = -1; i < 1000; i++) {
            if (has.contains(i)) {
                continue;
            }
            int tmp = Math.abs(i - x);
            if (tmp < diff) {
                diff = tmp;
                res = i;
            }
        }
        outln(res);
    }



    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  ll N;
  cin >> N;

  vll ret;

  ll a = 1;
  while (true) {
    ll M = N-a;
    if (M<=0) break;

    ll m = M/a;
    if (a>=m) break;
    if (M%a==0) {
      ret.emplace_back(m);
    }
    a++;
  }

  cout << accumulate(begin(ret), end(ret), 0ll) << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, 0, N){
        cin >> C.at(i);
        rep(j, 0, M){
            cin >> A.at(i).at(j);
        }
    }
    int ans = INF;
    rep(tmp, 0, 1 << 12){
        bitset<12> s(tmp);
        int cost = 0;
        vector<int> reach(M, 0);
        bool can = true;
        rep(i, 0, N){
            if (s.test(i)){
                cost += C.at(i);
                rep(j, 0, M){
                    reach.at(j) += A.at(i).at(j);
                }
            }
        }
        rep(j, 0, M){
            if (reach.at(j) < X) can = false;
        }
        if (can){
            ans = min(ans, cost);
        }
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int n, a;
ll dp[55][55][2555] = {0};

int main () {
  cin >> n >> a;
  vi x(n);
  rep(i,n) cin >> x[i];

  dp[0][0][0] = 1;
  rep(s,2555) {
    rep(k,n+1) {
      rep(j,n+1) {
        if (j >= 1 && s < x[j-1]) {
          dp[j][k][s] = dp[j-1][k][s];
        }
        if (j >= 1 && k >= 1 && s >= x[j-1]) {
          dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]];
        }
      }
    }
  }

  ll ans = 0;
  FOR(k,1,n+1) {
    ans += dp[n][k][k*a];
  }

  cout << ans << endl;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


    string s;
    cin >> s;

    int ans = 0;

    for(int i = 0; i < s.size(); i++)
    {
      string str = "";

      for(int j = i; j < s.size(); j++)
      {
        if(s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or s[j] == 'T')
        {
          str += s[j];
        }
        else
        {
          break;
        }
      }
      ans = max(ans,(int)str.size());
    }

    cout << ans;


    


    return 0; 
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM 1e18
#define mod 1000000007
#define FOR(i,j,n)    for(ll i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

ll calculate(ll x){
    ll count = 0;
    while((x & 1) == 0){
        count++;
        x = x >> 1;
    }
    return count;
}

int main(){
    ll n,a,ans = 0;
    cin>>n;
    while(n--){
        cin>>a;
        ans += calculate(a);
    }
    cout<<ans<<endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  int64_t ans = 0, p = 1;

  while (p <= n) {
    p *= k;
    ans++;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
unsigned long long A,C;
double B;
int main(){
cin>>A>>B;
C=B*1000;
C=C*A/1000;
cout<<C<<endl;
return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()



int main(){
  ll N,M;
  cin >> N >> M;
  scc_graph g(N);
  rep(i,M){
    ll a,b;
    cin >> a >> b;
    g.add_edge(a,b);
  }
  auto A=g.scc();
  cout << A.size() << endl;
  rep(i,A.size()){
    cout << A.at(i).size();
    rep(j,A.at(i).size()){
      cout << " " << A.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 40092
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int cakes, donuts;
  for(cakes=0; cakes <= N/4; ++cakes){
    for(donuts=0; donuts <=N/7; ++donuts){
      if(N == (cakes*4+donuts*7)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

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


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
   
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let mut it = buf.split_whitespace().map(|n| i32::from_str(n).unwrap());
    let W = it.next().unwrap();
    let H = it.next().unwrap();
    let x = it.next().unwrap();
    let y = it.next().unwrap();
    let r = it.next().unwrap();

    if x-r<0{
        println!("No");
    }else if x+r>W{
        println!("No");
    }else if y-r<0{
        println!("No");
    }else if y+r>H{
        println!("No");
    }else{
        println!("Yes");
    }

}


Measured memory_bytes: 5024
import sys
input = sys.stdin.readline

mod = 10**9 + 7
N, C = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
dp = [0] * (C + 1)
dp[0] = 1
for i in range(N):
    X = [0] * (C + 1)
    for j in range(A[i], B[i] + 1):
        x = 1
        for k in range(C+1):
            X[k] = (X[k] + x) % mod
            x = x * j % mod
    ndp = [0] * (C + 1)
    for j in range(C+1):
        for k in range(C+1-j):
            ndp[j + k] = (ndp[j + k] + dp[j] * X[k]) % mod
    dp = ndp
print(dp[C])

Measured memory_bytes: 74008
#include<stdio.h>

int main(){
  int a,b,c,w;
  
  scanf("%d",&a);
  scanf("%d",&b);  
  scanf("%d",&c);
  
  w=a-b;
  
  while(w>0 && c>0){
    w--;
    c--;
  }
  printf("%d",c);
  
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int i,n,m,a[10000],ans=-1;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&a[i]);
        n -= a[i];
    }
    if(n>=0) ans = n;
    printf("%d\n",ans);
    return 0;
}

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

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

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))
#define INF (1<<28)
#define pb(i) push_back(i)
#define fs first
#define sc second

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

int main(){
	int n;
	cin >> n;
		vi a(n);
	rep(i,n) cin >> a[i];

	int cur = 2;
	ll cnt = 0;
	cnt = a[0] -1;
	a[0] = 1;
	reps(i,1,n){
		if(a[i]> cur){
			cnt += (a[i]-1)/cur;
		}else if(cur == a[i]){
			cur++;
		}
	}
	cout << cnt << endl;

	

	return 0;
}


Measured memory_bytes: 640