akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;


int main() {
    int N;
    vector<pair<int, int>> f;  
    cin >> N;
    for(int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        f.push_back(make_pair(x, y));
    }
    double sum = 0.0;
    double n = 1.0;
  	double t = 2.0;
    for(int i = 0; i < N; i++) {
      	n *= i + 1;
        for(int j = i + 1; j < N; j++) {
            sum += sqrt(pow(f[i].first - f[j].first, 2) + pow(f[i].second - f[j].second, 2));
        }
    }
    cout<< setprecision(10) << fixed << sum * 2.0 / N << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n,x;cin>>n>>x;
  int l[n];
  REP(i,n){
    cin>>l[i];
  }

  int ans = 1;
  int now = 0;
  REP(i,n){
    now += l[i];
    if(now<=x)ans++;
  }

  cout<<ans<<endl;

 

  return 0;
}

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

#define co(x) cout << x << endl
#define cos(x1 , x2) cout << fixed << setprecision(x1) << x2 << endl

int main ()
{
    int num , cou = 0 ;
    double res = 0 ;

    cin >> num ;

    for (int i = 0 ; i < num ; i ++)
    {
        if (i % 2 == 0 )
    {
        cou ++ ;
    }
    }

    res = (double )cou / (double) num ;

    cos (10 , res ) ;

    return 0 ;
}


