akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;
void dfs(std::vector<std::vector<int>> &g,std::vector<int>& ans,int p){
    erep(i,g[p]){
        if(ans[i]==0){
            ans[i]=p+1;
            dfs(g,ans,i);
        }
    }
}

int main(){
    int n,m;
    std::cin >> n>>m;
    std::vector<std::vector<int> > g(n);
    rep(i,m){
        itn a,b;
        std::cin >> a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    std::vector<int> ans(n,-1);
    ans[0]=0;
    std::queue<int> q;
    q.push(0);
    while(!q.empty()){
        int p=q.front();
   //     std::cout << p << std::endl;
        erep(i,g[p]){
            if(ans[i]==-1)
            {ans[i]=p+1;
            q.push(i);}
        }
        q.pop();
    }
    std::cout << Yes << std::endl;
    rrep(i,1,n){
        std::cout << ans[i] << std::endl;
    }
}


Measured memory_bytes: 10176
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
 
int main()
{
    int N;
    cin >> N;
    double sum = 0;
    double x;
    string u;
    for(int i = 0;i < N;i++)
    {
        cin >> x >> u;
        if(u == "JPY")
            sum += x;
        else
            sum += (x * 380000);
    }
    cout << sum << '\n';
}

Measured memory_bytes: 764
A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        if A % 2 != 0:
            A -= 1
        A //= 2
        B += A
    else:
        if B % 2 != 0:
            B -= 1
        B //= 2
        A += B

print("{0} {1}".format(A, B))

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		
		for(int i = 0 ; i < m ;i++) {
			int p = Integer.parseInt(sc.next())-1;
			int q = Integer.parseInt(sc.next())-1;
			a[p]++;
			a[q]++;
		}
		
		for(int i = 0 ; i < n ;i++) {
			if(a[i] % 2 == 1) {
				System.out.println("NO");
				return;
			}
		}
		
		System.out.println("YES");

	}

}


Measured memory_bytes: 59804
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#else
#define gc() 1
#define max3(a,b,c) max(a,b,c)
#define min3(a,b,c) min(a,b,c)
#endif

typedef long long lint;

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

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



#define MAXIN 100

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

	lint a, b, c; cin >> a >> b >> c;
	Yes(a + b >= c);

	gc();
}


Measured memory_bytes: 256
#include <iostream>
    #include <fstream>
    #include <cstdio>
    #include <cmath>
    #include <vector>
    #include <cstring>
    #include <string>
    #include <set>
    #include <map>
    #include <stack>
    #include <queue>
    #include <algorithm>
    using namespace std;
     
    #define REP(i,n) for(int i=0; i<n; ++i)
    #define FOR(i,a,b) for(int i=a; i<=b; ++i)
    #define FORR(i,a,b) for (int i=a; i>=b; --i)
    #define pi acos(-1.0)
     
    typedef long long ll;
    typedef vector<int> VI;
    typedef vector<ll> VL;
    typedef vector<VI> VVI;
    typedef pair<int,int> P;
    typedef pair<ll,ll> PL;
     
     
     
    int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        ll x, y;
        cin >> x >> y;
        cout << (abs(x - y) <= 1 ? "Brown" : "Alice" ) << "\n";
        return 0;
    }

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

import numpy as np

Nwin = np.zeros(N)

#print(Nwin)

A = []

for q in range(Q):
  a = int(input())
  #A.append(a)
  Nwin[a-1] += 1

#print(Nwin)

for n in range(N):
  if (K-Q+Nwin[n]>0):
    #print(n)
    print('Yes')
  else:
    ##print(n)
    print('No')

Measured memory_bytes: 22948
#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::{max,min};
use std::collections::{HashSet,HashMap};

#[fastout]
fn main() {
    input!{
        a:i64,
        b:i64,
        c:i64,
        k:i64,
    }

    let ans;
    if a >= k{
        ans = k;
    }else if a+b >= k{
        ans = a;
    }else{
        ans = a - (k - a - b);
    }
    println!("{}",ans);
}

Measured memory_bytes: 2204
n=parse(Int,readline())
k=Int(floor(log10(n))+1)
s=0
if n==1
  print(n)
else
  for i=1:k-1
    if i%2==1
      s +=9*(10)^(i-1)
    end
  end
  if k%2==0
    print(s)
  else
    s+=n-10^(k-1)+1
    print(s)
  end
end

