akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0;
    string s;
    cin >> s ;
    if(s=="ABC") cout << "ARC" ;
    else cout << "ABC" ;
    
    return 0;
}

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

void b(vector<vector<int>> A,vector<int> B,int &l){
  int j=0;
  for(vector<int> i:A){
    if(B[i[1]]-B[i[0]]==i[2])
      j+=i[3];
  }
  l=max(j,l);
}

void a(vector<vector<int>> A,vector<int> B,int N,int j,int M,int i,int &l){
  if(j==0){
    b(A,B,l);
    return;
  }
  for(int k=i;k<=M;k++){
    B[N-j]=k;
    a(A,B,N,j-1,M,k,l);
  }
}

signed main(){
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<vector<int>> A(Q,vector<int>(4));
  for(vector<int> &i:A){
    int j1,j2,j3,j4;
    cin>>j1>>j2>>j3>>j4;
    i={j1-1,j2-1,j3,j4};
  }
  int i=0;
  vector<int> B(N);
  a(A,B,N,N,M,1,i);
  cout<<i<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
const int MAXN = 1 << 11;

int N, X, Y;
int res[MAXN];

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

	for ( int i=0; i < N; ++i )
		for ( int j=i + 1; j < N; ++j ){
			d = min( abs(i - X) + abs(j - Y) + 1, abs(i - Y) + abs(j - X) + 1 );
			d = min( d, j - i );
			res[d]++;
		}
	for ( int i=1; i < N; ++i )
		printf("%d\n", res[i]);
	return 0;
}


Measured memory_bytes: 128
def dfs(v, N, visited):
    all_visited = True

    for i in range(N):
        if visited[i] == False:
            all_visited = False

    if all_visited:
        return 1

    ret = 0
    for i in range(N):
        if graph[v][i] == False: continue
        if visited[i]: continue

        visited[i] = True
        ret += dfs(i, N, visited)
        visited[i] = False

    return ret


N, M = map(int, input().split())

graph = [[False for _ in range(8)] for _ in range(8)]


for i in range(M):
    a, b = map(int, input().split())
    graph[a-1][b-1] = True
    graph[b-1][a-1] = True

visited = [False for _ in range(N)]
visited[0] = True

print(dfs(0, N, visited))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(330)


void deal(){
	ll n, k;
	cin>>n>>k;
	vector<ll> arr(n);
	fori(n)
		cin>>arr[i];
	vector<ll> dp(k+1,0);
	for(ll i = 1; i<= k; i++)
		for(auto el: arr)
			if(i>=el)
				dp[i] |= !(dp[i-el]);
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

Measured memory_bytes: 1024
use std::collections::HashMap;
use whiteread::parse_line;

fn main() {
    let (_n, k): (usize, usize) = parse_line().unwrap();
    let a: Vec<usize> = parse_line().unwrap();
    let mut map: HashMap<usize, usize> = HashMap::new();

    for &ai in &a {
        map.entry(ai).and_modify(|x| *x += 1).or_insert(1);
    }
    let mut val: Vec<_> = map.values().collect();
    let len = val.len();
    if len > k {
        val.sort();
        println!("{}", val.iter().take(len - k).fold(0, |x, &y| x + y));
    } else {
        println!("0");
    }
}


Measured memory_bytes: 12124
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int h,a;
    cin >> h >> a;

    if(h%a == 0) cout << h/a << endl;
    else  cout << h/a + 1 << endl; 
    return 0;
}

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


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }
ll find_greater_equal(ll a[], ll N, ll x){ int q = lower_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }
ll find_greater(ll a[], ll N, ll x){ int q = upper_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }

ll N, T;
ll c[102], t[102];

int main(){
    ios::sync_with_stdio(0);
	cin >> N >> T;
	int res = -1;
	for (int i = 0; i < N; i++){
		cin >> c[i] >> t[i];
		if(t[i] <= T){
			if(res == -1){
				res = c[i];
			}
			else if(c[i] < res){
				res = c[i];
			}
		}
	}
	if(res == - 1){
		cout << "TLE"; return 0;
	}
	cout << res;
    return 0;
}





