akhauriyash/Code-Regression huggingface dataset:
class Heap
  attr_reader :arr

  def initialize(arr = [])
    @arr = []
    arr.each {|val| push(val) }
  end

  def condition(parent, child)
    parent >= child
  end

  def push(val)
    idx = @arr.size
    while idx > 0
      parent_idx = (idx - 1) / 2
      break if condition(@arr[parent_idx], val)
      @arr[idx] = @arr[parent_idx]; idx = parent_idx
    end
    @arr[idx] = val
  end

  def top
    @arr[0]
  end

  def pop
    ret = @arr[0]
    val = @arr.pop
    return ret if @arr.empty?
    idx = 0
    while true
      left = idx * 2 + 1; l_val = @arr[left]
      right = idx * 2 + 2; r_val = @arr[right]
      if right < @arr.size && !condition(val, r_val) && !condition(l_val, r_val)
        @arr[idx] = r_val; idx = right
      elsif left < @arr.size && !condition(val, l_val)
        @arr[idx] = l_val; idx = left
      else
        break
      end
    end
    @arr[idx] = val
    return ret
  end
end

_, M = gets.split.map(&:to_i)
h = Heap.new gets.split.map(&:to_i)
M.times do
  h.push(h.pop / 2)
end
puts h.arr.inject(&:+)


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll h, w;
	cin >> h >> w;

	vvll a(h, vll(w));
	REP(i, h){
		REP(j, w) cin >> a[i][j];
	}
	vector<P> cur, dst;
    cur.reserve(h*w);
    dst.reserve(h*w);
	REP(i, h){
		REP(j, w - 1){
			if(a[i][j] % 2){
				cur.push_back(P{i + 1, j + 1});
				dst.push_back(P{i + 1, j + 2});
				a[i][j + 1]++;
			}
		}
	}
	REP(i, h - 1){
		if(a[i][w - 1] % 2){
			cur.push_back(P{i + 1, w});
			dst.push_back(P{i + 2, w});
			a[i + 1][w - 1]++;
		}
	}
	ll n = cur.size();
	cout << n << endl;
	REP(i, n){
		cout << cur[i].first << " " << cur[i].second << " ";
		cout << dst[i].first << " " << dst[i].second << endl;
	}
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Vertex {
    vector<ll> node;
};
ll N, M;
Vertex V[10];

bool check(vector<ll> &v) {
    ll now = 0;
    REP(i, v.size()) {
        ll nxt = v[i];
        bool exist = false;
        REP(j, V[now].node.size()) {
            if (V[now].node[j] == nxt)
                exist = true;
        }
        if (!exist)
            return false;
        now = nxt;
    }
    return true;
}

int main() {
    cin >> N >> M;
    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(b);
        V[b].node.push_back(a);
    }

    vector<ll> v;
    REP(i, N - 1) {
        v.push_back(i + 1);
    }

    ll ans = 0;
    do {
        if (check(v))
            ans++;
    } while (next_permutation(v.begin(), v.end()));

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
    int N,K,ans=0;
    cin >> N >> K;
    int A[N+10]={};
    for(int i=0; i<N; i++){
        int x; cin >> x;
     A[x]++;
    }
    sort(A,A+N,greater<int>());
    for(int i=K; i<=N; i++){
        ans+=A[i];
    }
    cout << ans << endl;
	}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007
#define INF INT_MAX/3

using namespace std;


long N, K;

vector<long> way[2001];
long dis[2001][2001];
vector<pair<long, long> >hen;



void dik(long start){
	queue<pair<long, long> > Q;

	Q.push(make_pair(0, start));
	while(!Q.empty()){
		long po, cost;
		cost = Q.front().first;
		po = Q.front().second;
		Q.pop();
		if(dis[start][po] != INF){
			//cout << "con" << endl;
			continue;
		}
		dis[start][po] = cost;
		for(int i = 0; i < way[po].size(); i++){
			if(dis[start][way[po][i]] != INF){
				continue;
			}
			Q.push(make_pair(dis[start][po] + 1, way[po][i]));
		}
	}
}


void caldis(){
	for(int i = 0; i < N; i++){
		dik(i);
	}
}