Measured memory_bytes: 256
/*=======Kaihatsu========*/
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;++i)
    {
        cin>>h[i];
    }
    int dis[n]={0};
    dis[0]=0;
    for(int i=1;i<n;++i)
    {
        dis[i]=INT_MAX;
        for(int j=1;j<=min(i,k);++j)
        {
            dis[i]=min(dis[i-j]+abs(h[i]-h[i-j]),dis[i]);
        }
    }
    cout<<dis[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

ll price[2][3];

int main(void){
	ll n;
	cin >> n;
	rep(i, 2)rep(j, 3) cin >> price[i][j];


	ll cur = n;

	rep(i, 2){
		vector<int> buy, sell;
		rep(j, 3){
			if(price[i][j] < price[i ^ 1][j]){
				buy.push_back(price[i][j]);
				sell.push_back(price[i ^ 1][j]);
			}
		}

		ll nxt = cur;
		if(buy.size() == 3){
			rep(an, cur + 1) rep(bn, cur + 1){
				ll rest = cur - 1LL * buy[0] * an - 1LL * buy[1] * bn;
				if(rest < 0) continue;
				const ll cn = rest / buy[2];
				rest -= buy[2] * cn;

				const ll tmp = 1LL * sell[0] * an + 1LL * sell[1] * bn + 1LL * sell[2] * cn + rest;
				chmax(nxt, tmp);
			}
		} else if(buy.size() == 2){
			rep(an, cur + 1) {
				ll rest = cur - 1LL * buy[0] * an;
				if(rest < 0) continue;
				const ll bn = rest / buy[1];
				rest -= buy[1] * bn;
				const ll tmp = 1LL * sell[0] * an + 1LL * sell[1] * bn + rest;
				chmax(nxt, tmp);
			}
		} else if(buy.size() == 1) {
			ll rest = cur;
			const ll an = rest / buy[0];
			rest -= buy[0] * an;
			const ll tmp = 1LL * sell[0] * an + rest;
			chmax(nxt, tmp);
		}

		chmax(cur, nxt);
	}

	cout << cur << endl;

	return 0;
}

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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); cout.tie(NULL);

  int n, a, b;
  cin >> n >> a >> b;
	
  cout << min(a, b) << " " << max(0, a + b - n) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    unsigned long long int S, C;
    unsigned long long int num = 0;

    scanf("%llu%llu", &S, &C);

    if (2*S <= C) {
        num = S;
        C -= 2*S;
        S = 0;
        num += (C/4);
    } else {
        num = C/2;
    }

    printf("%llu\n", num);

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N, M; cin >> N >> M;
	set<int> s;
	set<pair<int, int>> conditions;
	for (int i = 0; i < M; ++i) {
		int si, ci; cin >> si >> ci;
		s.insert(si);
		conditions.insert({si, ci});
	}
	if (s.size() != conditions.size()) cout << -1;
	else if (M == 0 && N == 1) cout << 0;
	else if (M == 0 && N == 2) cout << 10;
	else if (M == 0 && N == 3) cout << 100;
	else {
		vector<pair<int, int>> pCond(conditions.begin(), conditions.end());
		sort(pCond.begin(), pCond.end());
		string result = "";
		int cPos = 1;
		for (unsigned int i = 0; i < pCond.size(); ++i) {
			int si = pCond[i].first; 
			int ci = pCond[i].second;
			if (si == 1 && ci == 0 && N == 1) {result = '0'; break;}
			if (si == 1 && ci == 0 && N > 1) {result += "-1"; break;}
			if (cPos == si) {result += '0' + ci; cPos++; continue;}
			else {
				while (cPos < si) {
					if (cPos == 1) result += '1';
					else result += '0';
					cPos++;
				}
				result += '0' + ci; cPos++;
			}
		}
		if (result != "-1") {
			while (result.size() < N) {result += '0';}
		}
		cout << result;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int n, r, g, b;
string s;
long long res;
int main() {
    DAU
    cin >> n >> s;
    s = '$' + s;
    for (int i = 1; i <= n; ++i)
        if (s[i] == 'R')
            ++r;
        else if (s[i] == 'G')
            ++g;
        else ++b;
    res = 1LL * r * g * b;
    for (int i = 1; i <= n; ++i)
        for (int k = i + 2; k <= n; k += 2)
            if (s[i] != s[k]) {
                int j = (i + k) / 2;
                if (s[j] != s[i] && s[j] != s[k])
                    --res;
            }
    cout << res;
    PLEC
}


Measured memory_bytes: 3652
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():

    n = int(input())
    A = readInts()
    B = [a - i for i,a in enumerate(A,1)] # index 1 から
    from statistics import median

    medi = int(median(B))
    print(sum([abs(a-medi) for a in B]))




    """sumA = sum(A)
    facA = (n * (n+1))//2
    na = sumA - facA

    if na / n < 0:
        p = na/n
        if abs(p) % 10 != 0:
            b = int(p) - 1
        else:
            b = int(p)
    else:
        b = round(na/n)
    #print(b)
    ans = 0
    nya = len(A)
    for i in range(len(A)):
        #print(A[i],b,i+1)
        print(i)
        ans += abs(A[i] - (b + (i+1)))
    print(ans)"""



if __name__ == '__main__':
  main()


Measured memory_bytes: 29736
#include<stdio.h>
#include<stdlib.h>

int main(){
  int n,S[10001],q,T[501],i,j,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
    if(S[i]<0 || S[i]>1000000000){
      exit(1);
      }
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    if(T[i]<0 || T[i]>1000000000){
      exit(8);
      }
  }
  
    for(i=0;i<q;i++){
      for(j=0;j<n;j++){
      if(T[i]==S[j]){
	count++;
	break;
      }
      }
    }
  
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 636
local mfl = math.floor
local mod = 1000000007
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local function getComb(n, k)
  local ret = 1
  for i = 1, k do
    ret = bmul(ret, n + 1 - i)
    ret = bmul(ret, modinv(i))
  end
  return ret
end

local x, y = io.read("*n", "*n")
if (x + y) % 3 ~= 0 then
  print(0)
else
  local n = mfl((x + y) / 3)
  if x < n or y < n then
    print(0)
  else
    x = x - n
    y = y - n
    print(getComb(n, y))
  end
end


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

int main(){
  int N, x, l;
  cin >> N;
  vector<pair<int, int>> robots;
  map<int, int> paths;
  map<int, int> cont;
  for (int i=0; i<N; i++){
    cin >> x >> l;
    robots.emplace_back(x, l);
  }
  sort(robots.begin(), robots.end());
  pair<int, int> max_element(-1, 0);
  cont[-1] = -1e9;
  for (int i=0; i<N; i++){
    x = robots[i].first;
    l = robots[i].second;
    int left = x - l;
    int right = x + l;
    if (cont[max_element.first] <= left){
      max_element.first = i;
      max_element.second++;
    }
    else if (cont[max_element.first] > right){
      max_element.first = i;
    }
    cont[i] = right;
    
    /*
    for (auto e = paths.begin(); e != paths.end(); e++){
      if (cont.find(e->first) != cont.end() && cont[e->first] <= left){
        cont.erase(e->first);
        paths.erase(e->first);
        max_element = ((max_element.second) < (e->second) ? pair<int, int>(e->first, e->second) : max_element);
      }
    }
    */
  }
  cout << max_element.second << endl;
  return 0;
}

Measured memory_bytes: 5748
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);

constexpr int64 MOD = 1000000007;


