akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";

vector<int> z_algorithm(string S){
    int N = S.size();
    vector<int> A(N,0);
    A[0] = N;
    int left=1;
    int len = 0;
    while(left < N){
        while(left+len < N && S[len]==S[left+len]){
            len++;
        } //文字列の頭からと、leftからの文字列の共通接頭辞の長さを求める
        A[left] = len;
        if(len == 0){
            left ++;
            continue;
        }
        int k=1;
        while(left + k < N && k + A[k] < len){
            A[left+k] = A[k];
            k++;
        }

        left += k;
        len-=k;
    }
    return A;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    vector<int> res;
    int ans = 0;
    REP(i,N){
        string sub = S.substr(i);
        res = z_algorithm(sub);
        REP(j,res.size()){
            int len = res[j];
            ans = max(ans, min(len, j));
        }
    }
    cout << ans << endl;

}
/*
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
void print(T &x) { cout << x << "\n"; }

int dp[5005][5005];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    cout << "a" << 'a';
    exit(0);
    for(int i=N-1; i>=0;i--){
        for(int j=N-1;j>i;j--){
            if (S[i] == S[j]){
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }
    int ans = 0;
    REP(i,N)REP(j,N){
        int len = min(j-i, dp[i][j]);
        ans = max(ans,len);
    }
    cout << ans << endl;

    return 0;
}
*/

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		
		num = num % 10;
		
		switch (num) {
		    case 2:
		    case 4:
		    case 5:
		    case 7:
		    case 9:
		        System.out.println("hon");
		        break;
		    case 0:
		    case 1:
		    case 6:
		    case 8:
		        System.out.println("pon");
		        break;
		    case 3:
		        System.out.println("bon");
		        break;
	        default:
	            break;
		}
	}
}

Measured memory_bytes: 35768
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		char[] moji = stdIn.next().toCharArray();
		int cnt =moji.length;
		int ans = 1;
	Outer:	for(int i = cnt-2; i >= 1; i--) {
			if(i % 2 == 0) {
				continue;
			}
			for(int j = 0; j <= i/2; j++) {
				if(moji[j]!=moji[j+1+i/2]) {
					continue Outer;
				}
			}
			ans = i+1;
			break;
			
			
		}
		
		System.out.println(ans);
		
		
		
		
		
		
		
	}

}


Measured memory_bytes: 21972
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;

	int ans = 0;
	for(int c=1;c<=N;c += 2){
		int cnt = 0;
		for(int i=1;i<=c;++i){
			if(c % i == 0) ++cnt;
		}
		if(cnt == 8) ++ans;
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 3*1e5+5;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

vi TE(maxn),TW(maxn);

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    int n;
    string s;
    cin>>n>>s;
    int w[n]={},e[n]={};
    for(int i=1;i<n;i++){
        if(s[i-1]=='W'){
            w[i]=w[i-1]+1;
        }
        else w[i]=w[i-1];
    }
    for(int i=n-2;i>=0;i--){
        if(s[i+1]=='E'){
            e[i]=e[i+1]+1;
        }
        else e[i]=e[i+1];
    }
    int ans=n;
    rep(i,n){
        ans=min(ans,e[i]+w[i]);
    }
    cout<<ans<<enl;

    return 0;
}


