akhauriyash/Code-Regression huggingface dataset:
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
int main(){
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    vector<pair<ll,ll>> b(n);
    vector<ll> doko(n);
    set<ll> s;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i]--;
        doko[a[i]] = i;
    }
    // [,]　こうもつ
    for (int i = 0; i < n; i++) {
        auto itr = s.upper_bound(doko[i]);
        
        if(itr == s.begin()){
            b[i].first = 0;
        }else{
            itr--;
            b[i].first = *itr+1;
            itr++;
        }
        if(itr == s.end()){
            b[i].second = n-1;
        }else{
            b[i].second = *itr-1;
        }
        s.insert(doko[i]);
    }
    ll result = 0;
    for (int i = 0; i < n; i++) {
        result += ( (b[i].second-doko[i])*(doko[i]-b[i].first)+(b[i].second-doko[i])+(doko[i]-b[i].first)+1 )*(i+1);
    }
    std::cout << result << std::endl;
}



Measured memory_bytes: 15872
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	var ary = lines[0].split(" ").map(Number);
	var a = ary[0], b = ary[1], C = ary[2] / 180 * Math.PI;
	console.log(a * b * Math.sin(C) / 2);
	console.log(a + b + Math.sqrt(a*a + b*b - 2*a*b*Math.cos(C)));
	console.log(b * Math.sin(C));
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

struct edge {
	int from;
	int to;
	ll cost;
};
//有向グラフ、負の閉路がある場合の最短経路算出

static const ll INF = 1e15;

struct BellmanFord {

	std::vector<edge> edges_;
	int vertexCount_;
	std::vector<ll> cost;
	std::vector<bool> visit;

	BellmanFord(int vertexCount, std::vector<edge>&& edges) : edges_(std::move(edges)), vertexCount_(vertexCount) {
	}

