akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,i,a[100001];
char l[100001];
int main(){
	cin>>n;
	for(i=1;i<=n;i++)cin>>l[i];
	a[1]=0;a[2]=0;
	for(i=3;i<=n;i++){
		if(l[i-1]=='o'){
			if(a[i-1]){
				a[i]=1-a[i-2];
			}else{
				a[i]=a[i-2];
			}
		}else{
			if(a[i-1]){
				a[i]=a[i-2];
			}else{
				a[i]=1-a[i-2];
			}
		}
	}
	int s,s1;
	if(l[1]=='o'){
		s=a[2];
	}else s=1-a[2];
	if(l[n]=='o'){
		if(a[n]){
			s1=1-a[1];
		}else s1=a[1];
	}else{
		if(a[n]){
			s1=a[1];
		}else s1=1-a[1];
	}
	if(s==a[n]&&s1==a[n-1]){
		for(i=1;i<=n;i++){
			if(a[i])cout<<'W';else cout<<'S';
		}
		cout<<endl;
		return 0;
	}
	a[1]=0;a[2]=1;
	for(i=3;i<=n;i++){
		if(l[i-1]=='o'){
			if(a[i-1]){
				a[i]=1-a[i-2];
			}else{
				a[i]=a[i-2];
			}
		}else{
			if(a[i-1]){
				a[i]=a[i-2];
			}else{
				a[i]=1-a[i-2];
			}
		}
	}
	if(l[1]=='o'){
		s=a[2];
	}else s=1-a[2];
	if(l[n]=='o'){
		if(a[n]){
			s1=1-a[1];
		}else s1=a[1];
	}else{
		if(a[n]){
			s1=a[1];
		}else s1=1-a[1];
	}
	if(s==a[n]&&s1==a[n-1]){
		for(i=1;i<=n;i++){
			if(a[i])cout<<'W';else cout<<'S';
		}
		cout<<endl;
		return 0;
	}
	a[1]=1;a[2]=0;
	for(i=3;i<=n;i++){
		if(l[i-1]=='o'){
			if(a[i-1]){
				a[i]=1-a[i-2];
			}else{
				a[i]=a[i-2];
			}
		}else{
			if(a[i-1]){
				a[i]=a[i-2];
			}else{
				a[i]=1-a[i-2];
			}
		}
	}
	if(l[1]!='o'){
		s=a[2];
	}else s=1-a[2];
	if(l[n]=='o'){
		if(a[n]){
			s1=1-a[1];
		}else s1=a[1];
	}else{
		if(a[n]){
			s1=a[1];
		}else s1=1-a[1];
	}
	if(s==a[n]&&s1==a[n-1]){
		for(i=1;i<=n;i++){
			if(a[i])cout<<'W';else cout<<'S';
		}
		cout<<endl;
		return 0;
	}
	a[1]=1;a[2]=1;
	for(i=3;i<=n;i++){
		if(l[i-1]=='o'){
			if(a[i-1]){
				a[i]=1-a[i-2];
			}else{
				a[i]=a[i-2];
			}
		}else{
			if(a[i-1]){
				a[i]=a[i-2];
			}else{
				a[i]=1-a[i-2];
			}
		}
	}
	if(l[1]!='o'){
		s=a[2];
	}else s=1-a[2];
	if(l[n]=='o'){
		if(a[n]){
			s1=1-a[1];
		}else s1=a[1];
	}else{
		if(a[n]){
			s1=a[1];
		}else s1=1-a[1];
	}
	if(s==a[n]&&s1==a[n-1]){
		for(i=1;i<=n;i++){
			if(a[i])cout<<'W';else cout<<'S';
		}
		cout<<endl;
		return 0;
	}
	cout<<"-1";
	return 0;
}




Measured memory_bytes: 768
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        q: usize,
        h: usize,
        s: usize,
        d: usize,
        n: usize,
    }
    let mut h = h;
    let mut s = s;
    let mut d = d;
    h = min(h, q * 2);
    s = min(s, h * 2);
    d = min(d, s * 2);
    let ans = (n / 2) * d + (n % 2) * s;
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include<stdio.h>
#define MAX 1000000

void maxHeapify(int);

int h,H[MAX];

int main(){
  int i;
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&H[i]);
  }
  for(i=h/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i=1;i<=h;i++){
    printf(" %d",H[i]);
  }
  printf("\n");
  return 0;
}

