akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
using namespace std;
const int INF = 1000000009;

int n, z, w;
int a[2000];

int main(){
	scanf("%d%d%d", &n, &z, &w);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	if(n >= 2){
		printf("%d\n", max(abs(w - a[n-1]), abs(a[n-2]-a[n-1])));
	}else{
		printf("%d\n", abs(w-a[0]));
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "div7"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			ifstream cin(_is); \
			ofstream cout(_os);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 100005;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-8;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;


int32_t main() {
	FAST;

	int n, w;
	cin >> n >> w;
	vector<pair<int, int>> a;
	for (int i = 0; i < n ; i++) {
		int x, y;
		cin >> x >> y;
		a.emplace_back(x, y);
	}


	int mv = (n + 1) * 1000;
	vector<vector<int>> dp(n + 1, vector<int> (mv, INF));

	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < mv; j++) {
			dp[i][j] = dp[i-1][j];
			if (j >= a[i - 1].second) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j - a[i - 1].second] + a[i - 1].first);
			}
		}
	}

	int ans = 0;
	for (int j = 1; j < mv; j++) {
		if (dp[n][j] <= w)
			ans = j;
	}

	cout << ans;
}


Measured memory_bytes: 83960
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
#include <climits>
#include <numeric>

//usings
using namespace std;

//type def
typedef long long int64;
typedef pair<int, int> ii;

//consts
const int mod = 1e9 + 7;

//methods
template<typename T>
bool chmax(T& source, const T& compare_to) {
    if(source < compare_to) {
        source = compare_to;
        return true;
    }
    return false;
}

int modpow(int64 base, int n) {
    int64 ret = 1;
    while(n) {
        if(n & 1) ret = ret * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return ret;
}

class Solution {
private:
public:
    string solve(int n, int m, vector<int>& pop, int sum) {
        sort(rbegin(pop), rend(pop));
        int i = 0;
        for(; i < m && pop[i] * 4 * m >= sum; ++i);
        return i == m ? "Yes" : "No"; 
    }
};

int main() {
    int n, m, sum = 0;
    cin >> n >> m;
    vector<int> pops(n);
    for(int i = 0; i < n; ++i) {
        cin >> pops[i];
        sum += pops[i];
    }
    Solution sol;
    auto ret = sol.solve(n, m, pops, sum);
    cout << ret << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] str = sc.nextLine().toCharArray();
		
		for(int i=0;i<str.length;i++) {
			if(Character.isUpperCase(str[i])) {
				str[i]=Character.toLowerCase(str[i]);
			}
			else if (Character.isLowerCase(str[i]) ) {
				str[i]=Character.toUpperCase(str[i]);
			}else {
				
			}
		}
		
		for(int i=0;i<str.length;i++) {
			System.out.print(str[i]);
		}
		System.out.println();
		sc.close();

	}

}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  int n;
  cin>>n;
  int arr[n];
  int sum = 0;
  rep(i, 0, n) {
    cin>>arr[i];
    sum += arr[i];
  }
  int m;
  cin>>m;
  rep(i, 0, m)
  {
    int a, b;
    cin>>a>>b;
    a--;
    cout<<(sum-arr[a]+b)<<endl;
  }

  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;

  if (A == B) {
    cout << A + B << endl;
  }
  else if (A < B){
    cout << B + B - 1 << endl;
  }
  else if (A > B){
    cout << A + A - 1 << endl;
  } 
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int m, k;
  cin >> m >> k;
  if (k >= 1 << m) {
    puts("-1");
    return 0;
  }
  // k < 2^m
  if (m == 0) {
    puts("0 0");
  } else if (m == 1) {
    if (k == 0) {
      puts("0 0 1 1");
    } else {
      puts("-1");
    }
  } else {
    cout << k;
    REP(i, 1 << m) {
      if (i == k) continue;
      cout << " " << i;
    }
    cout << " " << k;
    REP(i, 1 << m) {
      if (((1 << m) - 1 - i) == k) continue;
      cout << " " << (1 << m) - 1 - i;
    }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        String bs = in.next();

        long b100 = Long.valueOf(bs.split("\\.")[0]) * 100 +
            Long.valueOf(bs.split("\\.")[1]);
        a *= b100;
        System.out.println(a / 100);
    }
}

Measured memory_bytes: 35852
# coding: utf-8
 
