akhauriyash/Code-Regression huggingface dataset:
# greedy is all you need
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


def score(D, C, S, T):
    last = [-1] * 26
    # scores = [0]
    score = 0
    for d in range(D):
        # scores.append(scores[-1] + S[d][T[d]])
        score += S[d][T[d]]
        last[T[d]] = d
        for i in range(26):
            # scores[-1] -= C[i] * (d - last[i])
            score -= C[i] * (d - last[i])  # この場で一番罰則が大きいやつを使うとか？
    return score


D = a_int()
C = ints()
S = read_tuple(D)

T = []

last = [-1] * 26
for d in range(D):
    mi = INF
    for i in range(26):
        tmp = C[i] * (d - last[i])
        if tmp < mi:
            t = i
            mi = tmp
    last[t] = d  # Tを選んだあとで決める
    T.append(t)

# print(score(D, C, S, T))

print(*mina(*T, sub=-1), sep='\n')


Measured memory_bytes: 68216
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
vector<string>v;
string s;
bool b[200];
void dfs(int d){
    if(d==s.size())v.push_back(s);
    else{
        if(s[d]=='a'||b[s[d]])dfs(d+1);
        if(!b[s[d]+1]&&s[d]!='z'){
            s[d]++;
            b[s[d]]=1;
            dfs(d+1);
            b[s[d]]=0;
            s[d]--;
        }
    }
}
int main(){
    while(cin>>s,s!="#"){
        memset(b,0,sizeof(b));
        v.clear();
        dfs(0);
        cout<<v.size()<<endl;
        if(v.size()<=10)r(i,v.size())cout<<v[i]<<endl;
        else{
            r(i,5)cout<<v[i]<<endl;
            r(i,5)cout<<v[v.size()+i-5]<<endl;
        }
    }
}

Measured memory_bytes: 4284
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    string ans = "";
    do
    {
        if(n < 0)
        {
            int x = n / -2;
            int y = (-n) % 2;
            if(y == 0)
            {
                ans = "0" + ans;
                n = x;
            }
            else
            {
                ans = "1" + ans;
                n = x + 1;
            }
        }
        else
        {
            int x = n / -2;
            int y = n % 2;
            if(y == 0)
            {
                ans = "0" + ans;
                n = x;
            }
            else
            {
                ans = "1" + ans;
                n = x;
            }
        }

    }while(n != 0);
    PUTS(ans);
}

Measured memory_bytes: 384
import numpy as np

h,w=map(int,input().split())
g = np.array([list(input()) for _ in range(h)])
g = np.where(g=='.',1,0)

l = np.zeros((h,w),dtype=np.int)
r = np.zeros((h,w),dtype=np.int)
u = np.zeros((h,w),dtype=np.int)
d = np.zeros((h,w),dtype=np.int)

for i in range(w):
  l[:,i] = (l[:,i-1]+1)*g[:,i]
  r[:,-i-1] = (r[:,-i]+1)*g[:,-i-1]

for i in range(h):
  u[i,:]=(u[i-1,:]+1)*g[i,:]
  d[-i-1,:]=(d[-i,:]+1)*g[-i-1,:]

print(np.max(l+r+u+d)-3)

Measured memory_bytes: 250884
d,n = map(int, input().split())
#print(d,n)

if d == 0:
    if n == 100:
        print(101)
    else:
        print(n)
elif d == 1:
    if n ==100:
        print(10100)
    else:
        print(100*n)
else:
    if n == 100:
        print(1010000)
    else:
        print(10000*n)


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

//const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    string s;
    cin >> s;
    vector<int> k('z' + 1, 0);
    
    for (int i = 0; i < s.size(); i++) {
        k[s[i]]++;
        if (k[s[i]] == 2) {
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))


def solve(L):
    L.sort()
    j = 0
    while L[j] == 0:
        j += 1
    if j == N - 1 or L[j] == 1:
        return L[j]
    for i in range(j + 1, N):
        L[i] %= L[j]
    return solve(L)


print(solve(A))

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int n = 100;