void maxHeapify(int i){
  int r,l,max,temp;
  r=i*2+1;
  l=i*2;
  if(H[i]<H[l] && l<=h){
    max=l;
  }else{
    max=i;
  }
  if(H[max]<H[r] && r<=h){
    max=r;
  }
  if(max!=i){
    temp=H[max];
    H[max]=H[i];
    H[i]=temp;    
    maxHeapify(max);
  }
}
  
  



Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll a,b;
    scanf("%lld%lld",&a,&b);
    // ll [n];
    // rep(i,0,n){
    //     scanf("%lld",&[i]);
    // }
    if(a<=0 && b>=0){
    }else{
        if((b-a+1)%2 && b<0){
            printf("Negative\n");
        }else{
            printf("Positive\n");
        }
        return 0;
    }

    
    printf("Zero\n");
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        List<int> L = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();

        Console.WriteLine(L.OrderBy(o => o).Select((o, p) => new[] { o, p }).Where(o => o[1] % 2 == 0).Sum(o => o[0]));
    }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll fac[maxn], ifac[maxn], inv[maxn];

ll nck(ll n, ll k) {
    if (n<k) return 0;
    return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}

void gen_inv() {
    fac[0]=inv[0]=ifac[0]=1;
    fac[1]=inv[1]=ifac[1]=1;

    for (int i=2; i<maxn; i++) {
	fac[i]=fac[i-1]*i%mod;
	inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
    }

    assert(nck(4,2)==6);
}

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}


ll N, A, B, C;

ll X(ll M) {
    return nck(M-1,N-1)*((pw(A,N)*pw(B,M-N)%mod + pw(A,M-N)*pw(B,N))%mod)%mod;
}

