akhauriyash/Code-Regression huggingface dataset:
from random import randint, getrandbits
import time
import sys
input = sys.stdin.readline
start = time.time()

def scoring():
    last = [0] * 26
    res = 0
    penalty = 0
    for i in range(D):
        t = out[i]
        res += S[i][t]
        penalty += sc - (i + 1 - last[t]) * C[t]
        res -= penalty
        last[t] = i + 1
    return res

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
out = [randint(0, 25) for _ in range(D)]
sc = sum(C)
score = scoring()
while time.time() < start + 1.80:
    if getrandbits(1):
        d = randint(0, D - 1)
        q = randint(0, 25)
        old = out[d]
        out[d] = q
        tmp = scoring()
        if tmp > score:
            score = tmp
        else:
            out[d] = old
    else:
        d1 = randint(0, D - 2)
        d2 = randint(d1 + 1, min(d1 + 16, D - 1))
        out[d1], out[d2] = out[d2], out[d1]
        tmp = scoring()
        if tmp > score:
            score = tmp
        else:
            out[d1], out[d2] = out[d2], out[d1]
for i in out:
    print(i + 1)

Measured memory_bytes: 82600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	int n,l,c,i,m;
	vector<int> p;
	ll k;
	cin>>n>>k;
	int a[n+1],ind[n+1];
	for(i=0;i<n;i++) 
	{
	cin>>a[i+1];
	ind[i+1]=-1;
	}	
	i=1; c=0;
	while(true)
	{
		if(ind[i]!=-1) { l=ind[i]; break;}
		ind[i]=c++;
		p.pb(i);
		i=a[i];
	}
	if(k<l) cout<<p[k];
	else 
	{
		k-=l;
		m=k%(p.size()-l);
		cout<<p[l+m];
		
	}
	return 0;
}

Measured memory_bytes: 5884
#include<stdio.h>
#include<string.h>
 
#define N 1000001
 
void insert(char *);
void find(char *);
int h(int);
int h2(int);
int h3(char *, int);
 
int ins;
char dict[N][13];
 
int main()
{
  int n, i;
  char str[13];
   
  scanf("%d", &n);
  for(i=0; i<N; i++)
    {
      strcpy(dict[i], "\0");
    }
 
  for(i=0; i<n; i++)
    {
      scanf("%s", str);
       
      if(strcmp(str, "insert") == 0)
    {
      scanf("%s", str);
      insert(str);
    }
      else if(strcmp(str, "find") == 0)
    {
      scanf("%s", str);
      find(str);
    }
    }
  return 0;
}
 
void insert(char *str)
{
  int i=0;
 
  while(strcmp(dict[h3(str, i)], "\0") != 0)
    {
      i++;
    }
  strcpy(dict[h3(str, i)], str);
  ins = i;
  //printf("%d\n", hash(str, i));
}
void find(char *str)
{
  int i=0;
 
  while(1)
    {
      if(strcmp(dict[h3(str, i)], "\0") == 0)
    {
      printf("no\n");
      break;
    }
      else if(strcmp(dict[h3(str, i)], str) == 0)
    {
      printf("yes\n");
      break;
    }
      i++;
    }
}
int h(int k)
{
  return k % N;
}
int h2(int k)
{
  return 1 + k%(N-1);
}
int h3(char *str, int i)
{
  int j, k=0, n=1;
  for(j=0; str[j]!='\0'; j++)
    {
      if(str[j] == 'A')
    {
      k += n*0;
    }
      else if(str[j] == 'C')
    {
      k += n*1;
    }
      else if(str[j] == 'G')
    {
      k += n*2;
    }
      else if(str[j] == 'T')
    {
      k += n*3;
    }
      n *= 4;
    }

   
  return (h(k) + i*h2(k))%N;
}

Measured memory_bytes: 13296
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

