akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    
    vector<int> MonstersHP(N);
    for (int i = 0; i < N; i++)
    {
        cin >> MonstersHP.at(i);
    }

    sort(MonstersHP.begin(),MonstersHP.end());
    
    long int c = 0;
    for (int i = 0; i < N-K; i++)
    {
        c += MonstersHP.at(i);
    }

    cout << c << endl;
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 500005;
string s;
int stree[N << 2][26];
int n, q;

int build(int l, int r, int pos, int c) {
    if(l == r) {
        stree[pos][c] = s[l - 1] == c + 'a';
        return stree[pos][c];
    }
    int m = l + r >> 1;
    int x = build(l, m, pos * 2 + 1, c);
    int y = build(m + 1, r, pos * 2 + 2, c);
    stree[pos][c] = x + y;
    return stree[pos][c];
}

int update(int i, int cl, int cr, int v, int pos, int c) {
    if(cl > i || cr < i) {
        return stree[pos][c];
    } else if(cl == i && cr == i) {
        stree[pos][c] = v;
        return v;
    }
    int m = cl + cr >> 1;
    int x = update(i, cl, m, v, pos * 2 + 1, c);
    int y = update(i, m + 1, cr, v, pos * 2 + 2, c);
    stree[pos][c] = x + y;
    return stree[pos][c];
}