ll Y(ll M) {
    ll res = M*pw((1-C+mod)%mod, mod-2);
    res %= mod;
    res += mod;
    res %= mod;
    return res;
}

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

    gen_inv();

    cin>>N>>A>>B>>C;
    
    ll tmp = A+B;

    A = A * pw(tmp, mod-2) % mod;
    B = B * pw(tmp, mod-2) % mod;
    C = C * pw(100, mod-2) % mod;


    ll res = 0;

    // M: # of non-tie games played
    for (ll M=N; M<=2*N-1; M++) {
	// X(M) * Y(M)
	// X(M): Pr of player 1 or 2 achieving N wins in M non-tie games
	// Y(M): Expected # of games to achieve M non-tie games
	ll cur = X(M) * Y(M) % mod;
	// watch(X(M));
	// watch(Y(M));
	// cout<<M<<": "<<cur<<endl;
	
	res += cur;
	res %= mod;
    }


    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 27072
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, C: int, x: "List[int]", v: "List[int]"):
    x = [0] + x
    v = [0] + v

    mx_r = [0]
    for xx, acc in zip(x[1:], accumulate(v[1:], add)):
        mx_r.append(max(acc - xx, mx_r[-1]))

    mx_l = [0]
    for xx, cal in zip(reversed(x), accumulate(reversed(v), add)):
        mx_l.append(max(cal - (C - xx), mx_l[-1]))
    mx_l.reverse()

    ans = 0
    for i in range(N+1):
        ans = max(mx_r[i], mx_r[i] - x[i] + mx_l[i+1], ans)
        if i != 0:
            ans = max(mx_l[i], mx_l[i] - (C - x[i]) + mx_r[i-1], ans)
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        v[i] = int(next(tokens))
    result = solve(N, C, x, v)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 22460
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static int[][] dp;
	static int[] x;
	static int o=5001*5001;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		if(n==1){Console.WriteLine("POSSIBLE");return;}
		var p=sc.Ia;
		x=sc.Ia3(0);
		li=new List<int>[n+1];
		dp=new int[n+1][];
		for(int i=1;i<=n;i++){li[i]=new List<int>();}
		for(int i = 0;i<p.Length;i++) {li[p[i]].Add(i+2);}
		Console.WriteLine("{0}",Fu(1)!=o?"POSSIBLE":"IMPOSSIBLE");
	}
	static int Fu(int a){
		dp[a]=Enumerable.Repeat(o,x[a]+1).ToArray();
		dp[a][0]=0;
		int b=o;
		for(int i=0;i<li[a].Count;i++){
			int q=Fu(li[a][i]);
			for(int j = x[a];j>=0;j--) {
				dp[a][j]=Min(j>=q?dp[a][j-q]+x[li[a][i]]:o,j>=x[li[a][i]]?dp[a][j-x[li[a][i]]]+q:o);
				if(i==li[a].Count-1&&b>dp[a][j]){
					b=dp[a][j];
				}
			}
		}
		return li[a].Count==0?0:b;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

long long f(vector<long long> &v, int i, int j, vector<vector<long long> > &dp) {
	if(i == j)
      	return v[i];
  
 	if(dp[i][j] != -1)
      	return dp[i][j];
  
  	dp[i][j] = max(v[i] - f(v, i+1, j, dp),
                   v[j] - f(v, i, j-1, dp));
                   
    return dp[i][j];
}
int main() {
  	int N;
 	cin>>N;
  	vector<long long> v(N,0);
  	
  	for(int i = 0 ; i < N ; i++) {
    	cin>>v[i];
    }
  
  	vector<vector<long long> > dp(N, vector<long long> (N, -1));
  	cout << f(v, 0, N-1, dp) << endl;
  	return 0;
}

Measured memory_bytes: 71040
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
const int maxn=2e5+10;
const int INF=1e9;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair

struct node
{
	int l,r;
	node *ls,*rs;
	int mini;
} *root;
int n,a[maxn],q,pos;
int s[maxn];
pii p[maxn];
int dp[maxn];

void build(node *p,int l,int r)
{
	p->l=l;p->r=r;
	p->mini=INF;
	
	if (l==r) return;
	int mid=(l+r)>>1;
	p->ls=new node;
	p->rs=new node;
	build(p->ls,l,mid);
	build(p->rs,mid+1,r);
	return;
}

int getmin(node *p,int l,int r)
{
	if (l<=p->l && p->r<=r) return p->mini;
	else if (r<p->l || p->r<l) return INF;
	else return min(getmin(p->ls,l,r),getmin(p->rs,l,r));
}

void update(node *p,int pos,int val)
{
	if (p->l==p->r) 
	{
		p->mini=min(p->mini,val);
		return;
	}
	else
	{
		if (pos<=p->ls->r) update(p->ls,pos,val);
		else update(p->rs,pos,val);
		p->mini=min(p->ls->mini,p->rs->mini);
		return;
	}
}

int main() 
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		s[i]=s[i-1]+(1-a[i]);
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++) scanf("%d%d",&p[i].x,&p[i].y);
	sort(p+1,p+q+1);
	
	root=new node;
	build(root,0,n);
	for(int i=1;i<=n;i++) dp[i]=INF;
	update(root,0,0);
	dp[0]=0;
	
	pos=1;
	for(int i=1;i<=n;i++)
	{
		dp[i]=min(dp[i],dp[i-1]+a[i]);
		
		int st=pos;
		while(pos<=q && p[pos].x==i) pos++;
		int ed=pos-1;
		
		for(int j=st;j<=ed;j++)
		{
			int tmp=min(dp[i-1]+s[p[j].y]-s[i-1],
				getmin(root,p[j].x,p[j].y-1)+s[p[j].y]);
			dp[p[j].y]=min(dp[p[j].y],tmp);
			update(root,p[j].y,tmp-s[p[j].y]);
		}
	}
	
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 23040
#include <iostream>
#include <vector>

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> f(N + 1, 0);

    for (int x = 1; 6 * x * x <= N; x++) {
        for (int y = x; x * (x + 2 * y) + 3 * y * y <= N; y++) {
            auto x_plus_y = x + y;

            for (int z = y;; z++) {
                auto y_plus_z = y + z,
                     z_plus_x = z + x;

                auto tmp_n = (x_plus_y * x_plus_y + y_plus_z * y_plus_z + z_plus_x * z_plus_x) / 2;

                if (tmp_n <= N) {

                    switch (int{x == y} + int{y == z}) {
                    case 0:
                        f[tmp_n] += 6;
                        break;
                    case 1:
                        f[tmp_n] += 3;
                        break;
                    case 2:
                        f[tmp_n] += 1;
                        break;
                    default:
                        break;
                    }
                } else {
                    break;
                }
            }
        }
    }

    for (auto i = 1; i <= N; i++) {
        std::cout << f[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3572
package main

import (
	"fmt"
)

var A, B, C, D int

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

func main() {
	fmt.Scan(&A, &B, &C, &D)
	fmt.Println(min(A, B) + min(C, D))
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll a,b,c; cin>>a>>b>>c;
ll k;cin>>k;
while(a>=b)
{
    b*=2;
    k--;
}
while(b>=c)
{
    c*=2;
    k--;
}
if(k>=0)cout<<"Yes\n";
else cout<<"No\n";
return 0;
}
/*
23 5
10 3 3
2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22
4 6 3 18 23
*/


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int ui32;
const long long INFLL = 1e18;

using namespace std;

const int MAXN = 101;

pair<int, int> a[MAXN + 1], b[MAXN + 1];

int n, k;
vector < vector<int> > g;
vector<int> mt;
vector<char> used;

bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}

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

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    for (int i = 0; i < n; i++) {
        cin >> b[i].first >> b[i].second;
    }

    int ans = 0;

    k = n;

    g.resize(n);
    mt.assign (k, -1);

    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < n; j++) {
            if (a[i].first < b[j].first && a[i].second < b[j].second) {
                g[i].push_back(j);
            }
        }
    }

    for (int v=0; v<n; ++v) {
        used.assign (n, false);
        try_kuhn (v);
    }

    for (int i=0; i<k; ++i)
        if (mt[i] != -1)
            ++ans;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d}) << "\n";
	return 0;
}

