akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, M; cin >> N >> M;
    pair<int,int>P[N];
    rep(i, N) {
    	int A,B;
        cin >> A >> B;
        P[i].first=A;
        P[i].second=B;
    }
    long long ans = 0;
    sort(P,P+N,greater<pair<int,int>>());
    int j=N-1;
    rep(i, M) {
        if (P[j].second == 0)j--;
        ans += P[j].first;
        P[j].second--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4356
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {
    int n; cin >> n;
    vector<ll> a(n),c(n,0);
    ll ans1 = 0, ans2 = 0;

    rep(i,n) cin >> a[i];
    rep(i,n-1){
        if(i%2 == 0){
            c[i] ++;
            c[i+1] --;
        }else{
            c[i] --;
            c[i+1] ++;
        }
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());

    rep(i,n) ans1 += a[i]*c[i];

    rep(i,n) c[i] = 0;

    rep(i,n-1){
        if(i%2 == 0){
            c[i] --;
            c[i+1] ++;
        }else{
            c[i] ++;
            c[i+1] --;
        }
    }

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

    rep(i,n) ans2 += a[i]*c[i];

    cout << max(ans1,ans2);
}


Measured memory_bytes: 4848
N = int(input())
S = input()
str_dict = {}

for s in S:
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] = str_dict[s] + 1

single_char = {k: v for k, v in str_dict.items() if v == 1}
multiple_char = {k: v for k, v in str_dict.items() if v != 1}
single_char_num = len(single_char)

base_permutation = 2 ** single_char_num % (10 ** 9 + 7)

all_permutation = base_permutation
for v in multiple_char.values():
    all_permutation = all_permutation * (v + 1)
all_permutation = all_permutation - 1

print(all_permutation % (10 ** 9 + 7))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
#define INF 1e+9
using namespace std;