Measured memory_bytes: 12892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Direction
    {
        internal int l, u, lu, ru;
    }

    class Grid
    {
        readonly int n;

        char[,] map;
        Direction[,] memo;

        public Grid(int n)
        {
            this.n = n;
            map = new char[n + 1, n + 2];
            memo = new Direction[n + 1, n + 2];
        }

        public void MakeMap()
        {
            for (int i = 1; i <= n; i++)
            {
                string input = Console.ReadLine();

                for (int j = 0; j < n; j++)
                {
                    map[i, j + 1] = input[j];
                }
            }
        }

        public int SearchMax()
        {
            int ret = 0;

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    if (map[i, j] == '1')
                    {
                        memo[i, j].l = memo[i, j - 1].l + 1;
                        ret = Math.Max(ret, memo[i, j].l);

                        memo[i, j].u = memo[i - 1, j].u + 1;
                        ret = Math.Max(ret, memo[i, j].u);

                        memo[i, j].lu = memo[i - 1, j - 1].lu + 1;
                        ret = Math.Max(ret, memo[i, j].lu);

                        memo[i, j].ru = memo[i - 1, j + 1].ru + 1;
                        ret = Math.Max(ret, memo[i, j].ru);
                    }
                }
            }
            return ret;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Grid g = new Grid(n);
                g.MakeMap();
                sb.AppendLine(g.SearchMax().ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 12936
/*
[abc099] C - Strange Bank
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100000;

int N;

int solve() {
    int ans = N;
    for (int t = 0; t <= N; t++) {
        int cnt = 0;
        for (int i = t; i > 0; i /= 6) {
            cnt += i % 6;
        }
        for (int i = N - t; i > 0; i /= 9) {
            cnt += i % 9;
        }
        ans = min(ans, cnt);
    }
    return ans;
}

int main() {
    cin >> N;

    cout << solve() << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

class cake {
public:
  i64 sum;
  i32 a, b, c;
  bool operator<(const cake &that) const {
    if (sum == that.sum) {
      if (a == that.a) {
        if (b == that.b) {
          return c < that.c;
        } else {
          return b < that.b;
        }
      } else {
        return a < that.a;
      }
    } else {
      return sum < that.sum;
    }
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i32 x, y, z, k;
  cin >> x >> y >> z >> k;
  vi64 a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  sort(all(a), greater<i64>());
  sort(all(b), greater<i64>());
  sort(all(c), greater<i64>());
  priority_queue<cake> que;
  set<cake> s;
  que.push({a[0] + b[0] + c[0], 0, 0, 0});
  rep(_, k) {
    auto q = que.top();
    que.pop();
    if (s.find(q) == s.end()) {
      cout << q.sum << endl;
      s.insert(q);
    } else {
      _--;
      continue;
    }
    if (q.a < x - 1) {
      que.push({a[q.a + 1] + b[q.b] + c[q.c], q.a + 1, q.b, q.c});
    }
    if (q.b < y - 1) {
      que.push({a[q.a] + b[q.b + 1] + c[q.c], q.a, q.b + 1, q.c});
    }
    if (q.c < z - 1) {
      que.push({a[q.a] + b[q.b] + c[q.c + 1], q.a, q.b, q.c + 1});
    }
  }
  return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, A;
    cin >> N >> A;
    int tmp = N % 500;
    if (tmp <= A) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
}


Measured memory_bytes: 256
from collections import deque
INF = float('inf')
ROAD = '.'
WALL = '#'
STEPS = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def main():
    H,W = map(int, input().split())
    maze = [None]*H
    white = 0
    
    for i in range(H):
        maze[i] = list(input())
        for j in range(W):
            if maze[i][j] == ROAD:
                white += 1
                maze[i][j] = INF
    
    # mazeにはその地点に到達するまでに必要な白の枚数を記録
    maze[0][0] = 1
    que = deque([[0, 0]])

    while que:
        y,x = que.popleft()

        for (i, j) in STEPS:
            ny, nx = y+i, x+j
            if ny < 0 or ny >= H or nx < 0 or nx >= W:
                continue
            
            target = maze[ny][nx]
            if target != WALL:
                if target > maze[y][x]+1:
                    maze[ny][nx] = maze[y][x] + 1
                    que.append([ny,nx])
    
    if maze[H-1][W-1] == INF:
        print(-1)
    else:
        print(white - maze[H-1][W-1])
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  if (A + B >= A - B && A + B >= A * B){
    cout << A + B << endl;
  }
  else if ( A - B >= A + B && A - B >= A *B ){
    cout << A - B << endl;
  }
  else {
    cout << A * B << endl;
  }
}


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

int main(){
    int a,b;
    
    cin >> a >> b;
    
    if(a > b){
        cout << "a > b"<<endl;
    }if(a < b){
        cout << "a < b"<<endl;
    }if(a == b){
        cout << "a == b"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		String relation;

		if(a > b){
			relation = ">";
		}else if(a < b){
			relation = "<";
		}else{
			relation = "==";
		}

		System.out.printf("a %s b\n", relation);
	}
}




Measured memory_bytes: 26352
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

const int MOD = 1000000007;

void add(int& x, int y){
    x = (x + y) % MOD;
}

bool match(char c, int k){
    if(c == '?') return true;
    return c - '0' == k;
}

int main(){
    string s, t, w;
    while(cin >> s >> t >> w){
        int n = s.size();
        int cur[2] = {};
        cur[0] = 1;
        reverse(s.begin(), s.end());
        reverse(t.begin(), t.end());
        reverse(w.begin(), w.end());
        for(int i = 0; i < n; i++){
            int next[2] = {};
            for(int x = (i < n - 1 ? 0 : 1); x < 10; x++) if(match(s[i], x)) {
                for(int y = (i < n - 1 ? 0 : 1); y < 10; y++) if(match(t[i], y)) {
                    for(int a = 0; a < 2; a++){
                        int z = (x + y + a) % 10;
                        if(z == 0 && i == n - 1) continue;
                        int b = (x + y + a) / 10;
                        if(match(w[i], z)) {
                            add(next[b], cur[a]);
                        }
                    }
                }
            }
            memcpy(cur, next, sizeof(cur));
        }
        cout << cur[0] << endl;
    }
    return 0;
}

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

int func(int z){
  int val;
  
  return val;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int x1,y1,x2,y2;
  cin >> x1>>y1>>x2>>y2;
  int x = x2-x1; 
  int y = y2-y1;
  cout << x2-y << " " << y2+x <<" " << x1-y << " " << y1 + x;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>
#include <climits>
#include <set>
#include <numeric>

using namespace std;

double sq(double x){return x*x;}

int main(){
	int l[10],v1,v2;
	while(~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",l,l+1,l+2,l+3,l+4,l+5,l+6,l+7,l+8,l+9,&v1,&v2)){
		int len = accumulate(l,l+10,0);
		double left = (double)len * v1 / (v1 + v2);
		for (int i = 0; i < 10; i++)
		{
			left -= l[i];
			if(left <= 0){
				printf("%d\n",i+1);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
s = [list(input()) for i in range(n)]
cnt=0
for i in range(n):
    for j in range(m):
        if s[i][j]=='#':
            cnt+=1
if cnt>n+m-1:
    print('Impossible')
else:
    print('Possible')


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

using namespace std;
using ll = long long;

int main() {
	long long int N, M, tmp, ans = 0; 

	cin >> N >> M;
	
	if (N >= 3 && M >= 3) {
		ans = (N - 2) * (M - 2);
	}
	else if (N == 2 || M == 2) {
		ans = 0;
	}
	else if (N == 1 && M == 1) {
		ans = 1;
	}
	else if (N == 1 || M == 1) {
		ans = max(N, M) - 2;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3136
var s:string;
    a:array['A'..'Z'] of byte;
    i:integer;
    _i:char;
begin
  readln(s);
  for i:=1 to length(s) do 
    inc(a[s[i]]);
  i:=0;
  for _i:='A' to 'Z' do if a[_i] = 2 then inc(i);
  if i = 2 then write('Yes') else write('No')
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
using namespace std;
/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main()
{
	kira;
    lli T=1;
    //cin>>T;
    while(T--)
    {
    	lli n;
        cin>>n;
        string a,b,s="";
        cin>>a>>b;
        forz(i,n)
            s+=(char)a[i],s+=(char)b[i];
        cout<<s<<endl;        
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            n = 0
            while str(i) != S[n] and n < N-3:
                n += 1
            if S[n] != str(i):
                break
            n += 1
            while str(j) != S[n] and n < N-2:
                n += 1
            if S[n] != str(j):
                break
            n += 1
            while str(k) != S[n] and n < N-1:
                n += 1
            if S[n] == str(k):
                ans += 1
print(ans)

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

int main() {
  long long N;
  cin>>N;
  vector<long long> A(N);
  
  long long start=0,end=N-1;
  long long Ans=1000,kabu=0;
  
  rep(i,N){cin >> A.at(i);}
 
  while(end!=0&&A.at(end)<A.at(end-1)){end--;}
  
   for(long long i=0;i<=end;i++){
     while(i!=end&&A.at(i)==A.at(i+1)){i++;}
     while(i!=end&&A.at(i)>A.at(i+1)){i++;}
     kabu=Ans/A.at(i);
     Ans=Ans%A.at(i);
     while(i!=end&&A.at(i)<=A.at(i+1)){i++;}
     Ans=Ans+A.at(i)*kabu;
     kabu=0;
  }
     Ans=Ans+A.at(end)*kabu;
     cout<<Ans<<endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            int[] dp = new int[n + 10];
            dp[0] = 1;
            for (int i = 0; i < n + 1; i++) {
                dp[i + 1] += dp[i];
                dp[i + 2] += dp[i];
                dp[i + 3] += dp[i];
            }
            dp[n] /= 10;
            System.out.println(dp[n] / 365 + 1);
        }
    }

}

Measured memory_bytes: 17180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

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

	LL A, B, C;
	int K;
	cin >> A >> B >> C;
	cin >> K;

	int i=0;
	if(B <= A){
		while(true){
			B *= 2;
			i++;
			if(B > A){
				break;
			}
		}
	}
	if(C <= B){
		while(true){
			C *= 2;
			i++;
			if(C > B){
				break;
			}
		}
	}

	if(i <= K){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(s.at(n-1) == 's'){
    s += 'e';
    s += 's';
  } 
  else s += 's';
  cout << s << endl;
}

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

int N, D, arr[10][10];

bool valid(int x, int y){
	int sum = 0;
	for(int i = 0; i < D; i++) sum += (arr[x][i] - arr[y][i]) * (arr[x][i] - arr[y][i]);
       	double val = sqrt(sum);
	return (val == (double)((int)val));       
}

int main(){		
	int res = 0;
	scanf("%d%d", &N, &D);
	for(int i = 0; i < N; i++)
		for(int j = 0; j < D; j++) scanf("%d", &arr[i][j]);
	for(int i = 0; i < N - 1; i++)
		for(int j = i + 1; j < N; j++)
			if(valid(i, j)) res++;
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 256
//=========================================c++
/* ===========================================
// 20.04.03 日立製作所 社会システム事業部 プログラミングコンテスト2020 - B. Nice Shopping
// 
// 
=========================================== */
/* ===========================================

あなたは、冷蔵庫と電子レンジを買うために、とある家電量販店に来ました。

この家電量販店では、 A 種類の冷蔵庫と B 種類の電子レンジが販売されています。 
i 番目( 1≤i≤A )の冷蔵庫の値段は ai 円であり、 j 番目( 1≤j≤B )の電子レンジの値段
は bj 円です。また、あなたは M 種類の割引券を所持しており、 i 番目 ( 1≤i≤M )の
割引券では、 xi 番目の冷蔵庫 と yi 番目の電子レンジを同時に買うと、 支払総額が 
ci 円安くなります。ただし、複数の割引券を同時に使うことはできません。

さて、あなたは冷蔵庫と電子レンジをちょうど1 台ずつ買おうと思っています。
かかる金額の最小値を求めてください。

test input:
1 1 2
10
10
1 1 5
1 1 10


2 2 1
3 5
3 5
2 2 2

=========================================== */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define ET "\n"
#define CLR(arr) memset(&arr, 0, sizeof(arr))
#define PAIR pair<int, int>
const ll INF = 1LL << 50;

static struct GV{
    int A, B, M;
    vector<int> renzi;
    vector<int> reizo;
}gv;

void build(){
    cin >> gv.A >> gv.B >> gv.M;
    rep (i, gv.A) {
        int buf; cin >> buf;
        gv.renzi.push_back(buf);
    }
    rep (i, gv.B) {
        int buf; cin >> buf;
        gv.reizo.push_back(buf);
    }
}

void solve(){
    
    int renzi_min = *min_element(gv.renzi.begin(), gv.renzi.end());
    int reizo_min = *min_element(gv.reizo.begin(), gv.reizo.end());
    
    int ans = renzi_min + reizo_min;
    
    rez (i, gv.M) {
        int rx, ry, rc;
        cin >> rx >> ry >> rc;
        
        int ans_buf = gv.renzi[rx - 1] + gv.reizo[ry - 1] - rc;
        ans = min(ans, ans_buf);
    }
    
    cout << ans;
}

int main(){
    build();
    solve();
    
}



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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a=in<ll>();
    ll b=in<ll>();
    string ans;

    if(a<0&&b>0){
        ans="Zero";
    }else if(a>0){
        ans="Positive";
    }else{
        if((b-a)%2==0){
            ans="Negative";
        }else{
            ans="Positive";
        }
    }
    print(ans);
    return 0;
}

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