	bool solve(int start)
	{
		cost.resize(vertexCount_, INF);
		visit.resize(vertexCount_, false);
		cost[start] = 0;
		visit[start] = true;

		for (int i = 0; i < vertexCount_; i++) {
			for (int j = 0; j < (int)edges_.size(); j++) {
				const auto& e = edges_[j];
				if (visit[e.from]) {
					visit[e.to] = true;
				}
			}
		}
		for (int i = 0; i < vertexCount_; i++) {
			for (int j = 0; j < (int)edges_.size(); j++) {
				const auto& e = edges_[j];
				if (!visit[e.from]) continue;
				if (cost[e.to] > cost[e.from] + e.cost) {
					cost[e.to] = cost[e.from] + e.cost;
					if (i == vertexCount_ - 1) {
						return false;
					}
				}
			}
		}
		return true;
	}
};
int main(void)
{
	int v, e, r;
	cin >> v >> e >> r;
	vector<edge> g;
	rep(i, e) {
		int s, t; 
		ll d;
		cin >> s >> t >> d;
		g.push_back({ s,t,d });
	}
	BellmanFord bf(v, move(g));
	auto ok = bf.solve(r);
	if (!ok) {
		cout << "NEGATIVE CYCLE" << endl;
		return 0;
	}
	rep(i, v) {
		if (!bf.visit[i]) {
			cout << "INF" << endl;
		}
		else {
			cout << bf.cost[i] << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3200
def main():
    N, A, B = map(int, input().split())
    H = [0] * N
    for i in range(N):
        H[i] = int(input())
    
    def isOK(x):
        cnt = 0
        for i in range(N):
            now = H[i] - B * x
            if now > 0:
                cnt += now // (A - B) if now % (A - B) == 0 else (now // (A - B)) + 1
            if cnt > x:
                return False
        return True
        

    def binary_search():
        ng = -1
        ok = 1010101010

        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2

            if (isOK(mid)):
                ok = mid
            else:
                ng = mid
        return ok

    ans = binary_search()
    print(ans)

    

if __name__ == "__main__":
    main()

Measured memory_bytes: 44952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a;
  b = a / 100;
  c = (a % 100) / 10;
  d = ((a % 100) % 10) / 1; 
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int r, g, b, k;
    cin >> r >> g >> b >> k;

    while(g <= r){
        g *= 2;
        --k;
    }

    while(b <= g){
        b *= 2;
        --k;
    }

    if(k < 0){
        cout << "No\n";
    }
    else{
        cout << "Yes\n";
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    string s;
    cin >> s;
    int len = s.length();

    int ten = 1;
    vector<int> d(len+1);
    for(int i=len-1; i>=0; i--){
        int a = (s[i] - '0') * ten % 2019;
        d[i] = (d[i+1] + a) % 2019;
        ten *= 10; ten %= 2019;
    }

    vector<int> cnt(2019);
    ll ans = 0;
    for(int i=len; i>=0; i--){
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4448
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

typedef struct{ll x,y;}queue;
ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

ll dist[51][51]={};
ll step[51][51]={};

int main(void){
    char s[55][55];
    ll h,w,black=0;
    scanf("%lld%lld",&h,&w);
    // ll [n];
    rep(i,0,h){
        scanf("%s",s[i]);
    }
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='#') black++;
        }
    }
    ll hw=10000;
    queue q[hw];
    rep(i,0,hw) q[i].x=-1;
    ll head=0,tail=0;
    q[head].x=0;
    q[head].y=0;
    dist[0][0]=1;
    step[q[head].y][q[head].x]=1;


    while(q[head].x!=-1){
        // printf("%lld %lld %lld\n",q[head].x,q[head].y,step[q[head].y][q[head].x]);
        rep(i,0,4){
            ll X=q[head].x+dx[i],Y=q[head].y+dy[i];
            if( X<0 || Y<0 || X>=w || Y>=h ) continue;
            if(s[Y][X]=='.'&&dist[Y][X]==0){
                tail++;
                q[tail].y=Y;
                q[tail].x=X;
                step[q[tail].y][q[tail].x] = step[q[head].y][q[head].x] + 1 ;
                dist[q[tail].y][q[tail].x] = 1;
            }
        }
        head++;
    }
    if(dist[h-1][w-1]){
        printf("%lld\n",h*w-step[h-1][w-1]-black);
    }else{
        printf("-1\n");
    }

    // printf("\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    int k;
    string s;
    cin >> k >> s;
    int l = s.size();
    if(l>k){
        string ans = "";
        rep(i,k){
            ans += s[i];
        }
        ans += "...";
        cout << ans << endl;
    }
    else{
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
bool dp[85][85][85 * 85] = {};
bool in(int x)
{
  return abs(x) < 85 * 85;
}
void solve(long long H, long long W, std::vector<std::vector<long long>> A,
           std::vector<std::vector<long long>> B)
{
  dp[0][0][abs(A[0][0] - B[0][0])] = true;
  rep(i, H) rep(j, W)
  {
    if (i == 0 && j == 0)
      continue;
    lli ma = max(A[i][j], B[i][j]);
    lli mi = min(A[i][j], B[i][j]);

    rep(k, 85 * 85)
    {

      lli neko = abs(k + mi - ma);
      lli piyo = abs(k + ma - mi);
      if (j)
      {
        if (in(k + mi - ma))
          dp[i][j][neko] |= dp[i][j - 1][k];
        if (in(k + ma - mi))
          dp[i][j][piyo] |= dp[i][j - 1][k];
      }
      if (i)
      {
        if (in(k + mi - ma))
          dp[i][j][neko] |= dp[i - 1][j][k];
        if (in(k + ma - mi))
          dp[i][j][piyo] |= dp[i - 1][j][k];
      }
    }
  }
  rep(i, 85 * 85)
  {
    if (dp[H - 1][W - 1][i])
    {
      cout << i << endl;
      return;
    }
  }
}

signed main()
{
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  std::vector<std::vector<long long>> A(H, std::vector<long long>(W));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      scanf("%lld", &A[i][j]);
    }
  }
  std::vector<std::vector<long long>> B(H, std::vector<long long>(W));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      scanf("%lld", &B[i][j]);
    }
  }
  solve(H, W, std::move(A), std::move(B));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 49408
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  vector<ll> s(3);
  rep(i,3){
    cin >> s[i];
  }
  sort(all(s));
  if(s[0]==5&&s[1]==5&&s[2]==7){
    print("YES");
  }
  else{
    print("NO");
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
if n%2==1:
  for i in range(m):
    print(i+1,i+1+(m-i)*2-1)
else:
  for i in range(m):
    a=i//2
    b=i%2
    if b==0:
      print(a+1,a+1+m-i)
    else:
      print(n-a-(m-i),n-a)


Measured memory_bytes: 9272
#include <stdio.h>

int main(void){

  int A; //X's rate
  int B; //Y's rate
  int C; //Y's limit L
  int D; //Y's over late
  int P; //JOI's water

  int X=0;
  int Y=0;
  
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&D);
  scanf("%d",&P);

  X=A*P;
  
  if(P>C){
    Y=B+D*(P-C);
  }
  else{
    Y=B;
  }
  if(X<Y){
    printf("%d\n",X);
  }

  else{
    printf("%d\n",Y);
  }
  return 0;

}
  

Measured memory_bytes: 596
a, b, c = map(int, input().split())
k = int(input())
count = 0

for i in range(k):
    if a >= b:
        b = 2 * b
    elif b >= c:
        c = 2 * c
    count += 1

if a < b and b < c:
    if count <= k:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

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

    static class ForbiddenList {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();
            int n = in.nextInt();

            if (n == 0) {
                out.append(String.valueOf(x));
                return;
            }

            boolean[] p = new boolean[100 + 1];
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                p[a] = true;
            }

            int pos = 0;
            while (true) {
                int minus = x - pos;
                if (0 <= minus && minus <= 100) {
                    if (!p[minus]) {
                        out.append(String.valueOf(minus));
                        return;
                    }
                }
                int plus = x + pos;
                if (0 <= plus && plus <= 100) {
                    if (!p[plus]) {
                        out.append(String.valueOf(plus));
                        return;
                    }
                }
                if (minus <= 0) {
                    out.append(String.valueOf(minus));
                    return;
                }

                if (100 < plus) {
                    out.append(String.valueOf(plus));
                    return;
                }
                pos++;
            }
        }

    }
}