signed main(){
	int n,a[100001] = {},ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = 0;i < n;i++){
		ans += a[i] / 2;
		if(a[i] % 2 && a[i + 1]){
			a[i + 1]--;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(a>b) swap(a,b);
	if(b<=a+w) puts("0");
	else printf("%d\n",b-a-w);
	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> h(N);
    REP(i,N) cin >> h[i];
    vector<ll> dp(N+10, LINF);
    dp[0] = 0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<min(N,i+3);j++){
            chmin(dp[j], dp[i] + abs(h[j] - h[i]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i, s, t) for(ll i = (ll)(s - 1); (ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max() / 4;
constexpr ll n_max = 2e5 + 10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {
    return '"' + s + '"';
}
string to_string(const char *c) {
    return to_string((string)c);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll p;
    cin >> p;
    vector<ll> a(p);
    for(int i = 0; i < p; i++) cin >> a[i];
    vector<ll> ans(p);
    ans[0] = a[0];
    ll inv = modinv(p - 1, p);
    debug(inv);
    rep(i, 0, p) {
        a[i] -= ans[0];
        if(a[i] < 0)a[i] += p;
    }
    debug(a);
    rep(i, 1, p){
        ll sum = 0;
        rep(i,0,p){
            sum += a[i];
            sum %= p;
            a[i] *= i;
            a[i] %= p;
        }
        debug(sum);
        ans[p-i] = sum * inv % p;
    }
    print(ans);
}

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

int f(int x ,int y , int z);

signed main()
{
    int n , ans[10001] = {};
    
    cin >> n;
    
    for(int x=1 ;x<=10000 ;x++ ){
        for(int y=1 ;y<=10000 ;y++ ){
            if(x*x + y*y + x*y + y + x > 10000){
                goto YEND;
            } else {
                for(int z=1 ;z<=10000 ;z++ ){
                    if( f(x,y,z) <= 10000){
                        ans [ f(x,y,z) ]++;
                    } else {
                        goto ZEND;
                    }
                }
            }
            ZEND: ;
        }
        YEND: ;
    }
    
    for(int i=1 ;i<=n ;i++ ){
        cout << ans[i] << endl;
    }
    
    return (0);
}

int f(int x , int y , int z)
{
    return ( x*x + y*y + z*z + x*y + x*z + y*z);
}

Measured memory_bytes: 3584
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]
H_t = [T - 0.006 * h for h in H]
min_dif = abs(H_t[0] - A)
ans = 0
for i in range(1, len(H_t)):
    if abs(H_t[i] - A) < min_dif:
        min_dif = abs(H_t[i] - A)
        ans = i
print(ans + 1)


Measured memory_bytes: 3064
from bisect import bisect_left, bisect_right
a,b = map(int,input().split())
l_1=range(10,100)
l_2=range(0,10)
l=[]
for i in l_1:
    for j in l_2:
        tmp=int(str(i)+str(j)+str(i)[::-1])
        l.append(tmp)
print(bisect_right(l,b)-bisect_left(l,a))

Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;



int main(){
    ll n;
    cin >>  n;
    ll res = 0;
    if(n % 2 == 0){
        n /= 2;
        while(n != 0){
            res += n / 5;
            n /= 5;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
vector<ll> v[100001];
ll vis[100001]={0};
ll val[100001]={0};
void dfs(ll node)
{
	vis[node]=1;
	for(ll i=0;i<v[node].size();i++)
	{
		if(vis[v[node][i]]==0)
		{
			dfs(v[node][i]);
			val[node]^=(val[v[node][i]]+1);
		}
	}
	return;
}
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n-1;i++)
	{
		ll x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1);
	if(val[1]!=0)
	cout<<"Alice"<<endl;
	else
	cout<<"Bob"<<endl;
}

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

int main() {
    long long n,p;
    cin >> n >> p;
    long long a[n];
    int b=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]%2==1) b=1;
    }
    long long k[n+1];
    k[0]=1;
    for(int i=1;i<=n;i++){
        k[i]=k[i-1]*2;
    }
    if(b==0&&p==0){
        cout << k[n] << endl;
    }
    else if(b==0&&p==1){
        cout << 0 << endl;
    }
    else{
        cout << k[n-1] << endl;
    }
}

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

using namespace std;

int main() {

  int n, m, ans = 0, a;
  cin >> n >> m;
  for(int i = 1;i <= m;i++){
    cin >> a;
    ans += a;
  }
  if(n < ans){
    cout << -1;
  }else{cout << n - ans;}
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdlib>
using namespace std;
int main(void){
    int w[100] = {0};
    int n;
    int sum=0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
        sum += w[i];
    }
    
    int min = 100000;
    int a = 0;
    int b;
    for (int i = 0; i < n; i++)
    {
        a += w[i];
        b = 2 * a - sum;
        if (abs(b) < min) min = abs(b);
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define high 1000000000

typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<vector<int>>v(10,vector<int>(10));
    for (int i = 1; i <= n; i++){
        int x = i;
        while(x >= 10) x/=10;
        ++v.at(x).at(i%10);
    }
    int ans = 0;
    for (int i = 1; i < 10; i++){
        for (int j = 1; j < 10; j++){
            if (j < i) continue;
            int x = v.at(i).at(j) * v.at(j).at(i);
            if (i != j) x*=2;
            ans += x;
        }
    }
    cout << ans << "\n";
}

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

const int N_MAX = 110;
const int W_MAX = 110000;

long long dp[N_MAX][W_MAX];

int main(){
  int n, w;
  cin >> n >> w;
  long long weight[N_MAX], value[N_MAX];
  for(int i = 0; i < n; ++i)cin >> weight[i] >> value[i];

  // initial condition
  for(int i = 0; i <= w; ++i)dp[0][i] = 0;

  for(int i = 0; i < n; ++i){
    for(int j = 1; j <= w; ++j){
      if(j >= weight[i])dp[i + 1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i]);
      else dp[i + 1][j] = dp[i][j];
    }
  }

  cout << dp[n][w] << endl;
}


Measured memory_bytes: 88192
N, D  = map(int, input().split())

grid = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    grid.append(array)

n = 0

for i in range(N):
    if (grid[i][0]**2 + grid[i][1]**2)**0.5 <= D:
        n = n+1

print(n)


Measured memory_bytes: 45712
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    aa=[int(input())-1 for _ in range(n)]
    b=0
    fin=set()
    ans=0
    for _ in range(n):
        if b in fin:
            print(-1)
            exit()
        if b==1:break
        fin.add(b)
        b=aa[b]
        ans+=1
    print(ans)

main()

Measured memory_bytes: 13220
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 1; i <= 30; i++)
			list.add(i);
		for (int i = 0; i < 28; i++)
			list.remove(Integer.valueOf(scanner.next()));
		for (int ans : list)
			System.out.println(ans);
	}
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string sa ,sb , sc ;
  queue<char> A , B , C ;
  cin >> sa >> sb >> sc ;
  
  rep(i,sa.size()) A.push(sa.at(i));
  rep(i,sb.size()) B.push(sb.at(i));
  rep(i,sc.size()) C.push(sc.at(i));
  
  char now = A.front();
  A.pop();
  
  string ans = "No";
  while(ans == "No"){
    if(now == 'a'){
      if(A.empty()) ans = 'A';
      now = A.front();
      A.pop();
    }
    else if (now == 'b'){
      if(B.empty()) ans = 'B';
      now = B.front();
      B.pop();
    }
    else if(now == 'c'){
      if(C.empty()) ans = 'C';
      now = C.front();
      C.pop();
    }
   
  }
    
    
    cout << ans <<endl;
   


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=155;
int dp[N][N][N],mod,DP[N];
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
ll solve1(int n,int k){
	DP[0]=1; 
	
	For(i,1,n+1){
		DP[i]=0;
		For(j,0,i-1)if(i-j-1<=k)DP[i]=(DP[i]+DP[j])%mod;
	}
	//cout<<ans<<" "<<DP[1]<<" "<<DP[2]<<" "<<DP[3]<<" "<<DP[4]<<endl;
	return DP[n+1];
}
int solve2(int n,int k){
	dp[1][0][0]=1;
	for(int i=1;i*2-k<=n;i++){//cout<<n<<" "<<k<<" "<<i<<endl;
		For(j,0,k+1){
			For(l,0,k)if(dp[i][j][l]){//cout<<dp[i][j][l]<<endl;
				add(dp[i+1][0][0],dp[i][j][l]);
				if(2*i-k>=1){
					add(dp[i+1][j?j+1:0][0],dp[i][j][l]);
				}
				if(2*i<=n){
					add(dp[i+1][0][min(l+1,k)],dp[i][j][l]);
				}
				if(2*i-k>=1&&2*i<=n)add(dp[i+1][max(j+1,2+l)][min(l+1,k)],dp[i][j][l]);
			}
		}
	}
	int ans=0;
	For(i,0,k+1)For(j,0,k)ans=(ans+dp[(n+k)/2+1][i][j])%mod;
	return ans;
}
int main(){
	int n=read(),k=read(); mod=read();
	if(k%2==0){
		cout<<solve1(n/2,k/2)*solve1(n-n/2,k/2)%mod<<endl;
	}else{
		cout<<solve2(n,k)<<endl;
	}
}