int trace(int buf[], int sum)
{
	for(int i = 0; i < sum; i++) {
		if( i > 0 ) 
			cout << " ";
		cout << buf[i];
	}
	cout << endl;
	return 0;
}

void insertionSort(int buf[], int sum) 
{
	int i, j, key;
	for( i = 1; i < sum; i++) {
		j = i - 1;
		key = buf[i];
		while(j >= 0 && buf[j] > key) {
			buf[j+1] = buf[j];
			j--;
		}
		buf[j+1] = key;
		trace(buf, sum);
	}
}

int main()
{
	int buf[n];
	int sum = 0;
	cin >> sum;
	for(int i = 0; i < sum; i++)
		cin >> buf[i];
	trace(buf, sum);
	insertionSort(buf, sum);
	return 0;
}


Measured memory_bytes: 3124
n,m,c = map(int,input().split(" "))

b = list(map(int,input().split(" ")))
result = 0
for i in range(n):
    ai = list(map(int,input().split(" ")))
    temp = c
    for j in range(m):
        temp = temp + (ai[j] * b[j])

    if temp > 0:
        result = result + 1

print(result)

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

int main(){
    int a,b,c;
    cin >> a >> b >>c;
    if(a+b==c||b+c==a||c+a==b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

//https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
/*
int main() {
    int n, m, flag = 0;
    cin >> n >> m;
    vector<set<int>> fl(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        fl[a].insert(b);
        fl[b].insert(a);
    }
    int ans = 1;
    int gn[204040] = {0}, flag[202020] = {0};
    rep(i,n){
        
    }

    cout << ans;
    printf("\n");
}
*/

int main() {
    int n, m, flag = 0;
    cin >> n >> m;
    UnionFind tree(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(!tree.same(a,b))tree.unite(a,b);
    }
    int ans = 1;
    vi cnt(n,0);
    rep(i,n){
        cnt[tree.root(i)]++;
    }
    rep(i,n){
        ans = max(cnt[i],ans);
    }


    cout << ans;
    printf("\n");
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> W(N),E(N);
  W.at(0)=0;
  E.at(N-1)=0;
  for(int i=1;i<N;i++){
    if(S.at(i-1)=='W'){
      W.at(i)=W.at(i-1)+1;
    }else{
      W.at(i)=W.at(i-1);
    }
  }
  for(int i=N-2;i>=0;i--){
    if(S.at(i+1)=='E'){
      E.at(i)=E.at(i+1)+1;
    }else{
      E.at(i)=E.at(i+1);
    }
  }
  priority_queue<int64_t,vector<int64_t>,greater<int64_t> > pq;
  for(int i=0;i<N;i++){
    pq.push(W.at(i)+E.at(i));
  }
  cout << pq.top() << endl;
  return 0;
}


Measured memory_bytes: 8952
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

int main(){
    int N,K;
    string S;
    cin>>N>>K;
    cin>>S;
    int score=0;
    rep(i,N-1){
        if(S[i]==S[i+1]){
            score++;
        }
    }
    int ans= min(score+2*K,N-1);
    cout<<ans<<endl;
    return 0; 
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        int a;cin>>a;
        cout<<(a+a*a+a*a*a);
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int a,b;
  cin >> a >> b;
  cout << a-b+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int n, a;
ll dp[55][55][2555] = {0};

int main () {
  cin >> n >> a;
  vi x(n);
  rep(i,n) cin >> x[i];

  dp[0][0][0] = 1;
  rep(j,n+1) {
    rep(k,n+1) {
      rep(s,2555) {
        if (j >= 1 && s < x[j-1]) {
          dp[j][k][s] = dp[j-1][k][s];
        }
        if (j >= 1 && k >= 1 && s >= x[j-1]) {
          dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]];
        }
      }
    }
  }

  ll ans = 0;
  FOR(k,1,n+1) {
    ans += dp[n][k][k*a];
  }

  cout << ans << endl;
}


Measured memory_bytes: 56448
import numpy as np 
n,m=map(int, input().split())
coef = np.minimum(np.arange(n,1,-1),np.arange(1,n))
dp = np.zeros(n, dtype=np.int64)
dp[0] = 1
for c in coef:
    ndp = dp.copy()
    for i in range(c, n, c):
        ndp[i:] += dp[:n-i]
    dp = ndp % m #更新する

print((dp*np.arange(n, 0, -1) % m).sum() % m)

Measured memory_bytes: 14540
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  long long int n,k;
  cin>>n>>k;
    long long int ans=n%k;
    long long int pre=abs(ans-k);
    ans=min(ans,pre);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define faster cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
// # setprecision doubt



int n,k;


int main()
{
	int temp;
	cin>>n>>k;
    vector<int>arr;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        arr.push_back(temp);
    }
    sort(arr.begin(),arr.end());
	vector<bool> dp(k+1,0);
	for(int i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i-arr[j]<0) break;
			if(dp[i-arr[j]]==false)
			{
				// found a way to defeat a opponent
				// so i win
				dp[i]=true;
				break;
			}
		}
	}
	if(dp[k])
    {
        cout<<"First"<<endl;
    }
    else
    {
        cout<<"Second"<<endl;
    }
}
	


