akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

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

    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> z(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> z[i]; 
    }


    vector<ll> value(N);
    ll maxValue = 0;

    for(int i = 0; i < N; i++){
        value[i] = x[i] + y[i] + z[i];
    }
    sort(rall(value));
    maxValue = max(maxValue, accumulate(value.begin(), value.begin() + M , 0ll) );

    for(int i = 0; i < N; i++){
        value[i] = x[i] + y[i] - z[i];
    }
    sort(rall(value));
    maxValue = max(maxValue, accumulate(value.begin(), value.begin() + M , 0ll) );


    for(int i = 0; i < N; i++){
        value[i] = x[i] - y[i] + z[i];
    }
    sort(rall(value));
    maxValue = max(maxValue, accumulate(value.begin(), value.begin() + M , 0ll) );

    for(int i = 0; i < N; i++){
        value[i] = x[i] - y[i] - z[i];
    }
    sort(rall(value));
    maxValue = max(maxValue, accumulate(value.begin(), value.begin() + M , 0ll) );


    for(int i = 0; i < N; i++){
        value[i] = -x[i] + y[i] + z[i];
    }
    sort(rall(value));
    maxValue = max(maxValue, accumulate(value.begin(), value.begin() + M , 0ll) );

    for(int i = 0; i < N; i++){
        value[i] = -x[i] + y[i] - z[i];
    }
    sort(rall(value));
    maxValue = max(maxValue, accumulate(value.begin(), value.begin() + M , 0ll) );


    for(int i = 0; i < N; i++){
        value[i] = -x[i] - y[i] + z[i];
    }
    sort(rall(value));
    maxValue = max(maxValue, accumulate(value.begin(), value.begin() + M , 0ll) );

    for(int i = 0; i < N; i++){
        value[i] = -x[i] - y[i] - z[i];
    }
    sort(rall(value));
    maxValue = max(maxValue, accumulate(value.begin(), value.begin() + M , 0ll) );

    cout << maxValue << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  int mx =0;
  int ans = 0;
  rep(i,n) {
    int a; cin >> a;
    if (mx <= a) ans++;
    chmax(mx, a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                  1000000007
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={-2,-2,1,-1,-1,-1,1,1};
int dy[8]={1,-1,-2,-2,-1,1,-1,1};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    string s;
    cin>>s;
    int n=(int)s.length();
    vector<vector<ll>> dp(n+1,vector<ll> (13,0));
    if(s[0]=='?')
    {
        for(int i=0;i<10;i++)
        {
            dp[1][i]=1;
        }
    }
    else
    {
        dp[1][s[0]-48]=1;
    }
    for(int i=1;i<n;i++)
    {
        if(s[i]=='?')
        {
            for(int j=0;j<13;j++)
            {
                for(int k=0;k<10;k++)
                {
                    int num=(j*10+k)%13;
                    dp[i+1][num]=(dp[i+1][num]%inf+dp[i][j]%inf)%inf;
                }
            }
        }
        else
        {
            for(int k=0;k<13;k++)
            {
                int num=(k*10+s[i]-48)%13;
                dp[i+1][num]=(dp[i+1][num]%inf+dp[i][k]%inf)%inf;
            }
        }
    }
    cout<<dp[n][5]<<endl;
}


Measured memory_bytes: 13648
#!/usr/bin/env python

n, q = map(int ,input().split())
par = [-1 for _ in range(n)]
rank = [-1 for _ in range(n)]

def init(n):
    for i in range(n):
        par[i] = i 
        rank[i] = 0 

def root(x):
    if par[x] == x:
        return x

    # ここをしっかり理解する
    else:
        par[x] = root(par[x])
        return par[x]

def same(x, y): 
    return root(x) == root(y)

def unite(x, y): 
    x = root(x)
    y = root(y)
    if x == y:
        return
    par[x] = y 

# main
t = [0 for _ in range(q)]
u = [0 for _ in range(q)]
v = [0 for _ in range(q)]

init(n)
for i in range(q):
    t[i], u[i], v[i] = map(int, input().split())
    if t[i] == 0:unite(u[i], v[i])
    else:print(int(same(u[i], v[i])))


Measured memory_bytes: 28180
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    string s;
    cin>>s;
    int ans = 0;
    for(int i=s.size()-1; i>0; i--){
        for(int j=1; j<=i/2; j++){
            if(i%j || (i/j)%2) continue;
            bool ok=true;
            for(int k=0; k+j<=i; k+=j){
                if(s.substr(0,j)!=s.substr(k,j)) ok=false;
            }
            if(ok){
                ans=max(ans,i);
            }
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    // int x1, x2, y1, y2;
    long ans;
    // if(b < 0 && d < 0){
    //     ans = (long)a * c;
    // }
    // else if(b > 0 && d > 0){
    //     ans = (long)b * d;
    // }
    // else if(a > 0 && d < 0){
    //     ans = (long)a * d;
    // }
    // else if(b < 0 && c > 0){
    //     ans = (long)b * c;
    // }

    if(a < 0 && b == 0 && c < 0){
        ans = (long)a * c;
    }
    else if(a < 0 && b == 0 && c >= 0){
        ans = (long)b * c;
    }
    else if(a == 0 && b > 0 && d < 0){
        ans = (long)a * c;
    }
    else if(a == 0 && b > 0 && d > 0){
        ans = (long)b * d;
    }
    
    else if(c < 0 && d == 0 && a < 0){
        ans = (long)a * c;
    }
    else if(c < 0 && d == 0 && a >= 0){
        ans = (long)d * a;
    }
    else if(c == 0 && d > 0 && b < 0){
        ans = (long)a * c;
    }
    else if(c == 0 && d > 0 && b > 0){
        ans = (long)b * d;
    }
    else if((a == 0 && b == 0) || (c == 0 && d == 0)){
        ans = 0;
    }
    
    else if(a < 0 && b < 0 && c < 0 && d < 0){
        ans = (long)a * c;
    }
    else if(a < 0 && b < 0 && c < 0 && d > 0){
        ans = (long)a * c;
    }
    else if(a < 0 && b < 0 && c > 0){
        ans = (long)b * c;
    }

    else if(a < 0 && b < 0 && c < 0 && d < 0){
        ans = (long)a * c;
    }
    else if(c < 0 && d < 0 && a < 0 && b > 0){
        ans = (long)a * c;
    }
    else if(c < 0 && d < 0 && a > 0){
        ans = (long)a * d;
    }



    else if(a < 0 && b > 0 && c < 0 && d < 0){
        ans = (long)a * c;
    }
    else if(a < 0 && b > 0 && c < 0 && d > 0){
        long tmp1 = (long)a * c;
        long tmp2 = (long)b * d;
        if(tmp1 > tmp2){
            ans = tmp1;
        }
        else{
            ans = tmp2;
        }
    }
    else if(a < 0 && b > 0 && c > 0){
        ans = (long)b * d;
    }

    else if(c < 0 && d > 0 && a < 0 && b < 0){
        ans = (long)a * c;
    }
    else if(c < 0 && d > 0 && a < 0 && b > 0){
        long tmp1 = (long)a * c;
        long tmp2 = (long)b * d;
        if(tmp1 > tmp2){
            ans = tmp1;
        }
        else{
            ans = tmp2;
        }
    }
    else if(c < 0 && d > 0 && a > 0){
        ans = (long)b * d;
    }



    else if(a > 0 && c < 0 && d < 0){
        ans = (long)a * d;
    }
    else if(a > 0 && c < 0 && d > 0){
        ans = (long)b * d;
    }
    else if(a > 0 && c > 0){
        ans = (long)b * d;
    }

    else if(c > 0 && a < 0 && b < 0){
        ans = (long)c * b;
    }
    else if(c > 0 && a < 0 && b > 0){
        ans = (long)b * d;
    }
    else if(a > 0 && c > 0){
        ans = (long)b * d;
    }
    
    cout << ans << endl;
    return 0;
}

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

const int N = 200005, LN = 150;

int n, head[N], tot;
struct edge { int to, nxt; } e[N << 1];

void link(int x, int y) {
	e[++tot] = (edge) { y, head[x] }, head[x] = tot;
	e[++tot] = (edge) { x, head[y] }, head[y] = tot;
}

int sum[N * LN], lc[N * LN], rc[N * LN], root0[N], root1[N], idx;

void insert(int &root, int pos, int l = 1, int r = n) {
	sum[root = ++idx] = 1;
	if (l == r) return;
	int mid = l + r >> 1;
	if (pos <= mid) insert(lc[root], pos, l, mid);
	else insert(rc[root], pos, mid + 1, r);
}
int merge(int x, int y) {
	if (!x || !y) return x | y;
	int id = ++idx;
	sum[id] = sum[x] + sum[y];
	lc[id] = merge(lc[x], lc[y]);
	rc[id] = merge(rc[x], rc[y]);
	return id;
}
int query(int root, int pos, int l = 1, int r = n) {
	if (!root || pos == r) return sum[root];
	int mid = l + r >> 1;
	if (pos <= mid) return query(lc[root], pos, l, mid);
	else return query(rc[root], pos, mid + 1, r) + sum[lc[root]];
}

int ans[N], f[N], max[N], second[N];
void dfs0(int x, int max = 0, int second = 0) {
	if (x > max) second = max, max = x; else if (x > second) second = x;
	if (x > 1) insert(root0[x], max), insert(root1[x], second);
	::max[x] = max, ::second[x] = second;
	for (int i = head[x]; i; i = e[i].nxt) if (e[i].to != f[x]) {
		f[e[i].to] = x, dfs0(e[i].to, max, second);
		root0[x] = merge(root0[x], root0[e[i].to]);
		root1[x] = merge(root1[x], root1[e[i].to]);
	}
}
void dfs1(int x, int son = 0) {
	if (!second[x]) ans[x] = x > 1;
	else if (max[x] == x) {
		ans[x] = ans[f[x]] + query(root1[x], second[x]);
	} else {
		ans[x] = ans[f[max[x]]] + query(root0[son], max[x]) + query(root1[max[x]], second[max[x]]) - query(root1[son], second[max[x]]);
	}
	for (int i = head[x]; i; i = e[i].nxt) if (e[i].to != f[x]) {
		if (max[x] == x) son = e[i].to;
		dfs1(e[i].to, son);
	}
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 2, x, y; i <= n; ++i)
		std::cin >> x >> y, link(x, y);
	dfs0(1), dfs1(1);
	for (int i = 2; i <= n; ++i)
		std::cout << ans[i] << ' '; std::cout << '\n';
	return 0;
}

Measured memory_bytes: 199168
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  string a,b,c;
  cin >> a >> b >> c;
  int ans=0;
  rep(i,n){
    if(a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i])ans+=2;
    else if(a[i]==b[i] && b[i]==c[i])continue;
    else ans++;
  }
  cout << ans << endl;
}


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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num = 0;

  int a, b; cin >> a >> b;

  if (a <= b) num = a;
  else num = a - 1;
  
  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int k;
    scanf("%d",&k);
    int a[k+10],i,count=0;
    for(i=0;i<k;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<k-1;i++)
    {
       if(a[i]>a[i-1])
       {
           if(a[i]<a[i+1])count++;
       }
       else if(a[i]<a[i-1])
       {
           if(a[i]>a[i+1])count++;
       }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    ll n,m;
    cin>>n>>m;
    //bitDP
    vector<ll> dp((1<<n),0);
    rep(i,m){
        ll a,b;cin>>a>>b;
        ll bit=0;
        while(b--){
            ll t;cin>>t;t--;
            bit+=(1<<t);
        }
        if(dp[bit]>0) dp[bit]=min(dp[bit],a);
        else dp[bit]=a;
    }

    for(int i=0;i<(1<<n);i++)if(dp[i]>0){
        for(int j=0;j<i;j++)if(dp[j]>0){
            if(dp[i|j]>0) dp[i|j]=min(dp[i|j],dp[i]+dp[j]);
            else dp[i|j]=dp[i]+dp[j];
        }
    }
    if(dp[(1<<n)-1]==0) cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
    
    return 0;
}