int query(int l, int r, int cl, int cr, int pos, int c) {
    if(cl > r || cr < l) {
        return 0;
    } else if(cl >= l && cr <= r) {
        return stree[pos][c];
    }
    int m = cl + cr >> 1;
    int x = query(l, r, cl, m, pos * 2 + 1, c);
    int y = query(l, r, m + 1, cr, pos * 2 + 2, c);
    return x + y;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> s >> q;
    rep(c, 0, 25) {
        build(1, n, 0, c);
    }
    while(q--) {
        char c;
        int t, l, r;
        cin >> t;
        if(t == 1) {
            cin >> l >> c;
            rep(cc, 0, 25) {
                update(l, 1, n, c == cc + 'a', 0, cc);
            }
        } else if(t == 2) {
            cin >> l >> r;
            int ans = 0;
            rep(cc, 0, 25) {
                ans += query(l, r, 1, n, 0, cc) > 0;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


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

int main(){
  int n = 0;
  int h[100000] = {};
  int c[100000] = {};
  int i = 0;
  int k = 0;
  int a = 0;
  int b = 0;

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

  for (i = 0; i < n; i++){
    if (b > i) {
    }else{
    for (k = 0; i + k + 1 < n; k++){
      if (h[i + k] >= h[i + k + 1]){
        c[i] = c[i] + 1;
        b = i + k + 1;
      }else{break; }
    }
    if (a < c[i]) a = c[i];
  }}

  cout << a;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);

    vector<int> a(n+1);
    int i;
    for(i=0; i<m; i++) {
        int tmp;
        scanf("%d", &tmp);
        a[tmp]=1;
    }

    vector<ll> dp(n+1,0);
    dp[0]=1;
    for(i=1; i<=n; i++) {
        if(!a[i]) {
            if(i==1) dp[i]=dp[0];
            else dp[i]=(dp[i-1]+dp[i-2])%MOD;
        }
    }
    printf("%lld\n", dp[n]);

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr long long LINF=334ll<<53; constexpr int INF=15<<26; constexpr long long MOD=1E9+7;

struct Edge{
    int from,to;
    Edge(int from,int to)
        : from(from),to(to) {};
};
typedef vector<vector<Edge>> Graph;




void ok(){cout << "YES" <<"\n"; exit(0);}
void fail(){cout << "NO" <<"\n"; exit(0);}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n),upward(n),l(n),u(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }
    Graph t(n);
    for(int i=0; i<n-1; ++i){
        int a,b;
        cin >> a >> b;
        --a;--b;
        t[a].push_back(Edge(a,b));
        t[b].push_back(Edge(b,a));
    }
    if(n==2){
        if(a[0]==a[1])ok();
        else fail();
    }

    int root=0;
    for(int i=0; i<n; ++i){
        if((int)t[i].size()>1){
            root=i;
        }
    }

    function <void(int,int)> dfs = [&](int par, int cur){
        if((int)t[cur].size()==1){
            upward[cur]=a[cur];
            return;
        }
        int ub=0,sum=0;
        for(auto &e : t[cur]){
            if(e.to!=par){
                dfs(cur,e.to);
                sum+=upward[e.to];
                ub=max(ub,upward[e.to]);
            }
        }
        if(sum<a[cur])fail();
        upward[cur]=a[cur]*2-sum;
        if(upward[cur]<0) fail();
        if(ub>a[cur]) fail();
    };


    dfs(-1,root);
    if(upward[root]==0)ok();
    else fail();


    return 0;
}



Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

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

const ll mod = 1e9 + 7;

int main(){
    ll K, S;
    cin >> K >> S;
    ll ans = 0;
    rep(x,K+1){
        rep(y,K+1){
            ll z = S - x - y;
            if (z>=0 && z<=K){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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


int main(){
	int n;
	std::cin >> n;
	std::map<int, int> ans;

	int arr[n+1];
	for(int i = 2;i <= n;i++){
		std::cin >> arr[i];
		ans[arr[i]]++;
	}

	for(int i = 1;i <= n;i++){
		std::cout << ans[i] << '\n';
	}

}


Measured memory_bytes: 13752
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1e5+5;
const int MAXM=2e5+5;
int edge,head[MAXN],tail[MAXM],nex[MAXM];
int rd[MAXN],d[MAXN];
int n,m;
void add(int u,int v){
	edge++,nex[edge]=head[u],head[u]=edge,tail[edge]=v;
}
void dfs1(int u){
	for (int e=head[u];e;e=nex[e]){
		int v=tail[e];
		if (d[v]==-1){
			d[v]=d[u]+1; dfs1(v);
		}
		else if (d[v]>d[u]){
			printf("%d %d\n",u,v);
//			cout<<"in"<<endl;
			rd[u]++;
//			cout<<"out"<<endl;
		}
	}
}
void dfs2(int u,int p){
	for (int e=head[u];e;e=nex[e]){
		int v=tail[e];
		if (d[v]==d[u]+1) dfs2(v,u);
	}
//	cout<<u<<" "<<p<<endl;
	if (u==1) return;
	if (rd[u]&1) printf("%d %d\n",u,p);
	else printf("%d %d\n",p,u),rd[p]++;
}
int main(){
	scanf("%d%d",&n,&m);
//	if (m&1) return printf("0\n"),0;
	for (int i=1;i<=m;i++){
		int u,v; scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	if (m&1) return printf("-1\n"),0;
	for (int i=2;i<=n;i++) d[i]=-1;
	dfs1(1); 
//	for (int i=1;i<=n;i++) printf("id:%d d:%d rd:%d\n",i,d[i],rd[i]);
	dfs2(1,0);
	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for(ll i = 0; i < (n); i++)
#define fori(i, b, e) for(ll i = (b); i < (e); i++)
#define forr(i, b, e) for(ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    Arr a(n + 1);
    forn(i, n) cin >> a[i + 1];
    vector<bool> ans(n + 1);
    forr(i, n, 1)
    {
        bool res = a[i];
        for(ll j = i * 2; j <= n; j += i)
            res ^= ans[j];
        ans[i] = res;
    }
    cout << count_if(allele(ans), [](bool x)->bool{
        return x;
    }) << endl;
    forn(i, n) if(ans[i + 1]) cout << (i + 1) << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc151/tasks/abc151_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> wa(N + 1);
    bitset<100001> bt;
    while (M--) {
        int p;
        string s;
        cin >> p >> s;
        // ACしていない
        if (!bt[p]) {
            if (s == "AC") {
                bt.set(p);
            } else {
                wa[p]++;
            }
        }
    }
    int a = 0, b = 0;
    FOR(i, 1, N + 1) {
        if (bt[i]) {
            a++;
            b += wa[i];
        }
    }
    cout << a << " " << b << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3980
from copy import copy
n = int(input())
s = list(map(int, input()))
m = 1000
DP = [0]*m
DP[0] = 1

s1 = set()
s1.add((0,0))
ans = [0]*m
for si in s:
    s2 = copy(s1)
    for i,j in s1:
        k = (i*10+si)%m
        if j == 2:
            ans[k] = 1
        else:
            s2.add((k, j+1))
    s1 = s2

print(sum(ans))

Measured memory_bytes: 43924
N, T = map(int, input().split())
t = list(map(int, input().split()))
c = 0
for i in range(N - 1):
    if t[i + 1] - t[i] > T:
        c += T
    else:
        c += t[i + 1] - t[i]
print(c + T)


Measured memory_bytes: 26832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		
		for(int i = 0 ; i <= 200 ; i++) {
			for(int j = 0 ; j <= 200 ; j++) {
				if((i+j) == x && (2*i + 4*j) == y) {
					System.out.println("Yes");
					return;
				}
			}
		}
		
		System.out.println("No");
		}

}


Measured memory_bytes: 35700
#include <stdio.h>

#define PutChar(c) ; *p = (char)(c); ++p;

#define MAX_N (2000001)
#define MAX_Ai (10000)
#define STR_SIZE (10000010)

int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int lenA);

int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;

int main(void) {
	register int i;
	int n;

	fread(str, 1, STR_SIZE, stdin);
	
	n = getNum();
	
	for (i = 1; i <= n; ++i) {
		A[i] = getNum();
	}
	
	CountingSort(A, B, MAX_Ai, n);
	
	p = str;
	--n;
	for (i = 1; i <= n; ++i) {
		putNum(B[i]);
		PutChar(' ');
	}
	putNum(B[i]);
	PutChar('\0');
	
	puts(str);
	
	return 0;
}

int getNum(void) {
	int n = 0;
	while ((*p >= '0') && (*p <= '9')) {
		n = n * 10 + (int)(*p - '0');
		++p;
	}
	++p;
	return n;
}

void putNum(int n) {
	int d;
	if (n < 10) {
		PutChar('0' + n);
		return;
	}
	d = n / 10;
	if (d) putNum(d);
	PutChar('0' + (n - (d * 10)));
}

void CountingSort(int A[], int B[], int k, int len) {
	int C[MAX_Ai] = { 0 };
	int i, j;
	for (j = 1; j <= len; ++j) {
		++C[A[j]];
	}
	for (i = 1; i <= k; ++i) {
		C[i] += C[i - 1];
	}
	for (j = len; j > 0; --j) {
		B[C[A[j]]] = A[j];
		--C[A[j]];
	}
}

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

template <typename T> struct fenwick {
	int n;
	int step;
	vector<T> a;

	fenwick(int _n) : n(_n), a(n + 1) { 
		for (step = 1; 2 * step <= n; step *= 2) { }
	}

	 // update i, 0 <= i < n
	void update(int i, T v) {
		assert(0 <= i && i < n);
		for (i++; i <= n; i += (i & -i)) {
			a[i] += v;
		}
	}

	// sum [0, i), 0 <= i <= n
	T query(int i) {
		assert(0 <= i && i <= n);
		T res{};
		for (; i; i -= (i & -i)) {
			res += a[i];
		}
		return res;
	}

	// sum [a, b)
	T query(int l, int r) {
		return query(r) - query(l);
	}

	// minimum i such that sum[0, i) >= v
	// returns n+1 if sum of all elements < v
	// [NOT TESTED]
	int lowerBound(T v) {
		if (v <= 0) return 0;
		int res = 0;
		for (int len = step; len >= 1; len /= 2) {
			int nxt = res + len;
			if (nxt <= n && a[nxt] < v) {
				v -= a[nxt];
				res = nxt;
			}
		}
		return res + 1;
	}
};

const int MAXM = 1.1e5;
int N;
int M;

vector<int> evts[MAXM];
vector<int> divisors[MAXM];

int ans[MAXM];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		int l, r; cin >> l >> r; r++;
		evts[l].push_back(r);
	}

	for (int x = 1; x <= M; x++) {
		for (int y = x; y <= M; y += x) {
			divisors[y].push_back(x);
		}
	}

	fenwick<int> sum(M+2);
	for (int x = 1; x <= M; x++) {
		for (int r : evts[x]) {
			sum.update(x, 1);
			sum.update(r, -1);
		}

		for (int d : divisors[x]) {
			ans[d] += sum.query(x + 1);
			if (x + d <= M) {
				ans[d] -= sum.query(x + d + 1);
			}
		}
	}

	for (int x = 1; x <= M; x++) {
		cout << ans[x] << '\n';
	}

	return 0;
}


Measured memory_bytes: 17536
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    ll n,ma,k=0;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n){
        cin>>a[i];
        ma=max(ma,a[i]);
    }
  rep(i,0,n) if(abs(ma/2-a[i])<abs(ma/2-k))k=a[i];
  cout<<ma<<" "<<k;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
long myPow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
struct Numbers{
    int n;
    int r=MOD;
    vector<int> array;
    Numbers(int N){
        n=N;
        rep(i,n+1){
            array.push_back(1);
        }
        rep1(i,n){
            array[i]=array[i-1]*i;
            array[i]%=r;
        }
    }
    long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
    }
    int comb(int n,int k){
        int res=array[n];
        res*=modinv(array[n-k],r);
        res%=r;
        res*=modinv(array[k],r);
        res%=r;
        return res;
    }
};
signed main(){
  int n,m;cin>>n>>m;
  vector<int> div;
  int buf=m;
  int cur=2;
  while(buf>1){
    if(buf%cur==0){
      buf/=cur;
      div.push_back(cur);
    }
    else{
      cur++;
    }
    if(cur>40000){
      break;
    }
  }
  if(buf!=1)div.push_back(buf);
  int num=div.size();
  div.push_back(inf);
  Numbers nums(1000000);
  cur=0;int last=inf;
  int res=1;
  rep(i,num+1){
    if(div[i]==last){
      cur++;
    }
    else{
      last=div[i];
      if(i==0){
        cur=1;
        continue;
      }
      res*=nums.comb(cur+n-1,cur);
      res%=MOD;
      cur=1;
    }
    //cout<<res<<endl;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
#define   ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define   ll  long long
#define   pi  pair<int,int>
#define   pb  push_back
const int N=2e5+2;
string a,b;
int main()
{
    ft
    ll t,i,j,n,m,k,r,s,p,ans=0;
    cin>>n>>k>>r>>s>>p>>a;
    ll sz=a.size();
    ll mn=min(sz,k);
    for(i=0; i<mn; i++)
    {
        if(a[i]=='r')
        {
            b+='p';
            ans+=p;
        }
        else if(a[i]=='p')
        {
            b+='s';
            ans+=s;
        }
        else
        {
            b+='r';
            ans+=r;
        }
    }
    for(i=mn; i<sz; i++)
    {
        if(a[i]=='r')
        {
            if(b[i-k]!='p')
            {
                b+='p';
                ans+=p;
            }
            else
            {
                if(a[i-k]=='p')
                {
                    b[i-k]='r';
                    ans+=p;
                    b+='p';
                }
                else
                {
                    b+='r';
                }
            }
        }
        else if(a[i]=='p')
        {
            if(b[i-k]!='s')
            {
                b+='s';
                ans+=s;
            }
             else
            {
                if(a[i-k]=='s')
                {
                    b[i-k]='p';
                    ans+=s;
                    b+='s';
                }
                else
                {
                    b+='p';
                }
            }
        }
        else
        {
            if(b[i-k]!='r')
            {
                b+='r';
                ans+=r;
            }
             else
            {
                if(a[i-k]=='r')
                {
                    b[i-k]='s';
                    ans+=r;
                    b+='r';
                }
                else
                {
                    b+='s';
                }
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 640
n,m = map(int, input().split())
l = [[] for _ in range(n)]
for i in range(m):
    p,y = map(int, input().split())
    l[p-1].append((y, i))
ans = [None]*m
for i,pre in enumerate(l):
    pre.sort()
    for j,(a,b) in enumerate(pre):
        ans[b] = "{:0>6}{:0>6}".format(i+1,j+1)
print("\n".join(ans))

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

int main() {
    string s;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < 3; i++){
        if(s[i] == 'A') a++;
        if(s[i] == 'B') b++;
    }
    if(a >= 1 && b >= 1) s = "Yes";
    else s = "No";
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(void){
int a,i;
float b,c,d,e,f,g,h,j;

scanf("%d",&a);
for(i = 1; i <= a; i++){
  scanf("%f %f %f %f %f %f %f %f",&b,&c,&d,&e,&f,&g,&h,&j);


  if((e - c)/(d - b) == (j - g)/(h - f))
   printf("YES\n");
  
  else
  printf("NO\n");
  
}
return 0;

}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N=1e7+5;

int n,k,jc[N],inv[N];

const int mod=1e9+7;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

inline int ksm(int x,int y)
{
	int ret=1ll;
	while(y)
	{
		if(y&1) ret=ret*x%mod;
		x=x*x%mod;
		y>>=1ll;
	}
	return ret;
}

inline int C(int x,int y)
{
	if (y>x) return 0;
	return jc[x]%mod*inv[y]%mod*inv[x-y]%mod;
}

signed main() 
{
    n=read();
    k=read();
    jc[0]=inv[0]=1;
    for ( int i=1;i<=n;i++ ) jc[i]=jc[i-1]*i%mod;
    for ( int i=1;i<=n;i++ ) inv[i]=ksm(jc[i],mod-2)%mod;
    for ( int i=1;i<=k;i++ ) 
    	printf("%lld\n",(C(n-k+1,i)%mod*C(k-1,i-1)%mod+mod)%mod);
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int D, N;
    cin >> D >> N;

    if (D == 0 && N < 100){
        cout << N << endl;
    }
    else if(D == 0 && N == 100){
        cout << N + 1 << endl;
    }
    else if (D == 1 && N < 100){
        cout << N * 100 << endl;
    }
    else if (D == 1 && N == 100){
        cout << (N + 1)* 100 << endl;
    }
    else if (D == 2 && N < 100){
        cout << N * 100 * 100 << endl;
    }
    else {
        cout << (N + 1) * 100 * 100 << endl;
    }
}

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

typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> key;

    rep(i, M) {
        ll a, b;
        cin >> a >> b;

        ll s = 0;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            s |= 1 << c;
        }
        key.emplace_back(s, a);
    }

    vector<ll> dp(1<<N, INF);
    dp[0] = 0;
    rep(s, 1 << N) {
        rep(i, M) {
            ll t = s | key[i].first;
            ll cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }

    ll ans = dp.back();
    if (ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int d, g;
  int p[11], c[11];

  scanf("%d%d", &d, &g);

  for(int i=0;i<d;i++) scanf("%d%d", p+i, c+i);

  int ans = INF;
  
  for(int i=0;i<(1<<d);i++){
    ll sum = 0;
    int count = 0;
    
    for(int j=0;j<d;j++){
      if((i>>j)&1){
        sum += p[j] * (j+1) * 100 + c[j];
        count += p[j];
      }
    }

    for(int j=d-1;j>=0;j--){
      if((i>>j)&1) continue;
      if(sum >= g) continue;
      int q = min((g - sum)/((j+1) * 100), (ll)p[j]);
      count += q;
      sum += (j+1) * 100 * q;
    }

    if(g <= sum)
      ans = min(ans, count);
  }

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



Measured memory_bytes: 256
n = int(input())

ans = 0
for i in range(1,n+1):
	if i %2 == 0 :
		continue
	count = 0
	for j in range(1,n+1):

		if i%j == 0:
			count += 1
		

	if count == 8:
		ans += 1

print ans

Measured memory_bytes: 2568
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

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

bool is_prime(ll x) {
  for (ll i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

ll A, B;

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

  vector<ll> a_divs = divisor(A);
  vector<ll> b_divs = divisor(B);
  vector<ll> com_divs;
  int i = 0, j = 0;
  while (i < a_divs.size() && j < b_divs.size()) {
    if (a_divs[i] == b_divs[j]) {
      com_divs.push_back(a_divs[i]);
      i++;
      j++;
    } else if (a_divs[i] < b_divs[j]) {
      i++;
    } else if (a_divs[i] > b_divs[j]) {
      j++;
    }
  }
  ll ans = 0;
  for (auto &e : com_divs) {
    if (is_prime(e)) {
      ans++;
    }
  }

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

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
const int N = 1e5 + 10;
const LL inf = (1LL << 59);
int x, y, z;
LL ans = 0, ans1[N], ans2[N], mx = 0;
pii t[N];
#define mp(a,b) make_pair(a,b)
priority_queue<LL> q;
int main() {
	scanf("%d%d%d",&x,&y,&z); int n = x + y + z;
	rep(i,1,n) {
		LL a, b, c; scanf("%lld%lld%lld",&a,&b,&c);
		ans += c, a -= c, b -= c;
		t[i] = mp(a - b, b);
	}
	sort(t + 1, t + n + 1);
	LL s = 0; ans1[0] = ans2[0] = ans1[n + 1] = ans2[n + 1] = -inf;
	dep(i,n,1) {
		LL w = t[i].first + t[i].second; 
		q.push(-w); s += w; if (q.size() > x) s += q.top(), q.pop();
		ans1[i] = q.size() == x ? s : -inf;
	}
	s = 0; while (!q.empty()) q.pop();
	rep(i,1,n) {
		LL w = t[i].second;
		q.push(-w); s += w; if (q.size() > y) s += q.top(), q.pop();
		ans2[i] = q.size() == y ? s : -inf;
	}
	rep(i,0,n) mx = max(mx, ans + ans1[i + 1] + ans2[i]);
	printf("%lld\n",mx);
	return 0;
}

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	int ans;
	if(n==m)ans+=2*n;
	else
	ans=max(n,m)*2-1;
	cout<<ans;
}


Measured memory_bytes: 256
def draw_check(h, w):
    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0: 
                print("#", end="")
            else:
                print(".", end="")

        print("")

    print("")

while True:
    [h, w] = map(int, input().split(" "))
    if h == 0 and w == 0:
        break
    
    draw_check(h, w)





Measured memory_bytes: 7016
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if b%d == 0:
  x = b // d
else:
  x = b // d +1

if c%e == 0:
  y = c // e
else:
  y = c // e +1

if x >= y:
  print(a-x)
else:
  print(a-y)


Measured memory_bytes: 5592
n, m = list(map(int, input().split()))
llist = []
rlist = []
for i in range(m) :
    l, r = list(map(int, input().split()))
    llist.append(l)
    rlist.append(r)
ll = max(llist)
rr = min(rlist)
print(max(0, min(rr, n)-ll+1))

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
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 / gcd(a, b) * b; }

// ---- ----

LL a, b, x;
int main() {
	cin >> a >> b >> x;
	
	a--;
	a += x;
	b += x;
	cout << b / x - a / x << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define reppe(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define repm(i, a, b) for (int i = (int)(a); i > (int)(b); --i)
#define repme(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)

typedef long long ll;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    return GCD(b, a % b);
}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> cR(N);
    vector<int> cG(N);
    vector<int> cB(N);

    if (S[0] == 'R') cR[0] = 1;
    if (S[0] == 'G') cG[0] = 1;
    if (S[0] == 'B') cB[0] = 1;
    repp(i, 1, N) {
        cR[i] = cR[i - 1];
        cG[i] = cG[i - 1];
        cB[i] = cB[i - 1];
        if (S[i] == 'R') cR[i] += 1;
        if (S[i] == 'G') cG[i] += 1;
        if (S[i] == 'B') cB[i] += 1;
    }

    long long res = 0;
    repp(i, 0, N) {
        repp(j, i + 1, N) {
            if (S[i] == 'R') {
                if (S[j] == 'G') {
                    res += cB[j - 1] - cB[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'B') --res;
                } else if (S[j] == 'B') {
                    res += cG[j - 1] - cG[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'G') --res;
                }
            } else if (S[i] == 'G') {
                if (S[j] == 'B') {
                    res += cR[j - 1] - cR[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'R') --res;
                } else if (S[j] == 'R') {
                    res += cB[j - 1] - cB[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'B') --res;
                }
            } else if (S[i] == 'B') {
                if (S[j] == 'R') {
                    res += cG[j - 1] - cG[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'G') --res;
                } else if (S[j] == 'G') {
                    res += cR[j - 1] - cR[i];
                    if ((i + j) % 2 == 0 && S[(i + j) / 2] == 'R') --res;
                }
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,maxx,i,j,minn,a,c;bool b[1000000];
int main(){
    cin>>n;
    maxx=0;
    memset(b,true,sizeof(b));
    for(i=1;i<=n;i++){
    	cin>>a>>c;
    	if(maxx<c)maxx=c;
    	if(minn>a)minn=a;
		for(j=a;j<=c;j++)b[j]=false; 
	} 
	int ans=0;
	for(i=minn;i<=maxx;i++)if(!b[i])ans++;
	cout<<ans;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
bool i[111100];
vector<pair<int ,int> > ii;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=1,e=1,f=0,g=1,h=1,j;
  cin >>a;
  for(int n=1;n<=a;n++){
    cin >>b;
    ii.push_back(mp(b,n));
  }
  sort(ii.begin(),ii.end());
  cout <<ii[0].se;
  for(int n=1;n<a;n++){
    cout <<' '<<ii[n].se;
  }
  cout <<'\n';
  return (0);
}


Measured memory_bytes: 1780
import java.io.*;
import java.util.*;
@SuppressWarnings("unused")
public class Main{
    public static void main(String args[]) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String s[] = br.readLine().trim().split(" ");
        int n = Integer.parseInt(s[0]);
        int w = Integer.parseInt(s[1]);
        int[] val = new int[n];
        long[] wt = new long[n];
        for(int i=0;i<n;i++) {
            String st[] = br.readLine().trim().split(" ");
            wt[i] = Integer.parseInt(st[0]);
            val[i] = Integer.parseInt(st[1]);
        }
        int maxval = (int) 1e5+10;
        long[] dp = new long[maxval];
        long INF = (long) 1e18;
        Arrays.fill(dp, INF);
        dp[0] = 0;
        int ans = 0;
        for(int i=0;i<n;i++){
            for(int j=maxval-1;j >= val[i];--j){
                dp[j] = Math.min(dp[j], dp[j-val[i]] + wt[i]);
                if(dp[j]<=w) ans = Math.max(ans, j);
            }
        }
        
        out.println(ans);
        out.flush();
    }
}

Measured memory_bytes: 34128
import java.util.ArrayList;
import java.util.Scanner;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
			int n=in.nextInt();
			int m=in.nextInt();
			ArrayList<Integer> L=new ArrayList<Integer>();
			for(int i=1;i<=2*n;i++)
				L.add(i);
			for(int i=0;i<m;i++)
			{
				int k=in.nextInt();
				if(k==0)
				{
					ArrayList<Integer> L1=new ArrayList<Integer>();
					ArrayList<Integer> L2=new ArrayList<Integer>();
					for(int j=0;j<n;j++)
						L1.add(L.get(j));
					for(int j=n;j<2*n;j++)
						L2.add(L.get(j));
					L=new ArrayList<Integer>();
					for(int j=0;j<n;j++)
					{
						L.add(L1.get(j));
						L.add(L2.get(j));
					}
				}
				else
				{
					ArrayList<Integer> L1=new ArrayList<Integer>();
					ArrayList<Integer> L2=new ArrayList<Integer>();
					for(int j=0;j<k;j++)
						L1.add(L.get(j));
					for(int j=k;j<2*n;j++)
						L2.add(L.get(j));
					L=new ArrayList<Integer>();
					for(int j=0;j<L2.size();j++)
						L.add(L2.get(j));
					for(int j=0;j<L1.size();j++)
						L.add(L1.get(j));
				}
			}
			for(int i=0;i<L.size();i++)
				System.out.println(L.get(i));
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<endl;}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  vector<int> l(3);cin>>l[0]>>l[1]>>l[2];
  ndifix::sort(l);
  cout<<(l[0]*l[1])/2<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}


Measured memory_bytes: 21716
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n = int(input())
s = input()
r,g,b = 0,0,0
for i in range(n):
    if s[i] == "R":
        r+=1
    elif s[i] == "G":
        g+=1
    else:
        b+=1
rgb = r*g*b
for i in range(n):
    for j in range(i+1,n):
        k = 2*j-i
        if k<n:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                rgb-=1
print(rgb)

Measured memory_bytes: 9436
L,R = [int(i) for i in input().split()]
list=[]
list2=[]
if R-L>=672:
    print(0)
else:
    for i in range(L,R+1):
        list.append(i%2019)
    else:
        for j in range(len(list)-1):
            for k in range(j+1,len(list)):
                list2.append((list[j]*list[k])%2019)
        else:
            print(sorted(list2)[0])



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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int x = 0;
    int y = 0;

    rep(i, n) {
        char c = s[i];
        if (c == 'c') {
            cout << "No" << endl;
            continue;
        }
        if (c == 'a') {
            if (x + y < a + b) {
                cout << "Yes" << endl;
                x++;
                continue;
            } else {
                cout << "No" << endl;
                continue;
            }
        }
        if (c == 'b') {
            if (x + y < a + b && y < b) {
                cout << "Yes" << endl;
                y++;
                continue;
            } else {
                cout << "No" << endl;
                continue;
            }
        }
    }

}


Measured memory_bytes: 896
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val xyhs = (1..N).map{ readLine()!!.split(" ").map{ it.toInt() } }
    for(x in 0..100)y@for(y in 0..100){
        val p=xyhs.first{ it[2]!=0 }
        val h = p[2] + Math.abs(x-p[0]) + Math.abs(y-p[1])
        if(xyhs.all{ it[2] + Math.abs(x-it[0]) + Math.abs(y-it[1]) == h
                || it[2]==0 && Math.abs(x-it[0]) + Math.abs(y-it[1]) >=h}) {
            println("$x $y $h")
            return
        }
    }
}

Measured memory_bytes: 38068
#include "bits/stdc++.h"
using namespace std;

double dist(vector<double> a, vector<double> b)
{
	int d = a.size();
	double d2 = 0;
	for (int i = 0; i < d; i++) {
		d2 += pow(a.at(i) - b.at(i), 2);
	}
	return sqrt(d2);
}

int main()
{
	int n, d;
	cin >> n >> d;
	vector<vector<double>> x(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			double x_in;
			cin >> x_in;
			x.at(i).push_back(x_in);
		}
	}

	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			double d = dist(x.at(i), x.at(j));
			int d_int = (int)d;
			if (d_int == d) {
				ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

// AC
public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int[] a, rev;
	int n, m;

	void run(){
		// 10Â©ç5ÂIÔñP(10,5)=30240
		// 2^5=32p^[½]³¹éD½]³¹ÄàÏíçÈ¢àÌÍd¡l¶
		// 5Â©çÈép^[ÉÎ·ép^[ðcè5ÂÅìêé©»è

		n=10;
		m=n/2;
		a=new int[n];
		rev=new int[1<<m];
		for(int i=0; i<1<<m; i++){
			int x=i;
			x=(x&0x55555555)<<1|(x>>1)&0x55555555;
			x=(x&0x33333333)<<2|(x>>2)&0x33333333;
			x=(x&0x0f0f0f0f)<<4|(x>>4)&0x0f0f0f0f;
			x=(x<<24)|((x&0xff00)<<8)|((x>>8)&0xff00)|(x>>24);
			rev[i]=(int)(x>>(32-m))&((1<<m)-1);
		}

		for(;;){
			for(int i=0; i<n; i++){
				String s=sc.next();
				if(s.equals("END")){
					return;
				}
				a[i]=Integer.parseInt(s, 2);
			}
			solve();
		}
	}

	void solve(){
		int ans=0;
		int[] b=new int[m];
		int[] c=new int[m];
		int comb=(1<<m)-1;
		boolean[] used=new boolean[m];

		for(; comb<1<<n;){
			// 2^(½]³¹Äà¯¶àÌÌÂ)Åé
			int div=1;
			for(int i=0, j=0, k=0; k<10; k++){
				if((comb>>k&1)==1){
					b[i++]=a[k];
					if(rev[a[k]]==a[k]){
						div*=2;
					}
				}else{
					c[j++]=a[k];
				}
			}

			Arrays.sort(b);
			int sum=0;
			for(;;){
				// 2^nÊè½]³¹é
				for(int sup=0; sup<1<<m; sup++){
					for(int i=0; i<m; i++){
						if((sup>>i&1)==1){
							b[i]=rev[b[i]];
						}
					}
					// bÌÀÑðcÅ\zÅ«é©
					Arrays.fill(used, false);
					sum++;
					for(int i=0; i<m; i++){
						int bits=0;
						for(int j=0; j<m; j++){
							bits=(bits<<1)|(b[j]>>i&1);
						}
						int k=-1;
						for(int j=0; j<m; j++){
							if(!used[j]
									&&((c[j]^bits)==(1<<m)-1||(rev[c[j]]^bits)==(1<<m)-1)){
								k=j;
							}
						}
						if(k>=0){
							used[k]=true;
						}else{
							sum--;
							break;
						}
					}
					for(int i=0; i<m; i++){
						if((sup>>i&1)==1){
							b[i]=rev[b[i]];
						}
					}
				}
				if(!nextPermutation(b)){
					break;
				}
			}
			ans+=sum/div;

			int x=comb&-comb, y=comb+x;
			comb=((comb&~y)/x>>1)|y;
		}
		ans/=8; // ¾½]*ñ]
		println(""+ans);
	}

	boolean nextPermutation(int[] is){
		int n=is.length;
		for(int i=n-1; i>0; i--){
			if(is[i-1]<is[i]){
				int j=n;
				while(is[i-1]>=is[--j]);
				swap(is, i-1, j);
				rev(is, i, n);
				return true;
			}
		}
		rev(is, 0, n);
		return false;
	}

	void swap(int[] is, int i, int j){
		int t=is[i];
		is[i]=is[j];
		is[j]=t;
	}

	void rev(int[] is, int i, int j){
		for(j--; i<j; i++, j--){
			int t=is[i];
			is[i]=is[j];
			is[j]=t;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

template <std::uint_fast64_t mod>
class ModInt {
    using u64 = std::uint_fast64_t;

   public:
    u64 x;
    ModInt(const ll x = 0) : x(x < 0 ? (mod - (-x % mod)) % mod : x % mod) {}

    ModInt operator+(const ModInt r) { return ModInt(*this) += r; }
    ModInt operator*(const ModInt r) { return ModInt(*this) *= r; }
    ModInt operator-(const ModInt r) { return ModInt(*this) -= r; }
    ModInt operator/(const ModInt r) { return ModInt(*this) /= r; }
    ModInt operator-() { return ModInt(mod - x); }

    ModInt &operator+=(const ModInt r) {
        x += r.x;
        if (x >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt r) {
        if (x < r.x) x += mod;
        x -= r.x;
        return *this;
    }
    ModInt &operator*=(const ModInt r) {
        x *= r.x;
        if (x >= mod) x %= mod;
        return *this;
    }
    ModInt &operator/=(ModInt r) {
        if (!(x % r.x)) {
            x /= r.x;
            return *this;
        }
        u64 p = mod - 2;
        while (p > 0) {
            if (p & 1) *this *= r;
            r *= r;
            p >>= 1;
        }
        return *this;
    }
    ModInt &operator++(int) { return (*this) += 1; }
    ModInt &operator++() { return (*this) += 1; }
    ModInt &operator--(int) { return (*this) -= 1; }
    ModInt &operator--() { return (*this) -= 1; }

    bool operator<(const ModInt r) { return x < r.x; }
    bool operator>(const ModInt r) { return x > r.x; }
    bool operator<=(const ModInt r) { return x <= r.x; }
    bool operator>=(const ModInt r) { return x >= r.x; }
    bool operator==(const ModInt r) { return x == r.x; }
    bool operator!=(const ModInt r) { return x != r.x; }

    ModInt inv() { return (ModInt)1 / (*this); }
    int get_mod() { return mod; }

    friend std::istream &operator>>(std::istream &in, ModInt &m) {
        ll a;
        in >> a;
        if (a < 0) a = mod - (-a % mod);
        if (a >= mod) a %= mod;
        m.x = a;
        return in;
    }
    friend std::ostream &operator<<(std::ostream &out, const ModInt &m) {
        out << m.x;
        return out;
    }
};
constexpr std::uint_fast64_t mod = 998244353;
using mint = ModInt<mod>;

int main() {
    int N, S;
    cin >> N >> S;
    vector<int> A(N + 1);
    for (int i = 0; i < N; i++) cin >> A[i + 1];

    vector<vector<mint>> dp(N + 1, vector<mint>(S + 1, 0));
    mint ans = 0;
    for (int i = 1; i <= N; i++) {
        dp[i - 1][0]++;
        for (int x = 0; x <= S; x++) {
            if (dp[i - 1][x] > 0) {
                dp[i][x] += dp[i - 1][x];
                if (x + A[i] <= S) dp[i][x + A[i]] += dp[i - 1][x];
            }
        }
    }
    for (int i = 1; i <= N; i++) ans += dp[i][S];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

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

using namespace std;
int main()
{
	string s,t,ans="No";
	cin >> s;
	cin >> t;
	if (s.size()+1==t.size() && s==t.substr(0,s.size())) ans="Yes";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
bool s[200000], x[200000];int n, S, v;
#pragma warning (disable:4996)
int main() {
	while (true) {
		cin >> n;
		if (!n) { break; }
		S = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d", &v);
			if (v == 0) { s[i] = false; }
			else { s[i] = true; }
		}
		for (int i = 0; i < n; i++) {
			x[i] = s[i];
			if (i % 2 == 1) {
				for (int j = i - 1; j >= 0; j--) {
					if (x[j] == s[i]) {
						break;
					}
					else {
						x[j] ^= true;
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (x[i] == false) { S++; }
		}
		cout << S << endl;
	}
	return 0;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] inputCookiesCount = br.readLine().split(" ");

            int cookieCountA = Integer.parseInt(inputCookiesCount[0]);
            int cookieCountB = Integer.parseInt(inputCookiesCount[1]);

            String sharingIs = "Impossible";

            if (cookieCountA % 3 == 0 || cookieCountB % 3 == 0 || (cookieCountA + cookieCountB) % 3 == 0) {
                sharingIs = "Possible";
            }

            System.out.println(sharingIs);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21332
#include <cstdio>

int main()
{
  int n, m, x, y;
  scanf("%d %d %d %d", &n, &m, &x, &y);
  int xmax = -1e8;
  int ymin = 1e8;
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    if (xmax < a) xmax = a;
  }
  for (int i = 0; i < m; ++i)
  {
    int a;
    scanf("%d", &a);
    if (ymin > a) ymin = a;
  }
  puts(xmax + 1 <= y && ymin >= x + 1 && ymin - xmax > 0 ? "No War" : "War");
  return 0;
}

Measured memory_bytes: 128