Measured memory_bytes: 256
def main():
    N = int(input())
    *A, = map(int, input().split())

    f(N, A)


def f(N, A):
    """
    2 ≤ N ≤ 10^5
    −5000 ≤ Ai ≤ 5000 (1≤ i≤ N)

    第一印象: 累積和?
    →不要,合計のみ必要だった
    """
    costs = [abs(A[0])]
    for i in range(1, N):
        cost = abs(A[i] - A[i-1])
        costs.append(cost)

    # 0へ戻る
    cost_N_to_start = abs(A[-1])
    costs.append(cost_N_to_start)
    costs_cumsum = sum(costs)

    for i in range(N):
        total = costs_cumsum
        # skip: i-1 to i and i to i+1
        total -= (costs[i] + costs[i+1])

        # add: i-1 to i+1
        bef, aft = 0, 0
        if i - 1 >= 0:
            bef = A[i-1]
        if i + 1 < N:
            aft = A[i+1]
        total += abs(bef - aft)

        print(total)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14164
#include <stdio.h>

int main(void){
    int hills[11];
    int i,j,temp;
    for(i=0;i<10;i++){
        scanf("%d",&hills[i]);
    }
    for(i=1;i<10;i++){
        temp = hills[i];
        j=i-1;
        while(j>=0 && hills[j]>temp){
            hills[j+1] = hills[j];
            j--;
        }
        hills[j+1] = temp;
    }
    for(i=9;i>6;i--) printf("%d\n",hills[i]);
    return(0);
}

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

#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)
#define maxn 100010

using namespace std;
const int oo = 1e9;

struct dta { int a, b, c; };

int n, A[maxn][3], F[maxn][3];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	FOR(i, 1, n)
	FOR(j, 0, 2)
        cin >> A[i][j];

    FOR(j, 0, 2) F[0][j] = 0;
    FOR(i, 1, n)
    FOR(j, 0, 2) {
        F[i][j] = 0;
        FOR(k, 0, 2)
            if (j != k) F[i][j] = max(F[i][j], F[i-1][k]);
        F[i][j] += A[i][j];
    }

    int res = 0;
    FOR(j, 0, 2) res = max(res, F[n][j]);
    cout << res;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
#define endl "\n"
const int N = 1e6 + 5;
#define ll long long
ll a[N];

int main()
{
	ios_base::sync_with_stdio (false);
    cin.tie (NULL);
     ll n,q,sum=0;
     map<ll,ll>m;
     cin>>n;
     for(int i=0;i<n;i++)
     {
     	cin>>a[i];
     	m[a[i]]++;
     	sum+=a[i];
     }	
     cin>>q;
     while(q--)
     {
        ll b,c;
        cin>>b>>c;
        ll noofbs=m[b];
        sum+=(c-b)*noofbs;
        m[b]=0;
        m[c]+=noofbs;
        cout<<sum<<endl;
     }

	return 0;
}

Measured memory_bytes: 10280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {
    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }

        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        }

        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 

    }

    public static void main(String[] args) {
        FastReader fs = new FastReader();
        
        int n = fs.nextInt();
        int k = fs.nextInt();
        int[] A = new int[n];
        
        for (int i = 0; i < n; i++) {
            A[i] = fs.nextInt();
        }
        
        Arrays.sort(A);

        boolean[] dp = new boolean[k+1];

        int i = 0;

        while (i < A[0]) {
            dp[i] = false;
            ++i;
        }


        // m gives one value of k;

        for (int m = i; m < dp.length; m++) {
            int j = 0;
            while (j < A.length && A[j] <= m) {
                if (!dp[m-A[j]]) {
                    dp[m] = true;
                    break;
                }
                ++j;
            }
        }

        if (dp[dp.length-1]) System.out.println("First");
        else System.out.println("Second");

    }

}

Measured memory_bytes: 33812
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;



