akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }


void solveF() {

}

void solveE() {

}

void solveD() {

}

void solveC() {

}

void solveB() {

}

void solveA() {
	int ans =0 , x,n, m, c;
	cin >> n >> m >> c;
	vi b(m);
	lop(i, m) cin >> b[i];
	lop(i, n) {
		int sum = c;
		lop(j, m) cin >> x, sum += x*b[j];
		ans += sum > 0;
	}
	cout << ans << endl;
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) {
		solveA();
		//solveB();
		//solveC();
		//solveD();
		//solveE();
		//solveF();
	}


	return 0;
}


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

int main() {
    
    int H, W;
    
    cin >> H >> W;
    
    string matrix[H];
    
    for(int i = 0; i < H; i++) {
        cin >> matrix[i];
    }
    
    
    
    for(int i = 0; i < H; i++) {
        string::size_type index = -1;
        while(true) {
            index = matrix[i].find("#", index+1);
            if(index == string::npos) {
                break;
            }
            bitset<4> bitset = {0};
            if(index > 0) {
                if(matrix[i][index-1] == '.') {
                    bitset.set(0);
                }
            } else {
                bitset.set(0);
            }
            if(index < W - 1) {
                if(matrix[i][index+1] == '.') {
                    bitset.set(1);
                }
            } else {
                bitset.set(1);
            }
            if(i > 0) {
                if(matrix[i-1][index] == '.') {
                    bitset.set(2);
                }
            } else {
                bitset.set(2);
            }
            if(i < H - 1) {
                if(matrix[i+1][index] == '.') {
                    bitset.set(3);
                }
            } else {
                bitset.set(3);
            }
            
            if(bitset.all()) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define maxn 100
using namespace std;
int n, m;
template<class T>
inline void read(T &a){
	int s = 0, w = 1; char c;
	while(c < '0' || c > '9') {if(c == '-') w = -1; c = getchar();}
	while(c >= '0' && c <= '9'){s = (s << 1) + (s << 3) + (c ^ 48); c = getchar();}
	a = s*w;
}
int a[maxn], b[maxn];
int dfs(int n, int x){
if(x == 0 || (x == 1) && (n != 0)) return 0;
	if(x == b[n]) return a[n];
    if(n == 0) return 1;
	if(x <= 1) return 0;
	if(x >= b[n-1]*2 + 2) return a[n-1] * 2 + 1;
	else{
		if(x >= b[n-1] + 2) return a[n-1] + 1 + dfs(n - 1, x - b[n-1] - 2);
			else{
				 return dfs(n - 1, x - 1);
			}
		}
}
signed main(){
	read(n); read(m);
	a[0] = b[0] = 1;
	for (int i = 1; i <= n; i++){
		a[i] = a[i-1] * 2 + 1;
		b[i] = b[i-1] * 2 + 3;
	}
	printf("%lld", dfs(n, m));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e5+7;
ll dp[N];
ll a[N];
int main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
     ll k=2;

    dp[n]=0;
    ll l;
    for(ll i=n-1;i>0;i--)
    {
        dp[i]=1e9;
        for(ll j=1;j<=k;j++)
        {
            l=min(n,i+j);
            dp[i]=min(dp[i],dp[l]+abs(a[i]-a[l]));
        }
    }
    cout<<dp[1];
}


Measured memory_bytes: 5136
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n;
  cin>>n;
  int a[n];
  rep(i, n) cin>>a[i];
  sort(a, a+ n);
  cout << a[n- 1] - a[0] << endl;

  return 0;
}


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

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

  int count = 0;
  int check = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == 'R' && check != 0) {
      count++;
      check++;
    } else if (str.at(i) == 'R' && count != 0) {
      check++;
    } else if (str.at(i) == 'R' && count == 0) {
      count++;
      check++;
    } else {
      check = 0;
    }
  }

  cout << count << endl;
}

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

using namespace std;

const int N = 105;

int sum[N][N], sum2[N][N], sum3[N][N], sum4[N][N], n, K, x, y;

struct Point {
	int x, y;
}p[N], p2[N];

bool cmp_x(Point x, Point y) {
	return x.x < y.x;
}

bool cmp_y(Point x, Point y) {
	return x.y > y.y;
}

inline int SUM(int up, int dn, int lf, int rt) {
	return sum[rt][dn] + sum4[lf][up] - sum2[lf][dn] - sum3[rt][up];
}