Measured memory_bytes: 36008
#include <iostream>
#include <cstdio>
using namespace std;
#define N 50

int main(){
	while(1){
		int n,m;
		int ca[N];
		cin >> n >> m;
		if(!n&&!m) break;
		fill(ca,ca+n,0);
		
		int wan = m;
		int k = 0;
		while(1){
			while(wan){
				ca[k]++;
				k++;
				k = k%n;
				wan--;
			}
			if((k==0&&ca[n-1]==m)||(ca[k-1]==m)){
				break;
			}else{
				wan = ca[k];
				ca[k] = 0;
				k++;
				k = k%n;
			}
		}
		if(!k){
			cout << n-1 << endl;
		}else{
			cout << k-1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std ;
#define int unsigned long long
const int mxn = 8000005 ;
const int Mod = 1e9+7 ;
int frac[mxn], inv[mxn];
int f[2005][2005], n, k;
/*
设f(i,j)表示在这些位置上已经放了i个白球，j种其他颜色的球。(i<j)
f(i,j) = f(i-1, j)+f(i ,j-1)*(n-j+1)*C(k-2, n*k-i-(j-1)*(k-1)-1)
*/
int power(int a, int b){
	int res=1, car=a; 
	while(b){
		if(b&1) (res*=car)%=Mod;
		(car*=car)%=Mod;
		b>>=1;
	}
	return res;
}
void init(){
	frac[0]=1 ;
	for(int i=1;i<mxn;++i) (frac[i]=frac[i-1]*i)%=Mod ;
	inv[mxn-1] = power(frac[mxn-1], Mod-2);
	for(int i=mxn-2;i>0;--i) inv[i]=(inv[i+1]*(i+1))%Mod ;
	inv[0] = 1 ;
}
int C(int n, int k){
	return ((frac[n]*inv[k]%Mod)*inv[n-k])%Mod ;
}
signed main(){
	init() ;
	cin>>n>>k;
	if(k==1) return puts("1"),0 ;
	f[0][0] = 1 ;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=i;++j)
			(f[i][j] = f[i-1][j]+(j?((((f[i][j-1]*(n-j+1))%Mod)*C(n*k-i-(j-1)*(k-1)-1, k-2))%Mod):(0)))%=Mod ;
	cout<<f[n][n]<<endl ;
}

Measured memory_bytes: 155136
#include "bits/stdc++.h"
#define all(v) v.begin(),v.end()
#define SZ(x) (int)x.size()
#define endl "\n"
#define thunder ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(15);
using namespace std;
typedef long long int ll;
#ifdef ONLINE_JUDGE
#define debug(...)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif
void debug_out() { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
map<int,ll>mp;
int main()
{
    thunder
    auto start = chrono::high_resolution_clock::now();
    int n;ll k;cin>>n>>k;
    for(int i=0,x,y;i<n;++i)
    {
        cin>>x>>y;
        mp[x]+=y;
    }
    for(auto x:mp)
    {
        debug(x.first,x.second);
        if(x.second<k)k-=x.second;
        else
        {
           cout<<x.first<<endl;return 0;
        }
    }

   





   auto end = chrono::high_resolution_clock::now(); 
   double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
   time_taken *= 1e-9;
   debug(time_taken);
}

Measured memory_bytes: 7548
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long 
#define f(j) for(ll i=0;i<j;i++)
#define pb(i) push_back(i)
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;    
typedef vector<vector<long long> > matrix; 
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	// faster
	int n;
	cin>>n;
	int a[n],b[n],c[n],dp[n][3]; // 0-a,1-b,2-c
	f(n)	cin>>a[i]>>b[i]>>c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i=1;i<n;i++){
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][2],dp[i-1][0]);
		dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
return 0;	
}

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

