akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque

readline = sys.stdin.buffer.readline
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def solve():
    mod = 10**9 + 7
    n, k = nm()
    G = [list() for _ in range(n)]
    ans = 1
    for _ in range(n-1):
        u, v = nm()
        u -= 1; v -= 1
        G[u].append(v)
        G[v].append(u)
    q = deque()
    chi = [0]*n
    par = [-1]*n
    q.append(0)
    while q:
        v = q.popleft()
        c = k - chi[par[v]]
        if par[v] >= 0:
            chi[par[v]] += 1
            c -= 1
            if par[par[v]] >= 0:
                c -= 1
        ans = ans * c % mod
        for x in G[v]:
            if x != par[v]:
                par[x] = v
                q.append(x)
    print(ans)
    return

solve()

# T = ni()
# for _ in range(T):
#     solve()


Measured memory_bytes: 24684
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define	GETBIT(X, Data)			((Data >> (X)) & 0x01)
#define	SETBIT_ON(X, Data)		((0x01 << (X)) | Data)
#define SETBIT_OFF(X, Data)		((~(0x01 << (X))) & Data)

unsigned long long SubInt(const int& s, const int& e, const string& input)
{
	char str[20] = { 0 };
	memcpy(str, &input[s], e - s + 1);	
	return atoll(str);
}

unsigned long long SolveOptStr(const int& opts, const string& input)
{
	int s, e;
	unsigned long long r;
	s = 0;
	e = 0;
	r = 0;
	for (size_t i = 0; i < input.length(); ++i)
	{
		int k = GETBIT(input.length() - 1 - i, opts);
		if (GETBIT(input.length() - 1 - i, opts) == 0)
		{
			++e;
			continue;
		}

		r += SubInt(s, e, input);
		s = i + 1;
		e = i + 1;
	}

	return r;
}

void InitOpts(int& opts)
{
	opts = 0x01;
}

void OptsPlus(int& opts)
{
	opts = (((opts >> 1) + 1) << 1) | 0x01;
}