int main()
{
	int value;
	int c500, c5;

	cin >> value;
	c500 = value / 500;
	c5 = (value % 500) / 5;

	printf("%d", c500 * 1000 + c5 * 5);
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Maxn 500007
int n,val[Maxn];
char ch[Maxn];
long long sum=0LL;
int calc(int x)
{
    if (val[x]!=-1) return val[x];
    int &v=val[x];
    if (x==1)
    {
        if (ch[1]=='<') v=0; else v=calc(x+1)+1;
    } else if (x==n)
    {
        if (ch[n-1]=='>') v=0; else v=calc(x-1)+1;
    } else if (ch[x-1]=='>'&&ch[x]=='>') v=calc(x+1)+1;
    else if (ch[x-1]=='<'&&ch[x]=='<') v=calc(x-1)+1;
    else if (ch[x-1]=='<'&&ch[x]=='>') v=max(calc(x-1),calc(x+1))+1;
    else v=0;
    return v;
}
int main()
{
    scanf("%s",ch+1);
    n=strlen(ch+1)+1;
    memset(val,-1,sizeof(val));
    for (int i=1;i<=n;i++)
        sum+=calc(i);
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 18304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



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

  int t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    string s;
    cin >> s;

    vector<ll> b(61, 0);
    bool f = false;
    repr(i, n - 1) {
      if (s[i] == '0') {
        repr(j, 60) {
          if ((1LL << j) & a[i]) {
            if (b[j] == 0) {
              b[j] = a[i];
              break;
            }
            else a[i] ^= b[j];
          }
        }
      }
      else {
        repr(j, 60) {
          if ((1LL << j) & a[i]) {
            a[i] ^= b[j];
          }
        }
        if (a[i] != 0) {
          f = true;
          break;
        }
      }
    }
    cout << f << '\n';
  }

  




  
  return 0;
}

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

    string a;
    cin >> a;
    if(a[0] =='7'||a[1]=='7'||a[2]=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 200010;
const ll MOD = TEN(9) + 7;

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

	int n = N * 2;

	char la = 'W';

	ll ans = 1;
	int ltp = -1;

	int lr = 0;

	rep(i, n) {
		bool f = (s[i] != la);

		if (i == 0) {
			if (!f) {
				ans = 0;
				break;
			}
			lr = 1;
			ltp = f;
		} else {
			int nx = ltp ^ (!f);
			if (nx == 1) {
				++lr;
			} else {
				if (lr == 0) {
					ans = 0;
				}
				ans = ans * lr % MOD;
				--lr;
			}
			ltp = nx;
		}

		la = s[i];
	}

	if (lr != 0) {
		ans = 0;
	}

	for (int i = 1; i <= N; ++i) {
		ans = ans * i % MOD;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int r,a=10000000,n,l;
int main()
{
	cin>>n>>l;
	for (int i=1;i<=n;i++)
	  r+=l+i-1;
	for (int i=1;i<=n;i++)
	  if (abs(l+i-1)<abs(a)) a=l+i-1;
	cout<<r-a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define per(i,a,b) for(int i = (a);i >= (b);i--)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int a[10];
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	rep(i,0,4) cin >> a[i];
	rep(i,0,4){
		if(!a[i]) cout << (i + 1) << endl;
	}
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(c >= a && c <= b){
            System.out.println("Yes");
            
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
using System;
// using System.Collections.Generic;
// using System.Linq;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        String S, T;
        S = arr[0];
        T = arr[1];
        Console.WriteLine(T.ToString() + S.ToString());
        return;
    }
}

Measured memory_bytes: 25768
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;
 
 ll mod=998244353;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    // Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
      ll a,b;
      cin>>a>>b;
      cout<<a*b;
    }
    return 0;
   }