def count_char_max(text):
 
  a = "abcdefghijklmnopqrstuvwxyz"
  l = [0] * 26
 
  for i in text:
 
    ascNum = ord(i.lower()) - 97
 
    if ascNum < 0 or 25 < ascNum:
      continue
 
    l[ascNum] += 1
 
  return max(l)
 
s = raw_input()

for i in range(len(s) - 1):

  if (s[i] == s[i + 1]):
    print "%d %d" % (i + 1, i + 2)
    quit()

for i in range(len(s) - 2):

  if (count_char_max(s[i:i+3]) == 2):
    print "%d %d" % (i + 1, i + 3)
    quit()

print "-1 -1"

Measured memory_bytes: 5892
function Main(input) {
	input = input.trim().split(" ");
	var A = input[0];
	var B = input[1];
	var a1 = parseInt(A.slice(0, -7),10);
	var a2 = parseInt(A.substr(-7, 7),10);
	var b1 = parseInt(B.trim().split(".")[0]);
	var b2 = parseInt(B.trim().split(".")[1]);
	if (isNaN(a1)) a1 = 0;
	if (isNaN(a2)) a2 = 0;
	if (isNaN(b1)) b1 = 0;
	if (isNaN(b2)) b2 = 0;
	var ANS, ans1, ans2, ansMiddle, tmp;
	
	ans1 = a1 * (b1 * 100 + b2);
	tmp = String(a2 * (b1 * 100 + b2)).slice(0,-2); 
	ansMiddle = parseInt(tmp.slice(0, -5),10);
  	if (isNaN(ansMiddle)) ansMiddle = 0;
	ans2 = parseInt(tmp.substr(-5, 5),10);
	if (isNaN(ans2)) ans2 = 0;
	ans1 = String(ans1 + ansMiddle);
	if (ans1 === '0'){
		ANS = String(ans2);
	} else {

		ANS = ans1 + String(ans2 + 100000).substr(-5,5);
	}	
 	console.log(ANS);	
}   

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll L, R;
    cin >> L >> R;
    ll K = L + 2100;
    ll res = (1ll << 60);
    for(ll i=L;i<=min(R, K);i++){
    	for(ll j=L;j<=min(R, K);j++){
    		if(i<j) res = min(res, i*j%2019);
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    ll N,M; cin>>N>>M;
    ll ans = 0;
    if(N >= M/2){
        ans = M/2;
    }else{
        ans = N;
        M -= N*2;
        ans += M/4;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < max(a, b); i++) cout << min(a, b);
    return 0;
}




Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
	int a, b;

	cin >> a >> b;

	if(a <= 8 && b <= 8){
		cout << "Yay!" << endl;
	} else {
		cout << ":(" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long lolo;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ulolo;

const int maxn = (int)1e5 + 5;
const lolo maxx = (lolo)10000001;
const int maxm =(int)2e3 + 5;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = (int)1e6 + 3;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') { c = '0', flag = -1;}
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

int main() {
//    freopen("../in.txt", "r", stdin);
    pii cv[22];
    int n;
    read(n);
    for (int i = 0; i < n; ++i) {
        read(cv[i].first);
    }
    for (int i = 0; i < n; ++i) {
        read(cv[i].second);
    }
    sort(cv, cv+n, [](pii a, pii b) {
       return a.first-a.second>b.first-b.second;
    });
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (cv[i].first>cv[i].second) {
            ans += cv[i].first-cv[i].second;
        } else {
            break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
def sieve(n):
    prime = [True] * n
    prime[0] = prime[1] = False
    for i in xrange(2, int(n ** 0.5) + 1):
        if prime[i]:
            for j in range(i * i, n, i):
                prime[j] = False
    return [i for i in xrange(2, n) if prime[i]]

while 1:
    try:
        print len(sieve(input() + 1))
    except:
        break

Measured memory_bytes: 27908
#include<iostream>
#include<algorithm>
using namespace std;
int a[200] = {0};
int main()
{
	int n, sum = 0;
	cin >> n;
	for(int i = 1; i < n; i++)
		cin >> a[i];
	a[0] = a[n] = 2147483647;
	for(int i = 0; i < n; i++)
		sum += min(a[i],a[i+1]);
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	int k=0;
	while(cin>>a)
	{
		if(a=='C'&&k==0)
		{
			k++;
		}
		if(a=='F'&&k==1)
		{
			k++;
		}
	}
	if(k==2)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

ll bit[200010];
//ll kai[3010];
ll Cnt[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	//i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	//i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			Cnt[j] = max(Cnt[j], cnt);
		}
	}
	if (X != 1) Cnt[X] = max(Cnt[X], 1LL);
}

ll N;
ll u, v;
vector<ll> E[100010];
ll a, b;
ll numChildren[100010];
ll len[100010];
ll c, d;
ll par[100010];
ll ans;

ll make_par(ll now, ll from, ll le) {
	par[now] = from;
	len[now] = le;
	ll nu = 0;
	for (ll V : E[now]) {
		if (V == from) continue;
		nu = max(nu, make_par(V, now, le + 1) + 1);
	}
	return numChildren[now] = nu;
}

void path(ll now) {
	//cout << now << ' ' << len[now] << ' ' << numChildren[now] << endl;
	if (len[u] - len[now] >= len[now]) return;
	if (par[now] == 0) return;
	ans = max(ans, len[now] + numChildren[now]);
	//cout << now << ' ' << len[now] << ' ' << numChildren[now] << endl;
	path(par[now]);
}

void solve() {
	cin >> N >> u >> v;
	rep(i, N - 1) {
		cin >> a >> b;
		E[a].pb(b);
		E[b].pb(a);
	}
	make_par(v, 0, 0);
	path(u);
	cout << ans - 1 << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

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

int main() {
  int n, m, c;
  while ( cin >> n >> m >> c ) {
    int arr[ m+5 ];
    for (int i = 0; i < m; ++i)
      cin >> arr[i];
    
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      int tmp = c;
      for (int j = 0; j < m; ++j) {
        int s; cin >> s;
        tmp += arr[j] * s;
      }
      if ( tmp > 0 ) cnt++ ;
    }
    cout << cnt << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin >> s1>>s2;
    int count =0;
    for(int i=0; i<3; i++)
    {
            if(s1[i]==s2[i])
            {
                count++;
            }
    }
    cout << count <<endl;

}

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

int main()
{
    long long int n,r,m=0,d,c=0;
    cin>>n>>r;
    while(n)
    {
        d=n%r;
        c++;
        n=n/r;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, X):
    layer = [1]
    pate = [1]
    for _ in range(N):
        layer.append(layer[-1] * 2 + 3)
        pate.append(pate[-1] * 2 + 1)

    # print(layer[-1])
    # print(pate[-1])

    def burger(n, l):
        if layer[n] <= l:
            return pate[n]
        if l == 0:
            return 0
        re = 0
        if layer[n] // 2 + 1 <= l:
            re += pate[n - 1] + 1  # center pattie
            l -= layer[n] // 2 + 1
        else:
            l -= 1  # first bun
        re += burger(n - 1, l)
        return re

    print(burger(N, X))


if __name__ == '__main__':
    N, X = map(int, input().split())
    solve(N, X)

    # # test
    # from random import randint
    # from func import random_str
    # N, X = 3, 1
    # for i in range(1, 29 + 1):
    #     solve(N, i)


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

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

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        new Main().exe();
    }

    private void exe(){
        Scanner sc = new Scanner(System.in);
        HashSet<String> hs = new HashSet<String>();

        int n = sc.nextInt();

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

            String a = sc.next();
            String str = sc.next();
            switch(a){
                case "insert":
                    hs.add(str);
                    break;

                case "find":
                    System.out.println(hs.contains(str) ? "yes":"no");
                    break;

            }

        }



    }
}


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

int main(){
  string s;
  cin>>s;
  bool ans=1;
  int i = s.size()-1;
  for(int i = s.size()-1; i>=0; i--){
    if(s[i]=='r'){
      if(i-5>=0 && s.substr(i-5,6)=="eraser"){
        i-=5;
      }else if(i-6>=0 && s.substr(i-6,7)=="dreamer"){
        i-=6;
      }else{
        ans=0;
      }
    }else if(s[i]=='m'){
      if(i-4>=0 && s.substr(i-4,5)=="dream"){
        i-=4;
      }
    }else if(s[i]=='e'){
      if(i-4>=0 && s.substr(i-4,5)=="erase"){
        i-=4;
      }
    }else{
      ans=0;
    }
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 3712
import math
A,B= map(int,input().split())
min_x = math.ceil(max(A/0.08,B/0.10))
# min_x = max(A//0.08,B//0.10) +1
max_x = (min((A+1)/8,(B+1)/10)*100)

if max_x-min_x>0:
    ans = int(min_x)
else:
    ans = -1
print(ans)

Measured memory_bytes: 3060
'use strict';
const main = input => {
  const nums = input[0].split(' ').map(val => parseInt(val));
  let n = nums[0], k = nums[1];
  k=k>n?n:k;
  let h = input[1].split(' ').map(val => parseInt(val));
  h.sort((x, y) => y-x);
  // console.log(h);
  let arr = h.slice(k, h.length);
  if (!arr.length) return console.log(0);
  let ans = arr.reduce((prev, current) => prev + current);
  console.log(ans);
  // console.log(arr);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 48400
import sys
from collections import Counter, defaultdict
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = read().decode().rstrip()

reminders = defaultdict(lambda: 0)
tmp = 0
mul = 1

for c in S[::-1]:
    c = int(c)
    tmp = (tmp + c * mul) % 2019
    mul = mul * 10 % 2019
    reminders[tmp] += 1
reminders[0] += 1

ans = 0

for r, cnt in reminders.items():
    ans += cnt * (cnt - 1) // 2

print(ans)

Measured memory_bytes: 9520
#include<iostream>
using namespace std; // 575

int main() {
	int N;
	cin >> N;
	cout << (N <= 999 ? "ABC" : "ABD");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int a[N],n,b[N];
bool check(int x) {
  for (int i = 1 ; i <= 2 * n - 1 ; ++ i)
    b[i] = (a[i] >= x);
  if (b[n] == b[n-1] || b[n] == b[n+1])
    return b[n];
  int lp = 0, rp = 0;
  while (b[n - lp] != b[n-lp-1] && lp < n) ++ lp;
  while (b[n + rp] != b[n+rp+1] && rp < n) ++ rp;
  if (lp < n || rp < n) {
    if (lp <= rp) return b[n-lp];
    else return b[n+rp];
  }
  return b[n] ^ (n&1) ^ 1;
}
int main() {
  scanf("%d",&n);
  for (int i = 1 ; i <= 2 * n - 1 ; ++ i)
    scanf("%d",&a[i]);
  int l = 1, r = 2*n - 1, ans = 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid)) l = mid + 1, ans = mid;
    else r = mid - 1;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int a, b, y, count=1;
    while(scanf("%d%d", &a, &b)!=EOF){
        count=1, y=a+b;
        while(y/10>0)y/=10, count++;
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>
using namespace std;
char dp[(1<<24)];
int n,x[24],y[24],r[24],c[24],s[24];
int dist(int a,int b){return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]);}

int check(int a,int b){
  int ra=r[a]+r[b];
  if(dist(a,b) < ra*ra)return 1;
  else return 0;
}


int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int i,j,k,ans=0;
    for(i=0;i<n;i++)
      scanf("%d %d %d %d",&x[i],&y[i],&r[i],&c[i]);
    for(i=0;i<n;i++){
      s[i]=0;
      for(j=i-1;j>=0;j--)s[i]+=(check(i,j)<<j);
    }
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for(k=0;k<(1<<n);k++){
      if(dp[k]==-1)continue;
      if(ans<dp[k])ans=dp[k];
      for(i=0;i<n;i++){
	if((k>>i&1)||(k&s[i])!=s[i])continue;
	for(j=i+1;j<n;j++){
	  if(c[i]!=c[j]||(k>>j&1)||(k&s[j])!=s[j])continue;
	  int nk=k+(1<<i)+(1<<j);
	  if(dp[nk]<dp[k]+2)dp[nk]=dp[k]+2;
	}
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 17420
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1e9+7
typedef pair<int,int> P;
typedef pair<int,P> PP;

int ans,n;
vector<string> s;
vector<char> ntoc;
vector<int> wari,cton,usedn,mae,usi;

void dfs(int k=0){
  if(k==wari.size()){
    int sum=0;
    for(int i=0;i<k;i++){
	 sum+=mae[i]*wari[i];
    }
    if(sum==0)ans++;
    return;
  }
  for(int i=0;i<10;i++){
    if(usedn[i]||(i==0&&usi[k]))continue;
    usedn[i]=1;
    wari[k]=i;
    dfs(k+1);
    usedn[i]=0;
  }
}

signed main(){
  while(1){
    cin>>n;
    if(n==0)break;
    s=vector<string>(n);
    ans=0;
    ntoc=vector<char>();
    cton=vector<int>(30,-1);
    usedn=vector<int>(10,0);

    int used[30]={};
    for(int i=0;i<n;i++){
	 cin>>s[i];
	 for(int j=0;j<s[i].size();j++){
	   int sn=s[i][j]-'A';
	   if(used[sn])continue;
	   used[sn]=1;
	   cton[sn]=ntoc.size();
	   ntoc.pb(s[i][j]);
	 }
    }
    mae=vector<int>(ntoc.size(),0);
    usi=vector<int>(ntoc.size(),0);
    for(int i=0;i<n;i++){
	 if(s[i].size()==1){
	   if(i<n-1)mae[cton[s[i][0]-'A']]++;
	   else mae[cton[s[i][0]-'A']]--;
	   continue;
	 }
	 usi[cton[s[i][0]-'A']]=1;
	 int t=1;
	 for(int j=0;j<s[i].size();j++){
	   if(i<n-1) mae[cton[s[i][s[i].size()-1-j]-'A']]+=t;
	   else mae[cton[s[i][s[i].size()-1-j]-'A']]-=t;
	   t*=10;
	 }
    }
    wari=vector<int>(ntoc.size(),-1);
    dfs();
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3144
import Data.List
import Data.Array.IO
import Control.Monad

type Vertex = (Int, [Int])

main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  edge <- (\[x, y] -> zip x y) . transpose . map (map read . words) . lines <$> getContents :: IO [(Int, Int)]
  let v = [(i, []) | i <- [1..n]]
  print =<< foldM (solve n v edge) 0 edge

makeMark :: Int -> IO (IOUArray Int Bool)
makeMark n = newArray (1, n) False

makeGraph :: [Vertex] -> (Int, Int) -> [Vertex]
makeGraph v (i, j) = write i j $ write j i v

write :: Int -> Int -> [Vertex] -> [Vertex]
write x y v = take (x-1) v ++ [(x, y:(snd $ v !! (x-1)))] ++ drop x v

search :: [Vertex] -> IOUArray Int Bool -> Int -> IO (IOUArray Int Bool)
search [] mark i = return mark
search graph mark i = do
  let (v, neighbors) = graph !! (i - 1)
  b <- readArray mark i
  case b of
    True -> do
      return mark
    False -> do
      writeArray mark i True
      return =<< foldM (search graph) mark neighbors

solve :: Int -> [Vertex] -> [(Int, Int)] -> Int -> (Int, Int) -> IO Int
solve n v edges brigde e = do
  let graph = foldl makeGraph v $ delete e edges
  mark <- makeMark n
  search graph mark 1
  ans <- and <$> getElems mark
  return $ if ans then brigde else brigde + 1


Measured memory_bytes: 1148
from functools import reduce
INF = 10 ** 7
N, M = map(int, input().split())
L = 1 << N
table = [INF] * L
table[0] = 0
for m in range(M):
    cost, _ = map(int, input().split())
    match = reduce(lambda a, b: a | b, (1 << shamt for shamt in map(lambda n: int(n) - 1, input().split())))
    for l in range(L):
        now = table[l]
        if l and not now:
            continue
        table[l | match] = min(now + cost, table[l | match])
print(table[L - 1] if table[L - 1] != INF else -1)

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

typedef int lli;

lli get_(lli &n, lli a) {
	return (n * (2*a + (n-1) * a))/2;
}

lli get(lli &n) {
	lli n3 = n/3, n5 = n/5, n15 = n/15;
	lli sum3 = get_(n3, 3), sum5 = get_(n5, 5), sum15 = get_(n15, 15);
	return sum3 + sum5 - sum15;

}
lli hcf(lli a, lli b) {
	if (a == 0)
		return b;
	if (b == 0)
		return a;
	return hcf(b, a%b);
}

lli gcd(lli a, lli b, lli c) {
	return hcf(hcf(a, b), c);
}


int main(void) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	lli n ;
	cin>>n;
	long long int sum = 0;
	for (lli a = 1; a <= n; a++) {
		for (lli b = 1; b <= n; b++) {
			for (lli c = 1; c <= n; c++) {
				sum += gcd(a, b, c);
			}
		}
	}
	cout<<sum<<"\n";
	return 0;
}

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

INF = 2 ** 63 - 1


def solve(a, b, n):
    # a + x = k * d, b = l * g
    # 1 <= k <= n, 1 <= l <= n
    x = INF
    for l in range(1, n + 1):
        d, m = divmod(b, l)
        if not m:
            for k in range(1, n + 1):
                x = min(x, abs(k * d - a))
    return x


def main():
    a, b, n = map(int, input().split())
    print(solve(a, b, n))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7772
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int ans=987654;
		int cnt[2]={0};
		int	dp[11][11];
		int memo[11]={};
		for(int i=0;i<11;i++){
			for(int j=0;j<11;j++){
				dp[i][j]=987654;
			}
		}
		if(n==0)break;
		int a,b,c;
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			dp[a][b]=c;
			dp[b][a]=c;
			memo[a]++;
			memo[b]++;
		}
		int N=0;
		for(int i=0;i<10;i++){
			if(memo[i]>0){
				N++;
			}
		}
		for(int m=0;m<N;m++){
		for(int k=0;k<N;k++){
			for(int i=0;i<N;i++){
				for(int j=0;j<N;j++){
					dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
				}
			}
		}
		cnt[1]=0;
		for(int i=0;i<N;i++){
			cnt[1]+=dp[m][i];
		}
		cnt[1]-=dp[m][m];
		if(ans>cnt[1]){
			cnt[2]=m;
			ans=cnt[1];
		}
		}
		cout<<cnt[2]<<" "<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long int t=0;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int max=a[0];
    for(auto &i:a)
    {
        if(i>=max)
        {
            max=i;
        }
        else
        {
            t+=(max-i);
        }
        
    }
    cout<<t;
}

Measured memory_bytes: 4044
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_10-D

Math Functions - Distance II
Time Limit : 1 sec, Memory Limit : 65536 KB
??????????????????????????¢

???????????????????????????????????????????????????????????????????????¢??§??¬???????????????????????????????????°???????????????????§?????????¨????????§????????????????????????????????§??????????????? n
?¬???????????????? x={x1,x2,...,xn} ??¨ y={y1,y2,...,yn}

????????¢????¨????????????????????????????

????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\?????????????????????
Dxy=(???i=1n|xi???yi|p)1p

p=1 ?????¨???
Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

??¨?????????????????????????????????????????¢??¨?????°????????????

p=2 ?????¨???
Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2?????????????????????????????????????????????????????????????????????????????????????????????????????????

??¨???????????????????????¬?????????????????????????????????????????¢??????????????????

p=??? ?????¨???

Dxy=maxni=1(|xi???yi|)



??¨???????????????????????§????????§????????¢??¨?????°????????????

????????? n
?¬???????????????????????????????????????§???p ??????????????? 1???2???3??????

?????????????????????????????¢????±???????????????°????????????????????????????????????
Input

??????????????´??° n
???????????????????????????????????????????????? x ???????´? {x1,x2,...xn}??????????????????????????? y ???????´? {y1,y2,...yn}

????????????????????§???????????????????????\?????????????????´??°?????§??????
Output

p
??????????????? 1???2???3??????

??????????????????????????????????????¢??????????????????????????????????????????0.00001 ??\????????????????????£????????????????????¨????????????
Constraints

    1???n???100

0???xi,yi???1000

Sample Input

3
1 2 3
2 0 4

Sample Output

4.000000
2.449490
2.154435
2.000000

=end
class Dist
  def initialize(f0,f1)
    @len = f0.length
    @v0 = f0
    @v1 = f1
  end

  def dis1
    sum = 0.0
    (0..(@len-1)).each {|i| sum += (@v0[i] - @v1[i]).abs}
    sum
  end

  def dis2
    sum = 0.0
    (0..(@len-1)).each {|i| sum += (@v0[i] - @v1[i])**2}
    Math.sqrt(sum)
  end

  def dis3
    sum = 0.0
    (0..(@len-1)).each {|i| sum += (@v0[i] - @v1[i]).abs**3}
    sum**(1.0/3)
  end

  def disLarge
    l=99
    sum = 0.0
    (0..(@len-1)).each {|i| sum += (@v0[i] - @v1[i]).abs**l}
    sum**(1.0/l)
  end

  def disInf
    v2 = []
    (0..(@len-1)).each {|i| v2[i] = (@v0[i] - @v1[i]).abs}
    v2.max
  end

end

class Main
  def initialize
    fh = STDIN
    fh.gets
    n = $_.chomp.to_i
    fl0 = fh.gets.chomp.split.map{|x| x.to_f}
    fl1 = fh.gets.chomp.split.map{|x| x.to_f}
    d = Dist.new(fl0,fl1)
    puts d.dis1
    puts d.dis2
    puts d.dis3
    #      puts d.disLarge
    puts d.disInf
  end

  def stddev(f)
    n = f.length
    sum = f.inject(0.0){|acc,x| acc + x}
    ave = sum / n
    sq_sum = f.inject(0.0){|acc,x| acc + (x - ave)**2}
    Math.sqrt(sq_sum / n) 
  end
end

if $0==__FILE__ then
  Main.new()
end

Measured memory_bytes: 8856
#include<iostream>
#include<cstdio>
#define ll long long
#define maxb 20
#define maxn 200020
using namespace std;
int n,a[maxn],pow2[maxb],l,r;
bool t[maxb];
inline void get(int &x){
	char c=getchar();bool p=0;
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')p=1,c=getchar();x=c-'0',c=getchar();
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	if(p)x=-x;
}
void init(){
	l=1;get(n);pow2[0]=1;
	for(int i=1;i<maxb;++i)pow2[i]=pow2[i-1]<<1;
	for(int i=1;i<=n;++i)get(a[i]);
}
inline bool check(int x){
	for(int i=0;i<maxb;++i)
	if(t[i]&&(x&pow2[i]))return 0;
	return 1;
}
inline void del(int x){
	for(int i=0;i<maxb;++i)
	if(x&pow2[i])t[i]=0;
}
inline void insert(int x){
	for(int i=0;i<maxb;++i)
	if(x&pow2[i])t[i]=1;
}
void solve(){
	ll ans=0;
	for(int r=1;r<=n;++r){
		while(!check(a[r])){
			ans+=r-l;
			del(a[l]);
			++l;
		}
		insert(a[r]);
	}
	ans+=1ll*(n-l+2ll)*(n-l+1ll)/2ll;
	printf("%lld\n",ans);
}
int main(){
	init();
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
int main() {
    int n, x;
    for (std::cin >> n >> x; n != 0 || x != 0; std::cin >> n >> x) {
        int c = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                for (int k = j + 1; k <= n; ++k) {
                    if (i + j + k == x) {
                        ++c;
                    }
                }
            }
        }
        std::cout << c << std::endl;
    }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
bool A[105][105];
int main()
{
	memset(A,0,sizeof(A));
	int n,v,u,du;
	cin>>n;
	getchar();
	for(int i=1;i<=n;i++){
		cin>>v>>du;
		while(du--)
			cin>>u,
			A[v][u] = 1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j==1) cout<<A[i][j];
			else cout<<' '<<A[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

unsigned gcd(unsigned a, unsigned b) {
	if (a < b) gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
char tolower(char c) {
	return (c + 0x20);
}
ld num(ld a,ld b) {
	ld c = 1;
	while (b > a) {
		a *= 2;
		c*=2;
	}
	return c;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 5)cout << 0 << endl;
	else if (a <= 12)cout << b / 2 << endl;
	else cout << b << endl;
	cin >> a;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;

map<string, int> m;

string s, t, u;
int a, b;


int main()
{
	cin >> s >> t >> a >> b >> u;
	m[s] = a; m[t] = b; m[u]--;
	cout << m[s] << " " << m[t];

	return 0;
}

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

int main(){
    int N,H[25],dif,ans=0,i,j,count;
    cin>>N;
    for(i=0;i<N;i++){
        cin>>H[i];
    }
    for(i=0;i<N;i++){
        count=0;
        for(j=0;j<i;j++){
            dif=H[i]-H[j];
            if(dif<0){
                count++;
            }
        }
        if(count==0){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll a, b; int k;
	cin >> a >> b >> k;
	rep(i, k) {
		if (i % 2 == 0) {
			b += a / 2; a /= 2;
		}
		else {
			a += b / 2; b /= 2;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n,b=0,c=0,d=0;
	cin >> n;
	vec(a,n);
	REP(i,n){
		cin >> a[i];
		if(a[i]%4 == 0){
			b++;
		}
		else if(a[i]%2 == 0){
			c++;
		}
		else d++;
	}
	if(d-b == 1){
		if(c == 0){
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else if(d-b > 1) cout << "No" << endl;
	else cout << "Yes" << endl;

    return 0;
}

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

 
int main() {
	string s,t;
	cin >> s >> t;
	map<char,char> ma,ima;
	bool ok=true;
	for(int i=0;i<s.size();i++){
		char ss=s[i],tt=t[i];
		if(ma.count(ss)){
			if(ma[ss]!=tt) ok=false;
		}
		if(ima.count(tt)){
			if(ima[tt]!=ss) ok=false;
		}
		ma[ss] = tt;
		ima[tt] = ss;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+1;

int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>k || a+b>k)
    {
        cout<<k;
    }
    else if(a+b+c>k)
    {
        ll ans=0;
        ans+=a;
        ans+=-1*(k-a-b);
        cout<<ans;
    }
    else
    {
        cout<<a-c;
    }
    
    

}

Measured memory_bytes: 3584
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Ans struct {
	x, y int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	mx, mn := 0, 0
	for i := 0; i < N; i++ {
		if A[mx] < A[i] {
			mx = i
		}
		if A[i] < A[mn] {
			mn = i
		}
	}
	ans := []Ans{}
	if abs(A[mn]) <= abs(A[mx]) {
		for i := 0; i < N; i++ {
			ans = append(ans, Ans{mx, i})
		}
		for i := 0; i < N-1; i++ {
			ans = append(ans, Ans{i, i + 1})
		}
	} else {
		for i := 0; i < N; i++ {
			ans = append(ans, Ans{mn, i})
		}
		for i := N - 1; i > 0; i-- {
			ans = append(ans, Ans{i, i - 1})
		}
	}

	fmt.Fprintln(wtr, len(ans))
	for i := 0; i < len(ans); i++ {
		fmt.Fprintln(wtr, ans[i].x+1, ans[i].y+1)
	}
}


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

const int N = 100 * 1000 + 5;

set <pair <int, int> > s;
set <int> adj[N];
int h[N];
int par[N];
bool mark2[N];
void dfs(int v) {
	s.insert({-h[v], v});
	for (auto u : adj[v]) {
		if (u != par[v]) {
			par[u] = v;
			h[u] = h[v] + 1;
			dfs(u);
		}
	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].insert(v);
		adj[v].insert(u);
	}
	if (n % 2 == 1) {
		cout << "First";
	}
	else {
		dfs(1);
		while (s.size()) {
			pair <int, int> p = *s.begin();
			int v = p.second, u = par[v];
		//	cout << v << " " << u << endl;
			s.erase({-h[v], v});
			s.erase({-h[u], u});
			if (mark2[u] == true) {
				cout << "First";
				return 0;
			}
			for (auto w : adj[u]) {
				adj[w].erase(u);
			}
			adj[u].erase(v);
			mark2[v] = true;
			mark2[u] = true;
		}
		cout << "Second";
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 200'010;
const int M = 998244353;
ll fact[N];

ll binpow(ll x, ll p) {
    ll res = 1;
    while (p) {
        if (p & 1) res = res * x % M;
        x = x * x % M;
        p >>= 1;
    }
    return res;
}

ll comb(ll n, ll k) {
    ll res = fact[n] * binpow(fact[k], M - 2) % M;
    res = res * binpow(fact[n - k], M - 2) % M;
    return res;
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    fact[0] = 1;
    for (ll i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % M;
    ll ans = 0;
    for (int s = n - k - 1; s < n; s++) {
        ll add = comb(n - 1, s) * m % M;
        add = add * binpow(m - 1, s) % M;
        ans = (ans + add) % M;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5156
class Node
  attr_reader :id
  @@i = 0
  def self.clear
    @@i = 0
  end
  def initialize
    @u = nil
    @id = @@i
    @@i += 1
  end

  def ==(other)
    return find().id == other.find.id
  end
  def find()
    if @u
      return @u = @u.find()
    else
      return self
    end
  end

  def join(other)
    if @u
      @u.find.join(other)
    else
      @u = (other.find == (self)) ? nil : other.find
    end
  end
end

def main
  while (n = gets.to_i) != 0
    m = gets.to_i
    nodes = Array.new(n){Node.new}
    path = Array.new(m){gets.chomp.split(",").map(&:to_i)}.sort_by{|(a, b, c)|c}
    puts path.map{|r|
      unless nodes[r[0]] == nodes[r[1]]
        nodes[r[0]].join(nodes[r[1]])
        r[2] - 100
      else
        0
      end}.reduce(0){|a, i|a + i / 100}
    Node.clear
  end
end
main

Measured memory_bytes: 8944
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll h,w,d;
  cin >> h >> w >> d;
  UnionFind<ll>tree(h*w+1);
  
  ll a[h][w];
  map<ll,P>mp;
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
      mp[a[i][j]]=P(i+1,j+1);
    }
  }
  exrep(i,1,h*w-d){
    int y=mp[i].first,x=mp[i].second;
    int ny=mp[i+d].first,nx=mp[i+d].second;
    tree.merge(i,i+d,abs(y-ny)+abs(x-nx));
  }
  int q;
  cin >> q;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    cout << tree.diff(l,r) << endl;
  }
      
        
      
  return 0;     
}


Measured memory_bytes: 8832