int main(int argc, char* argv[])
{
	string	S;
	cin >> S;

	int opts;
	InitOpts(opts);
	
	unsigned long long res = 0;
	size_t loop = (size_t)pow(2, S.length() - 1);
	for (size_t i = 0; i < loop; ++i)
	{
		res += SolveOptStr(opts, S);
		OptsPlus(opts);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a*b%2 == 0) puts("Even");
    else puts("Odd");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int i, n;
    int *a;
    scanf( "%d\n", &n );
    
    a = (int *)malloc( sizeof(int) * n);

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

    for(i = (n-1); i >= 0; i--){
        printf("%d",a[i]);
        if(i != 0){printf(" ");}
    }
    
    free(a);
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
def main():
    n,k = map(int,input().split())

    ans = 0
    if k == 0:
        ans = n * n
    else:
        for i in range(k+1,n+1):
            ans += n // i * (i-k)
            ans += max(0,n%i-k+1)
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  string ans = "";
  REP(i,s.size()){
    if(s[i]=='0') ans += "0";
    else if(s[i]=='1') ans += "1";
    else if(ans!="") ans.erase(--ans.end()); 
  }
  OUT(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
typedef long long ll;
using namespace std;

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

    ll n;
    string s, pin, sub_s;
    int ans = 0, pos;
    bool ok;
    cin >> n >> s;
    REP(i,1000){
        ostringstream sout;
        sout << std::setfill('0') << std::setw(3) << i;
        pin = sout.str();
        sub_s = s;
        ok = true;
        REP(j,3)
        {
            pos = sub_s.find_first_of(pin[j]);
            if(pos != string::npos){
                sub_s = sub_s.substr(pos+1);
            }
            else{
                ok = false;
                break;
            }
        }
        if(ok) ans += 1;
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    vector<char> p;string s;
    cin>>s;
    for(char c:s)
        if(c=='B'){
            if(!p.empty())
                p.pop_back();
        }else
            p.pb(c);
    for(auto c:p)cout<<c;cout<<endl;
	return 0;
}


Measured memory_bytes: 256
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n, k = intin()
    if n % k == 0:
        print(0)
    else:
        print(1)


if __name__ == '__main__':
    main()


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

int solve() {
    int N;
    cin >> N;
    if(N==0) return 0;
    vector<int> datas;
    datas.resize(N);
    for(int i=0; i<N; i++) {
        cin >> datas[i];
    }
    sort(datas.begin(), datas.end());
    int sum = 0;
    int counter = 0;
    for(auto itr=datas.begin()+1; itr!=datas.end()-1; itr++) {
        sum += *itr; counter++;
    }
    cout << sum/counter << endl;
    return 1;
}

int main() {
    while(solve()) {}
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cstdio>
#define ll long long
using namespace std;

int main() {
	string ss;
	cin >> ss;
	int ans = 0;
	int n = ss.length();
	int s[n];
	for(int i = 0; i < n; i++){
		if(ss[i] == 'W')
			s[i] = 1;
		else if(ss[i] == 'B')
			s[i] = -1;
		// cout << s[i] << endl;
	}
	for(int i = 0; i < n-1; i++){
		if(s[i+1] * s[i] == -1) ans++;
	}

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

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

    private static final int MOD = 1_000_000_007;

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

        int n = sc.nextInt();

        int[] p = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        int cnt = 0;

        for (int i = 1; i < n - 1; i++) {
            if ((p[i - 1] > p[i] && p[i] > p[i + 1]) || p[i - 1] < p[i] && p[i] < p[i + 1]) ++cnt;
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 21972
//By : BebekJK
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//Declare -> ordered_set NAMA;
//Nth smallest integer -> find_by_order(N-1)
//Number of elements less than N -> order_of_key(N)
//Delete N from the set -> erase(N)

#define endl '\n'
#define MOD 1000000007
#define PI 3.141592653
#define fi first
#define sc second
#define pb push_back
#define pbb pop_back

//#pragma GCC optimize("Ofast")
//#pragma GCC target ("string"...)
//#pragma GCC push_options
//#pragma GCC pop_options
//#pragma GCC reset_options
//#pragma GCC optimize ("O3")

typedef long long ll;
typedef long double ld;
typedef pair<int , int> pii;
typedef pair<long long , long long> pll;

void BOOST(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
void fcin(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c=='-'){
		neg = true;
		c = getchar();
	}
	for(;(c>47 && c<58);c=getchar())x = (x<<1)+(x<<3)+c-48;
	if(neg)x*=-1;
}
ll pmod(ll a , ll b){
	if(b==0)return 1;
	ll temp = pmod(a , b/2);
	if(b%2==0)return(temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
string S;
int Sum =  0;
int main(){
	cin>>S;
	for(auto i:S){
		Sum+=(i-'0');
	}
	if(Sum%9==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}







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

long long f(long long t) {
	if (t % 4 == 0)
		return t;
	else if (t % 4 == 1)
		return 1;
	else if (t % 4 == 2)
		return (t ^ 1);
	else
		return 0;
}

int main()
{
	long long a, b;

	cin >> a >> b;
	cout << (f(a - 1) ^ f(b)) << endl;

	return 0;
}

Measured memory_bytes: 256
def solve():


    A, B, C, D, E, F = map(int, input().split())

    #memo
    list = {}

    #操作1-4
    ope1 = 100 * A
    ope2 = 100 * B
    ope3 = C
    ope4 = D


    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    w_sum = i * ope1 + j * ope2
                    s_sum = k * ope3 + l * ope4
                    if w_sum == 0:
                        break
                    if w_sum+s_sum > F:
                        break
                    else:
                        if w_sum/100 * E >= s_sum:
                            p_tmp = (s_sum / (w_sum + s_sum)) * 100
                            list[i, j, k, l] = p_tmp

    max_v = max(list.values())

    for k, v in list.items():
        if v == max_v:
            print(ope1*k[0] + ope2*k[1] + ope3*k[2] + ope4*k[3], ope3*k[2] + ope4*k[3])
            break

if __name__ == "__main__":
    solve()


Measured memory_bytes: 45028
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
pair<double, string> otoshidama[11];

void input(){
    cin >> n;
    for(int i=0;i<n;++i){
        double x;
        string u;
        cin >> x >> u;
        otoshidama[i] = make_pair(x, u);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    double ans = 0;
    for(int i=0;i<n;i++){
        if(otoshidama[i].second == "JPY"){
            ans += otoshidama[i].first;
        }
        else{
            ans += otoshidama[i].first * 380000.0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define ll long long
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	ll ans = b / x - max((a - 1),(ll)0) / x;
	if (a == 0)ans++;
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            uf.makeSame(sc.nextInt() - 1, sc.nextInt() - 1);
            sc.nextInt();
        }
        System.out.println(uf.length);
    }

}

class UnionFind {

    int length;
    int[] parent;
    int[] deep;
    int rootX, rootY;

    public UnionFind(int length) {
        this.length = length;
        parent = new int[length];
        for (int i = 0; i < length; i++) {
            parent[i] = i;
        }
        deep = new int[length];
    }

    public int getRoot(int x) {
        if (parent[x] == x) {
            return x;
        } else {
            return parent[x] = getRoot(parent[x]);
        }
    }

    public void makeSame(int x, int y) {
        rootX = getRoot(x);
        rootY = getRoot(y);
        if (rootX == rootY) {
            return;
        } else if (deep[rootX] > deep[rootY]) {
            parent[rootY] = parent[rootX];
        } else {
            parent[rootX] = parent[rootY];
            if (deep[rootX] == deep[rootY]) {
                deep[rootY]++;
            }
        }
        length--;
    }

    public boolean isSame(int x, int y) {
        return getRoot(x) == getRoot(y);
    }
}

Measured memory_bytes: 92852
function main()
    N = pread(Int)
    a = sort(readvec(Int, N))
    c = 1
    s = 0
    for i in 2:N
        if 2 * (a[i-1] + s) >= a[i]
            c += 1
        else
            c = 1
        end
        s += a[i-1]
    end
    println(c)
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


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

 int DigitsSum (int n) {
   int sum = 0;
   while (n > 0){
     sum += n % 10;
     n /= 10;
   }
   return sum;
 }

int main() {
  int N, B, a, b;
  cin >> N;
  
  int min = 1000000;
  
  for (int A = 1; A < N ; A++) {
    B = N - A;
    a = DigitsSum(A);
    b = DigitsSum(B);
     if (a + b < min)
       min = a + b;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define debug(a) cout<<a<<endl
#define pii pair<int,int>
#define maxn 100009
using namespace std;
int pai[maxn],ranks[maxn];
int find(int x){
    if(pai[x]!=x)return pai[x]=find(pai[x]);
    else return x;
}
bool issameset(int a,int b){
    if(find(a)==find(b))return true;
    else return false;
}
void unions(int a ,int b){
    int paia=find(a);
    int paib=find(b);
    if(paia==paib)return;
    if(ranks[paia]>ranks[paib]){
        pai[paib]=paia;
        ranks[paia]+=ranks[paib];
    }
    else{
        pai[paia]=paib;
        ranks[paib]+=ranks[paia];
    }
}
int main(){
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<maxn;i++){
        pai[i]=i;
        ranks[i]=1;
    }
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        unions(a,b);
    }
    map<int,int> cont;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(cont[find(i)]==0){
            ans++;
            cont[find(i)]=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}
///usar double sempre ou long double
///pensar em casos que coisas dao negativas
///N esquecer de limpar as coisas em quest de varios testes
///OLHAR A COMPLEXIDADE PRA VER SE N PASSA POR BRUTE FORCE OU BRUTE FORCE COM ALGUMAS OTIMIZACOES

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;

	printf("%.10f\n", w*h / 2);
	if (x == w / 2 && y == h / 2) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,x,y;
int main(){
	scanf("%d%d%d%d",&n,&m,&x,&y);
	int ma=-99999999,mi=99999999;
	for(register int i=1,tmp;i<=n;i++){
		scanf("%d",&tmp);
		ma=max(ma,tmp+1);
	}
	for(register int i=1,tmp;i<=m;i++){
		scanf("%d",&tmp);
		mi=min(mi,tmp);
	}
	int mii=min(mi,y);
	int maa=max(ma,x+1);
	if(maa<=mii)cout<<"No War"<<endl;
	else cout<<"War"<<endl;
}

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

int main() {
	int n, sum;
	 cin >> n >> sum;
	
	 for (int i = 0; i <= n; i++) {
		 for (int j = 0; j <= n; j++) {
			 int k = n - i - j;
			 if (0 <= k && k <= n && i * 10000 + j * 5000 + k * 1000 == sum) {
				 cout << i << ' ' << j << ' ' << k << endl;
				 return 0;
			 }
		 }
	 }
	 cout << "-1" << ' ' << "-1" << ' ' << "-1" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int N;
  string c;
  cin >> N;
  cin >> c;
  if(N<3200){
   cout << "red" << endl;
  }else{
   cout << c << endl; 
  }

  return 0;
}

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

using namespace std;

int main(void) {

	int h, w;

	cin >> h >> w;

	vector<string> s(h);

	for (int k = 0; k < h; k++)
	{
		cin >> s.at(k);
	}

	//cout << "cout\n";

	for (int k = 0; k < h; k++)
	{
		cout << s[k] << "\n" << s[k] << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int,input().split()))


for i in range(n):
    a = sum(w[:i+1])
    b = sum(w[i+1:])
    if i == 0:
        s = abs(a-b)
    else:
        if abs(a-b) < s:
            s = abs(a-b)

print(s)

Measured memory_bytes: 3060
#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>;

bool is_palindrome(string s) {
  string t(s.rbegin(), s.rend());
  return s == t;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();

  if (is_palindrome(s) && is_palindrome(s.substr(0, (n - 1)/2)) && is_palindrome(s.substr((n + 1) / 2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll lg=22;
const ll N=2e5+5;
const ll M=5e8;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
 
inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}


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

int main()
{
  int a, b;

  cin >> a >> b;
  int c = 0;
  if (b == 1) {
    c = 0;
  } else if (b <= a) {
    c = 1;
  } else {
    c = 2 + ((b - a - 1) / (a - 1));
  }
  cout << c;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c[10],s[10],a[5],m,n;
int main()
{
	scanf("%d%d",&n,&m);
	if(m==0&&n==1) printf("0");
	else{
		bool q=false;
		memset(a,-1,sizeof(a));
		for(int i=1;i<=m;++i){
			scanf("%d%d",&s[i],&c[i]);
			for(int j=1;j<i;++j){
				if(s[i]==s[j]&&c[i]!=c[j]) q=true;
			}
			if(s[i]==1&&c[i]==0&&n!=1) q=true;
			a[s[i]]=c[i];
		}
		for(int i=1;i<=n;++i){
			if(a[i]==-1){
				if(i==1&&n!=1) a[i]=1;
				else a[i]=0;
			}
		}
		if(q) printf("-1");
		else{
			for(int i=1;i<=n;++i)printf("%d",a[i]);
		}
	}
}

Measured memory_bytes: 256
[(a, b, c), (d, e, f), (g, h, i)] = [
    map(int, input().split()) for i in range(3)]

q1 = a - b == d - e== g - h
q2 = a - c == d - f == g - i
q3 = a - d == b - e== c - f
q4 = a - g == b - h == c - i

print("Yes" if q1 and q2 and q3 and q4 else "No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
int a[300000];
int b[300000];
 
int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d",&a[i+1]);
	}
	vector<int>ans;
	for(int i=n;i>=1;i--){
		int cnt=0;
		for(int j=i*2;j<=n;j+=i){
			cnt+=b[j];
		}
		cnt%=2;
		b[i]=cnt^a[i];
		if(b[i]){
			ans.push_back(i);
		}
	}
	cout<<ans.size()<<endl;
	for(int i:ans){
		cout<<i<<' ';
	}
	cout<<endl;
}

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<sstream>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

string next(string s){
	int idx = 0;
	if(s[idx] == '^' || s[idx] == '_'){
		int cnt = 0;
		for(;idx<s.size();idx++){
			if(s[idx] == '('){
				cnt++;
			}else if(s[idx] == ')'){
				cnt--;
				if(!cnt){ return s.substr(0, idx + 1);}
			}
		}
	}else{
		while(s[idx] >= '0' && s[idx] <= '9') idx++;
		return s.substr(0, idx);
	}
}

pair<int, int> calc(string s, int mini = 0, int maxi = 99){
	// cout<<s<<' '<<mini<<' '<<maxi<<endl;
	string lstr, rstr;
	int l, r;
	if(s[0] == '^'){
		int idx = 2;
		lstr = next(s.substr(idx));
		auto lp = calc(lstr, mini, maxi);
		l = lp.first;
		if(l >= maxi){ return {maxi, idx + lp.second}; }
		idx += lstr.size() + 1;
		rstr = next(s.substr(idx));
		auto rp = calc(rstr, max(mini, l), maxi);
		r = rp.first;
		return {min(maxi, max(mini, max(l, r))), idx + rp.second};
	}else if(s[0] == '_'){
		int idx = 2;
		lstr = next(s.substr(idx));
		auto lp = calc(lstr, mini, maxi);
		l = lp.first;
		if(l <= mini){ return {mini, idx + lp.second}; }
		idx += lstr.size() + 1;
		rstr = next(s.substr(idx));
		auto rp = calc(rstr, mini, min(maxi, l));
		r = rp.first;
		return {min(maxi, max(mini, min(l, r))), idx + rp.second};
	}else{
		int idx = 0;
		lstr = next(s.substr(idx));
		if(lstr[0] - '0' >= maxi){ return {maxi, 1}; }
		if(lstr[0] == '0'){ return {0, 1}; }
		if(lstr[0] - '0' < (mini + 1) / 10){ return {mini, 1}; }
		l = atoi(lstr.c_str());
		return {l, 2};
	}
}

int main(){
	int q;
	cin >> q;
	for(int i=0;i<q;i++){
		string s;
		cin >> s;
		auto p = calc(s);
		cout << p.first << ' ' << p.second << endl;
	}
	return 0;
}



Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <stdio.h>
using namespace std;
int main() {
    string W, T;
    cin >> W;
    transform (W.begin(), W.end(), W.begin(), ::tolower);
    int cnt = 0;
    while(cin >> T, T != "END_OF_TEXT"){
        transform (T.begin(), T.end(), T.begin(), ::tolower);
        if(W == T){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 20000000
int main()
{
        string a,b;
        while(1)
        {
                cin >> a >> b;
                if(a.size()<=2&&b.size()<=2)break;
                int hit_count=0;
                for(int i=0;i<4;i++)
                {
                        if(a[i]==b[i])
                        {
                                hit_count++;
                        }
                }
                int blow_count=0;
                for(int i=0;i<4;i++)
                {
                        for(int j=0;j<4;j++)
                        {
                                if(b[i]==a[j])
                                {
                                        blow_count++;
                                        break;
                                }
                        }
                }
                cout << hit_count << ' ' << blow_count-hit_count << endl;
        }
        return 0;
}

Measured memory_bytes: 1180
n,k = map(int,input().split())
ls = [int(x) for x in input().split()]

mini = 10**9
for i in range(n-k+1):
    flg1 = abs(ls[i])+abs(ls[i]-ls[i+k-1])
    flg2 = abs(ls[i+k-1])+abs(ls[i]-ls[i+k-1])
    mini = min(flg1,flg2,mini)
print(mini)

Measured memory_bytes: 62576
#include <stdio.h>

#define N 100

int main()
{
  int i,j,k,hako[N],n,count = 0;

  scanf("%d",&n);

  for(i =  0;i < n;i ++)
    {
      scanf("%d",&hako[i]);
    }
  
  for(i = 0;i < n;i ++)
    {
      for(j = 0;j < n - i - 1;j ++)
	{
	  if(hako[j] > hako[j + 1]){
	    k = hako[j];
	  hako[j] = hako[j + 1];
	  hako[j + 1] = k;
	  count ++;
	  }

	}
    }

  for(i = 0;i < n -1 ;i ++)
    {
      printf("%d ",hako[i]);
    }

  printf("%d\n",hako[i]);
  printf("%d\n",count);

  return 0;
}

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

int main() {
    int n;
    while (~scanf("%d", &n)) {
        int mx = INT_MIN;
        int mn = INT_MAX;
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            register int x;
            scanf("%d", &x);
            mx = std::max(mx, x);
            mn = std::min(mn, x);
            sum += x;
        }
        printf("%d %d %lld\n", mn, mx, sum);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N;
    cin >> N;
    map<int , int> ma;
    REP(i,N){
        int a;
        cin >> a;
        if(ma.find(a) == ma.end()){
            ma[a]++;
        }
        else{
            int tmp = ma[a] + 1;
            if(tmp == 3) tmp = 1;
            ma[a] = tmp;
        }
    }

    ll ans = 0;
    int two = 0;
    for(auto&& t : ma){
        int a = t.first;
        int num = t.second;
        if(num == 1) ans++;
        else two++;
    }

    if(two%2){
        ans += (two-1);
    }
    else{
        ans += two;
    }

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


Measured memory_bytes: 4992
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;



int main(int argc, char *argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 7 && b == 5 && c == 5) {
        cout << "YES" << endl;
    }
    else if (a == 5 && b == 7 && c == 5) {
        cout << "YES" << endl;
    }
    else if (a == 5 && b == 5 && c == 7) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100],b[100],s[100];
int main(){
	scanf("%s%s",a,b);
	for(int i=0;i<strlen(a);i++)s[i*2]=a[i];
	for(int i=0;i<strlen(b);i++)s[i*2+1]=b[i];
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int increase(int a,int maxn)
{
	int sum=0;
    while(a+2<=maxn)
    {
      a+=2;
      sum++;
    }
    return sum;
}
int main()
{
	int a[3],tol=0;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	tol+=increase(a[0],a[2])+increase(a[1],a[2]);
	for(int i=0; i<2; i++)
	{
	if((a[2]-a[i])%2==0)
	 {
	 	a[i]=a[2];
	 }
	 else a[i]=a[2]-1;
    }
    if(a[0]==a[1]&&a[1]==a[2]) { cout<<tol; return 0;}
	else if(a[0]==a[1]) { cout<<tol+1; return 0;}
	else if(a[1]==a[2]||a[0]==a[2]) { cout<<tol+2; return 0;}
   return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define mod 1e9 +7;
typedef long long ll;
typedef vector<ll> vll;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    int n; cin >> n;
    vll a(n);
    rep(i,n)cin >> a[i];
    vll b = a;
    sort(all(b));
    ll m1 = b[n/2], m2 = b[n/2-1];
    rep(i,n){
        if(a[i] < m1)cout << m1 << endl;
        else cout << m2 << endl;
    }
    return 0;
} 

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

int main(){
    int N;
    int t;
    long long int MOD=1e9+7;
    long long int res=1;
    cin >> N;

    vector<long long int> T(N+2),A(N+2);
    for(int i=1;i<=N;i++){
        cin >>t;
        T[i]=t;
    }
    for(int i=1;i<=N;i++){
        cin >>t;
        A[i]=t;
    }
    for (int i=1;i<=N;i++){
        bool t = T[i]!=T[i-1];
        bool a = A[i]!=A[i+1];
        if( a||t){
            if((a && A[i]>T[i]) || (t && T[i]>A[i])) res=0;
        } else {
            res = (res*min(A[i],T[i]))%MOD;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int t;
	while(cin >> t && t)
	{
		int n;
		cin >> n;

		int ret = 0;
		rep(i,n)
		{
			int a,b;
			cin >> a >> b;
			ret += b - a;
		}

		if(t - ret <= 0) cout << "OK" << endl;
		else cout << t - ret << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  while(k>0)
  {
    if(b<=a)
    	b*=2;
   	else if(c<=b)
      c*=2;
    else
    {}
    k--;
  }
  if(c>b&&b>a)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3128
#include <stdio.h>
int queue[100001];
int head=0,tail=0;
void enqueue(int);
int dequeue();
int main (){
    int n,q,time[100000];
    char name[100000][11];
    int i,tmp,clock=0;
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s %d",name[i],&time[i]);
        enqueue(i);
    }

    while(1){
        tmp=dequeue();
        if(tmp<0){
            break;
        }
        time[tmp]-=q;
        if(time[tmp]<=0){
            clock+=q+time[tmp];
            printf("%s %d\n",name[tmp],clock);
        }
        else{
            clock+=q;
            enqueue(tmp);
        }
    }
    return 0;
}

void enqueue(int num){
    int next=(tail+1)%100001;
    queue[tail]=num;
    tail=next;
}

int dequeue(){
    int val;
    if(head==tail){
        return -1;
    }
    val=queue[head];
    head=(head+1)%100001;
    return val;
}


Measured memory_bytes: 2856
def main(x0,y0,x1,y1):
    c0 = complex(x0,y0)
    c1 = complex(x1,y1)
    c = c1 - c0
    c2 = c1 + c *1j
    c3 = c2 +c *(-1)
    x2 = int(c2.real)
    y2 = int(c2.imag)
    x3 = int(c3.real)
    y3 = int(c3.imag)
    return "{} {} {} {}".format(x2,y2,x3,y3)
x0,y0,x1,y1 = map(int,input().split())
print(main(x0,y0,x1,y1))


Measured memory_bytes: 3188
import java.util.Scanner;

/**
 * B - Multiple of 9
 * 整数 N が 9 の倍数であることと、N を十進法で表したときの各桁の数の和が 9 の倍数であることは同値です。
 * N が 9 の倍数であるか判定してください。
 */
public class Main {

    public static void main( String[] args ) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        String n = sc.next(); // 整数

        int sum = 0;
        for( int i = 0; i < n.length(); i++ ) {
            sum += Integer.parseInt( n.substring( i, i + 1 ) );
        }

        System.out.println( ( sum % 9 == 0 ) ? "Yes" : "No"  );

        sc.close();
    }
}

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

int main(){
    string s;
    cin >> s;
    string com="keyence";
    string ans="YES";
    if(s==com){
        cout << ans << endl;
        return 0;
    }
    int a=s.size();
    for(int i=0;i<a;i++){
        for(int j=i;j<a;j++){
            string str="";
            for(int k=0;k<a;k++){
                if(k>=i&&k<=j){
                    continue;
                }
                else{
                    str.push_back(s[k]);
                }
            }
            if(str==com){
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BSimilarArrays {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N);
        for(auto& a : A) in>>a;
        int ans = 1, d = 1;
        REP(i, N) ans *= 3;
        for(auto& a : A){
            if(a%2==0) d *= 2;
        }
        out<<ans-d<<'\n';
    }
};


int main() {
	BSimilarArrays solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cassert>
using namespace std;

int main(){
    string S,T;
    cin >> S >> T;
    int M = T.size();
    string SS = S + S;
    while(SS.size()<2*M) SS += S;
    int N = S.size();
    vector<int> kmpnext(M+1,-1);
    vector<vector<int>> v(N+1);
    auto prekmp = [&](string x,int m){
        int i = 0,j = kmpnext[0] = -1;
        while(i<m){
            while(j>-1 && x[i]!=x[j]) j = kmpnext[j];
            i++; j++;
            if(x[i]==x[j]) kmpnext[i] = kmpnext[j];
            else kmpnext[i] = j;
        }
    };
    auto KMP = [&](string x,int m,string y,int n){
        int i = 0,j = 0;
        prekmp(x,m);
        while(j<n){
            while(i>-1 && x[i]!=y[j]) i = kmpnext[i];
            i++; j++;
            if(i>=m){
//                cerr << j-i << " " << (j-i+x.size())%N << endl;
                v[(j-i)%N].push_back((j-i+x.size())%N);
                i = kmpnext[i];
            }
        }
    };
    KMP(T,M,SS,SS.size());
    vector<int> vis(N+1,0);
    function<bool(int)> dfs = [&](int n){
        vis[n] = -1;
        bool ok = true;
        for(auto x:v[n]){
            if(vis[x]==0) ok &= dfs(x);
            else if(vis[x]==-1) return false;
        }
        vis[n] = 1;
        return ok;
    };
    for(int i=0;i<N;i++){
        if(vis[i]==0){
            if(!dfs(i)){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    vector<int> u;
    for(int i=0;i<N;i++) vis[i] = 0;
    function<void(int)> topso = [&](int n){
        vis[n] = 1;
        for(auto x:v[n]) if(!vis[n]) topso(x);
        u.push_back(n);
    };
    for(int i=0;i<N;i++) if(!vis[i]) topso(i);
    reverse(u.begin(),u.end());
    vector<int> d(N+1,0);
    function<int(int)> dfs2 = [&](int n){
        vis[n] = 1;
        d[n] = 1;
        for(auto x:v[n]){
            if(!vis[x] && !v[x].empty()) d[n] = max(d[n],dfs2(x)+1);
            else if(vis[x]==1) d[n] = max(d[n],d[x]+1);
        }
        return d[n];
    };
    for(int i=0;i<N;i++) vis[i] = 0;
    for(auto x:u){
        if(!vis[x] && !v[x].empty()) dfs2(x);
    }
    int ans = 0;
    for(int i=0;i<N;i++) ans = max(ans,d[i]);
    cout << ans << endl;
}

Measured memory_bytes: 66476
#include <stdio.h>

#define N 10

void display(int weight, const int data[], int sw[], int n){
	
	int i;
	
	printf("wstones::%d ||", weight);
	
	for(i=0; i<n; i++){
		
		if(sw[i] == 1){
			
			printf(" %d", data[i]);
		
		}
		
	}
	
	printf("\n");
	
}

int main(void){
	
	int weight, wstones;
	const int stones[N] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int isUse[N] = {0};
	int i;
	int count;
	int lastNum;
	
	while(scanf("%d", &weight) != EOF){
		
		//printf("weight::%d\n", weight);
		
		for(i=0; i<N; i++){
			
			isUse[i] = 0;
			
		}
		
		wstones = 0;
		i = 0;
		count = 0;
		
		//分銅の重さ合計と、入力の重さが等しくなるまで繰り返す
		while(weight != wstones){
			
			//display(wstones, stones, isUse, N);
			
			//分銅の方が軽い
			if(weight > wstones){
				
				if(isUse[i] == 0){
					
					wstones += stones[i];
					isUse[i] = 1;
					
					
				}
				
				i++;
				
			}
			
			//分銅の方が重い
			else{
				
				i--;
				
				if(lastNum == i){
					
					i--;
					
				}
				
				if(isUse[i] == 1){
					
					isUse[i] = 0;
					wstones -= stones[i];
					
					lastNum = i;
					
				}
				
			}
			
		}
		
		for(i=0; i<N; i++){
			
			if(isUse[i] == 1){
				
				if(count > 0){
					
					printf(" ");
					
				}
				
				printf("%d", stones[i]);
				count++;
				
			}
			
		}
		
		printf("\n");
		
	}
	
	
	return 0;
	
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, t, a;
    cin >> n >> t >> a;
    vector<double> h(n);
    double y = 100000;
    int index = -1;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        h[i] = t - x * 0.006;
        if(abs(h[i] - a) < y){
            y = abs(h[i] - a);
            index = i;
        }
    }
    cout << index + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int isprime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0)return 0;
  }
  return 1;
}
int main(){
  int k,n;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(k=n-2;k>=2;k--){
      if(isprime(k)&&isprime(k+2)){
        printf("%d %d\n",k,k+2);
        break;
      }
    }
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<vector<int>> adj(N + 5, vector<int>(N + 5, 0));
  int a, b;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &a, &b);
    adj[a][b] = adj[b][a] = 1;
  }

  vector<int> v;
  for (int i = 1; i <= N; ++i) { v.push_back(i); }

  int ans = 0;
  do {
    bool ok = true;
    for (int i = 0; i + 1 < N; ++i) {
      if (adj[v[i]][v[i + 1]] == 0) {
        ok = false;
        break;
      }
    }
    if (ok) { ++ans; }

  } while (next_permutation(v.begin() + 1, v.end()));

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
N,q = map(int,input().split())
name = []
time = []
now = 0
for i in range(N):
    n,t = input().split()
    name.append(n)
    time.append(int(t))
while N != 0:
    if time[0] > q:
        t = time.pop(0)-q
        n = name.pop(0)
        time.append(t)
        name.append(n)
        now += q
    else:
        t = time.pop(0)
        n = name.pop(0)
        now += t
        print(n,now)
        N -= 1


Measured memory_bytes: 9536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  cin >> N;

  vector<long> a(N);
  for (long i = 0; i < N; i++) {
    cin >> a.at(i);
  }
 
  long count;
  count = 0;

  for (long i = 0; i < N; i++) {
    if ((i + 1) % 2 != 0 && a[i] % 2 != 0){
        count += 1;
    }
  }
     
    cout << count <<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double a,b;
  int i=0;
  cin>>a>>b;
  while(true){
    if((10*b<=i&&i<10*b+10)&&(12.5*a<=i&&i<12.5*a+12.5)){
      cout<<i;
      break;
    }
    if(10*b+10<=i&&12.5*a+12.5<=i){
      cout<<"-1";
      break;
    }
    
    i++;
  }
  
}

Measured memory_bytes: 256