Measured memory_bytes: 14128
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int digit(unsigned long long int n)
{
  int result;

  result = 0;
  while (n > 0)
  {
    n = n / 10;
    result += 1;
  }
  return (result);
}

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 数入力 */
  ull    answer;
  ull    n;
  ull    *a;

  scan = scanf("%llu", &n);
  a = (ull *)malloc(sizeof(ull) * n);
  for (ull i = 0; i < n; i++) {
    scan = scanf("%llu", &a[i]);
  }  
 
  /* プログラムを書く */
  answer = 1;
  for (ull k = 0; k < n; k++) {
    if (a[k] == 0) {
      printf("0");
      return (0);
    }
  }
  for (ull k = 0; k < n; k++) {
    if (a[k] >= (ull)pow(10, 18)) {
      printf("-1");
      return (0);
    } else {
      int dig = digit(a[k]);
      int ansdig = digit(answer);
      if (dig + ansdig >= 20 && answer * a[k] != 1000000000000000000) {
        printf("-1");
        return (0);
      }
      answer = answer * a[k];
      if (answer > (ull)pow(10, 18)) {
        printf("-1");
        return (0);
      }
    }
  }

  printf("%llu", answer);
  return (0);
}


Measured memory_bytes: 2516
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int64_t x;
    cin>>x;
    int64_t a=0,b=0;
    for(int i=-700;i<=700;i++){
        for(int j=-700;j<=700;j++){
            if(pow(i,5)-pow(j,5)==x){
                a=i;
                b=j;
                break;
            }
        }
    }
    cout<<a<<" "<<b<<endl;
}



Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int a[10];
int main(){
	int k,m,n=100;
	int ans=0;
	scanf("%d%d%d%d%d",&a[1],&a[2],&a[3],&a[4],&a[5]);
	for(register int i=1;i<=5;i++){
		if(a[i]%10==0)m=10;
		else m=a[i]%10;
		//cout<<m<<" "<<n<<endl;
		n=min(m,n);
		ans+=(a[i]+9)/10*10;
	}
	printf("%d\n",ans+n-10);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <bitset>
using namespace std;

typedef long long ll;

#define sz(a)  int((a).size())
#define pb  push_back
#define rep(var,n)  for(int var=0;var<(n);++var)

#define M 1000000007LL
ll f(int k) {
  ll x = 1LL;
  for (int i=2; i<=k; ++i) {
    x = (x * i) % M;
  }
  return x;
}
int main(){
  int n,m; cin >> n>>m;
  if (abs(n-m) > 1) {
    cout<<0<<endl;
    return 0;
  }
  ll nf = f(n), mf = f(m), al = nf * mf % M;
  if (n==m) al = al*2 % M;
  cout << al << endl;
  return 0; 
}


Measured memory_bytes: 256
#include<stdio.h>

int binarySearch(int n, int A[],int key){
	int left = 0;
	int right = n;

	while(left<right){
		int mid = (left+right)/2;
		if(A[mid]==key){
			return 1;
		}else if(key<A[mid]){
			right = mid;
		}else{
			left = mid+1;
		}
	}
	return 0;
}

int main(void){
	int n,i,q;

	scanf("%d",&n);

	int S[n];

	for(i=0;i<n;i++){scanf("%d",&S[i]);}

	scanf("%d\n",&q);

	int T[q];

	for(i=0;i<q;i++){scanf("%d",&T[i]);}

	int k=0;
	for(i=0; i<q; i++){
		k += binarySearch(n,S,T[i]);
	}

	printf("%d\n",k);

	return 0;
}



Measured memory_bytes: 2296
#include <stdio.h>

int main(void){
  int i,n;
  int cnt=0;
  long int a;
  
  scanf("%d",&n);
  for(i = 0;i < n; ++i){
    scanf("%ld",&a);
    while(!(a % 2)){
      a /= 2;
      ++cnt;
    }
  }
  printf("%d\n",cnt);
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    while(1){
        int d,e;
        cin >> d >> e;
        if (d==0)break;
        double ans = 9999999;
        for(int i=0;i<d;i++){
            ans = min(ans,abs(pow(i*i+(d-i)*(d-i),0.5)-e));
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3476
import java.util.*;
public class Main {
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	String S = sc.next();
	int max = 0;
	int count = 0;
	String S_split[] = S.split("");
	for(int i = 0;i < S_split.length;i++){
		if(S_split[i].equals("I")){
			count += 1;
			max = Math.max(max,count);			
		}else if(S_split[i].equals("D")){
			count -= 1;			
			max = Math.max(max,count);
		}
	}
	System.out.println(max);
	}
}
	



Measured memory_bytes: 23764
def main():
    n = int(input())
    slis = list()
    ans = 0
    sdic = {}
    for _ in range(n):
        s = input()
        s = ''.join(sorted(s))
        #print(s)
        if s in sdic:
            tmp = sdic[s]
            ans += tmp
            sdic[s] += 1
        else:
            sdic[s] = 1
            #print(sdic)
    print(ans)

    


if __name__ == "__main__":
    main()


Measured memory_bytes: 98204
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let d = i::uv(n);
    let m = i::u();
    let t = i::uv(m);
    let mut d_set = HashMap::new();
    for d_i in d {
        *d_set.entry(d_i).or_insert(0) += 1;
    }
    let mut t_set = HashMap::new();
    for t_i in t {
        *t_set.entry(t_i).or_insert(0) += 1;
    }

    //dbg!(&t_set, &d_set);
    for t in t_set {
        //dbg!(&t);
        if !d_set.contains_key(&t.0) || d_set[&t.0] < t.1 {
            println!("{}", "NO");
            return;
        }
    }
    println!("{}", "YES");
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 21748
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}

  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) { return -par[root(x)]; }
};

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

  int N, M;
  cin >> N >> M;
  vector<int> X(M), Y(M), Z(M);
  rep(i, M) {
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--;
    Y[i]--;
  }
  UnionFind uf(N);
  rep(i, M) uf.merge(X[i], Y[i]);
  set<int> se;
  rep(i, N) se.insert(uf.root(i));
  cout << (int)se.size() << endl;

  return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