int main(){
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			dis[i][j] = INF;
		}
	}
	for(int i = 0; i < N - 1; i++){
		long a, b;
		cin >> a >> b;
		a--;b--;
		way[a].push_back(b);
		way[b].push_back(a);
		hen.push_back(make_pair(a, b));
	}
	caldis();
	if(K%2 == 0){
		long long ans = INF;
		for(int mid = 0; mid < N; mid++){
			long long tmp = 0;
			for(int j = 0; j < N; j++){
				if(dis[mid][j] > K/2){
					tmp++;
				}
			}
			ans = min(tmp, ans);
		}
		cout << ans << endl;
	}else{
		long long ans = INF;
		for(int midhen = 0; midhen < hen.size(); midhen++){
			long long p1 = hen[midhen].first;
			long long p2 = hen[midhen].second;

			long long tmp = 0;
			for(int j = 0; j < N; j++){
				if((dis[p1][j] > (K-1)/2) && (dis[p2][j] > (K-1)/2)){
					tmp++;
				}
			}
			ans = min(tmp, ans);
		}
		cout << ans << endl;
	}

}


Measured memory_bytes: 31744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt() ;
		int d;
		int sum = 0;

		for(int i = 0; i < a-1; i++) {
			d = sc.nextInt();
			if((d - c) < b) {
				sum += (d-c);

			} else {
				sum += b;
			}
			c = d;
		}
		sum += b;
		System.out.println(sum);
	}

}


Measured memory_bytes: 63972
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
typedef long long ll;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
priority_queue<ll,vector<ll>,greater<ll> > q;
int k;
int main(){
	k=read();
	for(int i=1;i<=9;++i){
		q.push(i);
	}
	while(k--){
		ll u=q.top();
		q.pop();
		if(!k){
			printf("%lld\n",u);
			break;
		}
		int las=u%10;
		q.push(u*10+las);
		if(las-1>=0)q.push(u*10+las-1);
		if(las+1<=9)q.push(u*10+las+1);
	}
//	getchar();
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int counter = 0;
  rep(i,S.size()/2){
    if(S.at(i) != S.at((int)S.size()-1-i)) counter++;
  }
  
  cout << counter << endl;
}

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

#define print(x) cout << #x << '=' << x << endl

int main()
{
    long long a,b,c,d,ans1,ans2,ans3,ans4;
    cin >> a >> b >> c >> d;

    ans1 = a*c;
    ans2 = a*d;
    ans3 = b*c;
    ans4 = b*d;

    cout << max(ans1,max(ans2,max(ans3,ans4))) << endl;
    return 0;
}

Measured memory_bytes: 3136
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>

bool parse(const std::string& s, size_t& i) {
  std::set<char> pos, neg;
  assert(s[i] == '(');
  ++i;
  for (int j=0; j<3; ++j) {
    if (s[i] == '~') {
      char ch=s[++i];
      if (pos.count(ch)) goto fail;
      neg.insert(ch);
    } else {
      char ch=s[i];
      if (neg.count(ch)) goto fail;
      pos.insert(ch);
    }
    ++i;
    assert(s[i] == '&' || s[i] == ')');
    ++i;
  }
  if (i < s.length()) {
    assert(s[i] == '|');
    ++i;
  }

  return true;

fail:
  while (i < s.length() && s[i] != '(') ++i;
  return false;
}