Measured memory_bytes: 12672
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
	LL A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;

	if (A > B) {
		LL A2 = A - V * T;
		LL B2 = B - W * T;
		if (A2 <= B2) {
			col("YES");
			return 0;
		}
	}
	else {
		LL A2 = A + V * T;
		LL B2 = B + W * T;
		if (A2 >= B2) {
			col("YES");
			return 0;
		}
	}

	col("NO");
	return 0;
}


Measured memory_bytes: 3636
import std.stdio;
import std.string;
import std.conv;
import std.algorithm.searching;

void main(){
	auto str = readln.chomp;
	if(str[2] == str[3] && str[4] == str[5])
	{
		"Yes".writeln;
	}
	else
	{
		"No".writeln;
	}
}


Measured memory_bytes: 256
n = int(input())
ans = ''
for i in range(1, 99):
    if n <= 26 ** i:
        n -= 1
        for j in range(i):
            ans += chr(ord('a') + n % 26)
            n //= 26
        break
    else:
        n -= 26 ** i
print(ans[::-1])

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  ll n, k;
  cin >> n >> k;

  vector<bitset<40>> va;
  for (ll i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    va.emplace_back(a);
  }

  ll pow2 = 1, bit_size = 1;
  while (pow2 <= k) {
    pow2 *= 2;
    bit_size++;
  }
  pow2 /= 2;
  bit_size--;

  ll x = 0;
  for (int i = bit_size - 1; i >= 0; --i, pow2 /= 2) {
    int cnt1 = 0;
    for (int j = 0; j < va.size(); j++) {
      cnt1 += va[j].test(i);
    }

    if (va.size() - cnt1 > cnt1 && x + pow2 <= k) {
      x += pow2;
    }
  }

  ll ans = 0;
  for (int i = 0; i < va.size(); ++i) {
    ll a = va[i].to_ullong();
    ans += a ^ x;
  }

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

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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var K = Readint();
            var dpt1=Enumerable.Repeat(0, s.Length).Select(x => Enumerable.Repeat(0, K + 1).ToArray()).ToArray();
            var dpt2 = Enumerable.Repeat(0, s.Length).Select(x => Enumerable.Repeat(0, K + 1).ToArray()).ToArray();

            dpt1[0][1] = int.Parse(s[0].ToString()) - 1;
            dpt2[0][1] = 1;
            dpt1[0][0] = 1;

            foreach (var i in Enumerable.Range(1,s.Length-1))
            {
                var current = int.Parse(s[i].ToString());
                dpt1[i][0]=1;
                for(int j=1; j<=K;j++)
                {
                    if (current == 0)
                    {
                        dpt1[i][j] += dpt1[i - 1][j];
                        dpt2[i][j] += dpt2[i - 1][j];
                        dpt1[i][j] += dpt1[i - 1][j - 1] * 9;

                    }
                    else
                    {

                        dpt1[i][j] += dpt1[i - 1][j];
                        dpt2[i][j] += dpt2[i - 1][j - 1];
                        dpt1[i][j] += dpt1[i - 1][j - 1] * 9;

                        dpt1[i][j] += dpt2[i - 1][j];
                        dpt1[i][j] += dpt2[i - 1][j - 1] * (current-1  );
                    }

                }
            }


            Console.WriteLine(dpt1[s.Length-1][K] + dpt2[s.Length-1][K]);
            Console.ReadLine();
  
        }

        static List<int> Readints()
        {
            return  Console.ReadLine().Split(' ').Select(x =>x.ToInt()).ToList();
        }
        static int Readint()
        {
            return Console.ReadLine().ToInt();
        }
        static void Read2int(out int a,out int b)
        {
            var ints = Readints();
            a = ints[0];
            b = ints[1];
        }    
        static int Max(int a,int b)
        {
            return a > b ? a : b;
        }
        



    }

    static  class extensions
    {
        public static int ToInt(this string s)
        {
            return int.Parse(s);
        }

        public static string LJoin<T>(this IEnumerable<T> list)
        {
            return string.Join(" ",list);
        }


    } 


}