int main() {
  int K;
  
  string S ;
  cin >> K >> S ;
  
  
  string N = S.substr(0,K);
  N +="...";
  
  
  if(S.size()<=K){
    cout << S <<endl;
  }
  
  else{
    cout << N <<endl;
  }
  
}


Measured memory_bytes: 3604
// AOJ
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_C

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <iterator>
#include <algorithm>

typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

using namespace std;

// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> void output(std::vector<T> & A) {
    const int n = A.size();
    for (int i = 0; i < n - 1; ++i) {
        std::cout << A[i] << " ";
    }
    std::cout << A[n - 1] << std::endl;
}

struct Node {
    int key;
    Node* parent, *left, *right;
};
Node *nil, *root;


//string nodeType(int currentNb) {
//    if (node[currentNb].parent == NIL) return "root";
//    if (getDegree(currentNb) == 0) return "leaf";
//    return "internal node";
//}
//
void preParse(Node *node) {
    // if (nbNode == NIL) return;
    cout << " " << node->key;
    if (node->left  != nil) preParse(node->left);
    if (node->right != nil) preParse(node->right);
}

void intParse(Node *node) {
    if (node->left != nil) intParse(node->left);
    cout << " " << node->key;
    if (node->right != nil) intParse(node->right);
}
//
//void postParse(int nbNode) {
//    if (node[nbNode].left != NIL) postParse(node[nbNode].left);
//    if (node[nbNode].right != NIL) postParse(node[nbNode].right);
//    cout << " " << nbNode;
//}

void insert(Node* node) {
    Node* tmp = root;
    Node* par = nil;
    while (tmp != nil) {
        par = tmp;
        const int pkey = tmp->key;
        tmp = (node->key < pkey) ? tmp->left : tmp->right;
    }
    // node = tmp;
    if (par == nil) {
        root = node;
    }
    else {
        node->parent = par;
        if (node->key < par->key) {
            par->left = node;
        }
        else {
            par->right = node;
        }
    }
}

