akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int n,m;

  cin>>n>>m;
  vector<int> a(m),b(m),c(n,0);
  //r(i,n)cout<<c.at(i)<<endl;;

  r(i,m)cin>>a.at(i)>>b.at(i);
  r(i,m){
    c.at(a.at(i)-1)++;
    c.at(b.at(i)-1)++;
  }
  r(i,n)cout<<c.at(i)<<endl;



  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main() {

    ll A, B, C; cin >> A >> B >> C;
    ll ans = A + B + C;

    if(ans >= 22){
        cout << "bust" << endl;
    }else if(ans <= 21){
        cout << "win" << endl;
    }

}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev, col;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
  d.resize(G.size());
  REP(i, d.size())d[i] = INF;
  d[s] = 0;
  priority_queue<P, vector<P>, greater<P>> q;
  q.push(make_pair(0, s));
  while (!q.empty()) {
    P a = q.top();
    q.pop();
    if (d[a.second] < a.first)continue;
    REP(i, G[a.second].size()) {
      Edge e = G[a.second][i];
      if (d[e.to] > d[a.second] + e.cap) {
        d[e.to] = d[a.second] + e.cap;
        q.push(make_pair(d[e.to], e.to));
      }
    }
  }
}

bool tsort(Graph& graph, Array& order) { 
 int n = graph.size(), k = 0;
 Array in(n);
 for (auto& es : graph)
  for (auto& e : es)in[e.to]++;
 priority_queue<ll, Array, greater<ll>> que;
 REP(i, n)
  if (in[i] == 0)que.push(i);
 while (que.size()) {
  int v = que.top();
  que.pop();
  order.push_back(v);
  for (auto& e : graph[v])
   if (--in[e.to] == 0)que.push(e.to);
 }
 if (order.size() != n)return false;
 else return true;
}

void solve(){
    ll n,k;
    cin>>n>>k;
    Array a(n),b(n);
    REP(i,n) cin>>a[i]>>b[i];

    auto check = [&]()->ll{
        ll sum=0;
        REP(i,n){
            if((~k)&a[i]) continue;
            sum+=b[i];
        }
        return sum;
    };

    ll ans=check();

    REP(r,30){
        if(k>>r&1){
            k-=(1LL<<r);
            chmax(ans,check());
        }
        k+=(1LL<<r);
    }
    cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int n, A[1010], min_num = INF;
int B[1010], num[10010];
void Mergesort(int A[], int left, int right)
{
    if(right - left == 1) return;
    int mid = left + (right - left) / 2;
    Mergesort(A, left, mid);
    Mergesort(A, mid, right);
    int buf[1010], pos = 0;
    for(int i = left; i < mid; i++)
    {
        buf[pos] = A[i];
        pos++;
    }
    for(int i = right - 1; i >= mid; i--)
    {
        buf[pos] = A[i];
        pos++;
    }
    int itel = 0;
    int iter = pos - 1;
    for(int i = left; i < right; i++)
    {
        if(buf[itel] <= buf[iter]) A[i] = buf[itel++];
        else A[i] = buf[iter--];
    }
}
int solve()
{
    int ret = 0;
    bool flag[1010];
    for(int i = 0; i < n; i++)
    {
        B[i] = A[i];
        flag[i] = false;
    }
    Mergesort(B, 0, n);
    for(int i = 0; i < n; i++) num[B[i]] = i;
    for(int i = 0; i < n; i++)
    {
        if(flag[i]) continue;
        int pos = i, sum = 0, m = INF, alpha = 0;
        while(1)
        {
            flag[pos] = true;
            int tmp = A[pos];
            m = min(m, tmp);
            sum += tmp;
            alpha++;
            pos = num[tmp];
            if(flag[pos]) break;
        }
        ret += min(sum + (alpha - 2) * m, m + sum + (alpha + 1) * min_num);
    }
    return ret;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
        min_num = min(min_num, A[i]);
    }
    cout << solve() << endl;
    return 0;
}




Measured memory_bytes: 3240
N = int(input())
D=[]
b=0
for _ in range(N):
  A,B=map(int, input().split())
  D.append([A,B,A+B])
  b+=B
D.sort(reverse=True, key=lambda x:x[2])

ans=0
while D!=[]:
  ans+=D[0][2]
  D.pop(0)
  if D!=[]:
    D.pop(0)
  
print(ans-b)