Measured memory_bytes: 256
n, m = map(int, input().split())
D = [list(map(int, input().split())) for i in range(m)]

A = [0] * (n+1)

M = [[] for i in range(n+1)]

for i in range(m):
    M[D[i][0]].append([D[i][1], D[i][2]])
    M[D[i][1]].append([D[i][0], -D[i][2]])

V = [0] * (n+1)


# print(M)

for ii in range(1, n+1):
    if V[ii] == 0 and len(M[ii]) > 0:

        Q = [[ii, 0]]
        st = 0
        while st < len(Q):
            # print(A,V,Q)
            node = Q[st][0]
            dist = Q[st][1]
            if V[node] == 0 and len(M[node]) > 0:
                V[node] = 1
                A[node] += dist
                for i in M[node]:
                    if V[i[0]] == 0:
                        Q.append([i[0], A[node] + i[1]])
            st += 1

# print(A)

def d():
    for i in range(m):
        if A[D[i][1]] - A[D[i][0]] != D[i][2]:
            return "No"
    return "Yes"

print(d())

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

typedef long long ll;
typedef unsigned long long ull;

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

    for(int k=0;k<N;k++) cout << A[k] << (k<N-1?" ":"\n");
    for(int i=1;i<N;i++){
        int v=A[i];
        int j;
        for(j=i-1;j>=0 && A[j]>v;j--) A[j+1]=A[j];
        A[j+1]=v;

        for(int k=0;k<N;k++) cout << A[k] << (k<N-1?" ":"\n");
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    ll X, Y, Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y;
}

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

int main()
{
int n,u,k,v;scanf("%d",&n);
vector<vector<int>> G(n);
for(int i=0;i<n;i++)
{
scanf("%d %d",&u,&k);
for(int j=0;j<k;j++)
{
scanf("%d",&v);
G[u-1].push_back(v-1);
}
}
vector<int> dis(n,-1);
queue<int> que;
dis[0]=0;
que.push(0);
while(!que.empty())
{
v=que.front();
que.pop();
for(int nv : G[v])
{
if(dis[nv]!=-1)continue;
dis[nv]=dis[v]+1;
que.push(nv);
}
}
for(int i=0;i<n;i++)printf("%d %d\n",i+1,dis[i]);
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e5+5;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

bool compare(const pair<pair<ll,ll>,pair<ll,ll> >  &a,const pair<pair<ll,ll>,pair<ll,ll> >  &b){
        if(a.fi.fi<b.fi.fi)
            return true;
        if(a.fi.fi==b.fi.fi && a.fi.se<b.fi.se)
            return true;
        if(a.fi.fi==b.fi.fi && a.fi.se==b.fi.se && a.se.fi<b.se.fi)
            return true;
            return false;
        }
long long expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%mod,n/2,mod);
    else                             //n is odd
        return (x*expo((x*x)%mod,(n-1)/2,mod))%mod;

}

void solve(){

}