void init(Node* node) {
    node->parent = nil;
    node->left   = nil;
    node->right  = nil;
}

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

    nil = new Node;
    init(nil);
    root = nil;

    int n; cin >> n;
    rep(i, n) {
        string order; cin >> order;
        if (order.compare("insert") == 0) {
            int key; cin >> key;
            Node* newNode = new Node;
            init(newNode);
            newNode->key = key;
            if (root == nil) root = newNode;
            else insert(newNode);
        }
        else {
            intParse(root); cout << endl;
            preParse(root); cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 26468
N,M = map(int, input().split())
f=[0]*(N+1)
ans_a=[0]*(N+1)
ans_w=0
for i in range(M):
    p,s = map(str, input().split())
    if s=='WA' and ans_a[int(p)]==0:
        f[int(p)]+=1
    else:
        if ans_a[int(p)]==0:
            ans_a[int(p)]+=1
            ans_w+=f[int(p)]
print(sum(ans_a),ans_w)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;

		if (tmp & 1)
			continue;

		if (tmp % 3 != 0 && tmp % 5 != 0)
		{
			cout << "DENIED" << endl;
			return;
		}
	}

	cout << "APPROVED" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main() {
  int N, l, r, sum;
  sum = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define reps(i,j,n) for(int i = (j) ; i < (int)(n) ; ++i)    
#define rep(i,n) reps(i,0,n)  
#define each(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)    
typedef pair< int , int > Pi;  
typedef pair< int , Pi > Pii;
typedef long long int64;  
const int INF = 1 << 30;  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is>>a.first>>a.second; }  
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os<<a.first<<" "<<a.second; }  
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ rep(i,sz(vc)) is >> vc[i]; return is;}  
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ rep(i,sz(vc)) os << vc[i] << endl; return os; }

int N;
Pi data[300000];

int calc(int value) { //value:許容匹数
  int64 sum = 0; //放出量の合計
  priority_queue< Pi, vector< Pi >, greater< Pi > > que; //許容量が小さい順
  for(int i = 0; i < N; i++){
    que.push( Pi( data[i].second, data[i].first));
    sum += data[i].first;
    // sum / que.size() を摂取する → sum / que.size() <= que.top()
    while(!que.empty() && sum > (int64)que.size() * que.top().first){
      sum -= que.top().second;
      que.pop();
    }
    if(que.size() >= value) return true;
  }
  return false;
}

int Binary_Search( int row, int high) {
  int mid = (row + high + 1) >> 1;
  if(row == high)    return(row);
  else if(calc(mid)) return(Binary_Search( mid, high));
  else               return(Binary_Search( row, mid - 1));
}

int main() {

  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%d %d", &data[i].first, &data[i].second);
  }
  sort( data, data + N);
  cout << Binary_Search( 0, N) << endl;
}

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

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

  int C[N];
  for(int i = 0; i < N; i++) {
    C[i] = -1;
  }
  long long int as = 0;
  while(1) {
    int K[N];
    for(int i = 0; i < N; i++) {
        K[i] = A[i] + C[i];
    }
    long long int ans = K[0];
    for(int i = 1; i < N; i++) {
      ans *= K[i];
    }
    if(ans % 2 == 0) {
      as++;
    }



    bool end = true;
    for(int i = 0; i < N; i++) {
      if(C[i] != 1) {
        end = false;
        break;
      }
    }
    if(end) break;
    C[0] += 1;
    for(int i = 0; i < N-1; i++) {
      if(C[i] == 2) {
        C[i+1] += 1;
        C[i] = -1;
      }
    }
  }
  cout << as << endl;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int A = sc.nextInt();
			int B = sc.nextInt();

			for (int i = 1; i <= 3; i++) {
				if (A != i && B != i) {
					System.out.println(i);
					return;
				}
			}
		}
	}

}