Measured memory_bytes: 13524
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

double const inf = 1e20;

int a[200],n;
double dp[200];
double d[10001];
int main(){
    while(cin>>n && n){
        rep(i,n)cin>>a[i+1];
        a[0]=0;
        double b,r,v,e,f;
        cin>>b;
        cin>>r>>v>>e>>f;
        d[0]=0;
        rep(i,10000){
            if(i>=r)d[i+1] = d[i]+1./(v-e*(i-r));
            else d[i+1] = d[i]+1./(v-f*(r-i));
        }
        rep(i,200)dp[i]=inf;
        dp[0]=0;
        for(int i=1;i<=n;i++){
            for(int j=0;j<i;j++){
                double t = dp[j]+d[a[i]-a[j]];
                if(j!=0)t+=b;
                dp[i] = min(dp[i], t);
            }
        }
        printf("%.10lf\n", dp[n]);
    }
}

Measured memory_bytes: 1316
#include <iostream>
#include <string>
#include <sstream>
#include <stdio.h>
#include <vector>

using namespace std;

#define max 6

int main(void){
	int div[] = {1, 10, 100, 1000, 10000, 100000, 1000000 };

	while(1) {
		int t, num, lim, indx = -1, summax = 0;
		bool error = true, rejected = false;
		stringstream ss;
		vector< vector< int > > vs;

		cin >> t >> num;
		ss << num;
		if( !( t | num ) ) break;

		lim = ( 1 << ( ss.str().length() - 1 ) ) - 1;

		for(int i = 0; i <= lim; i++) {
			vector< int > v;
			int temp = 0;
			for(int j = 0; j < max; j++) {
				if( i & ( 1 << j ) ) {
					v.push_back( ( num % div[j + 1] ) / div[temp] );
					temp = j + 1;
				}
			}
			v.push_back( num / div[temp] );
			vs.push_back( v );
		}

		for(int i = 0; i < vs.size(); i++) {
			int sum = 0;
			for(int j = 0; j < vs[i].size(); j++)
				sum += vs[i][j];
			if( sum <= t ) {
				error = false;
				if( sum == summax ) {
					rejected = true;
				} else if( sum > summax ) {
					indx = i;
					summax = sum;
					rejected = false;
				}
			}
		}
		if( error == true ) {
			cout << "error" << endl;
		} else if( rejected == true ) {
			cout << "rejected" << endl;
		} else {
			cout << summax;
			for(int i = vs[indx].size() - 1; i >= 0; i--)
				cout << " " << vs[indx][i];
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1244
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = getLong(sc);
		double b = getDouble(sc);

		BigDecimal bd = BigDecimal.valueOf(a).multiply(BigDecimal.valueOf(b));
		System.out.println(bd.longValue());
	}

	private static double getDouble(Scanner sc) {

		return Double.parseDouble(sc.next());
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	int row = 0;
	int col = 0;
	int candies = 0;

	public Status(int row, int col, int candies) {
		this.row = row;
		this.col = col;
		this.candies = candies;
	}
}


Measured memory_bytes: 36004
n = int(input())
h = list(map(int, input().split()))

dp =[0, abs(h[1] - h[0])]

for i in range(2, n):
    dp += [min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))]