bool isPrime(int n)
{
    int max = (int)sqrt(n) + 1;
    InitRep(i, 2, max)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int x;
    cin >> x;
    
    constexpr int MAX = 100004;
    InitRep(i, x, MAX)
    {
        if (isPrime(i))
        {
            cout << i << endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	
	int n,m[15],st;
	int b;
	char f[150];
	int i,j;
	int tmp;
	
	while (cin >> n,n)
	{
		
		for(i=0;i<15;i++)  m[i]=0;
		b=0;
		st=0;
		
		cin >> f;  // scanf("%s",f);
		
		for(i=0;i<100;i++)
		{
			
			if(st==n) st=0;
			
			if(f[i]=='M')
			{
//				cout << m[st] << endl ;
				m[st]++;
			}
			else if(f[i]=='L')
			{
//				cout << m[st] << endl ;
				m[st]+=b+1;
				b=0;
			}
			else
			{
//				cout << m[st] << endl ;
				b+=m[st]+1;
				m[st]=0;
			}
			
			st++;
		}
		for(i=0;i<n-1;i++)
		{
			for(j=i+1;j<n;j++)
			{
				if(m[i]>m[j])
				{
					tmp=m[i];
					m[i]=m[j];
					m[j]=tmp;
				}
			}
		}
		for(i=0;i<n;i++)
		{
			cout << m[i] << " " ;
		}
		cout << b << endl;
	}
	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_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(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;

int main() {
	FAST;

	string s;
	int w;

	cin >> s;
	cin >> w;

	int l=s.length();

	rep(i, l) {
		if (i*w < l) cout << s[i*w];
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int h, a;
    cin >> h >> a;
    cout << (h-1) / a  + 1 << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string t;
  cin>>t;
  int n=t.length();
    for(int i=0;i<n;i++)
    {
      if(t[i]=='?')
      {
          t[i]='D';
      }
  	}
  cout<<t<<endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
set<ll> s;

int main(){
    ll n,k; cin>>n>>k;
    if(n<k){
        cout<<min(n,abs(n-k));
    }
    else {
        if(n%k==0)
            cout<<0;
        else{
            ll a=k*(n/k);
            ll b=k+a;
            cout<<min(abs(n-a),abs(n-b));
        }
    }
    return 0;
}


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

const int MAXN = 50;
const int BITS = 18;
const LL mod = 1e9 + 7;

LL dp[MAXN][1 << BITS];

int main() {
  ios_base::sync_with_stdio(false);
  LL n;
  cin >> n;
  LL x, y, z;
  cin >> x >> y >> z;
  unsigned LL mask = 0;
  y += x;
  z += y;
  int beware = (1 << x) | (1 << y) | (1 << z);
  dp[0][1] = 1;
  for(int i = 0; i < n; i++) {
    for(int mask = 0; mask < (1 << BITS); mask++) {
      for(int d = 1; d <= 10; d++) {
        int n_mask = (mask << d) | 1;
        n_mask &= (1 << BITS) - 1;
        if((n_mask & beware) == beware) {
          continue;
        }
        dp[i + 1][n_mask] += dp[i][mask];
        if(dp[i + 1][n_mask] >= mod) dp[i + 1][n_mask] -= mod;
      }
    }
  }
  LL res = 1;
  for(int i = 0; i < n; i++) {
    res *= 10;
    res %= mod;
  }
  for(int mask = 0; mask < (1 << BITS); mask++) {
    res -= dp[n][mask];
    if(res < 0) res += mod;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 84224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define sqr(x) (x)*(x)
#define mod 1000000007
#define pi acos(-1.0)

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll r;
    cin>>r;
    cout<<setprecision(10)<<2.0*pi*r<<endl;
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y){
  if(y==0) return x;
  gcd(y, x%y);
}
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> x(N+1);
  for(int i=0; i<N; i++) cin >> x[i];
  x[N] = X;
  sort(x.begin(), x.end());
  vector<int> distance(N);
  for(int i=0; i<N; i++){
    distance[i] = x[i+1] - x[i];
  }
  vector<int> L(N+1);
  for(int i=0; i<N+1; i++){
    L[i+1] = gcd(L[i], distance[i]);
  }
  cout << L[N] << endl;
}

Measured memory_bytes: 1408
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<int> ans;
    int pos = 0;
    m = min(m, n);
//    cout << s << endl;
    while(pos != n)
    {
//        printf("pos: %d, m: %d\n", pos, m);
        bool invalid = true;
        rep(i, m)
        {
            auto index = m - i;
//            printf(" index: %d\n", index);
            if(s[pos + index] == '0')
            {
                pos += index;
                m = min(n - pos, m);
                ans.push_back(index);
                invalid = false;
                break;
            }
        }
        if(invalid)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    reverse(ans.begin(), ans.end());
    rep(i, (int)ans.size())
    {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int Mod=998244353,Inv2=Mod+1>>1,MAXN=1e5+5,ba=716070898;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
inline int Add(int x,int y){return x+y>=Mod?x+y-Mod:x+y;}
inline int Sub(int x,int y){return x-y<0?x-y+Mod:x-y;}
inline void Div(int&x){if(x&1)x=1ll*x*Inv2%Mod;else x/=2;}
int n,m,len,SG[MAXN],Sum[5][MAXN],ans[MAXN],S[MAXN],N,Fpow[MAXN];
vector<int>G[MAXN];
inline int Get(int x){
	N=0;for(auto y:G[x])S[++N]=SG[y];sort(S+1,S+N+1);
	S[0]=-1;Rep(i,1,N)if(S[i]>S[i-1]+1)return S[i-1]+1;
	return S[N]+1;
}
inline void FwtXor(int*F,int len,int opt){
	for(int i=1;i<len;i<<=1)for(int j=0;j<len;j+=i<<1)for(int k=0;k<i;k++){
		int x=F[i+j+k],y=F[j+k];F[j+k]=Add(x,y),F[i+j+k]=Sub(y,x);if(opt==-1)Div(F[j+k]),Div(F[i+j+k]);
	}
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();Fpow[0]=1;Rep(i,1,n)Fpow[i]=1ll*Fpow[i-1]*ba%Mod;
	for(int t=1;t<=3;t++){
		m=read(),len=1024;
		Rep(i,1,m){int x=read(),y=read();if(x<y)swap(x,y);G[y].push_back(x);}
		Red(i,n,1)SG[i]=Get(i),Sum[t][SG[i]]=(Sum[t][SG[i]]+Fpow[i])%Mod;FwtXor(Sum[t],len,1);
		Rep(i,1,n)G[i].clear();
	}for(int i=0;i<len;i++)ans[i]=1ll*Sum[1][i]*Sum[2][i]%Mod*Sum[3][i]%Mod;
	FwtXor(ans,len,-1);cout<<ans[0]<<"\n";
	return 0;
}




Measured memory_bytes: 9340
[a,b,k] = [int(x) for x in input().split()]

temp_a = []
for i in range(1,a+1):
    if a%i == 0:
        temp_a.append(i)

temp_b = []
for i in range(1,b+1):
    if b%i == 0:
        temp_b.append(i)

# 重複する約数を削除してから、リストに変換している
nums = list(set(temp_a) & set(temp_b))

# 降順にソート
nums.sort(reverse=True)

print(nums[k-1])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	long long ans=0,m,n;
	cin>>n>>m;
	m/=2;
	ans=min(n,m);
	m-=ans;
	ans+=m/2;
	cout<<ans<<endl;
	cin.get();
	cin.get();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n;
  cin >> n;
  vector<vector<int>> pos(n);
  vector<vector<int>> neg(n);
  rep(ni,n){
    int a;
    cin >> a;
    rep(i,a){
      int x,y;
      cin >> x >> y;
      --x;
      if(y==1){
        pos[ni].emplace_back(x);
      } else {
        neg[ni].emplace_back(x);
      }
    }
  }

  int ans = 0;
  int MAX = 1<<n;
  rep(i,MAX){
    auto bit = [&](int x){ return (i>>x)&1; };
    bool ok = [&]{
      rep(ni,n){
        if(!bit(ni)) continue;
        for(int x : pos[ni]) if(!bit(x)) return false;
        for(int x : neg[ni]) if(bit(x)) return false;
      }
      return true;
    }();
    if(ok) ans = max(ans,__builtin_popcount(i)); 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
cx,cy,ct=0,0,0
flag=true
N.times do|i|
    t,x,y=get_i
    dx=(cx-x).abs
    dy=(cy-y).abs
    dt=t-ct
    d=dt-(dx+dy)
    unless d>=0 and d.even?
        flag=false
        break
    end
    cx,cy,ct=x,y,t
end
puts yn_judge(flag)

Measured memory_bytes: 1788
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long a1, a2, a3;
    scan(a1, a2, a3);
    if (a1 + a2 + a3 <= 21)
    {
        writeln("win");
    }
    else if (22 <= a1 + a2 + a3)
    {
        writeln("bust");
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 3556
n = int(input())
vv = list(map(int, input().split()))

f = {}
b = {}

fcnt = 0
bcnt = 0
for v in vv:
    if fcnt == bcnt:
        if v in f:
            f[v] += 1
        else:
            f[v] = 1
        fcnt += 1
    else:
        if v in b:
            b[v] += 1
        else:
            b[v] = 1
        bcnt += 1


ff = sorted(list(map(lambda x: tuple(reversed(x)), f.items())), reverse = True)
bb = sorted(list(map(lambda x: tuple(reversed(x)), b.items())), reverse = True)

if ff[0][1] != bb[0][1]:
    print(n - ff[0][0] - bb[0][0])
else:
    ans = 1145141919
    if len(bb) == 1:
        ans = min(ans, n - ff[0][0])
    else:
        ans = min(ans, n - ff[0][0] - bb[1][0])
    
    if len(ff) == 1:
        ans = min(ans, n - bb[0][0])
    else:
        ans = min(ans, n - bb[0][0] - ff[1][0])
    print(ans)

Measured memory_bytes: 67972
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
#define deb(x) cerr << "\n" << (#x) << " is " << (x) << endl
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}
auto random_add = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_add() | 1);
mt19937_64 rng(SEED);


const int N=2e5+5;



void solve()
{ 
  int ok=0;
  int n;
  cin>>n;
  int a[n+1][3];
  for(int i=1;i<=n;i++)
  {
    cin>>a[i][0]>>a[i][1];
    if(i>=3)
    {
      int ct=0;
      for(int j=i-2;j<=i;j++)
      {
        if(a[j][0]==a[j][1])
        {
          ct++;
        }
      }
      if(ct==3)
        ok=1;
    }
  } 
  if(ok)
    cout<<"Yes\n";
  else
    cout<<"No\n";

}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
// cin>>t;
 for(int i=1;i<=t;i++)
 {
   solve();
 }
}


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

int main(){
  ll N = 0,K = 0;
  cin >> N >> K;
  if(N >=10){
    cout << K;
  }
  else{
    cout << K + 100 * (10 - N);
  }
}

Measured memory_bytes: 256
#include <iostream>
 
typedef unsigned long long int ulli;
 
int main()
{
  ulli a, b, x;
  std::cin >> a >> b >> x;
  
  ulli c = (b / x) - (a / x);
  
  if((a % x) == 0) ++c;
  
  std::cout << c << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ld long double
#define inf 1e18
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mk make_pair
#define mod 1000000007
#define setbits __builtin_popcount
#define fi first
#define se second
ll modu(ll x,ll p)
{
    x%=p;
    if(x<0)
    {
        x+=p;
    }
    return x;
}
ll inverse(ll x,ll p)
{
    x=modu(x,p);
    if(x==1)
    {
        return x;
    }
    return modu((-p/x)*(inverse(p%x,p)),p);
}
ll fact[100001];
ll ifact[100001];
void ifacto()
{
    ifact[0]=1;
    for(ll i=1;i<100001;i++)
    {
        ifact[i]=ifact[i-1]*inverse(i,mod)%mod;
    }
}
void facto()
{
    fact[0]=1;
    for(ll i=1;i<100001;i++)
    {
        fact[i]=fact[i-1]*i%mod;
    }
}
ll powermod(ll x,ll y, ll p) 
{ 
    ll res = 1;    
    x = x % p; 
    while (y > 0) 
    {   
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 
int main()
{
    fastIO;
    ll n,k;
    cin>>n>>k;
    facto();
    ifacto();
    ll a[n],i,sum[n]={0};
    for(i=0;i<n;i++)
    {   
        cin>>a[i];
        sum[i]+=a[i];
    }
    sort(a,a+n);
    ll val2,val3,count=n-1,val=0,val1=0,ans=0;
    for(i=n-1;i>=k-1;i--)
    {
        val2=((fact[count]%mod)*((ifact[k-1]%mod*ifact[count-k+1]%mod)%mod))%mod;
        val=((val%mod)+((((a[i]+mod)%mod)*(val2%mod))%mod)+mod)%mod;
        count--;
    }
    count=n-1;
    for(i=0;i<=n-k;i++)
    {
        val2=((fact[count]%mod)*((ifact[k-1]%mod*ifact[count-k+1]%mod)%mod))%mod;
        val1=((val1%mod)+((((a[i]+mod)%mod)*(val2%mod))%mod)+mod)%mod;
        count--;
    }
    cout<<(val-val1+mod)%mod<<'\n';
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 1e5+12;
//indexed_set s;

int n;
int q,w,e,r;

int main() {

    cin >> n;
    for (int i = 1; i <= n; i++) {
        string s = "";
        cin >> s;
        if (s == "AC")q++;
        if (s == "WA")w++;
        if (s == "TLE")e++;
        if (s == "RE")r++;
    }

    cout << "AC x " << q << endl;

    cout << "WA x " << w << endl;

    cout << "TLE x " << e << endl;
    cout << "RE x " << r << endl;

return 0;
}


Measured memory_bytes: 3544
sentence = input()
jobs = int(input())

def my_print(s, x, y):
    print(s[x:y+1])

def my_replace(s, x, y, t):
    s = list(s)
    s[x:y+1] = t
    return "".join(s)

def my_reverse(s, x, y):
    s = list(s)
    ss = s[x:y+1]
    ss.reverse()
    s[x:y+1] = ss
    return "".join(s)

for _ in range(jobs):
    task = input().split()
    task[1], task[2] = int(task[1]), int(task[2])
    if task[0] == "print":
        my_print(sentence, task[1], task[2])
    elif task[0] == "replace":
        sentence = my_replace(sentence, task[1], task[2], task[3])
    elif task[0] == "reverse":
        sentence = my_reverse(sentence, task[1], task[2])


Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int N,K;
int h[101010];

int dp[101010];

int main(){
  cin >> N >> K;
  rep(i,N) {cin >> h[i];dp[i]=INF;}

  dp[0]=0;


  rep(i,N){
    reps(j,K){
       dp[i+j]=min(dp[i+j],dp[i]+abs(h[j+i]-h[i]));
    }
  }
  cout << dp[N-1] << endl;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

lli d[3000];
bool vis[3000];

signed main(){

	lli n,x,y;
	cin>>n>>x>>y;
	x--,y--;
	map<lli,lli> cnt;

	REP(i,0,n){
		REP(j,0,n){
			lli diff1 = j-i;
			lli diff2 = abs(i-x)+abs(y-j)+1;
			lli diff3 = abs(i-y)+abs(j-x)+1;
			cnt[min({diff1,diff2,diff3})]++;
		}
	}

	for(lli i=1;i<n;i++){
		cout<<cnt[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 512
//11-1 ????¨???????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int y = a+b+c+d;
    int x = 0;
    while(y>=60){
        y -= 60;
        x += 1;
    }
    cout << x << endl << y << endl;

    return 0;
}


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

int main()
{
	ll H;
	cin >> H;
	ll ans = 0;
	ll temp = 1;
	while(H > 1)
	{
		ans += temp;
		temp *= 2;
		H /= 2;
	}
	ans += temp;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 2505;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

struct FenwickTree {
    FenwickTree() {}
    inline void increase(int r, int c, int x) {
        for (int i = r; i <= n; i += lowbit(i))
            for (int j = c; j <= m; j += lowbit(j)) {
                a[i][j] += x;
                b[i][j] += r * x;
                d[i][j] += c * x;
                e[i][j] += r * c * x;
            }
    }
    inline int getSum(int r, int c) {
        int ans = 0;
        for (int i = r; i; i -= lowbit(i))
            for (int j = c; j; j -= lowbit(j)) {
                ans += a[i][j] * (r + 1) * (c + 1);
                ans -= b[i][j] * (c + 1);
                ans -= d[i][j] * (r + 1);
                ans += e[i][j];
            }
        return ans;
    }
    int a[MAXN][MAXN], b[MAXN][MAXN], d[MAXN][MAXN], e[MAXN][MAXN];
    inline int lowbit(int x) { return x & (-x); }
};

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    printf("%s\n", n >= 30 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main {
    static HashMap<Integer, HashMap<Integer, Long>> dp = new HashMap<>();
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Snack[] snacks = new Snack[n];
        for (int i = 0; i < n; i++) {
            snacks[i] = new Snack(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(snacks, new Comparator<Snack>() {
            public int compare(Snack s1, Snack s2) {
                return s2.price - s1.price;
            }
        });
        Friend[] friends = new Friend[m];
        for (int i = 0; i < m; i++) {
            friends[i] = new Friend(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(friends);
        PriorityQueue<Snack> queue = new PriorityQueue<Snack>(new Comparator<Snack>() {
            public int compare(Snack s1, Snack s2) {
                return s1.value - s2.value;
            }
        });
        int idx = 0;
        for (int i = 0; i < m; i++) {
            while (idx < n && friends[i].price <= snacks[idx].price) {
                queue.add(snacks[idx]);
                idx++;
            }
            while (friends[i].count <= queue.size()) {
                queue.poll();
            }
        }
        while (idx < n) {
            queue.add(snacks[idx]);
            idx++;
        }
        long total = 0;
        while (queue.size() > 0) {
            total += queue.poll().value;
        }
        System.out.println(total);
    }
    
    static class Snack {
        int price;
        int value;
        
        public Snack(int price, int value) {
            this.price = price;
            this.value = value;
        }
        
        public String toString() {
            return "price:" + price + " value:" + value;
        }
    }
    
    static class Friend implements Comparable<Friend> {
        int price;
        int count;
        
        public Friend(int price, int count) {
            this.price = price;
            this.count = count;
        }
        
        public int compareTo(Friend another) {
            return another.price - price;
        }
    }
}


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

int main () {
   int N,A;
   cin>>N;
   set<int>S;
   for (int i=0; i<N;i++){
       cin>>A;
       if(S.count(A))
           S.erase(A);
      else S.insert(A);
   }
   cout<<S.size()<<endl;

   return 0;}


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

int main()
{
    int a, b;
    char op;
    cin >> a >> op >> b;

    switch (op) {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
    }

    return 0;
}


Measured memory_bytes: 256
n, x = list(map(int, input().split()))
a = list(map(int, input().split()))

ans = 0
a.sort()
for i in range(n):
  if x<a[i]:
    break
  x -= a[i]
  ans += 1
if x>0 and ans==n:
  ans -= 1
print(ans)

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

const ll MOD = 1000000007;
void modf(ll &a) {
    a = a % MOD;
}

int main() {
    string s;
    cin >> s;

    vector<vector<ll>> dp(s.size() + 1, vector<ll>(4));
    dp[0][0] = 1;

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < 4; j++) {
            if (s.at(i) == '?') {
                dp[i + 1][j] += dp[i][j] * 3;
                modf(dp[i + 1][j]);
            } else {
                dp[i + 1][j] += dp[i][j];
                modf(dp[i + 1][j]);
            }
        }

        if (s.at(i) == 'A' || s.at(i) == '?') {
            dp[i + 1][1] += dp[i][0];
            modf(dp[i + 1][1]);
        }
        if (s.at(i) == 'B' || s.at(i) == '?') {
            dp[i + 1][2] += dp[i][1];
            modf(dp[i + 1][2]);
        }
        if (s.at(i) == 'C' || s.at(i) == '?') {
            dp[i + 1][3] += dp[i][2];
            modf(dp[i + 1][3]);
        }
    }

    cout << dp[s.size()][3] << endl;
}

Measured memory_bytes: 10336
#include<stdio.h>
#include<math.h>
int main(){
  int x,i,j,ans=0;
  scanf("%d",&x);
  for(i=1;i<32;i++){
    for(j=2;j<10;j++){
      if(pow(i,j)<=x&&ans<pow(i,j)){
        ans=(int)pow(i,j);
      }
    }
  }
  printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int a, b;

void init() {

}

void input() {

}

void solve() {
  cin >> a >> b;
  cout << a*b - a - b + 1 << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    int a[n]; rep(i, n) cin >> a[i];
    ll b[n + 1]; fill_n(b, n + 1, 0);
    //1の倍数だけ別処理したらいい
    for (int i = n; i >= 2; --i) {
        ll sum = 0;
        int num = i;
        int mul = 2;
        while (num * mul < n + 1) {
            sum += b[num * mul];
            mul++;
        }
        if (a[i - 1] == 0) {
            if (sum % 2 == 0) b[i] = 0;
            else b[i] = 1;
        } else {
            if (sum % 2 == 0) b[i] = 1;
            else b[i] = 0;
        }
    }
    ll tmp = 0;
    rep3(i, 2, n + 1) {
        tmp += b[i];
    }
    if (a[0] == 0) {
        if (tmp % 2 == 0) b[1] = 0;
        else b[1] = 1;
    } else {
        if (tmp % 2 == 0) b[1] = 1;
        else b[1] = 0;
    }
    int c = 0;
    rep3(i, 1, n + 1) if (b[i] == 1) c++;
    cout << c << endl;
    if (c == 0) return 0;
    c = 0;
    rep3(i, 1, n + 1) {
        if (c) cout << " ";
        c++;
        if (b[i] == 1) cout << i;
    }
    cout << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main()
{
  int w, h;
  while (cin >> w >> h && h != 0) {
    vector<vector<char> > grid(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> grid[i][j];
      }
    }
    
    int white = 0, black = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (grid[i][j] != '.') {
          continue;
        }
        int color = 0;  // uninitialized
        queue<pair<int,int> > q;
        q.push(make_pair(i, j));
        grid[i][j] = ' ';
        int count = 1;
        while (!q.empty()) {
          const pair<int,int> p = q.front();
          q.pop();
          const int a = p.first;
          const int b = p.second;
          for (int d = 0; d < 4; d++) {
            static const int dir_i[] = {1, -1, 0, 0};
            static const int dir_j[] = {0, 0, 1, -1};
            const int k = a + dir_i[d];
            const int l = b + dir_j[d];
            if (0 <= k && k < h && 0 <= l && l < w) {
              if (grid[k][l] == 'W') {
                if (color == 0 || color == 1) {
                  color = 1;
                } else {
                  color = -1;
                }
              } else if (grid[k][l] == 'B') {
                if (color == 0 || color == 2) {
                  color = 2;
                } else {
                  color = -1;
                }
              } else if (grid[k][l] == '.') {
                grid[k][l] = ' ';
                q.push(make_pair(k, l));
                count++;
              }
            }
          }
        }
        if (color == 1) {
          white += count;
        } else if (color == 2) {
          black += count;
        }
      }
    }
    cout << black << ' ' << white << endl;
  }
  return 0;
}

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

#define int long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>

using namespace std;

int inf = 1e18;
const int N = 1e6+5;
int mod = 1e9+7-998244353+998244353;
/*void dfs(int u,int par,int maxx)
{


    for(int v:adj[u])
    {
        if(v==par)
            continue;
        dfs(v,u,maxx);
    }
}


int ncr(int n , int r ){
	r = min(r,n-r);
	int res = 1 ;
	for(int i = 1 ; i <= r ; i++ ){
		( res *= n-i+1 )%= mod;
		res /= i ;
	}
	return res ;
}
*/

int32_t main()
{
    io
    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int a,b,c;
        cin>>a>>b>>c;
        int sum = a+b+c;
        if(sum>=22)
            cout<<"bust"<<el;
        else
            cout<<"win";

    }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt(),c=nxt(),d=nxt();
    bool t=1;
    while(a>0&&c>0)
    {
        if(t)
        {
            t=0;
            c-=b;
        }
        else
        {
            t=1;
            a-=d;
        }
    }
    if(a>0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    return 0;   
}




 
 


Measured memory_bytes: 3644
import itertools

red_num0, green_num0, blue_num0 = list(map(int, input().split()))
red_num1, green_num1, blue_num1 = red_num0, green_num0, blue_num0
K = int(input())
flag = False

for card_list in list(itertools.product(["red", "green", "blue"], repeat=K)):
    for card in card_list:
        if card == "red":
            red_num1 *= 2
        elif card == "green":
            green_num1 *= 2
        elif card == "blue":
            blue_num1 *= 2
    else:
        if(green_num1 > red_num1 and blue_num1 > green_num1):
            print("Yes")
            flag = True
            break
        red_num1, green_num1, blue_num1 = red_num0, green_num0, blue_num0

if(not flag):
    print("No")


Measured memory_bytes: 65676
from sys import stdin
from copy import deepcopy
import queue

class Dice:
    def __init__(self, nums):
        self.labels = [None] + [ nums[i] for i in range(6) ]
        self.pos = {
            "E" : 3,
            "W" : 4,
            "S" : 2,
            "N" : 5,
            "T" : 1,
            "B" : 6
        }

    def rolled(dice, queries):
        d = deepcopy(dice)
        for q in queries:
            if q == "E":
                d.pos["T"], d.pos["E"], d.pos["B"], d.pos["W"] = d.pos["W"], d.pos["T"], d.pos["E"], d.pos["B"]
            elif q == "W":
                d.pos["T"], d.pos["E"], d.pos["B"], d.pos["W"] = d.pos["E"], d.pos["B"], d.pos["W"], d.pos["T"]
            elif q == "S":
                d.pos["T"], d.pos["S"], d.pos["B"], d.pos["N"] = d.pos["N"], d.pos["T"], d.pos["S"], d.pos["B"]
            elif q == "N":
                d.pos["T"], d.pos["S"], d.pos["B"], d.pos["N"] = d.pos["S"], d.pos["B"], d.pos["N"], d.pos["T"]
        else:
            return d

nums = [int(x) for x in stdin.readline().rstrip().split()]
q = int(stdin.readline().rstrip())
dice = Dice(nums)

# TとSに対応するクエリを記憶し, resをすぐに呼び出せるようにする
memo = [[False] * 7 for i in range(7)]
memo[dice.pos["T"]][dice.pos["S"]] = ""

# クエリとさいころの東面を記憶
res = { "" : dice.labels[dice.pos["E"]] }

# BFSで探索, 解を求めたらreturn Trueで抜け出す
# diceの中身をいじってはならない
def solve(T, S):
	que = queue.Queue()
	que.put(dice)
	sol_q = ["E", "N", "S", "W"]
	
	while not que.empty():
		d = que.get()
		if d.pos["T"] == T and d.pos["S"] == S:
			break
		else:
			for i in sol_q:
				d_next = Dice.rolled(d, i)
				que.put(d_next)
				memo[d_next.pos["T"]][d_next.pos["S"]] = memo[d.pos["T"]][d.pos["S"]] + i
				res[memo[d_next.pos["T"]][d_next.pos["S"]]] = d_next.labels[d_next.pos["E"]]
	else:
		return memo[T][S]

for i in range(q):
    ts = [int(x) for x in stdin.readline().rstrip().split()]
    T = dice.labels.index(ts[0])
    S = dice.labels.index(ts[1])
    
    if solve(T, S) != False:
        print(res[memo[T][S]])


Measured memory_bytes: 7344