Measured memory_bytes: 3644
# 0405の分もやる

# ABC153-C
if False:
    N,K=map(int,input().split())
    H=[int(i) for i in input().split()]
    H.sort(reverse=True)
    print(sum(H[K:]))

# ABC153-D
if False:
    H=int(input())
    cnt=1
    ans=0
    while H>1:
        ans+=cnt
        H//=2
        cnt*=2
    print(ans+cnt)

# ABC153-A
if True:
    # ceil関数
    def ceil(a,b): #ceil(a/b)
        return (a+b-1)//b

    H,A=map(int,input().split())
    print(ceil(H,A))
    

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define F first
#define S second

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  pii p[100];
  rep(i,n*(n-1)/2){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;
    if(c>d) p[a].F++;
    else if(c<d) p[b].F++;
    else p[a].S++,p[b].S++;
  }
  rep(i,n){
    p[i].F=p[i].F*3+p[i].S;
    p[i].S=i+1;
  }
  sort(p,p+n);
  vi v(n);
  v[p[n-1].S]=1;
  for(i=n-2;i>=0;i--)
    if(p[i].F==p[i+1].F)v[p[i].S]=v[p[i+1].S];
    else                v[p[i].S]=n-i;
  for(i=1;i<=n;i++)cout<<v[i]<<endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    long n;
    cin >> n;

    long sum = 0;
    for(long i = 1; i*i < n; i++){
        if((n/i) == (n%i)){
//            cerr << n/i << " " << n%i << endl;
            cerr << i << endl;
            sum += i;
        }
        long c = n/i-1;
        if(n/c == n%c){
            cerr << c << endl;
            sum += c;
        }
    }

    cout << sum << endl;

    return 0;
}


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

S = input()[:-1]
dp = [[0]*2 for _ in range(len(S))]
dp[0][0] = 1
dp[1][1] = 1

for i in range(len(S)):
    if i>=1 and S[i]!=S[i-1]:
        dp[i][0] = max(dp[i][0], dp[i-1][0]+1)
    
    if i>=1:
        dp[i][0] = max(dp[i][0], dp[i-1][1]+1)
        
    if i>=2:
        dp[i][1] = max(dp[i][1], dp[i-2][0]+1)
    
    if i>=2 and S[i-3:i-1]!=S[i-1:i+1]:
        dp[i][1] = max(dp[i][1], dp[i-2][1]+1)

print(max(dp[-1]))

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

int main()
{  
  	string s,t;
    cin>>s>>t;
    if(t.substr(0, s.size()) == s && t.size()>s.size()) 
      cout<<"Yes"<<"\n";
    else 
      cout<<"No"<<"\n"; 
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)

template<class T>inline void chmin(T &a,T b){a=min(a,b);}
template<class T>inline void chmax(T &a,T b){a=max(a,b);}

int N,K;
double p[200005];
signed main(){
	cin>>N>>K;
	rep(i,N)cin>>p[i];
	double mx=0.;
	double sum=0;
	rep(i,N){
		sum+=(1+p[i])/2.;
		if(i>=K)sum-=(1+p[i-K])/2.;
		chmax(mx,sum);
	}
	printf("%.12lf\n",mx);
}