int testcase_ends() {
  std::string s;
  std::cin >> s;
  if (s == "#") return 1;

  size_t i=0;
  while (i < s.length())
    if (parse(s, i)) 
      return !printf("yes\n");

  printf("no\n");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 3280
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
int test[123456];
signed main() {
	int n, a, sum = 0, ans = 0; cin >> n >> a;
	sum = n / gcd(n, a) + a / gcd(n, a) - 1;
	cout << sum * gcd(n,a) + 1 << endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
#define br "\n"

void solve(){
    ll n;
    cin >> n;
    if(n >= 400 && n < 600) cout << 8;
    else if(n >= 600 && n < 800) cout << 7;
    else if(n >= 800 && n < 1000) cout << 6;
    else if(n >= 1000 && n < 1200) cout << 5;
    else if(n >= 1200 && n < 1400) cout << 4;
    else if(n >= 1400 && n < 1600) cout << 3;
    else if(n >= 1600 && n < 1800) cout << 2;
    else if(n >= 1800 && n < 2000) cout << 1;

}
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}

Measured memory_bytes: 3644
n=int(input())
nas=0
da=list(map(int,input().split()))
for i in range(1,n-1):
    if (da[i-1] < da[i] and da[i] < da[i+1]) or (da[i-1] > da[i] and da[i] > da[i+1]):
        nas+=1
print(nas)

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

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    // (nx-zx)*(ny-zy)が白い部分の面積になる
    int zx =0,nx = w,zy =0,ny=h;

    rep(i,n){
        int x,y,a;
        cin >> x >> y >> a;
        // a=1ならxより左側を黒くする(zxがずれる)
        if(a ==1) zx=max(zx,x);
        // a=2ならxより右側を黒くする(zxがずれる)
        else if(a ==2) nx =min(nx,x);
        // a=3ならyより下側を黒くする(zxがずれる)
        else if(a ==3) zy = max(zy,y);
        // a=4ならyより上側を黒くする(zxがずれる)
        else ny = min(ny,y);
    }
    cout << max(nx-zx,0) * max(ny-zy,0) << endl;

    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String a, b, c, d, e, f;
        a = s.next();
        b = s.next();
        c = s.next();
        d = a.toUpperCase();
        e = b.toUpperCase();
        f = c.toUpperCase();

        System.out.print(d.charAt(0));
        System.out.print(e.charAt(0));
        System.out.print(f.charAt(0));
    }
}


Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
    static void solve(long x) {
        for (int a = 0; a<=1000;a++) {
            for (int b=-1000;b<=1000;b++) {
                if (a*a*a*a*a - b*b*b*b*b == x) {
                    System.out.println(a + " " + b);
                    return;
                }
            }
        }
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long x = in.nextLong();
        solve(x);
    }
}

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