Measured memory_bytes: 21332
//file_name:ABC92_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b;
    scanf("%d%d",&a,&b);

    int h = 100;

    cout << h << ' ' << h << endl;

    int dp[100][100];
    rep(i,100){
        rep(j,100){
            if(j<50){
                dp[i][j]=0;
            }else{
                dp[i][j]=1;
            }
        }
    }

    int countb = 0;
    int counta = 0;
    rep(i,b-1){
        int tate = countb / 100;
        int yoko = countb % 100;
        dp[yoko][tate*2] = 1;
        countb += 2;
    }
    rep(i,a-1){
        int tate = counta / 100;
        int yoko = counta % 100;
        dp[yoko][60+tate*2] = 0;
        counta += 2;
    }

    rep(i,100){
        rep(j,100){
            if(dp[i][j]==0){
                cout << '.';
            }else{
                cout << '#';
            }
        }
        cout << endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	long long int mozi[5] = {0};
	long long int ans = 1;
	long long int zenbu = 0;
	int i, j, k;
	char s[11];

	scanf("%d", &n);
	for (i= 0; i < n; i++) {
		scanf("%s", s);

		switch (s[0]) {
			case 'M' :
				mozi[0]++;
				break;
			case 'A' :
				mozi[1]++;
				break;
			case 'R' :
				mozi[2]++;
				break;
			case 'C' :
				mozi[3]++;
				break;
			case 'H' :
				mozi[4]++;
				break;
		}

	}

	for (i = 0; i < 3; i++) {
		for (j = i+1; j < 4; j++) {
			for (k = j+1; k < 5; k++) {
				ans = mozi[i] * mozi[j] * mozi[k];
				zenbu += ans;
			}
		}
	}

	printf("%lld", zenbu);
	return 0;
}



Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define REP(a,b) for(int a = 0;a < b;++a)
int main(){
   int n;
cin >> n;
REP(i,n){
    int a,b;
cin >> a >> b;
        map<int,int> c;
   c[a / 100 + b / 30 * 5] = 1;
         c[(a+99) / 100 + (b+29)/ 30 * 5] = 1;
 c[(a+99) / 100 + b / 30 * 5] = 1;
 c[a / 100 + (b+29)/ 30 * 5] = 1;
        int aas = 0;
        for(auto i = c.begin();i != c.end();++i){
        if(aas == 0) aas= 1;
                else cout << " ";
            cout << i -> first;
    }
        cout << endl;
}
}
        


Measured memory_bytes: 3124
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

totalA = [0]
totalB = [0]
sumA = 0
for i in range(N):
    sumA += A[i]
    totalA.append(sumA)
sumB = 0
for i in range(M):
    sumB += B[i]
    totalB.append(sumB)

iB = M
countMax = 0
for iA in range(N+1):
  if totalA[iA]>K:
    break
  else:
    while totalA[iA] + totalB[iB] > K:
      iB -= 1
  countMax = max(countMax,iA+iB)

print(countMax)



Measured memory_bytes: 47456
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  a,b=map(int,input().split())
  uf.union(a-1,b-1)
ans=1
for i in range(n):
  c=uf.size(i)
  if c>ans:
    ans=c
print(ans)

Measured memory_bytes: 76264
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Y = sc.nextInt();
    int x = -1;
    int y = -1;
    int z = -1;
    for(int i=0;i<=N;i++){
      for(int j=0;j<=N-i;j++){
        int k = N-i-j;
        int sum = 10000*i+5000*j+1000*k; 
        if(sum == Y){
          x = i;
          y = j;
          z = k;
        }
      }
    }
    System.out.println(x+" "+y+" "+z);
  }
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    ll h,a;
    cin >> h >> a;

    int ans = h % a == 0? h/a : h/a + 1;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int main(){
    int n;
    while(1){
        cin>>n;
        if(n==0) break;
        int a,sum=0;
        LP(i,n/4){
            cin>>a;
            sum+=a;
        }
        cout<<sum<<endl;
    }
    return 0;
}



Measured memory_bytes: 3072
item = gets.chomp.split(/\s+/).map { |e| e.to_i }
n = item[0]
k = item[1]
ps = gets.chomp.split(/\s+/).map { |e| e.to_i }

# 隣接
max = 0
max_index = 0

curr = ps[0,k].inject(:+)

0.upto(n-k) { |i|
  if curr > max
    max = curr
    max_index = i
  end
  curr += -ps[i] + ps[i+k] if i != n-k
}

saikoros = ps[max_index, k]

puts saikoros.map { |saikoro|
  saikoro * (saikoro + 1) / 2.0 / saikoro
}.inject(:+)


Measured memory_bytes: 17540
#include <stdio.h>
 