Measured memory_bytes: 1792
# MInt(ModInt)
class Integer

  attr_accessor :mod
  @@mod = 10 ** 9 + 7
  @@h = Hash.new

  def +@(other)
    super(other) % @@mod
  end

  def -@(other)
    super(other) % @@mod
  end

  alias_method :primitive_times, :*
  def *(other)
    self.primitive_times(other) % @@mod
  end

  def /(other)
    @@h[other] ||= other.pow(@@mod-2, @@mod)
    self * @@h[other] % @@mod
  end
  
  alias_method :primitive_equal, :==
  def ==(other)
    ( self % @@mod ).primitive_equal( other % @@mod )
  end
  
  def abs
    self % @@mod
  end
  
  def <<(value)
    self * 2.pow(value, @@mod)
  end
  
  def >>(value)
    self / 2.pow(value, @@mod)
  end
  
  alias_method :primitive_inspect, :inspect
  def inspect
    (self % @@mod).primitive_inspect
  end

  alias_method :primitive_to_s, :to_s
  def to_s
    (self % @@mod).primitive_to_s
  end
end

# ABC163
n, k = gets.to_s.split.map{|e|e.to_i}

ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.sum

puts ans
# p 1.class.instance_methods
# p 1.class.superclass.instance_methods




Measured memory_bytes: 16120
#!/usr/bin/env python3
import sys
from collections import defaultdict
INF = float("inf")


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):

    edges = defaultdict(list)
    for f_, t_ in zip(a, b):
        edges[f_-1].append(t_-1)
        edges[t_-1].append(f_-1)

    visited = [False] * N

    def dfs(f_, pre):
        if visited[f_] is True:
            return True

        visited[f_] = True
        for t_ in edges[f_]:
            if t_ == pre:
                continue
            dfs(t_, f_)
        return

    counter = 0
    for f_, t_ in zip(a, b):
        edges[f_-1].remove(t_-1)
        edges[t_-1].remove(f_-1)
        visited = [False] * N
        dfs(0, -1)
        if all(visited) is False:
            counter += 1
        edges[f_-1].append(t_-1)
        edges[t_-1].append(f_-1)
    print(counter)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