inline long long abss(long long x) {
	return x > 0 ? x : -x;
}

inline long long AREA(int up, int dn, int lf, int rt) {
	long long ans = 1ll * (p2[up].y - p2[dn].y) * (p[rt].x - p[lf].x);
	return abss(ans);
}

int main() {
//	freopen("1.in", "r", stdin);
	cin >> n >> K;
	for(int i = 1; i <= n; i++) {
		cin >> x >> y;
		p[i] = (Point) {x, y};
		p2[i] = (Point) {x, y};
	}
	sort(p2 + 1, p2 + n + 1, cmp_y);
	sort(p + 1, p + n + 1, cmp_x);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= n; k++) {
				if(p[k].x <= p[i].x && p[k].y >= p2[j].y)
					sum[i][j] ++;
				if(p[k].x < p[i].x && p[k].y >= p2[j].y)
					sum2[i][j] ++;
				if(p[k].x <= p[i].x && p[k].y > p2[j].y) 
					sum3[i][j] ++;
				if(p[k].x < p[i].x && p[k].y > p2[j].y)
					sum4[i][j] ++;
			}
	}
//	cout << endl << endl;
//	for(int i = 1; i <= n; i++)
//		cout << p[i].x << ',' << p[i].y << endl;
//	cout << endl << endl;
//	for(int i = 1; i <= n; i++)
//		cout << p2[i].x << ',' << p2[i].y << endl;
//	for(int i = 1; i <= n; i++)
//		for(int j = 1; j <= n; j++)
//			cout << "y = " << p2[j].y << " x = " << p[i].x << "  sum[" << i << "][" << j  << "] = " << sum[i][j] << endl;
	long long ans =	(long long) 9223372036854775807;
	for(int i = 1; i <= n; i++) {
		for(int j = i; j <= n; j++)
			for(int k = 1; k <= n; k++)
				for(int l = k; l <= n; l++)
					if(SUM(i, j, k, l) >= K && AREA(i, j, k, l) < ans) {
						ans = AREA(i, j, k, l);
						if(ans == 0) cout << "i = " << i << " j = " << j << " k = " << k << " l = " << l << endl;
					}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
def main():
    x = int(input())
    ans = [i**5 for i in range(-125, 126)]
    for i, v1 in enumerate(ans, -125):
        for j, v2 in enumerate(ans, -125):
            if (v1-v2==x):
                print(i, j)
                return

if __name__ == "__main__":
    main()

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

int main() {

  int x[3000][2], i, j, a;

  for(i=0;i<3000;i++) {
    cin >> x[i][0] >> x[i][1];
    if(x[i][0]==0 && x[i][1]==0) break;
  }

  for(i=0;i<3000;i++) {
    if(x[i][0]==0 && x[i][1]==0) break;
    if(x[i][0]>x[i][1]){
      a = x[i][0];
      x[i][0] = x[i][1];
      x[i][1] = a;
    }
    cout << x[i][0] << " " << x[i][1] << endl;
  }





}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int p, q, r;
  cin >> p >> q >> r;
  vector<int> a;
  a.push_back(p + q);
  a.push_back(p + r);
  a.push_back(q + r);
  SORT(a);
  cout << a[0] << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> Vector;
typedef vector<vector<ll>> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX/3
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)
Vector a;
ll rec(ll num) {
if(a[num] == -1)a[num] = rec(num-1)+rec(num-2);
return a[num];
}

