akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    if(n%1000 != 0){
        cout << 1000-n%1000 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int a,b;
	cin >> a >> b;
	cout << b + (b - a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int diffm = m2 - m1;
  if(m2 < m1){
    diffm = 60 - m1 + m2;
    h2--;
  }
  int diffh = h2 - h1;
  if(h2 < h1){
    diffh = 60 - h1 + h2;
  }
  int sum = diffm + diffh * 60;
  cout << sum - k << endl;

}


Measured memory_bytes: 3656
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

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

#include <cctype>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}

int main(){
  int n;cin>>n;
	if(n==1){
		cout << 'a' << endl;
		return 0;
	}
	vector<int> A(n);
	for(int i = 0; n > i; i++){
		A[i] = 0;
	}
	A[n-1] = -1;
	while(true){
		int nw = n-1;
		while(0 < nw){
			int mx = 0;
			for(int i = 0; nw > i; i++){
				mx = max(mx,A[i]);
			}
			if(A[nw]-A[nw-1] < 1 || A[nw] <= mx){

				A[nw]++;
				break;
			}else{
				A[nw] = 0;
			}
			nw--;
		}
		if(!nw)break;
		for(int i = 0; n > i; i++){
			cout << (char)('a'+A[i]);
		}
		cout << endl;
	}
}

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

#define fst first
#define snd second
#define mkp make_pair
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pll;
const int MAXN = 210;
const ll MOD = 1000000007;

inline ll read() {
	ll x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n, cn;
map<vector<ll>, vector<pll> > m;
map<vector<ll>, vector<pll> >::iterator it;
ll a[MAXN], c[MAXN], b[MAXN];
ll ans, K;
vector<ll> t;
vector<pll> q;

int main() {
	int i, j, k;
	n = read(), K = read();
	ans = 0;
	for(i = 1; i <= n; i++) a[i] = read();
	for(k = 0; k <= min(K, 60LL); k++) {
		ll all = (1LL<<k)-1;
		for(i = 1; i <= n; i++) c[i] = a[i]&all;
		sort(c+1, c+n+1);
		cn = unique(c+1, c+n+1)-c-1;
		c[0] = -1;
		if(c[cn] != all) c[++cn] = all;
		for(i = 0; i < cn; i++) {
			ll P, res = 1LL<<61;
			if(c[i] == -1) P = 0;
			else {
				for(j = 60; j >= 0; j--) 
					if((c[i]>>j)^(c[i+1]>>j)) break;
				P = ((c[i+1]>>j)|1LL)<<j;
			}
			for(j = 1; j <= n; j++) {
				b[j] = (a[j]&all) >= P ? a[j]>>k : (a[j]>>k)-1;
				res = min(res, b[j]);
			}
			int cnt = __builtin_popcountll(P);
			res = min(res, K-cnt-k);
			if(res < 0) continue;
			t.clear();
			for(j = 1; j < n; j++) t.push_back(b[j+1]-b[j]);
			m[t].push_back(mkp(b[1]-res, b[1]));
		}
	}
	for(it = m.begin(); it != m.end(); it++) {
		q = it->snd;
		sort(q.begin(), q.end());
		ll maxr = q[0].snd, lef = q[0].fst;
		for(i = 1; i < (int)q.size(); i++) {
			if(q[i].snd <= maxr) continue;
			if(q[i].fst > maxr) {
				ans = (ans+maxr-lef+1)%MOD;
				lef = q[i].fst, maxr = q[i].snd;
				continue;
			}
			maxr = max(maxr, q[i].snd);
		}
		ans = (ans+maxr-lef+1)%MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 16384
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,a,b;
  cin >> n >> a >> b;

  int sum = (n * a > b) ? b : n * a;
  cout << sum;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include<queue>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

// int min(int a, )

int main(){

    int n,m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> b(m), c(m);
    for (int i = 0; i < m; i++)
    {
        cin >> b[i] >> c[i];
    }
    priority_queue<pair<ll,ll> > q;

    for (int i = 0; i < n; i++)
    {
        q.push(pair<ll, ll>(a[i], 1));
    }

    for (int i = 0; i < m; i++)
    {
        q.push(pair<ll, ll>(c[i], b[i]));
    }

    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        pair<ll, ll> top = q.top();
        q.pop();
        ans += top.first;
        // cout << top.first << ' ' << top.second << endl;
        top.second--;
        if (top.second > 0)
            q.push(top);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int min = Math.Min(ab[0], ab[1]);
            int max = Math.Max(ab[0], ab[1]);
            for(int i = 0; i < max; i++)
            { Console.Write(min); }
        }
    }
}


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

using namespace std;

#define ll long long
#define vi vector<int>
#define mkp make_pair
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD = 1e9 + 7;
int arr[mxn];
int n, m, k;
string s;

ll pow(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}

void read(){
    cin >> n;
//    for(int i = 0, u, v; i < n; i++){
//        cin >> arr[i];
//    }
}

void solve(){
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 && i % 5) ans += i;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    //init();
    while(T--) read(), solve();
    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		double[] A = new double[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = double.Parse(str[i]);
		}
		Array.Sort(A,(x,y)=>x.CompareTo(y));
		double ans = (A[0]+A[1])/2;
		for(int i=2;i<N;i++){
			ans = (ans + A[i])/2;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11220
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (S == U)
		--A;
	if (T == U)
		--B;
	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// マラソン用時間計測
clock_t start_clock;
constexpr double time_limit = 1.919114514; // 実行時間[s]より0.1ms程度余裕をあける
constexpr double CLOCKS_PER_SEC_INV = 1.0 / CLOCKS_PER_SEC;
inline double nowtime() { return CLOCKS_PER_SEC_INV * (clock() - start_clock); }
inline bool intime() { return nowtime() < time_limit; }

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (int i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (int i=(is), i##_end=(ie); i<=i##_end; i++)
#define FOREACH(i, arr) for (auto &i : arr)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using ll = long long;
using namespace std;

// 汎用クラス
struct union_find {
    vector<int> par;
    vector<int> num;
    union_find(int n) : par(n, 0), num(n, 1) { iota(ALL_OF(par), 0); }
    int root(int i) { return par[i] == i ? i : (par[i] = root(par[i])); }
    bool same(int i, int j) { return root(i) == root(j); }
    void unite(int i, int j) {
        int ri = root(i);
        int rj = root(j);
        if (ri != rj) {
            if (num[ri] > num[rj]) swap(ri, rj);
            par[ri] = rj;
            num[rj] += num[ri];
        }
    }
};

// main前実行のためのダミークラス
struct preexec_dummy {
    preexec_dummy() {
        start_clock = clock();
    }
} preexec_dummy_instance;

// Let's comp(u|e)te!
int main() {
    
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w) << endl;
    
}

Measured memory_bytes: 256
N, *A = [int(_) for _ in open(0).read().split()]
win_lose = {i: set() for i in range(1, N + 1)}
for win, lose in zip(A, range(2, N + 1)):
    win_lose[win].add(lose)
s1 = [1]
s2 = []
while s1:
    a = s1.pop()
    s2 += [a]
    for b in win_lose[a]:
        s1 += [b]
dp = [0] * (N + 1)
for x in s2[::-1]:
    if win_lose[x] == set():
        dp[x] = 0
    else:
        dp[x] = max(a + b for a, b in zip(
            sorted(dp[y] for y in win_lose[x])[::-1], range(1, N + 1)))
print(dp[1])


Measured memory_bytes: 52660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

const int INF = 1 << 30;
const long long LINF = 1ll << 62;

const int MAXN = 100005;
const int MAXM = 100005;

long long need[MAXN];

int A[MAXN], B[MAXN], pos[MAXN], rk[MAXN];

int n, m, u, v;

struct Edge
{
	int to, next;
}e[2 * MAXM];
int head[MAXN], te = 1;

inline void addE(int u, int v)
{
	e[++te] = (Edge){v, head[u]}, head[u] = te;
}

//dsu
long long sum[MAXN];
int fa[MAXN];

void init()
{
	for (int i = 1; i <= n; i++)
		fa[i] = i, sum[i] = B[i];
}

int find(int x)
{
	return (fa[x] == x ? x : fa[x] = find(fa[x]));
}

void Union(int x, int y)
{
	sum[x] += sum[y];
	fa[y] = x;
}

inline bool cmp(const int &x, const int &y)
{
	return A[x] - B[x] < A[y] - B[y];	
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> A[i] >> B[i];
	for (int i = 1; i <= m; i++)
	{
		cin >> u >> v;
		addE(u, v), addE(v, u);
	}
	for (int i = 1; i <= n; i++)
		pos[i] = i;
	sort(pos + 1, pos + n + 1, cmp);
	for (int i = 1; i <= n; i++)
		rk[pos[i]] = i;
	for (int i = 1; i <= n; i++)
		need[i] = LINF;
	init();
	for (int i = 1; i <= n; i++)
	{
		int u = pos[i], x = find(u);
		for (int j = head[u]; j != 0; j = e[j].next)
		{
			int v = e[j].to, y = find(v);
			if (x != y && rk[v] < rk[u])
			{
				need[x] = min(need[x], max(need[y], max(0ll, A[u] - B[u] - sum[y])));
				Union(x, y);
			}
		}
		need[x] = min(need[x], max(0ll, (long long)(A[u] - B[u])));
	}
	long long res = need[find(pos[n])] + sum[find(pos[n])];
	cout << res << endl;
	return 0;
}


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

const int MN = 100010;

int N;
vector<int> adj[MN];
int dp[MN];

void dfs(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        dfs(v, u);
        dp[u] ^= (dp[v] + 1);
    }
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(0, -1);

    if(dp[0]) printf("Alice");
    else printf("Bob");
}


Measured memory_bytes: 13952
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <numeric>
#include <functional>
using namespace std;
using ll = long long int;
ll AtMod = 1000000000+7;
ll RS(ll N, ll P, ll M);

int main(void){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans;
  ans = RS(2,n,AtMod);
  
  //nCaの値を求める
  ll a_comb = 1; ll bunbo = 1; ll bunshi = 1;
  a = min(a,n-a);
  for (ll i = 0; i < a; i++){
	bunshi = bunshi * (n-i) % AtMod;
    bunbo = bunbo * (i+1) % AtMod;
  }
  a_comb = bunshi * RS(bunbo,AtMod-2,AtMod) % AtMod;

  ll b_comb = 1; bunbo = 1; bunshi = 1;
  b = min(b,n-b);
  for (ll i = 0; i < b; i++){
	bunshi = bunshi * (n-i) % AtMod;
    bunbo = bunbo * (i+1) % AtMod;
  }
  b_comb = bunshi * RS(bunbo,AtMod-2,AtMod) % AtMod;
  ans -= (a_comb + b_comb)%AtMod;
  if (ans < 0) ans += AtMod;
  cout << ans-1 << endl;
  return 0;
}

ll RS(ll N, ll P, ll M){
  if (P==0) return 1;
  else if (P%2==0){
    ll sq = RS(N,P/2,M);
    return sq*sq%M;
  }
  else{
    return N*RS(N,P-1,M)%M;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    map<string,ll> m;
ll t;
cin>>t;
while(t--){
string s;
cin>>s;
sort(s.begin(),s.end());
m[s]++;
}
ll ans = 0;
for(auto it = m.begin();it != m.end();it++){
    if(it->second>1){
        ans += ((it->second*(it->second - 1))/2);
    }
}
cout<<ans<<"\n";
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int a[110];

int main() {

    int N;
    cin >> N;
    rep(i, N)cin >> a[i];

    ll ans = 2000000000000000;
    for (int i = -100; i <= 100; i++) {
        ll sum = 0;
        rep(j, N) {
            sum += pow((a[j] - i), 2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m,k; cin>>n>>m>>k;
	int64_t sum=0;
	vector<int>a(1,0),b(m+1); b.front()=0;
	for(int i=0;i<n;++i){
		int A; cin>>A;
		if(sum<k){
			a.emplace_back(A);
			sum+=A;
		}
	}
	if(sum>k){
		sum-=a.back();
		a.pop_back();
	}
	for(auto i=b.begin()+1;i!=b.end();++i)cin>>*i;
	int ans=0;
	for(int i=a.size()-1,j=0;i>=0;--i){
		while(j<=m&&sum+b.at(j)<=k)sum+=b.at(j),++j;
		ans=max(ans,i+j-1);
		sum-=a.at(i);
	}
	cout<<ans<<"\n"s;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct mint {
    long long x;
    mint(long long 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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long 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 {
        mint res(*this);
        return res/=a;
    }
};
 
signed main()
{   
    gearup;
    ll n; cin >> n;
    deque<int> deq;
    rep(i,n){
        int num; cin >> num;
        int idx = lower_bound(all(deq),num) - deq.begin();
        if(idx == 0)deq.push_front(num);
        else deq[idx - 1] = num; //上書き
    }
    int res = deq.size();
    out(res);
}


Measured memory_bytes: 3992
import sys

cnt = {}

for line in sys.stdin:
  for l in line:
    if l.isalpha():
      c = l.lower()
      cnt[c] = cnt.get(c,0)+1

for i in range(26):
  c = chr(ord('a')+i)
  print( c, " : ", cnt.get(c,0), sep = '' )


Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i = a; i <= b; i++)
    {
        if(i%c == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define endl "\n"
#define ff first
#define ss second

void solve()
{
	int A, B;
	cin >> A >> B;

	if (B < 2*A)
	{
		cout << "No";
		return;
	}
	int d1 = (4 * A - B);
	if (d1 >= 0 and d1 % 2 == 0)
		cout << "Yes";
	else cout << "No";
}


signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(ll x=0;x<n;x++){
        cin>>a[x]>>b[x]>>c[x];
    }
    ll dp1[n],dp2[n],dp3[n];
    dp1[0]=a[0];
    dp2[0]=b[0];
    dp3[0]=c[0];
    for(ll x=1;x<n;x++){
        dp1[x]=a[x]+max(dp2[x-1],dp3[x-1]);
        dp2[x]=b[x]+max(dp1[x-1],dp3[x-1]);
        dp3[x]=c[x]+max(dp1[x-1],dp2[x-1]);
    }
    cout<<max({dp1[n-1],dp2[n-1],dp3[n-1]})<<endl;
    return 0;
}

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

int main(){
  string A="CODEFESTIVAL2016";
  string B;
  cin>>B;
  int ans=0;
  for(int i=0;i<A.length();i++){
    if(A.at(i)!=B.at(i))ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  double a, b, x, y;
  cin >> a >> b >> x;

  if (2*x<a*a*b) 
    y = atan(a*b*b/(2*x))*180/M_PI;
  else 
    y = atan(2*(a*a*b-x)/(a*a*a))*180/M_PI;
  std::cout << std::fixed;
  cout << y << endl;
  return 0;    
}



Measured memory_bytes: 256
def solve()
  n = gets.to_i
  v = gets.split.map!(&:to_f)
  v = v.sort
  memo = (v[0] + v[1]) / 2
  (2..n-1).each do |i|
    memo = (memo + v[i]) / 2
  end
  print memo
end
solve()

Measured memory_bytes: 1916
#include <iostream>
using namespace std;
int N, A, B;
long long K;
const int MOD = 998244353;
int Fact[300005], Inv[300005];
int ans;
int power(int n, int p)
{
    int sol = 1;
    while(p)
    {
        if(p % 2 == 1)
        {
            sol = (1LL * sol * n) % MOD;
        }
        p /= 2;
        n = (1LL * n * n) % MOD;
    }
    return sol;
}

void precalcFact()
{
    Fact[0] = 1;
    for(int i = 1; i <= N; i++)
        Fact[i] = (1LL * Fact[i - 1] * i) % MOD;
    Inv[N] = power(Fact[N], MOD - 2);
    for(int i = N - 1; i >= 0; i--)
    {
        Inv[i] = (1LL * Inv[i + 1] * (i + 1)) % MOD;
    }
}

int Comb(int n, int k)
{
    return (((1LL * Fact[n] * Inv[n - k]) % MOD) * Inv[k]) % MOD;
}
void Read()
{
    cin >> N >> A >> B >> K;

}
int main()
{
    Read();
    precalcFact();
     for(int i = 0; i <= N; i++)
    {
        long long sum = (1LL * i * A);
        long long rem = K - sum;
        if(rem < 0 || rem % B != 0 || rem / B > N)
            continue;
        ans += (1LL * Comb(N, i) * Comb(N, rem / B)) % MOD;
        if(ans >= MOD)
            ans -= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;


int main() {
    // your code goes here
    ll a,b,n,g;
    cin >> a >> b >> n;
    if(n>=b){
        cout << (a*(b-1))/b << endl;
    } else {
        cout << (a*n)/b << endl;
    }
    return 0;
}

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


int main() {
    int N;
    std::cin >> N;
    std::vector<int> sub(N, 0);

    for (int i = 1; i < N; i++) {
        int a;
        std::cin >> a;
        sub[a - 1]++;
    }

    for (int i = 0; i < N; i++) {
        std::cout << sub[i] << std::endl;
    }
}


Measured memory_bytes: 3708
a,b = map(int,input().split())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

gc = gcd(a,b)
#print(gc)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ko = factorization(gc)
if gc == 1:
    print(len(ko))
else:
    print(len(ko)+1)

Measured memory_bytes: 38512
#include <iostream>

int main(){
  int a;
  int b;
  int c;
  std::cin >> a;
  std::cin >> b;
  std::cin >> c;
  if(a < b && b < c){
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}



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

int main() {

  vector<int> S(2);
  cin >> S.at(0);
  S.at(1) = S.at(0)%100;
  S.at(0) /= 100;
  
  if(0<S.at(0) && S.at(0)<13){
    if(0<S.at(1)&& S.at(1)<13){ 
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" <<endl;
    }
    
  }else{
    if(0<S.at(1)&&S.at(1)<13){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
 
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N;
	int i, j, k;
	int n[100];
	int v;
	
	cin >> N;
	
	for (i = 0; i < N; i++){
		cin >> n[i];
	}
	
	for (i = 1; i < N; i++){
		for (k = 0; k < N; k++){
			cout << n[k];
			if (k == N - 1){
				cout << "\n";
			}
			else {
				cout << " ";
			}
		}
		v = n[i];
		j = i - 1;
		while (j >= 0 && n[j] > v){
			n[j+1] = n[j];
			j--;
		}
		n[j+1] = v;
	}
	
	for (i = 0; i < N; i++){
		cout << n[i];
		if (i == N - 1){
			cout << "\n";
		}
		else {
			cout << " ";
		}
	}
	
	return (0);
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {

    ll N,W; cin >> N >> W;
    vector<ll> w(N),v(N);
    for(ll i=0; i<N; i++) cin >> v[i] >> w[i];

    vector<vector<ll>> dp(N+1,vector<ll>(N*100+1,INT_MAX));
    dp[0][0] = 0;
    for(ll i=0; i<N; i++) {
	for(ll j=0; j<N*100; j++) {
	    dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
	    if( dp[i][j] + w[i] <= W)
		dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
	}
    }
    for(ll i=N*100; i>=0; i--) {
	if(dp[N][i] != INT_MAX) {
	    cout << i << endl;
//	    cout << dp[N][i] << endl;
	    return 0;
	}
    }
	    
}

Measured memory_bytes: 10796
#include<map>
#include<cstdio>
#include<algorithm>

using namespace std;

int n, q;
int c[500005];
int lo[500005];
int lor[500005];
int bit[500005];
map<int, int> m;

struct query {
    int l, r, i;
    int ans;
} qy[500005];

void update(int x) {
    for (int i = x; i <= n; i += (i & (-i))) {
        bit[i]++;
    }
}

int count(int x) {
    int res = 0;
    for (int i = x; i; i -= (i & (-i))) {
        res += bit[i];
    }
    return res;
}

int count(int l, int r) {
    return count(r) - count(l - 1);
}

int main() {
    scanf("%d %d", &n, &q);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &c[i]);
        lo[i] = m[c[i]];
        lor[i] = i;
        m[c[i]] = i;
    }
    sort(lor + 1, lor + n + 1, [] (int x, int y) {
        return lo[x] < lo[y];
    });
    for (int i = 0; i < q; i++) {
        qy[i].i = i;
        scanf("%d %d", &qy[i].l, &qy[i].r);
    }
    sort(qy, qy + q, [] (query x, query y) {
        return x.l < y.l;
    });
    for (int i = 0, j = 0; i < q; i++) {
        while (j < n && lo[lor[j+1]] < qy[i].l) {
            update(lor[++j]);
        }
        qy[i].ans = count(qy[i].l, qy[i].r);
    }
    sort(qy, qy + q, [] (query x, query y) {
        return x.i < y.i;
    });
    for (int i = 0; i < q; i++) {
        printf("%d\n", qy[i].ans);
    }
}

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


/* Driver program to test above functions */
int32_t main()
{

    int h, n;
    cin>>h>>n;
    int arr[n];
    int sum = 0;
    for(int i = 0; i<n; i++){
        cin>>arr[i];
        sum += arr[i];
    }
    if(sum >= h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var X = int.Parse(ss[0]);
            var A = int.Parse(ss[1]);

            Console.WriteLine(X < A ? 0 : 10);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main()
{
	int  a = 100000;
	int b;
	cin >> b;
	int x;
	for (int i = 0; i < b; i++)
	{
		a = a*1.05;
		x = a % 1000;
		if (x>0)
		{
			a = a + 1000 - x;
		}
	}
	cout << a << endl;


	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
inline constexpr int IntInf = 2000000000;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

struct key {
    int a;
    int p=0;
};

int main() {
    fastio;
    ll N,M;
    cin >> N >> M;
    vector<key> keys(M);
    rep(i,M) {
        key& k = keys[i];
        int b;
        cin >> k.a >> b;
        rep(j,b) {
            int c;
            cin >> c;
            --c;
            k.p |= 1 << c;
        }
    }
    vector<vector<int>> dp(1005, vector<int>(1<<N, IntInf));
    dp[0][0] = 0;
    rep(i,M) {
        rep(j,1<<N) {
            updmin(dp[i+1][j], dp[i][j]);
            updmin(dp[i+1][j | keys[i].p], dp[i][j] + keys[i].a);
        }
    }
    int ans=IntInf;
    rep1(i,M) {
        updmin(ans, dp[i][(1<<N)-1]);
    }
    if (ans == IntInf)
        ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 19272
_[9],s,i,k;main(n){for(;~scanf("%d",_+i);){s|=1<<(_[i++]-1);if(i%5==0){for(;i--;)printf("%d\n",k?k-_[4-i]?2:1:3,k=s%5?s%3?0:s%2?1:2:3);s=i=0;}}}

Measured memory_bytes: 0
n, d = gets.strip.split.map(&:to_i)
x = Array.new(n, Array.new(d, 0) )

for i in 0...n
  x[i]=gets.strip.split.map(&:to_i)
end

res=0
for i in 0...n
  for j in i+1...n
    sum2=0
    for k in 0...d
      sum2+=(x[i][k]-x[j][k])**2
    end
    len=Math.sqrt(sum2)
    if(len==len.floor)
      res+=1
    end
  end
end

puts res


Measured memory_bytes: 1788
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::*;
use std::string::*;
use std::f64::consts::PI;

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }

    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }

    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let s: String = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();

        return s.parse::<T>().ok().unwrap();
    }

    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn prime_factorization(n: i64) -> HashMap<i64, i64> {
    let mut n = n;
    let mut res = HashMap::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            let count = res.entry(i).or_insert(0);
            *count += 1;
        }
        i += 1;
    }

    if n > 1 {
        res.insert(n, 1);
    }

    return res;
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n = sc.read();
    let k = sc.read();
    let mut cnt = vec![0; n];
    for i in 0..k {
        let d = sc.read();
        let line: Vec<i64> = sc.vec(d);
        for j in 0..d {
            cnt[line[j] as usize - 1] += 1;
        }
    }

    println!("{}", cnt.iter().filter(|x| **x == 0).count());
}

Measured memory_bytes: 2172
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <set>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 5e18+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll n, k; cin >> n >> k;
  vector<int> p(n); rep (i, n) { cin >> p[i]; p[i]--; }
  vector<int> c(n); rep (i, n) cin >> c[i];



  vector<vector<int>> cycles(n, vector<int>());
  vector<ll> scores(n);
  for (int i = 0; i < n; i++) {
    vector<bool> seen(n+1);
    int curr = i;
    while (true) {
      if (seen[curr]) break;
      seen[curr] = true;
      cycles[i].push_back(curr);
      scores[i] += c[curr];
      curr = p[curr];
    }
  }


  ll ans = -inf;
  for (int i = 0; i < n; i++) {

    int next = p[i];

    ll curr_score = 0;
    int curr = next;
    for (int j = 0; j < cycles[next].size()*3 && j < k; j++) {
      curr_score += c[curr];
      curr = p[curr];
      ans = max(curr_score, ans);
    }

    curr_score = 0;

    if (k >= cycles[next].size()) {
      curr_score += (k / cycles[next].size() - 1) * scores[next];
      curr = next;
      for (int j = 0; j < cycles[next].size(); j++) {
        curr_score += c[curr];
        curr = p[curr];
        ans = max(ans, curr_score);
      }
    }

    curr_score = 0;

    curr_score += (k / cycles[next].size()) * scores[next];
    curr = next;
    if (k / cycles[next].size() != 0) ans = max(ans, curr_score);
    for (int j = 0; j < k % cycles[next].size(); j++) {
      curr_score += c[curr];
      curr = p[curr];
      ans = max(ans, curr_score);
    }
  }

  cout << ans << endl;

  return 0;
}

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

N = int(input())

ans = N
for i in range(N // 9 + 1):
    nine = i * 9
    six = N - nine
    tmp_ans = 0
    while nine > 0:
        tmp_ans += nine % 9
        nine = nine // 9
    while six > 0:
        tmp_ans += six % 6
        six = six // 6
    ans = min(tmp_ans, ans)

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
int L[1000][4], A[100];
int main(void)
{
    int i, j;
    int a, b, c;
    while (scanf("%d%d%d", &a, &b, &c), a) {
        int N, changed;
        scanf("%d", &N);
        for (i=0; i<a+b+c; ++i) A[i] = 2;
        for (i=0; i<N; ++i) {
            for (j=0; j<4; ++j) scanf("%d", &L[i][j]);
            if (L[i][3] == 1)
                for (j=0; j<3; ++j) A[L[i][j]-1] = 1;
        }

        changed = 1;
        while (changed) {
            changed = 0;
            for (i=0; i<N; ++i) {
                if (L[i][3] == 0) {
                    int fine = 0, ambiguous = 0, index;
                    for (j=0; j<3; ++j) {
                        int t = L[i][j] - 1;
                        if (A[t] == 2) { ambiguous++; index = t; }
                        else if (A[t] == 1) fine++;
                    }
                    if (fine == 2 && ambiguous == 1) {
                        A[index] = 0;
                        changed = 1;
                    }
                }
            }
        }
        for (i=0; i<a+b+c; ++i) printf("%d\n", A[i]);
    }
    return 0;
}

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1e9+7;
struct mint {
  typedef long long ll;
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  bool operator>(const mint a) const {
    mint res(*this);
    return res.x > a.x;
  }
  bool operator<(const mint a) const {
    mint res(*this);
    return res.x < a.x;
  }
  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 {
    mint res(*this);
    return res/=a;
  }
};

constexpr int premax = 200020; 
std::array<mint, premax> f, rf; 
bool mymodflag = false;
mint nCk (int n, int k) {
  if ( n == k ) return mint(1);
  if ( n < k  ) return mint(0);
  if ( !mymodflag ) {
    f[0] = 1; for(int i=1; i<premax; i++) f[i] = f[i-1]*i;
    rf[premax-1] = f[premax-1].pow(mod-2); for(int i=premax-2; i>=0; i--) rf[i] = rf[i+1]*(i+1);
    mymodflag = true;
  }
  return f[n]*rf[n-k]*rf[k];
}

mint nPk (int n, int k) {
  if ( n < k  ) return mint(0);
  if ( !mymodflag ) {
    f[0] = 1; for(int i=1; i<premax; i++) f[i] = f[i-1]*i;
    rf[premax-1] = f[premax-1].pow(mod-2); for(int i=premax-2; i>=0; i--) rf[i] = rf[i+1]*(i+1);
    mymodflag = true;
  }
  return f[n]*rf[n-k];
}


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  mint all = 1;
  rep(i,n) all *= 10;

  mint z = 1;
  rep(i,n) z *= 9;
  mint t = all - z;

  mint m = 1;
  rep(i,n) m *= 8;
  mint y = all - m;

  mint ans = t + t;
  ans -= y;
  std::cout << ans.x << std::endl;

  return 0;
}



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

int main()
{
	long long A, B, K;
	cin >> A >> B >> K;
	long long t, a;
	t = max(A - K, 0LL);
	a = max(B - max(K - A, 0LL), 0LL);
	cout << t << " " << a << '\n';
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

ll BallBoxCombination4(ll n,ll k){
	Combination comb(n+k-1);
	return comb.Caluclation(n+k-1,n);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N;
	while(cin>>N){
		N = min(N,4000-N);
		if(N<=1000){
			out(BallBoxCombination4(N,4));
		}
		else{
			auto lhs = BallBoxCombination4(N,4);
			auto rhs = 4*BallBoxCombination4(N-1001,4);
			if(lhs-rhs<0){
				lhs += atcoder_mod;
			}
			out(lhs-rhs);
		}
	}

	return 0;
}


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

using ll = long long;

int compress(vector<ll>& v, vector<ll>& vs) {
    sort(vs.begin(), vs.end());
    vs.erase(unique(vs.begin(), vs.end()), vs.end());
    for(int i=0; i<v.size(); ++i) {
        v[i] = lower_bound(vs.begin(), vs.end(), v[i]) - vs.begin();
    }
    return vs.size();
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> x(2*N), y(2*N), z(2*N), xs(2*N), ys(2*N), zs(2*N);
    for(int i=0; i<N; ++i) {
        ll x1, y1, z1, x2, y2, z2;
        cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
        x[2*i] = xs[2*i] = x1, x[2*i+1] = xs[2*i+1] = x2;
        y[2*i] = ys[2*i] = y1, y[2*i+1] = ys[2*i+1] = y2;
        z[2*i] = zs[2*i] = z1, z[2*i+1] = zs[2*i+1] = z2;
    }
    int xsize = compress(x, xs);
    int ysize = compress(y, ys);
    int zsize = compress(z, zs);
    vector<vector<vector<int>>> sum(xsize, vector<vector<int>>(ysize, vector<int>(zsize)));
    for(int i=0; i<N; ++i) {
        for(int j=x[2*i]; j<x[2*i+1]; ++j) {
            for(int k=y[2*i]; k<y[2*i+1]; ++k) {
                for(int l=z[2*i]; l<z[2*i+1]; ++l) {
                    ++sum[j][k][l];
                }
            }
        }
    }
    ll res = 0;
    for(int i=0; i<xsize-1; ++i) {
        for(int j=0; j<ysize-1; ++j) {
            for(int k=0; k<zsize-1; ++k) {
                if(sum[i][j][k] >= K) {
                    res += (xs[i+1] - xs[i]) * (ys[j+1] - ys[j]) * (zs[k+1] - zs[k]);
                }
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 7104
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N)]
CD = [tuple(map(int,input().split())) for i in range(M)]
for a,b in AB:
    best_i = -1
    best_d = 10**9
    for i,(c,d) in enumerate(CD):
        dist = abs(a-c) + abs(b-d)
        if dist < best_d:
            best_d = dist
            best_i = i
    print(best_i + 1)

Measured memory_bytes: 9020
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,a,sum=0,count=0;
  cin>>n>>m;
  vector<int>v;
  while(cin>>a)
  {
    v.push_back(a);
    sum+=a;
  }
  float c=(float)sum/(4*m);
  for(int i=0;i<v.size();i++)
  {
    if(v[i]>=c)
      count++;
  }
  if(count>=m)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}

Measured memory_bytes: 256
S=input()
l=len(S)-1
ans =0
for i in range(1 << l):
    s=S[0]
    for j in range(l):
        if (i >> j)&1:
            s+="+"
        else:
            s+="-"
        s+=S[j+1]
    if eval(s)==7:
        print(s+"=7")
        exit()
    

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

int main(void){
	int n,m;
	int ans=0;
	int na,ma;

	scanf("%d %d",&n,&m);
	na=n*(n-1)/2;
	ma=m*(m-1)/2;
	ans=na+ma;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		TreeSet<Integer> x = new TreeSet<>();
		for (int i = 1; i*i <= M; i++) {
			if (M % i == 0) {
				x.add(i);
				x.add(M / i);
			}
		}

		System.out.println(M/x.ceiling(N));

	}
}


Measured memory_bytes: 23764