int main() {
  int n, m;
  cin>>n>>m;
  int s[m], c[m];
  for (int i=0; i<m; i++) cin>>s[i]>>c[i];
  int min_i, max_i;
  if (n == 1) {
    min_i = 0;
    max_i = 9;
  } else if (n == 2) {
    min_i = 10;
    max_i = 99;
  } else {
    min_i = 100;
    max_i = 999;
  }
  for (int i=min_i; i<=max_i; i++) {
    string t = to_string(i);
    bool ok = true;
    for (int j=0; j<m; j++) {
      if (t[s[j] - 1] - '0' != c[j]) {
        ok = false;
      }
    }
    if (ok) {
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = sorted(int(input()) for i in range(n))
median = a[(n-1)//2]
ans = 0
for i in range(n):
    ans += 2*abs(a[i] - median)
if n % 2 == 0:
    ans -= abs(a[(n-1)//2+1] - median)
else:
    ans -= min(abs(a[(n-1)//2+1] - median), abs(a[(n-1)//2-1] - median))
print(ans)

Measured memory_bytes: 7488
#pragma GCC optimize("Ofast")   //Comment optimisations for an interatcive problem - use endl
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cout<<"///REACHED///\n";
#define  deb1(x)        cout<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cout<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cout<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int qq;
ll x, y;
ll res=0;

//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//

int main(){
	fastio;randomINIT;

	cin>>x>>y;
	if(x<=3)res+=(4-x)*100000;
	if(y<=3)res+=(4-y)*100000;
	if(x==y && x==1)res+=(4)*100000;
	cout<<res;


}

Measured memory_bytes: 2560
N = 8
flag_row = [False]*N
flag_col = [False]*N
flag_diag_right = [False]*(2*N-1)
flag_diag_left  = [False]*(2*N-1)
B = [ [False for n in range(N)] for n in range(N)]

def ShowBoard():
    for i in range(N):
        for j in range(N):
            if B[i][j] :
                if flag_row[i] != j:
                    return

    for i in range(N):
        for j in range(N):
            if flag_row[i] == j:
                print("Q", end = "")
            else:
                print(".", end = "")
        print()

def SetQueen(i):
    if i == N  :
        ShowBoard()
        return

    for j in range(N):
        if flag_col[j] == False and flag_diag_left[i + j] == False and flag_diag_right[i - j + (N -1)] == False :

            flag_row[i] = j
            flag_col[j] = True
            flag_diag_left[i + j] = True
            flag_diag_right[i - j + (N -1)] = True

            SetQueen(i + 1)

            flag_row[i] = False
            flag_col[j] = False
            flag_diag_left[i + j] = False
            flag_diag_right[i - j + (N -1)] = False

def Main():
    K = int(input())

    for k in range(K):
        r, c = map(int, input().split())
        B[r][c] = True

    SetQueen(0)

Main()


Measured memory_bytes: 5620
#input
A, B = map(int, input().split())

#output
import math
p = math.ceil(max(A/0.08, B/0.1))
q = math.floor(min((A+1)/0.08, (B+1)/0.1))

answer = 0
if p < q:
    answer = p
else:
    answer = -1

print(answer)

Measured memory_bytes: 3064
n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

count = {}
for x in v:
    if x in count:
        count[x] += 1
    else:
        count[x] = 1

fact = [1] * 51
for i in range(1, 51):
    fact[i] = fact[i-1] * i

def comb(a, b):
    return fact[a] // fact[a-b] // fact[b]

ans = 0
if v[0] == v[a-1]:
    b = min(b, count[v[0]])
    for i in range(a, b+1):
        ans += comb(count[v[0]], i)
    print(v[0])
    print(ans)
else:
    c = v[:a].count(v[a-1])
    print(sum(v[:a]) / a)
    print(comb(count[v[a-1]], c))

Measured memory_bytes: 3064
//nani?
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
using namespace __gnu_pbds;
const int inf=1e7;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MAX_N = 2e5+5;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll a[MAX_N];
ll b[MAX_N];
ll cnt[MAX_N][4];

int main(){
    fastio;
    ll n;
  	cin>>n;
  set <string> s;
  	f(i,0,n){
        string c;
      	cin>>c;
    	s.insert(c);
    }
  cout<<s.size()<<endl;

    
} 


Measured memory_bytes: 19240
#include <iostream>
#include<string>
#include <vector>
int main()
{
	std::string s;
	while (getline(std::cin, s) && s != "0")
	{
		std::vector<int> lst;
		int ans = 0;
		for (size_t i = 0; i < s.size(); i++)
		{
			ans += s[i] - '0';
		}
		std::cout << ans << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3172
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


m,d = list(map(int, input().split()))
ans = 0
for i in range(1, m+1):
    for j in range(1, d+1):
        if j<10:
            continue
        d1 = int(str(j)[0])
        d2 = int(str(j)[1])
        if d1*d2==i and d1>=2 and d2>=2:
            ans += 1
print(ans)

Measured memory_bytes: 68648
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;


const ll MOD = 1e9+7;

struct DICE{
    ll num[6];
    ll top;
    ll north,south,west,east;

    DICE(){
        top = 0;
        south = 1;
        east = 2;
        west = 3;
        north = 4;
    }

};


int main(){
    ll n;
    cin >> n;
    DICE d[n];

    srand(time(NULL));
    rep(i,0,n){
        rep(j,0,6) cin >> d[i].num[j];
    }

    rep(i,0,n-1){
        rep(j,i+1,n){
            ll roopcnt = 0;

            while(roopcnt++ <= 50){
                ll rnd = rand() % 4;
                ll tmp;

                switch(rnd){
                    case 0:
                        tmp = d[j].south;
                        d[j].south = 5 - d[j].top;
                        d[j].north = d[j].top;
                        d[j].top = tmp;
                        break;
                    case 1:
                        tmp = d[j].west;
                        d[j].west = 5 - d[j].top;
                        d[j].east = d[j].top;
                        d[j].top = tmp;
                        break;
                    case 2:
                        tmp = d[j].north;
                        d[j].north = 5 - d[j].top;
                        d[j].south = d[j].top;
                        d[j].top = tmp;
                        break;
                    case 3:
                        tmp = d[j].east;
                        d[j].east = 5 - d[j].top;
                        d[j].west = d[j].top;
                        d[j].top = tmp;
                        break;
                }
                if(d[j].num[d[j].east] == d[i].num[d[i].east] && d[j].num[d[j].north] == d[i].num[d[i].north] && d[j].num[d[j].south] == d[i].num[d[i].south]){
                    if(d[j].num[d[j].west] == d[i].num[d[i].west] && d[j].num[d[j].top] == d[i].num[d[i].top] && d[j].num[5-d[j].top] == d[i].num[5-d[i].top]){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }

            
        }
    }
    
    cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 3104
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	double a[n];
	forci(0,n){
		cin>>a[i];
	}
	sort(a,a+n);
	double sum=(a[0]+a[1])/2.0;
	for(int i=2;i<n;i++){
		sum=(sum+a[i])/2.0;
	}
	cout<<fixed<<setprecision(6)<<sum<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

bool rec(int a,int b,int c,int t){
    if(c>b&&b>a)return true;
    if(t==0)return false;
    bool res=false;
    res|=rec(a*2,b,c,t-1);
    res|=rec(a,b*2,c,t-1);
    res|=rec(a,b,c*2,t-1);
    return res;
}

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

    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(rec(a,b,c,k))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3684
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    int n, m ,x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    rep(i,n){
        cin >> c.at(i);
        rep(j,m){
            cin >> a.at(i).at(j);
        }
    }
    
    int ans = 1001001001;
    
    rep(i,1<<n){
        int cost = 0;
        vector<int> d(m);
        rep(j,n){
            if(i>>j&1){
                cost += c.at(j);
                rep(s,m) d.at(s) += a.at(j).at(s);
            }
        }
        bool ok = true;
        rep(j,m) if(d.at(j) < x) ok=false;
        if(ok) ans = min(ans,cost);
    }
    
    if(ans == 1001001001) dunk("-1");
    else dunk(ans);
    
    return 0;
}



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

using namespace std;



int main(){


 
 ios_base::sync_with_stdio(NULL); 
 cin.tie(0);
  #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);
#endif

  int n;
  cin>>n;
  int k;
  cin>>k;
  vector< double  > arr(n);
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    arr[i]=(double(a) +1.0)/2;
  }

  double maxx = 0.0;
  for(int i=0;i<min(k,n);i++){
    maxx+= arr[i];
  }
  double  temp = maxx;
  for(int i=k;i<n;i++){
    temp +=(-1*arr[i-k]+arr[i]) ;
    maxx = max(maxx,temp);


  }
  printf("%.8f\n",maxx );

}

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

fun solve(N: Int, K: Int, x: IntArray){
    (0 until N).map{ Pair(x[it], it+1) }.map{ Math.min(Math.abs(K-it.first), it.first) }.sum().let{ println(2*it) }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val K = sc.next().toInt()
    val x = IntArray(N)
    for (i in 0 until N) {
        x[i] = sc.next().toInt()
    }
    solve(N, K, x)
}



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


int main(){
  int bus[20],index;
  for(int i=0;i<=9;i++)bus[i]=i;
  index=10;
  for(int i=5;i>=0;i--)bus[index++]=i;
  //for(int i=0;i<16;i++)cout << bus[i] << " ";
  //cout << endl;
  int n,st,ed,rs;
  cin >> n;
    vector<int> perm,vec;
    bool giveway;
    for(int k=0;k<n;k++){
      perm.clear();vec.clear();
      giveway = false;
      cin >> st >> ed;
      rs = st;
      
      while(st != ed){

	perm.push_back(st);
	if(!giveway)st++;
	if(giveway)st--;
	if(!giveway &&st == 10){
	  st = 5;
	  giveway = true;
	}
	else if(giveway && st == 0){
	  giveway = false;
	}
      }
      giveway = false;
      perm.push_back(ed);
     
      if(1<=rs && rs<=5){
     
	while(rs != ed){
	  vec.push_back(rs);
	  if(!giveway)rs--;
	  if(giveway)rs++;
	  if(!giveway &&rs == 0){
	    giveway = true;
	  }
	  else if(giveway && rs == 10){
	    rs = 5;
	    giveway = false;
	  }
	}
  vec.push_back(ed);
      if(perm.size() > vec.size() )perm = vec;
      }
    
  
      for(int i=0;i<perm.size();i++){
	cout << perm[i];
	i == perm.size()-1 ? cout << endl:cout << " ";
      }


    }

  
  return 0;
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    ll n,k,total;
    cin>>n>>k;

    total=0;

    vector<ll> arr;
    while(n--) {
        ll num;
        cin>>num;
        arr.push_back(num);
        total+=num;
    }

    sort(arr.begin(),arr.end(),greater<ll>());

    for(int i=0;i<arr.size();i++) {
        if(k>0) {
            total-=arr[i];
            k--;
        }
        else {
            break;
        }
    }

    cout<<total<<endl;



}




Measured memory_bytes: 5332
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"

#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define LINF ((ll)1 << 60)
#define INF (1 << 28)
template<typename T>
void chmax(T& a, T b) {
        if (a < b) a = b;
}
template<typename T>
void chmin(T& a,T b) {
        if (a > b) a = b;
}
//.....................
ull mod = (int)1e9 + 7;
const int MAX = (int)2e5 + 5;

ll N;
vector<ll> a;
ll res;

void solve() {
        cin >> N;
        a.resize(N);
        rep(i, N) cin >> a[i];
        rep(i, N) {
                int end_id = N;
                ll sum = 0;
                REP(j, i, N) {
                        sum += a[j];
                        if (a[j] == 0) {
                                end_id = j;
                                break;
                        }
                }
                res += sum / 2;
                i = end_id;
        }
        cout << res << endl;
}

signed main() {
        int T = 1;
        cout << fixed << setprecision(20);
        rep(i, T) {
                solve();
        }
        return 0;
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

string merge(string a, string b) {
	string res = "";
	for (size_t i = 0; i < a.size() + b.size(); i++) {
		if (i % 2 == 0) {
			res += a[i / 2];
		} else {
			res += b[i / 2];
		}
	}
	return res;
}

signed main() {
	string o, e;
	cin >> o >> e;
	cout << merge(o, e) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt32();
            var N = line[0];
            var M = line[1];
            var C = line[2];

            var b = consoleReader.SplitInt32();
            var a = consoleReader.RepeatSplitInt32(N).ToArray();

            return Enumerable.Range(0, N).Count(i => a[i].Zip(b, (x, y) => x * y).Sum() + C > 0);
        }

        const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader
    {
        public virtual string String() => Console.ReadLine();
        public int Int32() => int.Parse(String());
        public long Int64() => long.Parse(String());
        public ulong UInt64() => ulong.Parse(String());
        public double Double() => double.Parse(String());
        public string[] Split() => String().Split().ToArray();
        public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray();
        public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray();
        public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray();
        public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray();

        public IEnumerable<string> Repeat(int count)
        {
            for (int i = 0; i < count; i++)
                yield return String();
        }
        public IEnumerable<int> RepeatInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int32();
        }
        public IEnumerable<long> RepeatInt64(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Int64();
        }
        public IEnumerable<string[]> RepeatSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return Split();
        }
        public IEnumerable<int[]> RepeatSplitInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return SplitInt32();
        }
    }
}


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

int main()
{
	int nA = 0, nB = 0;
	while (cin >> nA >> nB)
	{
		string strOut;
		int nSum = nA + nB;
		strOut = to_string(nSum);
		cout << strOut.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
	
	if(std::abs(a - c) <= d or (std::abs(a - b) <= d and std::abs(c - b) <= d)) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
int x ,y;
for(int i=0; ;i++)
{
cin>>x>>y;
if(x==0&&y==0)
break;
else if(x>y)
cout<<y<<' '<<x<<endl;
else
cout<<x<<' '<<y<<endl;
}
    return 0;
}



Measured memory_bytes: 3020
import numpy as np
N = int(input())
A_1 = [0] + list(map(int,input().split()))
A_2 = [0] + list(map(int,input().split()))
s = []

for i in range(1,N+1):
    sum1 = np.sum(A_1[:i])
    sum2 = np.sum(A_2[i+1:])
    s.append(sum1+sum2+A_1[i]+A_2[i])

print(int(max(s)))
    

Measured memory_bytes: 12508
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 3e5 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}

vector<int> g[N];
int n, k;
vector<int> mt;
vector<char> used;
 
bool try_kuhn (int v) {
	if (used[v])  return false;
	used[v] = true;
	for (size_t i=0; i<g[v].size(); ++i) {
		int to = g[v][i];
		if (mt[to] == -1 || try_kuhn (mt[to])) {
			mt[to] = v;
			return true;
		}
	}
	return false;
}
 

void solve()
{
		cin >> n;
		vector<pii> p(n), q(n);
		rep(i, n) cin >> p[i].F >> p[i].S;
		rep(i, n) cin >> q[i].F >> q[i].S;
		sort(all(p));
		sort(all(q));
		rep(i, sz(p)){
			rep(j, sz(q)){
				if(p[i].F < q[j].F && p[i].S < q[j].S) g[i].pb(j + n), g[j + n].pb(i);
			}
		}
	k = 2 * n;
	mt.assign (k, -1);
	for (int v=0; v<n; ++v) {
		used.assign (n, false);
		try_kuhn (v);
	}
 
 	int res = 0;
	for (int i=n; i<2*n; ++i)
		if (mt[i] != -1) ++res;
	cout << res;
}

int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 10708
#include <stdio.h>
int main(){
    int a, b;
    scanf("%d %d",&a, &b);
    
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else if(a==b){
        printf("a == b\n");
    }    
    
    return 0;
    
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;cin>>a>>b;
  
  int ans=0;
  for(int i=a;i<=b;i++){
    string s=to_string(i);
    int len=s.size();
    int half=(len+1)/2;
    rep(j,half){
      if(s[j]!=s[len-j-1])break;
      if(j==half-1)ans++;
    }
  }
  
  cout(ans);
  return 0;
}

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

int	main()
{
	int	n;
	cin >> n;
	string	t, h;
	int	score_t = 0, score_h = 0;
	for (int i = 0; i < n; ++i) {
		cin >> t >> h;
		if (t < h)
			score_h += 3;
		else if (t > h)
			score_t += 3;
		else {
			++score_t;
			++score_h;
		}
	}
	cout << score_t << " " << score_h << endl;
}


Measured memory_bytes: 3172
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node {
    int parent, left, right;
};

Node T[MAX];
int n;

void preParse(int u){
    if ( u == NIL ) return;
    printf(" %d", u);
    preParse(T[u].left);
    preParse(T[u].right);
}

void inParse(int u){
    if ( u == NIL ) return;
    inParse(T[u].left);
    printf(" %d", u);
    inParse(T[u].right);
}

void postParse(int u){
    if ( u == NIL ) return;
    postParse(T[u].left);
    postParse(T[u].right);
    printf(" %d", u);
}
int main(){
    int v, l, r, root = 0;
    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) T[i].parent = NIL;

    for ( int i = 0; i < n; i++ ){
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if ( l != NIL ) T[l].parent = v;
        if ( r != NIL ) T[r].parent = v;
    }

    for( int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i; 

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
        
    return 0;
}


Measured memory_bytes: 2732
list = []
for x in ["S", "H", "C", "D"]:
    for y in [str(i) for i in range(1, 14)]:
        list.append(x+" "+y)
n = int(input())
while n > 0:
    list.remove(input())
    n -= 1
for i in list:
    print(i)


Measured memory_bytes: 5604
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val k = cin.nextInt()
    var ans: Long = 0
    for (b in k+1..n) {
        val x_max = n / b
        val r_min = k
        val r_max = b - 1
        ans += x_max * (r_max - r_min + 1)
        val exd = n - b * x_max
        if (exd >= r_min) {
            ans += exd - r_min + 1
        }
    }
    if (k == 0) {
        ans = n.toLong() * n.toLong()
    }
    println(ans)
}

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

using namespace std;

int main(){
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j<= 9; j++)
        {
            cout << i << "x" << j << "=" << i*j << endl;

        }
    }


    return 0;
}

Measured memory_bytes: 1116
#include<stdio.h>
#include<stdlib.h>
int main()
{
	long long a[10]={},ans=0,temp=0;
	for(int i=1;i<=7;i++)
		scanf("%lld",&a[i]);
	//3 6 7号方块不可能拼出高为2的矩形 直接pass
	ans+=(a[1]/2)*2; //每两个一方块可以拼成单位为2的矩形
	ans+=a[2]; //一个方形方块就是一个单位
	ans+=(a[4]/2)*2; //每两个J方块可以组成单位为2的矩形
	ans+=(a[5]/2)*2; //每两个L方块可以组成单位为2的矩形
	if(a[1]>0&&a[4]>0&&a[5]>0){ //一JL方块3个单位
		a[1]--; a[4]--; a[5]--;
		temp+=(a[1]/2)*2; //每两个一方块可以拼成单位为2的矩形
		temp+=a[2]; //一个方形方块就是一个单位
		temp+=(a[4]/2)*2; //每两个J方块可以组成单位为2的矩形
		temp+=(a[5]/2)*2; //每两个L方块可以组成单位为2的矩形
		temp+=3;
	}
	ans=ans>temp?ans:temp;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(mut x: isize, mut k: isize, d: isize);
    x = x.abs();

    let xd = x / d;

    if xd > k {
        println!("{}", (x - (k * d)).abs());
    } else {
        let aaa = x % d;

        let ax = (k - xd) % 2;
        if ax == 0 {
            println!("{}", aaa);
        } else {
            println!("{}", (aaa - d).abs());
        }
    }
}


Measured memory_bytes: 2176
A, B, C = map(int, input().split())

if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    print (0)
    exit()

if A == B == C:
    print (-1)
    exit()

def check(a, b, c):
    if a % 2 == b % 2 == c % 2 == 0: #すべて偶数の時
        return True 
    return False


count = 0
while True:
    if check(A, B, C):
        count += 1
        A, B, C = (B + C)//2, (C + A)//2 , (A + B)//2
    else:
        break
print (count)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}  

int main() {
	char s[20];
	scanf("%s", s);
	for(int i = 0; s[i]; i ++) {
		if(i == 4) putchar(' ');
		putchar(s[i]);
	}
	puts("");
}


Measured memory_bytes: 256
#import numpy as np

H, W = map(int, input().split())
masu = [input() for i in range(H)]
#temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
#masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]

#dp = np.zeros((H, W))
dp = [[0]*W for i in range(H)]
if masu[0][0] == "#":
    dp[0][0] = 1

for i in range(0,H):
    for j in range(0,W):
        if i == 0:
            a = 100000
        else:
            if masu[i][j] == "#" and masu[i-1][j] == ".":
                a = dp[i-1][j] + 1
            else:
                a = dp[i-1][j]
        if j == 0:
            b = 100000
        else:
            if masu[i][j] == "#" and masu[i][j-1] == ".":
                b = dp[i][j-1] + 1
            else:
                b = dp[i][j-1]
        if a != 100000 or b != 100000:
            dp[i][j] = min([a, b])
print(int(dp[H-1][W-1]))


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int ans = 0;
	repn(i, 1, n + 1){
		int x;
		cin >> x;
		ans += ((x & 1) && (i & 1));
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3652
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		in.close();
		
		List<Integer> list = new LinkedList<>();
		int n = s.length();
		char c = s.charAt(0);
		int count = 1;
		for(int i=1;i<n;i++) {
			if(s.charAt(i)==c) count++;
			else {
				list.add(count);
				count = 1;
				c = s.charAt(i);
			}
		}
		list.add(count);
		if(list.size()==1) System.out.println(list.get(0));
		else {
			while(list.size()>2) {
				int size = list.size();
				int first = list.get(0);
				int last = list.get(list.size()-1);
				if(first>last) list.add(list.remove(size-1)+list.remove(size-2));
				else list.add(0,list.remove(1)+list.remove(0));
			}
			System.out.println(Math.max(list.get(0), list.get(1)));
		}
	}

}


Measured memory_bytes: 30408
n,a,b = map(int,input().split())
mod = 10**9+7
a = min(a,n-a)
b = min(b,n-b)
m = max(a,b)
X = [0]*(m+1)
Y = [0]*(m+1)
X[0] = 1
X[1] = n
Y[0] = Y[1] = 1

for i in range(2,m+1):
    X[i] = X[i-1]*(n-i+1)%mod
    Y[i] = Y[i-1]*i%mod
    
ans = (((pow(2,n,mod)-1)%mod-X[a]*pow(Y[a],mod-2,mod)%mod)%mod-X[b]*pow(Y[b],mod-2,mod)%mod)%mod
print(ans)

Measured memory_bytes: 18804