class UnionFindFixed{
    vector<int> data;
public:
    UnionFindFixed(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(){
    
    int N,M; cin>>N>>M;
    vector<vector<int>> L;
    REP(i,N){
        vector<int> t;
        int K; cin>>K;
        REP(j,K){
            int tt; cin>>tt;
            t.push_back(tt);
        }
        L.push_back(t);
    }
    
    UnionFindFixed inst(300010);
    
    REP(i,N){
        REP(j,L[i].size()){
            inst.unionSet(i,L[i][j]+200000);
        }
    }
    
    int root=inst.root(0);
    REP(i,N){
        if(inst.root(i)!=root){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout<<"YES"<<endl;
    
    return 0;
}


Measured memory_bytes: 6832
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define inf 0x3f3f3f3f
#define N 500010
using namespace std;
typedef long long ll;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((a*100+b*10+c)%4)puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin>>s;
	vector<int> cnt(3,0);
	for(int i = 0; i < s.size(); i++){
		cnt[s[i]-'a']++;
	}
	int m = *min_element(all(cnt));
	int res=0;
	for(int i = 0; i < 3; i++){
		cnt[i] -= m;
	}
	sort(all(cnt));
	cout<<(cnt[2]<2?"YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin >> b;
  if(b == 'A') cout << 'T';
  if(b == 'C') cout << 'G';
  if(b == 'G') cout << 'C';
  if(b == 'T') cout << 'A';
}


Measured memory_bytes: 256
N = int(input())
A = input().split()
judge = 1 #1:継続, 0:終了
count = 0

while(judge):
  for i in range(N):
   A[i] = int(A[i])
   if(A[i]%2 == 1):
    judge = 0
    break
   else:
    A[i] = A[i]/2
    count += 1

print(int(count/N))

Measured memory_bytes: 3060
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  for (int i = 1; i < n+1; i++)
  {
  p=i/10000+i/1000-10*(i/10000)+i/100-10*(i/1000)+i/10-10*(i/100)+i%10;
  if(a<=p&&p<=b)q+=i;
  }
  print(q)
}

Measured memory_bytes: 3616
n = int(input())

t,a = map(int, input().split( ))

for i in range(n-1):
    ti,ai = map(int, input().split( ))
    coef = max((ti+t-1)//ti,(ai+a-1)//ai)
    t,a = ti*coef,ai*coef
    
    
print(t+a)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
int N;
int ans;
bool D[100010];
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		if (i + 1 == tmp)D[i] = true;
	}
	for (int i = 0; i < N - 1; i++) {
		if (D[i]) {
			D[i] = false;
			ans++;
			if (D[i + 1]) {
				D[i + 1] = false;
			}
		}
	}
	if (D[N - 1])ans++;
	std::cout << ans << std::endl;
	return 0;
}


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

int main(){
    int way[6][2] = {
        {3, 4} ,
        {4, 3} ,
        {1, 4} ,
        {-1, 5} ,
        {3, -1} ,
        {2, 1}
    };

    string p;
    int now;

    while(cin >> p){
        if(p == "#")    break;

        int now = 0;
        for(int i = 0; now != -1 && i < p.length(); i++){
            if(p[i] == '0'){
                now = way[now][0];
            }else if(p[i] == '1'){
                now = way[now][1];
            }
        }

        if(now != 1){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
        
    }

    return 0;
}


Measured memory_bytes: 3156
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,t,dp[100010][110];//dp[max_weight][used items' numbers]
pii wv[110];

int main()
{
	cin>>n>>t;
	rep(i,n) scanf("%I64d%I64d",&wv[i].fi,&wv[i].se);
	sort(wv,wv+n);
	for(int i=wv[0].fi;i<=t;i++) dp[i][0]=wv[0].se;
	rep(i,n) dp[wv[0].fi][i]=wv[0].se;
	repn(i,t)
	{
		repn(j,n-1) if(i-wv[j].fi>=0) dp[i][j]=max(dp[i-wv[j].fi][j-1]+wv[j].se,dp[i][j-1]);
		//,cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
	}
	cout<<dp[t][n-1]<<endl;
	rt0;
}

Measured memory_bytes: 86016
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
minhasuu = 10


if a % 10 != 0:
    minhasuu = a % 10
    a = ((a // 10) + 1) * 10
if b % 10 != 0:
    if minhasuu > b % 10:
        minhasuu = b % 10
    b = ((b // 10) + 1) * 10
if c % 10 != 0:
    if minhasuu > c % 10:
        minhasuu = c % 10
    c = ((c // 10) + 1) * 10
if d % 10 != 0:
    if minhasuu > d % 10:
        minhasuu = d % 10
    d = ((d // 10) + 1) * 10
if e % 10 != 0:
    if minhasuu > e % 10:
        minhasuu = e % 10
    e = ((e // 10) + 1) * 10

print(a + b + c + d + e + minhasuu - 10)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector <int> ans(n + 1, 0);
  REP1(x, 1e2) {
	REP1(y, 1e2) {
	  REP1(z, 1e2) {
		int a = x * x + y * y + z * z + x * y + y * z + z * x;
		if (a <= n) {
			ans[a]++;
		  }
	  }
	}
  }
  REP1(i, n) {
	cout << ans[i] << endl;
  }
  return 0;
}


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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

void swap(int *a, int *b){int tmp=*a;*a=*b;*b=tmp;}

int main(){
  int i, n, col;
  int a, b;
  int res[30];

  memset(res, 0, sizeof(res));
  scanf("%d",&col);
  rep(i,col) res[i] = i+1;

  scanf("%d",&n);
  rep(i,n){
    scanf("%d,%d",&a,&b);
    swap(&res[--a], &res[--b]);
  }

  rep(i,col) printf("%d\n",res[i]);

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
#include <unordered_set>

#define NMAX 100010
#define MOD 1000000007
#define INF 2000000000
#define PI 3.1415926535
#define EPS 1.e10-6

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) > 0 ? (a) : (-a))

typedef unsigned long long ull;

using namespace std;

char str[101];
int n;

int main()
{
	cin >> str;
	n = strlen(str);
	int ans = 0;
	for (int i = 0; i < n / 2; i++)
		if (str[i] != str[n - i - 1])
			ans++;

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (n, m) = nextIntList()
    val work = intAry2(n, 2)
    repeat(n){
        val (a, b) = nextIntList()
        work[it][0] = a
        work[it][1] = b
    }
    work.sortBy { it[0] }

    val queue: PriorityQueue<Int> = PriorityQueue<Int>(n){x: Int, y: Int ->
        return@PriorityQueue y - x
    }

    var index = 0
    var ans = 0
    for (day in 1..m){
        while(index < n){
            if(work[index][0] <= day){
                queue.add(work[index][1])
                index++
            } else {
                break
            }
        }
        if(queue.isNotEmpty()) ans += queue.poll()
    }

    println(ans)

}



fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!
fun swap(a: String, b: String) = Pair<String, String>(b, a)
fun swap(a: Int, b: Int) = Pair<Int, Int>(b, a)
fun swap(a: Long, b: Long) = Pair<Long, Long>(b, a)
fun swap(a: Double, b: Double) = Pair<Double, Double>(b, a)

fun gcd(a: Long, b: Long) : Long = if(a % b == 0L) b else gcd(b, (a % b))

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

const int N = 8;
const bool FREE = false;
const bool NOT_FREE = true;
int row[N];
bool col[N],dpos[2*N-1],dneg[2*N-1];
int skip[N],k;

void init() {
    for(int i=0; i<N; i++) {
        row[i] = -1;
        col[i]=FREE;
    }
    for(int i=0; i<2*N-1; i++) dpos[i]=dneg[i]=FREE;
}

void printBoard() {
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            if(row[i]==j) cout << "Q";
            else cout << ".";
        }
        cout << endl;
    }
}

void putQueen(int i) {
    bool flg = true;
    if(i==N) {
        printBoard();
        return;
    }

    for(int j=0; j<k; j++) {
        if(i == skip[j]) {flg = false; break;}
    }

    if(flg) {
        for(int j=0; j<N; j++) {
            if(col[j] == NOT_FREE ||
               dpos[i+j] == NOT_FREE ||
               dneg[i-j+N-1] == NOT_FREE) continue;
            row[i] = j;
            col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
            putQueen(i+1);
            row[i] = -1;
            col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
        }
    }

    else putQueen(i+1);
}

int main() {
    init();

    cin >> k;
    for(int i=0; i<k; i++) {
        int r,c;
        cin >> r >> c;
        row[r] = c;
        skip[i] = r;
        col[c] = dpos[r+c] = dneg[r-c+N-1] = NOT_FREE;
    }
    putQueen(0);
    return 0;
}



Measured memory_bytes: 3104
#include<iostream>

using namespace std;

int main() {
	int n, a, b[100001]{ 0 };
	cin >> n;
	for (int i = 0; i<n; i++) {
		cin >> a;
		if (a == i + 1)b[i] = 1;
	}
	int cnt = 0;
	for (int i = 0; i < n;) {
		if (b[i]) {
			cnt++;
			i += 2;
		}
		else i++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

const (
	MOD = 998244353
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var W, H, x, y int
	fmt.Scanf("%d %d %d %d\n", &W, &H, &x, &y)

	fmt.Print(float64(W*H)/2, " ")
	if 2*x == W && 2*y == H {
		fmt.Print(1)
	} else {
		fmt.Println(0)
	}
	fmt.Println()
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> as(n);
    for(int i=0; i<n; ++i){
        cin >> as[i];
    }
    unordered_map<int, int> cnt;
    unordered_set<int> ans;
    for(int i=n-1; i>=0; --i){
        if(cnt[i]%2==as[i]) continue;
        ans.insert(i+1);
        for(int j=1; j*j<=(i+1); ++j){
            if((i+1)%j==0){
                if(j*j!=i+1) ++cnt[(i+1)/j-1];
                ++cnt[j-1];
            }
        }

    }
    cout << ans.size() << endl;
    bool first=true;
    for(auto b : ans){
        if(first) first=false;
        else cout << " ";
        cout << b;
    }
    if(ans.size())
        cout << endl;
    return 0;
}



Measured memory_bytes: 16328
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String n=gs();
	    //int a=gi();
	    //int b=gi();
	    //String y=gs();

        System.out.println(n.length()-n.replaceAll("1", "").length());
//        if (()==n.charAt(3))) {
//        	System.out.print("Yes");
//        }else {
//        	System.out.print("No");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35596
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    vector<string> s;
    string temps;
    do{
        cin>>temps;
        if (temps!="0")
            s.push_back(temps);
    }while (temps!="0");
    for (vector<string>::iterator i=s.begin();i!=s.end();i++){
        int sum=0;
        for (int j=0;j<i->length();j++){
            sum+=(*i)[j]-'0';
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1204
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
#$v2 = explode(" ", $stdin[0]);


if($stdin[0] % 2 == 1){
  $ans = "No";
}else{
  
  $split = str_split($stdin[1], $stdin[0] / 2);

  if($split[0] == $split[1]){
    $ans = "Yes";
  }else{
    $ans = "No";
  }
  
}

echo $ans . PHP_EOL;





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

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    string k;
    ll d;
    cin >> k >> d;
    vector<mint> dp(d, 0);

    for(int i = 0; i < k.at(0) - '0'; ++i){
        dp.at(i % d) += 1;
    }
    ll top = (k.at(0) - '0') % d;

    for(int i = 1; i < k.size(); ++i){
        vector<mint> dp2(d, 0);
        for(int j = 0; j < d; ++j){
            for(int x = 0; x <= 9; ++x){
                dp2.at((j + x) % d) += dp.at(j);
            }
        }
        for(int x = 0; x < k.at(i) - '0'; ++x){
            dp2.at((top + x) % d) += 1;
        }
        top = (top + (k.at(i) - '0')) % d;
        dp.swap(dp2);
    }
    cout << dp.at(0) + (top == 0) - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = (int)n-1; i >= 0; i--)
#define ll long long int
#define pb push_back
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  int N, q, M;
  cin >> N;
  vector<int> a(N);
  rep(i, N){
    cin >> a[i];
  }
  vector<bool> sum_a(40001, false);
  // {0, 1, ..., n-1} の部分集合の全探索
  for (int bit = 0; bit < (1<<N); ++bit)
  {
      /* きちんとできていることを確認してみる */
      // bit の表す集合を求める
      vector<int> S;
      for (int i = 0; i < N; ++i) {
          if (bit & (1<<i)) { // i が bit に入るかどうか
              S.push_back(a[i]);
          }
      }

      int sum = 0;
      for (int i = 0; i < (int)S.size(); ++i) {
          sum += S[i];
      }
      sum_a[sum] = true;
      
  }
  cin >> q;
  rep(i, q){
    cin >> M;    
    if(sum_a[M]) print("yes");
    else print("no");
  }
}



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

#define int long long

#define inf 1000000007LL
#define mod 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  rep(i, 1000) {
    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
      cout << i << endl;
      return 0;
    }
    int aw = (b + c) / 2;
    int bw = (a + c) / 2;
    int cw = (a + b) / 2;
    a = aw;
    b = bw;
    c = cw;
  }
  cout << -1 << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<pair<int,int> > p(n, pair<int,int>(0,0));
  for (int i = 0; i < n; i++){
    cin >> p[i].second >> p[i].first;
    p[i].second = -p[i].second;
  }
  sort(p.begin(), p.end(), greater<pair<int,int> >());
  cout << (-p[0].second) << ' ' << p[0].first << endl;
}

Measured memory_bytes: 1204
#include<iostream>
using namespace std;
int main() {
	int a, b, c,x;
	cin >> a >> b >> c;
	if (a != b && a != c && b != c) {
		cout << 3 << endl;
	}
	else if (a == b && a == c && b == c) {
		cout << 1 << endl;
	}
	else {
		cout << 2 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M = 1e9+5 ;
int main()
{
	int m,d;
	cin >> m >> d;
	int f=0;
	for(int i=22;i<=d;i++) {
		if(i/10>=2&&i%10>=2&&(i/10)*(i%10)<=m&&(i/10)*(i%10)>=1) {
			f++;
			//cout <<i<<endl; 
		} 
	}
	cout << f<<endl;
	return 0;
}

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

int main() {
	ll n, m;
	cin >> n >> m;
	if (n % 2 == 1) {
		for (ll i = 0; i < m; ++i) {
			cout << i + 1 << " " << n - i << endl;
		}
	}
	else {
		ll k = m / 2;
		n = m * 2 + 2;
		for (ll i = 0; i < k; ++i) {
			cout << i + 1 << " " << n - i - 1 << endl;
		}
		for (ll i = k; i < m; ++i) {
			cout << i + 2 << " " << n - i - 1 << endl;
		}
	}
}


Measured memory_bytes: 3608
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  auto k = "CODEFESTIVAL2016";
  int cnt;
  foreach (i; 0..s.length) {
    if (s[i] != k[i]) {
      cnt++;
    }
  }
  cnt.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const int INF = 1e+9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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;}

const int MAX_N = 110000;

int dp[MAX_N];

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

  for ( int i = 0; i < MAX_N; i++) dp[i] = N;
  dp[0] = 0;

  for (int n = 0; n < N; n++) {
    for (int pow6 = 1; n+pow6 <= N; pow6 *= 6) {
      dp[n+pow6] = min(dp[n+pow6], dp[n]+1);
    }
    for (int pow9 = 1; n+pow9 <= N; pow9 *= 9) {
      dp[n+pow9] = min(dp[n+pow9], dp[n]+1);
    }
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 640
# D - Candy Distribution

import numpy as np
from collections import defaultdict

N, M = map(int, input().split())
A = np.array(list(map(int, input().split())), np.int64)

C = A.cumsum()
C = np.insert(C,0,0)
remainder = defaultdict(int)

for x in C:
    remainder[x%M] += 1

ans = 0
for key in remainder:
    if remainder[key] >= 2:
        ans += (remainder[key] * (remainder[key] - 1)) // 2

print(ans)

Measured memory_bytes: 23204
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();
		boolean P=false,W=false,G=false,Y=false;
		String S;
		for(int i=1;i<N;i++) {
			S=sc.next();
			if(S.equals("P"))P=true;
			else if(S.equals("W"))W=true;
			else if(S.equals("G"))G=true;
			else if(S.equals("Y"))Y=true;
		}
		if(P && W && G) {
			if(Y)System.out.println("Four");
			else System.out.println("Three");
		}

	}

}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void)
{
	int a,b,tmp,i,w,n;
	int array[30];
	for(i=0;i<30;i++)
	{
		array[i] = i+1;
	}
	scanf("%d",&w);
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d,%d",&a,&b);
		tmp = array[a-1];
		array[a-1] = array[b-1];
		array[b-1] = tmp;
	}
	for(i=0;i<w;i++)
	{
		printf("%d\n",array[i]);
	}
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
using namespace std;

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


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

	if (S == "SUN") {
		cout << 7;
	}
	else if (S == "MON") {
		cout << 6;
	}
	else if (S == "TUE") {
		cout << 5;
	}
	else if (S == "WED") {
		cout << 4;
	}
	else if (S == "THU") {
		cout << 3;
	}
	else if (S == "FRI") {
		cout << 2;
	}
	else if (S == "SAT") {
		cout << 1;
	}

}


Measured memory_bytes: 256
///////////////////////////////////////////////////
/* __                                       __   */
/*|  |--.-----.---.-.----.----.-----.-----.|  |_ */
/*|  _  |  -__|  _  |  __|  __|  -__|  _  ||   _|*/
/*|_____|_____|___._|____|____|_____|   __||____|*/
/*                                  |__|         */
///////////////////////////////////////////////////
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < (limit); counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}setupios;
int main() {

  int n,k;
  cin>>n>>k;
  vector<bool> sunuke(n,false);
  rep(q,k){
    int a;
    cin>>a;
    rep(i,a){
      int b;
      cin>>b;
      sunuke[b-1]=true;
    }
  }
  int ans=0;
  rep(i,sunuke.size()){
    if(!sunuke[i]){
      ans++;
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 3656
import bisect
Q=int(input())
query=[list(map(int,input().split())) for _ in range(Q)]
n = 5*(10**4)
primes = set(range(2, n + 1))
for i in range(2, int(n ** 0.5 + 1)):
    primes.difference_update(range(i * 2, n + 1, i))
primes = list(primes)
#print(primes)
like2019=[]
for k in primes:
    pf = {}
    m = 2*k-1
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1: pf[m] = 1
    #print(pf)
    keys = list(pf.keys())
    values = list(pf.values())
    if (len(values)==1)and(values[0]==1):
        like2019.append(2*k-1)
    #input()
#print(like2019)
for i in range(Q):
    l,r=map(int,query[i])
    lind=bisect.bisect_left(like2019,l-1)
    rind=bisect.bisect_left(like2019,r+1)
    print(rind-lind)

Measured memory_bytes: 85464
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

long long int DP[110000] = {};

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i <= N; i++){
		DP[i] = INF;
	}
	DP[0] = 0;
	
	int v1 = 1;
	for(int i = 0; i < 10; i++){
		for(int j = v1; j <= N; j++){
			DP[j] = min(DP[j], DP[j - v1] + 1);
		}
		v1 *= 6;
	}
	v1 = 1;
	for(int i = 0; i < 10; i++){
		for(int j = v1; j <= N; j++){
			DP[j] = min(DP[j], DP[j - v1] + 1);
		}
		v1 *= 9;
	}
	
	cout << DP[N] << endl;
	
	return 0;
}

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

int main(int argc, char** argv)
{
	int row, column;
	std::cin >> row >> column;

	std::vector<std::vector<int>> mat;
	std::vector<int> finalRow;
	for (int r = 0; r < row; ++r)
	{
		std::vector<int> v;
		int total = 0;
		for (int c = 0; c < column; ++c)
		{
			int tmp;
			std::cin >> tmp;
			v.push_back(tmp);
			total += tmp;
		}

		v.push_back(total);
		mat.push_back(v);
	}

	for (int c = 0; c < column; ++c)
	{
		int total = 0;
		for (int r = 0; r < row; ++r)
		{
			total += mat[r][c];
		}

		finalRow.push_back(total);
	}

	int finalRowSum = 0;
	for (size_t i = 0; i < finalRow.size(); ++i)
	{
		finalRowSum += finalRow[i];
	}
	finalRow.push_back(finalRowSum);
	mat.push_back(finalRow);

	for (int r = 0; r < row + 1; ++r)
	{
		for (int c = 0; c < column + 1; ++c)
		{
			std::cout << mat[r][c];
			if (c < column)
			{
				std::cout << " ";
			}
		}
		std::cout << std::endl;
	}
}


Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

	set<ll> W;
	set<ll> S;

	repe(i, 0, F / 100 * A) {
		repe(j, 0, F / 100 * B) {
			ll v = (i *A + j * B);
			if (v * 100 <= F) {
				W.insert(v * 100);
			}
		}
	}

	rep(i, 0, F / C) {
		rep(j, 0, F / D) {
			ll v = (i *C + j * D);
			if (v <= F) {
				S.insert(v);
			}
		}
	}
	ll maxS = 0;
	ll maxW = 0;
	double maxD = 0;

	for (set<ll>::iterator itw = W.begin(); itw != W.end(); itw++) {
		for (set<ll>::iterator its = S.begin(); its != S.end(); its++) {
			double e = (double)100 * E / (double)(100 + E);
			//if (*itw == 1700 && *its == 956) {
			//	cout << endl;
			//}
			if (*itw + *its == 0 || *itw + *its > F) {
				continue;
			}
			//if (*itw == 1700 && *its == 934) {
			//	cout << endl;
			//}
			double ans = (double)(100 * *its) / (double)(*itw + *its);
			if (e >= ans) {
				if (maxD <= ans) {
					maxD = ans;
					maxS = *its;
					maxW = *itw;
				}
			}
		}
	}
	cout << maxW + maxS << " " << maxS << endl;

	return 0;
}

Measured memory_bytes: 384
from itertools import product

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

ks = [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

ans = 0

#それぞれのスイッチの状態について検証を行う
for i in product(range(2), repeat=N):
    cnt = 0
    #電灯ごとの点滅を調べる
    for j in range(M):
        cnt_p = 0
        for k in ks[j][1:]:
            cnt_p += i[k-1]
        if cnt_p %2 == p[j]:
            cnt += 1
        else:
            break
    #全てつくならansに+1
    if cnt == M:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define		fast			ios::sync_with_stdio(false);cin.tie(0);cout.tie(NULL);
#define		rep(i,n)		for(int i = 1; i<=n; i++)
#define		all(p)			p.begin(),p.end()
#define		mem(ar,val)		memset(ar, val, sizeof(ar))
#define		sz(c)			(int)c.size()
#define		pb(x)			push_back(x)
#define		mkp(x,y)		make_pair(x,y)
#define 	deb			cout<<"hehehe\n"
#define		ff			first
#define		ss			second
#define 	pf 			printf
#define 	sf 			scanf
#define		ll			long long
#define		pii			pair<int, int>
#define 	pll			pair<ll, ll>
#define 	vll			vector<long long>
#define 	vi			vector<int>
#define		nl			"\n"
#define		pnl			printf("\n");
#define		S(a)			scanf("%lld",&a)
#define		SS(a,b)			scanf("%lld %lld",&a,&b)
#define		SSS(a,b,c)			scanf("%lld %lld %lld",&a,&b,&c)
#define		P(a)			printf("%lld\n",a)
#define		PP(a,b)			printf("%lld %lld\n",a,b)
#define 	total_bit(a)		__builtin_popcount(a)
#define 	UNIQUE(a)		sort(all(a)); a.erase(unique(all(a)), a.end())
#define		FI			freopen("input.txt", "r", stdin);
#define 	FO			freopen("output.txt", "w", stdout);
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x7f7f7f7f;
const int M = 1e9 + 7;
const int N = 1e6+7;
void solve()
{
	ll n;
	S(n);
	ll ar[n];
	int z[50]={0};int o[50]={0};
	for(ll i = 0; i<n; i++)
	{
		S(ar[i]);
		ll x = ar[i];
		int idx = 0;
		while(x)
		{
			if(x & 1LL)
				o[idx]++;
			else z[idx]++;
			x >>= 1LL;
			idx++;
		}
	}
//	for(int i = 0; i<50; i++)
//		cout<<o[i]<<" ";
//	pnl;	
	vll ans;
	for(ll i = 0; i<n; i++)
	{
		ll sum = 0;
		for(int j = 0; j<50; j++)
		{
			if(ar[i] & 1LL)
			{
				if(o[j] %2 == 0)
					sum += 1LL << j;
			}
			else
			{
				if(o[j] % 2 != 0)
					sum += 1LL << j;
			}
			ar[i] >>= 1LL;
		}
		ans.push_back(sum);
	}
	for(ll y : ans)
		cout<<y<<" ";
	pnl;
}
int main()
{
//	ll t;
//	S(t);
//	while(t--)
//	{
		solve();
//	}
	return 0;
}


Measured memory_bytes: 6832
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3],k,pro=1;
	for(int i=1;i<=3;i++)
	{
		cin>>a[i];
	}
	cin>>k;
	sort(a+1,a+3+1);
	for(int j=1;j<=k;j++)
	{
		pro=pro*2;
	}
	cout<<a[3]*pro+a[1]+a[2];
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto &i : a) cin >> i;
  sort(a.rbegin(), a.rend());
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += a[i / 2];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4800
#include <atcoder/convolution>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;
using mint = modint998244353;
int cc[100001];
vector<mint> d[1000001];
vector<mint> fac(100001);
vector<mint> inv(100001);
int dn;
mint C(int n, int m) {
    return fac[n] * inv[m] * inv[n - m];
}
int main() {
    int n, m;
    scanf("%d", &n);
    fac[0]=1;
    for(int i = 1; i <= 100000; i++) {
        fac[i] = fac[i-1] * i;
    }
    inv[100000] = fac[100000].inv();
    for(int i = 100000 - 1; i >= 0; i--) {
        inv[i] = inv[i + 1] * (i + 1);
    }
    for(int i = 0; i < 2 * n; i++){
        int x;
        scanf("%d",&x);
        cc[x]++;
    }
    for(int i = 1; i <= 100000; i++) {
        if(cc[i] > 1) {
            d[dn] = vector<mint>(cc[i] / 2 + 1);
            for(int j = 0; j < (int)d[dn].size(); j++) {
                d[dn][j] = C(cc[i], 2 * j) * fac[2 * j] * inv[j];
            }
            dn++;
        }
    }
    if(!dn){
        d[dn].push_back(1);
        dn++;
    }
    int it = 0;
    while(it + 1 < dn) {
        d[dn++] = convolution(d[it], d[it + 1]);
        it += 2;
    }
    mint an;
    for(int i = 0; i < (int)d[it].size(); i++) {
        if(i & 1) {
            an -= d[it][i] * C(n, i) * fac[2 * n - 2 * i] * fac[i];
        } else {
            an += d[it][i] * C(n, i) * fac[2 * n - 2 * i] * fac[i];
        }
    }
    an *= inv[n];
    for(int i = 0; i < n; i++) {
        an *= inv[2];
    }
    printf("%d\n",an.val());
    return 0;
}




Measured memory_bytes: 31808
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const double INF = 1e300;

const int N = 100 + 5;

struct Point {
  double x, y;
};

Point C1[N], C2[N];

double width(const Point c[], int n, double x) {
  double y_min = INF, y_max = -INF;
  for (int i = 0; i < n; ++i) {
    int j = (i + 1) % n;
    double x1 = c[i].x, y1 = c[i].y, x2 = c[j].x, y2 = c[j].y;
    if (x1 != x2 && (x1 - x) * (x2 - x) <= 0.0) {
      double y = y1 + (x - x1) / (x2 - x1) * (y2 - y1);
      y_min = min(y_min, y);
      y_max = max(y_max, y);
    }
  }
  return max(0.0, y_max - y_min);
}

int main() {
#ifdef DEBUG
  freopen("in.txt", "r", stdin);
#endif

  int n, m;
  while (scanf("%d%d", &n, &m) != EOF && n && m) {
    vector<double> xs;
    double min_x1 = INF, max_x1 = -INF, min_x2 = INF, max_x2 = -INF;

    for (int i = 0; i < n; ++i) {
      scanf("%lf%lf", &C1[i].x, &C1[i].y);
      xs.push_back(C1[i].x);
      min_x1 = min(min_x1, C1[i].x);
      max_x1 = max(max_x1, C1[i].x);
    }

    for (int i = 0; i < m; ++i) {
      scanf("%lf%lf", &C2[i].x, &C2[i].y);
      xs.push_back(C2[i].x);
      min_x2 = min(min_x2, C2[i].x);
      max_x2 = max(max_x2, C2[i].x);
    }

    sort(xs.begin(), xs.end());

    double V = 0.0;
    for (size_t i = 0; i + 1 < xs.size(); ++i) {
      double a = xs[i], b = xs[i + 1], c = (a + b) / 2.0;
      if ((min_x1 <= c && c <= max_x1) &&
          (min_x2 <= c && c <= max_x2)) {
        double fa = width(C1, n, a) * width(C2, m, a);
        double fb = width(C1, n, b) * width(C2, m, b);
        double fc = width(C1, n, c) * width(C2, m, c);
        V += (b - a) / 6 * (fa + 4 * fc + fb);
      }
    }
    printf("%.10f\n", V);
  }

  return 0;
}



Measured memory_bytes: 2788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  double ans=0;
  
  for(int i=1;i<=N;i++){
     double tmp=1.0/N;
    int now=i;
    while(now<K){
      now*=2;
      tmp/=2;
    }
    ans+=tmp;
  }
  
  printf("%.12f\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<vector>
#include <map>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 2000000000000000000ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////

ll n,m,r[4];
//ll ar[mx+2];
ll DP[mx+2][4];
char ar[mx+2];
ll a[4];
int re(char s){
    if(s== 'r')return 0;
    else if(s=='s')return 1;
    return 2;
}

ll dp(int pos, int fl){

    if(pos > n)return 0;
    ll &ret = DP[pos][fl];

    if(ret!=-1)return ret;

    ret = 0;

    for(int i = 1;i<=3;i++){
        if(fl == i)continue;

        if(i%3 == re(ar[pos])){
           // cout<<pos<<" "<<i<<" "<<a[i]<<" lol "<<a[pos]<<endl;
            ret = max(ret, a[i]+ dp(pos + m, i));}
        else ret = max(ret, dp(pos+m, i));
    }

    return ret;
}

int main(){

   cin>>n>>m;
   for(int i=1;i<=3;i++){
       cin>>a[i];
   }
   scanf("%s", ar + 1);
   memset(DP,-1,sizeof DP);
   ll res =0;
   for(int i=1;i<=m;i++){
       res+=dp(i,0);
     //  cout<<i<<endl;
     //  cout<<dp(i,0)<<endl;
   }
   cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 23680
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-08 00:18:59
**/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P =pair<int,int>;

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, N) {
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    reverse(H.begin(), H.end());
    int i = 0;
    ll attack = 0;
    while(1) {
        if(H.at(i) == 0) {
            //i++;
            if(i == N - 1) {
                break;
            }
            i++;
            continue;
        }else {
            if(K > 0) {
                H.at(i) = 0;
                //attack++;
                K--;
            }else{
                //H.at(i) --;
                //attack++;
                attack+=H.at(i);
                H.at(i)=0;
            }
        }
    }
    cout << attack << endl;
return 0;}
/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication46
{
    class Program
    {
        static void Main()
        {
            while (true) { 
            string s = "";
                string y = Console.ReadLine();
                if (y == null) break;
            int A = int.Parse(y);
            for(int B = 2; A != 0; B *=2)
            {
                if (A % B != 0) { s += B / 2 + " ";A -= B / 2; }
            }
            for(int r = 0; r < s.Length - 1; r++)
            {
                Console.Write(s[r]);
            }
            Console.WriteLine();
            }
        }
    }
}

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

ll N, M, X[100000], Y[100000];

int main(void) {
  cin >> N >> M;
  REP(i, 0, M) cin >> X[i] >> Y[i], X[i]--, Y[i]--;

  vector<ll> cnt(N, 1);
  vector<bool> red(N, false);
  red[0] = true;
  REP(i, 0, M) {
    ll x = X[i], y = Y[i];
    cnt[x]--;
    cnt[y]++;
    if(red[x]) red[y] = true;
    if(cnt[x] == 0) red[x] = false;
  }

  ll ans = 0;
  REP(i, 0, N) if(red[i]) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 2560