Measured memory_bytes: 256
x = int(input())
pow5 = [i**5 for i in range(10**3)]
powp = []
pown = []
for i in range(10**3):
    powp.append(pow5[i])
    pown.append(-pow5[i])

for i, ii in enumerate(pow5):
    for j, ji in enumerate(powp):
        if ii - ji == x:
            # print('pp')
            print(i, j)
            exit()
    for j, ji in enumerate(pown):
        if ii - ji == x:
            # print('p1')
            print(i, -j)
            exit()

Measured memory_bytes: 9252
n = int(input())
h = list(map(int,input().split()))
h[0]-=1
ans = True
for i in range(1,n):
    if h[i]<h[i-1]:
        ans=False
        break
    if h[i]==h[i-1]:
        continue
    if h[i]>h[i-1]:
        h[i]-=1
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

namespace {
long ans(const long N, const long L) {
  assert(2 <= N && N <= 200);
  assert(-100 <= L && L <= 100);

  const auto orig = (L + L + N - 1) * N / 2;
  if (L >= 0) return orig - L;
  if (N <= -L) return orig - (L + N - 1);
  return orig;
}
} // namespace

int main() {
  long N, L;
  cin >> N >> L;
  cout << ans(N, L);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main()
{
  int n;
  cin >> n;
  double up = 1.0;
  double down = 0.0;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    up *= a[i];
  }
  rep(i, n) {
    down += (up/a[i]);
  }
  double ans = up/down;
  printf("%.10f", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> b(n);
  rep(i, k) {
    int d; cin >> d;
    vector<int> a(d);
    rep(j, d) {
      cin >> a.at(j);
      b.at(a.at(j)-1)++;
    }
  }
  int cnt=0;
  rep(i, n) {
    if(b.at(i)==0) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll N,M;
    INX(N,M);
    
    vector<set<ll>> con(N+1);
    for (ll i = 0; i < M; i++)
    {
        ll A,B;
        INX(A,B);
        con[A].insert(B);
        con[B].insert(A);
    }

    vector<set<ll>> grp;
    vector<bool> checked(N+1,false);
    for(ll i = 1; i <= N; i++)
    {
        if(checked[i])
        {
            continue;
        }
        checked[i] = true;
        
        queue<ll> q;
        for(auto x : con[i])
        {
            q.push(x);
        }

        grp.resize(grp.size() + 1);
        ll grpindex = grp.size() - 1;
        grp[grpindex].insert(i);

        while(q.size() != 0)
        {
            ll target = q.front();
            q.pop();

            if(checked[target])
            {
                continue;
            }
            checked[target] = true;
            
            for(auto x : con[target])
            {
                q.push(x);
            }

            grp[grpindex].insert(target);
        }
    }
    OUTX(grp.size() - 1);
    



    return 0;
}


Measured memory_bytes: 22696
/* ex3_2
    riverstone*/

#include<stdio.h>
 
int main(void){
    //nをint型で定義して入力する。
    int n;
    scanf("%d", &n);
 
    // nを10で割った余りをswitchで場合分け
    switch (n % 10){
    case 2: case 4: case 5: case 7: case 9:
        printf("hon\n");
        break;
    
    case 0: case 1: case 6: case 8:
        printf("pon\n");
        break;
 
    case 3:
        printf("bon\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

// class ReconstructNumber {
// public:
//     string smallest(string);
// };

// string ReconstructNumber::smallest(string s) {
// }

int n, k;
ll C[5010][5010];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    C[0][0] = 1;
    FOR(i,1,5000)
        FOR(j,0,i)
            if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MODBASE;
    cin >> n >> k;
    int m = n - k;
    FOR(i,1,k) {
        int mid = i-1;
        if (m < mid) {
            cout << 0 << "\n";
            continue;
        }
        ll g = C[k-1][mid];
        int e = mid + 2;
        int w = m - mid;
        cout << g * C[w+e-1][e-1] % MODBASE << "\n";
    }
    return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

int main(){
    int n,a;
    cin>>n>>a;
    if(n%500<=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=3010;
const ll MOD=998244353;
int N,S;
int A[MAXN];
ll cnt[MAXN];
ll pre[MAXN][MAXN];
void read()
{
    cin>>N>>S;
    for(int u=1;u<=N;u++)cin>>A[u];
}
void solve()
{
    read();
    ll ans=0;
    for(int u=1;u<=N;u++){
        if(A[u]>S)continue;
        if(A[u]==S){
            ans=(ans+(ll)u*(N-u+1)%MOD)%MOD;
            continue;
        }
        ans=(ans+cnt[S-A[u]]*(N-u+1)%MOD)%MOD;
        for(int v=S;v>=A[u];v--){
            cnt[v]=(cnt[v]+cnt[v-A[u]])%MOD;
        }
        cnt[A[u]]=(cnt[A[u]]+u)%MOD;
    }
    cout<<ans;
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 384
from collections import deque

n, q = list(map(int, input().split()))
L = [deque() for _ in range(n)]

for i in range(q):
    query = input()

    # insert
    if query[0] == "0":
        _, t, x = list(map(int, query.split()))
        L[t].append(x)

    # dump
    elif query[0] == "1":
        _, t = list(map(int, query.split()))
        print(*L[t])
    
    # splice
    else:
        _, s, t = list(map(int, query.split()))
        if L[t]:
            if len(L[s]) == 1:
                L[t].append(L[s][0])
            elif len(L[t]) == 1:
                L[s].appendleft(L[t][0])
                L[t] = L[s]
            else:
                L[t].extend(L[s])
        else:
            L[t] = L[s]

        L[s] = deque()


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


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> ok(n,true);
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  if(n%2==0){
    long long ans=0;
    for(int i=0;i<(n/2)-1;++i) ans+=a[i]*(-2);

    ans-=a[n/2-1];
    ans+=a[n/2];

    for(int i=(n/2)+1;i<n;++i) ans+=a[i]*2;

    cout << ans << endl;

  }else{
    long long ans1=0;
    for(int i=0;i<(n/2);++i) ans1+=a[i]*(-2);
    ans1+=a[n/2+1]+a[n/2];
    for(int i=n/2+2;i<n;++i) ans1+=a[i]*2;


    long long ans2=0;
    for(int i=0;i<n/2-1;++i) ans2+=a[i]*(-2);

    ans2-=(a[n/2]+a[n/2-1]);

    for(int i=n/2+1;i<n;++i) ans2+=a[i]*2;

    long long ans=max(ans1,ans2);

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


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

using namespace std;

int main (){
    int a, b ,c; cin >> a >> b >> c;
    vector<int> vec = {a,b,c};
    sort(vec.begin(), vec.end());
    if(vec[0] == 5 && vec[1] ==5 && vec[2] == 7)
         cout << "YES";
         else
             cout << "NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    bool ok = false;
    for (int i = 0; i * 4 <= N; i++) {
        ok |= (N - 4 * i) % 7 == 0;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(void) {

    int a,b,c;

    cin >> a;
    cin >> b;
    cin >> c;

    cout << c;
    cout << " ";
    cout << a;
    cout << " ";
    cout << b ;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	string s;
	cin>>s;
	int x=0;
	int ans=0;
	for(int i=0;i<N;i++){
		if(s[i]=='I')x++;
		else x--;
		ans=max(ans,x);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
ll gcd(ll x,ll y){
  if(x%y==0){return y;}
  return gcd(y,x%y);
}
int main(){
  ll n,x;
  cin>>n>>x;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  if(n>1){
    ll g1=abs(a[1]-a[0]),g2=abs(a[0]-x);
    REP(i,2,n){
      g1=gcd(g1,abs(a[i]-a[0]));
      g2=gcd(g2,abs(a[i]-x));
    }
    g1=gcd(g1,g2);
    cout<<g1<<endl;
  }
  else{
    cout<<(abs(a[0]-x))<<endl;
  }
}

Measured memory_bytes: 1024
#include<stdio.h>
int n=0,k=0,dp[100005];

int min(int a,int b)
{
        int c=a<b?a:b;
        return c;
}
int mod(int a)
{
        if(a>=0)
                return a;
        else
                return -1*a;
}

int s(int a[],int i)
{
if(i==n-1)
return 0;

        if(dp[i]==-1)
        {
		dp[i] = s(a,i+1)+mod(a[i+1]-a[i]);
		for(int j=1;j<min(n-i-1,k);j++)
                dp[i] = min(dp[i], s(a,i+1+j)+mod(a[i+1+j]-a[i]));
        }
return dp[i];
}

int main()
{

        scanf("%d %d",&n,&k);
        int a[n];

        for(int i=0;i<n;i++)
        {scanf("%d",&a[i]); dp[i]=-1;}

        int sum = s(a,0);

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

        return 0;
}



Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
  int x, y;
  cin >> x >> y;
  bool xy = false;

  for (int i = 0; i <= x;i++){
    if(i*2+(x-i)*4==y)
      xy = true;
  }
  
  if(xy)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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 mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};

vector<int> G[50];
vector<vector<int>> id(50,vector<int> (50,0));

bool dfs(int u,int v,int s,vector<int> &f){
    if(u==s) return true;
    for(auto g:G[u]){
        if(g==v) continue;
        if(dfs(g,u,s,f)){
            f[id[u][g]] = true;
            return true;
        }
    }
    return false;
}


int main(){
    int n;cin >> n;
    vector<LL> p2(n+1,1);
    for (int i = 1; i <= n; i++) {
        p2[i] = p2[i-1] * 2;
    }
    for (int i = 0; i < n-1; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
        id[a][b] = i;
        id[b][a] = i;
    }
    int m;cin >> m;
    vector<P> v(m);
    for (int i = 0; i < m; i++) {
        cin >> v[i].fs >> v[i].sc;
        v[i].fs--,v[i].sc--;
    }
    vector<vector<int>> f(m, vector<int> (n-1,false));
    for (int i = 0; i < m; i++) {
        dfs(v[i].fs,v[i].fs,v[i].sc,f[i]);
    }
    vector<vector<int>> dp(1<<m,vector<int> (n-1,0));
    vector<bool> vis(1<<m,false);
    for (int bit = 0; bit < (1<<m); bit++) {
        for (int j = 0; j < m; j++) {
            if(!((bit>>j)&1)&&!vis[bit|1<<j]){
                int nbit = bit|(1<<j);
                dp[nbit] = dp[bit];
                for (int k = 0; k < n-1; k++) {
                    dp[nbit][k] |= f[j][k];
                }
                vis[nbit] = true;
            }
        }
    }
    vector<LL> cnt(1<<m,0);
    for (int i = 0; i < (1<<m); i++) {
        LL c = n-1;
        for (int j = 0; j < n-1; j++) {
            if(dp[i][j]) c--;
        }
        cnt[i] = p2[c];
    }
    LL ans = 0;
    for (int bit = 0; bit < (1<<m); bit++) {
        int f = __builtin_popcount(bit);
        if(f&1){
            ans -= cnt[bit];
        }
        else{
            ans += cnt[bit];
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int MAXN = 100;
const int MAXW = 100000;

unsigned long long dp[MAXN+1][MAXW+1];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, W;
    cin >> n >> W;
    int v[n+1], w[n+1];
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> v[i];
    }
    for(int i = 0; i <= n; i++){
        dp[i][0] = 0;
    }
    for(int i = 1; i <= W; i++){
        dp[0][i] = 0;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= W; j++){
            if(w[i] <= j) {
                dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    
    cout << dp[n][W];
    return 0;
}


Measured memory_bytes: 82528
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
2 3 2
..#
###
'''

def solve(L,H,W,K):
	R,C = [],[]
	rows = [i for i in range(H)]
	cols = [i for i in range(W)]
	for r in range(H+1):
		R.append(list(combinations(rows,r)))
	for c in range(W+1):
		C.append(list(combinations(cols,c)))
	RR,CC = [],[]
	for i in R:
		for j in i:
			jj = list(j)
			RR.append(jj)
	for i in C:
		for j in i:
			jj = list(j)
			CC.append(jj)
	ans = 0
	blacks = 0
	for i in range(H):
		for j in range(W):
			if(L[i][j] == '#'):
				blacks += 1
	for rc in RR:
		for cc in CC:
			curr = blacks
			for r in range(H):
				for c in range(W):
					if(r in rc or c in cc):
						if(L[r][c] == '#'):
							curr -= 1
			if(curr == K):
				ans += 1
	return ans



H,W,K = list(map(int, stdin.readline().rstrip().split()))
L = []
for i in range(H):
	L.append(list(input()))
ans = solve(L,H,W,K)
print(ans)



Measured memory_bytes: 78572
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main()
{
    fastio
    int x,y,n,m; cin>>x>>y;
    if(y%2==0)
    {
        n=(4*x-y)/2; m=(y-2*x)/2;
        if(n>=0&&m>=0) cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3664
using System;
using System.Linq;

class ITP1
{
    static void Main()
    {
        while (true)
        {
        var str = Console.ReadLine();
        int a = int.Parse(str.Split(' ')[0]);
        int b = int.Parse(str.Split(' ')[1]);
        int c = int.Parse(str.Split(' ')[2]);
        if(a == -1 && b == -1 && c == -1)break;
        else if((30 > (a + b)) || (a == -1 || b == -1))
            Console.WriteLine("F");
        else if(a + b >= 80)
            Console.WriteLine("A");
        else if(80 > (a + b) && (a + b) >= 65)
            Console.WriteLine("B");
        else if((65 > (a + b) && (a + b) >= 50)
            || ((50 > (a + b) && (a + b) >= 30) && c >=50))
            Console.WriteLine("C");
        else if(50 > (a + b) && (a + b) >= 30)
            Console.WriteLine("D");
    }
    }
}

Measured memory_bytes: 15528
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

// solution 
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        a: [i64; N],
    }
    let mut b = vec![0; N];
    for aind in 0..N {
        let res = N - aind;
        let bind = 
        if res % 2 == 0 { // 後ろから
            N - res / 2
        } else {
            res / 2
        };
        b[bind] = a[aind];
    }

    for &bi in b.iter() {
        print!("{} ", bi);
    }
}


Measured memory_bytes: 10364
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(li[K-1])

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

typedef long long ll;

vector<ll> divisor(ll N){
    vector<ll> res;
    for(ll i=1;i*i<=N;i++){
        if(N%i==0){
            res.push_back(i);
            if(i!=N/i) res.push_back(N/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}

int main(){
    int N,K; cin >> N >> K;
    ll a[N];
    ll sum=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        sum+=a[i];
    }
    vector<ll> div=divisor(sum);
    ll ans=0;
    for(int i=0;i<div.size();i++){
        ll tmp[N];
        for(int j=0;j<N;j++){
            tmp[j]=a[j]%div[i];
            //cout << tmp[j] << " ";
        }
        sort(tmp,tmp+N);
        for(int j=1;j<N;j++){
            tmp[j]+=tmp[j-1];
        }
        bool flag=false;
        for(int j=0;j<N;j++){
            ll a=0;ll b=0;
            a+=tmp[j];
            b+=div[i]*(N-1-j)-(tmp[N-1]-tmp[j]);
            //cout << res << " ";
            if(max(a,b)<=K){
                flag=true;
                break;
            }
        }
        //cout << endl;
        if(flag) ans=max(ans,div[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  vector<int> v, w;
  map<char, int> mp1, mp2;
  int c = 1;
  for (int i = 0; i < n; i++) {
    if (mp1[s[i]] == 0) {
      mp1[s[i]] = c++;
    }
    v.push_back(mp1[s[i]]);
  }
  c = 1;
  for (int i = 0; i < n; i++) {
    if (mp2[t[i]] == 0) {
      mp2[t[i]] = c++;
    }
    w.push_back(mp2[t[i]]);
  }
  bool ok = true;
  for (int i = 0; i < n; i++)
    if (v[i] != w[i])
      ok = false;
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 2940
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0

for i in range(60):
    cnt = 0
    digit = 1 << i
    for j in a:
        if digit & j:
            cnt += 1
    ans += digit*cnt*(n - cnt)%mod

print(ans%mod)

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

int main()
{
	scanf("%d",&a);
    for(int i=6;i>=0;i--)
    {
      int ans=pow(2,i);
      if(ans<=a)  {printf("%d\n",ans);return 0;}
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

int main(){
    string s;
    cin >> s;
    int flag = 1;
    int i;
    int count1 = 0;
    int count2 = 0;
    
    if(s[0] != 'A'){
        flag = 0;
    }
    
    for(i = 0; i < s.size(); i++){
        if(i >= 2 && i <= s.size()-2){
            if(s[i] == 'C'){
                count1++;
            }
        }
        
        if(s[i] >= 'a' && s[i] <= 'z'){
            count2++;
        }
    }
    
    if(count1 != 1 || count2 != s.size()-2){
        flag = 0;
    }
    
    if(flag){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}



Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = [int(m) for m in input().split()]
a = []
for i in range(n):#h:高さ
    a.append([int(m) for m in input().split()])

tmp = 0
ans = 0
for i in range(n):
    for j in range(m):
        tmp += a[i][j] * b[j]
    if tmp > -c:
        ans += 1
    tmp = 0
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, k, a[100];
bool dp[100008];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> k;
	zep(j, 0, n){cin >> a[j];}
	
	memset(dp, 0, sizeof(dp));
	rep(i, 1, k){
		zep(j, 0, n){
			if(i-a[j] >= 0 && !dp[i-a[j]]){
				dp[i] = true;
			}
		}
	}
	//printa(dp, 0, k)
	print((dp[k])? "First" : "Second")
	return 0;
}

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

const N = Number(stdin.split('\n')[0])
const s = stdin.split('\n')[1]

const S = s.split('')

let leftBlack = 0
let rightWhite = S.reduce((p, c) => {
  return p += c === '.' ? 1 : 0
}, 0)

let min = Math.min(rightWhite, N - rightWhite)
S.forEach(v => {
  leftBlack += v === '#' ? 1 : 0 
  rightWhite -= v === '.' ? 1 : 0
  
  const sum = leftBlack + rightWhite

  min = sum < min ? sum : min
})

console.log(min)


Measured memory_bytes: 9676
def score(m, f, r)
  return 'F' if m == -1 || f == -1
  return 'A' if m + f >= 80
  return 'B' if m + f >= 65
  return 'C' if m + f >= 50
  if m + f >= 30
    return 'C' if r >= 50
    return 'D'
  end
  'F'
end

data = []
loop do
  d = gets.split.map(&:to_i)
  break if d == [-1, -1, -1]
  data << d
end

data.each do |d|
  puts score(*d)
end

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

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int>v(n);
	vector<int>arr(n);//stores minimum energy to reach ith pillar
	arr[0]=0;
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
		
	}
	arr[1]=abs(v[0]-v[1]);
//	cout<<arr[1];
	for(int i=2;i<n;i++)
	{
		arr[i]=min((arr[i-1]+abs(v[i]-v[i-1])),(arr[i-2]+abs(v[i]-v[i-2])));
	//	cout<<arr[i];
	}
	cout<<arr[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int a, b, d, r;
  double f;
  scanf("%d %d", &a, &b);
  d = a/b;
  r = a%b;
  f = a/(double)b;
  printf("%d %d %f\n", d, r, f);
  return 0;
}

Measured memory_bytes: 1804
#include<cstdio>
int a[999][8],z,u,n,i,j,k;main(){scanf("%d ",&n);a[0][2]=1;for(i=0;i<n;i++){u=getchar()%4-1;j=8;while(j--){k=8;while(k--){if(j&k&&j>>u&1)a[i+1][j]+=a[i][k]%10007;}z+=a[n][j];}}printf("%d\n",z%10007);}

Measured memory_bytes: 1052
(N, A, B), Vs = readlines.map{|l| l.split.map(&:to_i)}

class Integer
  def !
    return 1 if self.zero?
    (1 .. self).inject(:*)
  end

  def C(m)
    self.! / (self - m).! / m.!
  end
end

v = Vs.sort.reverse
a = v.take(A)
ans = a.inject(:+) / A.to_f
m = a.min
x, y = v.count(m), a.count(m)
c = x.C y
(A ... B).each do |i|
  if v[i] == ans
    c += x.C(y += 1)
  else
    break
  end
end
puts ans, c

Measured memory_bytes: 1788
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
i = 0
kaisuu = 0


for i in range(k):
    h[i]=0
    if(i>=n-1):
        break

j = i

for j in range(j, n):
    kaisuu = kaisuu + h[j]

print(kaisuu)


Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int answer = 0;
  int i = 0;
  while (1000 * i - N < 1000) {
    answer = 1000 * i - N;
    i++;
  }
  cout << answer << endl;
}

Measured memory_bytes: 3532
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	cin >> M;
	vector<vector<long long int>>dp(2, vector<long long int>(M + 1));
	vector<long long int>by(M + 1, 1);
	for (int i = 0; i <= M; i++) {
		for (int j = 0; j < N; j++) {
			by[i] *= i;
			by[i] %= MOD;
		}
	}
	dp[0][M] = 1;
	for (auto i : v) {
		for (int k = 0; k <= M - i; k++) {
			for (int j = 0; j < 2; j++) {
				dp[j ^ 1][k] += dp[j][k + i];
				dp[j ^ 1][k] %= MOD;
			}
		}
	}
	long long int ans = 0;
	for (int i = 0; i <= M; i++) {
		ans += dp[0][i] * by[i] % MOD;
	}
	for (int i = 0; i <= M; i++) {
		ans += MOD - dp[1][i] * by[i] % MOD;
	}
	cout << ans % MOD << endl;
}


Measured memory_bytes: 4924
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 2e3 + 10;
const int M = 1e4 + 10;
const int D = 4e3;
char a[N], b[N], c[N];
bool ab[M], ac[M], bc[M];//若true则不满足 
int lena, lenb, lenc;
bool check(int x, int y) {
	return (x == '?' || y == '?' || x == y);
}
int main() {
	scanf("%s%s%s", a, b, c);
	lena = strlen(a);
	lenb = strlen(b);
	lenc = strlen(c);
	for (int i = 0; i < lena; i++) {
		for (int j = 0; j < lenb; j++) {
			if (!check(a[i], b[j])) {
				ab[i - j + D] = 1;
			}
		}
	}
	for (int i = 0; i < lena; i++) {
		for (int j = 0; j < lenc; j++) {
			if (!check(a[i], c[j])) {
				ac[i - j + D] = 1;
			}
		}
	}
	for (int i = 0; i < lenb; i++) {
		for (int j = 0; j < lenc; j++) {
			if (!check(b[i], c[j])) {
				bc[i - j + D] = 1;
			}
		}
	}
	int ans = 0x7f7f7f7f;
	for (int i = -D; i <= D; i++) {
		for (int j = -D; j <= D; j++) {
			if (!ab[i + D] && !ac[j + D] && !bc[j - i + D]) {
				int l = min(0, min(i, j));
				int r = max(lena, max(lenb + i, lenc + j));
				ans = min(ans, r - l); 
			}
		}
	}
	printf("%d", ans);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double arr[n];
    for(int i = 0;i<n;i++)
    {
        cin >> arr[i];
    }
    double dp[n+1][n+1];
    // dp(i, j) = probability of geting j heads from i coins
    for(int i = 0;i<=n;i++)
    for(int j = 0;j<=n;j++)
    {
        if(i == 0 and j == 0)
        dp[i][j] = 1.0;
        else if(j == 0 )
        dp[i][j] = (1 - arr[i-1])*dp[i-1][j];
        else if(i < j)
        {
            dp[i][j] = 0.0;
        }
        else
        {
            dp[i][j] = 1.0;
        }
    }
    for(int i = 1;i<=n;i++)
    {
        for(int j = 1;j<=i;j++)
        {
            dp[i][j] = arr[i-1]*(dp[i-1][j-1]) + (1.0 - arr[i-1])*dp[i-1][j];
        }
    }
    double sol = 0;0;
    for(int i = 1;i<=n;i++)
    {
        if(i > n - i)
        {
            sol += dp[n][i];
        }
    }
    cout << fixed ;
    cout.precision(15);
    cout << sol;
    
    return 0;
}

Measured memory_bytes: 70528
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char a[305][305],b[305][305];
int main()
{
    int n,i,j,l,k,flag,ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s",a[i]);
    for(i=0;i<n;i++)
 //       puts(a[i]);
    for(i=0;i<n;i++)
    {
        flag=1;
        for(j=0;j<n;j++)
        {
            for(k=0;k<n;k++)
                b[j][k]=a[(i+j)%n][k];
        }
        for(l=0;l<n;l++)
            for(k=0;k<n;k++)
        if(b[l][k]!=b[k][l]){
            flag=0;
            break;
        }
        if(flag) ans++;
    }
    printf("%d\n",ans*n);
}


Measured memory_bytes: 384
S=input()
j=0
refO=set(["R","U","D"])
refE=set(["L","U","D"])
for i in range(len(S)):
  if i%2==1 and (S[i] in refE):
    j+=1
  elif i%2==0 and (S[i] in refO):
    j+=1
  else:
    break
if j==len(S):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064