akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

string s;
int n;
ll mod_pow(ll a,ll b,ll p){ //(a^b)%p
	ll res=1;
	a%=p;

	while(b>0){
		if(b&1==1) res=((res%p)*(a%p))%p;
		a=(a%p*a%p)%p;
		b>>=1;
	}
	return res;
}

//mod_inv=mod_pow(denominator,MOD-2,MOD);

int dp[maxn][13][10];

int solve(int ind, int rem, int val){
	if(ind == n){
		if(rem == 5) return 1;
		else return 0;
	}
	int &res=  dp[ind][rem][val];
	if(res != -1) return res;
	res = 0;
	
	if(s[ind] != '?'){
		int k = mod_pow(10,ind,13);
		k = k * (s[ind] - '0');
		res += solve(ind + 1, (k%13 + rem % 13) % 13,(s[ind]-'0'));
		res %= mod;
	}else{
		int k = mod_pow(10,ind,13);
		for(int i = 0; i <= 9 ; i++){
			res += solve(ind + 1, ((k * i) % 13 + rem % 13) % 13,val);
			res %= mod;
		}
		res %= mod;
		
	}
	
	return res;
}

int32_t main(){
	fastio();
	cin >> s;
	 n = s.length();

	reverse(all(s));
	memset(dp, -1, sizeof(dp));
	int ans = solve(0,0,0);
	cout << ans;
}

Measured memory_bytes: 114716
from itertools import permutations
n = int(input())
a = list(map(int,input().split()))
a = tuple(map(lambda x: x-1, a))
b = list(map(int,input().split()))
b = tuple(map(lambda x: x-1, b))
ai = 0
bi = 0
ind = 0
for i in permutations(range(n),n):

    if i == a: ai = ind
    if i == b: bi = ind
    ind += 1
print(abs(ai-bi))

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

int main(){
	int a, b;
	
	cin >> a >> b;
	
	if ( a < b ) cout << "a < b" << endl;
	else if ( a > b ) cout << "a > b" << endl;
	else cout << "a == b" << endl;
	
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char a,b;
    cin >> a >>b;
    if(a == 'H')    cout << b << '\n';
    else{
        if(b == 'D')    cout << "H\n";
        else{
            cout << "D\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float("inf")]*n
dp[0]=0
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]))

print(dp[n-1])


Measured memory_bytes: 55008
def main():
    N, K = map(int, input().split())
    d = {i:0 for i in range(1, N+1)}
    for i in range(K):
        D = int(input())
        a = list(map(int, input().split()))
        for j in a:
            d[j] += 1
    r = 0
    for i in d:
        if d[i] == 0:
            r += 1
    return r
print(main())


Measured memory_bytes: 67760
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

map<pss, int> lhs;
map<pss, int> rhs;

int n;
char buf[40];

void loadLHS() {
  for(int mask = 0; mask < (1<<n); mask++) {
    string a = "";
    string b = "";
    for(int i = 0; i < n; i++) {
      if((mask&(1<<i))) {
        a += buf[i];
      }
      else {
        b += buf[i];
      }
    }
    lhs[pss(a, b)]++;
  }
}

void loadRHS() {
  for(int mask = 0; mask < (1<<n); mask++) {
    string a = "";
    string b = "";
    for(int i = 0; i < n; i++) {
      if((mask&(1<<i))) {
        a += buf[2*n-1-i];
      }
      else {
        b += buf[2*n-1-i];
      }
    }
    rhs[pss(a, b)]++;
  }
}

int main() {
  scanf("%d\n%s", &n, buf);
  loadLHS();
  loadRHS();
  ll ret = 0;
  for(auto x: lhs) {
    ret += x.second * (ll)rhs[x.first];
  }
  printf("%lld\n", ret);
}


Measured memory_bytes: 108288
//40
#include<iostream>
#include<queue>
#include<set>
#include<algorithm>

using namespace std;

struct S{
  int t;
  int c[3];
  bool operator<(S a)const{
    return lexicographical_compare(c,c+3,a.c,a.c+3);
  }
};

