akhauriyash/Code-Regression huggingface dataset:
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: usize, b: usize};

    if a > b {
        let mut b2 = 0;
        for _ in 0..a {
            b2 = b2 * 10 + b
        }
        println!("{}", b2);
    } else {
        let mut a2 = 0;
        for _ in 0..b {
            a2 = a2 * 10 + a
        }
        println!("{}", a2);
    }
}


Measured memory_bytes: 2172
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, aa, bb;
	cin >> nn >> aa >> bb;
	cout << (nn * aa < bb ? nn * aa : bb) << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n,m = map(int,input().split())
    edge = [[] for i in range(n)]
    #st:入る辺が無い頂点
    st = []
    #to[i]:頂点iに入る辺数
    to = [0]*n
    for i in range(m):
        x,y = map(int, input().split())
        edge[x-1].append(y-1)
        to[y-1] += 1
    for i in range(n):
        if to[i] == 0:
            st.append(i)

    #dp[i]:頂点iを終点とする最長のパスの長さ
    dp = [0]*n
    while st:
        go = st.pop()
        for e in edge[go]:
            to[e] -= 1
            if to[e] == 0:
                st.append(e)
            dp[e] = max(dp[e],dp[go]+1)
    print(max(dp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 56368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int n, k;

bool finished(const vector<int> &a) {
    for (auto &each : a) if (each != n) return false;
    return true;
}

vector<int> mutate(const vector<int> &a) {
    vector<int> new_a(n, 0);
    fori (i, 0, n) {
        int left = max(0, i - a[i]);
        int right = min(n - 1, i + a[i]);
        new_a[left]++;
        if (right < n - 1) new_a[right + 1]--;
    }
    fori (i, 1, n) {
        new_a[i] += new_a[i - 1];
    }
    return new_a;
}

void solve() {
    cin >> n >> k;
    vector<int> a(n);
    fori (i, 0, n) cin >> a[i];
    for (int i = 0; i < k && !finished(a); i++) {
        a = mutate(a);
    }
    fori (i, 0, n) cout << a[i] << " ";
    cout << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  map<char, char> mp;
  mp['A'] = 'T', mp['C'] = 'G', mp['G'] = 'C', mp['T'] = 'A';
  VAR(char, b); OUTL(mp[b]);
  return 0;
}


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

typedef long long ll;

ll calc(ll x, ll y){
    if(y>=x) return y-x;
    else return INF;
}

int main(void){
    ll x,y;
    cin>>x>>y;
    
    ll ans=min({calc(x,y),calc(-x,y)+1,calc(x,-y)+1,calc(-x,-y)+2});
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n;
vector<int>G[114514];
//0=White,1=Black
int dp[114514][2];
bool used[114514];
P dfs(int x) {
	used[x] = 1;
	rep(i, G[x].size()) {
		int t = G[x][i];
		if (used[t])continue;
		P memo = dfs(t);
		dp[x][0] *= memo.first + memo.second;
		dp[x][1] *= memo.first;
		dp[x][0] %= mod;
		dp[x][1] %= mod;
	}
	return { dp[x][0],dp[x][1] };
}
signed main() {
	cin >> n;
	rep(i, n) {
		dp[i][0] = 1; dp[i][1] = 1;
	}
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	P memo = dfs(0);
	cout << (memo.first + memo.second) % mod << endl;
}

Measured memory_bytes: 13312
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;

int main(){
	int n,m;
	while(cin >> n && n){
		P star1[210];
		P star2[1010];
		for(int i=0;i<n;i++){
			cin >> star1[i].first >> star1[i].second;
		}
		cin >> m;
		for(int i=0;i<m;i++){
			cin >> star2[i].first >> star2[i].second;
		}
		int mx=star1[0].first;
		int my=star1[0].second;
		for(int i=0;i<m;i++){
			int hx = star2[i].first - mx;
			int hy = star2[i].second - my;
			int cou = 0;
			for(int j=1;j<n;j++){
				int tx = star1[j].first + hx;
				int ty = star1[j].second + hy;
				for(int k=0;k<m;k++){
					int gx = star2[k].first;
					int gy = star2[k].second;
					if(gx == tx && gy == ty){
						cou++;
						break;
					}
				}
				if(cou != j) break;
			}
			if(cou == n-1){
				cout << hx << " " << hy << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1172
import math
N,H = map(int,input().split())
A,B = [],[]
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A.sort(reverse=True)
B.sort(reverse=True)
i,p = 0,0
while i<N and A[0]<=B[i] and p<H:
    p += B[i]
    i += 1
ans = math.ceil((H-p)/A[0]) if p<H else 0
print(ans+i)


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

vector<string> maze;
int h , w;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        string s;
        cin >> s;
        maze.push_back(s);
    }

    int ans = 0;
    for(int y = 0; y < h; y++) {
        for(int x = 0; x < w; x++) {
            if(maze[y][x] == '#') {
                int cnt = 0;
                for(int k = 0; k < 4; k++) {
                    int nx = x + dx[k];
                    int ny = y + dy[k];
                    if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                    if(maze[ny][nx] == '#') cnt++;
                }
                if(cnt == 0){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

// ユークリッドの互除法
LL extgcd(LL a, LL b, LL& x, LL& y)
{
	LL g = a; x = 1; y = 0;
	if (b != 0)
	{
		g = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	return g;
}

// 逆元
LL mod_inverse(LL a, LL m)
{
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

// 階乗
std::vector<LL>fact;
void mod_fact(LL n, LL m)
{
	fact.resize(n + 1);
	fact[0] = 1;
	for (LL i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i % m;
}

// nCk mod p
LL mod_comb(LL n, LL k, LL m)
{
	if (n < k) return 0;
	return fact[n] * mod_inverse(fact[k] * fact[n - k] % m, m) % m;
}

// (num ^ x) % mod
LL pow_mod(LL num, LL x, LL mod)
{
	LL res = 1;
	while (x > 0)
	{
		if (x & 1) res = (res * num) % mod;
		(num *= num) %= mod;
		x >>= 1;
	}
	return res;
}

int main()
{
	LL N, A, B, C;
	in >> N >> A >> B >> C;

	LL ans = 0;
	mod_fact(2 * N, mod);
	for (LL i = N; i <= 2 * N - 1; ++i)
	{
		LL bunsi = (pow_mod(A, N, mod) * pow_mod(B, i - N, mod) % mod + pow_mod(A, i - N, mod) * pow_mod(B, N, mod) % mod) * i * 100 % mod;
		LL bunbo = pow_mod(A + B, i, mod) * (100 - C) % mod;
		(ans += mod_comb(i - 1, N - 1, mod) * bunsi % mod * mod_inverse(bunbo, mod) % mod) %= mod;
	}

	out << ans << std::endl;
}


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

int main(){
  int N, D;
  
  cin >> N >> D;
  
  if (N <= (2 * D + 1) ){
    cout << 1 << endl;
  }
  else{
    if (N % (2 * D + 1)   == 0){
      cout <<  N / (2 * D + 1) << endl;
    }
    else{
      cout << 1 + N / (2 * D + 1) << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,A,B;
int Delete(int x,int p) {
    int d = x & (1 << p) - 1;
    int u = x & (1 << 20) - (1 << p + 1);
    return (u >> 1) + d;
}
int Insert(int x,int p,int v) {
    int d = x & (1 << p) - 1;
    int u = x & (1 << 20) - (1 << p);
    return (u << 1) + v + d;
}
vector<int> Calc(int s,int t,int n) {
    if(n == 1) {
        vector<int> v;v.pb(s);v.pb(t);
        return v;
    }
    int x = 1,p = 0;
    while(1) {
        if((s & x) != (t & x)) break;
        x <<= 1;++p;
    }
    int a,b;
    a = Delete(s,p);b = Delete(t,p);
    int c = a ^ 1;
    vector<int> f = Calc(a,c,n - 1),h = Calc(c,b,n - 1);
    for(int i = 0 ; i < (1 << n - 1) ; ++i) {
        f[i] = Insert(f[i],p,(s & x));
        h[i] = Insert(h[i],p,(t & x));
    }
    f.insert(f.end(),h.begin(),h.end());
    return f;
}
int count(int x) {
    int res = 0;
    while(x) {
        res += (x & 1);
        x >>= 1;
    }
    return res;
}
void Solve() {
    read(N);read(A);read(B);
    if(!(count(A^B) & 1)) {puts("NO");return;}
    puts("YES");
    vector<int> ans = Calc(A,B,N);
    for(int i = 0 ; i < (1 << N) ; ++i) {
        out(ans[i]);space;
    }
    enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 1648
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
  int x,i=1;
  
  while(true){
      scanf("%d",&x);
      if(x==0) break;
      printf("Case %d: %d\n",i,x);
      i++;
  }
    return (0);
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,s,n) for(int i=s;i<n;i++)
#define lol(i,n) for(int i=0;i<n;i++)
typedef long long ll;
#define N 100010
ll a[N],b[N],h,w,cs[N];
int main(){
    cin>>h>>w;
    lol(i,h)cin>>a[i];
    lol(j,w)cin>>b[j];
    sort(a,a+h); sort(b,b+w);
    cs[0]=0; lol(i,w)cs[i+1]=cs[i]+b[i];
    ll ans=0;
    lol(i,h){
	ll t=lower_bound(b,b+w,a[i])-b;
	ans+=cs[t]+a[i]*(w-t);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5512
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================








int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	string S;
	cin >> S;

	char first = S[0];
	for (int i = 0; i < S.length(); i++) {
		if( S[i] != first){
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
void add_self(ll &a, ll b){
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
}
ll rangeSum(int l, int r , ll prefix[]){
    if(l > r){
        return 0;
    }
    return (prefix[r] - ((l-1 >= 0 ) ? prefix[l-1] : 0) + MOD)%MOD;
}
int n;
string s;
int main() {
    IO;
    cin >> n;
    cin >> s;
    ll dp[n][n+1] = {};
    dp[0][1] = 1;
    ll prefix[n+1];
    for(int i = 1; i < n; i++){// numbers from 1-> i+1 where i index
        prefix[0] = dp[i-1][0];
        for(int j = 1; j < n+1; j++){
            prefix[j] = (prefix[j-1] + dp[i-1][j])%MOD;
        }
        for(int j = 1; j <= i+1; j++){
            if(s[i-1] == '>'){
                add_self(dp[i][j], rangeSum(j, i, prefix));
            }else{
                add_self(dp[i][j], rangeSum(0, j-1, prefix));
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < n+1; i++){
        add_self(ans, dp[n-1][i]);
    }
    cout << ans;




    return 0;
}


Measured memory_bytes: 70656
#include <stdio.h>

int main(void)
{
        int n,ac=0,wa=0,tle=0,re=0;
        char s[10];
        scanf("%d",&n);
        for(int i=0;i<n;i++){
                scanf("%s",s);
                if(s[0]=='A') ac++;
                else if(s[0]=='W') wa++;
                else if(s[0]=='T') tle++;
                else if(s[0]=='R') re++;
        }
        printf("AC x %d\n",ac);
        printf("WA x %d\n",wa);
        printf("TLE x %d\n",tle);
        printf("RE x %d\n",re);
        return 0;
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string ans;
	stack<char> st;
	rep (i, s.size()) {
		if (st.empty() && s[i] == 'B') continue;
		if (s[i] == 'B') {
			st.pop();
		} else {
			st.push(s[i]);
		}
	}
	while (st.size()) {
		ans += st.top();
		st.pop();
	}
	reverse(all(ans));
	cout << ans << endl;
	return 0;
}



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

string n;
int k;

int comb(int n, int k) {
	int rv = 1;
	for (int i = 0; i < k; i++)
		rv *= n--;
	while (k)
		rv /= k--;
	return rv;
}

int g(int free, int k) {
	return comb(free, k) * pow(9, k);
}

int f(string n, int k) {
	if (k == 0)
		return 1;
	if (n.size() < k)
		return 0;
	int init = n[0] - '0';
	if (init) {
		return f(n.substr(1), k - 1) + (init - 1) * g(n.size() - 1, k - 1)
				+ g(n.size() - 1, k);
	}
	return f(n.substr(1), k);
}

int main() {
	cin >> n >> k;
	cout << f(n, k) << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
char a,b;
int main()
{
    cin>>a>>b;
    if(a==b)
    	cout<<"H"<<endl;
    else
    	cout<<"D"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define endl '\n'
#define mod 1000000007
#define modd 998244353
#define PI 3.1415926535897932384626
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	int x,y;
	cin>>x>>y;
	int k=4*x-y;
	if(k%2==0 && k/2>=0 && k/2<=x)
		cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

int main(){
	int n;
	while(1){
		int a[100]={0};
		int sum=0;
		cin>>n;
		if(n==0) break;
		for(int i=0 ; i<n ; i++){
			cin >> a[i] ;
		}
		for(int i=n-1 ; i>=0 ; i--){
			for(int j=0 ; j< i ; j++){
				if(a[j]>a[j+1]){
					a[j]^=a[j+1];
					a[j+1]^=a[j];
					a[j]^=a[j+1];
				}
			}
		}
		for(int i=1 ; i<n-1 ; i++){
			sum+=a[i];
		}
			cout << sum/(n-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

bool sunuke[110];

int main() {
  int N,K;
  cin >> N >> K;
  rep(i,K) {
    int d;
    cin >> d;
    rep(j,d) {
      int a;
      cin >> a;
      a--;
      sunuke[a] = true;
    }
  }
  int ans = 0;
  rep(i,N) if(!sunuke[i]) ans++;
  cout << ans << endl;
  
  
}


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

int main(void) { 
    int s, k;
    cin >> k >> s;
    int ans = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int num = s - i - j;
            if(num < 0 || num > k) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
typedef vector<vector<Weight>> Graph;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

int n;

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

  cin >> n;
	//vector<ll> a(n); rep(i,n) cin >> a[i];

	if (n >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 3648
#!/usr/local/gnu/bin/bash
a=()
for i in `seq 3`
do
    read -a t
    a+=(`echo ${t[@]}`)
done
read n
for i in `seq $n`
do
    read b
    for j in `seq 0 8`
    do
        if((a[j]==b))
        then
            a[$j]=0
            break
        fi
    done
done
for i in `seq 0 2`
do
    if((a[3*i]+a[3*i+1]+a[3*i+2]==0||a[i]+a[i+3]+a[i+6]==0))
    then
        echo Yes
        exit
    fi
done
if((a[0]+a[4]+a[8]==0||a[2]+a[4]+a[6]==0))
then
    echo Yes
    exit
fi
echo No

Measured memory_bytes: 1708
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<int,int> m;
int a[100005];
int main(){
	int n,x,k=0,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		if(m[x]==0)
			a[++k]=x;
		m[x]++;
	}
	for(int i=1;i<=k;i++){
		if(m[a[i]]>a[i])
			ans+=m[a[i]]-a[i];
		else if(m[a[i]]<a[i])
			ans+=m[a[i]];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5120
n = int(input())
a_list = list(map(int, input().split()))

a_list.sort(reverse = True)

a_point = 0
b_point = 0

for i in range(n):
  if i % 2 == 0:
    a_point += a_list[i]
  else:
    b_point += a_list[i]

print(a_point - b_point)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define fi first
#define sc second
#define mp make_pair
#define pb push_back
typedef pair<int,int> P;
typedef long long ll;

int n,k;
ll dp[105][105];

int main(){
	cin >> n >> k;
	dp[1][1] = dp[1][k] = 1;
	for(int i=1;i<n;i++){
		for(int j=1;j<=n;j++){
			if(dp[i][j] == 0) continue;
			if(i%2==1){
				if(j < n) dp[i+1][j+1] += dp[i][j];
			}
			else{
				if(j+1 <= n) dp[i+1][j+1] += dp[i][j];
				if(j+k <= n) dp[i+1][j+k] += dp[i][j];
			}
		}
	}
	ll ans = 0;
	repn(i,n) repn(j,n) if(i%2 == 1) ans += dp[i][j];
	cout << ans << endl;
}



Measured memory_bytes: 3196
#include <stdio.h>
 int main(void){
     int i, j,H,W;
     while(scanf("%d %d",&H,&W)!=EOF){
      if(H==0&&W==0){
         break;
      }
     for ( i = 0; i < H; i++ ){
     for ( j = 0; j < W; j++ ){
         printf("#");
     }
     printf("\n");
    
     }
     printf("\n");
 }
     

    return(0);// Your code 
     
 }






Measured memory_bytes: 2608
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for( int i = 0; i < 3; ++ i )
    {
        if( a[i] == b[i] )
            ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w, k int
	fmt.Scanf("%d", &h)
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &k)

	b := make([]string, h)
	for i := 0; i < len(b); i++ {
		fmt.Scanf("%s", &b[i])
	}

	c := make([][]string, h)
	for i := 0; i < h; i++ {
		c[i] = make([]string, w)

		_b := strings.Split(b[i], "")
		for j := 0; j < w; j++ {
			c[i][j] = _b[j]
		}
	}

	ans := 0
	var i, j uint
	var i2, j2 uint
	for i = 0; i < (uint(1) << uint(h)); i++ {
		for j = 0; j < (uint(1) << uint(w)); j++ {
			k_count := 0

			for i2 = 0; i2 < uint(h); i2++ {
				for j2 = 0; j2 < uint(w); j2++ {
					if i>>i2&1 == 0 && j>>j2&1 == 0 && c[i2][j2] == "#" {
						k_count = k_count + 1
					}
				}
			}

			if k == k_count {
				ans = ans + 1
			}
		}
	}

	fmt.Println(ans)
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; i++)
    {
        if(i % 2 == 0) Alice += a.at(i);
        else Bob += a.at(i);
    }
    
    cout << Alice - Bob << endl;
}

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

int main(){
	int x, y, tmp;
	while(1){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}
		if(y < x){
			tmp = x;
			x = y;
			y = tmp;
		}
		
		cout << x << " " << y << endl;
	}
	
	return 0;
} 

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

int64_t luca(int64_t n, vector<int64_t> &memo){
  if( n == 0 ) return 2;
  else if ( n == 1 ) return 1;
  
  if (memo.at(n) != -1) return memo.at(n);
  return memo.at(n) = luca(n-1, memo) + luca(n-2, memo);
}

int main() {
  int64_t n;
  cin >> n;
  
  vector<int64_t> memo(n+1, -1);
  cout << luca(n, memo) << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,m;
  cin >> n >> m;

  vll a(n);
  vll cumlative(n+1);
  REP(i, n)
    cin >> a[i];

  map<ll, ll> remind;
  remind[0] += 1;
  set<ll> s;
  s.insert(0);
  REP(i, n){
    cumlative[i+1] = (cumlative[i] + a[i])%m;
    remind[cumlative[i+1]] += 1;
    s.insert(cumlative[i+1]);
  }

  ll ans = 0;
  for(auto pt : s)
    ans += (remind[pt]-1)*remind[pt]/2;

  cout << ans << endl;
}


Measured memory_bytes: 8704
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;


int main() {
	long r, D, x; cin >> r >> D >> x;

	for (int i = 0; i < 10; i++) {
		x = x * r - D;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) {
    if (s[i] == 'R') a[i] = 0;
    if (s[i] == 'G') a[i] = 1;
    if (s[i] == 'B') a[i] = 2;
  }
  vector<ll> cnt(3);
  rep(i,n) cnt[a[i]]++;
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  rep(j,n)rep(i,j) {
    int k = j + (j-i);
    if (k < n) {
      if (a[i] == a[j]) continue;
      if (a[i] == a[k]) continue;
      if (a[k] == a[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

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

  int longest = 0;
  int a0;
  int prevA = 0;
  for (int n=0; n<N; ++n) {
    int a;
    cin >> a;

    if (n==0)
      a0 = a;
    
    longest = max(longest, a-prevA);

    prevA = a;
  }

  longest = max(longest, a0 + (K-prevA));

  cout << K - longest << endl;

  return 0;
}


Measured memory_bytes: 256
def solve(y,m,d):
	if y<1868 or (y==1868 and m<9) or (y==1868 and m==9 and d<8):
		print("pre-meiji")
	elif 1868<y<1912 or (y==1868 and 9<m) or (y==1868 and m==9 and 8<=d) or (y==1912 and m<7) or(y==1912 and m==7 and d<=29):
		print("meiji %d %d %d"%(y-1868+1,m,d))
	elif 1912<y<1926 or (y==1912 and 7<m) or (y==1912 and m==7 and 30<=d) or (y==1926 and m<12) or (y==1926 and m==12 and d<=24):
		print("taisho %d %d %d"%(y-1912+1,m,d))
	elif 1926<y<1989 or (y==1926 and 12<m) or (y==1926 and m==12 and 25<=d) or (y==1989 and m<1) or (y==1989 and m==1 and d<=7):
		print("showa %d %d %d"%(y-1926+1,m,d))	
	else:
		print("heisei %d %d %d"%(y-1989+1,m,d))


while True:
	try:
		y,m,d=map(int,input().split())
		solve(y,m,d)
	except EOFError:
		break

Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順(昇順)
//g++ code.cpp   ./a.out 
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(a>=c){
    cout << c << endl;
    return 0;
  }
  else if(a+b==60){
    cout << "-1" << endl;
    return 0;
  } 
  else{
    rep(i,1000){
      rep(j,1000){
        if((i+1)*a+(i+1)*b<=c+60*j && c+60*j<=(i+2)*a+(i+1)*b){
          cout << c+60*j << endl;
          return 0;
        }  
      }
    }
    cout << -1 << endl;
  }
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int A,B,K,count=0;
  cin >> A >> B >> K;
  for(int i=100;i>=1;i--){
    if(A%i==0 && B%i==0){
      count++;
    }
    if(count==K){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 384
while True:
    x=int(input())
    if x==0:
        break
    y=1000-x
    a=y//500
    b=(y-500*a)//100
    c=(y-500*a-100*b)//50
    d=(y-500*a-100*b-50*c)//10
    e=(y-500*a-100*b-50*c-10*d)//5
    f=(y-500*a-100*b-50*c-10*d-5*e)
    print(a+b+c+d+e+f)


Measured memory_bytes: 5588
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100005
using namespace std;
const int mod = 1e9+7;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n, m, S, S_, SS, SS_, T, T_;
int x[N], y[N];

void upd(int &x, int y){ x += y; if(x >= mod) x -= mod; }

int main(){
	n = read(); m = read();
	for(int i = 1; i <= n; i++) x[i] = read(), upd(x[i], mod);
	for(int i = 1; i <= m; i++) y[i] = read(), upd(y[i], mod);
	for(int i = 1; i <= n; i++) upd(T_, 1LL * x[i] * (n - i) % mod);
	for(int i = 1; i <= m; i++) upd(T, 1LL * y[i] * (m - i) % mod);
	for(int i = 1; i <= n; i++) upd(x[i], x[i - 1]); S_ = x[n];
	for(int i = 1; i <= m; i++) upd(y[i], y[i - 1]); S = y[m];
	for(int i = 1; i <= n; i++) upd(x[i], x[i - 1]); SS_ = x[n];
	for(int i = 1; i <= m; i++) upd(y[i], y[i - 1]); SS = y[m];
	int ans = 1LL * n * m % mod * S_ % mod * S % mod;
	upd(ans, mod - 1LL * SS_ * m % mod * S % mod);
	upd(ans, mod - 1LL * n * S_ % mod * SS % mod);
	upd(ans, 1LL * SS * SS_ % mod);
	upd(ans, mod - 1LL * n * S_ % mod * T % mod);
	upd(ans, 1LL * SS_ * T % mod); 
	upd(ans, mod - 1LL * m * T_ % mod * S % mod);
	upd(ans, 1LL * T_ % mod * SS % mod);
	upd(ans, 1LL * T_ % mod * T % mod);
	printf("%d\n", ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  ll N,K;
  cin >> N >> K;
  vector< vector<ll> > A;
  vector<ll> x(N);
  A.push_back(x);
  FOR(i,0,N) cin >> A[0][i], A[0][i]--;

  ll k = 1;
  FOR(i,1,1000000){
    k *= 2;
    if(k>K) break;
    A.push_back(x);
    FOR(j,0,N){
      A[i][j] = A[i-1][ A[i-1][j] ];
    }
  }


  ll ans = 0;
  k = 1;
  FOR(i,0,A.size()){
    if(K&k){
      ans = A[i][ans];
    }
    k *= 2;
  }
  cout << ans+1 << endl;

}


Measured memory_bytes: 98564
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int a, b; cin >> a >> b;
    if (a == b) cout << a << endl;
    else if (a <= b) cout << a << endl;
    else cout << a-1 << endl;
}

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


int main(){
	int K, S, ans = 0;
	scanf("%d %d", &K, &S);
	for(int X= 0; X <= K; X++)
		for(int Y = 0; Y <= K; Y++){
			int Z =  S - X - Y;
			if (Z >= 0 && Z <= K) ans++;
		}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}
fn main() {
    input!{ n: usize, a: [i32;n] }
    let mut b = vec![0;n];

    for i in (1..n+1).rev() {
        let mut j = i;
        let mut sum = 0;
        while j <= n {
            sum += b[j-1];
            j += i;
        }
        if a[i-1] != sum%2 {
            b[i-1] = 1;
        }
    }

    let mut ans = Vec::new();
    for i in 0..n {
        if b[i] == 1 {
            ans.push(i+1);
        }
    }
    println!("{}", ans.len());
    for (i,v) in ans.iter().enumerate() {
        if i > 0 {
            print!(" ");
        }
        print!("{}", v);
    }
    println!();
}

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

#define INF 1.1e9
#define LINF 1.1e18
#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 pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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

int n,m;
vector<int> g[2000];
int ans=INF;
vector<P> e;

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

	cin>>n>>m;
	REP(i,n-1) {
		int a,b;cin>>a>>b;a--,b--;
		g[a].pb(b),g[b].pb(a);
		e.pb(P(a,b));
	}
	if(m&1) {
		for(auto k:e) {
			int cnt=0;
			int d[n]={};
			d[k.fi]=1;
			d[k.se]=1;
			queue<int> q;
			q.push(k.fi);
			q.push(k.se);
			while(!q.empty()) {
				int v=q.front();q.pop();
				for(auto u:g[v]) {
					if(d[u]!=0) continue;
					d[u]=d[v]+1;
					q.push(u);
					if(d[u]-1>m/2) cnt++;
				}
			}
			ans=min(ans,cnt);
		}
	}
	else {
		REP(k,n) {
			int cnt=0;
			int d[n]={};
			d[k]=1;
			queue<int> q;
			q.push(k);
			while(!q.empty()) {
				int v=q.front();q.pop();
				for(auto u:g[v]) {
					if(d[u]!=0) continue;
					d[u]=d[v]+1;
					q.push(u);
					if(d[u]-1>m/2) cnt++;
				}
			}
			ans=min(ans,cnt);
		}
	}
	cout<<ans<<endl;

	return 0;
}


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

char map[101][101];
char moji;
int H,W;

void bfs( int i,int j ) {
  if ( map[i][j] != moji ) return;
  if ( map[i][j] == moji ) {
    map[i][j] = '$';
    if( i+1 <= H ) bfs( i+1,j );
    if( i-1 >= 1 ) bfs( i-1,j );
    if( j+1 <= W ) bfs( i,j+1 );
    if( j-1 >= 1 ) bfs( i,j-1 );
  }

}

int main(){
  while ( cin >> H >> W, H+W ) {
    for ( int i = 1; i <= H; i++ ) {
      for ( int j = 1; j <= W; j++ ) cin >> map[i][j];
    }
    int cnt = 0;
    for ( int i = 1; i <= H; i++ ) {
      for ( int j = 1; j <= W; j++ ) {
	if ( map[i][j] == '@' ){
	  cnt++;
	  moji = '@';
	  bfs(i,j);
	} else if ( map[i][j] == '#' ) {
	  cnt++;
	  moji = '#';
	  bfs(i,j);
	} else if ( map[i][j] == '*' ) {
	  cnt++;
	  moji = '*';
	  bfs(i,j);
	}
      }
    }
    cout << cnt << endl;
     
  }
  return 0;
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 15;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m;
char mp[MAXN][MAXN];
int rnum[MAXN], cnum[MAXN];
bool visrow[MAXN], viscol[MAXN];
bool row[MAXN][MAXN], col[MAXN][MAXN];
void check() {
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
		if (mp[rnum[i]][cnum[j]] != mp[rnum[n - i + 1]][cnum[m - j + 1]]) return;
	printf("YES\n");
	exit(0);
}
void workc(int pos, int type) {
	if (pos == 0) {
		check();
		return;
	}
	if (type) {
		for (int i = 1; i <= m; i++) {
			viscol[i] = true;
			cnum[pos] = i;
			workc(pos - 1, 0);
			viscol[i] = false;
		}
	} else {
		for (int i = 1; i <= m; i++) {
			if (viscol[i]) continue;
			for (int j = i + 1; j <= m; j++)
				if (!viscol[j] && col[i][j]) {
					viscol[i] = true;
					viscol[j] = true;
					cnum[pos] = i;
					cnum[m + 1 - pos] = j;
					workc(pos - 1, 0);
					viscol[i] = false;
					viscol[j] = false;
				}
			return;
		}
	}
}
void workr(int pos, int type) {
	if (pos == 0) {
		workc((m + 1) / 2, m & 1);
		return;
	}
	if (type) {
		for (int i = 1; i <= n; i++) {
			visrow[i] = true;
			rnum[pos] = i;
			workr(pos - 1, 0);
			visrow[i] = false;
		}
	} else {
		for (int i = 1; i <= n; i++) {
			if (visrow[i]) continue;
			for (int j = i + 1; j <= n; j++)
				if (!visrow[j] && row[i][j]) {
					visrow[i] = true;
					visrow[j] = true;
					rnum[pos] = i;
					rnum[n + 1 - pos] = j;
					workr(pos - 1, 0);
					visrow[i] = false;
					visrow[j] = false;
				}
			return;
		}
	}
}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
		scanf("%s", mp[i] + 1);
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= n; j++) {
		static char x[MAXN], y[MAXN];
		for (int k = 1; k <= m; k++) {
			x[k] = mp[i][k];
			y[k] = mp[j][k];
		}
		sort(x + 1, x + m + 1);
		sort(y + 1, y + m + 1);
		row[i][j] = true;
		for (int k = 1; k <= m; k++)
			if (x[k] != y[k]) row[i][j] = false;
	}
	for (int i = 1; i <= m; i++)
	for (int j = 1; j <= m; j++) {
		static char x[MAXN], y[MAXN];
		for (int k = 1; k <= n; k++) {
			x[k] = mp[k][i];
			y[k] = mp[k][j];
		}
		sort(x + 1, x + n + 1);
		sort(y + 1, y + n + 1);
		col[i][j] = true;
		for (int k = 1; k <= n; k++)
			if (x[k] != y[k]) col[i][j] = false;
	}
	workr((n + 1) / 2, n & 1);
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> mons(n+1);
  vector<int> hero(n+1);
  for (int i = 0;i < n+1;i++) cin >> mons[i];
  for (int i = 0;i < n;i++) cin >> hero[i];
  ll ans = 0;
  int rest = 0;
  for (int i = 0;i < n+1;i++) {
    ans += min(rest, mons[i]);
    mons[i] -= min(rest, mons[i]);
    ans += min(mons[i], hero[i]);
    hero[i] -= min(mons[i], hero[i]);
    rest = hero[i];
  }
  cout << ans << endl;
}

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

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

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    ll X,Y;
    cin>>X>>Y;
    ll t = X-Y;
    if(t==1||t==0||t==-1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  for(ll i=0;i<=n;i++) cin >> a[i];
  vector<ll> d(n+1);
  vector<ll> d2(n+1);
  d[0] = 1;
  if(a[0]==1){
     d[0] = 0;
  }
  else if(a[0]>1){
     cout << -1 << endl;
     return 0;
  }
  for(ll i=1;i<=n;i++){
    d[i]=d[i-1]*2-a[i];
    if(d[i]>=1e16) d[i] = 1e16;
  }
  for(ll i=0;i<=n;i++){
    if(d[i]<0){
      cout << -1 << endl;
      return 0;
    }
  }
  d2[n] = a[n];
  for(ll i=n-1;i>=0;i--){
    d2[i] = d2[i+1] + a[i];
    if(d2[i]>(d[i]+a[i])) d2[i] = d[i]+a[i];
  }
  ll ans = 0;
  for(ll i=0;i<=n;i++){
    ans += d2[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 5572
#include <iostream>
#include <cassert>
#include <algorithm>
#define N 2000ll
using namespace std;
typedef pair<long long,long long>P;
long long f[N+1][N+1]={0};
P d[N];
int main(int argc,char ** argv)
{
    long long n;
    cin>>n;
    for(long long i=0;i<n;++i){cin>>d[i].first;d[i].second=i;}
    sort(d,d+n,[](P& a,P& b)->bool{return a.first>b.first;});

    for(long long i=0;i<=n;++i){
        for(long long j=0;j+i<=n;++j){
            f[i][j]=+max((i>0?f[i-1][j]+d[i+j-1].first*abs(i-1-d[i+j-1].second):0),(j>0?f[i][j-1]+d[i+j-1].first*abs(n-j-d[i+j-1].second):0));
        }
    }
    long long ans=0;
    for(long long i=0;i<=n;++i){
        ans=max(ans,f[i][n-i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 26204
import java.util.*;
public class Main {

	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] ps = new int[n];
		
		for(int i=0; i< n; i++) {
			ps[i] = sc.nextInt();
		}
		
		int[] p_sum = new int[n];
		int max = 0;
		for(int i =0;i<k;i++) {
			p_sum[k-1] += ps[i];
			max = p_sum[k-1];
		}
		for(int i=k; i <n;i++) {
			p_sum[i] = ps[i] + p_sum[i-1] - ps[i-k] ;
			max = Math.max(max, p_sum[i]);
		}
		System.out.println((max+k)/2.0);
		
		
		
		
	}
	


}

 

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

using namespace std;

int main()
{
	double ans=0x3f3f3f3f; 
	int n,t,a,h,num;
	cin>>n>>t>>a;
	for(int i=1;i<=n;i++)
	{
		cin>>h;
		if(abs(t-h*0.006-a)<ans)
		{
			ans=abs(t-h*0.006-a);
			num=i;
		}
	}
	cout<<num<<endl;
	return 0;
 }

Measured memory_bytes: 256