akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

typedef pair<int, int> P;
const int INF = 10000000;

int mh[4] = {-1, 0, 1, 0};
int mw[4] = {0, -1, 0, 1};

void Main() {
  int H, W;
  cin >> H >> W;

  int Ch, Cw, Dh, Dw;
  cin >> Ch >> Cw >> Dh >> Dw;
  Ch--; Cw--; Dh--; Dw--;

  char S[H][W];
  int d[H][W];
  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      cin >> S[h][w];
      d[h][w] = INF;
    }
  }

  d[Ch][Cw] = 0;
  deque<P> q;
  q.push_front(P(Ch, Cw));
  while (!q.empty()) {
    P p = q.front(); q.pop_front();
    int h = p.first, w = p.second;
    for (int i = 0; i < 4; i++) {
      int nh = h + mh[i], nw = w + mw[i];
      if (nh >= 0 && nh < H && nw >= 0 && nw < W && S[nh][nw] == '.') {
        if (d[nh][nw] > d[h][w]) {
          d[nh][nw] = d[h][w];
          q.push_front(P(nh, nw));
        }
      }
    }

    for (int y = -2; y <= 2; y++) {
      for (int x = -2; x <= 2; x++) {
        int nh = h + y, nw = w + x;
        if (nh >= 0 && nh < H && nw >= 0 && nw < W && S[nh][nw] == '.' && d[nh][nw] == INF) {
          if (d[nh][nw] - d[h][w] > 1) {
            d[nh][nw] = d[h][w] + 1;
            q.push_back(P(nh, nw));
          }
        }
      }
    }
  }

  if (d[Dh][Dw] == INF) cout << -1 << endl;
  else cout << d[Dh][Dw] << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}




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

int main() {
  int N, K;
  cin >> N >> K;
  int X = 1;
  int i = 0;
  
	for ( ; i < N && X < K ; i++) X *= 2;
    
  	for ( ; i < N ; i++) X += K;
  
  cout << X << endl;
  
}


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