int cv(int *a){
  int r[3]={};
  for(int j=0;j<15;j++){
    for(int i=0;i<3;i++){
      r[i]=(r[i]*3)+(a[i]>>j&1);
    }
  }
  return r[0]*2+r[1];
}

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    S is={0,{0,0,0}};
    for(int i=0;i<3;i++){
      int k;
      cin>>k;
      while(k--){
	int c;
	cin>>c;
	is.c[i]|=1<<(n-c);
      }
    }
    queue<S> que;
    que.push(is);
    static bool p[14348907]={};
    fill_n(p,14348907,false);
    while(!que.empty()&&que.front().t<=m){
      S c=que.front();
      if(c.c[0]==(1<<n)-1||c.c[2]==(1<<n)-1)break;
      que.pop();
      if(p[cv(c.c)]++)continue;
      for(int i=0;i<3;i++){
	for(int d=-1;d<=1;d+=2){
	  int nd=i+d;
	  int l=c.c[i]&~(c.c[i]-1);
	  if(0<=nd&&nd<3&&c.c[i]&&(c.c[nd]==0||l<(c.c[nd]&~(c.c[nd]-1)))){
	    S n=c;
	    n.c[nd]|=l;
	    n.c[i]&=~l;
	    n.t++;
	    que.push(n);
	  }
	}
      }
    }
    if(!que.empty()&&que.front().t<=m){
      cout<<que.front().t<<endl;
    }else{
      cout<<-1<<endl;
    }
  }
  return 0;
}
   
	

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int i=0; i<n; i++)
#define FOR1(i, n) for(int i=1; i<=n; i++)
#define FORI(i, n) for(int i=n-1; i>=0; i--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i, n) cin >> a[i];
    ll sol = 0;
    int mx = a[0];
    FOR1(i, n-1){
        sol += max(0, mx-a[i]);
        umax(mx, a[i]);
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 3988
N,X,Y=map(int,input().split())
count=[0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        distance=min(j-i,abs(j-X)+abs(i-Y)+1,abs(j-Y)+abs(i-X)+1)
        count[distance]+=1
print(*count[1:],sep="\n")

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  double sum = 0;
  for (int i = 0; i < N; i++){
    cin >> a[i];
    sum += a[i];
    a[i] *= N;
  }
  int m = 1000000;
  int c = 0;
  for (int i = 0; i < N; i++){
    if (abs(sum - a[i]) < m){
      m = abs(sum - a[i]);
      c = i;
    }
  }
  cout << c;
}

Measured memory_bytes: 256
N = int(input())
cnt = [[0]*10 for _ in range(10)]

for i in range(1, N+1):
    f = int(str(i)[0])
    l = int(str(i)[-1])
    cnt[f][l] += 1

ans = 0

for i in range(1, 10):
    for j in range(1, 10):
        ans += cnt[i][j]*cnt[j][i]

print(ans)

Measured memory_bytes: 40428
//============================================================================
// Name        : template.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int A() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

int B() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, d;
	cin >> n >> d;
	int an = 0;
	while (n--) {
		double x, y; cin >> x >> y;
		double dis = (x * x) + (y * y);
		if (dis <= d * d) {
			an++;
		}
	}
	cout << an << "\n";
	return 0;
}

int C() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	ll x = 0;
	ll ct = 0;
	ll lmt = 10e7;
	while(ct < lmt) {
       
	}
	return 0;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s ; cin >> s;
	string org = s;
	int reds = 0;
	forn(i,n) {
     if(s[i] == 'R') reds++;
	}
     int ans = 0;
	forn(i , reds) {
		if(org[i] == 'W') ans++;
	}
	cout << ans << "\n";
	return 0;
}


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