Measured memory_bytes: 24888
#include <iostream>
using namespace::std;
int N,K;
int main(){
    
    int h[100000]={0};
    int ans=0;
    cin>>N>>K;
    for(int i=1;i<=N;++i){
        cin>>h[i];
        if(h[i]>=K){
            ++ans;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
/*            IIIIIIIIIIIIIIIII  NNN           NN  TTTTTTTTTTTTTTT
                      II         NN NN         NN         TT
                      II         NN  NN        NN         TT
                      II         NN   NN       NN         TT
                      II         NN    NN      NN         TT
                      II         NN     NN     NN         TT
                      II         NN      NN    NN         TT
                      II         NN       NN   NN         TT
                      II         NN        NN  NN         TT
______________        II         NN         NN NN         TT
______________IIIIIIIIIIIIIIIII  NN           NNN         TT
*/


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define in insert
using namespace std;


int posA,posZ;
string s;

int main () {
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'A'){
            posA = i;
            break;
        }
    }
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'Z'){
            posZ = i;
        }
    }
    cout << posZ - (posA - 1);
	return 0;
}


Measured memory_bytes: 640
A,B,C = map(int,input().split(" "))

F = [
    lambda x:x,
    lambda x:[x[0]+1,x[1]+1,x[2]  ],
    lambda x:[x[0]  ,x[1]+1,x[2]+1],
    lambda x:[x[0]+1,x[1]  ,x[2]+1],
    lambda x:[x[0]+2,x[1]+1,x[2]+1],
    lambda x:[x[0]+1,x[1]+2,x[2]+1],
    lambda x:[x[0]+1,x[1]+1,x[2]+2]
    ]

T = [0,1,1,1,2,2,2]