int main(){
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for(int A=0; A<=K; A++){
    for(int B=0; B<=K; B++){
      if(0<=S-A-B && S-A-B<=K){
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
using ll = long long;

const int mx = 1e5+5;
const int inf = 1e9+9;
const int mod = 1e9+7;

int main(int argc, const char** argv) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll k, n; cin >> k >> n;

    ll v = 0, tot = 0;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i) {
            ll x = (a[i]-a[i-1]);
            v = max(v, x);
            tot += x;
        }
    }

    ll x = (k - a[n-1] + a[0]);
    v = max(v, x);
    tot += x;

    tot -= v;
    cout << tot << '\n';

    return 0;
}

Measured memory_bytes: 1792
#define taskname ""
#include <bits/stdc++.h>

using namespace std;

const int maxN = 1e5;

const int up = 1e6;
const int dw = -1e6;

int k, x;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> k >> x;
    for (int i = max(dw, x - k + 1); i <= min(up, x + k - 1); ++i)
    {
        cout << i << ' ';
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

bool less_than(pair<long long, long long> &a, pair<long long, long long> &b) {
    return a.second < b.second;
}

int main() {
    long long n, m; cin >> n >> m;
    vector<long long> a(n), b(n);
    rep (i, n) cin >> a[i] >> b[i];

    vector<pair<long long, long long>> ca(n), cb(n);
    rep (i, n) ca[i] = make_pair(a[i], a[i]);
    rep (i, n) cb[i] = make_pair(b[i], a[i]);

    sort(ca.begin(), ca.end(), less_than);
    sort(cb.begin(), cb.end(), less_than);

    long long ans = 0;
    long long ttl = m;

    rep (i, n) {
        // num: Number of drinks what I can buy
        //
        // ideal: m
        // real: cb[i].first
        long long num = min(ttl, cb[i].first);
        long long prc = num * ca[i].first;

        ans += prc;
        ttl -= num;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define lgt length()
#define sz size()
#define REP(i, n) for(int i = 0; i < n; i++)
#define SORT(v) sort(v.begin(), v.end())
#define veci(a, n) vector<int> a(n)
#define vecs(a, n) vector<string> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define SP(n) cout << setprecision(n) << fixed

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(0, min(B, D) - max(A, C)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vull = vector<ull>;
#define rep(i, n) for (ull i = 0; i < n; ++i)
#define rep1(i, n) for (ull i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}
template <typename T> void arrout(const T arr, ull n) {
  for (ull i = 0; i < n; ++i, cout << (i != n ? " " : "\n")) {
    cout << arr[i];
  }
}

template <typename T>
class UnionFind {
private:
  vector<T> parent,rank,size;
  T root(T k) {
    if(parent[k]==k) return k;
    else return parent[k]=root(parent[k]);
  }

public:
  UnionFind(T n) {
    parent.resize(n);
    rep(i,n) parent[i]=i;
    rank.resize(n,0);
    size.resize(n,1);
  }

  bool is_same(T i,T j) {return root(i)==root(j);}

  T get_size(T k) {return size[root(k)];}

  void unite(T i,T j) {
    i=root(i); j=root(j);
    if(i==j) return;
    if(rank[i]>rank[j]) {
      parent[j]=i;
      size[i]+=size[j];
    } else {
      parent[i]=j;
      size[j]+=size[i];
      if(rank[i]==rank[j]) rank[j]++;
    }
  }

};

void solve() {
  // main coding
  ll n,m; cin>>n>>m;
  vector<pll> ab;
  ll a,b;
  rep(i,m) {
    cin>>a>>b;
    ab.emplace_back(--a,--b);
  }
  // calculate
  UnionFind<ll> tree(n);
  vll ans;
  ll score=n*(n-1)/2;
  ans.pb(score);
  for(auto it=--ab.end();it!=ab.begin();--it){
    a=it->fi; b=it->se;
    if(not tree.is_same(a,b)){
      score-=tree.get_size(a)*tree.get_size(b);
      tree.unite(a,b);
    }
    ans.pb(score);
  }
  // output
  reverse(ans.begin(),ans.end());
  iter(it,ans) cout<<*it<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 7024
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool flag = true;
    if(s[0]!='A')flag = false;
    int cnt = 0;
    FOR(i,2,n-1){
        if(s[i]=='C')cnt++;
    }
    if(cnt!=1)flag = false;
    FOR(i,1,n){
        int c = s[i];
        if(('a'<=c&&c<='z')||c=='C'){
            
        }else{
            flag = false;
        }
    }
    if(flag){
        put("AC");
    }else{
        put("WA");
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMedianSum solver = new CMedianSum();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMedianSum {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];

            int sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                sum += a[i];
            }

            BigInteger possible = BigInteger.ONE; // possible[0] = 1

            for (int x : a) {
                possible = possible.or(possible.shiftLeft(x));
            }

            for (int i = (sum + 1) / 2; ; i++) {
                if (possible.testBit(i)) {
                    out.println(i);
                    return;
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 222384
#include <stdio.h>

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

int main() {
    int n, A[200000+1];
    scanf("%d", &n);
    for (int i=0;i<n;i++) {
        scanf("%d", &A[i]);
    }
    int minv = A[0];//min{A[0],A[1],...,A[j-1]}

    //let p[k] be max profit when sell at time k
    int maxp = A[1]-A[0]; //max{p[1],p[2],...,p[j-1]}

    for (int j=1;j<n;j++){
        maxp = max(maxp, A[j]-minv);
        minv = min(minv, A[j]);
    }
    printf("%d\n", maxp);
    
        
    return 0;
}



Measured memory_bytes: 3532
n,k=map(int,input().split())

d = [i for i in range(10)]
din = list(map(int,input().split()))

for i in din:
    d.remove(i)

flg = 0

for i in range(n,100000):
    for j in range(len(din)):
        #嫌いな数値が居た場合
        if str(din[j]) in str(i):
            flg=1
            break
    if flg == 0:
        print(i)
        break
    else:
        flg=0
    


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B;
	cin >> A >> B;
	cout << (A + B) / 2 + bool((A + B) % 2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

    int H,W;
    cin >> H >> W;
    string a[H];
    for(int i = 0; i < H; i++){
        cin >> a[i];
    }

    vector<int> tate_eraser;
    vector<int> yoko_eraser;

    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            if(a[j][i] == '#'){
                break;
            }
            if(j == H-1){
                tate_eraser.push_back(i);
                //cout << "tate : " << i << endl;
            }
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(a[i][j] == '#'){
                break;
            }
            if(j == W-1){
                yoko_eraser.push_back(i);
                //cout << "yoko : " << i << endl;
            }
        }
    }


    string gyou_result = ""; 

    for(int i = 0; i < H; i++){
        //cout << i << endl;
        if(find(yoko_eraser.begin(), yoko_eraser.end(),i) != yoko_eraser.end()){
            continue;
        }
        for(int j = 0; j < W; j++){
            if(find(tate_eraser.begin(), tate_eraser.end(),j) != tate_eraser.end()){
            continue;
            }
            gyou_result += a[i][j];
        }
        cout << gyou_result << endl;
        gyou_result = "";
    }

    return 0;

}


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

int main () {
  long long  A, B, C, K;
  cin >> A >> B >> C >> K;
  long long ans = 0;
  if (K >= A){
    ans += A;
    K -= A+B;
    if (K >= 0) ans -= K;
    cout << ans << endl;
  }
  else cout << K << endl;
}


Measured memory_bytes: 3632
import sys

DBG =  not True

def g(x):
    y = x%4
    if y==0:
        return x
    elif y==1:
        return 1
    elif y==2:
        return x+1
    elif y==3:
        return 0

a,b = map(int, input().split())
ret = g(b)^g(a-1)
if DBG:
    print('b {} a-1 {} gb {} ga1 {} ret {}'.format(
                              b,a-1,g(b),g(a-1),ret))
print(ret)


Measured memory_bytes: 38256
import sys
import math

n = int(sys.stdin.readline())


def koch(st, en):

    st_x, st_y = st[0], st[1]
    en_x, en_y = en[0], en[1]

    p1_x, p1_y = (2 * st_x + en_x) / 3, (2 * st_y + en_y) / 3
    p2_x, p2_y = (st_x + 2 * en_x) / 3, (st_y + 2 * en_y) / 3

    vec_x, vec_y = (p2_x - p1_x, p2_y - p1_y)  # vec p1->p2

    # 60°回転
    vec_r_x = vec_x * math.cos(math.pi / 3) - vec_y * math.sin(math.pi / 3)
    vec_r_y = vec_x * math.sin(math.pi / 3) + vec_y * math.cos(math.pi / 3)

    p3_x = vec_r_x + p1_x
    p3_y = vec_r_y + p1_y

    return (p1_x, p1_y), (p3_x, p3_y), (p2_x, p2_y)


def koch_r(n, st, en):
    if n == 0:
        return
    
    s, u, t = koch(st, en)
    
    koch_r(n - 1, st, s)
    print(f"{s[0]:f} {s[1]:f}")
    koch_r(n - 1, s, u)
    print(f"{u[0]:f} {u[1]:f}")
    koch_r(n - 1, u, t)
    print(f"{t[0]:f} {t[1]:f}")
    koch_r(n - 1, t, en)


st, en = (0, 0), (100, 0)

print(f"{st[0]:f} {st[1]:f}")
koch_r(n, st, en)
print(f"{en[0]:f} {en[1]:f}")



Measured memory_bytes: 5796
#coding:utf-8
data = input()
xmax = len(data)
data_list = list(data)
data_list.reverse()
reverse_data = []
for sig in data_list:
    if sig == "\\":
        reverse_data.append("/")
    elif sig == "/":
        reverse_data.append("\\")
    else:
        reverse_data.append(sig)

reverse_data = "".join(reverse_data)


def partialSqu(h, sig):
    if sig == "\\":
        squ = h + 1/2
        h += 1
    elif sig == "/":
        squ = h - 1/2
        h -= 1
    elif sig == "_":
        squ = h
    return squ, h


x_squ_dict = {}
cnt = 0
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in data:
    x += 1
    if sw == 0 and sig == "\\":
        sw = 1
    if sw == 1 :
        squ, h = partialSqu(h, sig)
        totalSqu += squ
        
        if h == 0:
            x_squ_dict[x] = totalSqu
            totalSqu = 0
            sw = 0



keys = x_squ_dict.keys()
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in reverse_data:
    x += 1
    if sw == 0 and sig == "\\" :
        sw = 1
        x_p = xmax - x +1
    if sw == 1 :
        squ, h = partialSqu(h, sig)
        totalSqu += squ            
        if h == 0:
            x_squ_dict[x_p] = totalSqu
            totalSqu = 0
            sw = 0


keys = x_squ_dict.keys()
keys = list(keys)
keys.sort()
squ_list = []
for key in keys:
    squ_list.append(x_squ_dict[key])
    
a = int(sum(squ_list))
print(a)    
squ_list.insert(0,len(keys))

squ_list = " ".join([str(int(num)) for num in squ_list])
print(squ_list)





Measured memory_bytes: 6200
import sys
from bisect import bisect_left

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
XY = [lr() for _ in range(N)]
V = list(range(2 * 10**5 + 1)) # 1-indexed X coordinate、Y coordinateの順番

# Aでxの根を求める
def find(A,x):
    p = A[x]
    if p == x: return x
    a = find(A,p)
    A[x] = a
    return a
# Aでxとyの属する集合の併合
def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[by] = bx # 根をbxに統一

for x, y in XY:
    y += 10**5
    if find(V, x) != find(V, y):
        union(V, x, y)

set_V = [set() for _ in range(2 * 10**5 + 1)] # 1-indexed
for x, y in XY:
    root = find(V, x)
    set_V[root] |= set([x, y+10**5])

set_V = [x for x in set_V if x]
answer = 0
for z in set_V:
    z = sorted(list(z))
    cnt_x = bisect_left(z, 10 ** 5 + 1)
    cnt_y = len(z) - cnt_x
    answer += cnt_x * cnt_y

answer -= N
print(answer)
# 48

Measured memory_bytes: 87752
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N =  int(sys.stdin.readline())
L =  list(map(int, sys.stdin.readline().split()))

def div_num(x):
    cnt = 0
    while x > 0:
        if x % 2 == 0:
            cnt += 1
            x //= 2
        else:
            break
    return cnt

print(sum([div_num(x)  for x in L]))

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

using ll=long long;

int main() {
  string S;
  char p;
  int i,c=1,t=0,a,b;
  bool x=1;
  ll K,r;
  cin >> S >> K;

  p = S[0];
  for(i=1; i<S.size(); i++) {
    if(S[i] == p)
      c++;
    else {
      if(x) {
        a = c;
        x = 0;
      }
      t += c/2;
      c = 1;
    }
    p = S[i];
  }
  b = c;
  t += c/2;

  if(c == S.size())
    r = S.size()*K/2;
  else {
    r = t*K;
    if(S[0] == S[S.size()-1])
      r -= (a/2+b/2-(a+b)/2)*(K-1);
  }

  cout << r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  int a[n + 5], x[n + 5][n + 5], y[n + 5][n + 5];
  rep(i, n){
    cin >> a[i];
    rep(j, a[i]){
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  bool out;
  rep(bit, (1 << n)){
    out = false;
    rep(i, n){
      if(bit & (1 << i)){
	rep(j, a[i]){
	  if(bit & (1 << x[i][j] - 1)){
	    if(y[i][j] == 0){
	      out = true;
	    }
	  } else {
	    if(y[i][j] == 1){
	      out = true;
	    }
	  }
	}
      }
    }
    if(!out){
      ans = max(ans, __builtin_popcount(bit));
    }
  }
  cout << ans << '\n';
  return 0;
}


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

long long f(long long n)
{
    if(n < 0) return 0;
    long long k = ((n + 1) / 2) % 2;
    if(n % 2 == 1) return k;
    else {
        if(k == 0) return n;
        else       return n + 1;
    }
}

int main()
{
    long long a, b, k = 0;
    cin >> a >> b;
    cout << (f(a-1) ^ f(b)) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
 
r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')
 
ans = r_cnt * g_cnt * b_cnt
 
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
 
print(ans)

Measured memory_bytes: 68092
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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 (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N;
    string S;
    VLL A(N);
    ll H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << (H2-H1)*60+(M2-M1)-K << endl;

}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define sc second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int jc[100005];
int ext_gcd(int a,int b,int &x,int &y){
    if(b==0){x=1;y=0;return a;}
    int q=a/b, g=ext_gcd(b,a-q*b,x,y), z=x-q*y;
    x=y; y=z;
    return g;
}
int inv(int a){
    int x,y;
    ext_gcd(a,mo_num,x,y);
    return (x+mo_num)%mo_num;
}
void init(int *x, int len){
    x[0]=1;
    for(int i=1;i<len;i++)x[i]=(x[i-1]*i)%mo_num;
}

int C(int r,int n){
    if(n<0||n<r||r<0)return 0;
    return (jc[n]*inv(jc[r])%mo_num)*inv(jc[n-r])%mo_num;
}

int32_t main(){
    int k,n;
    cin>>n>>k;
    init(jc,2001);
    for(int i=1;i<=k;i++){
        out(C(i,n-k+1)*C(i-1,k-i+i-1)%mo_num)
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string a;
    //文字列a
    string b;
    //文字列b
    cin >> a >> b;
    if (a == "H" && b == "H"){
        cout << "H" << endl;
    } else if (a == "H" && b == "D"){
        cout << "D" << endl;
    } else if (a == "D" && b == "D"){
        cout << "H" << endl;
    } else if (a == "D" && b == "H"){
        cout << "D" << endl;
    }
}

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]
s = [[0] * W] + s + [[0] * W]

for i in range(H + 2):
    s[i] = [0] + s[i] + [0]

for i in range(H):
    for j in range(W):
        if s[i + 1][j + 1] == '#':
            if s[i][j + 1] != '#' and s[i + 2][j + 1] != '#' and s[i + 1][j] != '#' and s[i + 1][j + 2] != '#':
                print('No')
                exit()
        else:
            continue
print('Yes')

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

    int n; std::cin >> n;
    vi a(n); rep(i, n) std::cin >> a[i];
    sort(rng(a));
    const int MAX = 1e6+5;
    vi cnt(MAX);
    int ans = 0;
    rep(i, n) {
        int c = 1;
        while (i+1 < n && a[i] == a[i+1]) i++, c++;
        int ai = a[i];
        for (int j = ai; j < MAX; j+=ai) {
            cnt[j] += c;
        }
        if (cnt[ai] == 1) ans++;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 7924
N = int(input())
T = list(map(int, input().split()))
M = int(input())
px = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    id = px[i][0]-1
    if id >= 1:
        print(sum(T[:id]) + sum(T[id+1:]) + px[i][1])
    else:
        print(sum(T[id+1:])+px[i][1])


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

int main() {
	string S;
	cin >> S;
	long long ans = 0, cntb = 0;
	for (long long i = 0; i < S.size(); i++) {
		if (S[i] == 'B') {
			cntb++;
		} else if (S[i] == 'W') {
			ans += cntb;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int rem = A - 2 * B;

        if(rem <= 0){
          System.out.print(0);
        }else{
          System.out.print(rem);
        }
    }
}

Measured memory_bytes: 23124
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

dp=[[0 for i in range(w+1)] for j in range(n+1)]

for i in range(n):
 for sum_w in range(w+1):

  if sum_w-l[i][0]>=0:
   dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-l[i][0]]+l[i][1])

  dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w])

print(dp[-1][-1])

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

using namespace std;

int n,k,c,t[100010];
int p=1,cnt=1,tb;

int main(){
	scanf("%d%d%d",&n,&c,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&t[i]);
	}
	sort(t+1,t+n+1);
	tb=t[1]+k;
	for(int i=2;i<=n;i++){
		if(t[i]>tb||p==c){
			cnt++;
			tb=t[i]+k;
			p=1;
		}
		else p++;
	}
	printf("%d",cnt);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string str;
    int countA,countB,countO,countAB;
    countA=0;
    countB=0;
    countO=0;
    countAB=0;
    while (cin>>str) {
        char s = str.at(str.size()-1);
        if (s=='B' && str.at(str.size()-2)=='A') {
            countAB++;
        } else if (s=='A') {
            countA++;
        } else if (s=='B') {
            countB++;
        } else if (s=='O') {
            countO++;
        }
    }
    cout<<countA<<endl;
    cout<<countB<<endl;
    cout<<countAB<<endl;
    cout<<countO<<endl;
}



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

int main(){
    string str;
    while(cin>>str){
        for(int i=0;i<str.length();i++){
            if(str[i]=='@'){
                int c=str[i+1]-'0';
                while(c--)cout<<str[i+2];
                i+=2;
                continue;
            }
            cout<<str[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long long int n,k;cin>>n>>k;
    long long int dp[n];
    long long int arr[n];
    for(long long int i=0;i<n;i++)
        cin>>arr[i];
    dp[n-1]=0;    
    for(long long int i=n-2;i>=0;i--){
        dp[i]=1e10;
        long long int p = min(n-1-i,k);
        for(long long int j=1;j<=p;j++){
            dp[i]=min(dp[i],dp[i+j]+abs(arr[i+j]-arr[i]));
        }
    }    
    cout<<dp[0]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


Measured memory_bytes: 1920
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	cin >> N;
	VI A(N);
	int n = N - 1;
	LL ans = 0;
	for (int n = 0; n < N; n++)cin >> A[n];
	if (A[0] != 0) goto failure;
	ans += A.back();
	for (int n = N - 2; n >= 0; n--) {
		if (A[n] - n < A[n + 1] - (n + 1))goto failure;
		if (A[n] - n > A[n + 1] - (n + 1))ans += A[n];
	}
	cout << ans << "\n";
	return 0;
failure:
	cout << -1 << "\n";
	return 0;
}


Measured memory_bytes: 3676
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        BigDecimal[] nums = new BigDecimal[N];
        for (int i = 0; i < N; i++) {
            nums[i] = new BigDecimal(sc.next());
        }
        final BigDecimal limit = new BigDecimal("1000000000000000000");
        final BigDecimal zero = new BigDecimal(0);
        Arrays.sort(nums);
        BigDecimal ans = nums[0];
        if (ans.longValue() == 0) {
            System.out.println(0);
        } else {
            boolean over = false;
            for (int i = 1; i < N; i++) {
                ans = ans.multiply(nums[i]);
                if (limit.subtract(ans).compareTo(zero) < 0) {
                    System.out.println(-1);
                    over = true;
                    break;
                }
            }
            if (!over) {
                System.out.println(ans.longValue());
            }
        }
    }
}

Measured memory_bytes: 65916
#include <stdio.h>

int main()
{
	int i, N, a[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));

	int flag = 0;
	for (i = 1; i <= N; i++) if (a[i] % 2 == 1) flag = 1;
	if (flag == 1) printf("first\n");
	else printf("second\n");
	fflush(stdout);
	return 0;
}

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

using namespace std;
typedef long long ll;
const ll p = 1e9 + 7;
const int N = 2e5 + 100;

ll fact[N],infact[N];
ll qpow(ll a,ll b)
{
    ll res = 1 % p;
    while(b)
    {
        if(b & 1)res = res * a % p;
        b >>= 1;
        a = a * a % p;
    }
    return res % p;
}
ll inv(ll m)
{
    return qpow(m,p-2) % p;
}
void init()
{
    fact[0] = 1,infact[0] = 1;
    for(int i = 1;i < N;i++)
    {
        fact[i] = (fact[i - 1] * i * 1ll) % p;
        infact[i] = inv(fact[i]) % p;
    }
}
ll C(ll m,ll n)
{
    if(m > n)return  0;
    return (fact[n] * infact[n - m] % p) * infact[m] % p;
}
int main()
{
    init();
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = 0;i <= min(k,n-1);i++)
    {
        ans = (ans +  C(i,n) * C(n - i - 1,n - 1) % p) % p;
    }
    cout << ans % p;
    
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;

const LL INF=1<<30;
const LL MOD=1000000007;

    LL memo[90];
    int n;

LL ryuka(int a){
    memo[a]=memo[a-1]+memo[a-2];
    
    if(a==n)return memo[a];
    return ryuka(a+1);
}




int main(){
    memo[0]=2;memo[1]=1;
    cin>>n;
    if(n==1)cout<<1<<endl;
    else
    cout<<ryuka(2)<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[], int N) {
    int i;
    for (int i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertion_sort(int A[], int N) {
    int j, i, v;
    for (int i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}


int main(int argc, char const *argv[])
{
    int N, i, j;
    int A[100];

    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    trace(A, N);
    insertion_sort(A, N);

    return 0;
}



Measured memory_bytes: 2104
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    a, b = map(int, input().split())
    k = (a + b) // 2
    if abs(a - k) == abs(b - k):
        print(k)
    else:
        print('IMPOSSIBLE')


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

int main() {
    int h, w, a, b;
    scanf("%d %d %d %d", &h, &w, &a, &b);
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (i <= h - b) printf("%c", j <= a ? '1' : '0');
            else printf("%c", j > a ? '1' : '0');
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, L, m;
int a[N], to[N];
int block, num, ans;
int nxt[N], val[N], belong[N];
int find(int x)
{
    int l = x + 1, r = n, ans = 0;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (a[mid] - a[x] <= L)
            l = mid + 1, ans = mid;
        else
            r = mid - 1;
    }
    return ans;
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a + 1, a + n + 1);
    scanf("%d%d", &L, &m);
    for (int i = 1; i < n; i++) {
        to[i] = find(i);
    }
    to[n] = n + 1;
    // for(int i=1;i<=n;i++){
    //     cout<<to[i]<<" ";
    // }
    block = sqrt(n);
    num = n / block;
    if (n % block)
        num++;
    for (int i = 1; i <= n; i++) {
        belong[i] = (i - 1) / block + 1;
    }
    for (int i = 1; i < n; i++) {
        int t = i, sp = 0;
        while (belong[t] == belong[i]) {
            t = to[t];
            sp++;
        }
        val[i] = sp;
        nxt[i] = t;
        if (i >= block * (num - 1) + 1) {
            val[i]--;
            nxt[i]--;
        }
    }
    for (int i = 1; i <= m; i++) {
        int x, y;
        ans = 0;
        scanf("%d%d", &x, &y);
        if (x > y)
            swap(x, y);
        while (belong[x] < belong[y]) {
            ans += val[x];
            x = nxt[x];
        }
        while (x < y) {
            x = to[x];
            ans++;
        }
        printf("%d\n", ans);
    }
    //system("pause");
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
int main(){
    Fast;
    ll n;
    cin>>n;
    vector<ll>v(n);
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        ans^=v[i];
    }
    for(int i=0;i<n;i++){
        cout<<(ans^v[i])<<" ";
    }

}


Measured memory_bytes: 4788
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> count_win(n,0);
    for(int i = 0; i < q; i++){
        int a;
        cin >> a;
        count_win[a-1]++;       
    }
    if(k > q){
        for(int i = 0; i < n; i++){
            cout << "Yes" << endl;
        }
        return 0;
    }
    else{
        for(int i = 0; i < n; i++){
            if(q - count_win[i] < k){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
    }

    return 0;
}


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

typedef long long ll;
const ll MAX = 1000000000;

int main() {
    ll S;
    cin >> S;

    ll x1 = 0, y1 = 0, x2 = MAX, y2 = 1;
    ll x3 = (MAX - S % MAX) % MAX;
    ll y3 = (S + x3) / MAX;

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    return 0;
}

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

struct group{
  string name;
  set<string> member;
};

set<string> split(string s, char delimiter){
  set<string> res;
  int prev_split_point = 0;
  for (int i = 0; i < s.length(); i++) {
    while(s[i] != delimiter && i < s.length())i++;
    string add = s.substr(prev_split_point, i - prev_split_point);
    if(!add.empty())res.insert(add);
    prev_split_point = i + 1;
  }
  return res;
}

int main(int argc, char *argv[]){
  int n, p = 0;
  while(cin >> n,n){
    string s;
    group g[n];
    cin >> s;
    p = 0;
    s = s.substr(0, s.length() - 1);
    while(s[p] != ':')p++;
    g[0].name = s.substr(0, p);
    g[0].member = split(s.substr(p + 1), ',');
    for (int i = 1; i < n; i++) {
      cin >> s;
      s = s.substr(0, s.length() - 1);
      p = 0;
      while(s[p] != ':')p++;
      g[i].name = s.substr(0, p);
      g[i].member = split(s.substr(p + 1), ',');
    }
    bool flag = true;
    int i = 0;
    while(flag){
      flag = false;
      for (int i = 1; i < n; i++) {
        if(g[0].member.find(g[i].name) != g[0].member.end()){
          flag = true;
          g[0].member.erase(g[0].member.find(g[i].name));
          for (string ss: g[i].member) {
            g[0].member.insert(ss);
          }
        }
      }
    }
    std::cout << g[0].member.size() << std::endl;
  }
  return 0;
}

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

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int (i) = (int)(initial); (i) < (int)(n); ++(i))
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int (i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int (i) = (int)(initial); (i) > (int)(n); (i)--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}
string alphabet() { return "abcdefghijklmnopqrstuvwxyz"; }

int main() {
	int n = 0;
	cin >> n;
	map<int, map<string, int> > m;
	repeat(i, n) {
		string S = "";
		cin >> S;

		map<string, int> m1;
		for(int j = 0; j < S.length(); j++) {
			string s = S.substr(j, 1);
			m1[s] += 1;
		}

		m[i] = m1;
	}

	string alpha = alphabet();
	string result = "";
	repeat(i, alpha.length()) {
		string s = alpha.substr(i, 1);

		vector<int> num(n, 0);
		for(int j = 0; j < n; j++) {
			num[j] = m[j][s];
		}

		int max_num = *min_element(num.begin(), num.end());
		if (max_num < 1) continue;

		for(int j = 0; j < max_num; j++) {
			result += s;
		}
	}

	cout << result << endl;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int max = 0;
	for(int i = 1; i < n; i++){
		int x[26] = {},y[26] = {};
		for(int j = 0; j < i; j++){
			x[s[j] - 'a']++;
		}
		for(int k = i; k < n; k++){
			y[s[k] - 'a']++;
		}
		int sum = 0;
		REP(i,26){
			if(x[i] > 0 && y[i] > 0){
				sum++;
			}
		}
		if(sum > max)max = sum;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    s[3] = 8 + '0';
    cout << s << endl;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    int N,T,c,t,min_cost = 2000;
    cin >> N >> T;
    rep(N){
        cin >> c >> t;
        if(t <= T) min_cost = min(min_cost, c);
    }
    if(min_cost == 2000){
        cout << "TLE" << endl;
    }else{
        cout << min_cost << endl;
    }
    return 0;
}


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

const int N = 100010;

int a[N], n, len;
map<int, int> cnt;

long long l, r;

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



	for(auto v : cnt) {
		if(v.second >= 2) {
			if(l < v.first)
				l = v.first;
		}
	}

	cnt[l] -= 2;

	for(auto v : cnt) {
		if(v.second >= 2) {
			if(r < v.first)
				r = v.first;
		}
	}

	cout << l * r << "\n";
}

Measured memory_bytes: 4992