void input()
{
   /*int n;
   cin>>n;
   set<int> sth[n];
   set<int> stu[n];
   for(int  i=0;i<n;i++)
   {
       int ai;
       cin>>ai;
       for(int  j=0;j<ai;j++)
       {
           int x,y;
           cin>>x>>y;
           if(y==1)
           {
               sth[i].insert(x);
           }
           else
           {
               stu[i].insert(x);
           }
       }
   }
   set<int> honest;
   set<int> unkind;*/
   int A1,A2,A3;
   cin>>A1>>A2>>A3;
   if(A1+A2+A3>=22)
    cout<<"bust"<<endl;
   else
    cout<<"win"<<endl;


}

int main(){
boost;
  input();
}


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

#define COMMANDMAX 5000000
std::string command[2] = { "insert", "print" };

class Node
{
public: 
    int key;
    Node *parent, *left, *right;
};

using namespace std;

class BinarySearchTree
{
public:
    BinarySearchTree();
    ~BinarySearchTree();

    Node *root;

    void insert(const int);
    void inorder(Node*);
    void preorder(Node*);
    void print();
};

int main() {
    int commandnum = 0, key = 0;
    string s;
    BinarySearchTree _tree;

    cin >> commandnum;
    for(int i=0; i<commandnum; ++i) {
        cin >> s;
        if(s == command[0]) {
            cin >> key;
            _tree.insert(key);
        }

        if(s == command[1]) _tree.print();
    }
    return 0;
}

BinarySearchTree::BinarySearchTree() {
    root = nullptr;
}

BinarySearchTree::~BinarySearchTree() {

}