int main(){
  cin.sync_with_stdio(false);
  ll n;
  cin >> n;
  a.resize(n+1,-1);
  a[0] = 2;
  a[1] = 1;
  cout << rec(n) << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    a.push_back(-INF);
    c.push_back(-INF);
    a.push_back(INF);
    c.push_back(INF);

    sort(ALL(a));
    sort(ALL(c));

    int ans = 0;
    rep(i, n){
        int lo, hi;

        lo = 0;
        hi = n + 2;
        while(hi - lo > 1){
            int mid = (lo + hi) / 2;
            if(a[mid] < b[i]){
                lo = mid;
            }else{
                hi = mid;
            }
        }

        int tmp = lo;

        lo = -1;
        hi = n + 1;
        while(hi - lo > 1){
            int mid = (lo + hi) / 2;
            if(c[mid] > b[i]){
                hi = mid;
            }else{
                lo = mid;
            }
        }
        tmp *= (n + 1 - hi);
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3440
#include <stdio.h>
#include <iostream>
#define eps 1E-8
using namespace std;


int n, f[7];

int dfs(int m,int i,int j,double r){
	int k, l, ret = 0;
	if(-eps <= r && r <= eps){
/*		for(int t = 0;t < i;t++){
			printf("1 / %d ",f[t]);
			if(t != i - 1) printf("+ ");
			else printf("\n");
		}*/
		return 1;
	}
	if(i == n || r < 0)
		return 0;
	for(k = min(m,j);k >= 1;k--){
		f[i] = k;
		ret += dfs(m / k,i + 1,k,r - 1.0 / k);
	}
	return ret;
}
		
int main(void){
	int p, q, a, i, ans;
	while(1){
		scanf("%d%d%d%d",&p,&q,&a,&n);
		if(p == 0 && q == 0 && a == 0 && n == 0)
			break;
		ans = 0;
		ans = dfs(a,0,a,(double)p / q);
		printf("%d\n",ans);
	}
	return 0;
}

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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 200 * 1000 + 123;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
map<int, int> a;
int h[N];

ll t[4 * N];

ll get_mx(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return t[v];

    if (ql > r || l > qr) return 0;

    int mid = (l + r) / 2;
    return max(
            get_mx(2 * v + 1, l, mid, ql, qr),
            get_mx(2 * v + 2, mid + 1, r, ql, qr)
    );
}

ll upd(int v, int l, int r, int pos, ll val) {
    if (l == r) {
        t[v] = val;
    } else {

        int mid = (l + r) / 2;
        if (pos <= mid) upd(2 * v + 1, l, mid, pos, val);
        else upd(2 * v + 2, mid + 1, r, pos, val);

        t[v] = max(
                t[2 * v + 1],
                t[2 * v + 2]
        );
    }
}

int main() {
    cin >> n;
    loop(i, n) {
        cin >> h[i];
    }
    loop(i, n) {
        cin >> a[h[i]];
    }

    vector<pii > v;
    loop(i, n) {
        v.push_back(make_pair(h[i], i));
    }
    sort(all(v));

    for (auto p : v) {
        int he = p.first;
        int i = p.second;

//        db(i);
        ll mx = get_mx(0, 0, n - 1, 0, i);

        upd(0, 0, n - 1, i, mx + a[he]);
    }


    ll res = t[0];
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 18292
n = int(input())
s = [None] *n
countdict = {}
for i in range(n):
    s[i] = str(input())
for moji in s:
    if moji in countdict.keys():
        countdict[moji] += 1
    else:
        countdict[moji] = 0
ma = max(countdict.values())
ma_lis = []
for ke in countdict.keys():
    if countdict[ke] == ma:
        ma_lis.append(ke)
ma_lis.sort()
for name in ma_lis:
    print(name)

Measured memory_bytes: 35176
def main():
    N = input()
    l = map(int, raw_input().split())
    result = 0
    for i in range(N):
        while l[i]%2 == 0:
            l[i] = l[i]/2
            result = result + 1
    print(result)


if __name__ == '__main__':
    main()


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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

int main()
{
    fastio;
    string s;
    cin>>s;
    lli tot = 0;
    lli ten = 1;
    lli mod = 2019;
    vlli cnt(mod,0);

    lli ans = 0;

    for(int i = s.length() - 1; i>=0;i--){
        cnt[tot]++;
        tot += (s[i] - '0')*ten;
        ten *= 10;
        tot %= mod;
        ten %= mod;
        ans += cnt[tot];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

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

    int A, B, C;
    int ans = 0;

    cin >> A >> B >> C;
    if(A%2 || B%2 || C%2) puts("0");
    else if(A == B && B == C) puts("-1");
    else{
        while(1){
        ans++;
        int nA = (B+C)/2;
        int nB = (C+A)/2;
        int nC = (A+B)/2;
        A=nA;
        B=nB;
        C=nC;
        if(A%2 || B%2 || C%2){
            cout << ans << "\n";
            break;
        }
        }
    }
    


    return 0;
}

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

s = input().split()
s = list(s[0])

for i in range(len(s)):
    if i%2==0:
        if s[i]=="L":
            print("No")
            sys.exit()
    else:
        if s[i]=="R":
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 3060
// 2014/07/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int r, c;
	cin >> r >> c;

	int S[101][101];
	for(int i=0; i<=r; i++){
		for(int j=0; j<=c; j++){
			S[i][j] = 0;
		}
	}

	for(int i=0; i<r; i++){
		for(int j=0; j<c; j++){
			cin >> S[i][j];

			S[r][j] += S[i][j];
			S[i][c] += S[i][j];
		}

		S[r][c] += S[i][c];
	}

	for(int i=0; i<=r; i++){
		for(int j=0; j<=c; j++){
			cout << S[i][j];

			if(j==c){
				cout << endl;
			}
			else{
				cout << ' ';
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1200
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int A = in.nextInt();
        if(N%500 <= A){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

        in.close();
    }
}


Measured memory_bytes: 23124
import sys
a=sys.stdin.readline()
res=[i for i in a.split()]
r1,r2=float(res[0]),float(res[1])
v1,v2=r1.is_integer(),r2.is_integer()
if v1==v2==True:
    A,B=int(r1),int(r2)
    if 0<=(A and B)<=1000000000:
        w=(A+B)/2
        v3=w.is_integer()
        if v3==True:
            print(int(w))
        elif v3!=True:
            print("IMPOSSIBLE")

Measured memory_bytes: 9064
h, w = map(int,input().split())
l = [['.']*(w+2)]
for i in range(h):
    row = list(input()) #一文字ずつリストに
    l.append(['.']+row+['.'])
l.append(['.']*(w+2))

'''for i in l:
    print(i)'''

flag = True

for i in range(h+2):
    for j in range(w+2):
        if l[i][j] == '#':
            if l[i-1][j]==l[i][j-1]==l[i+1][j]==l[i][j+1]=='.':
                flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
def main():
    s = input()
    if s[0] == s[1]:
        print(1, 2)
        return
    for i in range(len(s)-2):
        if len(set(s[i: i+3])) < 3:
            print(i+1, i+3)
            return
    print(-1, -1)
if __name__ == '__main__':
    main()

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

int main()
{
	long long k,a,b;
	cin>>k>>a>>b;
	if(a>=b-1)
	{
		cout<<k+1;
		return 0;
	}
	long long ans=0;
	k++;
	k-=a;
	ans=a;
	ans+=(b-a)*(k/2);
	ans+=k%2;
	cout<<ans;
	return 0;
}

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

count = 0
last = 0#前のBの余力
for i in range(N):
    at = min(A[i] - last, B[i])
    if at < 0:
        at = 0
    if at == 0:
        count += A[i]
    else:
        count += at + last
    last = B[i] - at
count += min(A[-1],last)
print(count)

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

int main() {
  int n, k;
  string s;

  cin >> n >> s >> k;

  for (int i = 0; i < n; i++) {
    if (s[k - 1] != s[i]) {
      s[i] = '*';
    }
  }
  cout << s;
  return 0;
}


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};
struct combination {
	vector<mint> fact, ifact;
	combination(int n):fact(n+1),ifact(n+1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};
int main(){
	FIO
	
	combination C(3e6);
	int x, y;cin >> x >> y;
	if((x + y) % 3 == 0){
		int m = (2 * x - y) / 3;
		int n = (y - m) / 2;
		if(n < 0 || m < 0){
			cout << 0;
			return 0;
		}
		cout << C(n + m, n).x;
	}
	else cout << 0;
	return 0;
}


Measured memory_bytes: 47104
#再帰の限度を拡張
import sys
sys.setrecursionlimit(1000000)
N,M = map(int, input().split())

parent_dict = dict() #key:子 value:親

#接続追加
def add_connect(A,B):
    A_parent = get_parent(A)
    B_parent = get_parent(B)
    
    if A_parent != B_parent:
        parent_dict[B_parent] = A_parent

#接続有無判断
def judge_connection(A,B):
    A_parent = get_parent(A) #未更新状態でも、ここで更新される
    B_parent = get_parent(B)
    
    if A_parent != B_parent:
        return False
    else:
        return True

#親の取得
def get_parent(child):
    if child not in parent_dict: #初出なら自分自身を親として追加
        parent_dict[child] = child
    
    parent = parent_dict[child]
    
    if parent == child: 
        return parent
    else: #最上位の親なら上の等式が成り立つ。不成立ならさらに上位の親を辿る。
        parent_dict[child] = get_parent(parent) 
        return parent_dict[child]


##注意!!　全入力完了後にget_parentをしないと、正しい親が得られない
#ex 12 23 13 56 61 43→{1: 5, 2: 1, 3: 5, 5: 4, 6: 5, 4: 4}になる
for i in range(M):
    A,B = map(int, input().split())
    add_connect(A,B)

for i in range(1,N+1):
    get_parent(i)

#print(parent_dict)

#最も子が多い親を求めるために、親:子の辞書を作る
child_dict = dict() #key:親 value:子

for i in range(1,N+1):
    if parent_dict[i] not in child_dict:
        child_dict[parent_dict[i]] = set()
    child_dict[parent_dict[i]].add(i)


ans = 1
for parent in child_dict:
    if len(child_dict[parent]) > ans:
        ans = len(child_dict[parent])

print(ans)

Measured memory_bytes: 96620
n = int(input())
result = 1
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

for _ in range(n):
    num = int(input())
    result = lcm(num, result)
print(result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    // int t;
    // cin>>t;
    // while(t--){
    long long int i,j,k,l,m,n,x=0,y=0,z=0,r=0,g,h;
    string p,q,s;
    vector<int>u,v;
    cin>>n>>k;
   long long int dp[n+1][k+1];
        int a[n+1],w[n+1];
        for(i=0;i<n;i++){
            cin>>w[i]>>a[i];
        }
        for(i=0;i<=n;i++){
            for(j=0;j<=k;j++){
                if((i==0)||(j==0)){
                    dp[i][j]=0;
                }
                else{
                    if(w[i-1]<=j){
                        x=dp[i-1][j];
                        y=dp[i-1][j-w[i-1]]+a[i-1];
                    dp[i][j]=max(x,y);
                    
                    }
                    else{
                        dp[i][j]=dp[i-1][j];
                    }
                }
            }
        }
        cout<<dp[n][k]<<"\n";
    
}

Measured memory_bytes: 79104
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

i64 mod_pow(i64 x, i64 n, const i64 mod) {
    i64 res = 1LL;
    for(; n > 0LL; n >>= 1LL) {
        if(n & 1LL) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> mp;
    for(int _ : in(n)) {
        int x;
        cin >> x;
        bool ok = (n & 1) != (x & 1);
        if(!ok) {
            cout << 0 << endl;
            return 0;
        }
        mp[x]++;
        
    }
    for(const auto& p : mp) {
        bool ok = [&]() {
            if(p.first == 0) {
                if(p.second != 1)
                    return false;
            }
            else if(p.second != 2)
                return false;
            return true;
        }();
        if(!ok) {
            cout << 0 << endl;
            return 0;
        }
    }
    i64 num = mp.size();
    if(n & 1) --num;
    cout << mod_pow(2LL, num, 1000000007LL) << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>

char c;
int f;
int nextInt();

int N, A, i;

int main(void){
	N=nextInt();
	for(i=0; i<N; i++){
		A=nextInt();
		if(A%2){
			printf("first\n");
			return 0;
		}
	}
	printf("second\n");
	return 0;
}

int nextInt(){
	f=0; c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
# define ll long long int
# define ld long double
# define pb push_back
# define mp make_pair
# define mod 998244353 
# define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#else
// online submission
	#endif
	IOS
	int n;
	cin >> n;
	vector<int> cost, ans(n,0);
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		cost.pb(x);
	}
	ans[1] = abs(cost[1] - cost[0]);
	ans[2] = min(abs(cost[2] - cost[1]) + ans[1], abs(cost[2] - cost[0]));
	for(int i = 3; i < n; i++){
		ans[i] = min(ans[i - 1] + abs(cost[i] - cost[i - 1]), ans[ i - 2] + abs(cost[i] - cost[ i - 2]));
	}
	cout << ans[n - 1];
	return 0;
}

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

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;

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

    int n;
    cin >> n;
    vi xs(n);
    for(auto& xi: xs)
        cin >> xi;
    multiset<int> last;
    for (int i=0; i<n; ++i) {
        auto it = last.lower_bound(xs[i]);  // first >= xs[i]  --> prev(it) < xs[i]
        if (it != last.begin())
            last.erase(std::prev(it));
        last.insert(xs[i]);
    }
    cout << last.size() << endl;
}


Measured memory_bytes: 5376
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll dx[] = { 1, 0 , -1,  0 }, dy[] = { 0, 1, 0, -1 };

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


	ll n = s.size(), i = 0, j = n - 1, x = 0;
	bool flag = false;

	while (i <= j) {
		if (s[i] != s[j]) {
			if (s[i] == 'x') {
				x++;
				i++;
			}
			else if (s[j] == 'x') {
				x++;
				j--;
			}
			else {
				flag = true;
				break;
			}
		}
		else {
			i++;
			j--;
		}
	}

	if (flag) cout << -1;
	else cout << x;

	return 0;
}



ll gcd(ll a, ll b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    long double A, B, H, M;
    cin >> A >> B >> H >> M;
    long double a = M_PI / 2 - 2 * M_PI * M / 60;
    long double b = M_PI / 2 - 2 * M_PI * (60 * H + M) / 720;
    long double p = A * cosl(a), q = A * sinl(a);
    long double r = B * cosl(b), s = B * sinl(b);
    printf("%.10Lf\n", sqrtl((p - r) * (p - r) + (q - s) * (q - s)));
    return 0;
}

Measured memory_bytes: 4148
import math
import os
import random
import re
import sys
n= int(input())
arr=[int(s) for s in input().split()]
p=1;
count=0
for i in range(n):
    if arr[i]==0 : 
        count=1
        break
for i in range(n):
    p=p*arr[i]
    if(p>1000000000000000000):
        p=-1
        break
if(count==0) : print(p)
else : print(0)


Measured memory_bytes: 93968
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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




int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	ll N, D;
	cin >> N >> D;

	if (N % (2 * D + 1) != 0) {
		cout << (N / (2 * D + 1)) + 1 << endl;
	}
	else {
		cout << (N / (2 * D + 1)) << endl;
	}


	return 0;
}



Measured memory_bytes: 888
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 r;
  std::cin >> r;
  std::cout << 3 * r * r << std::endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
ans=0
RGB_dict={'R':0,'G':0,'B':0}
for s in S:
  RGB_dict[s]+=1
ans=RGB_dict['R']*RGB_dict['G']*RGB_dict['B']

for i in range(N-1):
  s1=S[i]
  for j in range(i+1,N):
    s2=S[j]
    if s1==s2: continue
    k=j+(j-i)
    if k>N-1: continue
    #print(k)
    s3=S[k]
    if s1!=s3 and s2!=s3:
      ans-=1
print(ans)

Measured memory_bytes: 68260
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int  a = sc.nextInt();
        int  b = sc.nextInt();
        int  c = sc.nextInt(); 
        if(a<b && b<c){
            System.out.println("Yes");
        }
        else{
        System.out.println("No");
        }
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  for (auto& e : h) cin >> e;

  sort(h.rbegin(), h.rend());
  ll r = 0;
  for (int i = k; i < n; i++) r += h[i];
  cout << r << endl;
}


Measured memory_bytes: 1792
'use strict'

const main = arg => {
    var input = arg.trim().split("\n");
    var config = input[0].split(" ").map(str => parseInt(str, 10));
    const matrixA = input.slice(1, config[0]+1).map(row => row.split(" ").map(str => parseInt(str, 10)));
    const matrixB = input.slice(config[0]+1, config[0]+1+config[1]).map(row => row.split(" ").map(str => parseInt(str, 10)));
    const result = [...Array(config[0])].map(obj1 => [...Array(config[2])].map(obj2 => 0));

    for(var n=0;n<config[0];n++){
        var cal = [];
        for(var l=0;l<config[2];l++){
            var cal = [];
            for(var m=0;m<config[1];m++){
                cal.push(matrixA[n][m] * matrixB[m][l]);
            }
            result[n][l] = cal.reduce((a, b) => a + b);
        }
    }

    console.log(result.map(a => a.join(" ") ).join("\n"));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21116
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String b = sc.next();
    String res  = "";
    switch (b){
        case "A":
            res = "T";
            break;
        case "C":
            res = "G";
            break;
        case "G":
            res = "C";
            break;
        case "T":
            res = "A";
            break;
    }
    System.out.println(res);
  }
  
}

Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N, count = 0;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++){
        cin >> L[i];
    }

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

    int a, b, c;
    for (int i = 0; i < N; i++){
        a = L[i];
        for (int j = i+1; j < N; j++){
            b = L[j];

            // (最初にa+b以上となる場所) - j - 1
            vector<int>::iterator low = lower_bound(L.begin(), L.end(), a+b);
            count += (low - L.begin()) - j - 1;
            // cout << "a:" << a << " b:" << b << " | " << (low - L.begin()) - j - 1 << " (" << low - L.begin() << ")"<< endl;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    string x , y ;
    double a = 0 ;
    cin >> x >> y ;
    for(int i=0;i<x.size();i++){
    if(x[i]==y[i])
    a=a+1;
    }
    cout<<a ;
    return 0 ;
}

Measured memory_bytes: 256
s = input().split()
N=int(s[0])
s = input().split()
count=[]
count.append(int(s[0]))
for i in range(1,N-1):
        if int(s[i])<int(s[i-1]):
                count.append(int(s[i]))
        else:
                count.append(int(s[i-1]))
count.append(int(s[N-2]))
print(sum(count))

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

int main() {
    int n;
    cin >> n;
    int z=0,f=0;
    int nt=0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(a%4==0) f++;
        else if(a%2==0) nt++;            
        else z++;
    }
    if(nt>0) {
        z++;
        n -= nt;
        n++;
    }
    if(n%2==0 && f>=z) cout << "Yes" << endl;
    else if(n%2==1 && f>=z-1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    int x = 0;
    int n;
    string s;
    cin >> n >> s;
    int ans = x, ans1 = x;
    rep(i, n) {
        if(s[i] == 'I') {
            ans1++;
        }
        else ans1--;
        ans = max(ans, ans1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int N,num,count=0;
	map<int,int> dmap;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>num;
		map<int,int>::iterator it = dmap.find(num);
		if(it==dmap.end()){
			dmap.insert(map<int, int>::value_type(num,1));
		}
	}
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>num;
		map<int,int>::iterator it = dmap.find(num);
		if(it!=dmap.end()){
			count++;
		}
	}
	cout<<count<<endl;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;
string s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	cin>>s ;
	if(n & 1)
		return cout<<"No\n" , 0 ;
	for(int i = 0 ; i < n/2 ; ++i)
	{
		if(s[i] != s[i+n/2])
			return cout<<"No\n" , 0 ;
	}
	return cout<<"Yes\n" , 0 ;
}		

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

double dp[3001][3001];
double p[3001];
void solve(){
	int n;
	cin>>n;
	rep(i,0,n)cin>>p[i];
	dp[0][0]=1-p[0];
	dp[0][1]=p[0];
	rep(i,1,n){
		dp[i][0]=dp[i-1][0]*(1-p[i]);
		rep(j,1,3000){
			dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
		}
	}
	double ans=0;
	rep(i,n/2+1,n+1){
		ans+=dp[n-1][i];
	}
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cout<<setprecision(12);
	cout<<fixed;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 70528
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#define next sfhds

using namespace std;

int a[200001][2],n,m,to[500001],next[500001],first[500001],is[200001],e1=0,k=0,v[200001];
char ch[200001];
queue<int> q;

void insert(int o,int p) {to[e1]=p;next[e1]=first[o];first[o]=e1++;}

int main()
{
	memset(first,-1,sizeof(first));
	scanf("%d%d",&n,&m);
	scanf("%s",ch);
	for(int i=0;i<n;i++) is[i+1]=ch[i]=='A';
	memset(a,0,sizeof(a));
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		insert(x,y);insert(y,x);
		a[x][is[y]]++;a[y][is[x]]++;
	}
	memset(v,0,sizeof(v));
	for(int i=1;i<=n;i++) if((a[i][0]==0)||(a[i][1]==0)) q.push(i),v[i]=1,k++;
	while(!q.empty())
	{
		int yu=q.front();
		for(int i=first[yu];i!=-1;i=next[i])
		    if(!v[to[i]])
		    {
		    	a[to[i]][is[yu]]--;
		    	if(a[to[i]][is[yu]]==0) q.push(to[i]),v[to[i]]=1,k++;
			}
		q.pop();
	}
	if(k<n) cout<<"Yes"<<endl;else cout<<"No"<<endl;
	return 0;
} 

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    sort(A.begin(), A.end());
    REP(i, N - 1) {
        if (A[i] == A[i + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,A,B; cin >> N >> A >> B;
	cout << min(A,B)<< " "<<(A+B<=N?0:A+B-N) << endl;






	return 0;
}


Measured memory_bytes: 256