akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := nextInt()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
	}
	var evens, odds []int
	var isEvenNum bool
	for _, a := range as {
		if isEvenNum {
			evens = append(evens, a)
			isEvenNum = false
		} else {
			odds = append(odds, a)
			isEvenNum = true
		}
	}
	if len(as)%2 == 0 {
		for i := len(evens) - 1; i >= 0; i-- {
			fmt.Printf("%d ", evens[i])
		}
		for _, odd := range odds {
			fmt.Printf("%d ", odd)
		}
	} else {
		for i := len(odds) - 1; i >= 0; i-- {
			fmt.Printf("%d ", odds[i])
		}
		for _, even := range evens {
			fmt.Printf("%d ", even)
		}
	}
	fmt.Println()
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 13080
#include<stdio.h>

int main(void){
    char c[3][3];
    int i;

    for(i = 0;i < 2;i++) scanf("%c%c%c ",&c[i][0],&c[i][1],&c[i][2]);
    scanf("%c%c%c",&c[i][0],&c[i][1],&c[i][2]);
    
    for(i = 0;i < 3;i++) printf("%c",c[i][i]);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;

  cin >> n;

  bool can = false;
  for(int i = 0; i * 4 <= n; i++) {
    int left_price = n - 4 * i;

    if(left_price % 7 == 0) {
      can = true;
      break;
    }
  }

  if(can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll a,b;

long long calc(ll x){
    if(x%2!=0){
        if((x+1)/2%2==0) return 0;
        else return 1;
    }
    else{
        return calc(x+1)^(x+1);//x
    }
}
int main(){
    cin>>a>>b;
    cout<<(calc(b)^calc(a-1))<<endl;
    //cout<<calc(a-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    # 作りたい要素数nで初期化
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズ
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


import sys
input = sys.stdin.readline

N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

P = [1]*(N+1)
uni = UnionFind(N+1)
for a, b in AB:
    P[a] += 1
    P[b] += 1
    uni.Unite(a, b)

ans = []
for n in range(1, N+1):
    ans.append(uni.Count(n)-P[n])

for c, d in CD:
    if uni.isSameGroup(c, d):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(*ans)

Measured memory_bytes: 109020
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 18;

long long A[maxN], B[maxN];

long long med(long long* T, int n)
{	return n % 2 == 1 ? T[n/2] : (T[n/2-1] + T[n/2]) / 2;	}

void solve()
{
	int n;
	scanf ("%d", &n);
	FOR(i, 0, n)
	{
		scanf ("%lld%lld", A+i, B+i);
		if (n % 2 == 0)
			A[i] *= 2, B[i] *= 2;
	}
	
	sort(A, A+n); sort(B, B+n);
	
	//printf("%lld %lld\n", med(A, n), med(B, n));
	
	long long res = med(B, n) - med(A, n) + 1;
	printf("%lld\n", res);
}

int main()
{
	int t = 1;
	//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}





Measured memory_bytes: 6944
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    g = Graph()
    
    for i in range(M):
        a,b = inputMap()
        g.add_edge(a-1, b-1, 1)
        g.add_edge(b-1, a-1, 1)
        
    d = Dijkstra(g, 0)
    tmp = d.shortest_distance(N-1)
    
    if tmp <= 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
        
        
    
class Graph(object):
    # 隣接リストによる有向グラフ
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    # ダイクストラ法（二分ヒープ）による最短経路探索
    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        # startノードからgoalノードまでの最短距離
        return self.dist[goal]

    def shortest_path(self, goal):
        # startノードからgoalノードまでの最短経路
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]
        
if __name__ == "__main__":
	main()


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

typedef long long ll;

int main(){
    string s;
    while(1){
        cin>>s;
        if(s.size() == 1 && s[0] == '0') break;
        vector<vector<ll> > dp(80000+10,vector<ll>(11+10));
        
        ll ans = 0;
        for(int i=0; i<s.size(); i++){
            int cur = s[i] - '0';
            if(cur != 0) dp[i+1][cur]++;

            for(int j=0; j<11; j++){
                dp[i+1][(j*10+cur)%11] += dp[i][j];
            }

            ans += dp[i+1][0];
        } 

        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 18636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator

#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 arr[25];
int brr[25];
int crr[25];

int32_t main()
{
    fast;
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    for(int i=1;i<=n;i++)
        cin>>brr[i];

    for(int i=2;i<=n;i++)
        cin>>crr[i];

    int ans=brr[arr[1]];
    for(int i=2;i<=n;i++)
    {
        ans+=brr[arr[i]];
        if(arr[i]==arr[i-1]+1)
            ans+=crr[arr[i]];
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<ll> a(n), s(n), b(n);
    rep(i, n)cin >> a[i];
    rep(i, n){
        if(!i)s[i] = a[i];
        else s[i] = s[i-1] + a[i];
    }
    rep(i, n){
        b[i] = s[i]-i-1;
        if(b[i] < 0)b[i] = k - (-b[i] % k);
        b[i] %= k;
    }
    map<ll, ll> mp;
    mp[0]++;
    rep(i, n){
        if(i == k-1)mp[0]--;
        else if(i >= k)mp[b[i-k]]--;
        ans += mp[b[i]];
        mp[b[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 17408
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

constexpr int digit = 40;

void solve() {
    LL n,k;
    cin >> n >> k;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VI cnt(digit);
    REP(i,0,n) REP(j,0,digit) if (a[i] & (1LL<<j)) cnt[j]++;
    VVLL dp(41, VLL(2, -1));
    dp[0][0] = 0;
    REP(i,0,digit) {
        int topd = digit-1-i;
        bool is1 = k & (1LL<<topd);
        //dump(i);
        REP(j,0,2) {
            if (dp[i][j] < 0) continue;
            REP(l,0,2) {
                if (!is1 && !j && l) continue;
                dp[i+1][j || (!l && is1)] = max(dp[i][j] + (LL)pow(2, topd) * ((n - cnt[topd] * 2) * l + cnt[topd]), dp[i+1][j || (!l && is1)]);
            }
        }
    }
    cout << max(dp[digit][0], dp[digit][1]) << endl;
}

int main() {
    solve();
    
    return 0;
}

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

int main() {
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
    {
        cout<<"1"<<endl;
    }
     if(b==0)
    {
        cout<<"2"<<endl;
    }
     if(c==0)
    {
        cout<<"3"<<endl;
    }
     if(d==0)
    {
        cout<<"4"<<endl;
    }
     if(e==0)
    {
        cout<<"5"<<endl;
    }
	// your code goes here
	return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    if (a >= b && a >= c)
        ans = a * 10 + b + c;
    else if (b >= a && b >= c)
        ans = b * 10 + a + c;
    else
        ans = c * 10 + a + b;

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


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

MOD = 10 ** 9 + 7

N, K = map(int, input().split())
g = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)


if N == 1 and K == 1:
    print (1)
    exit()

check = [0] * (N + 1)
count = [K - 1] * (N + 1)

check[1] = 1
# count[1] -= 1

ans = K
stack = [1]
while stack:
    tmp = stack.pop()
    for next_ in g[tmp]:
        if check[next_] == 1:
            continue
        ans *= count[tmp]
        ans %= MOD
        count[tmp] -= 1
        count[next_] -= 1
        stack.append(next_)
        check[tmp] = 1

print (ans)


Measured memory_bytes: 27624
#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 all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}
template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}
template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}


int main()
{
	ll n,avr = 0;
	cin >> n;
	vll x(n);
	rep(i,n){
		cin >> x[i];
		avr += x[i];
	}
	avr /= n;

	ll ans1 = 0,ans2 = 0;
	rep(i,n)ans1 += pow(x[i] - avr, 2);
	rep(i,n)ans2 += pow(avr + 1 - x[i], 2);
	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::collections::VecDeque;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let n = it.next().unwrap().parse::<usize>().unwrap();
    let m = it.next().unwrap().parse::<usize>().unwrap();
    let s = it.next().unwrap().as_bytes();
    let mut to = vec![vec![0; n]; 2];
    let mut g = vec![Vec::new(); n];
    for _ in 0..m {
        let a = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b = it.next().unwrap().parse::<usize>().unwrap() - 1;
        to[(s[b]-b'A') as usize][a] += 1;
        to[(s[a]-b'A') as usize][b] += 1;
        g[a].push(b);
        g[b].push(a);
    }
    let mut visit = vec![0; n];
    let mut qu = VecDeque::new();
    for i in 0..n {
        if to[0][i] == 0 || to[1][i] == 0 {
            qu.push_back(i);
            visit[i] = 1;
        }
    }
    while !qu.is_empty() {
        let p = qu.pop_front().unwrap();
        let idx = (s[p] - b'A') as usize;
        for &t in &g[p] {
            to[idx][t] -= 1;
            if to[idx][t] == 0 && visit[t] == 0 {
                qu.push_back(t);
                visit[t] = 1;
            }
        }
    }
    println!("{}", if visit.iter().any(|&x| x == 0) { "Yes" } else { "No" });
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  string s;
  cin >> s;
  int p;
  cin >> p;
  for (int i = 0; i < p; ++i) {
    string command;
    int a, b;
    cin >> command >> a >> b;
    if (command == "print") {
      fprintf(stdout, "%s\n", s.substr(a, b - a + 1).c_str());
    }
    else if (command == "reverse") {
      reverse(s.begin() + a, s.begin() + b + 1);
    }
    else if (command == "replace") {
      string t;
      cin >> t;
      s.replace(a, b - a + 1, t);
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <stack>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define endl "\n"


int main() {
    ios::sync_with_stdio(false);
    int A,B;
    cin>>A>>B;
    if(B%A==0){
        cout<< A+B;
    }else{
        cout<< B-A;
    }
}

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " = " << x << endl
#define print_array(arr, len) {cerr << #arr << " = "; for (int i = 0; i < len; i++) cerr << arr[i] << " "; cerr << endl;}
#define print_iterable(it) {cerr << #it << " = "; for (const auto &e : it) cerr << e << " "; cerr << endl;}
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) (void)0
#define print_iterable(it) (void)0
#endif

using ll = long long;
const int N = 4;

ll cost[N];
ll amount[N];

void solve()
{
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &cost[i]);
        amount[i] = 1LL << i;
    }
    ll n;
    scanf("%lld", &n);
    n *= 4;

    for (int i = 1; i < N; i++)
        cost[i] = min(cost[i], 2 * cost[i - 1]);

    ll total = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        ll full = n / amount[i];
        total += full * cost[i];
        n -= full * amount[i];
    }

    printf("%lld\n", total);
}

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

    solve();

    eprintf("\n\ntime = %.3lf\n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);

using namespace std;

signed main(){
    int n;
    cin >> n;
    vector<vector<int>> v(3);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x % 4 == 0){
            v[0].push_back(x);
        }
        else if(x % 2 == 0){
            v[1].push_back(x);
        }
        else{
            v[2].push_back(x);
        }
    }
    if(v[2].size() == 0){
        cout << "Yes";
        exit(0);
    }
    if(v[0].size() == 0){
        cout << "No";
        exit(0);
    }
    if(v[1].size() == 0){
        if(v[2].size() <= v[0].size() + 1){
            cout << "Yes";
            exit(0);
        }else{
            cout << "No";
            exit(0);
        }
    }else{
        if(v[2].size() <= v[0].size()){
            cout << "Yes";
            exit(0);
        }else{
            cout << "No";
            exit(0);
        }
    }
}

Measured memory_bytes: 1528
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	long long A, B, C, X, Y;
	long long price, temp, a, b;

	cin >> A >> B >> C >> X >> Y;

	int MAX = max(X, Y);
	price = X * A + Y * B;

	for (int i = 0; i <= 2 * MAX; i = i + 2) {
		a = (X - i / 2)*A;
		b = (Y - i / 2)*B;
		if (a < 0)a = 0;
		if (b < 0)b = 0;
		temp = i * C + a + b;

		if (temp < price) {
			price = temp;
		}
	}

	cout << price;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N,A[2*100000+10]={};
signed main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
    A[i]-=i+1;
  }
  sort(A,A+N);
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=abs(A[i]-A[N/2]);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s.substr(i, 3) == "ABC") ++ans;
    }

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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	r := getNextFloat64(scanner)
	fmt.Fprintln(writer, r*2*math.Pi)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = ll(1e8+7);
const ll MAX_N = ll(1e5 + 5);
const ll INF = LLONG_MAX;
#define REP(i, n) for (int i = 0; i < n; i++)


int main() {
    ll n, a[MAX_N], sum = 0, S, ans = INF;
    cin >> n >> S;
    REP(i,n) cin >> a[i];
    ll left = 0, right = 0;
    while(right <= n){
        if(sum < S){
            sum += a[right];
            right++;
        }
        else {
            ans = min(ans, right - left);
            sum -= a[left];
            left++;
        }
    }
    cout << (ans==INF?0:ans) << endl;
    return 0;
}



Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int N;
vector<int> graph[100005];
vector<int> dist;
 
void dfs(int cur, int d=0, int p=-1) {
  dist[cur] = d;
  for (int next : graph[cur]) {
    if (next == p) continue;
    dfs(next, d+1, cur);
  }
}
 
vector<int> calcDist(int start) {
  dist = vector<int> (N+1);
  dfs(start);
  return dist;
}
 
int main() {
  // UとVからそれぞれの頂点までの距離を求める、Uからの距離が小さいものの中でVからの距離-1が最大のもの
  int U, V;
  cin >> N >> U >> V; // 鬼の青木くんがVに最初いる
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
 
  vector<int> distU = calcDist(U);
  vector<int> distV = calcDist(V);
  
  int ans = 0;  
  for (int i = 1; i < N+1; i++) {
    if (distU[i] < distV[i]) {
      ans = max(ans, distV[i] - 1);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 13652
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ARC067C();

#if 1
int main()
{
	ARC067C();
	fflush(stdout);
	return 0;
}
#endif

template <class _T> void tp_getPrimes(_T targ, std::map<_T, _T>& primes)
{
	_T target = targ;
	_T i = 2;
	while ((i * i) <= target) {
		if ((target % i) == 0) {
			target /= i;
			primes[i]++;
		}
		else {
			i++;
		}
	}
	if (target > 1) {
		primes[target]++;
	}
}

static void ARC067C()
{
	int N;
	getint(N);

	std::vector<LLONG> dp(N + 1, 0);
	std::map<LLONG, LLONG> primes;
	for (int i = 1; i <= N; i++) {
		tp_getPrimes<LLONG>((LLONG)i, primes);
	}

	LLONG ans = 1;
	for (auto it = primes.begin(); it != primes.end(); it++) {
		ans = (ans * (it->second + 1)) % MOD_NUM;
	}
	//	ans--;	// all 0
	//	ans++;	//	1
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const long long int INF=1e18L+5; 
long long int dp[100001];
long long int newdp[100001];

int main()
{
	fastio;
	int n,w;
	cin>>n>>w;
	vector<pair<int,int>>a(n+1);
	long long sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].first>>a[i].second;
		sum+=a[i].second;
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=sum;j++)
		{
			if(i==1)
			{
				if(j==0)
				{
					newdp[j]=0;
					continue;
				}
				if(a[i].second==j)newdp[j]=a[i].first;
				else
				{
					newdp[j]=INF;
				}
				continue;
			}
			if(a[i].second>j)newdp[j]=dp[j];
			else
			{
				newdp[j]=min(dp[j],dp[j-a[i].second]+a[i].first);
			}
		}
		for(int j=0;j<=sum;j++)dp[j]=newdp[j];
	}
	long long int ans=0;
	for(long long int j=0;j<=sum;j++)
	{
		if(newdp[j]<=w)ans=max(ans,j);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
//9-D

/*
	print a b: str ??? a ??????????????? b ??????????????§??????????????????
	reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
	replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
 */

import java.util.Scanner;

class Main {
    public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
        
        String str = sc.next();
        
        int q = sc.nextInt();
        
        for( int i = 0 ; i < q ; i++ ){
        	
        	String meirei = sc.next();
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	
        	//meirei???????¨???? print reverse replace
        	if( meirei.equals("print")){
        		
        		System.out.println(str.substring( a , b+1 ));
        		
        	}else if(meirei.equals("reverse")){
        		
        		StringBuilder strbil1 = new StringBuilder(str);//str?????????????????°????????????????????????
        		StringBuilder strbil2 = new StringBuilder(strbil1.substring( a , b+1 ));//a-b?????????????????£??\
        		strbil2 = strbil2.reverse();//?????¢
        		strbil1.replace( a , b+1 , strbil2.toString() );//strbil1???a-b???3??????????????°?????\????????????
        		str = strbil1.toString();//StringBuilder???String???????????????
        		
        	}else if(meirei.equals("replace")){
        		
        		String p = sc.next();
        		
        		StringBuilder strbil1 = new StringBuilder(str);//str?????????????????°????????????????????????
        		strbil1.replace( a , b+1 , p );
        		str = strbil1.toString();
        		
        	}
        }
    }
}

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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std; 

int main(){
	int a,b,c;
	cin>>a>>b>>c;

	if(a+b+c>=22)
		cout<<"bust"<<endl;
	else
		cout<<"win"<<endl;	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

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

		while(true){
			int max = 0;
			int n = stdIn.nextInt();

			if(max<n){
				primeSet(n);
				max=n;
			}
			
			if(n==0){
				break;
			}

			for(int i=n;;i--){
				if(primes[i]&&primes[i-2]){
					System.out.println((i-2)+" "+i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,K;
  cin>>A>>B>>K;
     vector<int> C(101);
  
for (int i = 1; i < 101; i++) {
 if(A%i==0 && B%i==0){
   C[i]=i;
 }
}
sort(C.begin(), C.end());
reverse(C.begin(), C.end());
  cout<<C[K-1]<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<string.h>
#include<set>
#include<map>
#define LL long long
#define pr pair<int,int>
#define fr first
#define sc second
//#define mp make_pair
using namespace std;
LL read( ){LL sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) return -sum;return sum;}
void read(int &sum){sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) sum=-sum;}
void read(LL &sum){sum=0;char c=getchar( );bool f=0;while(c<'0' || c>'9') {if(c=='-') f=1;c=getchar( );}while(c>='0' && c<='9') {sum=sum*10+c-'0';c=getchar( );}if(f) sum=-sum;}
const int N=5000005;
const int M=20;
int m,pri[N];bool S[N+1];
int n;LL P[20],ans;
inline void exgcd(LL a,LL b,LL &x,LL &y)
{
  if(!b) {x=1;y=0;return;}
  exgcd(b,a%b,x,y);
  LL t=x;x=y;y=t-a/b*y;
}
void DFS(int p,LL a,LL b)
{
  if(p==n+1)
    {
      LL x,y;
      exgcd(a,b,x,y);y=-y;        
      y%=a;if(y<=0) y+=a;
      ans=min(ans,y*b);
      return;
    }
  DFS(p+1,a*P[p],b);
  DFS(p+1,a,b*P[p]);
}
int main( )
{
  int i,j;
  for(i=2;i<=N;i++)
     {
      if(S[i]) continue;
      pri[++m]=i;
      for(j=i+i;j<=N;j+=i) S[j]=1;
    }
  LL X=read( )*2;
  n=0;ans=X-1;
  for(i=1;i<=m&&pri[i]<=X;i++)
    {
      if(X%pri[i]!=0) continue;
      P[++n]=1;
      while(X%pri[i]==0) X/=pri[i],P[n]*=pri[i];
    }
  if(X>1) P[++n]=X;
  DFS(1,1,1);
  printf("%lld\n",ans);
  return 0;
}



Measured memory_bytes: 10012
package main

import (
  "fmt"
)

func foo(n, a, b int) int {
  ls := b - a
  if ls%2 == 0 {
    return ls/2
  } else {
    return Min(Min(a+foo(n, 1, b-a), b-1), Min(n-a, n-b+1+foo(n,a+n-b+1,n)))
  }
}

func Min(a, b int) int {
  if a < b {
    return a
  } else {
    return b
  }
}

func main() {
  var n, a, b int
  fmt.Scan(&n)
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Println(foo(n, a, b))
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define N 400005
#define M 900005
using namespace std;
int d1[N],d2[N],f1[N],f2[N],n,m,ans[N],fs[M],nt[M],dt[M],lt[M],sd[M],fx[M];
void link(int x,int y)
{
	lt[fs[x]]=++m;
	nt[m]=fs[x];
	dt[fs[x]=m]=y;
}
void lk(int x,int y)
{
	link(x,y),link(y,x),fx[m]=m-1,fx[m-1]=m;
}
void dfs(int k)
{
	for(int i=fs[k];i;i=fs[k])
	{
		int p=dt[i];
		fs[k]=nt[i],lt[fs[k]]=0;
		lt[nt[fx[i]]]=lt[fx[i]];
		nt[lt[fx[i]]]=nt[fx[i]];
		if(fs[p]==fx[i]) fs[p]=nt[fx[i]];
		dfs(p);
	}
	sd[++sd[0]]=k;
}
int main()
{
	cin>>n;
	int r=0;
	fo(i,1,n)
	{
		scanf("%d",&f1[i]);
		if(f1[i]!=-1) d1[f1[i]]++,lk(i,f1[i]);
		else r=i;
	}
	lk(0,r);
	fo(i,1,n)
	{
		scanf("%d",&f2[i]);
		if(f2[i]!=-1) d2[f2[i]]++,lk(i+n,f2[i]+n);
		else lk(0,i+n);
	}
	fo(i,1,n)
	{
		if(d1[i]%2!=d2[i]%2) {printf("IMPOSSIBLE\n");return 0;}
		else if(d1[i]%2==0) lk(i,i+n);
	}

	printf("POSSIBLE\n");
	dfs(1);
	fod(i,sd[0],2) 
	{
		if(sd[i]==0||sd[i-1]==0) continue;
		if(sd[i]==sd[i-1]-n) ans[sd[i]]=-1;
		if(sd[i]==sd[i-1]+n) ans[sd[i-1]]=1;
	}
	fo(i,1,n) 
	{
		printf("%d ",ans[i]);
	} 
}

Measured memory_bytes: 36480
def ans(l,k):
    if l==0:
        if k==1:
            return 1
    else:
        if k==1:
            return 0
        elif k<=2**(l+1)-2:
            return ans(l-1,k-1)
        elif k==2**(l+1)-1:
            return ans(l-1,2**(l+1)-3)+1
        elif k<2**(l+2)-3:
            return ans(l-1,2**(l+1)-3)+1 + ans(l-1,k-(2**(l+1)-3)-2)
        else:
            return 2*ans(l-1,2**(l+1)-3)+1
N,X=map(int,input().split())
print(ans(N,X))


Measured memory_bytes: 40368
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
x = list(map(int, input().split()))

dist = [0] * N
for i in range(N):
    dist[i] = abs(x[i] - X)

# distの最大公約数が欲しい
g = gcd(*dist)
print(g)


Measured memory_bytes: 20548
k=0
ans=0
while k==0:
 ans=0
 x,y=map(int,input().split())
 if x==0 and y==0:
  break
 else:
  for a in range(x):
   for b in range(x):
    for c in range(x):
     if a+b+c==y-3 and a!=b and b!=c and c!=a:
      ans+=1
  print(ans//6)
  


Measured memory_bytes: 5596
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
constexpr int dy[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll s, t, d;
  cin >> s >> t >> d;
  vl v(d);
  REP(i, d) cin >> v[i];
  vl a(d + 1);
  REP(i, d) {
    a[i + 1] = a[i] + v[i];
    if (a[i + 1] <= t - s) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  if (a[d] >= 0) {
    cout << -1 << endl;
    return 0;
  }
  ll r = -a[d];
  ll ans = INF * INF;
  REP(i, d) {
    ll k = ((s - t) + a[i] + r - 1) / r;
    chmin(ans, k * d + i);
  }

  cout << ans << endl;
}



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


int main(){
    string S;
    cin >> S;
    int N = S.length();
    vector<int> a;
    int ten = 1;
    for (int i=0; i<N; i++){
        int c = S[N-i-1] - '0';
        a.push_back(c * ten % 2019);
        ten = ten * 10 % 2019;
    }
    vector<int> s;
    int sum = 0;
    s.push_back(0);
    for (auto a_i : a){
        sum = (sum + a_i) % 2019;
        s.push_back(sum);
    }
    vector<int> mods(2019, 0);
    for (int i=0; i<N+1; i++){
        mods[s[i]]++;
    }
    // mods[i] = n の時 n_C_2 = n(n-1)/2
    int ans = 0;
    for (int i=0; i<2019; i++){
        ans += mods[i] * (mods[i]-1) / 2;
    }
    cout << ans << endl;
    return 0;
}



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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;

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

  int a,b;
  cin >> a >> b;

  int ab;
  if (b < 10) {
    ab = a * 10 + b;
  } else if (b < 100) {
    ab = a * 100 + b;
  } else {
    ab = a * 1000 + b;
  }

  EACH(i,1,sqrt(100100)) {
    if (i * i == ab) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}



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

int n, k, m = 0;

int main()
{
	cin >> n >> k;

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

		cin >> h;

		if (h >= k)
			m++;
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256
int main(void)
{
    int sec;
    int hh, mm, ss;
    int mod;

    scanf("%d", &sec);
    hh = sec / (60 * 60);
    mod = sec % (60 * 60);
    mm = mod / 60;
    ss = mod % 60;

    printf("%d:%d:%d\r\n", hh, mm, ss);

    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

typedef pair<double, int> PD;

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

bool ch[65][15];
int num[65][15];
int w,h;
double wei[160];
int x[160][2]; // 0:Xl,1:Xr
vector<int> v[160];



void find(int x,int y,int count){
    int sum = 1;
    queue<P> que;
    que.push(P(x,y));
    while(!que.empty()){
        if(sum == 4)break;
        P q = que.front(); que.pop();
        for(int k = 0;k < 4;k++){
            int nx = q.fs + dx[k],ny = q.sc + dy[k];
            if(nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
            if(ch[nx][ny] == false && num[x][y] == num[nx][ny]){
                sum++;
                ch[nx][ny] = true;
                num[nx][ny] = count;
                que.push(P(nx,ny));
            }
        }
    }
}

PD get_weight(int k){
    double wsum = wei[k];
    int sec = 4;
    for(int i = 0;i < v[k].size();i++){
        PD p = get_weight(v[k][i]);
        wsum += p.fs;
        sec += p.sc;
    }
    return (PD(wsum,sec));
}

int main(){
    while(true){
        cin >> w >> h;
        if(w == 0)break;
        for(int i = 0;i < h;i++){
            char tmp[20];
            cin >> tmp;
            for(int j = 0;j < w;j++){
                ch[i][j] = false;
                if(tmp[j] == '.'){
                    num[i][j] = 0;
                    ch[i][j] = true;
                }else{
                    num[i][j] = tmp[j] - '0';
                }
            }
        }
        for(int j = 0;j < w;j++) num[h][j] = 0;
        int count = 0;
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(ch[i][j] == false){
                    ch[i][j] = true;
                    count++;
                    find(i,j,count);
                    num[i][j] = count;
                }
            }
        }

        for(int k = 1;k <= count;k++){
            wei[k] = 0.0;
            int und=0;
            int a=100,b=-1;
            for(int i = 0;i < h;i++){
                for(int j = 0;j < w;j++){
                    if(num[i][j] != k) continue;
                    wei[k] += (double) j + 0.5;
                    if((num[i+1][j] >= 1 && num[i+1][j] != k) || i == h-1){
                        und = num[i+1][j];
                        a = min(a,j);
                        b = max(b,j+1); 
                    }
                }
            }
            v[und].push_back(k);
            x[k][0] = a;
            x[k][1] = b;
        }
        bool ans = true;
        for(int i = 1;i <= count;i++){
            PD p = get_weight(i);
            if(x[i][0] >= p.fs/(double)p.sc || x[i][1] <= p.fs/(double)p.sc){
                ans = false;
                break;
            }
        }
        if(ans){
            cout << "STABLE" << endl;
        }else{
            cout << "UNSTABLE" << endl;
        }
        for(int i = 0;i <= count;i++)  v[i].clear();
    }
}


Measured memory_bytes: 3148
s = input()
lower = "qwertyuiopasdfghjklzxcvbnm"
no = False
if s[0] != "A":
  no = True
if s[2:len(s)-1].count("C") != 1:
  no = True
if no:
  print("WA")
  exit()
ls = list(s)
ls.pop(ls.index("A"))
ls.pop(ls.index("C"))
sls = ""
for lsi in ls:
  sls += lsi
if sls != sls.lower():
  print("WA")
  exit()
print("AC")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
// #include <bits/stdc++.h>


using namespace std;
typedef long long li;

const int max_x = 303;

int calc(
        const vector<vector<int>>& elem_xy,
        const vector<vector<int>>& acc_xy,
        bool include_boundary
        ) {
    const int delta = include_boundary ? 0 : 1;

    int ans = 0;
    for (int l = 0; l < 2 * max_x; ++l) {
        for (int i = 0; i < elem_xy[l].size(); ++i) {
            const int low_y = elem_xy[l][i];
            for (int j = i + 1; j < elem_xy[l].size(); ++j) {
                const int high_y = elem_xy[l][j];
                const int d = high_y - low_y;
                vector<int> test_ls = {l - d, l + d};
                for (const auto &test_l : test_ls) {
                    if (test_l < 0 || test_l >= acc_xy.size()) {
                        continue;
                    }
                    const int search_low_y = low_y - 1 + delta;
                    const int search_high_y = high_y - delta;
                    ans += acc_xy[test_l][search_high_y] - acc_xy[test_l][search_low_y];
                }
            }
        }
    }
    return ans;

}

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

    int h, w;
    cin >> h >> w;
    vector<string> p(h);
    for (int i = 0; i < h; ++i) {
        cin >> p[i];
//        p[i] = string(w, '.');
    }

    vector<int> xs, ys;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (p[i][j] == '.') {
                continue;
            }
            int x = i + j;
            int y = i - j;
            xs.push_back(x);
            ys.push_back(y);
        }
    }

    const int n = xs.size();
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    const int x_offset = *min_element(xs.begin(), xs.end());
    const int y_offset = *min_element(ys.begin(), ys.end());
    for (int i = 0; i < n; ++i) {
        xs[i] -= x_offset - 1;
        ys[i] -= y_offset - 1;
    }

    vector<vector<int>> acc_xy(2 * max_x, vector<int>(2 * max_x));
    vector<vector<int>> acc_yx(2 * max_x, vector<int>(2 * max_x));
    vector<vector<int>> elem_xy(2 * max_x);
    vector<vector<int>> elem_yx(2 * max_x);
    for (int i = 0; i < n; ++i) {
        acc_xy[xs[i]][ys[i]]++;
        acc_yx[ys[i]][xs[i]]++;
        elem_xy[xs[i]].push_back(ys[i]);
        elem_yx[ys[i]].push_back(xs[i]);
    }

    for (int i = 0; i < 2 * max_x; ++i) {
        for (int j = 1; j < 2 * max_x; ++j) {
            acc_xy[i][j] += acc_xy[i][j - 1];
            acc_yx[i][j] += acc_yx[i][j - 1];
        }
        sort(elem_xy[i].begin(), elem_xy[i].end());
        sort(elem_yx[i].begin(), elem_yx[i].end());
    }

    cout << calc(elem_xy, acc_xy, false) + calc(elem_yx, acc_yx, true) << endl;
    return 0;
}


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

int main(void)
{
	double x, h, s, y;
	
	while (1){
		
		scanf("%lf %lf", &x, &h);
		
		if(x == 0 && h == 0){
			break;
		}
		y = sqrt(h * h + x / 2 * x / 2);
		s = x * x + x * y * 2;
		printf("%f\n", s);
	}
	
	return (0);
}

Measured memory_bytes: 644
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val N = scanner.nextInt()
    val K = scanner.nextInt()

    val heights = mutableListOf<Int>()
    for (i in (1..N)) {
        heights.add(scanner.nextInt())
    }

    println(heights.count { it >= K })
}

Measured memory_bytes: 52528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
void dfs(ll v,vector<bool> &seen,vl &ans,vvl &g){
    seen[v]=true;
    for(auto nv:g[v]){
        if(seen[nv])continue;
        ans.pb(nv);
        dfs(nv,seen,ans,g);
        break;
    }
}
int main(){
    ll n,m;cin >> n >>m;
    vvl g(n);
    rep(i,m){
        ll a,b;cin >> a >>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    vector<bool> seen(n,false);
    vl ans,pre;
    dfs(0,seen,ans,g);
    dfs(0,seen,pre,g);
    rev(all(pre));
    cout << ans.size()+pre.size()+1 <<endl;
    for(auto p:pre)cout << p+1 <<" ";
    cout << 1 <<" ";
    for(auto p:ans)cout << p+1 <<" ";
    cout << endl;
}

Measured memory_bytes: 12916