akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'
#define _ ios::sync_with_stdio(false);cin.tie(0);

using namespace std;

int main() {_
    int n, in, out, sum = 0;
    vector<int> ins;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> in;
        ins.push_back(in);
        sum ^= in;
    }

    for(int i=0; i<n; i++){
        out = ins[i] ^ sum;
        cout << out << ' ';
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

void siftdown(int a[], int i, int n)
{
	int j;
	int t = a[i];
	while ((j = 2 * i + 1) < n)
	{
		if (j < n - 1 && a[j] < a[j + 1])
			j++;
		if (a[j] > t)
		{
			a[i] = a[j];
			i = j;
		}
		else
			break;
	}
	a[i] = t;
}

void heap(int a[], int n)
{
	int i;
	for (i = (n - 2) / 2;i >= 0;i--)
		siftdown(a, i, n);
}

void siftup(int a[], int k)
{
	int j = k, i = (j - 1) / 2;
	int t = a[j];
	while (j > 0)
	{
		if (a[i] > t)
			break;
		else
		{
			a[j] = a[i];
			j = i;    
			i = (i - 1) / 2;
		}
	}
	a[j] = t;
}

int main()
{
	int n, m;
	cin >> n >> m;
	ull ans = 0;
	int a[100005];
	for (int i = 0;i < n;i++)
		cin >> a[i];
	heap(a, n);
	int temp;
	while (m--)
	{
		temp = a[0];
		a[0] = a[n - 1];
		a[n - 1] = temp / 2;
		siftdown(a, 0, n - 1);
		siftup(a, n - 1);
	}
	for (int i = 0;i < n;i++)
		ans += a[i];
	cout << ans;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e9;
const int N = (int)1e5+5;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n,w;
vector< pair<int,int> >v;
ll dp[105][N]; 
ll solve(int idx,int weight){  
    if(weight<0)return INT_MIN;
    if(idx == n)return 0;
    ll &ret = dp[idx][weight];
    if(~ret)return ret ;
    ret = solve(idx+1,weight);
    ret = max(ret , solve(idx + 1, weight - v[idx].first) + 1ll*v[idx].second);
    return ret;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    scanf("%d %d",&n,&w);
    lp(i,n){
        int x,y;
        scanf("%d %d",&x,&y);
        v.push_back({x,y});
    }
    memset(dp,-1,sizeof(dp));
    printf("%lld",solve(0,w));
    return 0;
}


Measured memory_bytes: 82304
#define MAX 50
#include <stdio.h>

void set_card(int *card,int n){
    int i;
    for(i=0;i<n;i++){
        card[i] = i+1;
    }
}

void copy_card(int *card,int *copy, int n){
    int i;
    for(i=0;i<n;i++){
        copy[i] = card[i];
    }
}
void shuffle_card(int *card, int *copy,int n,int p,int c){
    int i;
    for(i=0;i<p-1;i++){
        card[n-c-i-1] = copy[n-i-1];
    }
    for(i=0;i<c;i++){
        card[n-i-1] = copy[n-p-i];
    }
    
}
int main(void) {
    int n,r,p,c;
    int card[MAX] = {};
    int copy[MAX] = {};

    int i;
    
    while(1){
        scanf("%d%d",&n,&r);
        if(n==0 && r==0)
            break;
        set_card(card,n);
        copy_card(card,copy,n);
    
        for(i=0;i<r;i++){
            scanf("%d%d",&p,&c);
            shuffle_card(card,copy,n,p,c);
            copy_card(card,copy,n);
        }
        printf("%d\n", card[n-1]);
    }
    return 0;
    
    }

Measured memory_bytes: 600
n = int(input())
a = list(map(int, input().split()))

ruiseki = [0] * (n + 1)
ruiseki2 = [0] * (n + 1)
for i in range(n):
    ruiseki[i + 1] = ruiseki[i] + a[i]
    ruiseki2[i + 1] = ruiseki2[i] ^ a[i]

def solve(l, r):
    return ruiseki[r] - ruiseki[l] == ruiseki2[r] ^ ruiseki2[l]
  
ans = 0
for i in range(n):
    ok = i
    ng = n + 1
    while abs(ng - ok) > 1:
        mid = (ok + ng) // 2
        if solve(i, mid):
            ok = mid
        else:
            ng = mid
    ans += ok - i
print(ans)

Measured memory_bytes: 77900
#include <cstdio>
#include <algorithm>
using namespace std;
unsigned int a[3];
int main()
{
    int T = 1; //scanf("%d", &T);
    while(T--){
        unsigned int s, mx; s = mx = 0;
        for(int i = 0; i < 3; i++){
            scanf("%d", &a[i]);
            s += a[i];
            mx = max(mx, a[i]);
        }
        int ans;
        mx *= 3;
        for(int i = 0; i < 3; i++)
            mx -= a[i];
        if(mx%2==0) ans = mx/2;
        else ans = mx/2+2;
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	long long int n, m;
	scanf("%lld %lld", &n, &m);
	long long int a[100000], d[100000];
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		a[i]--;
	}
	for(int i=0; i<n-1; i++){
		d[i]=a[i+1]-a[i];
		if(d[i]<0) d[i]+=m;
	}
	long long int s0[100000]={};
	for(int i=0; i<n-1; i++){
		if(a[i+1]-d[i]+1>=0){
			if(a[i+1]-d[i]+2<m) s0[a[i+1]-d[i]+2]--;
			if(a[i+1]+1<m) s0[a[i+1]+1]++;
		}else{
			s0[1]--;
			s0[a[i+1]+1]++;
			if(a[i+1]-d[i]+2+m<m) s0[a[i+1]-d[i]+2+m]--;
		}
	}
	long long int s1[100000]={};
	for(int i=1; i<m; i++){
		s1[i]=s1[i-1]+s0[i];
	}
	for(int i=0; i<n-1; i++){
		if(a[i+1]+1<m) s1[a[i+1]+1]+=(d[i]-1);
	}
	long long int s2[100000];
	s2[0]=0;
	for(int i=0; i<n-1; i++){
		if(a[i+1]-d[i]+1>=0){
			s2[0]+=d[i];
		}else{
			s2[0]+=(a[i+1]+1);
		}
	}
	long long int ans=s2[0];
	for(int i=1; i<m; i++){
		s2[i]=s2[i-1]+s1[i];
		if(ans>s2[i]) ans=s2[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)

// N=2000 の O( N^3 ) は bitsetの可能性あり

int main()
{
	ull n = 0;
	cin >> n;
	vector<ll> a( n, 0 );
	REP(i, n) cin >> a[i];
	
	bitset<2000*2000+1> bs(1);
	REP(i,n) bs |= bs<<a[i];
	
	ll sumHalf = ( accumulate( ALL(a), 0 ) + 1 ) / 2;
	for( ll i = sumHalf; i < bs.size(); ++i )
		if( bs[i] ) { cout << i << endl; break; }

	return 0;
}

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

#define int long long

vector<int> v;
vector<string> u;
void solve(int i, int n, string ans) {
    if(i==4) {
        if(n==7) {
            u.push_back(ans);
        }
        return;
    }
    for(int j=0; j<2; ++j) {
        solve(i+1, n+v[i], ans+"+");
        solve(i+1, n-v[i], ans+"-");
    }
}

signed main() {
    string s;
    cin >> s;
    for(int i=0; i<s.size(); ++i) v.push_back(s[i]-'0');
    solve(1, v[0], "");
    string ans = u[0];
    cout << v[0] << ans[0] << v[1] << ans[1] << v[2] << ans[2] << v[3] << "=7" << endl;
    return 0;
}



Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

int main() {
    LL n,x;
    R(n,x);
    LL ans=n;
    LL a=x,b=n-x;
    while ( 1 ) {
        if ( a<b ) swap(a,b);
        if ( b==0 ) break;
        LL q=a/b;
        ans+=2*q*b;
        a%=b;
    }
    ans-=a;
    W(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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]);
    }
    int roor(int x){
      if(par[x]<0)return x;
      else return 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); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int N,M;cin>>N>>M;
  UnionFind UF(N);
  for(int X=0;X<M;X++){
    int A,B;cin>>A>>B;A--;B--;
    UF.merge(A,B);
  }
  int K=0;
  for(int X=0;X<N;X++){
    if(UF.size(X)>K){
      K=UF.size(X);
    }
  }
  cout<<K<<endl;
}

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

int n,a,m;
long long ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    while(n--){
        cin>>a;
        ans+=max(0,m-a);
        m=max(m,a);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3616
import math
A, B, H, M = map(int,input().split())
a = (((H + M / 60) * 2 * math.pi) / 12) - ((M * 2 * math.pi) / 60)
b = (A ** 2 + B ** 2 - 2 * A * B * math.cos(a)) ** 0.5
print(b)

Measured memory_bytes: 62532
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize, m: usize,
        py: [(usize, usize); m],
    }
    let mut py_ = Vec::with_capacity(m);

    for (i, pypy) in py.iter().enumerate() {
        py_.push((pypy.0, pypy.1, i))
    }
    py_.sort();

    let mut cnt = vec![0; n + 1];
    let mut ans = Vec::with_capacity(m);
    for (p, _, i) in py_ {
        cnt[p] += 1;
        ans.push((i, p, cnt[p]));
    }
    ans.sort();
    for (_, p, y_) in ans {
        println!("{:06}{:06}", p, y_);
    }
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll n;
    cin >> n;
    vector<string> d(n);
    rep(i,n){
        cin>>d[i];
    }
    sort(all(d));
    ll ans=n;
    rep(i,n-1){
        if(d[i]==d[i+1]){
            ans--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<double> vec;
int main(){
  int n;cin>>n;
  vec v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(), v.end());
  double ans=v[0];
  rep(i,n) ans=(ans+v[i])/2;
  cout<<ans;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
dp = [0] * n
dp[1] = abs(h[0]-h[1])
for i in range(2,n):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
#define int long long 

signed main(){
    int A,B;
    cin >> A >> B;
    if(A+B >= 10) cout << "error\n";
    else cout << A+B <<"\n";                                                                                                                                                  
}


Measured memory_bytes: 256
maxs = 10 ** 9 +7
N, K = [int(x) for x in raw_input().split(' ')]
A = [int(x) for x in raw_input().split(' ')]
B = sorted(A)
l1, l2 = [], []
for i in xrange(N):
    l1.append(len([A[j] for j in range(0, N) if A[j] < A[i]]))
    l2.append(len([A[j] for j in range(i, N) if A[j] < A[i]]))
ans = sum(l1)  * K * (K-1) / 2 + sum(l2) * K
print(ans % maxs)




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

int main() {
  string s;
  cin>>s;
  int n=s.length()/2;
  int ans=0;
  
  for(int i=1;i<n;i++){
    if(s.substr(0,i)==s.substr(i,i)){
      ans=i*2;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*=============================================================================================================================/*
                                               Bismillahir Rahmanir Rahim

      _     ____  ___  ____   _   _  _         ___  ____   _         _     __  __
     / \   / ___||_ _|| __ ) | | | || |       |_ _|/ ___| | |       / \   |  \/  |
    / _ \  \___ \ | | |  _ \ | | | || |        | | \___ \ | |      / _ \  | |\/| |
   / ___ \  ___) || | | |_) || |_| || |___     | |  ___) || |___  / ___ \ | |  | |
  /_/   \_\|____/|___||____/  \___/ |_____|   |___||____/ |_____|/_/   \_\|_|  |_|

   _   __           __  __  __
  |_) (_  _  o__   /   (_  |_
  |_)o__)(_  || |  \__ __) |__

    ___                    _   _      _                _ _               __   ___                 _         _        _
   / __|_ _ ___ ___ _ _   | | | |_ _ (_)_ _____ _ _ __(_) |_ _  _   ___ / _| | _ ) __ _ _ _  __ _| |__ _ __| |___ __| |_
  | (_ | '_/ -_) -_) ' \  | |_| | ' \| \ V / -_) '_(_-< |  _| || | / _ \  _| | _ \/ _` | ' \/ _` | / _` / _` / -_|_-< ' \
   \___|_| \___\___|_||_|  \___/|_||_|_|\_/\___|_| /__/_|\__|\_, | \___/_|   |___/\__,_|_||_\__, |_\__,_\__,_\___/__/_||_|
                                                            |__/                           |___/


   FB: https://facebook.com/SIAsibul
   Gmail: asibulislam8@gmail.com

/*=============================================================================================================================*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vii;
typedef vector<pil> vil;
typedef vector<pli> vli;
typedef vector<pll> vll;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,n) for(ll i=0;i<(n);i++)
#define f1(i,n) for(ll i=1;i<=(n);i++)
#define f2(i,a,n) for(ll i=(a);i<=(n);i++)
#define fr(i,n,a) for(ll i=(n);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define nl "\n"


const int INF = 1e9 + 5;
const int MXN = 2e5 + 5;
const int MOD = 1e9 + 7;

void solve(){
    ll n; cin >> n;
    ll a[n];
    f0(i, n) cin >> a[i];
    ll m = a[0], ans = 0;
    f0(i, n){
        m = max(m, a[i]);
        ans += m-a[i];
    }

    cout << ans << nl;
}



int main(){
    ll t;
    //cin >> t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
 }


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

using namespace std;

int main(){
     string S,T;
     cin >> S >>T;
     int same=0,memo=0;
     for(int i=0;i<int(S.length()-T.length())+1;i++){
          for(int j=0;j<int(T.length());j++){
               if(S[i+j]==T[j]){
                    memo++;
               }
          }
          if(memo>same)same=memo;
          memo=0;
     }
     cout << int(T.length()) - same <<endl;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <algorithm>
#include<iostream>
#define MAXN 1000
using namespace std;
int n,k,mins;
int main () {
   cin>>n;
   int flag=0;
   for(int i=0;i<=n;i++){
   	for(int j=0;j<=n;j++){
   		if(i*4+j*7==n){
   			flag=1;
   			break;
   			
		   }
	   }
   }
   if(flag){
   	cout<<"Yes";
   }else{
   	cout<<"No";
   }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int N,K,X,Y; 
	scanf("%d %d %d %d",&N,&K,&X,&Y );
	if(N<=K) { 
	printf ("%d\n",N*X); 
	} else {
	printf("%d\n",K*X+N*Y-K*Y);
	} 
	return 0;
	}
    

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


using namespace std;


int main() {
    int n; cin >> n;
    vector<vector<int>> a(2);
    for(int i=0; i<2; ++i) {
        a[i].resize(n);
        for (int j=0; j<n; ++j) cin >> a[i][j];
    }

    a[1][0] += a[0][0];
    for (int i=1; i<n; ++i) a[0][i] += a[0][i-1];
    for (int i=1; i<n; ++i) a[1][i] += max(a[0][i], a[1][i-1]);

    cout << a[1][n-1] << endl;
    return 0;
}



Measured memory_bytes: 888
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

int main() {
    int n; cin >> n;
    int p = 0;
    for (int i = 0; i < n; i++) {
        int tmp; cin >> tmp;
        p += tmp * pow(10,n - 1 - i);
    }
    int q  = 0;
    for (int i = 0; i < n; i++) {
        int tmp; cin >> tmp;
        q += tmp * pow(10,n - 1 - i);
    }
    vector<int> v,array;
    for (int i = 0; i < n; i++) array.push_back(i+1);
    do{
        int res = 0;
        for (int i = 0; i < n; i++) res += array[i] * pow(10,n-1-i);
        v.push_back(res);
    }while(next_permutation(array.begin(),array.end()));
    sort(v.begin(),v.end());
    int pnum,qnum;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] == p) pnum = i+1;
        if (v[i] == q) qnum = i+1;
    }
    int ans = abs(pnum-qnum);
    cout << ans << "\n";
}

Measured memory_bytes: 640
N = int(input())
List = [str(input()) for i in range(N)]
c0=0
c1=0
c2=0
c3=0
for i in List:
    if i=='AC':
        c0+=1
    elif i=='WA':
        c1+=1
    elif i=='TLE':
        c2+=1
    elif i=='RE':
        c3+=1
print('AC x {}'.format(c0))
print('WA x {}'.format(c1))
print('TLE x {}'.format(c2))
print('RE x {}'.format(c3))

Measured memory_bytes: 79240
def main():
    from math import ceil

    n, *csf = map(int, open(0).read().split())
    csf = list(zip(csf[::3], csf[1::3], csf[2::3]))
    ans = ""
    for i in range(n):
        time = 0
        for c, s, f in csf[i:]:
            if time <= s:
                time = s
            else:
                time = s + ceil((time - s) / f) * f
            time += c
        
        ans += str(time) + '\n'
    print(ans)

if __name__ == '__main__':
    main()


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

int k = 0;
vector<pair<int, int> > g[100009];
void dfs(int cur, int p, int color) {
  int e_color = 1;
  for (int i=0; i<g[cur].size(); i++) {
    if (g[cur][i].first == p) {
      continue;
    }
    if (e_color == color) {
      ++e_color;
    }
    g[cur][i].second = e_color;
    dfs(g[cur][i].first, cur, e_color);
    ++e_color;
  }
}
int main() {
  int n;
  cin>>n;
  pair<int, int> ab[n-1];
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    ab[i] = make_pair(a, b);
    g[a].push_back(make_pair(b, 0));
    g[b].push_back(make_pair(a, 0));
  }
  for (int i=0; i<n; i++) {
    k = max((int)g[i].size(), k);
  }
  dfs(0, -1, -1);
  vector<tuple<int, int, int> > edges;
  for (int i=0; i<n; i++) {
    for (auto e: g[i]) {
      int to = e.first;
      if (i > to) {
        continue;
      }
      edges.push_back(make_tuple(i, to, e.second));
    }
  }
  sort(edges.begin(), edges.end());
  cout<<k<<endl;
  for (int i=0; i<n-1; i++) {
    tuple<int, int, int> t = make_tuple(ab[i].first, ab[i].second, 0);
    auto it = lower_bound(edges.begin(), edges.end(), t);
    cout<<get<2>(*it)<<endl;
  }
}

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



int main(){
    int n;
    cin >> n;
    ll sum=0;
    int a[n+1];
    int b[n];
    rep(i,n+1){
        int x;
        cin >> x;
        a[i] = x;
    }
    rep(i,n){
        int x;
        cin >> x;
        b[i] = x;
    }
    rep(i,n){
        if(a[i]-b[i] > 0){
            a[i] = a[i]-b[i];
            sum+=b[i];
            b[i] = 0;
        }
        else{
            b[i] = b[i] -a[i];
            sum+=a[i];
            a[i] = 0;
        }
        if(b[i] > 0 && a[i+1]-b[i] >0){
            a[i+1] = a[i+1]-b[i];
            sum+=b[i];
            b[i] = 0;
        }
        else if(b[i] > 0 && a[i+1]-b[i] <=0){
            b[i] = b[i] -a[i+1];
            sum+=a[i+1];
          	a[i+1] = 0;
        }
        
    }
    cout << sum <<endl;
    
    
        
    
    
    
    return 0;
}













Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)          \
  cerr << #v << ": ";         \
  REP(__i, (v).size())        \
  cerr << ((v)[__i]) << ", "; \
  cerr << endl

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  float ans = 0.0;

  REP(i, N) {
    float x;
    string u;
    cin >> x >> u;
    if (u == "JPY")
      ans += x;
    else
      ans += 380000 * x;
  }
  cout << ans << endl;

  return 0;
}


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

int n;
bool eq(vector<int> a, vector<int> b) {
    for (int j = 0; j < n; j++) {
        if (a[j] != b[j]) return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }
    vector<int> pe;
    for (int j = 0; j < n; j++) {
        pe.push_back(j+1);
    }
    int pt = 0;
    int a = -1, b = -1;
    do {
        if (eq(p,pe)) {
            a = pt;
        }
        if (eq(q,pe)) {
            b = pt;
        }
        pt++;
    } while (next_permutation(pe.begin(),pe.end()));
    assert(a != -1 && b != -1);
    //cout << a << ' ' << b << '\n';
    cout << abs(a-b) << '\n';
}



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

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


Measured memory_bytes: 3104
X,N = map(int, input().split())
P = set(map(int, input().split()))

d = 10**9
ans = 0
for i in range(120) :
    if(i in P) :
        continue
    if(abs(X-i) < d) :
        ans = i
        d = abs(X-i)
print(ans)

Measured memory_bytes: 9032
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

string field[12];
string buf[12];

void fall(){
	int i,j;
	bool update;
	for(i=0;i<6;i++){
		update=true;
		while(update){
			update=false;
			for(j=11;j>0;j--){
				if(field[j][i]=='.'&&field[j-1][i]!='.'){
					field[j][i]=field[j-1][i];
					field[j-1][i]='.';
					update=true;
				}
			}
		}
	}
}

int count(string str[],int x,int y,char c){
	if(x<0||6<=x||y<0||12<=y)return 0;
	if(str[y][x]!=c)return 0;
	int res=1;
	str[y][x]='*';
	res+=count(str,x+1,y,c);
	res+=count(str,x-1,y,c);
	res+=count(str,x,y+1,c);
	res+=count(str,x,y-1,c);
	return res;
}

bool bomb(){
	int i,j;
	bool res=false;
	for(i=0;i<12;i++){
		buf[i]=field[i];
	}
	for(i=0;i<12;i++){
		for(j=0;j<6;j++){
			if(buf[i][j]=='R'||buf[i][j]=='G'||buf[i][j]=='B'||buf[i][j]=='Y'||buf[i][j]=='P'){
				int c=count(buf,j,i,buf[i][j]);
				if(4<=c){
					count(field,j,i,field[i][j]);
					res=true;
				}
			}
		}
	}
	int xx[]={1,-1,0,0},yy[]={0,0,1,-1};
	for(i=0;i<12;i++){
		for(j=0;j<6;j++){
			if(field[i][j]=='*'){
				int k;
				for(k=0;k<4;k++){
					if(i+yy[k]<0||i+yy[k]>=12||j+xx[k]<0||j+xx[k]>=6)continue;
					if(field[i+yy[k]][j+xx[k]]=='O')field[i+yy[k]][j+xx[k]]='.';
				}
				field[i][j]='.';
			}
		}
	}
	return res;
}

int main() {
	int n=in();
	while(n--){
		int i;
		for(i=0;i<12;i++){
			cin>>field[i];
		}
		int res=0;
		while(1){
			if(!bomb())break;
//for(i=0;i<12;i++){
//cout<<field[i]<<endl;
//}
//cout<<endl;
			fall();
//for(i=0;i<12;i++){
//cout<<field[i]<<endl;
//}
//cout<<endl;
			res++;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>

int hantei(int);

int main(){
int i,kosu=0,n,data;

  scanf("%d",&n);

  for(i=0;i<n;i++){

scanf("%d",&data);
 
 if(hantei(data)==1) kosu++;
 
  }
  printf("%d\n",kosu);
  
  return 0;
  }

int hantei(int data){
  
  int i;
  
  if(data!=2 && data%2==0) return 0;
  else if (data==2) return 1;

  if(data!=3 && data%3==0) return 0;
  else if (data==3) return 1;

  if(data!=5 && data%5==0) return 0;
  else if (data==5) return 1;

  
  for(i=3;i<sqrt(data)+1;i++){
    if(data%i==0) return 0;
  }
  return 1;
}
  



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

string answer(string s){
    string ans;
    for(char a:s){
        if(a=='?'){
            ans+='A';
        }
        else ans+=a;
    }
    return ans;
}
string rev(string s){
    reverse(s.begin(),s.end());
    return s;
}

string es(string s){
    string ans;
    for(int i=0;i<s.size();i++){
        if(s[i]=='['){
            int count=1;
            bool sw=true;
            for(int j=i+1;sw;j++){
                if(s[j]=='[')count++;
                if(s[j]==']')count--;
                if(!count){
                    ans+=rev(es(s.substr(i+1,j-i-1)));
                    i=j;
                    sw=false;
                }
            }
        }
        if(s[i]=='+'||s[i]=='-'){
            bool sw=true;
            for(int j=i+1;sw;j++){
                if(!(s[j]=='+'||s[j]=='-')){
                    char c;
                    int count=0;
                    for(int k=i;k<j;k++){
                        if(s[k]=='+')count++;
                        else count--;
                    }
                    count=(count+26)%26;
                    c=(s[j]=='?'?'?':(char)(s[j]+count));
                    while(c-'Z'>0){
                        c=(char)(c-26);
                    }
                    ans+=c;
                    i=j;
                    sw=false;
                }
            }
        }
        else if(s[i]=='?'||(s[i]-'A'>=0&&'Z'-s[i]>=0)){
            ans+=s[i];
        }
    }
    
    return ans;
    
}


void solve(string s){
    cout<<answer(es(s))<<endl;
}

int main(){
    string s;
    while(cin>>s,s!="."){
        solve(s);
    }
}



Measured memory_bytes: 3212
import math
def equal(x,y,z):
    return x**2 + y**2 + z**2 +x*y+y*z+z*x

N = int(input())
ans = [0 for _ in range(10050)]
for x in range(1,105):
        for y in range(1,105):
            for z in range(1,105):
                v = equal(x,y,z)
                if v < 10050:
                    ans[v]+=1
for i in range(N):
    print(ans[i+1])


Measured memory_bytes: 9236
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for (int i = 0; i < length; i++) {
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch) == true){
                    answer += Character.toUpperCase(ch);
                }else if(Character.isUpperCase(ch) == true){
                    answer += Character.toLowerCase(ch);
                }else{
                    answer += ch;
                }
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31484
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var b = xArray(0,1e6+1);
  for(var i = 0; i < n; i++){
    var a = next();
    b[a]++;
  }
  var ans = 0;
  for(var i = 1; i <= 1e6; i++){
    if(b[i] === 0)continue;
    if(b[i] === 1)ans++;
    for(var j = i+i; j <= 1e6; j+=i)b[j] = 0;
  }
  return ans;
}

Measured memory_bytes: 61604
NIL = -1
class Node():
    def __init__(self, val):
        self.val = val
        self.parent = NIL
        self.left = NIL
        self.right = NIL
    def __str__(self):
        return "val:{}, parent:{}, left:{}, right:{}".format(self.val, self.parent, self.left, self.right)
        
class Tree():
    def __init__(self):
        self.Nodes = {}
        self.Nodes[NIL] = Node(NIL)
        self.root = self.Nodes[NIL]
        
    def insert(self, node):
        y = self.Nodes[NIL]
        x = self.root
        while x.val != NIL:
            y = x
            if(node.val < x.val):
                x = self.Nodes[x.left]
            else:
                x = self.Nodes[x.right]
        node.parent = y.val
        
        if(y.val == NIL):
            self.root = node
        elif(node.val < y.val):
            y.left = node.val
        else:
            y.right = node.val
        self.Nodes[node.val] = node
    
    def find(self, x):
        cur_n = self.root
        while (cur_n.val != NIL and cur_n.val != x):
#             print(x, cur_n)
            if(x < cur_n.val):
                cur_n = self.Nodes[cur_n.left]
            else:
                cur_n = self.Nodes[cur_n.right]
        return "yes" if cur_n.val != NIL else "no"

    def getPreOrder(self):
        return self.preParse(self.root.val, [])    
        
    def getInOrder(self):
        return self.inParse(self.root.val, [])
    
    def getPostOrder(self):
        return self.postParse(self.root.val, [])
        
    def inParse(self, u, res):
        if(u == NIL):
            return
        self.inParse(self.Nodes[u].left, res)
        res += [u]
        self.inParse(self.Nodes[u].right, res)
        return res

    def postParse(self, u, res):
        if(u == NIL):
            return
        self.postParse(self.Nodes[u].left, res)
        self.postParse(self.Nodes[u].right, res)
        res += [u]
        return res
    
    def preParse(self, u, res):
        if(u == NIL):
            return 
        res += [u]
        self.preParse(self.Nodes[u].left, res)
        self.preParse(self.Nodes[u].right, res)
        return res
        
n = int(input())

tree = Tree()
for row in range(n):
    operate = input().split()
    if(operate[0] == "insert"):
        tree.insert(Node(int(operate[1])))
        
    if(operate[0] == "print"):
        print(" {}".format( " ".join([str(ss) for ss in tree.getInOrder()])))
        print(" {}".format( " ".join([str(ss) for ss in tree.getPreOrder()])))
        
    if(operate[0] == "find"):
        print(tree.find(int(operate[1])))


Measured memory_bytes: 135916
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int inf=1000000000;
int f[105][15];
int main( )
{
  int i,j,x,n=read( );
  for(i=1;i<=9;i++) f[0][i]=-inf;
  for(i=1;i<=n;i++)
    {
      for(j=0;j<=9;j++) f[i][j]=f[i-1][j];
      x=read( );
      for(j=0;j<=9;j++) f[i][j]=max(f[i][j],f[i-1][((j-x)%10+10)%10]+x);
    }
  int ans=0;
  for(j=1;j<=9;j++) ans=max(ans,f[n][j]);
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
#define modm 1000000007
int sumDigit(int n){
	int sum=0;
	while(n){
		sum+=n%10;
		n=n/10;
	}
	return sum;
}
	
//Sourav Mondal
int main(){
	int t;
	cin>>t;
	if(t%1000==0)
	cout<<0<<endl;
	else
	{
		for(int i=1;i<11;i++){
			if(i*1000>=t){
				cout<<abs(t-(i*1000))<<endl;
				break;
			}
		}
	}
	return 0;
}
			


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

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

Measured memory_bytes: 256
/**********************************************
 *Author*        :XzzF
 *Created Time*  : 2018/8/12 16:06:52
 *Ended  Time*  : 2018/8/12 16:28:30
*********************************************/

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <unordered_map>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100000;

int N;
LL M;
LL a[MaxN + 5], sum[MaxN + 5];

unordered_map <LL, LL> mp;

int main()
{
	while(scanf("%d %lld", &N, &M) != EOF)
	{
		sum[0] = 0LL;
		for(int i = 1; i <= N; i++) {
			scanf("%d", &a[i]);
			sum[i] = sum[i - 1] + a[i];
		}
		LL ans = 0LL;
		mp[0]++;
		for(int i = 1; i <= N; i++) {
			LL tmp = sum[i] % M;
			ans += mp[tmp];
			mp[tmp]++;
		}
		//for(int i = 1; i <= N; i++)
		//	if(a[i] % M == 0) ans++;
		printf("%lld\n", ans);
		mp.clear();
	}
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

std::string to_binString(unsigned int val)
{
  std::string str = "";
  while( val != 0 ) {
    if( (val & 1) == 0 )
      str.insert(str.begin(), '0');
    else
      str.insert(str.begin(), '1');
    val >>= 1;
  }
  while(str.size()<7){
    str = "0" + str;
  }
  return str;
}

const int bit[10] = {126,48,109,121,51,91,95,114,127,123};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
//   rep(i,10){
//     cout << i << " " +to_binString(bit[i])<<endl;
//   }
  ll n;
  while(cin >> n && n != -1){
    ll a;
    int state = 0;
    rep(i,n){
      cin >> a;
      auto s = to_binString(state ^ bit[a]);
      reverse(all(s));
      cout << s <<endl;
      state = bit[a];
    }
  }
  return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
using P=pair<int,int>;


int main(){
  int h,w,m;
  cin >> h >> w >> m;
  //vector<pair<int,int>> hw(m);
  map<P,int> mp;
  vector<int> yoko(w,0),tate(h,0);
  int hnum=-1;
  int wnum=-1;
  for(int i=0;i<m;++i){
    int h,w;
    cin >> h >> w;
    h--;
    w--;
    mp[P(h,w)]++;
    tate[h]++;
    yoko[w]++;
  }
  int hid;
  vector<int> hkouho;
  for(int i=0;i<h;++i) hnum=max(hnum,tate[i]);
  for(int i=0;i<w;++i) wnum=max(wnum,yoko[i]);
  for(int i=0;i<h;++i){
    //cout << tate[i] << endl;
    if(hnum==tate[i]){
      hkouho.push_back(i);
    }
  }
  //for(int i=0;i<hkouho.size();++i) cout << hkouho[i] << endl;
  int wid;
  vector<int> wkouho;
  for(int i=0;i<w;++i){
    //cout << yoko[i] << endl;
    if(wnum==yoko[i]) wkouho.push_back(i);
  }
  int ans=hnum+wnum;
  //cout << ans << endl;
  bool ok=false;
  for(int i=0;i<hkouho.size();++i){
    for(int j=0;j<wkouho.size();++j){
      //cout << mp[P(hkouho[i],wkouho[j])] << endl;
      if(ok){
        i=hkouho.size()+1;
        break;
      }else{
        if(mp[P(hkouho[i],wkouho[j])]==0){
          ok=true;
        }
      }
    }
  }
  if(!ok) ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 28444
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const double INF3 = 900000000000000;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()



int main() {
	int n, m, x, ansa = 0, ansb = 0;
	cin >> n >> m >> x;
	bool b[10000] = {0};
	for (int i = 0;i < m;i++) {
		int a;
		cin >> a;
		b[a] = true;
	}
	for (int i = x-1;i >= 0;i--) {
		if (b[i])ansa++;
	}
	for (int i = x + 1;i <= n;i++) {
		if (b[i])ansb++;
	}
	cout << min(ansa, ansb) << endl;
}

Measured memory_bytes: 256
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(int i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	int a[h][w];
	rep(i, 0, h) rep(j, 0, w) scanf("%d", &a[i][j]);
	rep(i, 0, h) rep(j, 0, w){
		int b;
		scanf("%d", &b);
		a[i][j] = abs(a[i][j]-b);
	}

	std::vector<std::vector<std::bitset<15000>>> dp(h, std::vector<std::bitset<15000>>(w));
	dp[0][0].set(0);
	rep(i, 0, h) rep(j, 0, w) {
		rep(k, 0, 15000) if(dp[i][j][k]) {
			if(j<w-1){
				dp[i][j+1].set(k+a[i][j]);
				dp[i][j+1].set(abs(k-a[i][j]));
			}
			if(i<h-1){
				dp[i+1][j].set(k+a[i][j]);
				dp[i+1][j].set(abs(k-a[i][j]));
			}
		}
	}
		
	int ans = 15000;
	rep(i, 0, 15000){
		if(dp[h-1][w-1][i]) ans = std::min({ans, i+a[h-1][w-1], abs(i-a[h-1][w-1])});
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 12288
#include<stdio.h>

int n,A[50];

solve(int i,int m){
	int res;
	if(m == 0){
		return 1;
	}
	if(i >= n){
		return 0;
	}
	res = solve(i + 1,m) || solve(i + 1,m - A[i]);
	return res;
}
int main(void){
	int q,M,i;
	
	scanf("%d",&n);
	for(i = 0; i < n; i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i = 0; i < q; i++){
		scanf("%d",&M);
		if(solve(0,M)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 1792
t1,n1=map(int,input().split())
t2,n2=map(int,input().split())
t3,n3=map(int,input().split())
t4,n4=map(int,input().split())

def keisan(t,n):
    if t==1:
        return(n*6000)
    elif t==2:
        return(n*4000)
    elif t==3:
        return(n*3000)
    else:
        return(n*2000)

print(keisan(t1,n1))
print(keisan(t2,n2))
print(keisan(t3,n3))
print(keisan(t4,n4))


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define INF INT_MAX
#define INFLL _I64_MAX
#define MOD 1000000007
#define PI 3.1415926535
using namespace std;
int main(void)
{
	int n, y, t, x[3];

	cin>>n>>y;

	t=y/1000-n;

	bool flag=false;
	
	rep(i, n+1){
		rep(j, n+1){
			int k=n-i-j;
			if(k>=0&&10000*i+5000*j+1000*k==y){
				x[0]=i; x[1]=j; x[2]=k;
				flag=true; break;
			}
		}
		if(flag) break;
	}
	if(flag){
		cout<<x[0]<<" "<<x[1]<<" "<<x[2]<<endl;
	}else{
		cout<<-1<<" "<<-1<<" "<<-1<<endl;
	}

}



Measured memory_bytes: 256
n = int(input())
l = input()
l = l.split()
a = 0
b = 1
c = 2
e = [0]
for d in range(int(n*(n-1)*(n-2)/6)):
    e.append(int(l[a]))
    e.append(int(l[b]))
    e.append(int(l[c]))
    if b == n - 2 and c == n - 1:
        a = a + 1
        b = a + 1
        c = a + 2
    elif c == n - 1:
        b = b + 1
        c = b + 1
    else:
        c = c + 1
j = 0
for f in range(int((len(e)-1)/3)):
    g = e[f*3+1]
    h = e[f*3+2]
    i = e[f*3+3]
    if g != h and h != i and g != i:
        if g + h > i and h + i > g and g + i > h:
            j = j + 1
print(j)

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<bool>d(10,true);
  for(int i = 0;i < k;i++){
    int a;
    cin >> a;
    d[a] = false;
  }
  for(int i = n;i <= 1000000;i++){
    string s = to_string(i);
    bool ok = true;
    for(int j = 0;j < s.size();j++){
      if(!d[s[j]-'0']) ok = false;
    }
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i;
  char c,x[1202];


  for(i=0;i<1201;i++){
    scanf("%c",&c);
    x[i]=c;
    if(c =='\n'){
      x[i+1]='\0';
      break;
    }
  }

  for(i=0;i<1201;i++){
    if('A'<=x[i] && x[i]<='Z'){
      x[i]=x[i]-'A'+'a';
    }else if('a'<=x[i] && x[i]<='z'){
      x[i]=x[i]-'a'+'A';
    }
  }
  printf("%s",x);
  return 0;
}

Measured memory_bytes: 536