akhauriyash/Code-Regression huggingface dataset:
*s, = map(str, input())

a = [""]*(len(s))
ans = 0

def rec(i:int, a:list) -> None:
    if i == len(s)-1:
        global ans
        ans += eval("".join(_s+_a for _s, _a in zip(s, a)))
        return

    a[i] = ""
    rec(i+1, a)
    a[i] = "+"
    rec(i+1, a)

rec(0, a)
print(ans)


Measured memory_bytes: 3060
N,P=map(int,input().split())
if N==1:
    print(P)
else:
    a=1
    for i in range(2,10**6+1):
        s=0
        while True:
            if P%i==0:
                P//=i
                s+=1
            else:
                if s>=N:
                    a*=i**(s//N)
                break
    print(a)

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

bool c[300001];
int main()
{
	int N, Q;
	scanf("%d %d", &N, &Q);
	
	for (int i = 0; i < N; i++){
		int a;
		scanf("%d", &a);
		c[a] = true;
	}
	
	for (int i = 0; i < Q; i++){
		int q;
		scanf("%d", &q);
		
		int res;
		int j = q - 1;
		bool f = false;
		while (!f){
			for (int k = j; k < 300000; k += q){
				if (c[k]){
					printf("%d\n", k % q);
					f = true;
					break;
				}
			}
			j--;
		}
	}
	
	return 0;
}

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

int main(){
  int N, Q;
  long K;
  cin >> N >> K >> Q;
  vector<long> A(N, K-Q);
  for(int i = 0; i < Q; i++){
    int temp;
    cin >> temp;
    A.at(temp-1)++;
  }
  for(int i = 0; i < N; i++){
    if(A.at(i) < 1) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string s, t;
    cin >> s >> t;
    vvi dp(s.size() + 1, vi(t.size() + 1, 0));
    for (int i = 1; i <= s.size(); ++i) {
        for (int j = 1; j <= t.size(); ++j) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            chmax(dp[i][j], dp[i][j - 1]);
            chmax(dp[i][j], dp[i - 1][j]);
        }
    }
    string ret = "";
    int sidx = s.size();
    int tidx = t.size();
    while (sidx > 0 && tidx > 0) {
        if (s[sidx - 1] == t[tidx - 1]) {
            ret = s[sidx - 1] + ret;
            --sidx;
            --tidx;
        } else if (dp[sidx][tidx] == dp[sidx - 1][tidx])
            --sidx;
        else
            --tidx;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

ll N; cin >> N;
ll cnt = 0;
set<ll> st; // N-1の約数(注：1を含む)
for(ll i = 1; i * i <= N-1; i++) {
    if((N-1) % i == 0) {
        st.insert(i);
        st.insert((N-1)/i);
    }
}
cnt += SZ(st) - 1;
for(ll i = 2; i * i <= N; i++) {
    if(N % i != 0) continue;
    if(i * i == N) {
        cnt++;
        continue;
    }
    ll j = N / i;
    ll cur = N;
    while(cur % i == 0) {
        cur /= i;
    }
    if(cur % i == 1) cnt++;
    cur = N;
    while(cur % j == 0) {
        cur /= j;
    }
    if(cur % j == 1) cnt++;
}
cnt++; // K = N
cout << cnt << endl;
return 0;
}

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


int main(){
	int k;
	int a,b;
	cin >> a >> b >> k;
	for(int i = a; i < min(b+1, a+k); i++)
		cout << i << "\n";
	for(int i = max(a+k, b-k+1); i <= b; i++)
		cout << i << "\n";
	
}


Measured memory_bytes: 256
read = lambda: map(int, input().split())
n = int(input())
a = list(read())
cnt = 1
f = 0
for i in range(1, n):
    if a[i] > a[i - 1] and f == -1:
        f = 0
        cnt += 1
    elif a[i] < a[i - 1] and f == 1:
        f = 0
        cnt += 1
    elif a[i] > a[i - 1]:
        f = 1
    elif a[i] < a[i - 1]:
        f = -1
print(cnt)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define Inf 1LL << 60
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

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

int N,K;

int main()
{
    cin >> N >> K;
    vl v(N);
    rep(i,N) cin >> v[i];
    SORT(v);
    ll mini = 1LL << 60;
    rep(i,N+1 - K) mini = min(mini,v[i + K - 1] - v[i]);
    cout << mini << '\n';
}


Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  N=II()

  i=1
  l=[i]
  sm=i
  while True:
    if sm==N:
      break
    elif sm>N:
      l.remove(sm-N)
      break
    else:
      i+=1
      l.append(i)
      sm+=i

  for x in l:
    print(x)

main()
# print(main())


Measured memory_bytes: 5932
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int k, a, b;
  cin >> k >> a >> b;
  
  for (int i = 1; i * k <= b; i++) {
    if (a <= k * i&& k * i <= b) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()


int N;
vector<i64> A;
int main(){
  cin >> N;
  A.resize(N);
  rep(i,0,N - 1){
    cin >> A[i];
    A[i] -= i + 1;
  }

  i64 x0 = -1e9;
  i64 x3 = 1e9;

  auto f = [&](i64 k){
    i64 sum = 0;
    rep(i,0,N - 1){
      sum += abs(A[i] - k);
    }

    return sum;
  };


  while(x3 - x0 > 10){
    i64 x1 = (x0 * 2 + x3) / 3;
    i64 x2 = (x0 + x3 * 2) / 3;
    if(f(x1) < f(x2)){
      x3 = x2;
    }
    else{
      x0 = x1;
    }
  }
  i64 ans = 1e18;
  rep(i,x0,x3){
    ans = min(ans , f(i));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,a[100001],x[100001];
long long ans;
int main() {
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=1; i<n-1; i++) { //i is jump length (a-b)
        long long cur=0;
        int l=0,r=n-1;
        while (l!=r and i<r and l<n-1 and x[r]!=i and x[l]!=i) {
            cur+=a[l]; cur+=a[r];
            x[l]=i; x[r]=i;
            l+=i; r-=i;
            ans=max(ans,cur);
        }
    }
    cout<<ans<<'\n';
}
/*
*/

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

//typedef pair<int,int> P;
//typedef pair<int, P> PP;
//typedef pair<P, int> Pi;
typedef pair<string, string> P;
map<P, int> mp;

signed main(){
	int n, f;
	scanf("%lld%lld", &n, &f);
	rep(i,n){
		int m;
		scanf("%lld", &m);
		vector<string> str;
		rep(j,m){
			string s;
			cin >> s;
			str.pb(s);
		}
		sort(all(str));
		rep(j,m)rep(k,m){
			if(j >= k)continue;
			mp[P(str[j], str[k])]++;
		}
	}
	
	vector<P> ans;
	for(map<P, int>::iterator it = mp.begin();it != mp.end();it++){
		if(it->se >= f){
			ans.pb(P(it->fi.fi, it->fi.se));
		}
	}
	printf("%lld\n", (int)ans.size());
	rep(i,ans.size()){
		cout << ans[i].fi << " " << ans[i].se << endl;
	}
	return 0;
}








Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>

int length[50];

int main()
{
    int n, k;
    std::cin >> n >> k;
    for(int i = 0; i < n; i++){
        std::cin >> length[i];
    }
    std::sort(length, length+n, std::greater<int>());
    int result = 0;
    for(int i = 0; i < k; i++){
        result += length[i];
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
//--https://kenkoooo.com/atcoder/#/table/soma62jp


#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	int N,A,B;

	cin >> N >> A >> B;

	cout << ((N*A>B) ? B : N*A ) << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int ar[] = new int[N];
		float sum = 0;
		for(int n=0;n<N;n++){
			ar[n] = sc.nextInt();
			sum += ar[n];
		}
		float ave = sum/N;
		int ans=0;
		float dif = 99999;
		for(int n=0;n<N;n++){

			float d = Math.abs(ave-ar[n]);
			
			if(d<dif){
				ans = n;
				dif = d;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int pre[5][4005];
int suf[5][4005];

map <char, int> idx;

int main()
{
	IOS
	
	int n; cin >> n;
	string s; cin >> s;
	
	idx['R'] = 0;
	idx['G'] = 1;
	idx['B'] = 2;
	
	// prefix + suffix
		pre[idx[s[0]] ][0]++;
		
		for(int i = 1; i < n; i++){
			for(int j = 0; j <= 2; j++){
				pre[j][i] = pre[j][i - 1];
			}
			pre[idx[s[i]] ][i]++;
		}
		
		suf[idx[s[n - 1]] ][n - 1]++;
		for(int i = n - 2; i >= 0; i--){
			for(int j = 0; j <= 2; j++){
				suf[j][i] = suf[j][i + 1];
			}
			suf[idx[s[i]] ][i]++;
		}
	// prefix + suffix
	
	ll total = 0;
	
	for(int j = 1; j < n - 1; j++){
		total += 1LL * pre[(idx[s[j]] + 1) % 3][j] * suf[(idx[s[j]] + 2) % 3][j];
		total += 1LL * pre[(idx[s[j]] + 2) % 3][j] * suf[(idx[s[j]] + 1) % 3][j];
		
		for(int i = 0; i < j; i++){
			if(2 * j - i < n and s[i] != s[j] and s[i] != s[2 * j - i] and s[j] != s[2 * j - i]){
				total--;
			}
		}
	}	
	cout << total << endl;
}

Measured memory_bytes: 3696
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
using namespace std;
int main(void) {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	vector<int> distances(n);//i + 1件目の家との距離
	int l;
	int p = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		distances[i] = a[i + 1] - a[i];
	}
	distances[n - 1] = k - a[n - 1] + a[0];//
	//auto it = max_element(distances.begin(), distances.end());
	int max_distance = 0;
	int max_index = -1;
	for (int i = 0; i < n; i++) {
		if (distances[i] > max_distance )
		{
			max_distance = distances[i];
			max_index = i;
		}
	}
	cout << (k - max_distance) << endl;
}

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

int main(){
  int n;
  cin >> n;
  string s[n];
  map<string,ll> mp;
  rep(i,n) {
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    mp[s[i]]++;
  }
  ll ans = 0;
  for(auto x : mp) ans += x.second * (x.second - 1) / 2;
  cout << ans << endl;
  return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s,a,b;
  cin>>s;
  a=s.substr(0,4);
  b=s.substr(4,8);
  cout<<a<<' '<<b<<endl;
}
///////////////////////////

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

struct unionfind{
    vector<int> par,rank;
    unionfind(int x){
        par.resize(x);
        rank.resize(x);
        for(int i=0; i<x; i++)par[i]=i,rank[i]=0;
    }
    int root(int x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    void uni(int x,int y){
        x=root(x),y=root(y);
        if(x==y)return;
        if(rank[x]<rank[y])par[x]=y;
        else{
            par[y]=x;
            if(rank[x]==rank[y])rank[x]++;
        }
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    unionfind uf(n);
    for(int i=0; i<m; i++){
        int x,y,z;
        cin>>x>>y>>z;
        uf.uni(x-1,y-1);
    }
    int ans=0;
    for(int i=0; i<n; i++){
        if(uf.par[i]==i)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b := getInt(), getInt()

	for i := 0; i < 2000; i++ {
		x := i * 8 / 100
		y := i * 10 / 100
		if a == x && b == y {
			out(i)
			return
		}
	}
	out(-1)
}


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

void trace(vector<long> vi) {
    for (auto v : vi) cout << v << " ";
    cout << endl;
}

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

    // a : 10^5
    // b : 10^5
    // m : 10^5
    long a, b, m;
    cin >> a >> b >> m;

    vector<long> ai(a), bi(b);
    long a_min = 1000001, b_min = 1000001;
    rep(i, a) {
        cin >> ai[i];
        a_min = min(ai[i], a_min);
    }
    rep(i, b) {
        cin >> bi[i];
        b_min = min(bi[i], b_min);
    }

    // answer
    vector<long> price{a_min + b_min};
    vector<long> x(m), y(m), c(m);
    rep(i, m) {
        cin >> x[i];
        cin >> y[i];
        cin >> c[i];
    }

    rep(i, m) {
        // printf("%ld %ld %ld\n", ai[x[i]], bi[y[i]], c[i]);
        price.push_back(ai[x[i] - 1] + bi[y[i] - 1] - c[i]);
    }

    sort(price.begin(), price.end());
    // trace(price);
    cout << price[0] << endl;
    return 0;
}

Measured memory_bytes: 5368
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<complex>

#define llong long long;
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 55

//const int INF = 1e9 + 7;


typedef complex<int> cpi;
int n;
int m[ARRAY_MAX];


int main() {


	cpi mp[55][15];
	while (cin >> n,n)
	{
		for (int i = 0; i <= n; i++) {
			cin >> m[i];
			for (int j = 0; j < m[i]; j++) {
				int a, b;
				cin >> a >> b;
				mp[i][j] = cpi(a, b);
			}
		}

		//入力終了
		
		for (int i = 1; i <= n; i++) {

			if (m[0] != m[i]) {
				//座標の数が違う
				continue;
			}

			for (int tm = 0; tm < 4; tm++) {
				bool flag = true;
				//4回回転させる
				for (int j = 0; j < m[0]; j++) {
					mp[0][j] *= cpi(0, 1);//元の折れ線を回転させる
				}

				//そのまま比較
				for (int index = 1; index < m[0]; index++)
				{
					flag &= (((mp[i][index].real() - mp[i][index - 1].real()) == (mp[0][index].real() - mp[0][index - 1].real()))
						&& ((mp[i][index].imag() - mp[i][index - 1].imag()) == (mp[0][index].imag() - mp[0][index - 1].imag())));
				}

				if (flag == true) {
					cout << i << endl;
					break;
				}
				//逆順比較
				flag = true;
				for (int index = 1; index < m[0]; index++)
				{
					flag &= (((mp[i][index].real() - mp[i][index - 1].real()) == (mp[0][m[0] - 1 - index].real() - mp[0][m[0] - index].real()))
						&& ((mp[i][m[0] - 1 - index].imag() - mp[i][m[0] - index].imag()) == (mp[0][index].imag() - mp[0][index - 1].imag())));

				}

				if (flag == true) {
					cout << i << endl;
					break;
				}
			}
		}
		cout << "+++++" << endl;
	}

	return 0;
}


Measured memory_bytes: 3056
r=int(input())
data=(1200,2800)
name=('ABC', 'ARC', 'AGC')

[print(name[0]) for i in range(1) if r < 1200]
[print(name[1]) for i in range(1) if 1200 <= r < 2800 ]
[print(name[2]) for i in range(1) if 2800 <=r ]



Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n>>m;
 cout<<(n*3+m)/2;
  
//  cout<<c<<" ";
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
// C - Otoshidama
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N,Y; cin>>N>>Y;
	Y /= 1000;
	rpz(x, N+1){
		rpz(y, N-x+1){
			int z = N - x - y;
			if(x*10 + y*5 + z != Y) continue;
			printf("%d %d %d\n", x, y, z);
			return 0;
		}
	}
	puts("-1 -1 -1");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int N; cin>>N;
    vector<int> x(N),y(N);
    for(int i=0;i<N;i++) cin>>x[i]>>y[i];

    vector<int> p(N);
    for(int i=0;i<N;i++) p[i]=i;

    auto calc=[&]()
    {
        double res=0.0;
        for(int i=0;i<N-1;i++){
            double dx=x[p[i+1]]-x[p[i]];
            double dy=y[p[i+1]]-y[p[i]];
            res+=sqrt(dx*dx+dy*dy);
        }
        return res;
    };

    double ans=0.0;
    do{
        ans+=calc();
    }while(next_permutation(p.begin(),p.end()));

    for(int i=1;i<=N;i++) ans/=i;
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
int main()
{
	int A,B,C;cin>>A>>B>>C;
	if(A!=B||A!=C||B!=C) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

ll k;

ll gcd(ll p, ll q){
	while(q!=0){
		ll r = p%q;
		p = q;
		q = r;
	}
	return p;
}

int main(){
	cin >> k;
	ll ans = 0;
	FOR(i,1,k) FOR(j,1,k) FOR(l,1,k) ans += gcd(gcd(i,j),l);
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int n;
	int table[11][11];
	int i, j;
	int row[11];
	int col[11];
	int sum;
	
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		for (i = 0; i < 11; i++) {
			row[i] = col[i] = 0;
		}
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				scanf("%d", &table[i][j]);
				row[i] += table[i][j];
				col[j] += table[i][j];
			}
		}
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				printf("%5d", table[i][j]);
			}
			printf("%5d\n", row[i]);
		}
		sum = 0;
		for (i = 0; i < n; i++) {
			printf("%5d", col[i]);
			sum += col[i];
		}
		printf("%5d\n", sum);
	}
	return (0);
}

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

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> height(N);
  
  for (int i=0; i<N; i++) {
    cin >> height.at(i);
  }
  
  vector<int> admit(0);
  
  for (int i=0; i<N; i++) {
    if (height.at(i) >= K) {
      admit.push_back(i);
    }  
  }
  
  cout << admit.size() << endl;
}

Measured memory_bytes: 1148
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	long long int n,ans;
	string s;
	cin >> n;
	cin >> s;
	long long int dp[5003][5003] = {};
	int i,j;
	dp[0][0] = 1;
	for (i = 0; i < n; i++){
		for (j = 0; j < i+2; j++){
			if (j == 0){
				dp[i + 1][0] = (dp[i][0] + dp[i][1])%MOD;
			}
			else{
				dp[i + 1][j] = (dp[i][j - 1] * 2 + dp[i][j + 1])%MOD;
			}
		}
	}
	ans = dp[n][s.length()];
	for (i = 0; i < (int)s.length(); i++){
		ans = ans * 500000004 % MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 195968
// B - Comparison
#include <bits/stdc++.h>
using namespace std;
#define ote(x) cout<<(x)<<endl

int main(){
	double A,B; cin>>A>>B;
	if(A>B) ote("GREATER");
	else if(A<B) ote("LESS");
	else ote("EQUAL");
}

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

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;

int a[10];
stack<int> st[2];

bool dfs(int x) {
    if (x == 10) return true;
    int i;
    bool ret = false;
    REP (i,2) if (st[i].empty() || st[i].top() < a[x]) {
        st[i].push(a[x]);
        ret |= dfs(x+1);
        st[i].pop();
    }
    return ret;
}

int main(void) {
    int i, n;
    cin >> n;
    while (n--) {
        REP (i,10) cin >> a[i];
        if (dfs(0))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

int main(){

  string s;
  cin >> s;
  if(s.size()%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  bool flg =true;
  for(int i=0; i<s.size()/2; i++){
    int k = 2*i;
    if(s.at(k) != 'h' || s.at(k+1) != 'i'){
      flg = false;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  uint64_t n, k;
  cin >> n >> k;
  uint64_t a = n % k;
  if (-(a - k) < a) {
    cout << -(a - k) << endl;
  } else {
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def ceil(x,y):
    return x//y+(not( not x%y))
n=int(input())
a,b=1,1
for i in range(n):
    t,s = map(int,input().split())
    i = max( ceil(a,t), ceil(b,s) )
    a=t*i;b=s*i
print(a+b)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const int INF = 100000000;
int main(void){
    int h, w;
    int d[105][105];
    cin >> h >> w;
    for (int i = 0; i < 10; i++){
        for (int j = 0; j < 10; j++){
            cin >> d[i][j];
        }
    }

    for (int k = 0; k < 10; k++){
        for (int i = 0; i < 10; i++){
            for (int j = 0; j < 10; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < w; i++){
        for (int j = 0; j < h; j++){
            int s;
            cin >> s;
            if (s == -1) continue;
            ans += d[s][1];
        }
    }

    cout << ans << endl;



}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int dp[50][410][410];

int main(){
    int n, ma, mb; cin>>n>>ma>>mb;
    vector<int> a(410, 0), b(410, 0), c(410, 0);
    for(int i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i];

    for(int i=0; i<=40; i++){
        for(int ca=0; ca<=400; ca++){
            for(int cb=0; cb<=400; cb++){
                dp[i][ca][cb]=1e9;
            }
        }
    }
    
    dp[0][0][0]=0;
    for(int i=0; i<n; i++){
        for(int ca=0; ca<=400; ca++){
            for(int cb=0; cb<=400; cb++){
                //if(dp[i][ca][cb] == 1e9) continue;
                dp[i+1][ca][cb]=min(dp[i+1][ca][cb], dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i]);
            }
        }
    }

    int ans=1e9;
    for(int ca=1; ca<=400; ca++){
        for(int cb=1; cb<=400; cb++){
            if(ca*mb == cb*ma){
                ans=min(ans, dp[n][ca][cb]);
            }
        }
    }

    if(ans != 1e9) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 28928
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  string s;
  cin>>s;bool f1=true,f2=false;
  if(c<d){
    for(int i=a-1;i<c-2;i++){
      if(s[i+1]=='#'&&s[i+2]=='#'){
        f1=false;break;
      }
    }
    for(int i=b-1;i<d-2;i++){
      if(s[i+1]=='#'&&s[i+2]=='#'){
        f1=false;break;
      }
    }
    cout<<(f1?"Yes":"No")<<endl;
  }else{
    for(int i=b-2;i<d-1;i++){
      if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
        f2=true;break;
      }
    }
    for(int i=a-1;i<c-2;i++){
      if(s[i+1]=='#'&&s[i+2]=='#'){
        f1=false;break;
      }
    }
    cout<<((f1&&f2)?"Yes":"No")<<endl;
  }
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
import itertools
n,k=map(int,input().split())
X,Y,XY=[0]*n,[0]*n,[0]*n
for i in range(n):
  x,y=map(int,input().split())
  X[i],Y[i],XY[i]=x,y,[x,y]
X.sort()
Y.sort()
def count(x1,x2,y1,y2):
  ct=0
  for x,y in XY:
    if x1<=x<=x2 and y1<=y<=y2:
      ct+=1
  return ct
ans=float("inf")
for x1,x2 in itertools.combinations(X,2):
  for y1,y2 in itertools.combinations(Y,2):
    if count(x1,x2,y1,y2)==k:
      ans=min(ans,abs((x1-x2)*(y1-y2)))
print(ans)

Measured memory_bytes: 50652
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int s = 0, t = n;
	
	while (t > 0) {
		s += t % 10;
		t /= 10;
	}
	if (n%s == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX(a, b) (a >= b)? a: b;
#define MIN(a, b) (a <= b)? a: b;

int main(void)
{
    int i;

    int data_num;
    scanf("%d", &data_num);

    long rate_min, rate_tmp;
    scanf("%ld %ld", &rate_min, &rate_tmp);
    long range_max = rate_tmp - rate_min;
    rate_min = MIN(rate_min, rate_tmp);

    long range_tmp;
    for (i = 2; i < data_num; i++) {
        scanf("%ld", &rate_tmp);
        range_tmp = rate_tmp - rate_min;
        rate_min = MIN(rate_min, rate_tmp);
        range_max = MAX(range_max, range_tmp);
    }

    printf("%ld\n", range_max);

    return 0;
}

Measured memory_bytes: 596
#pragma warning(disable:4996)
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
const int maxn = 50;
long long a[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
	}
	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			ans += a[i] * a[j];
		}
	}
	printf("%lld\n", ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int X;
  cin >> X;
  if(X<100){
    cout << 0 << endl;
    return 0;
  }
  int new_X=X%100;
  int N_PC=new_X/5;
  new_X=new_X%5;
  int temp_X=105*N_PC+100+new_X;
  if(new_X==0) temp_X=105*N_PC;
  if(X<temp_X) cout << 0 << endl;
  else cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 3544
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std {
    bool operator<(const Point &lhs, const Point &rhs) {
        if (lhs.real() < rhs.real() - eps) return true;
        if (lhs.real() > rhs.real() + eps) return false;
        return lhs.imag() < rhs.imag();
    }
}
Point input_point() {ld x, y; cin >> x >> y; return Point(x, y);} // ????????\???
bool eq(ld a, ld b) {return (abs(a - b) < eps);} // ????????????????????????
ld dot(Point a, Point b) {return real(conj(a) * b);} // ??????
ld cross(Point a, Point b) {return imag(conj(a) * b);} // ??????

ll W,H,A,B,S;
ld ra,rb;
ld check(ld theta){
    ld res = 0.0;
    
    ld x = ra * cos(theta/2), y = ra*sin(theta/2);
    
    ld x2 = sqrt(rb*rb - y*y);
    ld ox = x2 + x;
    
    ld theta2 = 2 * asin(y/rb);
    
    ld SAB = 0.5 * ra * ra * sin(theta) + 0.5 * rb * rb * sin(theta2);
    
    ld S1 = pi * ra * ra * theta / (2*pi);
    ld S2 = pi * rb * rb * theta2 / (2*pi);
    
    res = S1 + S2 - SAB;
    return res;
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    while(cin >> W >> H >> A >> B >> S, W|H|A|B|S){
        bool f = false;
        if(A > B) {
            swap(A,B);
            f = true;
        }
        ra = sqrt(A/pi);
        rb = sqrt(B/pi);
        ld l = 0, r = 2*pi;
        for(int i = 0; i < 300; i++){
            ld m = (l + r)/2.0;
            ld area = check(m);
            if(area > S){
                r = m;
            }else{
                l = m;
            }
        }
        ld theta = r;
        
        ld XA,YA,XB,YB;
        
        XB = rb + 0.0001; YB = rb + 0.0001;
        
        if(XB + rb > (ld)W + 0.0001 || (YB + rb) > (ld)H + 0.0001){
            cout << "impossible" <<endl;
            continue;
        }
        
        ld x = ra * cos(theta/2), y = ra*sin(theta/2);
        ld x2 = sqrt(rb*rb - y*y);
        ld ox = x2 + x;
        
        bool f2 = false;
        for(ld T = 0.0; T < pi + eps; T += 0.0001){
            ld X = XB + ox * cos(T);
            ld Y = YB + ox *sin(T);
            if(((X + ra) < (ld)W + 0.0001) && ((X - ra) > -0.0001)){
                if(((Y + ra) < (ld)H + 0.0001) && ((Y - ra) > -0.0001)){
                    XA = X; YA = Y;
                    f2 = true;
                    break;
                }
            }
        }
        if(!f2){
            cout << "impossible" << endl;
            continue;
        }
        if(f){
            swap(XA,XB);
            swap(YA,YB);
            swap(ra,rb);
        }
        cout << fixed << setprecision(10) << XA << " " << YA << " " << ra << " " << XB << " " << YB << " " << rb << endl;
    }
    return 0;
}

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

int N;

void rec(vector<char> S, int keta, int mx){
  if (keta == N){
    for(auto& c: S){
      printf("%c", c + 'a');
    }
    cout << endl;
    return;
  }
    
  for(int i = 0; i < mx + 2; i++){
    S[keta] = i;
    rec(S, keta+1, max(i, mx));
  }
}

int main(){
  cin >> N;
  vector<char> S(N, 0);
  
  rec(S, 1, 0);
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<29)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

#define MAX_N 101

int G[MAX_N][MAX_N];

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  rep(i, n) {
    int u, k;
    cin >> u >> k;
    rep(j, k) {
      int node_num; cin >> node_num;
      G[u][node_num] = 1;
    }
  }
  REP(i, 1, n + 1) {
    REP(j, 1, n + 1) {
      if (j != 1) cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }
  return 0; 
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

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

  while(K--){
    if(A>=B)B *= 2;
    else if(B>=C)C *= 2;
  }

  cout<<( (A<B && B<C) ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
char S[105];
int N;
string s = "keyence";
int main(){
    scanf("%s", S);
    N = strlen(S);
    string t;
    for(int i = 0; i < N; i++){
        t.push_back(S[i]);
    }
    if(t == s){
        puts("YES");
        return 0;
    }
    for(int l = 0; l < N; l++){
        for(int r = l; r < N; r++){
            string ns;
            for(int i = 0; i < N; i++){
                if(l <= i && i <= r)  continue;
                ns.push_back(S[i]);
            }
            if(ns == s){
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    vector<int> a(N);
    string ans = "Yes";

    int odd = 0, even2 = 0, even4 = 0;

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if ( a % 4 == 0 ) {
            even4++;
        } else if ( a % 2 == 1 ) {
            odd++;
        } else {
            even2 = 1;
        }
    }

    if ( odd + even2 > even4 + 1 ) {
        ans = "No";
    }

    cout << ans << "\n";
    return 0;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;

  int Num = 1;
  int X = 0;
  for (X = 0; Num < B; X++) {
    Num = (Num - 1) + A;
  }
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;

int main(void){
	cin >> str;
	int res=0;
	int now=0;
	for(int i=0;i<str.size();i++){
		int mok=str[i]-'A';
		if(now==mok)res++;
		else{
			while(mok!=now){
				now=(now+1)%26;
				if(now==0)res++;
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
vector<ll> num;
int main() {
  ll a,b,k;
  cin>>a>>b>>k;
  for(int i=a;i<a+k;i++){
    num.push_back(i);
    if(i==b)break;
  }
  for(int i=b-k+1;i<=b;i++){
    if(i<a)continue;
    num.push_back(i);
  }
  sort(num.begin(),num.end());
  num.erase(unique(num.begin(),num.end()),num.end());
  for(int i=0;i<num.size();i++)cout<<num[i]<<endl;
  return 0;
}


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

int main() {
  int A,B,C,X;
  cin >>A>>B>>C>>X;
  int ans=0;
  for(int i =0;i<A+1;i++){
    for(int j =0;j<B+1;j++){
      for(int k =0;k<C+1;k++){
        if((i*500+j*100+k*50)==X){
          ans+=1;
        }
      }
    }
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()

b = S.count('#')
w = S.count('.')
black = [0]*int(3e5)
white = [0]*int(3e5)

cnt = 0

for i in range(N):
    check = True

    if S[i] == '#':
        if not black[cnt]:
            cnt += 1
        black[cnt] += 1
    else:
        if not white[cnt]:
            cnt += 1
        white[cnt] += 1

black2 = [0]*int(3e5)
white2 = [0]*int(3e5)

wa = 0
for i in range(int(3e5)):
    wa += black[i]
    black2[i] = wa

wa = 0
for i in range(int(3e5)):
    wa += white[i]
    white2[i] = wa

ans = int(3e5)
for i in range(N+1):
    check = black2[i] + w - white2[i]
    ans = min(check, ans)

print(ans)

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

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

  int ans=max({a,b,c});
  int sum=a+b+c-ans;

  for (int i = 0; i < k; i++)
  {
    ans*=2;
  }
  ans+=sum;

  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> xs(n);
  for(Int i=0;i<n;i++) cin>>xs[i],xs[i]--;

  using P = pair<Int, Int>;
  priority_queue<P, vector<P>, greater<P> > pq;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<i;j++)
      pq.emplace(xs[i],i);

  vector<Int> rev(n*n,-1);
  for(Int i=0;i<n;i++) rev[xs[i]]=i;

  vector<Int> cnt(n,0),ans(n*n,-1);
  for(Int i=0;i<n*n;i++){
    if(~rev[i]){
      Int k=rev[i];
      if(cnt[k]!=k) drop("No");
      ans[i]=k;
      for(Int j=k+1;j<n;j++) pq.emplace(n*n,k);
      continue;
    }
    if(pq.empty()) drop("No");
    Int k=pq.top().second;pq.pop();
    ans[i]=k;
    cnt[k]++;
  }

  cout<<"Yes"<<endl;
  for(Int i=0;i<n*n;i++){
    if(i) cout<<" ";
    cout<<ans[i]+1;
  }
  cout<<endl;
  return 0;
}


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


constexpr int SIZE=8;
string symbol="01+-*()=";

using Flag=bitset<SIZE>;
using Er=runtime_error;

using ll=long long;
ll E(int &p,string &exp);
ll N(int &p,string &exp){
    char dig=exp[p++];
    if(dig=='0') return 0;
    ll res=1;
    while(p<exp.size() && isdigit(exp[p])){
        res*=2;
        res+=(exp[p++]-'0');
    }
    return res;
}
ll F(int &p,string &exp){
    if(p>=exp.size()) throw Er("F_iter");
    if(isdigit(exp[p])){
        return N(p,exp);
    }
    if(exp[p]=='-'){
        p++;
        return -(F(p,exp));
    }
    if(exp[p]=='('){
        p++;
        ll res=E(p,exp);
        if(p>=exp.size() || exp[p]!=')') throw Er("F_par");
        p++;
        return res;
    }
    throw Er("F_no "+to_string(p));    

}
ll T(int &p,string &exp){
    ll res=F(p,exp);
    while(p<exp.size() && exp[p]!='=' && exp[p]!='+' && exp[p]!='-' && exp[p]!=')'){
        char op=exp[p++];
        if(op!='*') throw Er("T "+to_string(p));
        ll rhs=F(p,exp);
        res*=rhs;
    }
    return res;
}
ll E(int &p,string &exp){
    ll res=T(p,exp);
    while(p<exp.size() && exp[p]!='=' && exp[p]!=')'){
        char op=exp[p++];
        if(op!='+' && op!='-') throw Er("E");
        ll rhs=T(p,exp);
        if(op=='+') res+=rhs;
        else res-=rhs;
    }
    return res;
}
bool Q(int &p,string& exp){
    try{
        ll lhs=E(p,exp);
        if(p>=exp.size() || exp[p]!='=') return false;
        p++;
        ll rhs=E(p,exp);
        if(p!=exp.size()) return false;
        else{
            return lhs==rhs;
        }
    }
    catch(std::runtime_error re){
        // cerr<<re.what()<<endl;
        return false;
    }
}
int judge(string exp){
    int p=0;
    return Q(p,exp);
}
int dfs(int p,string str,map<char,char> mp,Flag used){
    if(p==str.size()){
        return judge(str);
    }
    if(find(symbol.begin(),symbol.end(),str[p])!=symbol.end()){
        return dfs(p+1,str,mp,used);
    }
    if(mp.count(str[p])){
        str[p]=mp[str[p]];
        return dfs(p+1,str,mp,used);
    }    
    int res=0;
    char org=str[p];
    for(int i=0;i<SIZE;i++){
        if(!used[i]){
            used[i]=true;
            mp[str[p]]=symbol[i];
            str[p]=symbol[i];
            res+=dfs(p+1,str,mp,used);
            str[p]=org;
            mp.erase(org);
            used[i]=false;
        }
    }
    return res;
}
int solve(string str){
    map<char,char> mp;
    return dfs(0,str,mp,Flag());
}
int main(){
    string str;
    cin>>str;
    cout<<solve(str)<<endl;    
    return 0;
}


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

const int maxn=305;
const int mod=998244353;
int n,ans;
char s[maxn];
bool f[maxn][maxn][maxn];
int g[maxn][maxn][maxn],suf[maxn];

void Add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

int main(){
	scanf("%s",s);n=strlen(s);
	f[0][0][0]=true;
	for(int i=0;i<n;i++)for(int j=n;j>=0;j--)for(int k=n;k>=0;k--)if(f[i][j][k]){
		if(i+1<n){
			if(s[i]=='0'||s[i+1]=='0')f[i+2][j+1][k]=true;
			if(s[i]=='1'||s[i+1]=='1')f[i+2][j][k+1]=true;
		}
		if(j+k>=2){
			if(j)f[i][j-1][k]=true;
			if(k)f[i][j][k-1]=true;
		}
		if(j+k>=1){
			f[i+1][j][k]=true;
			if(s[i]=='0'&&k)f[i+1][j+1][k-1]=true;
			if(s[i]=='1'&&j)f[i+1][j-1][k+1]=true;
		}
	}
	g[0][0][n]=1;
	for(int j=0;j<=n;j++)for(int k=0;k<=n;k++)for(int i=n;i>=0;i--)if(g[j][k][i]){
		Add(g[j+1][k][i-(i>0&&s[i-1]=='0')],g[j][k][i]);
		Add(g[j][k+1][i-(i>0&&s[i-1]=='1')],g[j][k][i]);
	}
	suf[n]=0;
	for(int i=n-1;i>=0;i--)suf[i]=suf[i+1]+(s[i]=='1');
	for(int j=0;j<=n;j++)for(int k=0;k<=n;k++){
		for(int i=0;i<=n;i++){
			int cj=j-(n-i-suf[i]),ck=k-suf[i];
			if(cj>=0&&ck>=0&&(f[i][cj][ck]||(i<n&&f[i][cj+1][ck])||(i<n&&f[i][cj][ck+1])||(i==1&&i<n&&cj==0&&ck==0)))
				Add(ans,g[j][k][i]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 121172