using namespace std;

typedef long long ll;

ll H, W, D, Q;
struct Square {
    ll i;
    ll j;
};
Square A[90001];
ll d[90001] = {};

int main()
{

    cin >> H >> W >> D;
    for (int i = 1; i <= H; ++i)
    {
        for (int j = 1; j <= W; ++j)
        {
            struct Square s = {i, j};
            ll p;
            scanf("%lld", &p);
            A[p] = s;
        }
    }

    for (int i = D + 1; i <= H * W; ++i)
    {
        struct Square prev = A[i - D];
        d[i] = d[i - D] + abs(A[i].i - prev.i) + abs(A[i].j - prev.j);
    }

    cin >> Q;

    ll result[Q];
    for (int q = 0; q < Q; ++q)
    {
        int L, R;
        scanf("%d", &L);
        scanf("%d", &R);

        result[q] = d[R] - d[L];
    }

    for (int q = 0; q < Q; ++q)
    {
        printf("%lld\n", result[q]);
    }

    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
// https://atcoder.jp/contests/abc159/submissions/11134399
const int INF = 1e9; 

int main() {
    int h, w, K; 
    cin >> h >> w >> K;
    vector<string> s(h); 
    rep(i, h) {
        string l;
        cin >> s[i];
    } 
    vector<vector<int>> dp(h+1, vector<int>(w+1, 0));
    rep(i, h) rep(j, w) {
        if (s[i][j] == '1') dp[i+1][j+1] = 1;
    }
    rep(i, h+1) rep1(j, w+1) {
        dp[i][j] += dp[i][j-1];
    }
    rep1(i, h+1) rep(j, w+1) {
        dp[i][j] += dp[i-1][j];
    }
    
    int ret = INF;
    rep(i, 1 << (h-1)) {
        vector<int> v;
        v.push_back(0);
        rep(j, h - 1){
            if ((i >> j) & 1) 
                v.push_back(j+1); 
        }
        v.push_back(h);
        int sum = v.size() - 2;
        int bef = 0;
        for(int j = bef; j < w; j++) {
            int flag = 0; 
            rep(k, v.size()-1) {
                if (dp[v[k+1]][j+1] - dp[v[k+1]][bef] - dp[v[k]][j+1] 
                    + dp[v[k]][bef] > K) {
                        if (bef == j) {
                            flag = 1;
                            sum = INF;
                            break;
                        }
                        bef = j;
                        sum++;
                        break;
                    }
            }
            if (flag == 1) break;
        }
        ret = min(ret, sum);
    }
    cout << ret << endl;
    return 0;
}

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

int main() {
  
  string s;
  cin >> s;
 
  int n = s.size();
 
  REP(i,n) {
    cout << 'x';
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int H,W;
    cin >> H >> W;
    char C[2*H][W];
    rep(h,H){
        rep(w,W){
            cin >> C[2*h][w];
            C[2*h+1][w] = C[2*h][w];
        }
    }
    rep(h,2*H){
        rep(w,W){
            cout << C[h][w];
        }
        cout << endl;
    }
}

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

int main() {
  int n, a, b; cin >> n >> a >> b;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    int dsum = 0;
    int k = i;
    while (k > 0) {
      dsum += k % 10;
      k /= 10;
    }
    if (a <= dsum && dsum <= b)
      res += i;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
k, a, b = map(int, input().split())
if b-a <= 1:
    ans = k+1
else:
    if k-1 >= a:
        r = k-a+1
        if r%2 == 0:
            ans = a+(b-a)*(r//2)
        else:
            ans = a+(b-a)*((r-1)//2)+1
    else:
        ans = k+1
print(ans)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if l, r := a+b, c+d; l < r {
		fmt.Println("Right")
	} else if l == r {
		fmt.Println("Balanced")
	} else {
		fmt.Println("Left")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	

	int n;
	
	while(cin>>n){
		int s=1;
		
		for(int i=1;i<=n;i++)
			s+=i;
		
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#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 INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
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);}

ll n,ans;
ll a[200010];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)a[i]-=i+1;
	sortup(a,n);
	ll temp=a[n/2];
	rep(i,0,n)ans+=llabs(a[i]-temp);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

// struct path
// {
//     pair<ll, ll> f;
//     pair<ll, ll> t;
// };

// struct cmp
// {
//     bool operator() ( path a, path b ) const
//     { return std::make_pair(a.f,a.t) > std::make_pair(b.f,b.t) ; }
// };

void solve()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ll mini = min(k, a);
    ans+=mini;
    k-=a;
    k-=min(b,k);
    mini = LONG_LONG_MAX;
    mini = min(c,k);
    ans-=mini;
    cout<<ans<<endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main (){
    vector <int> sum;
    int a,b,entrada,aux_a,aux_b;
    cin>>entrada;
    for(int i=0; i<entrada-1;i++){
        aux_b = 0;
        aux_a = 0;
        a=i+1;
        b=entrada-a;
        while(b!=0){
            aux_b += b%10;
            b = b/10;
        }
        while(a!=0){
            aux_a += a%10;
            a = a/10;
        }
        sum.push_back(aux_a+aux_b);
    }
    sort(sum.begin(),sum.end());
    cout<<sum[0]<<endl;
    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
int main(void){
ll n,x;
cin>>n>>x;
vector<ll> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
ll ans=0;
if(a[0]>x){
	ans+=a[0]-x;
a[0]=x;
}
for(ll i=1;i<n;i++){
if(a[i-1]+a[i]>x){
	ans+=a[i-1]+a[i]-x;
	if(a[i-1]<=x){
	a[i]-=a[i-1]+a[i]-x;
	}else{
	a[i]=0;
	}

}


}

cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

vector<ll> A ;
ll cost(ll N ){
  ll ans = 0;
  rep(i,A.size())
    ans  += ((N-A[i])*(N-A[i]));
  return ans ;
}


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

  ll N ; cin >> N;

  rep(i,N){
    ll inp; cin >> inp;
    A.pb(inp);
  }

  ll ans = 1e10;
  for(ll i = -100 ; i <= 100; i++)
    ans = min(ans, cost(i));
  
  cout << ans << endl;
  

  
  //cout << fixed << setprecision(16) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int n;cin>>n;
V<int> a(n);
for(int i=0;i<n;i++)cin>>a[i];
if(n>24){
    cout<<0<<endl;
    return 0;
}
 if(n>13){
    V<int> cnt(n);
    cnt[0]++;
    for(int i=0;i<n;i++){
        cnt[a[i]]++;
        if(cnt[0]==2||cnt[a[i]]==3){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
    return 0;
}
int ans=0;
for(int bit=0;bit<(1<<n);bit++){
    V<int> d(n+1);
    for(int i=0;i<n;i++){
        if(a[i]==0||bit&(1<<i))d[i]=a[i];
        else d[i]=24-a[i];
    }
    d[n]=0;
    int res=INT_MAX;
    for(int i=0;i<n+1;i++){
        for(int j=i+1;j<n+1;j++){
            int t=abs(d[i]-d[j]);
            if(t>12)t=24-t;
              chmin(res,t);
        }
    }
    chmax(ans,res);
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{

    int x, y, z;
    cin >> x >> y >> z;
    int ans = 0;
    x -= z;

    cout << x / (y + z) << endl;
    return 0;
}


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

using ll = long long;

int main() {
   int n;
   cin >> n;
   map<ll, ll> mp;
   for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      mp[a]++;
   }

   ll ans = 0;
   for (auto x : mp) {
      if (x.second % 2 == 1) ans++;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n;cin>>n;
  int res=48-n;
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);

	const int m1 = s[0], d1 = s[1];

	AtCoder::input(&s);

	const int m2 = s[0], d2 = s[1];

	if (m1 != m2) {
		printf("1\n");
	} else {
		printf("0\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int l,r,up,ans;
int main()
{
	ans=2020;
	scanf("%d%d",&l,&r);
	up=min(r,l+2019); 
	for(int i=l;i<=up;++i)
	{
		for(int j=i+1;j<=up;++j)
		ans=min(1ll*ans,(1ll*i*j)%2019);
	}
	printf("%d\n",ans);
    return 0;
}

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

int diff(string &a, string &b) {
	int res = 0;
	assert(a.size() == b.size());
	for (int i = 0; i < a.size(); i++) {
		res += a[i] != b[i];
	}
	return res;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = t.size();
	for (int i = 0; i <= (int)s.size() - (int)t.size(); i++) {
		string s_sub = s.substr(i, t.size());
		ans = min(ans, diff(s_sub, t));
	}
	cout << ans;
}



Measured memory_bytes: 3596
import sys

def warn(*m):
    print(m, file=sys.stderr)

D,*CS = map(int, open(0).read().split())
C = CS[:26]
S = [CS[26*i:26*(i+1)] for i in range(1, D+1)]

def imax(xs):
    m = -1
    i = 0
    for j, x in enumerate(xs):
        if x > m:
            i = j
            m = x
    return i

def ratio(xs):
    s = sum(xs)
    return [x / s for x in xs]

ds = [0] * 26

def pick(d):
    s = ratio(S[d])
    c = ratio([(1 + d - ds[i]) * x for i, x in enumerate(C)])
    return imax([x * y + y for x, y in zip(s, c)])

for d in range(D):
    i = pick(d)
    ds[i] = d + 1
    print(i + 1)


Measured memory_bytes: 10192
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define fix(n) fixed << setprecision(n)

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    
    ll n;
    cin >> n;

    vll v(n);
    rep(i,n) cin >> v[i];
    ll i = 1;
    ll count = 0;
    vll light(n,0);
    light[0] = 1;
    while(i != 2){
        light[i-1] = 1;
        i = v[i-1];
        count++;
        if(light[i-1] == 1){
            cout << -1;
            return 0;
        }
    }

    cout << count << endl;
    
    return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ss s;
    ll c1=0,c0=0;
    cin >> s;
    rep(i,SIZE(s)){
        if(s[i]=='0')c0++;
        else c1++;
    }
    cout << 2*min(c0,c1) << endl;
    return 0;
}


Measured memory_bytes: 512
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
K = int(input())
A,B = map(int,input().split())
c = 0
for i in range(A,B+1):
    if i % K == 0:
        c = 1
        break
if c == 1:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A<=8 && B<=8) {
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    a--; b--; c--; d--;
    string s; cin >> s;
    rrep(i, a + 2, c) {
        if (s[i - 1] == '#' && s[i] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    rrep(i, min(b + 2, (int)s.size()), d) {
        if (s[i - 1] == '#' && s[i] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if (c < d) {
        //先のやつが先に
        //岩が2個連続でなければ
        cout << "Yes" << endl;
        return 0;
    }
    rrep(i, b + 1, min(d + 1 + 1, (int)s.size())) {
        if (i - 2 < 0) continue;
        if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 592
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()

using namespace std;

int main () {
  string s;cin>>s;
  if(s[s.size()-1]=='s')s+="es";
  else s+="s";
  cout <<s<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int m=1e9+7;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>>v(h+1,vector<char>(w+1));
    for(int i=1;i<=h;i++){
         for(int j=1;j<=w;j++){
              cin>>v[i][j];
         }
    }
    vector<vector<int>>dp(h+1,vector<int>(w+1,0));
    dp[1][1]=1;
    for(int i=1;i<=h;i++){
         for(int j=1;j<=w;j++){
              if(i>1&&v[i-1][j]!='#'){
                   dp[i][j]=(dp[i][j]%m+dp[i-1][j]%m)%m;
              }
              if(j>1&&v[i][j-1]!='#'){
                   dp[i][j]=(dp[i][j]%m+dp[i][j-1]%m)%m;
              }
         }
    }
    cout<<dp[h][w]<<endl;
}

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

res = 0
while max(h) > 0:
    i = 0
    while i < n:
        if h[i] == 0:
            i += 1
            continue

        res += 1
        while i < n and h[i] > 0:
            h[i] -= 1
            i += 1

print(res)

Measured memory_bytes: 39152