void trace(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

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

int main() {
    int n, i, j;
    int a[100];

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    trace(a, n);
    insertionSort(a, n);
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 mp make_pair
#define fi first
#define sc second
ll n;
ll a[200];
ll cou[9];
int main(){
	cin >> n;
	REP(i,n)
		cin >> a[i];

	REP(i,n) {
		bool f = true;
		REP(j,8) {
			if(a[i] < (j + 1) * 400) {
				f = false;
				cou[j]++;
				break;
			}
		}
		if(f) {
			cou[8]++;
		}
	}
	ll ans1 = 0;
	REP(i,8) {
		if(cou[i] > 0)
			ans1++;
	}
	if(cou[8] == 0) {
		cout << ans1 << " " << ans1 << endl;
		return 0;
	}

	cout << ans1 + (ans1 == 0) << " " << ans1 + cou[8] << endl;
	return 0;
}


Measured memory_bytes: 256
import heapq
N, M = input().split(" ")
N = int(N)
M = int(M)
num_list = list(map(int, input().split(" ")))
num_list = list(map(lambda x: x * -1, num_list))
heapq.heapify(num_list)
for i in range(M):
    temp = heapq.heappop(num_list) * -1
    temp = temp // 2
    temp *= -1
    heapq.heappush(num_list, temp)
temp2 = sum(num_list)
print(temp2*-1)


Measured memory_bytes: 14180
#include <cstdio>
#include <algorithm>
#include <numeric>

int solve(int n) {
    int len = (n + 1) / 2;
    int a[len];
    for (int i = 0; i < len; i++) {
        a[i] = i * 2 + 1;
    }
    std::transform(a, a+len, a, [](int n) {
            int count = 0;
            for (int i = 1; i <= n; i += 2) {
                count += (n % i == 0) ? 1 : 0;
            }
            return count == 8;
        });
    return std::accumulate(a, a+len, 0);
}

int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", solve(n));
    return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X;
    cin >> X;
    if(X>=30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3648
#include<stdio.h>

int main()
{
  int a[5], sum = 0, i, ans;
  for(i = 0; i < 5; i++) {
    scanf("%d", &a[i]);
    if(a[i] < 40)
      a[i] = 40;
    sum += a[i];
  }
  ans = sum / 5.0;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 600
# B - 1 Dimensional World's Tale

N, M, X, Y = map(int, input().split())
x = list(int(x) for x in input().split())
y = list(int(y) for y in input().split())

x_max = max(x)
x_max = max(x_max, X)
y_min = min(y)
y_min = min(y_min, Y)

if x_max < y_min:
    print('No War')
else:
    print('War')


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

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn num_to_bits(mut num: u64, n: usize) -> Vec<i32> {
    let mut res = vec![0; n];
    for i in 0..n {
        res[i] = (num % 2) as i32;
        num /= 2;
    }
    res
}

fn bits_to_num(bits: &Vec<i32>) -> u64 {
    let mut res = 0;
    for i in 0..bits.len() {
        res += bits[i] as u64 * (1 << i);
    }
    res
}

fn invert_bit(i: usize, bits: &mut Vec<i32>) {
    if bits[i] == 1 {
        bits[i] = 0;
    } else {
        bits[i] = 1;
    }
}

fn route(start_bits: &Vec<i32>, end_bits: &Vec<i32>, bit_mask: &Vec<usize>) -> Vec<usize> {
    if bit_mask.len() == 2 {
        if start_bits[bit_mask[0]] != end_bits[bit_mask[0]] {
            assert!(start_bits[bit_mask[1]] == end_bits[bit_mask[1]]);
            return vec![bit_mask[1], bit_mask[0], bit_mask[1]];
        } else {
            assert!(start_bits[bit_mask[1]] != end_bits[bit_mask[1]]);
            return vec![bit_mask[0], bit_mask[1], bit_mask[0]];
        }
    }
    let mut new_bit_mask = Vec::new();
    let mut first_different_bit = 0usize;
    for &bit in bit_mask.iter() {
        if start_bits[bit] != end_bits[bit] {
            first_different_bit = bit;
            break;
        }
    }
    for &bit in bit_mask.iter() {
        if bit != first_different_bit {
            new_bit_mask.push(bit);
        }
    }

    let mut intermediate_bits = start_bits.clone();
    invert_bit(new_bit_mask[0], &mut intermediate_bits);
    let mut ret1 = route(&start_bits, &intermediate_bits, &new_bit_mask);

    invert_bit(first_different_bit, &mut intermediate_bits);
    ret1.push(first_different_bit);
    let ret2 = route(&intermediate_bits, &end_bits, &new_bit_mask);

    [ret1, ret2].concat()
}

fn main() {
    let v: Vec<u64> = read_vec();
    let (n, a, b) = (v[0], v[1], v[2]);
    let n = n as usize;

    let a_bits = num_to_bits(a, n);
    let b_bits = num_to_bits(b, n);

    if (a_bits.iter().sum::<i32>() - b_bits.iter().sum::<i32>()) % 2 == 0 {
        println!("NO");
        return;
    }
    println!("YES");
    if n == 1 {
        if a == 0 {
            println!("0 1");
        } else {
            println!("1 0");
        }
        return;
    }
    let bit_mask = (0..n).collect::<Vec<usize>>();
    let route_bits = route(&a_bits, &b_bits, &bit_mask);

    let mut answers = Vec::with_capacity(1 << n);
    let mut start_bits = a_bits;
    answers.push(bits_to_num(&start_bits));
    for &bit in route_bits.iter() {
        invert_bit(bit, &mut start_bits);
        answers.push(bits_to_num(&start_bits));
    }
    println!(
        "{}",
        answers
            .iter()
            .map(|&x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}


Measured memory_bytes: 14156
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		if (tmp % 2 == 1)ans = 1;
	}
	if (ans) {
		cout << "first" << endl;
	}
	else {
		cout << "second" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x;
    cin >> x;
    
    int n = 1;
    // i^j
    for(int i = 2; i < x; i ++){
        int ij = i;
        while(true){
            ij *= i;
            if(ij > x) break;
            n = (n < ij) ? ij : n;
        }
    }
    
    
    cout << n << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll func(ll a) {
  if (a <= 1) return 0;
  return a * (a - 1) / 2;
}

void solve() {
  int n;
  cin >> n;
  vector<ll> v(n);
  map<ll, ll> mp;
  rep(i,n){
    cin >> v[i];
    mp[v[i]]++;
  }
  ll sum = 0;
  for(auto p: mp) {
    sum += func(p.second);
  }
  rep(i,n) {
    ll temp = sum;
    temp -= func(mp[v[i]]);
    temp += func(mp[v[i]] - 1);
    cout << temp << endl;
  }
}

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

Measured memory_bytes: 12692
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vllint a(x), b(y), c(z);
	rep(i, x)cin >> a[i];
	rep(i, y)cin >> b[i];
	rep(i, z)cin >> c[i];
	sort(c.begin(), c.end(), check);
	priority_queue<pair<llint, int>>pairs;
	rep(i, x) {
		rep(j, y) {
			pairs.push({ a[i] + b[j] + c[0],0 });
		}
	}
	pair<llint, int> top;
	rep(i, k) {
		top = pairs.top();
		cout << top.first << endl;
		pairs.pop();
		if (top.second != z - 1) {
			pairs.push({ top.first - c[top.second] + c[top.second + 1],top.second + 1 });
		}
	}
	return 0;
}

Measured memory_bytes: 18540
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy 
print("R"*dx + "U"*dy + "L"*dx + "D"*dy + "D" + "R"*(dx + 1) + "U"*(dy + 1) + "L" + "U" + "L"*(dx + 1) + "D"*(dy + 1) + "R")

Measured memory_bytes: 3064
initialQues :: [Int] -> Int
initialQues xs = case filter odd xs of
            [] -> 1 + query xs
            _  -> 0

query :: [Int] -> Int
query xs = case filter odd $ map (`div` 2) xs of
             [] -> query (map (`div` 2) xs)+1
             _  -> 0

main::IO()
main = do
    n <- getLine
    s <- map read . words <$> getLine ::IO [Int] 

    print $ initialQues s


Measured memory_bytes: 1020
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psl = pair<string, ll>;

template <ll MOD>
struct ModLL {
  ll val;
  ModLL() : val(0) {}
  ModLL(ll v) : val(v >= 0 ? v % MOD : (MOD - (-v) % MOD) % MOD) {}

  ModLL operator-() const { return ModLL(-val); }

  ModLL& operator+=(const ModLL& r) {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return (*this);
  }
  ModLL operator+(const ModLL& r) const { return ModLL(*this) += r; }

  ModLL& operator-=(const ModLL& r) {
    val += MOD - r.val;
    if (val >= MOD) val -= MOD;
    return (*this);
  }
  ModLL operator-(const ModLL& r) const { return ModLL(*this) -= r; }

  ModLL& operator*=(const ModLL& r) {
    val *= r.val;
    if (val >= MOD) val %= MOD;
    return (*this);
  }
  ModLL operator*(const ModLL& r) const { return ModLL(*this) *= r; }

  ModLL& operator/=(const ModLL& r) {
    (*this) *= r.inv();
    return (*this);
  }
  ModLL operator/(const ModLL& r) const { return ModLL(*this) /= r; }

  bool operator==(const ModLL& r) { return val == r.val; }
  bool operator!=(const ModLL& r) { return val != r.val; }

  ModLL pow(ll n) {
    if (n == 0) return 1;
    ModLL x = pow(n / 2);
    x *= x;
    if (n % 2 == 1) x *= 2;
    return x;
  }

  ModLL inv() const {
    ll a = val, b = MOD, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModLL(u);
  }

  friend istream& operator>>(istream& is, ModLL<MOD>& r) {
    ll t;
    is >> t;
    r = ModLL<MOD>(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModLL<MOD>& r) {
    return os << r.val;
  }

  ModLL comb(ll n, ll k) {
    ModLL x = 1, y = 1;
    REP(i, k) {
      x *= n - i;
      y *= i + 1;
    }
    return x / y;
  }
};


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

  const ll MOD = 1e9 + 7;
  ll N, A, B;
  cin >> N >> A >> B;

  if (N == 2) {
    cout << 0 << endl;
    return 0;
  }

  ModLL<MOD> two(2);
  ModLL<MOD> ans = two.pow(N);
  ans -= 1;
  ModLL<MOD> Num(N);

  ans -= Num.comb(N, A);
  ans -= Num.comb(N, B);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#define MAX_V 10
#define INF 1000000
#define NIL -1
using namespace std;

struct edge {int to,cost;};
typedef pair<int,int> P;	//first:最短距離 second:頂点番号


int d[MAX_V];

void dijkstra(int s,vector<edge> G[]){
	//greater<P>を指定することでfirstが小さい順に取り出せるようになる
	priority_queue<P,vector<P>,greater<P> > que;
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;//最短距離でなければ無視する
		for(int i = 0;i < G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	
}

int E;
bool cities[MAX_V];//その番号の町が出てくるか否か

int main(){
	cin >>E;
	while(E != 0){
		vector<edge> G[MAX_V];		//隣接リスト
		fill(cities,cities + MAX_V,false);
		int a,b,cost;
		for(int i = 0;i < E;i++){
			cin >>a >>b >>cost;
			cities[a] = true;cities[b] = true;
			edge e;e.to = b;e.cost = cost;
			G[a].push_back(e);
			e.to = a;
			G[b].push_back(e);
		}
		int mini = INF;int num = NIL;
		for(int i = 0;i < MAX_V;i++){
			fill(d,d+MAX_V,INF);
			for(int j = 0;j < MAX_V;j++){
				if(!cities[j])d[j] = 0;}
			dijkstra(i,G);
			int min_tmp= 0;
			for(int k = 0;k < MAX_V;k++)min_tmp += d[k];
			if(min_tmp < mini){mini = min_tmp;num = i;}
		}
		cout <<num <<" " <<mini <<endl;
		cin >>E;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
int main(void)
{
	int n,a,b,c,d;
	int count = 0;
	while(scanf("%d",&n) != EOF){
		count = 0;
		for(a = 0 ; a <= 9 ; a++){
			for(b = 0 ; b <= 9 ; b++){
				for(c = 0 ; c <= 9 ; c++){
					for(d = 0 ; d <= 9 ; d++){
						if((a+b+c+d) == n){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

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

    int x = c - a;
    int y = d - b;

    cout << c - y << " " <<  d + x << " " <<  a - y << " " <<  b + x << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;



int main(){

  ll n;cin>>n;
  ll ma,mb;cin>>ma>>mb;
  ll a[n],b[n],c[n];rep(i,0,n)cin>>a[i]>>b[i]>>c[i];
  ll dp[410][410];
  rep(i,0,410)rep(j,0,410)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,0,n){
    repr(j,400,a[i]){
      repr(k,400,b[i]){
        chmin(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
      }
    }
  }
  ll ans=INF;
  rep(i,1,n+1)chmin(ans,dp[ma*i][mb*i]);

  if(ans==INF)out(-1);
  else out(ans);


  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <string>
#include <cstring>
#include <vector>
#include <iomanip>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <array>
#include <set>
#include <regex>
 
using namespace std;
using ll = long long;
 
#define endl "\n"
#define pb push_back
#define in insert

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

    ll a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22) {
        cout << "bust";
    } else {
        cout << "win";
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())
count = max_count = 0

for _ in range(N):
    d1, d2 = map(int, input().split())

    if d1 == d2:
        count += 1

        if count > max_count:
            max_count = count

    else:
        count = 0

if max_count >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#include <stdio.h>
#define max 10000

int main(void)
{
	int n;
	scanf("%d",&n);
	int i , k;
	int c[max];
	unsigned short *a , *b;
	a = malloc(sizeof(short)*n+1);
	b = malloc(sizeof(short)*n+1);

	scanf("%d",&a[0]);
	k = a[0];
	b[0] = 0;
	
	for( i = 1; i < n; i++)
	{
		scanf("%d",&a[i]);
		if(k < a[i])
		{
			k = a[i];
		}
		b[i] = 0;
	}
	
	for( i = 0; i <= k; i++)
	{
		c[i] = 0;
	}
	
	for( i = 0; i < n; i++)
	{
		c[a[i]]++;
	}
	
	for( i = 1; i <= k; i++)
	{
		c[i] = c[i] + c[i-1];
	}
	for( i = n; i >= 0; i--)
	{
		b[c[a[i]]] = a[i];
		c[a[i]]--;
	}
	for( i = 1; i <= n; i++)
	{
		if(i != n) printf("%d ",b[i]);
		else printf("%d\n",b[i]);
	}
	
	return 0;
}


Measured memory_bytes: 9564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            for(int i=1; i<=50000; i++)
            {
                if(i * 1.08 >= N && i * 1.08 < N + 1)
                {
                    Console.WriteLine(i);
                    break;
                }
                else if(i * 1.08 > N){ 
                    Console.WriteLine(":(");
                    break;
                }
            }

        }
    }
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int x;
    cin >> x;
    print(x >= 30 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long []a = new long [5];
		
		for(int i = 0; i < 5; i++) {
			a[i] = sc.nextLong();
			
		}
		Arrays.sort(a);
		
		long ans = (long)(Math.ceil((double)n/a[0]) + 4);
		
		System.out.println(ans);
		
		
	}
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean flag = false;

		for(int i=a;i<b+1;i++) {
			if(i%k==0) {
				flag=true;
				break;
			}
		}

		if(flag) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}

	}

	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


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

int main(){
  ll a,b; cin >> a >> b;
  ll ret=-1;
  rep(i,2000){
    if((ll)(i/12.5)==a&&(ll)(i/10)==b){
      ret=i;
      break;
    }
  }

  cout << ret;

}

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

int main(){
    int h, w;
    cin >> h >> w;
    char field[150][150];
    bool fh[150], fw[150];
    for(int i = 0; i < h; i++) cin >> field[i];

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(field[i][j] == '#'){
            fh[i] = true;
            fw[j] = true;
            }
        }
    }
    for(int i = 0; i < h; i++){
        if(fh[i]){
            for(int j = 0; j < w; j++){
                if(fw[j]){
                    cout << field[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

n,m,d = map(Decimal,input().split())
if d == 0:
    p = 1/n
else:
    p = (n-d)*2/n**2
print(p*(m-1))

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  array<int, 3> vars;
  cin >> n >> vars[0] >> vars[1] >> vars[2];

  vector<pair<int, int>> vp(n);
  for (auto &p : vp) {
    string s;
    cin >> s;
    p.first = s[0] - 'A';
    p.second = s[1] - 'A';
  }

  vector<char> ans;
  auto inc_fst = [&](pair<int, int> &p) {
    vars[p.first]++;
    vars[p.second]--;
    ans.push_back('A' + p.first);
  };

  auto inc_snd = [&](pair<int, int> &p) {
    vars[p.first]--;
    vars[p.second]++;
    ans.push_back('A' + p.second);
  };

  bool ok = true;
  for (int i = 0; i < n; ++i) {
    auto &p = vp[i];

    // 両方0
    if (!vars[p.first] && !vars[p.second]) {
      ok = false;
      break;
    }

    // 片方のみ0
    if (!vars[p.first] || !vars[p.second]) {
      if (vars[p.first]) {
        inc_snd(p);
      } else {
        inc_fst(p);
      }
      continue;
    }

    // 両方1
    if (vars[p.first] == 1 && vars[p.second] == 1) {
      if (i == n - 1 || p == vp[i + 1]) {
        inc_fst(p);
      } else {
        auto &p_next = vp[i + 1];
        if (p_next.first == p.first || p_next.second == p.first) {
          inc_fst(p);
        } else {
          inc_snd(p);
        }
      }

      continue;
    }

    if (vars[p.first] < vars[p.second]) {
      inc_fst(p);
    } else {
      inc_snd(p);
    }
  }

  if (!ok) {
    cout << "No" << '\n';
    return 0;
  }

  cout << "Yes" << '\n';
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

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

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    cin>>n>>k>>t;
    ll a[n]={0};
    rep(i,0,t){
        cin>>j;
        a[j-1]++;
    }     
    rep(i,0,n){
        // trace()
        if(k-(t-a[i])>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1408
N, K = [int(i) for i in input().split()]
R, S, P = [int(i) for i in input().split()]
d = {'r': P, 's': R, 'p': S}
T = input()
checked = [False for i in range(N)]
# 勝てるだけ勝てばいい
for i in range(N-K):
    if T[i] == T[i+K]:
        if checked[i] == False:
            checked[i+K] = True
result = 0
for i in range(N):
    if checked[i] == False:
        result += d[T[i]]
print(result)

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	int four = 0;
	int two = 0;
	int zero = 0;
	for( int i = 0; i < N; ++i ) {
		int a;
		cin >> a;

		if( a%4 == 0 ) {
			four += 1;
		}
		else if( a%2 == 0 ) {
			two += 1;
		}
		else {
			zero += 1;
		}
	}

	if( two >= 1 ) {
		zero += 1;
	}

	cout << (four+1 >= zero ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	int b[1100];
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",&b[i]);
	sort(b,b+a);
	double sum=b[0]+0.0;
	for(int i=1;i<a;i++)
	{
		sum=(sum+b[i])/2;
	}
	printf("%lf\n",sum);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

sign = -1
temp = []
temp2 = []
for i in range(N-1):
    if sign == -1:
        if A[i] >= A[i+1]:
            continue
        else:
            temp.append(A[i])
            sign = 1
    else:
        if A[i] <= A[i+1]:
            continue
        else:
            temp2.append(A[i])
            sign = -1

if sign == 1:
    if A[i] <= A[i+1]:
        temp2.append(A[i+1])
    else:
        temp2.append(A[i])


S = 1000
for a, b in zip(temp, temp2):
    cnt = S//a
    S += cnt*(b-a)

print(S)



Measured memory_bytes: 62008
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>
#include <time.h>
#include <stdio.h>

using namespace std;
typedef long long ll;
typedef pair<double, double> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) a.begin(), a.end()

template<typename T>
void vdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		if (i == size - 1) {
			cout << da[i] << endl;
		}
		else {
			cout << da[i] << ' ';
		}
	}
}
template<typename T>
void vvdeb(vector<T> &da) {
	int size = da.size();
	for (int i = 0;i < size;i++) {
		vdeb(da[i]);
	}
}

double ans = 15000;
const double max_ret = 15000;
P now;

double dist(P x, P y){
	double rr = (x.first-y.first)*(x.first-y.first) + (x.second-y.second)*(x.second-y.second);
	//cout << rr << endl;
	return sqrt(rr);
}

double q(double x){
	return x*x;
}

P cent(P x, P y, P z){
	double a = x.first, b = x.second, c = y.first, d = y.second,e = z.first, f = z.second;
	P ret;
	ret.second = ((e-a)*(q(a) + q(b) - q(c) - q(d)) - (c-a)*(q(a) + q(b) - q(e) - q(f))) /((e-a)*(b-d)-(c-a)*(b-f));
	ret.second /= 2;
	b = x.first, a = x.second, d = y.first, c = y.second, f = z.first, e = z.second;
	ret.first = ((e-a)*(q(a) + q(b) - q(c) - q(d)) - (c-a)*(q(a) + q(b) - q(e) - q(f))) /((e-a)*(b-d)-(c-a)*(b-f));
	ret.first /= 2;
	return ret;
}

double cal(P x, P y, P z){
	double s = (x.first-z.first)*(x.second-y.second);
	//cout << s << endl;
	s-= (x.second - z.second)*(x.first-y.first);
	s *= 2;
	s = abs(s);
	if(s == 0){
		double ret = max(dist(x,y),max(dist(y,z),dist(z,x)));
		return max_ret;
	}
	double ret = dist(x,y) * dist(y,z) * dist(z,x);
	//cout << ret/s << endl;
	now = cent(x,y,z);
	//cout << s << endl;
	return ret/s;
}


int main(){
	int n;
	cin >> n;
	vector<P> da(n);
	rip(i,n,0) cin >> da[i].first >> da[i].second;
	if(n==2){
	printf("%07f\n", dist(da[0], da[1])/2);
	return 0;
	}
	rip(i,n-2,0){
		rip(j,n-1,i+1){
			rip(k,n,j+1){
				double dit = cal(da[i], da[j], da[k]);
				//printf("%d %d %d\n",i,j,k);
				rip(l,n,0){
					if(dit < dist(da[l], now) && l !=i && l != j && l != k){
						dit = max_ret;
					}
				}
				ans = min(ans, dit);
			}
		}
	}
	rip(i,n-1,0){
		rip(j,n,i+1){
			double dit = dist(da[i],da[j])/2;
			now.first = (da[i].first + da[j].first)/2;
			now.second = (da[i].second + da[j].second)/2;
			rip(l,n,0){
				if(dit < dist(da[l], now) && l !=i && l != j){
					dit = max_ret;
				}
			}
			ans = min(ans, dit);
		}
	}
	printf("%.07f\n", ans);
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        a:[f64;n],
    }
    //    mut  a:[f64;n],

    let mut b = vec![0i64; n];
    for i in 0..n {
        b[i] = (a[i] * 1e9 + 0.5f64) as i64;
    }
    let mut c = vec![];
    let mut tfs = vec![vec![0i64; 20]; 20];
    for &x in b.iter() {
        let mut two = 0;
        let mut five = 0;
        let mut y = x;
        while y % 2 == 0 {
            y /= 2;
            two += 1;
        }
        while y % 5 == 0 {
            y /= 5;
            five += 1;
        }
        two = min(two, 18);
        five = min(five, 18);
        c.push((two, five));
        tfs[two][five] += 1i64;
    }
    let mut ans = 0i64;
    for &(two, five) in c.iter() {
        for i in (18 - two)..19 {
            for j in (18 - five)..19 {
                ans += tfs[i][j];
            }
        }
        if two >= 9 && five >= 9 {
            ans -= 1;
        }
    }
    println!("{}", ans >> 1);
}

const eps: f64 = 1e-10;


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

typedef long long lli;

const int MAXN = 40004;
int n;
lli h[MAXN], a[MAXN], d[MAXN], s[MAXN];

lli T(const int &e) {
  return (h[e]+(a[0]-d[e]-1))/(a[0]-d[e]);
}

bool comp(const int &e1, const int &e2) {
  return T(e1)*(a[e2]-d[0]) < T(e2)*(a[e1]-d[0]);
}

int main() {
  while(cin >> n) {
    ++n;
    for(int i = 0; i < n; ++i) {
      cin >> h[i] >> a[i] >> d[i] >> s[i];
    }
    vector<int> id;
    bool lose = false;
    for(int i = 1; i < n; ++i) {
      if(a[i]-d[0] <= 0) {
	continue;
      }
      if(a[0]-d[i] <= 0) {
	lose = true;
	break;
      }
      id.push_back(i);
    }
    if(lose) {
      cout << -1 << endl;
      continue;
    }
    sort(id.begin(), id.end(), comp);
    lli damage = 0;
    lli turn = 0;
    for(int i = 0; i < id.size(); ++i) {
      int e = id[i];
      turn += T(e);
      if(s[0] > s[e])
	damage += (turn-1)*(a[e]-d[0]);
      else
	damage += turn*(a[e]-d[0]);
      damage = min(damage, h[0]);
    }
    if(h[0]-damage <= 0) cout << -1 << endl;
    else cout << damage << endl;
  }
  return 0;
}

Measured memory_bytes: 2624
using System;
namespace ABC099C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int res = n;
            for (int i = 0; i <= n; i++)
            {
                int count = 0;
                int t = i;
                while (t > 0)
                {
                    count += t % 6;
                    t /= 6;
                }

                t = n - i;
                while (t > 0)
                {
                    count += t % 9;
                    t /= 9;
                }
                if (res > count) res = count;
            }
            
            Console.Write(res);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include <math.h>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;


bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}

struct tree {
	queue<lli> leaf;
	lli num;
};

Tree t[200001];

void dfs(lli n, lli num) {
	t[n].num += num;
	while (!t[n].leaf.empty()) {
		dfs(t[n].leaf.front(), t[n].num);
		t[n].leaf.pop();
	}

}
int main() {
	lli n,tmp,num=1,a,b,r;
	cin >>a>>b;
	if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
n=b;
	for(lli i=2;i<=sqrt(n);i++){
		if(n%i==0){
			num++;
			while(n%i==0)n/=i;
		}
	}
	if(n!=1)num++;
	cout<<num;
}


Measured memory_bytes: 136320
#include <iostream>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main(){
  int sx;
  int sy;
  int tx;
  int ty;
  cin >> sx >> sy >> tx >>ty ;
  
  for(int i=1;i<=(ty -sy);i++){
    cout << "U";
  } 
  for(int i=1;i<=(tx -sx );i++){
    cout << "R";
  }
  for(int i=1;i<=(ty -sy);i++){
    cout << "D";
  }   
  for(int i=1;i<=(tx -sx);i++){
    cout << "L";
  }
  cout <<"L";
  for(int i=1;i<=(ty -sy +1);i++){
    cout << "U";
  } 
  for(int i=1;i<=(tx -sx +1);i++){
    cout << "R";
  }
  
  cout << "D";
  cout << "R";
   
  for(int i=0;i<=(ty -sy);i++){
    cout << "D";
  }   
  for(int i=0;i<=(tx -sx);i++){
    cout << "L";
  }
  cout <<"U" << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
L = [[] for _ in range(N)]
for i in range(N):
    L[a[i]-1].append(i)
cnt = 0
for i in range(N):
    if a[i]-1 in L[i]:
        cnt += 1
print(cnt//2)

Measured memory_bytes: 61868