int main(void){
	int H,W;
	int i,f;
	for(;;){
	scanf("%d%d",&H,&W);
	if(H==0&&W==0)break;
	for(f=0;f<H;f++){
	for(i=0;i<W;i++){
	printf("#");
	}
	printf("\n");
	}
	printf("\n");
	}
    return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int k;
string str,str1;
set<string> st;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> str >> k;
    rep(sz(str)){
        str1.clear();
        rep1(j,min(5ll,sz(str)-i)){
            str1.pb(str[i+j]);
            st.insert(str1);
        }
    }
    for(auto str2:st){
        k--;
        if(!k){
            print1(str2);
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n, k;
int deg[N], ans[N];
vector<pair<int, int> > g[N];

void dfs(int u, int par, int c)
{
	for(auto &it:g[u])
	{
		if(it.first == par)
			continue;
		c = (c + 1) % k;
		ans[it.second] = c;
		dfs(it.first, u, c);
	}
}

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		deg[u]++, deg[v]++;
		g[u].push_back({v, i});
		g[v].push_back({u, i});
	}
	for(int i = 1; i <= n; i++)
		k = max(k, deg[i]);
	dfs(1, 1, 0);
	cout << k << endl;
	for(int i = 1; i <= n - 1; i++)
		cout << ans[i] + 1 << endl;
	return 0;	
}

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;

template <class T, class U>
T divup(T x, U y) {
    return (x + y - 1) / y;
}

template <class Pred>
ll partition_point_ll(ll first, ll last, Pred p) {
    ll count = last - first;
    while (count > 0) {
        ll step = count / 2;
        ll mid = first + step;
        if (p(mid)) {
            first = mid + 1;
            count -= step + 1;
        } else {
            count = step;
        }
    }
    return first;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> F[i];

    sort(all(A));
    sort(all(F), greater<ll>());

    function<bool(ll)> f = [&](ll t) -> bool {
        ll sum_training = 0;
        REP(i, N) {
            // (A[i] - training) * F[i] <= t;
            // A[i] * F[i] - t <= training * F[i];
            ll AF = A[i] * F[i];
            if (AF > t) {
                ll training = divup(AF - t, F[i]);
                sum_training += training;
                if (sum_training > K)
                    return true;
            }
        }
        return false;
    };

    cout << partition_point_ll(0, LLONG_MAX, f) << endl;

    return 0;
}

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

using namespace std;

int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = (c * e - b * f) / (a * e - b * d);
		double y = (c * d - a * f) / (b * d - a * e);
		if (-0.0005 <= x && x < 0.0005) x = 0;
		if (-0.0005 <= y && y < 0.0005) y = 0;
		// 数値を固定小数点形式で表示
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
}

Measured memory_bytes: 1280
//written by libra9z
#include <bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
	cin>>n>>m;
	int x=1;
	for (int i=0;i<m;++i)
	{
		x*=2;
	}
	int ans=1900*m+100*(n-m);
	ans*=x;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef unsigned long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
#define N 10007
lint a[5010][5010];
int main()
{
	int n;string s;cin>>n;cin>>s;
	rep(i,n){
		a[i][0]=0;
		rep(j,n-i) a[i][j+1]=a[i][j]*N+(s[i+j]-'a');
	}
	int out=0;
	rep(i,n) REP(j,i+1,n){
		int lo=out,hi=j-i;
		while(hi>lo){
			int mi=(hi+lo+1)/2;
			if(a[i][mi]==a[j][mi]) lo=mi;else hi=mi-1;
		}
		out=max(out,lo);
	}
	cout<<out<<endl;
}