int main()
{
    int N,A,B;
    scanf("%d %d %d",&N,&A,&B);
    if(N*A<B)
    {
        printf("%d",N*A);
    }
     else if(N*A>B)
    {
        printf("%d",B);
    }
     else if(N*A==B)
    {
        printf("%d",B);
    }

}


Measured memory_bytes: 128
n=int(input())
word=[]

for i in range(n):
    a=int(input())
    l=[list(map(int, input().split())) for j in range(a)]
    word.append(l)

ans=0

for i in range(2**n):
    flag=0
    cnt=0
    for j in range(n):
        if((i>>j)&1)==1 and flag==0:
            for k in range(len(word[j])):
                if ((i>>word[j][k][0]-1)&1) != word[j][k][1]:
                    flag=1
                    break
    
    if flag==0:
        cnt=bin(i).count("1")
        ans=max(ans, cnt)

print(ans)

Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        if(sa(a,c) <= d || sa(a,b) <= d && sa(b,c) <= d) System.out.println("Yes");
        else System.out.println("No");
    }
    
    static int sa(int a, int c) {
        if(a <= c) {
            return c-a;
        }else {
            return a-c;
        }
    }
}

Measured memory_bytes: 23764
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N, S int
	fmt.Scan(&N)
	nstr := strconv.Itoa(N)
	for i := 0; i < len(nstr); i++ {
		digit, _ := strconv.Atoi(nstr[i : i+1])
		S += digit
	}

	if N%S == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")

	}

	return
}


Measured memory_bytes: 512
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda x:x[0])
m=0
c=0
for i,x in enumerate(AB):
    m += x[1]
    c += x[0]*x[1]
    if m >= M:
        c -= (m-M)*x[0]
        print(c)
        exit()

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