print(dp[-1])

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

int main() {
        int n, k, s;
        cin >> n >> k >> s;
        rep(i, k) cout << s << " ";
        rep(i, n - k) cout << (s == 1000000000 ? 1 : 1000000000) << " ";
        cout << endl;
        return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 0; i + 1 < n; ++i){
		for(int j = 0; j + i + 1< n; ++j){
			cout << __builtin_ctz(~j) + 1 << " ";
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K,S;
    cin>>K>>S;

    int count=0;
    int Z;
    for(int X=0;X<=K;X++){
        for(int Y=0;Y<=K;Y++){
            if(X+Y>S) continue;
            else{
                Z=S-(X+Y);
                if(0<=Z & Z<=K) count++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		int []a=new int [n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		long []prefix=new long [n],suf=new long [n];
		for(int i=0;i<n;i++) {
			int s=i%2==0?1:-1;
			prefix[i]+=s*a[i];
			if(i>0)
				prefix[i]+=prefix[i-1];
		}
		for(int i=n-1;i>=0;i--) {
			int s=i%2==0?1:-1;
			suf[i]+=s*a[i];
			if(i+1<n)
				suf[i]+=suf[i+1];
		}
		for(int i=0;i<n;i++) {
			long ans=suf[i];
			if(i%2==1)
				ans*=-1;
			
			if(i>0) {
				int len=n-i;
				if(len%2==0)
					ans+=prefix[i-1];
				else
					ans-=prefix[i-1];
			}
			out.println(ans);
		}
		out.close();

	}
	 
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 43396
#include<stdio.h>
int main(void){
	int n,d_1,d_2;
	int cnt=0;
	scanf("%d",&n);
	while(n--){
		scanf("%d%d",&d_1,&d_2);
		if(cnt){
			if(d_1==d_2){
				cnt++;
			}
			else{
				cnt=0;
			}
		}
		else{
			cnt+=d_1==d_2;
		}
		if(3<=cnt){
			break;
		}
	}
	printf(3<=cnt?"Yes":"No");
	return 0;
}


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

using namespace std;

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

  if(s[2] == s[3] && s[4] == s[5]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }

                                                                                                                                                                                                            
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {

	int n;
	string s;
	cin>>n;
	cin>>s;

	int total=1;
	rep(i,s.size()-1){
		if(s[i]!=s[i+1])total++;
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s, s1, s2;
	int n, i, j, k, ans = 0, a, b, ct;
	cin >> n;
	cin >> s;
	set<char> c1, c2;
	for (i = 1; i < n; i++) {
		s1 = s.substr(0, i);
		s2 = s.substr(i);

		c1.clear();
		for (auto ch : s1) c1.insert(ch);
		c2.clear();
		for (auto ch : s2) c2.insert(ch);

		ct = 0;
		for (auto ch : c1) {
			if (c2.find(ch) != c2.end()) ct++;
		}
		ans = max(ans, ct);
	}
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    H, N = MI()
    A = [0] * N
    B = [0] * N
    dp = [[IINF] * (H+2) for i in range(N+1)]
    dp[0][0] = 0

    for i in range(N):
        A[i], B[i] = MI()
        # AB[i] = (A / B, A, B)

    # print(dp)
    for i in range(N):
        for j in range(H+1):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            max_h = min(H, j+A[i])
            dp[i+1][max_h] = min(dp[i+1][max_h], dp[i+1][j] + B[i])
    print(dp[N][H])


if __name__ == '__main__':
    main()


Measured memory_bytes: 119916
N=int(input())
s=[]
for i in range(N):
    krs=input()
    s.append(krs)
M=int(input())
t=[]
for i in range(M):
    krt=input()
    t.append(krt)

ans=0
for i in range(N):
    kans=0
    for j in range(i,N):
        if s[i]==s[j]:
            kans+=1
    for j in range(M):
        if s[i]==t[j]:
            kans-=1
    if ans<kans:
        ans=kans
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <string.h>
#include <iostream>

typedef struct {
	char number;
	int num;
} NUMBER;

using namespace std;

NUMBER N[100000];
char str[100000];
char nnn[20];

int main()
{
	int n;
	
	while (scanf("%d", &n), n){
		strcpy(str, "");
		scanf("%s", str);
		
		memset(N, 0, sizeof(N));
		
		for (int c = 0; c < n; c++){
			int i = 0;
			int j = 0;
			while (str[i] != '\0'){
				if (i > 0 && str[i] == str[i-1]){
					N[j-1].num++;
				}
				else {
					N[j].number = str[i];
					N[j].num = 1;
					j++;
				}
				
				i++;
			}
			
			strcpy(str, "");
			
			for (int i = 0; i < j; i++){
				sprintf(nnn, "%d", N[i].num);
//				printf("_%s\n", nnn);
				
				strcat(str, nnn);
				strncat(str, &N[i].number, 1);
			}
//			strncat(str, "\0", 1);
		}
		
		printf("%s\n", str);
	}
	
	return 0;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    if(k * 500 >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	if(y == 0) return 1;
	if(y == 1) return x;
	ll num = power(x,y/2) % mod;
	if(y%2 == 0) return (num*num)%mod;
	else return (((num*num)%mod)*x)%mod;
}

void solve(){

	int n;
 	cin >> n;
 	vector <int> p(n,0);
 	rep0(i,n) cin >> p[i];
 	sort(all(p));
 	ll sum = 0;
 	rep0(i,n-1) sum += p[i];
 	sum += p[n-1]/2;
 	cout << sum;

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
ll a[1919],b[1919],c[1919];
ll ans[1919902];
ll sa[3343343];
signed main(){
	ll x,y,z,k;
	cin>>x>>y>>z>>k;
	rep(i,x)cin>>a[i];
	rep(i,y)cin>>b[i];
	rep(i,z)cin>>c[i];
	rep(i,x){
		rep(j,y){
			ans[i*y+j]=a[i]+b[j];
		}
	}
	sort(ans,ans+x*y);
	reverse(ans,ans+x*y);
	rep(i,min(x*y,k)){
		rep(j,z){
			sa[i*z+j]=ans[i]+c[j];
		}
	}
	sort(sa,sa+min(x*y,k)*z);
	reverse(sa,sa+min(x*y,k)*z);
	rep(i,k)cout<<sa[i]<<endl;
}


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

int main() {
  string S;
  cin >> S;
  
  if(S == "hihi" || S == "hi" || S == "hihihihi" || S =="hihihihihi" || S == "hihihi"){
    cout << "Yes" << endl;
  }
    
    else{
      cout << "No" << endl;
    }
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    for (int i = 0; i < k; ++i) {
        cout << "ACL";
    }
    cout << endl;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
#include <cctype>
using namespace std;

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;
int n;
int a[MAXN];

int main(){
    //ios_base::sync_with_stdio(false);
	scanf("%d", &n);
	int sum1 = 0, sum2 = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		if(a[i]%2 == 0) sum1 ++;
		if(a[i]%4 == 0) sum2 ++;
	}
	sum1 -= sum2;
	int sum3 = n - sum1 - sum2;
	if(sum3 > sum2 + 1 || (sum1&1 && sum3 == sum2 + 1)) printf("No\n");
	else printf("Yes\n");

    return 0;
}


Measured memory_bytes: 640
N,K=map(int,input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return (fact[n] * factinv[r] * factinv[n-r]) % p

p=10**9 + 7
fact=[1, 1]
factinv=[1, 1]
inv=[0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


for i in range(K):
    print((cmb(N-K+1,i+1,p)*cmb(K-1,i,p))%p)

Measured memory_bytes: 42864
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3 10
---+/
/+---test
100000 5
---+/

void main(string[] args) {
  long N, K;
  readf(" %d %d ", &N, &K);

  double r = 0;
  foreach (n; 1..N+1) {
    r += (0.5).pow(log2(K*1./min(n, K)).ceil);
  }
  "%.10f".writefln(r / N);
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[0 for _ in range(n)]
ans[0]=1
li=[1 for _ in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    if ans[x-1]==1:
        ans[y-1]=1
    if li[x-1]==1:
        ans[x-1]=0
    li[x-1]-=1
    li[y-1]+=1
  
cnt=0
for i in range(n):
    if li[i]!=0 and ans[i]!=0:
        cnt+=1
print(cnt)

Measured memory_bytes: 4656
# coding: utf-8
# Your code here!

import sys

N = int(input())

X = []
for _ in range(N):
    X.append(list(map(int, input().rstrip().split(' '))))
    
X = sorted(X, key=lambda x: x[1])

cumsum = 0
for i in range(N):
    cumsum += X[i][0]
    if X[i][1] < cumsum:
        print('No')
        sys.exit()
        
print('Yes')

Measured memory_bytes: 90020
import qualified Data.Vector.Unboxed as V

solve :: Int -> Int -> V.Vector Int -> Int
solve n k xs = (\t -> if null t then 0 else minimum t) $ map (\i -> dist (xs V.! i) (xs V.! (i+k-1))) [0..n-k] where
  dist x y =
    let
      l = max (-x) 0
      r = max y 0
    in
      l + r + min l r

main = do
  [n,k] <- fmap read . words <$> getLine
  xs <- fmap read . words <$> getLine
  print $ solve n k $ V.fromList xs



Measured memory_bytes: 36220
X = int(input())
if X>=400 and X<=599:
  print(8)
if X>=600 and X<=799:
  print(7)
if X>=800 and X<=999:
  print(6)
if X>=1000 and X<=1199:
  print(5)
if X>=1200 and X<=1399:
  print(4)
if X>=1400 and X<=1599:
  print(3)
if X>=1600 and X<=1799:
  print(2)
if X>=1800 and X<=1999:
  print(1)


Measured memory_bytes: 61836
def main():
    import sys
    input = sys.stdin.readline
    import heapq

    N = int(input())
    A = list(map(int,input().split()))

    sectionX = A[:N]
    sumX = sum(sectionX)
    heapq.heapify(sectionX)
    maxListX = [sumX]
    for i in range(N,2*N):
        a = A[i]
        heapq.heappush(sectionX,a)
        b = heapq.heappop(sectionX)
        sumX += a - b
        maxListX.append(sumX)

    for i in range(3*N):
        A[i] *= -1
    A = A[::-1]
    sectionY = A[:N]
    sumY = sum(sectionY)
    heapq.heapify(sectionY)
    maxListY = [sumY]
    for i in range(N,2*N):
        a = A[i]
        heapq.heappush(sectionY,a)
        b = heapq.heappop(sectionY)
        sumY += a - b
        maxListY.append(sumY)
    for i in range(N+1):
        maxListY[i] *= -1

    maxList = []
    for i in range(N+1):
        maxList.append(maxListX[i]-maxListY[-i-1])
    print(max(maxList))
main()

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

int d[100], a[100];
map<vector<int>, int>id;
vector<int>re[5040];
int dp[100][5040];

int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d", &d[i]);
	rep(i, n)scanf("%d", &a[i]);
	vector<int>v(7); iota(v.begin(), v.end(), 0);
	int p = 0;
	do {
		id[v] = p; re[p] = v;
		int cnt = 0;
		bool t[7]{};
		for (int i : v) {
			rep(j, 7) {
				if (t[j] && abs(j - i) <= d[j])cnt += a[j];
			}
			t[i] = 1;
		}
		dp[0][p] = cnt;
		p++;
	} while (next_permutation(v.begin(), v.end()));
	int ans = 0;
	for (int i = 1; i + 6 < n; i++)rep(j, 5040)rep(k, 8) {
		auto t = re[j].begin();
		int cnt = 0, o = 0;
		bool p[8]{};
		vector<int>q(7);
		rep(l, 8) {
			if (k == l) {
				rep(y, 8) {
					if (p[y] && y + d[i - 1 + y] >= 7)
						cnt += a[i - 1 + y];
				}
				p[7] = 1; q[o++] = 6;
			}
			else {
				if (p[7] && 7 - d[i + 6] <= *t)cnt += a[i + 6];
				p[*t] = 1;
				if (*t)q[o++] = *t - 1;
				t++;
			}
		}
		int v = id[q];
		dp[i][v] = max(dp[i][v], dp[i - 1][j] + cnt);
		ans = max(ans, dp[i][v]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 6084
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]

ans_mem = [0]*(m+1)
ans = 10**10
for i in range(2**n):
    ans_mem = [0]*(m+1)
    a = '0'*(n-len(bin(i))+2)+bin(i)[2:]
    for j,k in enumerate(a):
        if int(k) == 1:
            for l in range(0,m+1):
                ans_mem[l]+=ca[j][l]
    if min(ans_mem[1:])>=x:
        ans = min(ans,ans_mem[0])

if ans==10**10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9244
#include <stdio.h>

int main(void)
{
  int e,y,z,m,cuz,sqy;

  for(;;){
    scanf("%d", &e);
    if(!e) break;

    m=1000000;
    for(z=0;z*z*z<=e;z++){
      cuz=z*z*z;
      for(y=0;y*y<=e-cuz;y++){
	sqy=y*y;
	if(e-sqy-cuz+y+z<m){
	  m=e-sqy-cuz+y+z;
	}
      }
    }
    printf("%d\n", m);
  }

  return 0;
}


Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int a, b, c, d, n;
  cin >> a >> b >> c >> d >> n;
  b = min(b, 2 * a);
  c = min(c, 2 * b);
  d = min(d, 2 * c);
  cout << (ll)(n / 2) * d + (n % 2) * c << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    ll N;
    cin >> N;
    vector<ll> x(N), y(N), h(N);
    for(ll i = 0; i < N; i++){
        cin >> x.at(i) >> y.at(i) >> h.at(i);
    }
    
    
    
    for(ll X = 0; X <= 100; X++){
        for(ll Y = 0; Y <= 100; Y++){
            ll H;
            for(ll i = 0; i < N; i++){
                if(h.at(i) > 0){
                    H = h.at(i) + abs(X - x.at(i)) + abs(Y - y.at(i));
                    break;
                }
            }
            bool l = true;
            for(int i = 0; i < N; i++){
                if(max((ll)0, H - abs(X - x.at(i)) - abs(Y - y.at(i))) != h.at(i)){
                    l = false;
                }
            }
            if(l){
                cout << X << " " << Y << " " << H << endl;
            }
            
        }
    }
    
    
}


Measured memory_bytes: 256