Measured memory_bytes: 194944
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: usize = sc.read();
    let x: Vec<usize> = sc.vec(n);
    let sum = x.iter().sum::<usize>();
    let mut dp = vec![vec![0; sum + 1]; n + 1];
    dp[0][0] = 1;
    for x in x.into_iter() {
        for cards in (0..(n + 1)).rev() {
            for cur in (0..(sum + 1)).rev() {
                if dp[cards][cur] == 0 {
                    continue;
                }
                if cards + 1 <= n && cur + x <= sum {
                    dp[cards + 1][cur + x] += dp[cards][cur];
                }
            }
        }
    }

    let ans = dp
        .into_iter()
        .enumerate()
        .map(|(cards, dp)| {
            dp.into_iter()
                .enumerate()
                .filter(|&(sum, _)| a * cards == sum && cards >= 1)
                .map(|(_, num)| num)
                .sum::<usize>()
        })
        .sum::<usize>();
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main() {
  int N, W;
  cin >> N >> W;
  N *= 1000;
  vector<long> DP(N + 1, 2e18);
  DP.at(0) = 0;
  for (int w, v; cin >> w >> v;) {
    for (int i = N; i >= 0; i--) {
      if (DP.at(i) == -1) continue;
      if (i + v > N) continue;
      DP.at(i + v) = min(DP.at(i + v), DP.at(i) + w);
    }
  }
  for (int i = N; i >= 0; i--) {
    if (DP.at(i) == 2e18) continue;
    if (DP.at(i) <= W) return cout << i << "\n", 0;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;

    if(a<b){
        long long tmp=a;
        a=b;
        b=tmp;
    }
    
    long long ac=a,bc=b;
    
    long long r=a%b;
    
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    
    cout<<ac*(bc/b)<<endl;
    
    return 0;
}

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

int main(){
	int a,b,c;
	int ans;
	int cnt=-1;
	
	while(cin>>a>>b){
		cnt++;
		//-----test-----
		if(a<1150) break;
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
INF = 10**10
MOD = 10**9+7

N, X = map(int, input().split())
a, b, ans = max(X, N-X), min(X, N-X), N
while 1:
    ans += 2*b*(a//b)
    a, b = b, a%b
    if b == 0:
        ans -= a
        break
print(ans)


Measured memory_bytes: 3444
import collections

N = int(input())
S = [input() for s in range(N)]
M = int(input())
T = [input() for t in range(M)]
S_counter = collections.Counter(S)
T_counter = collections.Counter(T)

for k, v in S_counter.items():
    if k in T_counter:
        S_counter[k] = S_counter[k] - T_counter[k] if (S_counter[k] - T_counter[k]) > 0 else 0

print(max(S_counter.values()))


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))

using namespace std;
using ll = long long;

vector<int> di = {-1, 0, 1, 0};
vector<int> dj = {0, -1, 0, 1};


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    bool ok = true;
    rep(i, h)rep(j, w) {
        if (s[i][j] == '#') {
            bool all_dot = true;
            rep(dir, 4) {
                int ni = i + di[dir];
                int nj = j + dj[dir];
                if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if (s[ni][nj] == '#') all_dot = false;
            }
            if (all_dot) {
                ok = false;
                break;
            }
        }
    }
    cout << ((ok) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
let s = read_line ()
let b = if s.[0] = s.[1] then s.[0] <> s.[2] && s.[2] = s.[3]
  else if s.[0] = s.[2] then s.[0] <> s.[1] && s.[1] = s.[3]
  else if s.[0] = s.[3] then s.[0] <> s.[1] && s.[1] = s.[2]
  else false
let _ = print_endline @@ if b then "Yes" else "No"

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

bool is_prime(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return n!=1;
}

signed main(){
    vector<ll> a;
    for(ll i=3;i<=100000;i++){
        if(i%2==1){
            if(is_prime(i)&&is_prime((i+1)/2)){
                a.push_back(i);
            }
        }
    }
    int q;
    cin>>q;
    vector<ll> b;
    while(q--){
        ll l,r;
        cin>>l>>r;
        ll m=ub(all(a),r)-a.begin();
        ll n=lb(all(a),l)-a.begin();
        b.push_back(m-n);
    }
    for(auto bb:b) cout<<bb<<endl;
}

Measured memory_bytes: 1540
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int N;  cin >> N;
    vector<int> l(N), r(N);
    for (int i = 0; i < N; i++) cin >> l[i] >> r[i];

    int ans = 0;
    for (int i = 0; i < N; i++){
        ans += r[i] - l[i] + 1;
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N ;
   vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
  cout << a.at(0)-a.at(N-1)<<endl;
}

Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    int sum;
    while(true){
      String line = br.readLine();
      if("0".equals(line)){
      break;
    }
    char[] c = line.toCharArray();
    sum = 0;
    for(int i = 0; i < c.length; i++){
      sum = sum + Character.getNumericValue(c[i]);
    }
    sb.append(sum);
    sb.append("\n");
  }
  System.out.print(sb);
}
}

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

int main(void){
    long long h,w,n;
    cin>>h>>w>>n;
    
    if(h>w){
        cout<<ceil((double)n/h)<<endl;
    }else{
        cout<<ceil((double)n/w)<<endl;
    }
}


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

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

Measured memory_bytes: 256