Measured memory_bytes: 167080
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int a[N];
	f(i, N)a[i] = 0;
	int n, k;
	int x, y, z;
	int ans;
	ans = 1000000000;
	scanf("%d %d", &n, &k);
	f(i, n){
		scanf("%d", &a[i]);
	}

	f(i, n-k+1){
		x = a[i];
		y = a[i + k - 1];
		if (x < 0 && y < 0)z = -x;
		else if (x < 0){
			x = -x;
			z = min(x, y);
			z += (x + y);
		}
		else z = y;
		if (z < ans)ans = z;
	}

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


	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
using namespace std;
int main() {
  int N;
  string A,B,C;
  cin >>N>>A>>B>>C;
  int x=0;
  for (int i=0;i<N;i++){
    if(A[i]==B[i]&&B[i]==C[i])continue;
    if(A[i]==B[i]||B[i]==C[i]||C[i]==A[i])x++;
    else x+=2;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,M;
    cin>>N>>M;
    
    cout<<((1900*M)+(100*(N-M)))*pow(2,M);
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <string>
using namespace std;

struct PN {
	string s;

	bool operator < (const PN & rhs) const{
		return s.size() < rhs.s.size() || (s.size() == rhs.s.size() && s < rhs.s);
	}
};

int main()
{	
	int n;
	map<PN, int> p;

	cin >> n;

	for (int i = 0; i < n; i++) {
		string s1;
		int t;

		cin >> s1 >> t;

		PN p1{s1};

		if (p.find(p1) != p.end())
			p[p1] += t;
		else
			p[p1] = t;
	}

	for (map<PN, int>::iterator itr = p.begin(); itr != p.end(); itr++)
		cout << itr->first.s << " " << itr->second << endl;
	
	return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define SZ(a) (int)(a).size()
typedef long long ll;

int main() {
	cin.sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	auto sum = 0ll;
	for (auto i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
		a[i] = x;
	}
	auto n2 = (ll)n*(n+1)/2;
	if (sum%n2 != 0) {
		puts("NO");
		return 0;
	}
	auto m = sum/n2;
	auto k = 0ll;
	for (auto i = 0; i < n; i++) {
		auto x = a[i]+m-a[(i+1)%n];
		if (x < 0 || x%n != 0) {
			puts("NO");
			return 0;
		}
		auto y = x/n;
		k += y;
	}
	if (k != m) {
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin >> s >> t;
	int ans = 2e9;
	for (int i=0; i<=(int)s.size()-(int)t.size(); i++) {
		int c = 0;
		for (int j=0; j<(int)t.size();j++) {
			c += t[j] != s[i+j];
		}
		ans = min(ans,c);
	}
	cout << ans << '\n';
	
	return 0;
}




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

long long gcd(long long a, long long b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

long long w[400010];

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

    constexpr int mod = 1000000007;
    w[0] = 1;
    for (int i = 0; i < 400000; i++) {
        w[i+1] = w[i] * 2 % mod;
    }

    int N; cin >> N;
    long long Z = 0, AZ = 0, BZ = 0;
    map<pair<long long, long long>, long long> Mp, Mm;
    for (int i = 0; i < N; i++) {
        long long a, b; cin >> a >> b;
        if (a < 0) a *= -1, b *= -1;
        if (a == 0 || b == 0) {
            if (a == 0) AZ++;
            if (b == 0) BZ++;
            if (a == 0 && b == 0) Z++;
            continue;
        }
        long long g = gcd(a, abs(b));
        a /= g, b /= g;
        if (b > 0) Mp[{a, b}]++;
        else Mm[{-b, a}]++;
    }

    long long nz = 1;
    for (auto &[p, c]: Mp) {
        auto d = Mm[p];
        nz *= (w[c] + w[d] - 1) % mod;
        nz %= mod;
    }
    
    for (auto &[p, c]: Mm) {
        if (Mp.count(p)) continue;
        nz *= w[c];
        nz %= mod;
    }

    long long ans = (nz - 1 + mod) % mod;
    ans += nz * (w[AZ - Z] - 1) % mod;
    ans += nz * (w[BZ - Z] - 1) % mod;
    ans += Z;

    cout << (ans + mod) % mod << "\n";

    return 0;
}

Measured memory_bytes: 25512
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

const int MAX_N = 100;

long long weight[MAX_N];
long long value[MAX_N];
map< int, map<long long, long long> > dp;

long long knapsack(int up_bound, long long weight_limit) {
        if (dp.find(up_bound)!=dp.end() && dp[up_bound].find(weight_limit)!=dp[up_bound].end()) {
                return dp[up_bound][weight_limit];
        }
        if (up_bound==0 || weight_limit==0) {
                dp[up_bound][weight_limit] = 0;
        } else if (weight_limit-weight[up_bound]<0) {
                dp[up_bound][weight_limit] = knapsack(up_bound-1, weight_limit);
        } else {
                dp[up_bound][weight_limit] = max(knapsack(up_bound-1, weight_limit),
                knapsack(up_bound-1, weight_limit-weight[up_bound])+
                value[up_bound]);
        }
        return dp[up_bound][weight_limit];
}

int main() {
        int item_num;
        long long total_weight;
        cin >> item_num >> total_weight;

        for (int i=1; i<=item_num; ++i) {
                cin >> weight[i] >> value[i];
        }

        cout << knapsack(item_num, total_weight) << endl;

        return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
	long long n, count = 1, ans = 0;
	cin >> n;

	vector<long long> a(n);

	for (long long i = 0; i < n; i++)
		cin >> a[i];
	
	for (long long i = 0; i < n; i++)
	{
		if (a[i] == count)
			count++;
		else
			ans++;
	}

	if (ans == n)
		ans = -1;

	cout << ans << std::endl;
}

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

int main() {
	
	int S;
	cin >>S;
	
	int L=S/100;
	int R=S%100;
	
	if(1<=L&&L<=12){
		
		if(1<=R&&R<=12){
			
			cout <<"AMBIGUOUS" <<endl;
			
		}
		else{
			
			cout <<"MMYY" <<endl;
			
		}
		
	}
	else{
		
		if(1<=R&&R<=12){
			
			cout <<"YYMM" <<endl;
			
		}
		else{
			
			cout <<"NA" <<endl;
			
		}
		
	}
	
}

Measured memory_bytes: 256
n,m,p;
char s[2],c[101];
A(){
	for(p=0;c[p]!='#';p++);
}
B(){
	for(p=n-1;p>=0;p--)
		if(c[p]=='#'&&(p+1==n||c[p+1]!='A')&&(p-1<0||c[p-1]!='A'))
			return;
	A();
}
C(){
	for(p=0;p<n;p++){
		if(c[p]!='#'){
			if(p+1!=n&&c[p+1]=='#'){
				p++;
				return;
			}
			if(p-1>=0&&c[p-1]=='#'){
				p--;
				return;
			}
		}
	}
	p=n/2;
}
D(){
	int D[100],d=n*2,q;
	for(p=-1;++p<n;){
		d++;
		if(c[p]!='#')
			d=0;
		D[p]=d;
	}
	for(d=n;--p>=0;){
		d++;
		if(c[p]!='#')
			d=0;
		if(d<D[p])
			D[p]=d;
	}
	for(p=q=0;q<n;q++)
		if(D[q]>D[p])
			p=q;
}
main(){
	for(;scanf("%d%d",&n,&m),n;){
		memset(c,'#',100);
		c[n]=0;
		for(;m--;){
			scanf("%s",s);
			if(s[0]=='A')
				A();
			if(s[0]=='B')
				B();
			if(s[0]=='C')
				C();
			if(s[0]=='D')
				D();
			c[p]=s[0];
		}
		puts(c);
	}
	exit(0);
}

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

using namespace std;

long long a, b, k;

int main() {
	cin >> a >> b >> k;
	if(a <= k) {
		k -= a, a = 0;
	} else {
		a -= k, k = 0;
	}
	if(b <= k) b = 0;
	else b -= k;
	cout << a << ' ' << b << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    s= input()
    n = len(s)
    ans = 0
    for i in range(1<<(n-1)):
        idx = [0]
        for j in range(n-1):
            if (i>>j)&1:
                idx.append(j+1)
        idx.append(n)
        for j in range(1, len(idx)):
            ans += int(s[idx[j-1]:idx[j]])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9160
// ABC 064 D Insertion

using System;

class Program
{
    static int N;
    static string S;

    static void Main()
    {
        /* 入力の受け取り */
        N = int.Parse(Console.ReadLine());
        S = Console.ReadLine();

        /* '('で+1,')'とする */
        int c = 0;
        int c_min = 0;
        for (int i = 0; i < N; i++)
        {
            c += S[i] == '(' ? 1 : -1;
            c_min = Math.Min(c, c_min);
        }

        /* -c_min個だけ'('を先頭に、c - c_minだけ')'を末尾に */
        for (int i = 0; i < -c_min; i++)
            Console.Write('(');
        Console.Write(S);
        for (int i = 0; i < c - c_min; i++)
            Console.Write(')');
        Console.WriteLine();
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
vi to[101010];

signed main(){
  int n;
  cin>>n;
  int check=0;
  rep(i,n){
    int a;
    cin>>a;
    check^=a;
  }

  if(check==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 2560
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    flg = ["0"] * 40
    for i in range(40):
        cnt = 0
        for a in A:
            if (a >> i) & 1:
                cnt += 1
        if cnt % 2 != 0:
            flg[i] = "1"

    flg = int("".join(flg[::-1]), 2)
    res = [a ^ flg for a in A]
    print(*res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31272
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int n,m;
double a[20][3],d[20][20];
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)cin>>a[i][j];
		for(int j=0;j<i;j++){
			double cnt=0.0;
			for(int k=0;k<3;k++)cnt+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			d[i][j]=cnt,d[j][i]=cnt;
		}
	}
	bool b[20];for(int i=0;i<n;i++)b[i]=0;
	double ans=0.0;
	for(int i=0;i<(1<<n);i++){
		int cnt=0;
		for(int j=0;j<n;j++)if(b[j])cnt++;
		if(cnt==m){
			double ret=0.0;
			for(int j=0;j<n;j++){
				for(int k=0;k<j;k++){
					if(b[j]&&b[k])ret+=d[j][k];
				}
			}
			ans=max(ans,ret);
		}
		for(int j=0;j<n;j++){
			if(i%(1<<j)==(1<<j)-1)b[j]=1-b[j];
		}
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3248
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;

int loop;
int HIT,OUT,point;
string stait;
int main(){
  scanf("%d",&loop);
  for(int i=0;i<loop;i++){

int base1=0,base2=0,base3=0;
    point = 0;
    OUT=0;
      while(OUT<3){
	cin>>stait;

	if(stait.substr(0,3)=="HIT"){
	  if(base3==1){base3=0;point++;}
	  if(base2==1){base2=0;base3=1;}
	  if(base1==1){base1=0;base2=1;}
	  base1=1;
	}
	if(stait.substr(0,3)=="OUT"){OUT++;}
	if(stait.substr(0,3)=="HOM"){
	  if(base3==1){base3=0;point++;}
	  if(base2==1){base2=0;point++;}
	  if(base1==1){base1=0;point++;}
	  point++;
	}
      };
    printf("%d\n",point);
  }
}

Measured memory_bytes: 1252
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int X = sc.nextInt();
    	int N = sc.nextInt();
    	if(N==0) {
    		System.out.println(X);
    	} else {
    		int[] p = new int[102];
    		for(int i=1;i<=N;i++) {
    			int x = sc.nextInt();
    			p[x] = 1;
    		}
    		int d = 10000;
    		int ans = X;
    		for(int j=-1;j<=101;j++) {
    			if(j<=0||j>=101) {
    				int d2 = Math.abs(j-X);
    				if(d2<d) {
    					d = d2;
    					ans = j;
    				}
    			} else {
        			if(p[j]!=1) {
        				int d2 = Math.abs(j-X);
        				if(d2<d) {
        					d = d2;
        					ans = j;
        				}
        			}
    			}
    		}
    		System.out.println(ans);
    	}
    }
}

Measured memory_bytes: 27228
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  ll n;cin >> n;
  ll i = 1;
  do{
    ll x = i;
    if(x%3 == 0){
      cout << " " << i;
    }else{
      do{
        if(x%10 == 3){
          cout << " " << i;
          break;
        }
        x /= 10;
      }while(x);
    }
  }while(++i <= n);
  cout << endl;
}



Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <stack>

using namespace std;
const int INF = 1001001001;

void step1(vector< vector<int> >& edges, vector<int>& d, vector<int>& f, vector<int>& color, int node, int& time)
{
    // stackを使用
    stack<int> S;
    S.push(node);
    d[node] = ++time;
    color[node] = 1;
    while(!S.empty())
    {
        node = S.top();
        if(color[node] != 2){
            bool flag = true;
            for(int e : edges[node])
            {
                if(color[e] == 0)
                {
                    S.push(e);
                    d[e] = ++time;
                    color[e] = 1;
                    flag = false;
                    break;
                }
            }
            if(flag) color[node] = 2;
        }
        else
        {
            f[node] = ++time;
            S.pop();
        }
    }
}

void step2(vector< vector<int> >& edges, vector<int>& d, vector<int>& f, vector<int>& color, int node, int& time)
{
    d[node] = ++time;
    color[node] = 1;
    for(int e : edges[node])
        {
            if(color[e] == 0) step2(edges, d, f, color, e, time);
        }
    
    f[node] = ++time;
}

void dfs(vector< vector<int> >& edges, vector<int>& d, vector<int>& f, vector<int>& color, int n)
{
    int time=0;
    for(int i=0;i<n;++i)
    {
        if(color[i] == 0) step2(edges, d, f, color, i, time);
    }
}

int main()
{
    int n, u, k, e;
    cin >> n;
    vector< vector<int> > edges(n);
    vector<int> d(n), f(n), color(n);
    for(int i=0;i<n;++i)
    {
        //d[i] = f[i] = INF;
    }
    for(int i=0;i<n;++i)
    {
        cin >> u >> k;
        --u;
        for(int j=0;j<k;++j)
        {
            cin >> e;
            --e;
            edges[u].push_back(e);
            //edges[e].push_back(u);
        }
    }

    dfs(edges, d, f, color, n);
    for(int i = 0;i < n; ++i)
    {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}



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



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

    int a, b, n;
    a = X / 500;
    n = X % 500;
    b = n / 5;

    cout << a * 1000 + b * 5 << endl;

    return 0;
}

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

int main() {
    int k,x;cin>>k>>x;

    vector<long long>jdg(2000001,0);
    for (int i=-1000000;i<1000000;i++) {
        if(i>=x-(k-1)&&i<=x+(k-1)){
            cout<<i<<" ";
        }
    }
    cout<<endl;

}


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

int n;
string s;
map<string, int> cnt;
long long ans;
int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
 // freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> n;
  while(n--){
    cin >> s;
    sort(s.begin(), s.end());
    ans += cnt[s];
    ++cnt[s];
  }cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11264
import java.util.*;
public class Main {
	int[] N;
	int n,p;
	Main(){
		n=-1;p=-1;
	}
		void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			n=sc.nextInt();
			p=sc.nextInt();
			if(n==0&&p==0)break;
			N=new int[n];
			System.out.println(solve(0,p));
		}
	}
		int solve(int current,int remains){
			while(true){
				if(remains==1&&N[current]+1==p)return current;
				if(remains==0){
					remains=N[current]+1;
					N[current]=0;
				}
				else{
					N[current]+=1;
				}
				current=(current+1)%n;
				remains=remains-1;
				for(int i=0;i<n;i++){
				}
			}
		}
	public static void main(String[] args) {
		new Main().run();
	}
}

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

#define rep(i, a, b) for(int i = a; i <= (b); ++i)
#define per(i, b, a) for(int i = b; i >= (a); --i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define boost ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define M (1000*1000*1000+7)
#define inf (2*1000*1000*1000+9)
#define infl ((ll)2*1000*1000*1000*1000*1000*1000+9)
#define debug1(a) cout<<#a<<" = " <<a<<endl; 
#define debug2(a,b) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<endl; 
#define debug3(a,b,c) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<endl; 
#define debug4(a,b,c,d) cout<<#a<<" = " <<a<<" , "<<#b<<" = "<<b<<" , "<<#c<<" = "<<c<<" , "<<#d<<" = " <<d<<endl; 
  
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc; 
typedef vector<ll> vll; 
typedef vector< pair<int,int> > vpii;

/* -------------------------------------------------------------------------*/
/* -------------------------------------------------------------------------*/


void solve(){ 
	int n; cin>>n; 
	vi a(n); 
	bool all_even=1; 
	rep(i,0,n-1) {
		cin>>a[i]; 	
		if(a[i]&1) all_even=0; 
	}
	if(all_even){
		cout<<"second"; 
	}
	else{
		cout<<"first"; 
	}
}


int main() {
  clock_t beg=clock(); 
  boost;
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
  clock_t end=clock(); 
  fprintf(stderr, "%lf\n", (double)(end-beg)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
int a[200010] = {};
vector<pair<int, int>> v[50];
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N, C;
	cin >> N >> C;
	rep(i, N) {
		int s, t, c;
		cin >> s >> t >> c;
		v[c].push_back(make_pair(s, t));
	}
	rrep(i, C) {
		sort(v[i].begin(), v[i].end());
		set<int> st;
		for (int j = 1; j < v[i].size(); j++) {
			if (v[i][j - 1].second == v[i][j].first) {
				v[i][j].first = v[i][j - 1].first;
				st.insert(j - 1);
			}
		}
		for (int j = 0; j < v[i].size(); j++) {
			if (st.find(j) == st.end()) {
				a[v[i][j].first * 2 - 1]++;
				a[v[i][j].second * 2]--;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i < 200010; i++) {
		a[i] += a[i - 1];
		ans = max(ans, a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6516
#include <stdio.h>
int main()
{
	int n;
	long long ans=0,a[55];
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n-1;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			ans+=a[i]*a[j];
		}
	}
	printf("%lld",ans);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  set<int> Set;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(Set.count(a)) Set.erase(a);
    else Set.insert(a);
  }

  cout << Set.size() << endl;
}


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

const int MAXN = 1e5+10;
int vet[MAXN];

int main(){
	vector<int> A;
	for (int i = 0 ; i < MAXN; i++)
		vet[i] = 1e9+7;
	int n, k, hi;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++){
		scanf("%d", &hi);
		A.push_back(hi);
	}
	vet[0] = 0;
	for (int i = 1; i < n; i++){
		for (int j = 1; j <= k; j++){
			if (i - j < 0) break;
			vet[i] = min(vet[i], vet[i-j] + abs(A[i] - A[i-j]));
		}
	}
	printf("%d\n", vet[n-1]);
	return 0;
}

Measured memory_bytes: 4300
import collections

n,p=map(int,input().split())

a=[]
while p % 2 == 0:
  p //= 2
  a.append(2)
f = 3
while f * f <= p:
  if p % f == 0:
    a.append(f)
    p //= f
  else:
    f += 2
if p != 1:
  a.append(p)

dct=collections.Counter(a)

ans=1


li=dct.items()


for tt in li:
  if tt[1]//n>=1:
    ans*=tt[0]**(tt[1]//n)
print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
 long double PI =  3.14159265358979323846;
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  cout << setprecision(10)<<fixed << PI * 2.0 * (long double)n << '\n';
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


Measured memory_bytes: 3796
#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;
    string s;
    cin >> s;
    vector <int> se(n+1,0),sw(n+1,0);
    int tmpe = 0, tmpw = 0;
    rep(i,n){
        if(s[i] == 'E') tmpe ++;
        else tmpw ++;
        se[i+1] = tmpe;
        sw[i+1] = tmpw;
    }

    int ans = min((se[n]-se[1]),sw[n-1]);
    if(n==2){
        cout << ans << endl;
        return 0;
    }

    for(int i=1; i<=n-2; i++){
        int tmp = sw[i] + (se[n]-se[i+1]);
        if(tmp < ans){
            ans = tmp;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, C, K; cin >> N >> C >> K;
    vector<int> T(N);
    rep(i,N) cin >> T.at(i);
    sort(T.begin(), T.end());    
    int i = 0, p = 0, ws = 0;
    ll res = 0;
    while(i < N) {
        if (p == 0) ws = T[i];
        p++;
        if (i == N-1 || p == C || T[i+1] - ws > K) {
            res++;
            p = 0;
        }
        i++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3700
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c,d,ab,bc,ac;
	cin>>a>>b>>c>>d;
	ab=a-b;
	bc=b-c;
	ac=a-c;
	if(ab<0){
		ab=ab*-1;
	}
	if(ac<0){
		ac=ac*-1;
	}
	if(bc<0){
		bc=bc*-1;
	}
 
	if(ac<=d){
		cout<<"Yes"<<endl;
	}
	else if(ab<=d&&bc<=d){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n;
string s;
int main(){FAST;
cin>>n>>s;
ll x = 0,y = n-1;
ll ans = 0;
while(1){
  if(x >= y)break;
  if(s[x] == 'R' and s[y] == 'W'){
    ++x,--y;
  }
  else if(s[x] == 'R' and s[y] == 'R'){
    ++x;
  }
  else if(s[x] == 'W' and s[y] == 'R'){
    swap(s[x],s[y]);
    ++ans;
  }
  else if(s[x] == 'W' and s[y] == 'W'){
    --y;
  }
}
cout<<ans;
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


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

main() {
    int A,B; cin >> A >> B;
    int X=max(A+B,A-B);
    X=max(X,A*B);
    cout << X << endl;

    return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define endl "\n"

const ll N = 1e6 + 7;
const ll mod = 998244353;

int32_t main()
{
	
	IOS

	vector<ll> v;
	ll n;
	string str;
	cin>>str;
	int flag = 0;
	for(int i=1;i<str.size();i++)
	{
		if(str[i] == str[i-1])
		{
			flag = 1;
			break;
		}
	}
	if(flag)
		cout<<"Bad";
	else
		cout<<"Good";
	return 0;
}

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

int main(void){
    int h,w,k,i,cnt_black,cnt_ans,j,inva,invb;

    cnt_ans = 0,cnt_black = 0;

    cin >> h >> w >> k;
    vector<vector<char>> c(6,vector<char>(6));

    bitset<6> red_gyou;
    bitset<6> red_retu;

    
    
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            cin >> c.at(i).at(j);
        }
    }

    for(i=0; i < (1 << h); i++){
        bitset<6> red_gyou(i);
        for(j=0; j < (1 << w); j++){
            bitset<6> red_retu(j);
            for(int a=0; a<h; a++){
                for(int b=0; b<w; b++){
                    if(red_gyou[a] == 0){
                        if((red_retu[b] == 0) && (c.at(a).at(b) == '#'))    cnt_black++;
                    }else if(red_gyou[a] == 1){
                        continue;
                    }
                    }
                }
                if(cnt_black == k) cnt_ans++;
                cnt_black = 0;
            }
        }

    cout << cnt_ans << endl;
    return 0;
}

Measured memory_bytes: 3632
s = input()

if s[0] == "A":
    s = s.replace("A", "a", 1)
    index = s.find("C")
    if index == s.rfind("C") and index >= 2 and index <= len(s) - 2:
        s = s.replace("C", "c", 1)
        if (s.islower()):
            print("AC")
            exit()
print("WA")

Measured memory_bytes: 3060
#include <cstdio>

int main()
{
    int card, num;
    bool spade[14] ,heart[14], club[14], dia[14];
    char symbol;
    for (int i = 0; i < 14; i++){
        spade[i] = false;
        club[i] = false;
        heart[i] = false;
        dia[i] = false;
    }

    scanf("%d", &card);
    
    for (int i = 0; i < card; i++){
        scanf(" %c %d", &symbol, &num);

        switch (symbol) {
            case 'S' :
                spade[num] = true;
                break;
            case 'H' :
                heart[num] = true;
                break;
            case 'C':
                club[num] = true;
                break;
            case 'D':
                dia[num] = true;
                break;
        }
    }

    for (int i = 1; i <= 13; i++){
        if (spade[i] == false){
            printf("S %d\n", i);
        }
    }

    for (int i = 1; i <= 13; i++){
        if (heart[i] == false){
            printf("H %d\n", i);
        }
    }

    for (int i = 1; i <= 13; i++){
        if (club[i] == false){
            printf("C %d\n", i);
        }
    }

    for (int i = 1; i <= 13; i++){
        if (dia[i] == false){
            printf("D %d\n", i);
        }
    }
                
    return 0;
}

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

#define ll long long
#define pb push_back

int main() {
    int n;
    cin >> n;
    int ost = n % 1000;
    if (ost == 0){
        cout << "0";
    } else {
        cout << 1000 - ost;
    }
}


Measured memory_bytes: 3608
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
    int n = scan!int, m = scan!int;
    Node[] nodes;
    foreach(i; 0 .. n) nodes ~= new Node(i);
    foreach(j; 0 .. m){
        Node a = nodes[scan!int - 1], b = nodes[scan!int - 1];
        a.nodes ~= b;
        b.nodes ~= a;
    }

    nodes[0].parent = nodes[0];
    auto nodeq = new Queue!Node();
    nodeq.enq(nodes[0]);

    while(nodeq.length){
        Node nd = nodeq.deq;
        foreach(kid; nd.nodes){
            if(! kid.parent) kid.parent = nd, nodeq.enq(kid);
        }
    }

    "Yes".print;

    foreach(nd; nodes){
        if(nd.parent.id != nd.id) print(nd.parent.id + 1);
    }

}

class Node{
    int id;
    Node[] nodes;
    Node parent;
    this(int id){
        this.id = id;
    }
}

// ----- キュー -----
class Queue(T){
	private T[] xs;
	private uint i, j; // i : 次に読み出す位置　j: 次に書き込む位置
	this(){	}
	this(T[] xs){ this.xs = xs; j = xs.length.to!uint; }
	uint length(){ return j - i; }
	bool isEmpty(){ return j == i; }
	void enq(T x){
		while(j + 1 >= xs.length) xs.length = xs.length * 2 + 1;
		xs[j ++] = x;
	}
	T deq(){ assert(i < j); return xs[i ++]; }
	T peek(){ assert(i < j); return xs[i]; }
	T opIndex(uint li){ assert(i + li < j); return xs[i + li]; }
	static Queue!T opCall(){ return new Queue!T; }
	static Queue!T opCall(T[] xs){ return new Queue!T(xs); }
	T[] array(){ return xs[i .. j]; }
	override string toString(){ return array.to!string; }
}


Measured memory_bytes: 37148
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int keta (ll n) {
    int keta = 0;
    while(n) {
        keta++;
        n /= 10;
    }
    return keta;
}

int main() {
    int n; cin >> n;
    ll ans = 1;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        
    }
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) {
            cout << 0 << "\n";
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] <= 1000000000000000000/ans) ans *= a[i];
        else {
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3968
n,*a=map(int,open(0).read().split())
d=0
l=[]
a=sorted(enumerate(a),key=lambda x:x[1])
b=a[n//2][1]
c=a[n//2-1][1]
for(k,v)in a:
    d+=1
    if d<n//2+1:
        l.append((k,b))
    else:
        l.append((k,c))
#print(l)
for(k,v)in sorted(l,key=lambda x:x[0]):
    print(v)


Measured memory_bytes: 51656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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;

int main(){
  int n, k; cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(all(h));

  int mi = 1001001001;
  rep(i, n-k+1) chmin(mi, h[i+k-1] - h[i]);

  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;

long long a[100000][3];
long long dp[100000][3];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (k == j)continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}

	cout << max(max(dp[N][0], dp[N][1]), dp[N][2]) << endl;
	return 0;
}


Measured memory_bytes: 4992
#!/usr/bin/env fsharpi

open System;

let parseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let parseInt1 ( str : string ) =
    parseIntN str |> fun arr -> arr.[0]

let parseInt2 ( str : string ) =
    parseIntN str |> fun arr -> (arr.[0],arr.[1])

let parseInt3 ( str : string ) =
    parseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let readLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

ignore(Console.ReadLine())
readLines 
|> Seq.map (fun a -> a + "\n" + a + "\n")
|> System.String.Concat
|> Console.Write


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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N;
vector <int > T,A,H;

vector <bool> M;



int main()
{

	cin >> N;

	T.resize(N);
	A.resize(N);
	H.resize(N);
	M.resize(N);
	REP(i,N){
		cin >> T[i];
		M[i] = true;
	}
	REP(i,N){
		cin >> A[i];
	}
	long long ans = 1;
	if(T[0] > A[0] || T[N-1] < A[N-1] || T[N-1] != A[0] ){
		cout <<0;
		return 0;
	}
	FOR(i,1,N-1){
		if(T[i] <= T[i-1]) {
			M[i] = false;
			H[i] = T[i];
		} else {
			if(T[i] > A[i]){
				cout << 0;
				return 0;
			}
		}
	}
	RFOR(i,0,N-1){
		if(M[i]){
			continue;
		} else if(A[i] <= A[i+1]) {
			M[i] = false;
			H[i] = min(T[i],A[i]);
		} else {
			M[i] = true;
			if(T[i] < A[i]){
				cout << 0;
				return 0;
			}
		}
	}



	REP(i,N) {
		if(!M[i]) {
			ans = (H[i] * ans) % 1000000007;
		}
	}

	cout << ans;

}

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

using namespace std;
typedef long long ll;

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

int main(){
// ここに処理を記述
    string s;
    cin >> s;

    queue<char> s_arr;
    REP(i,s.size()) s_arr.push(s[i]);

    string compare = "";
    string temp = "";
    int ans = 0;

    while(!s_arr.empty()){
        temp += s_arr.front();

        if(temp.size() != compare.size() || temp != compare){
            compare = temp;
            temp = "";
            ans++;
        }

        s_arr.pop();
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define il inline
#define ll long long 
#define int long long
#define Max 100005
#define Mod 1000000007
using namespace std;
il int read()
{
	char c=getchar();
	int x=0,f=1;
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
il ll qpw(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%Mod;
		a=a*a%Mod;
		b>>=1;
	}
	return res;
}
char s[Max];
int n,p[Max],ans=1,fac[Max],ifac[Max],cnt,lst[Max];
signed main()
{
	n=read();
	scanf("%s",s+1);
	for(int r=1;r<=n;r++)
	{
		p[s[r]-'a']++;
	}
	for(int i=0;i<=27;i++) ans=ans*(p[i]+1)%Mod;
	cout<<ans-1<<endl;
}

Measured memory_bytes: 384