void BinarySearchTree::insert(const int key) {
    Node *x = root, *y = nullptr, *z = new Node;
    z->key = key;
    z->left = z->right = nullptr;

    while(x != nullptr) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        }

        else {
            x = x->right;
        } 
    }

    z->parent = y;
    if(y==nullptr) {
        root = z;
    }
    else {
        if(z->key < y->key) {
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void BinarySearchTree::inorder(Node *p) {
    if(p == nullptr) 
        return ;

    inorder(p->left);
    cout << " " << p->key;
    inorder(p->right);
}

void BinarySearchTree::preorder(Node *p) {
    if(p == nullptr) return ;
    cout << " " << p->key;
    preorder(p->left);
    preorder(p->right);
}

void BinarySearchTree::print() {
    inorder(root);
    cout << endl;

    preorder(root);
    cout << endl;
}


Measured memory_bytes: 26532
require 'prime'
require 'set'

$primes = Set[*Prime.each(1000000).to_a]

loop {
	m, n = gets.split.map &:to_i
	break if m == 0
	
	y = max_x = max_y = min_x = min_y = 0
	x = -1
	dx = 1
	dy = 0
	k = 2
	
	hash = {}
	m.times {|i|
		x += dx
		y += dy
		if x < min_x
			min_x = x
			dx, dy = -dy, dx
		elsif x > max_x
			max_x = x
			dx, dy = -dy, dx
		elsif y < min_y
			min_y = y
			dx, dy = -dy, dx
		elsif y > max_y
			max_y = y
			dx, dy = -dy, dx
		end
	
		hash[[x, y]] = i+1
	}
	
	a = (min_y..max_y).map{ [0] * (max_x-min_y+1) }
	hash.each{|(x, y), k|
		a[y-min_y][x-min_x] = k
	}
	
	table = (min_x..max_x).map{[0,-1]}
	
	catch(:exit) {
		loop {
			t = []
			b = a.shift
			(0..b.size-1).each{|i|
				c, j = table[[i-1, 0].max..[i+1, b.size-1].min].max
				t[i] = [$primes.include?(b[i]) ? c+1 : c, c == 0 ? b[i] : j]
				if b[i] == n
					puts t[i][0] == 0 ? '0 0' : t[i].join(" ")
					throw :exit
				end
			}
			table = t
		}
	}
}

Measured memory_bytes: 154560
import numpy as np
n,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
a.sort()
p=a[a>0]
z=np.count_nonzero(a==0)
m=a[a<0]
r=10**19
l=-r
while r-l>1:
    # 区間[l,r]を半分に分けて探索。最終的にrが求める値になるようにする。
    # b以下のものがk個以上あるような、最小のbを求める。bを大きくする→b以下のものも増える。b以下のものがめちゃくちゃある→bを減らす。
    b=(l+r)//2
    c=0
    if b>=0:
        c+=z*n
    # 配列aに対し、配列b//pの要素たちをそれぞれsearchsortedする。結果の配列はb//pと同じ形になる。
    c+=a.searchsorted(b//p,side='right').sum()
    # 配列aに対し、配列b//mの要素たちをそれぞれsearchsortedする。結果の配列はb//mと同じ形になる。
    c+=n*len(m)-a.searchsorted(-(-b//m),side='left').sum()
    c-=np.count_nonzero(a*a<=b)
    if c//2>=k:
        r=b
    else:
        l=b
print(r)


Measured memory_bytes: 32232
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main()
{
  int a, b, x, y;
  scanf("%d%d%d%d", &a, &b, &x, &y);
  printf("%lf %d\n", double(a) * double(b) /2, x + x == a && y + y == b);
  
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

int main()
{
	//ifstream cin("input.txt");
	ll N;
	cin>>N;
	vi A(N);
	rep(i,0,N-1)
		cin>>A[i];

	ll mi = *min_element(A.begin(), A.end());
	ll prev = -1;
	while(mi != 0 && prev != mi)
	{
		rep(i, 0, N-1)
		{
			if(A[i] % mi == 0)
				A[i] = mi;
			else
				A[i] %= mi;
		}
		prev = mi;
		mi = *min_element(A.begin(), A.end());
	}

	cout<<mi;
	
}


Measured memory_bytes: 3984
//Feet don't fail me now
//Take me to the finish line
//Oh, my heart, it breaks every step that I take
//But I'm hoping at the gates, they'll tell me
//that IOI gold is mine
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer {cout << "NO"; exit(0);}
#define vectors vector<vector<llong> >
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)

const long long MXN = 2e5 + 10;
const long long MNN = 1e4 + 520;
const long long MOD = 10007;
const long long INF = 1e18;
const long long OO = 1e9;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, x;
bool used[MXN];
deque<int> ans;

int main(){
    ios;
    cin >> n >> x;
    if(x == 1 || x == n * 2 - 1) return cout << "No", 0;
    if(x == n){
        cout << "Yes" << nl;
        for(int i = 1; i <= 2 * n - 1; i++){
            cout << i << ' ';
        }
        return 0;
    }else if(x < n){
        ans.push_back(x);
        ans.push_front(x - 1);
        ans.push_front(n);
        used[n] = used[x] = used[x - 1] = 1;
        for(int i = 1; i <= n; i++){
            if(used[i] == 0){
                ans.push_front(i);
            }
        }
        for(int i = n + 1; i <= 2 * n - 1; i++){
            ans.push_back(i);
        }
        cout << "Yes" << nl;
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i] << ' ';
        }
    }else{
        for(int i = 1; i < n; i++) ans.push_back(i);
        ans.push_back(x);
        ans.push_back(x + 1);
        ans.push_back(n);
        used[x] = used[x + 1] = used[n] = 1;
        for(int i = n; i <= 2 * n - 1; i++){
            if(used[i] == 0) {
                ans.push_back(i);
            }
        }
        cout << "Yes" << nl;
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i] << ' ';
        }
    }
}


Measured memory_bytes: 2304
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()
    cnt = collections.Counter(a)
    kind = len(cnt)

    ans = False
    if kind == 1:
        ans |= a[0] == 0
    elif kind == 2:
        key = list(cnt.keys())
        value = list(cnt.values())
        if 0 in key:
            x = key[0]^key[1]
            ans = cnt[0]*2 == cnt[x]
    elif kind == 3:
        key = list(cnt.keys())
        value = list(cnt.values())
        ans = True
        ans &= key[0]^key[1] == key[2]
        ans &= key[1]^key[2] == key[0]
        ans &= key[2]^key[0] == key[1]
        ans &= len(set(value)) == 1
    print("Yes" if ans else "No")
main()


Measured memory_bytes: 97536
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

class UnionFind
{
public:
    UnionFind(int n)
    {
        par.resize(n);
    }

    void init()
    {
        for (int i = 0, n = par.size(); i < n; ++i)
        {
            par[i] = i;
        }
    }

    int find(int x)
    {
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            return par[x] = find(par[x]);
        }
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y) return;

        par[x] = y;
    }