o = []
for i in range(7):
    f = F[i]
    r = sorted(f([A,B,C]))
    if (r[2] - r[0])%2:
        continue
    if (r[2] - r[1])%2:
        continue
    o.append(T[i]+(r[2]-r[0])//2+(r[2]-r[1])//2)

print(min(o))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    int n,m,k;
    cin >> n >> m;

    vector<vector<int>> bulb(m,vector<int>());
    for(int i=0;i<m;++i){
        int k, s;
        cin >> k;
        for(int j=0;j<k;++j) {
            cin >> s;
            bulb[i].push_back(s-1);
        }
    }
    
    vector<int> p(m);
    for(int i=0;i<m;++i){
        cin >> p[i];
    }

    int ans = 0;
    for(int i=0;i<(1<<n);++i) {
        bool ok = true;
        for(int bi=0;bi<m;++bi) {
            int b_count = 0;
            for(int si: bulb[bi]) {
                if((1 << si) & i) {
                    ++b_count;
                }
            }
            if(b_count % 2 != p[bi]) {
                ok = false;
                break;
            }
        }
        if(ok) ++ans;
    }

    cout << ans << 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 n;
    cin >> n;
    ll a[n];

    cin >> a[0];
    ll sum = a[0];

    for (int i = 1; i < n; i++) {
        ll A;
        cin >> A;
        sum += A;
        a[i] = a[i - 1] + A;
    }

    ll ans = 1e12;
    rep(i, n - 1) {
        ll l = a[i];
        ll r = sum - a[i];
        ans = min(ans, abs(r - l));
    }

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


Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=500005;

char res[100];
int n;

int main(){
    while(~scanf("%s", &res)){
        int a=res[0]-'0', b=res[1]-'0', c=res[2]-'0', d=res[3]-'0';
        for(int i=0;i<2;i++){
            for(int j=0;j<2;j++){
                for(int k=0;k<2;k++){
                    int ans=a;
                    if(i==0)ans+=b;
                    else ans-=b;
                    if(j==0)ans+=c;
                    else ans-=c;
                    if(k==0)ans+=d;
                    else ans-=d;
                    if(ans==7){
                        printf("%d%c%d%c%d%c%d=7\n", a, i?'-':'+', b, j?'-':'+', c, k?'-':'+',d);
                        return 0;
                    }
                }
            }
        }
        //cout<<"gg"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	int a, b, t;
	cin >> a >> b >> t;
	cout << (t/a)*b;
	return 0;
}


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

signed main(){
    string s;
    cin >> s;
    cout << s.substr(0, 5) << " " << s.substr(6, 7) << " " << s.substr(14) << endl;
}

Measured memory_bytes: 256
n=int(input())
A=[]
for i in range(n):
  for _ in range(int(input())):
    x,y=map(int,input().split())
    A+=[(i,x-1,y)]
print(max(sum(map(int,bin(i)[2:])) for i in range(2**n) if all(i>>j&1<1 or i>>x&1==y for j,x,y in A)))

Measured memory_bytes: 9092
s = list(input())
cnt,tmp = 0,0
for i in range(len(s)):
    if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'):
        tmp += 1
    else:
        cnt = max(cnt,tmp)
        tmp = 0
cnt = max(cnt,tmp)
print(cnt)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
main()
{
	int w=0,x=0,p=0,len,i,y=0,z=0,cnt=0,c,cex=0;
	char s[10000];
	scanf("%s",s);
	len=strlen(s);
	if(s[0]=='A')
	{
		w=1;
	}
	for(i=2;i<len-1;i++)
	{
		if(s[i]>='A' && s[i]<='Z')
		{
			cnt++;
			c=i;
		}
	}
	
	if(cnt==1 && s[c]=='C')
	{
		x=1;
	}
	if(s[len-1]=='C' || (s[len-1]>='a' && s[len-1] <='z'))
	{
		y=1;
	}
	
	for(i=1;i<len-1;i++)
	{
		if(i!=c){
		if(s[i]>='a' && s[i]<='z')
		{
			z=1;
		}
		else if(s[i]<'a' || s[i]>'z'){
		break;}}
	}
	
	if(w==1 && x==1 && y==1 && z==1)
	{
		printf("AC\n");
	}
	else printf("WA\n");
	//printf("%d%d%d%d",w,x,y,z);
}
	
 


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;

int main(){

  int n;
  char c;
  int sum = 0;
  vector<int> V;

  while(1){
    scanf("%d%c",&n,&c);
    if(n == 0) break;
    
    V.push_back(n);
    if(c == '\n'){
      int first = 0;
      for(int i = 0; i < V.size(); i++){
	if(V[i] > 10 && V[i] <= 13 ) V[i] = 10;

	if(V[i] != 1) sum += V[i];
	else first++;
      }

      if(first > 0){
	int leaves = 21;
	leaves -= sum;
	leaves -= first;
	
	for(int i = 0; i < first;i++){
	  if(leaves >= 10) leaves -= 10;
	}
	sum = 21-leaves;

      } 
      if(sum > 21) sum = 0;
    }else{
      continue;
    }
    cout << sum << endl;
    sum = 0;
    V.clear();
  }

  return 0;
}

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

#define LISTSIZE 10000
 
int main(){
    int n[LISTSIZE];

    int x = 1;
    int i = 0;
    while (1){
        cin >> x;
        if (x==0) {
            break;
        }

        n[i] = x;
        i += 1;
    }

    for (int t=0; t<i; t=t+1) {
        cout << "Case " << t+1 << ": " << n[t] << endl;
    }

    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N, K;
ll cl[101010];
ll dp[60][60][5000];
ll i,j,k,l,ans;



int main(){
    scanf("%lld%lld", &N, &K);
    if(K%2){
        printf("0");
        return 0;
    }
    dp[0][0][0] = 1;
    fornum(i,0,N){
        //printf("%lld:\n", i + 1);
        fornum(j,0,N){
            fornum(k,2*j,N*N+1){
                if(j>0)
                    dp[i + 1][j][k] = ((1 + 2 * j) * dp[i][j][k - 2 * j] + (j+1) * (j+1) * dp[i][j + 1][k - 2 * j] + dp[i][j - 1][k - 2 * j])%MOD;
                else
                    dp[i + 1][j][k] = ((1 + 2 * j) * dp[i][j][k - 2 * j] + (j+1) * (j+1) *dp[i][j + 1][k - 2 * j])%MOD;
                //printf("%lld,", dp[i + 1][j][k]);
            }
            //printf("\n");
        }
    }
    printf("%lld", dp[N][0][K]);
    return 0;
}

Measured memory_bytes: 119040
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
c = 0
for i in range(n - 1):
    d = max(a[i + 1] + a[i] - x, 0)
    c += d
    if d <= a[i + 1]:
        a[i + 1] -= d
    else:
        a[i] -= d - a[i + 1]
        a[i + 1] = 0
print(c)

Measured memory_bytes: 14548
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, k, res = 0;
    int p[222222];
    double sum[222222] = {};
    cin>>n>>k;
    rep(i, n) {
        cin>>p[i];
        p[i]++;
    }
    rep(i, n) {
        sum[i + 1] += p[i] + sum[i];
    }
    double mx = -INF;
    rep(i, n - k + 1) {
        chmax(mx, sum[i + k] - sum[i]);
    }
    cout<<mx/2<<endl;
}


Measured memory_bytes: 3712
# -*- coding: utf-8 -*-

r, g, b, n = map(int, input().split())

ans = 0
for i in range((n//r)+1):
    for j in range(((n-i*r)//g)+1):
        if (n - i*r - j*g)%b == 0:
            ans += 1
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
ll Q,H,S,D,N;
cin>>Q>>H>>S>>D>>N;
N=N*4;
ll ans=0;
ll N2=0;
fx(4){
	ll Q2,H2,S2,D2,mini;
	switch(x){
		case 0:
		Q2=Q*8;H2=H*4;S2=S*2;D2=D;
		mini=min({Q2,H2,S2,D2});
		ans=mini*(N/8);
		N2+=(N/8)*8;
		break;
		case 1:
		Q2=Q*4;H2=H*2;S2=S;
		mini=min({Q2,H2,S2});
		ans+=mini*((N-N2)/4);
		N2+=((N-N2)/4)*4;
		break;
		case 2:
		Q2=Q*2;H2=H;
		mini=min({Q2,H2});
		ans+=mini*((N-N2)/2);
		N2+=((N-N2)/2)*2;
		break;
		case 3:
		Q2=Q;
		ans+=Q2*(N-N2);
		N2+=(N-N2);
		break;
	}

	if(N2==N){break;}
	
}

ce(ans)

}

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

int main(){

int k,cont1=1 , cont2=1, soma1=0,soma=0;

cin >> k;

for (int i=1;i<=k;i++){
    if (cont2%2==1){soma++;}
    cont2++;
}

for (int i=1;i<=k;i++){
    if (cont1%2==0){soma1++;}
    cont1++;
}
cout << soma*soma1 << endl;
return 0;
}


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

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

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

  //小さい順にソート
  sort(h.begin(), h.end());

  int ans = 1000000000;
  for (int i = 0; i < N-K+1; i++) {
    ans = min(ans, h[K-1+i]-h[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
signed main(){
	int n;
	cin >> n;
	int x[n],y[n];
	ll h[n];
	REP(i,n){
		cin >> x[i] >> y[i] >> h[i];
	}
	int non_zero;
	REP(i,n){
		if(h[i] != 0){
			non_zero = i;
			break;
		}
	}
	for(int cx = 0; cx <= 100; cx++){
		for(int cy = 0; cy <= 100; cy++){
			ll H = h[non_zero] + abs(x[non_zero] - cx) + abs(y[non_zero] - cy);
			REP(i,n){
				if(h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), (ll)0)){
					goto no;
				}
			}
			cout << cx << " " << cy << " " << H << endl;
			return 0;
			no:;
		}
	}
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }

    let mut ans = 0usize;
    let mut tail = 0;
    let mut xor = 0;
    let mut sum = 0;
    for head in 0..n {
        while tail < n && xor ^ a[tail] == sum + a[tail]  {
            xor ^= a[tail];
            sum += a[tail];
            tail += 1;
        }
        ans += tail - head;
        xor ^= a[head];
        sum -= a[head];
    }
    println!("{}", ans);
}


Measured memory_bytes: 4788
//52
#include<iostream>

using namespace std;

int main(){
  for(int c,cc,ccc;cin>>c>>cc>>ccc;){
    bool card[11]={};
    card[c]=card[cc]=card[ccc]=true;
    int u=0;
    for(int i=1;i<=10;i++){
      u+=(!card[i])&&(c+cc+i<=20);
    }
    cout<<((u>=4)?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else if(a == b){
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  if (A + B < 10) {
    cout << A + B << endl;
  } else {
    cout << "error" << endl;
  }
  
  
  return 0;  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<stack>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define mem(a,s) memset(a,s,sizeof(a))
stack<char> st;
char c;
int len;
int main(){
    //freopen("in.txt","r",stdin);
    while((c = getchar())!=EOF){
        if(c=='S')
            st.push(c);
        if(c=='T'){
            if(st.empty()||st.top()=='T'){
                len++;
                continue;
            }
            st.pop();
        }
    }
    cout<<len + st.size();
    return 0;
}

Measured memory_bytes: 384
s = input()
set_s = set(s)
ss = s[:]
t = []
_min = 10**7

for j in set_s:
    ss = s[:]
    t = []
    cnt = 0
    while len(set(ss)) != 1:
        for i in range(len(ss) - 1):
            if ss[i] == j or ss[i+1] == j:
                t.append(j)
            else:
                t.append(ss[i+1])
        ss = t[:]
        t.clear()
        cnt += 1
    
    _min = min(_min,cnt)    
print(_min)    
   

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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}

int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
  ll n,w;
  cin >> n >> w;
  
  vector<ll> weight(n);
  vector<ll> value(n);

  rep(i,n){
    cin >> weight[i] >> value[i];
  }
  vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));

  rep(i,n){
    rep(s,w+1){
      if(s >= weight[i])
        dp[i+1][s] = max(dp[i][s], dp[i][s-weight[i]]+value[i]);
      else
        dp[i+1][s] = dp[i][s];
    }
  }

  cout << dp[n][w] << endl;

	return 0;
}



Measured memory_bytes: 80256
//Pranet Verma
#include <bits/stdc++.h>
using namespace std;
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	s += s;
	cout << (s.find(t) == string::npos ? "No" : "Yes");
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    char b;
    scanf("%c", &b);
    char ans;
    switch(b){
        case 'A':
            ans = 'T';
            break;
        case 'C':
            ans = 'G';
            break;
        case 'G':
            ans = 'C';
            break;
        case 'T':
            ans = 'A';
            break;
        default:
            break;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
string q(int i){
    string s;
    cout<<i<<endl;
    cin>>s;
    return s;
}
int N;
int main(){
    cin>>N;
    long long l=0LL,r=N-1LL,mid;
    string s,L,R;
    L=q(l);if(L=="Vacant")return 0;
    R=q(r);if(R=="Vacant")return 0;

    while(r-l>1LL){
        s=q(mid=(l+r)/2LL);
        if(s=="Vacant")return 0;
        if((mid-l)%2==0&&s!=L||(mid-l)%2==1&&s==L)r=mid,R=s;
        else l=mid,L=s;
    }
    return 0;
}

Measured memory_bytes: 3860
n, m, s, t = gets.chomp.split(' ').map(&:to_i)
a_trains = Array.new(n + 1) { {} }
b_trains = Array.new(n + 1) { {} }

m.times.each do
  u, v, a, b = gets.chomp.split(' ').map(&:to_i)
  a_trains[u][v] = a_trains[v][u] = a
  b_trains[u][v] = b_trains[v][u] = b
end

def ds(s, trains, towns)
  towns[s] = 0
  queue = [s]
  while !queue.empty?
    n = queue.shift
    w = towns[n]
    trains[n].each do |next_town, value|
      next_w = w + value
      next if next_w >= towns[next_town]
      towns[next_town] = next_w
      queue << next_town
    end
  end
end

YEN = 1_000_000_000_000_000

towns_yen = Array.new(n + 1) { YEN }
towns_sn = Array.new(n + 1) { YEN }
ds(s, a_trains, towns_yen)
ds(t, b_trains, towns_sn)

ans = 1.upto(n).map { |i| towns_yen[i] + towns_sn[i] }
(n - 2).downto(0).each do |i|
  ans[i] = [ans[i], ans[i + 1]].min
end

0.upto(n - 1).each do |i|
  puts YEN - ans[i]
end



Measured memory_bytes: 79228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int group(int n){
    if(n==2)return 2;
    else if (n==4 || n==6|| n==9 || n==11) return 1;
    else return 3;
}
int main(){
    int x,y;cin>>x>>y;
    int X=group(x);
    int Y=group(y);
    if(X==Y)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;    
}


Measured memory_bytes: 3572
#include <stdio.h>
int main(void){
char s[100];
  char sb[100]="CODEFESTIVAL2016";
  int count,miss=0;
  scanf("%s",s);
  for(count=0;;count++){
  if(s[count]!=sb[count]){miss++;}
    if(count==16){break;}
  }
  printf("%d",miss);
return 0;
}

Measured memory_bytes: 128
A,B=map(int,input().split())
S=input()
cnt=0
for i in range(len(S)):
    if(S[i]=='-'):
        cnt+=1
if(cnt>1 or cnt<1):
    print("No")
    exit()
Sl,Sr=S.split('-')
if(len(Sl)==A and len(Sr)==B):
    print("Yes")
else:
    print("No")

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

int main() {
    int n;
    set<pair<string, pair<int, int>>> ans;

    cin >> n;
    for (int id = 1; id <= n; id++) {
        int point;
        string city;

        cin >> city >> point;
        ans.insert({city, {-point, id}});
    }

    for (auto i : ans) {
        cout << i.second.second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
const int P=1000000007;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
  ll n, m;
  cin>>n>>m;
  ll k=n-2;
  bool hoge=true;
  rep(i, m){
    if(n%2==0&&2*k<=n&&hoge){
      k--;
      hoge=false;
    }
    cout<<i+1<<" "<<i+1+k<<endl;
    k=k-2;
  }
  
}


Measured memory_bytes: 3876
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    const char *d[]={"lunch","dinner","midnight"};
    while(scanf("%d",&n),n){
        int cnt[3]={0},acnt[3]={0};
        while(n--){
            int t,m,r;
            scanf("%d%*c%d%d",&t,&m,&r);
            r-=m;
            if(r<0)r+=60;
            m+=t*60;
            if(11*60<=m&&15*60>m)t=0;
            else if(18*60<=m&&21*60>m)t=1;
            else if(21*60<=m||2*60>m)t=2;
            else continue;
            acnt[t]++;
            if(r<=8)cnt[t]++;
        }
        for(int i=0;i<3;i++){
            printf("%s ",d[i]);
            if(acnt[i]==0)printf("no guest\n");
            else printf("%d\n",100*cnt[i]/acnt[i]);
        }
    }
}

Measured memory_bytes: 1040
import math

animals = list(map(int, input().split(' ')))
dog = max(animals)
monkey = min(animals)
ans = 0



if dog - monkey == 0:
    ans = 2 * (math.factorial(dog) * math.factorial(monkey))
elif dog - monkey == 1:
    ans = math.factorial(dog) * math.factorial(monkey)
else:
    ans = 0
    
print(ans % (10 ** 9 + 7))

Measured memory_bytes: 5184
def main():
    A, B = map(int, input().split())
    S = input()
    print('YNeos'[not(
        S[A] == '-' and
        len(S[:A]) == A and S[:A].isdecimal() and
        len(S[A + 1:]) == B and S[A + 1:].isdecimal()
    )::2])


main()


Measured memory_bytes: 2940
object Main extends App {
  val Array(n, a, b) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val s = scala.io.StdIn.readLine
  var aa = 0
  var bb = 0

  s.foreach {
    case 'a' =>
      if ((aa + bb) < (a + b)) {
        println("Yes")
        aa += 1
      } else {
        println("No")

      }
    case 'b' =>
      if ((aa + bb) < (a + b) && bb < b) {
        println("Yes")
        bb += 1
      } else {
        println("No")
      }
    case 'c' =>
      println("No")
  }
}


Measured memory_bytes: 65928
N,M = map(int, input().split())
MOD = 10**9 + 7

if abs(N-M) > 1:
    print(0)
    exit()

n_res = 1
for i in range(1,N+1):
    n_res = i * n_res % MOD

m_res = 1
for i in range(1,M+1):
    m_res = i * m_res % MOD

if N == M:
    print((n_res **2 * 2) % MOD)
else:
    print((n_res * m_res) % MOD)


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

int main(void)
{
  int i, n, x, p[100], q[105] = {0}, result = 200, num = 200;
  
  scanf("%d %d", &x, &n);
  
  
  
  for( i = 0; i < n; i++ ){
      scanf("%d", &p[i]);
      q[p[i]] = 1;
  }
  
  for( i = -1; i < 102; i++ ){
    if( i == -1 || q[i] == 0 ){
        if( i <= x ){
            if( result > x - i ){
                result = x - i;
                num = i;
            }
        }
        if( i > x ){
            if( result > i - x ){
                result = i - x;
                num = i;
            }
        }
    }
  }
  
    printf("%d\n", num);
 
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

 
int main(void) {
    // your code goes here
    int a,b,z;
    scanf("%d %d",&a,&b);
    if(a>=10){
        printf("%d",b);
    }else{
        z=100*(10-a);
        z=z+b;
        printf("%d",z);
    }
    return 0;
}
 

Measured memory_bytes: 128
from collections import Counter
from functools import reduce
from itertools import combinations
from operator import xor

n = int(input())
nodes = [0] * n
for _ in range(n - 1):
    x, y, a = map(int, input().split())
    nodes[x] ^= a
    nodes[y] ^= a

c = Counter(nodes)
del c[0]
ans = 0
remains = set()
for i, v in c.items():
    ans += v // 2
    if v % 2:
        remains.add(i)

for r in (3, 4, 5):
    while not r < len(remains) < r * 2:
        for ns in combinations(remains, r):
            if reduce(xor, ns) == 0:
                remains.difference_update(ns)
                ans += r - 1
                break
        else:
            break
print(ans)


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

int main( int argc, char *argv[] )
{
int A;
int B;
int C;

	// 入力
	cin >> A;
	cin >> B;
	cin >> C;

	// 出力
	if(  A-B==B-C )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}



Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(12);
}
signed main(){
  init_io();
  ll n,k,pt;
  double ans=0;
  cin >> n >> k;
  for(int i=1;i<=n;i++){
    ll pt = i;
    double tmp = 1.0/n;
    while(pt<k){
      pt *= 2;
      tmp *= 1.0/2.0;
    }
    ans += tmp;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  char s;
  cin>>s;
  if(s>='A' && s<='Z')
    cout<<'A';
  else
    cout<<'a';
}

Measured memory_bytes: 3584
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto A = scan!long(N);
  auto Q = scan!int;
  auto Queues = Q.iota.map!(x => Queue(scan!long, scan!long)).array;

  void solve() {
    long[long] nums;
    long summary;
    foreach(a; A) {
      nums[a]++;
      summary += a;
    }

    foreach(q; Queues) {
      if (q.from in nums) {
        nums[q.to] += nums[q.from];
        summary += (q.to - q.from) * nums[q.from];
        nums.remove(q.from);
      }
      writeln(summary);
    }

    return;
  }

  solve();
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Queue = Tuple!(long, "from", long, "to");

// -----------------------------------------------


Measured memory_bytes: 9464
#include <iostream>
#include <string>
#define llint long long

using namespace std;

llint n;
string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	cin >> s;
	
	llint ans = 0;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < 10; k++){
				string t;
				t += i+'0';
				t += j+'0';
				t += k+'0';
				
				llint p = 0;
				for(int l = 0; l < n; l++){
					if(s[l] == t[p]) p++;
					if(p == 3) break;
				}
				if(p == 3) ans++;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
xy = list(map(int, input().split())) 
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]
if set(xy) <= set(g1) or set(xy) <= set(g2) or set(xy) <= set(g3):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
H, W = map(int, input().split())
A = []
for i in range(H):
    B = input()
    C = []
    for j in B:
        C.append(j)
    A.append(C)

flag = 0
for k in range(H):
    if flag == 1:
        break
    for l in range(W):
        if A[k][l] == "#":
            if A[max(0, k-1)][l] == A[k][max(0, l-1)] == A[min(H-1, k+1)][l] == A[k][min(W-1, l+1)] == ".":
                flag = 1
                break

if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
//Pantyhose + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_N = 4002;
const int MOD = 998244353;

int C[MAX_N][MAX_N];

int euler_candy(int n, int k) {
	if (n<0)
		return 0;
	return C[n+k-1][k-1];
}

void solve() {
	int n, k;
	cin >> k >> n;
	for (int i=0; i<=n+k; ++i)
		C[i][i] = C[i][0] = 1;
	for (int i=1; i<=n+k; ++i)
		for (int j=1; j<=n+k; ++j)
			C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
	for (int x=2; x<=2*k; ++x) {
		int cnt = min(k, x/2 + x%2 - 1) - max(1, x-k) + 1;
		//assert(cnt>=0);
		int res = 0;
		// if (x==4)
		// 	debug(cnt);
		for (int i=0; i<=cnt; ++i) {
			if (x%2) {
				int tmp = 1LL * C[cnt][i] * euler_candy(n-i*2, k) % MOD;
				//assert(tmp>=0);
				//debug(tmp);
				if (i%2==0)
					res = (res + tmp) % MOD;
				else
					res = (res - tmp + MOD) % MOD;
			}
			else {
				int tmp1 = 1LL * C[cnt][i] * euler_candy(n-i*2, k-1) % MOD;
				int tmp2 = 1LL * C[cnt][i] * euler_candy(n-i*2-1, k-1) % MOD;
				//assert(tmp1>=0 && tmp2>=0);
				if (i%2==0)
					res = (res + (tmp1 + tmp2) % MOD) % MOD;
				else
					res = (res - (tmp1 + tmp2) % MOD + MOD) % MOD;
			}
		}
		cout << res << '\n';
	}
}

int main() {
	#ifdef OFFLINE_JUDGE
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	solve();
}

Measured memory_bytes: 62848
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int ll;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

int main() {
    int a, b;
    cin >> a >> b;
    if (a+b < 10) cout << a+b << endl;
    else cout << "error" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <limits.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    std::vector<unsigned long long int> a;
    for(int i=0; i<n; i++){
        unsigned long long int tmp;
        cin >> tmp;
        if(tmp == 0){
            cout << 0 << endl;
            return 0;
        }
        a.push_back(tmp);
    }
    std::sort(a.begin(), a.end());
    
    unsigned long long int sum = a[0];
    for(int i=1; i<n; i++){
        if(sum > 1000000000000000000/a[i]){
            cout << "-1" << endl;
            return 0;
        }
        sum *= a[i];
        //cout << sum << endl;
    }

    cout << sum << endl;       
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> poss;
    vector<pair<int, int>> negs;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        int tot_o = 0, tot_c = 0;
        int max_c = 0;
        for (char c : s) {
            if (c == '(')
                tot_o++;
            else {
                tot_c++;
                max_c = max(max_c, tot_c - tot_o);
            }
        }
        int max_o = tot_o - tot_c + max_c;
        if (max_o >= max_c) {
            poss.emplace_back(max_c, max_o);
        } else {
            negs.emplace_back(max_o, max_c);
        }
    }
    sort(poss.begin(), poss.end());
    sort(negs.rbegin(), negs.rend());
    int curr = 0;
    for (auto pos : poss) {
        if (pos.first > curr) {
            cout << "No" << endl;
            return 0;
        }
        curr += pos.second - pos.first;
    }
    for (auto neg : negs) {
        if (neg.second > curr) {
            cout << "No" << endl;
            return 0;
        }
        curr += neg.first - neg.second;
    }
    if (curr == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 11268
import numpy as np

N = int(input())
As=input().split()
A = np.array([int(s) for s in As])
del(As)
Ans = np.sum(np.abs(A))
co = np.sum(A < 0)
if co%2==0:
    print(Ans)
else:
    Ans = Ans - 2*np.amin(np.abs(A))
    print(Ans)

Measured memory_bytes: 24124
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

int main() {
	for (int a = 0; a < 1000; a++) {
		string b;
		cin >> b;
		bool s = true;
		for (int c = 1; c < b.length(); c++) {
			if (abs(b[c] - b[c - 1]) != 3) {
				if (min(b[c], b[c - 1]) == 'C' || min(b[c], b[c - 1]) == 'F' || min(b[c], b[c - 1]) == 'I' || max(b[c], b[c - 1]) == 'A' || max(b[c], b[c - 1]) == 'D' || max(b[c], b[c - 1]) == 'G' || abs(b[c] - b[c - 1]) != 1)s = false;
			}
		}
		if (s)cout << b << endl;
	}
}

Measured memory_bytes: 3140
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

pi = np.pi

N,L = map(int,readline().split())
T = np.array(read().split(),np.int64)

theta = (T[:,None] + T[None,:]) * (pi/L)
a = np.arange(N)
coef = N-2*(a[None,:] - a[:,None])
coef = np.triu(coef,1)

cnt = N*(N-1)*(N-2)/6
x = np.sum(np.cos(theta) * coef) / cnt
y = np.sum(np.sin(theta) * coef) / cnt
print(x,y)

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

int main() {
   string S;
   cin >> S;
   if (S == "Sunny"){
       cout << "Cloudy";
   } else if (S == "Rainy"){
       cout << "Sunny";
   } else if (S == "Cloudy"){
       cout << "Rainy";
   }
   
   
   
   
   
   
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = int.Parse(Console.ReadLine());
            
            var h = input / 3600;
            var s = input % 3600;
            var m = s / 60;
            s = input % 60;

            Console.WriteLine("{0}:{1}:{2}",h,m,s);
        }
    }
}

Measured memory_bytes: 5620
N = int(input())
K = int(input())
x = list(map(int, input().split()))
A = [0] * N
B = [0] * N

ans = 0
for i in range(N):
    x[i] = [x[i], i+1]
    A[i] = [0, i+1]
    B[i] = [K, i+1]

    if x[i][1] == A[i][1] == B[i][1]:
        ans += min(abs(x[i][0] - A[i][0]), abs(x[i][0] - B[i][0]))

print(ans*2)

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    if (M ==1 || N >= M) {
      System.out.println(0);
      return;
    }
    int[] X = new int[M];
    int[] ds = new int[M-1];
    for (int i =0; i<M; i++) {
      X[i] = sc.nextInt();
    }
    Arrays.sort(X);
    long total =0;
    for (int i =0; i<M-1; i++) {
      ds[i] = X[i+1] - X[i];
      total += (long)ds[i];
    }
    Arrays.sort(ds);
    for (int i =M-2; i>M-N-1; i--) {
      total -= (long)ds[i];
    }
    System.out.println((long)total);
  }
}

Measured memory_bytes: 60080
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 1
#define dd if (DEBUG)

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    int i, j, n, a, b;
    cin >> a >> b;
    if (a < b)
        for (i = 0; i < b; ++i)
            cout << (char)(a + '0');
    else for (i = 0; i < a; ++i)
            cout << (char)(b + '0');
    cout << "\n";

    return 0;
}




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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    long long n,a,b,ans;
    while(cin>>n>>a>>b){
        ans=n/(a+b)*a;
        if(n%(a+b)!=0){
            ans+=min(a,n%(a+b));
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256