char s[20], t[20], u[20];
int a, b;
int main() {
	scanf("%s %s %d %d %s", s, t, &a, &b, u);
	int e = 1, n = 0;
	for (; s[n]; n++)
		e &= s[n] == u[n];
	e &= u[n] == 0;
	a -= e;

	e = 1, n = 0;
	for (; t[n]; n++)
		e &= t[n] == u[n];
	e &= u[n] == 0;
	b -= e;
	printf("%d %d\n", a ,b);
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int n, x, i, j;
  int tmp, ans;
  
  scanf("%d %d", &n, &x);
  int a[n];

  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  for(i = 0; i < n; i++){
    for(j = i + 1; j < n; j++){
      if(a[i] > a[j]){
	tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
      }
    }
  }

  /*  for(i = 0; i < n; i++){
    printf("%d ", a[i]);
  }
  printf("\n");*/
  
  ans = 0;
  
  for(i = 0; i < n; i++){
    if(x < 0){
      break;
    }
    if(i == n - 1){
      if(x == a[i]){
	ans++;
      }
      break;
    }
    else{
      if(x >= a[i]){
	ans++;
	x -= a[i];
      }
    }

    //    printf("%d ", x);
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  int a[A], b[B];
  rep(i, A) cin >> a[i];
  rep(i, B) cin >> b[i];
  int x[M], y[M], c[M];
  rep(i, M) cin >> x[i] >> y[i] >> c[i];
  
  int s[M];
  rep(i, M) s[i] = a[x[i] - 1] + b[y[i] - 1] - c[i];
  sort(s, s + M);
  sort(a, a + A);
  sort(b, b + B);
  cout << min(a[0] + b[0], s[0]);
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;
	int K;

	public void init() {
		N = 0;
		cnt = 0;
		K = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		K = Integer.parseInt(str);
	}

	public void solve() {
		int ans = 1;
		for (; N > 0 && ans < K; N--) {
			ans *= 2;
		}
		ans += N * K;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 10000
#define nil -1
#define vmax 10000
#define sentinel 2000000000
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main() {
    long long int n,w=0,e=0,cnt=inf;
    cin>>n;
    string s;
    cin>>s;
    int b=s.size();
    for(int i=0;i<b;i++){
        if(s[i]=='W'){
            w++;
        }else{
            e++;
        }

    }
    int w1=0;
    int e1=0;
    for(int i=0;i<b;i++){
        if(s[i]=='W'){
            cnt=min(cnt,w1+e-e1);
            w1++;
        }else{
            e1++;
            cnt=min(cnt,w1+e-e1);
        }
    }
    cout<<cnt<<endl;
}


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

int main() {
  
  int H,W;
  cin >> H >> W;
  
  int h,w;
  cin >> h >> w;
  
  cout << H*W-h*W-w*H+h*w/*==(H-h)*(W-w);*/ << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){	
	int h,w;
	cin>>h>>w;
	string s[100];
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for(int i=0;i<2*h;i++){
		int y=i/2;
		cout<<s[y]<<endl;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
char s[200005];
int nxt[2000005][30],n,dp[200005];
int main()
{
    cin.getline(s+1,200005);
    n=strlen(s+1);
    for(int i=0;i<26;++i) nxt[n+1][i]=n+1;
    dp[n+1]=1;
    for(int i=n;i>=1;--i)
    {
        for(int j=0;j<26;++j) nxt[i][j]=nxt[i+1][j];
        nxt[i][s[i]-'a']=i;
        dp[i]=n+1;
        for(int j=0;j<26;++j) dp[i]=min(dp[i],dp[nxt[i][j]+1]);
        ++dp[i];
    }
    int poz=1;
    while(poz<=n)
    {
        for(int i=0;i<26;++i)
        {
            if(nxt[poz][i]>n||dp[nxt[poz][i]+1]<dp[poz])
            {
                cout<<(char)('a'+i);
                poz=nxt[poz][i]+1;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 24960
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,D;
    cin >> N >> D;
    int d = N%(2*D+1);
    
    if(d==0){
        cout << N/(2*D+1) << endl;
    }else{
        cout <<  N/(2*D+1)+1 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  double a,b,c;
  cin>>a>>b>>c;
  c=PI*c/180;
  double s,l,h;
  s=a*b*sin(c)/2;
  l=a+b+sqrt(a*a+b*b-2*a*b*cos(c));
  h=2*s/a;
  printf("%.10f\n%.10f\n%.10f\n",s,l,h);
}

Measured memory_bytes: 1240
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 5005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
ll n,dp[MAXN*MAXN];
int w[3][2];
vector<P> v1,v2;
ll solve(ll n,vector<P> &v)
{
    memset(dp,-1,sizeof(dp));
    dp[n]=0;
    for(int i=0;i<(int)v.size();i++)
        for(int j=n;j>=0;j--)
        {            
            if(dp[j]==-1) continue;
            if(j>=v[i].F) dp[j-v[i].F]=max(dp[j-v[i].F],dp[j]+v[i].S);
        }
    ll ans=0;
    for(int i=0;i<=n;i++) ans=max(ans,dp[i]);
    return n+ans;
}
int main()
{
    scanf("%lld",&n);
    for(int i=0;i<2;i++)
        for(int j=0;j<3;j++)
            scanf("%d",&w[j][i]);
    for(int i=0;i<3;i++)
    {
        if(w[i][0]<w[i][1]) v1.push_back(P(w[i][0],w[i][1]-w[i][0]));
        else v2.push_back(P(w[i][1],w[i][0]-w[i][1]));
    }
    n=solve(n,v1);
    n=solve(n,v2);
    printf("%lld\n",n);
    return 0;
}



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

int main() {
    int n,l;
    cin >> n >> l;
    vector <string> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    for(int i = 0; i < n; i++){
        cout << v[i];
    }
}

Measured memory_bytes: 256
import sys
mina=10**10
X,N=map(int,input().split())
if N==0:
  print(X)
  sys.exit()
L=list(map(int,input().split()))
for i in range(52):
  if X-i not in L:
    print(X-i)
    sys.exit()
  if X+i not in L:
    print(X+i)
    sys.exit()

Measured memory_bytes: 9128
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict
n,m=map(int,input().split())
d=defaultdict(list)
for _ in range(m):
  x,y=map(int,input().split())
  d[x-1].append(y-1)

dp=[-1]*n

def rec(v):
  if dp[v]!=-1:
    return dp[v]
  res=0
  for nv in d[v]:
    res=max(res,rec(nv)+1)
  dp[v]=res
  return res

res=0
for v in range(n):
  res=max(res,rec(v))
print(res)

Measured memory_bytes: 201272
import sys
import math
from collections import defaultdict, deque
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
          p = 0
          l = 1
          while p == 0:
              new_y, new_x = y + j * l, x + k * l
              if (0 <= new_y < H) and (0 <= new_x < W):
                if maze[new_y][new_x] == "@":
                  p = 1
                elif visited[new_y][new_x] == -1:
                  visited[new_y][new_x] = visited[y][x] + 1
                  queue.append([new_y, new_x])
                elif visited[new_y][new_x] < visited[y][x] + 1:
                  p = 1
              else:
                p = 1
              l += 1
              if l == K + 1:
                p = 1

H, W, K = rm()
x1, y1, x2, y2 = rm()
x1, y1, x2, y2 = x1-1, y1-1, x2-1, y2-1
C = [0] * H
for i in range(H):
  C[i] = str(input())
visited = [[-1] * W for i in range(H)]
bfs(C, visited, x1, y1, x2, y2)
print(visited[x2][y2])

Measured memory_bytes: 123888
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n>=m:
    print(0)
else:
    x2=sorted(x)
    dis=[]
    for i in range(m-1):
        dis.append(x2[i+1]-x2[i])
    dis2=sorted(dis)
    #print(dis2)
    ans=0
    for i in range(m-n):
        ans+=dis2[i]
    print(ans)

Measured memory_bytes: 13968
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

const int N = (int)1e5 + 9;
int a[N];

int main(){
    fastIO;
    int n, l;
    cin >> n >> l;
    for(int i = 1; i <= n; i ++ )
        cin >> a[i];
    for(int i = 1; i < n; i ++ ){
        if(a[i] + a[i + 1] >= l){
            cout << "Possible\n";
            for(int j = 1; j < i; j ++ ){
                cout << j << "\n";
            }
            for(int j = n-1; j > i; j -- )
                cout << j << "\n";
            cout << i << "\n";
            return 0;
        }
    }
    cout << "Impossible\n";
    return 0;
}

Measured memory_bytes: 1280
using System;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[][] ab = new int[N][];

            for (int i = 0; i < N; i++)
            {
                int[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                ab[i] = new int[] { nbrs[0], nbrs[1] };
            }

            Array.Sort(ab, new Comparison<int[]>((x, y) => 
            {
                if (x[1] < y[1])
                    return -1;
                else if (x[1] > y[1])
                    return 1;
                else
                    return 0;
            }));

            string res = "Yes";
            int time = 0;

            for (int i = 0; i < N; i++)
            {
                time += ab[i][0];

                if (ab[i][1] < time)
                {
                    res = "No";
                    break;
                }
            }

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 28196
# -*- coding: utf-8 -*-

#問題文
#すぬけ君は 1,2,3 の番号がついた 3 つのマスからなるマス目を持っています。 各マスには 0 か 1 が書かれており、マス i
# には si が書かれています。
#すぬけ君は 1 が書かれたマスにビー玉を置きます。 ビー玉が置かれるマスがいくつあるか求めてください。

#制約
#s1,s2,s3 は 1 あるいは 0

countup = 0
s = str(raw_input())
for count in s :
    if count == '1':
        countup += 1
    else:
        countup = countup

print countup


Measured memory_bytes: 2568
// G - G AtCoder - 2299
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=100000+100;
int cnt[maxn];
int x;
int N;

void solve()
{
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<N;i++){
		scanf("%d",&x);
		cnt[x]++;
	}
	int odd,even;
	odd=even=0;
	for(int i=0;i<maxn;i++){
        if(cnt[i]==0)   continue;
		if(cnt[i]&1)	odd++;
		else even++;
	}
	int ans=0;
	if(odd==0){


        return;
	}
	if(even==0){
		ans=0;
	}
	else if(even&1){
		ans=even-1;
	}
	else{
		ans=even;
	}
	ans+=odd;
	printf("%d\n",ans);

}

int main()
{
	while(~scanf("%d",&N)){
		solve();
	}
	return 0;
}


Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  X -= A;
  X %= B;
  cout << X << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-b) <= d && abs(b-c) <= d){
        cout << "Yes" << endl;
    }
    else if(abs(a-c) <= d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N;
    cin >> N;
    
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    
    cout << a.at(N - 1) - a.at(0) << endl;
   
    return 0;
}


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(A)

for _ in range(M):
    mn = heapq.heappop(A)
    heapq.heappush(A, -mn//2*(-1))

print(-sum(A))

Measured memory_bytes: 14180
#include<iostream>
#include<string.h>
#define MAX 100
using namespace std ;
 
int main()
{
    int n;
    int t=0,h=0,comp=0;
    char tarou[MAX], hanako[MAX];
     
    cin >> n ;
     
    for(;n>0;n--)
	{     
        cin >> tarou >> hanako;

		comp = strcmp(tarou,hanako);
         
        if(comp>0)
		{
            t+=3;
        }
         
        else if(comp==0)
		{
            t++;
            h++;
        }
         
		else
		{
            h+=3;
        }
    }    
     
    cout << t << ' ' << h << endl ;
     
    return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

void solve() {
	long long a[7] = {};
	FOR(i, 0, 7) cin >> a[i];
	long long ans = 0;
	ans += a[3] / 2 * 2;
	ans += a[4] / 2 * 2;
	long long b = a[3] & 1;
	long long c = a[4] & 1;
	if (a[0] && b && c) {
		a[0]--;
		ans += 3;
	}
	else if (a[0] % 2 == 1 && b + c == 1) {
		if (b == 0) {
			if (a[3]) {
				ans++;
				a[0]--;
			}
		}
		else {
			if (a[4]) {
				ans++;
				a[0]--;
			}
		}
	}
	ans += a[0] / 2 * 2;
	ans += a[1];
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    for(int x=min(a, b); ; --x){
        if(a % x == 0 && b % x == 0){
            -- k;
            if(k == 0){
                cout << x << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  string S;
  cin>>S;
  int n=S.size();
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=S.at(i)-'0';
  }
  if(sum==1){
    cout<<10<<endl;
  }else{
    cout<<sum<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a=1,b=1,d=1,r=0;
	double f;

	scanf("%d %d",&a,&b);

	d=a/b;
	r=a-d*b;
	f=(double)a/b;

	printf("%d %d %.5lf",d,r,f);

	return 0;
}

Measured memory_bytes: 1828
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val x = new Array[Long](N+1)
  val y = new Array[Long](N+1)
  val z = new Array[Long](N+1)

  for(i <- 1 to N) {
    val a, b, c = in.next().toLong
    x(i) = a
    y(i) = b
    z(i) = c
  }
  // println(x.deep, y.deep, z.deep)


  //
  var ans = 0L
  val hoge = Seq(-1, 1)
  for(xvol <- hoge; yvol <- hoge; zvol <- hoge) {
    val tmp = (1 to N).map { i =>
      x(i) * xvol + y(i) * yvol + z(i) * zvol
    }

    val tmp2 = tmp.sorted.reverse.slice(0, M).sum

    //println(tmp)
    ans = Math.max(ans, tmp2)
  }

  println(ans)

}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



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

typedef pair<string, pair<int, int>> S; 

bool comp(S lhs, S rhs) {
  if (lhs.first == rhs.first)
    return lhs.second.first > rhs.second.first;
  return lhs.first < rhs.first;
}

int main(void){
    int N;
    cin >> N;
    vector<S> pairs(N);
    for(int i=0;i<N;i++){
        string a;
        int b;
        cin >> a >> b;
        pairs[i] = make_pair(a,make_pair(b, i));
    }
    sort(pairs.begin(),pairs.end(),comp);
    for(int i=0;i<N;i++){
        cout << pairs[i].second.second+1<< endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)

typedef long long ll;

using namespace std;

int main(){
  string a,b;
  cin >> a >> b;
  int ai=a[0]-'0',bi=b[0]-'0';
  rep(i,bi-1)a+=a[0];
  rep(i,ai-1)b+=b[0];
  if(a>b) cout << b << endl;
  else cout << a << endl;
}


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

int A[2000005], B[2000005], C[10005];

void CountingSort(int n) {
    int k = 10000;
    for (int i = 0; i <= k; i++) C[i] = 0;

    for (int j = 0; j < n; j++) C[A[j]]++;

    for (int i = 1; i <= k; i++) C[i] += C[i - 1];

    for (int j = n - 1; j >= 0; j--) {
        B[C[A[j]] - 1] = A[j];
        C[A[j]]--;
    } 
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    CountingSort(n);
    for (int i = 0; i < n; i++) cout << B[i] << (i != n - 1 ? " " : "\n");
}


Measured memory_bytes: 18728