private:
    vector<int> par;
};

int main()
{
    int N;
    cin >> N;
    UnionFind uf1(N + 1), uf2(N + 1);
    uf1.init();
    uf2.init();
    int K, L;
    cin >> K >> L;
    int s, d;
    REP(i, K)
    {
        cin >> s >> d;
        uf1.unite(s, d);
    }
    REP(i, L)
    {
        cin >> s >> d;
        uf2.unite(s, d);
    }
    map<pair<int, int>, int> M;
    REP(i, N)
    {
        ++M[make_pair(uf1.find(i + 1), uf2.find(i + 1))];
    }
    REP(i, N)
    {
        cout << M[make_pair(uf1.find(i + 1), uf2.find(i + 1))] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 13568
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void)
{
    int n;
    cin >>n;

    bool solved = false;
    int ans = -1;
    for(int i = 1; i <= 50000 && !solved; i++){
        if(floor(i*1.08) == n){
            solved = true;
            ans = i;
        }
    }

    if(solved){
        printf("%d\n", ans);
    }else{
        printf(":(\n");
    }

    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int W, H;
  while (cin >> W >> H, W) {
    vs v(H);
    rep(i, H) cin >> v[i];
    vvi dp(H, vi(W));
    int b = 0, w = 0;
    rep(i, H) rep(j, W) {
      dp[i][j] = 2 * (v[i][j] == 'B') + (v[i][j] == 'W');
      b -= v[i][j] == 'B';
      w -= v[i][j] == 'W';
    }
    rep(_, W * H) rep(i, H) rep(j, W) {
      if (v[i][j] != '.') continue;
      if (i > 0) dp[i][j] |= dp[i - 1][j];
      if (j > 0) dp[i][j] |= dp[i][j - 1];
      if (i < H - 1) dp[i][j] |= dp[i + 1][j];
      if (j < W - 1) dp[i][j] |= dp[i][j + 1];
    }
    rep(i, H) rep(j, W) {
      b += dp[i][j] == 2;
      w += dp[i][j] == 1;
    }
    cout << b << ' ' << w << endl;
  }
}

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

using namespace std;

#define M 300005

#define ll long long

int read() {

    int s=0,w=1;

    char ch=getchar();

    while(ch<'0'||ch>'9')

	{

	    if(ch=='-') w=-1;

	    ch=getchar();

	}

    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();

    return s*w;

}

struct Ele{

    int x,y;

}a[M];

int n;

ll L,p[M],t[M],ans;

int vis[M];

int sta[M],top;

void work() {

    for(int i=1;i<n;i++)

	{

	    if(vis[i]) continue ;

	    if(a[i].x==0&&a[i].y==0) sta[++top]=i;

	    else if(a[i].x==0&&a[i].y==1)

		{

		    ans+=2*L,vis[i]=1;

		    if(top) vis[sta[top--]]=1;

		}

	}

    top=0;

    for(int i=n-1;i>=1;i--)

	{

	    if(vis[i]) continue ;

	    if(a[i].x==0&&a[i].y==0) sta[++top]=i;

	    else if(a[i].x==1&&a[i].y==0)

		{

		    ans+=2*L,vis[i]=1;

		    if(top) vis[sta[top--]]=1;

		}

	}

    for(int i=1,las=0;i<n;i++)

	{

	    if(vis[i]) continue ;

	    if(!las&&a[i].x==0&&a[i].y==0) las=i;

	    else if(a[i].x==0&&a[i].y==0) vis[las]=vis[i]=1,ans+=2*L,las=0;

	}

    if(!vis[n]&&a[n].x==0)

	for(int i=1;i<n;i++)

	    if(!vis[i]&&a[i].y==0) {vis[i]=vis[n]=1,ans+=2*L;break ;}

    for(int i=1;i<=n;i++) ans+=(!vis[i])*(2*L);

    if(vis[n]) ans+=2*L;

    else if(a[n].x==1&&a[n].y==0) ans+=2*L;

    cout<<ans<<'\n';

}

int main()

{

    n=read();L=read();

    for(int i=1;i<=n;i++) p[i]=read();

    for(int i=1;i<=n;i++)

	{

	    t[i]=read();

	    ans+=t[i]/(2*L)*(2*L);

	    t[i]%=2*L;

	    if(!t[i]) vis[i]=1;

	    else

		{

		    if(t[i]<=2*(L-p[i])) a[i].x=0;

		    else a[i].x=1;

		    if(t[i]<=2*p[i]) a[i].y=0;

		    else a[i].y=1;

		    if(a[i].x==1&&a[i].y==1) ans+=2*L,vis[i]=1;

		}

	}

    work();

    return 0;

}

Measured memory_bytes: 9600
def main():
    S = input()
    mid = len(S) // 2
    if len(S) % 2 == 0:
        a = S[:mid]
        b = S[mid:]
    else:
        a = S[:mid]
        b = S[mid+1:]

    b = b[::-1]
    ans = 0
    for i in range(mid):
        if a[i] != b[i]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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



int main() {
    

    int N;
    int M;
    int C;
    
    cin >> N >> M >> C;
    
    vector<int> vec(M);
    
    int B;
    
    for(int x=0 ; x<M ; x++){
    
        cin >> B;
        vec.at(x) = B;
    }
    
    long answer = 0;
    long chech;
    long nyuryoku;

    for(int y=0;y<N;y++){
        chech = 0;
        for(int z=0;z<M;z++){
            nyuryoku=0;
            cin >> nyuryoku;
            chech = chech + nyuryoku * vec.at(z);
        }
        if(chech > -C){
            answer++;
        }
    }
    cout << answer << endl;

}


Measured memory_bytes: 256
N=int(input())
if N<105:
    print(0)
elif N==105:
    print(1)
else:
    ans=1
    for n in range(106,N+1):
        if n%2:
            K=n//2
            y=0
            #print(n,K)
            for k in range(2,K+1):
                if n%k==0:
                    y+=1
                    #print(k)
            if y==6:
                #print(n)
                ans+=1
    print(ans)

Measured memory_bytes: 9148
#include <cstdio>
#include <iostream>
#include <string>

int main()
{
    int N;
    int ans = 0;
    int x = 0;
    scanf("%d", &N);
    std::string s;
    std::cin >> s;
    for (int i = 0; i < N; i++) {
        if (s.at(i) == 'I') {
            x++;
        } else if (s.at(i) == 'D') {
            x--;
        }
        if (x > ans) {
            ans = x;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

bool pairCompare(const std::pair<string, int>& firstElem, const std::pair<string, int>& secondElem) {
    return firstElem.second > secondElem.second;
}

int main(){
    int n;
    bool isFirst = true;
    while(cin >>  n, n){
        if(!isFirst) cout << endl;

        vector<pair<string, int> > team;

        for(int i=0; i < n; i++){
            string name; int p, q, r;
            cin >> name >> p >> q >> r;
            team.pb(mp(name, 3*p+r));
        }

        sort(all(team), pairCompare);

        for(int i=0; i < team.size(); i++){
            cout << team[i].first << "," << team[i].second << endl;
        }

        isFirst = false;
    }
}

Measured memory_bytes: 1220
N = int(input())
a = list(map(int,input().split()))
b = [0]*N
for i in reversed(range(1,N+1)):
    c = 0
    for d in reversed(range(N//i)):
        c += b[i*(d+1)-1]
    #print(i,c)
    if c%2==a[i-1]:
        b[i-1] = 0
    else:
        b[i-1] = 1
print(sum(b))
if sum(b)>0:
    print(*[i+1 for i in range(N) if b[i]==1])

Measured memory_bytes: 71132
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

// const ll MOD = (ll)1e9+7;
const ll MAX = (ll)6e3+10;

int main(void) {
   ll N;
   cin>>N;
   ll xp = 0;
   ll yp = 0;
   ll tp = 0;
   bool flag = true;
   rep(i,0,N) {
      ll x,y,t;
      cin>>t>>x>>y;
      ll dis = abs(x-xp)+abs(y-yp);
      if (dis> t-tp) flag = false;
      else if (dis%2 == (t-tp)%2) flag = true;
      else flag = false;
      xp = x;
      yp = y;
      tp = t;
   }
   if (flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

   return 0;
}



Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

/*
 T = 2001
 1000 	{1,1}
 1 		{1000,2000}
 1		{1001,1999}
*/
int main() {

	long long n, T; cin >> n >> T;
	vector < pair<long long, long long>> v(n);
	for (long long i = 0; i <= n - 1; i++) cin >> v[i].ff >> v[i].ss;
	sort(v.begin(), v.end());
	map<long long, long long> dp;
	dp[0] = 0;

	for (long long i = 0; i <= n - 1; i++) {
		for (long long j = T - 1; j >= 0; j--) {
			if (dp.find(j) == dp.end()) continue;
			dp[j + v[i].ff] = max(dp[j + v[i].ff], dp[j] + v[i].ss);
		}
	}
	debug(dp);
	long long ans = 0;
	for (auto i : dp) ans = max(ans, i.ss);

	cout << ans;

	return 0;
}

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

int main() {
  int n, m, i, j, s, t, cnt = 0, ans = 0;
  cin >> n >> m;
  vector<string> a(n), b(m);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  if (n - m != 0) {
    for (s = 0; s < n - m; ++s) {
      for (t = 0; t < n - m; ++t) {
        cnt = 0;
        for (i = 0; i < m; ++i) {
          for (j = 0; j < m; ++j) {
            if (a[s + i][t + j] == b[i][j]) {
              ++cnt;
            }
          }
        }
        if (cnt == m * m) {
          ans = 1;
        }
      }
    }
  } else {
    cnt = 0;
    for (i = 0; i < m; i++) {
      for (j = 0; j < m; j++) {
        if (a[i][j] == b[i][j]) {
          ++cnt;
        }
      }
    }
    if (cnt == m * m) {
      ans = 1;
    }
  }
  if (ans) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h> 
#include<algorithm> 
#include<stdio.h> 
#include<sstream>
#include<fstream>  
using namespace std; 
typedef long long ll; 
typedef long double ld; 

int ceil(int a, int m){
    // division of a and m
    if(a % m == 0){
        return a/m; 
    }
    else{
        return a/m + 1; 
    }
}

vector<int> sort(vector<int> arr){
    sort(arr.begin(), arr.end()); 
    return arr; 
}





int main(){

char nl = '\n'; 
char bl = ' ';

int x;
 cin >> x; 
 if(x >=30){
 	cout << "Yes"; 
 }
 else{
 	cout << "No"; 
 }

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

ll x,y;
char s[100][100];
ll t[100][100]; 

void search(){
    for(ll i=-1;i<=1;++i){
        for(ll j=-1;j<=1;++j){
            if(s[x+i][y+j]=='.'){
                t[x+i][y+j] += 1;
            }
        }
    }
}

void solve(){
    ll h,w;
    cin>>h>>w;
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            cin>>s[i][j];
            if(s[i][j]=='.'){
                t[i][j]=0;
            }else if(s[i][j]=='#'){
                t[i][j]=-1;
            }
        }
    }
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(s[i][j]=='#'){
                x = i;
                y = j;
                search();
            }
        }
    }
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(t[i][j]==-1){
                cout<<s[i][j];
            }else{
                cout<<t[i][j];
            }
        }
        cout<<endl;
    }
    cout<<endl;
}

int main(){
    solve();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <math.h>
#include <iostream>
 int main(){

     using namespace std;
     
     string s;
     cin >> s;
     
     if(s[0] == s[1] && s[1] == s[2])
     {
         cout << "No" << endl;
     } else {
         cout << "Yes" << endl;
     }
     
     
     return 0;
    
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if (a >= k) {
        cout << k << "\n";
    } else if (a + b >= k) {
        cout << a << "\n";
    } else {
        cout << 2 * a + b - k << "\n";
    }

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  long a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256