int main(){ 
  string s;
  cin >> s;
  int n = sz(s);
  map<char,int> mp;
  for (char i = 'a'; i <= 'z'; i++) mp[i] = 0;
  rep(i,n) {
    mp[s[i]]++;
  }
  for (auto e : mp) {
    if (e.second == 0) {
      cout << e.first << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
} 

Measured memory_bytes: 512
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();

    let keyence = "keyence";
    let mut count = 0;

    for (c1, c2) in s.chars().zip(keyence.chars()) {
        if c1 == c2 {
            count += 1;
        } else {
            break;
        }
    }
    for (c1, c2) in s.chars().rev().zip(keyence.chars().rev()) {
        if c1 == c2 {
            count += 1;
        } else {
            break;
        }
    }

    let ans = if count >= keyence.len() { "YES" } else { "NO" };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int[] c = new int[3];
			for (int i = 0; i < 3; i++)
				c[i] = sc.nextInt();
			int[] p = new int[7];
			for (int i = 0, j = 1; j <= 10; j++) {
				if (j == c[0] || j == c[1] || j == c[2])
					continue;
				p[i++] = j;
			}
			int t = 0;
			for (int i = 0; i < 7; i++) {
				for (int j = 0; j < 7; j++) {
					if (i == j)
						continue;
					int m = c[0] + c[1] + p[i];
					if (m < 21)
						t++;
				}
			}
			System.out.println(t >= 21 ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 12000
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var K = cin.ReadInt;

            int[] AList = new int[K];
            int[] BList = new int[K];

            for (int i = 0; i < K; i++){
                AList[i] = A + i;
                BList[i] = B - i;
            }

            IEnumerable<int> ansSet = AList.Union<int>(BList)
                                            .Where(i => A <= i)
                                            .Where(i => i <= B)
                                            .OrderBy(i => i);

            foreach(int i in ansSet){
                WriteLine(i);
            }

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13536
while True:
    n,k = map(int, input().split())
    if n == 0 and k == 0:
        break
    a = []
    for i in range(n):
        a.append(int(input()))
        count = 0
    for i in range(k):
        count += a[i]
        ans = count
    for i in range(k, n):
        count += a[i]
        count -= a[i - k]
        ans = max(ans, count)
    print(ans)


Measured memory_bytes: 9608
import org.omg.CORBA.INTERNAL;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static ArrayList<ArrayList<Integer>> nextNode = new ArrayList<>();
    static int cnt = 0;

    static void dfs(int recent, int depth, boolean[] visied){

        if(depth == nextNode.size()-1){
            cnt++;
            return;
        }

        for(Integer next: nextNode.get(recent)){
            visied[recent] = true;
            if(!visied[next]) dfs(next, depth+1, visied);
            visied[recent] = false;
        }
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] in = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int m = Integer.parseInt(in[1]);

        for(int i=0; i<n; i++) nextNode.add(new ArrayList<>());

        for(int i=0; i<m; i++){
            in = br.readLine().split(" ");
            int node1 = Integer.parseInt(in[0]) - 1;
            int node2 = Integer.parseInt(in[1]) - 1;
            nextNode.get(node1).add(node2);
            nextNode.get(node2).add(node1);
        }

        boolean[] visited = new boolean[n];
        Arrays.fill(visited, false);
        dfs(0, 0, visited);
        System.out.println(cnt);
    }
}

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

int main() {
    
    int N;
    cin >> N;
    
    vector<int> card(N);
    for (int i = 0; i < N; i++){
        cin >> card.at(i);
    }
    
    sort(card.begin(),card.end());
    reverse(card.begin(),card.end());
    
    int a, b;
    
    if (N % 2 == 0){
        a = N / 2;
    }
    else {
        a = ( N + 1 ) / 2;
    }
    b = N - a;
    
    int A = 0, B = 0;
    
    for (int j = 0; j < a; j++){
        A += card.at(2 * j);
    }
    
    for (int k = 0; k < b; k++){
        B += card.at(2 * k + 1);
    }
    
    cout << A - B << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        var S = Reader.String();
        Func<char, char, bool> OK = (a, b) =>
            S.Any(c => c == a) == S.Any(c => c == b);
        Console.WriteLine(OK('E', 'W') && OK('N', 'S') ? "Yes" : "No");
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 2776
def b164(a, b, c, d):

    t = c // b
    o = a // d
    if c%b != 0:
        t += 1
    if a%d != 0:
        o += 1

    return "No" if t > o else "Yes"

def main():
    a, b, c, d = map(int, input().split())
    print(b164(a, b, c, d))

if __name__ == '__main__':
    main()

Measured memory_bytes: 61672
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int solve_testcase() {
    int A, B, C; cin >> A >> B >> C;
    if(A == 0 and B == 0 and C == 0) return 1;

    int N; cin >> N;

    vector<int> cnt0(A+B+C), cntW(A+B+C);
    vector<int> ans(A+B+C, 2);

    vector<int> X(N), Y(N), Z(N), cnt(N, 3);
    for(int i=0; i<N; i++) {
        int t; cin >> X[i] >> Y[i] >> Z[i] >> t;
        X[i]--; Y[i]--; Z[i]--;

        if(t == 1) {
            ans[ X[i] ] = ans[ Y[i] ] = ans[ Z[i] ] = 1;
        }
    }

    for(int i=0; i<N; i++) {
        if(ans[ X[i] ] == 1) cnt[i]--;
        if(ans[ Y[i] ] == 1) cnt[i]--;
        if(ans[ Z[i] ] == 1) cnt[i]--;
    }

    while(true) {
        bool updated = false;
        for(int i=0; i<N; i++) {
            if(cnt[i] == 1) {
                if(ans[ X[i] ] == 2) ans[ X[i] ] = 0, cnt[i]--;
                if(ans[ Y[i] ] == 2) ans[ Y[i] ] = 0, cnt[i]--;
                if(ans[ Z[i] ] == 2) ans[ Z[i] ] = 0, cnt[i]--;
                updated = true;
            }
        }
        if(!updated) break;
    }

    for(int i=0; i<A+B+C; i++) cout << ans[i] << endl;
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;



int main(){
    int r,d,x;
    cin >> r >> d >> x;
    for (int i=0;i<10;i++){
        x=r*x-d;
        cout << x << endl;
    }
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;


void ABC151A()
{
	char c;
	cin >> c;
	cout << ++c << endl;
}

int main()
{
	ABC151A();
	return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }

    if(a.at(0) != 0){
        cout << -1 << endl;
        return 0;
    }
    REP(i, n - 1){
        if(a.at(i) < a.at(i + 1) && a.at(i + 1) - a.at(i) > 1){
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 0;
    REP(i, n){
        if(i == n - 1 || a.at(i) + 1 != a.at(i + 1)){
            ans += a.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>
#include<queue>
#include<iomanip>

using namespace std;

int main() {
	double pi = 3.141592;
	double a, b, x;
	cin >> a >> b >> x;
	double ans;
	double u = a * a * b - x;
	double v = a * a * a;
	if (a * b * a / 2 >= x) {
		double j = atan(a * b * b / (2 * x));
		ans = (j * 180) / pi;
		cout << ans << endl;
	}
	else {
		long double h = atan((2 * u) / v);
		ans = (h * 180) / pi;
		cout <<setprecision(8)<< ans << endl;
	}
}

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

using namespace std;

/*Assumption:a > b*/
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

/*c is gcd.*/
int lcm(int a, int b, int c) {
  return (a / c) * b;
}

int main() {
  int a, b, c;
  while(cin >> a >> b) {
    swap(a, b);
    c = gcd(a, b);
    cout << c << ' ' << lcm(a, b, c) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	B := make([]int, N)
	countingSort(A, B, int(1e+4))

	for i := 0; i < N; i++ {
		if i != 0 {
			fmt.Fprint(wtr, " ")
		}
		fmt.Fprint(wtr, B[i])
	}
	fmt.Fprintln(wtr)
	wtr.Flush()
}

func countingSort(A, B []int, k int) {
	C := make([]int, k+1)
	for i := 0; i < len(A); i++ {
		C[A[i]]++
	}
	for i := 1; i <= k; i++ {
		C[i] = C[i] + C[i-1]
	}

	for i := len(A) - 1; i >= 0; i-- {
		B[C[A[i]]-1] = A[i]
		C[A[i]]--
	}
}



Measured memory_bytes: 43780