akhauriyash/Code-Regression huggingface dataset:
using System;

namespace EDPC
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            // initialize
            long[] h = new long[N];
            for (int i = 0; i < N; i++)
            {
                h[i] = int.Parse(input[i]);
            }

            // 初期条件
            long H = 100010;
            long[] dp = new long[N];
            for (int i = 0; i < N; i++)
            {
                dp[i] = H;
            }
            dp[0] = 0;
            dp[1] = Math.Abs(h[1] - h[0]);

            for (int i = 2; i < N; i++)
            {
                dp[i] = Math.Min(dp[i - 1] + Math.Abs(h[i] - h[i - 1]), dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
            }
            Console.WriteLine(dp[N - 1]);
        }

        //static void chmax(ref long a, long b) { if (a < b) { a = b; } }
        //static void chmin(ref long a, long b) { if (a > b) { a = b; } }

    }
}


Measured memory_bytes: 17632
#include<stdio.h>
int main(){
int a,b,c,d;
scanf("%d %d %d %d\n",&a,&b,&c,&d);
a=a*b,c=c+d;
if(a%2==1 && c%2==1){
printf("No\n");
}
else{
printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 2048
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
use std::cmp::min;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",min(a*b,c))
}

Measured memory_bytes: 4352
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


int main()
{
	char s[16];
	char a[16] = {0};

	scanf("%s", s);
	for(int i = 0; i < 4; ++i) a[i] = s[i];
	a[4] = ' ';
	for(int i = 0; i < 8; ++i) a[5 + i] = s[4 + i];
	printf("%s\n", a);

	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string rep;
char ans[222],fir;

int main(void){
	int n,i,j,l,r,x,y,m;
	cin >> n;
	l = 0; r = n;
	fill(ans,ans+222,'@');
	cout << "?";
	for(j=1; j<=n; ++j){
		cout << " " << (j);
	}
	cout << endl;
	cout.flush();
	cin >> rep;
	if(rep[0]=='-'){
		return 0;
	}
	fir = rep[0];
	while(r-l>1){
		m = (l+r)/2;
		cout << "?";
		for(j=1; j<=n; ++j){
			cout << " " << (m+j);
		}
		cout << endl;
		cout.flush();
		cin >> rep;
		if(rep[0]=='-'){
			return 0;
		}
		if(rep[0]==fir){
			l = m;
		}else{
			r = m;
		}
	}
	r = l+n; ++l;
	for(i=0; i<n*2; ++i){
		if(l<=i && i<r){
			continue;
		}
		cout << "? " << (i+1);
		for(j=l; j<r; ++j){
			cout << " " << (j+1);
		}
		cout << endl;
		cout.flush();
		cin >> rep;
		if(rep[0]=='-'){
			return 0;
		}
		ans[i] = rep[0];
	}
	for(i=l; i<r; ++i){
		cout << "? " << (i+1);
		x = (n-1)/2; y = (n-1)/2;
		for(j=0; j<2*n; ++j){
			if(l<=j && j<r){
				continue;
			}
			if(x && ans[j]=='R'){
				--x;
				cout << " " << (j+1);
			}
			if(y && ans[j]=='B'){
				--y;
				cout << " " << (j+1);
			}
		}
		cout << endl;
		cout.flush();
		cin >> rep;
		if(rep[0]=='-'){
			return 0;
		}
		ans[i] = rep[0];
	}
	cout << "! ";
	for(i=0; i<n*2; ++i){
		cout << ans[i];
	}
	cout << endl;
	cout.flush();
	return 0;
}


Measured memory_bytes: 724
#include <stdio.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if (k > a)
    {
        ans += a;
        k -= a;
    }
    else
    {
        ans += k;
        cout << ans << endl;
        return 0;
    }
    if (k <= b)
    {
        cout << ans << endl;
        return 0;
    }
    k -= b;
    ans -= k;
    cout << ans << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  int maxh = 0;
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
    maxh = max(h.at(i),maxh);
  }

  bool flag = true;
  int ans = 0;
  for (int i = 0; i < maxh; i++) {
    for (int j = 0; j < N; j++) {
      if (h.at(j) > 0) {
		h.at(j)--;
		if (flag) {
	  	  ans++;
	   	  flag = false;
		}
      }
      else {
		flag = true;
      }
      if (j == N - 1) {
		flag = true;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			if (!(a % 3 == 0 || a % 5 == 0)) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}

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



int main(){
	bool ok = false;
	string s;
	cin >> s;
	for(int i=1;i<s.size();i++){
		if(s[i]=='C'&&s[i-1]=='A') ok=true;
	}
	cout << (ok?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

import sys

input = sys.stdin.readline
R = [[] for _ in range(n)]
Sin = [-1]*n
Dis = [-1]*n
Sin[0] = 0
Dis[0] = 0

for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  R[a].append(b)
  R[b].append(a)

from collections import deque

d = deque()
d.append(0)

while len(d):
  cur = d.popleft()
  for to in R[cur]:
    if Dis[to]<0:
      Dis[to] = Dis[cur] + 1
      Sin[to] = cur + 1
      d.append(to)

if min(Dis)<0:
  print('No')
  sys.exit()
print('Yes')
for i in range(1,n):
  print(Sin[i])


Measured memory_bytes: 93668
"use strict";

/**
 * @see https://practice.contest.atcoder.jp/tasks/practice_1
 * @param  {string} input
 * @returns {string}
 */
var main = function(input) {
    const params = input.split("\n")[1];
    const cards = input.split("\n")[1]
        .split(" ")
        .map(x => parseInt(x))
        .sort((a, b) => b - a);
    
    const alice = cards.filter((x, i) => i % 2 === 0)
        .reduce((a, b) => a + b);
    const bob = cards.filter((x, i) => i % 2 === 1)
        .reduce((a, b) => a + b);
    return alice - bob;
};

const output = main(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(output); // console.log outputs with trailing new line!


Measured memory_bytes: 7500
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto x = readln.chomp.to!int;
  writeln(x ^^ 3);
}

Measured memory_bytes: 2440
n,m = map(int, input().split())
#print(n, m)
l = []
for i in range(n):
    a = [int(_) for _ in input().split()]
    l.append(a[1:a[0]+1])
#print(l)
y = []
for j in range(1,m+1):
    x = 0
    for k in range(n):
        if j in l[k]:
            x += 1
    if x == n:
        y.append(1)
print(len(y))


Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int a, b;
    char op;
    while(1){
    scanf("%d %c %d", &a, &op, &b);
    if(op == '?'){
        break;
    }
    if(op == '+'){
        a += b; 
    }else if(op == '-'){
        a -= b;
    }else if(op == '*'){
        a *= b;
    }else if(op == '/'){
        a /= b;
    }
    printf("%d\n", a);
    }
    return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REPB(i,n) for(long long i=((n)-1);i>=0;i--)
#define REPB1(i,n) for(long long i=(n);i>0;i--)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
typedef long long ll;
typedef pair<int,int> pii;
//---------------------
#define MAXN 200000
//---------------------
string s;
ll a,b,c,d,n;
int main(){
	cin>>n>>a>>b>>c>>d;
	cin>>s;
	a--;b--;c--;d--;
	bool flag=true;
	int num=0;
	for(int i=a;i<max(c,d);i++){
		char c=s[i];
		if(c=='#'){
			num++;
			if(num==2) {flag=false;break;}
		}else num=0;
	}
	if(flag){
		if(d<c){
		  	int num=0;
		  	flag=false;
			for(int i=b-1;i<=min(n-1,d+1);i++){
				char c=s[i];
				if(c=='.'){
					num++;
					if(num==3){
						flag=true;
						break;
					}
				}else num=0;
			}
		}
	}
	YNPRT(flag);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);

  if(a != b && b != c && c != a) printf("3\n");
  else if(a == b && b == c && c == a) printf("1\n");
  else printf("2\n");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;
using lli = long long int;
using tlli3 = tuple<lli, lli, lli>;

lli D[200] = {};

int main(void) {

	lli N, K, ans = 0;
	cin >> N >> K;

	std::vector<lli> vec;

	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}

	for (int l = 0; l < N; l++) {
		for (int r = l; r <= N; r++) {

			if (l + N - r > K)
				continue;

			lli t = 0;

			for (int i = 0; i < l; i++) {
				t += D[i];
				vec.push_back(D[i]);
			}
			for (int i = r; i < N; i++) {
				t += D[i];
				vec.push_back(D[i]);
			}

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

			for (int i = 0; i < min(K - (l + N - r), (lli)vec.size()); i++) {
				if (vec[i] < 0)
					t -= vec[i];
			}

			vec.clear();

			ans = max(ans, t);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    int bl[n]={0},wh[n]={0};
    for (i=0;i<n;i++)
    {
        if (s[i]=='#')
            bl[i]++;
        else
            wh[i]++;
        if (i!=0)
            bl[i]+=bl[i-1];
    }
    for (i=n-2;i>=0;i--)
        wh[i]+=wh[i+1];
    int ans=n;
    for (i=0;i<n-1;i++)
        ans=min(ans,bl[i]+wh[i+1]);
    ans=min(ans,bl[n-1]);
    ans=min(ans,wh[0]);
    cout<<ans<<endl;
}

Measured memory_bytes: 2196
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def solve(n, k):
    MOD = 10 ** 9 + 7
    facts, invs = prepare(2 * n, MOD)
    if k >= n - 1:
        return facts[2 * n - 1] * invs[n - 1] * invs[n] % MOD

    ans = 0
    for z in range(k + 1):
        tmp = facts[n] * invs[z] * invs[n - z] % MOD
        tmp = tmp * facts[n - 1] * invs[z] * invs[n - z - 1] % MOD
        ans = (ans + tmp) % MOD

    return ans


n, k = list(map(int, input().split()))
print(solve(n, k))


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long sum = 0;
  long long cnt1 = 0;
  for (int i = 0; i < N; i++) {
    sum += A[i];
    if (i % 2 == 0 and sum <= 0) {
      cnt1 += 1 - sum;
      sum = 1;
    } else if (i % 2 == 1 and sum >= 0) {
      cnt1 += sum + 1;
      sum = -1;
    }
  }
  sum = 0;
  long long cnt2 = 0;
  for (int i = 0; i < N; i++) {
    sum += A[i];
    if (i % 2 == 0 and sum >= 0) {
      cnt2 += sum + 1;
      sum = -1;
    } else if (i % 2 == 1 and sum <= 0) {
      cnt2 += 1 - sum;
      sum = 1;
    }
  }
  cout << min(cnt1, cnt2) << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
ll mulmod(ll a,ll b,ll c) 
{ 
    if (b==0) 
        return 0; 
    ll s = mulmod(a, b/2, c); 
    if (b%2==1) 
        return (a%c+2*(s%c)) % c; 
 
    else
        return (2*(s%c)) % c; 
} 

  
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{ll int t;
t=1;
//cin>>t;

while(t--)
{ll int h,n,i,j;
cin>>h>>n;
ll int w[n],v[n];
ll int dp[n+1][h+1];
for(i=0;i<n;i++)
{
    cin>>w[i]>>v[i];
}

for(i=0;i<=n;i++)
{ for(j=0;j<=h;j++)
   {   if(j==0)
   
       {dp[i][j]=0;
       continue;}
   
       if(i==0)
       {dp[i][j]=INT_MAX;
       continue;}
       else
       {   if(j-w[i-1]>=0)
           dp[i][j]=min(dp[i-1][j],dp[i][j-w[i-1]]+v[i-1]);
           else
           {dp[i][j]=min(dp[i-1][j],v[i-1]);
               
           }
           
       }
   }
}
cout<<dp[n][h]<<endl;
    
}
 
    return 0;
}

Measured memory_bytes: 78464
N = int(input())
H = list(map(int,input().split()))
H[0] -= 1

correct ="Yes"
for i in range(N-1): 
    if H[i] == H[i+1]:
        H[i+1] = H[i+1]
    elif H[i]  < H[i+1]:
        H[i+1] -= 1
    else:
        correct = "No"
        break

print(correct)
        

Measured memory_bytes: 15020
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean ans = true;
        if (checkPalindrome(s)) {
            boolean half1 = checkPalindrome(s.substring(0, (s.length() - 1) / 2));
            boolean half2 = checkPalindrome(s.substring((s.length() + 3) / 2 - 1, s.length()));
            ans = half1 && half2;
        } else {
            ans = false;
        }
        System.out.println(ans ? "Yes" : "No");
    }

    public static boolean checkPalindrome(String str) {
        boolean res = true;
        char[] chars = str.toCharArray();
        int strLength = str.length() - 1;
        for (int i = 0; i <= strLength / 2; i++) {
            if (chars[i] != chars[strLength - i]) {
                res = false;
                break;
            }
        }
        return res;
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0 ; i < 35 ; i++) {
            boolean flg = true;
            for (int j = 0 ; j < n ; j++) {
                if (a[j] % 2 != 0) {
                    flg = false;
                }
            }
            if (flg) {
                count++;
                for (int j = 0 ; j < n ; j++) {
                    a[j] /= 2;
                }
            } else {
                break;
            }
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 23764
n, q = map(int, input().split())
s = input()
lr = []
for _ in range(q):
    l, r = map(int, input().split())
    lr.append((l, r))
li = [0]*n
accu = 0
for i in range(n-1):
    if s[i:i+2]=='AC':
        accu += 1
    li[i+1] = accu

for l, r in lr:
    print(li[r-1]-li[l-1])

Measured memory_bytes: 19732
package main 
import "fmt"
func main() {
	var str string
	fmt.Scanf("%s",&str)
	ans := 0
	sz := len(str)
	for i := 0;i < sz;i++ {
		ans += (int)(str[i] - '0')
	}
	for i := 0;i < sz;i++ {
		if str[i] != '0' {
			cnt := 0
			for j := 0;j < i;j++ {
				cnt += (int)(str[j] - '0')
			}
			if i < sz {
				cnt += (int)(str[i] - '0' - 1)
			}
			cnt += max(0,sz - 1 - i) * 9;
			ans = max(ans,cnt)
		}
	}
	fmt.Println(ans)
}
func max(a,b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 512
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var list = [];
  for(var i = 0; i < input.length; i++){
    var tmp = input.slice(i,i+1);
    if(tmp != "B"){
       list.push(tmp);
    }else if(list.length > 0){
       list.pop();      
    }
  }
  myout(list.join(""));
}

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


Measured memory_bytes: 7372
import itertools

#n桁のm値のbitを生成
def bit(n, m):
    bit_list = list(itertools.product([i for i in range(m)], repeat=n))
    return bit_list

S = input()

if len(S) > 9:
    print('NO')
else:
    bit_list = bit(len(S) + 1, 2)
    res = 'NO'
    for bit in bit_list:
        tmp_s = ''
        for i in range(len(bit)):
            if bit[i] == 1:
                tmp_s += 'A'
            if i < len(S):
                tmp_s += S[i]
       
        if tmp_s == 'AKIHABARA':
            res = 'YES'
            break
    print(res)

Measured memory_bytes: 3188
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
	if a[i]==i+1:
		ans+=1
		if i==1 and a[0]==1:
			ans-=1
		a[i],a[i+1]=a[i+1],a[i]
if a[n-1]==n:
	ans+=1
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 1000;
  rep(i, n-2) {
    int cans = stoi(s.substr(i, 3)) - 753;
    if (cans < 0) cans *= -1;
    ans = min(ans, cans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
		int N;
		cin>>N;
		vec(H)
		fx(N){
			vecp(H)
		}
		int maxi=H.at(0);
		int ans=1;
		for(int i=1;i<N;i++){
			if(maxi<=H.at(i)){
				maxi=H.at(i);
				ans++;
			}
		}
		ce(ans)
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    sp = list(input().strip())
    s = ''
    for i, c in enumerate(sp):
        if i == 0 or sp[i-1] == ' ':
            s += c.upper()
    print(s)

main()


Measured memory_bytes: 3064
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(price)
for _ in range(m):
    max_price = -heapq.heappop(price)
    heapq.heappush(price, -(max_price//2))

ans = -sum(price)
print(ans)

Measured memory_bytes: 14180
#include <stdio.h>
#include <stdlib.h>

int main ()
{
  int n,i;
  long step=0;
  long *a;

  scanf("%d",&n);
  a = calloc(n,sizeof(long));

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

  for(i=1; i<n; i++){
    if(a[i] < a[i-1]){
      step += (a[i-1]-a[i]);
      a[i] += (a[i-1]-a[i]);
    }
  }

  printf("%ld", step);
  free(a);
  return 0;
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;
    int l;
    cin>>l;
    double ans=l*l*l;
    ans/=27.00;
    cout<<fixed<<setprecision(10)<<ans;
}


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

#define ll long long
#define ar array

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

    int L = s/100;
    int R = s%100;

    if (1 <= L && L <= 12){
        if (1 <= R && R <= 12){
            cout << "AMBIGUOUS";
        }
        else{
            cout << "MMYY";
        }
    }
    else{
        if (1 <= R && R <= 12){
            cout << "YYMM";
        }
        else{
            cout << "NA";
        }
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> v;
const ll MAX = 1e5+2;
ll dp[MAX];

int main()
{
    ll n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        ll x; cin >> x;
        v.push_back(x);
    }
    //BOTTOM UP
    memset(dp,0,sizeof(dp));
    dp[n-1] = 0;
    dp[n-2] = abs(v[n-2]- v[n-1]);
    for(int i=n-3;i>=0;i--)
        dp[i] = min(abs(v[i]-v[i+1]) + dp[i+1], abs(v[i]-v[i+2]) +dp[i+2]);
    cout<<dp[0];
    return 0;
}

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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

long long solve(int N, int K, vector<long long> A)
{
    sort(A.begin(), A.end(), [&](long long a, long long b){return abs(a)>abs(b);});

    long long ans = 1;
    long long M = 1000000007LL;

    bool allneg = true;
    for (int a: A)
        if (a>=0)
            allneg = false;
    if (allneg && K%2!=0)
    {
        for (int i=0; i<K; i++)
            ans = (ans*A[N-i-1]%M+M)%M;
    }
    else
    {
        int sign = 1;
        for (int i=0; i<K; i++)
        {
            ans = (ans*A[i]%M+M)%M;
            sign *= (A[i] > 0 ? 1 : A[i] < 0 ? -1 : 0);
        }

        if (sign < 0)
        {
            long long t00 = -1;
            for (int i=K-1; i>=0 && t00==-1; i--)
                if (A[i]>0)
                    t00 = i;
            long long t01 = -1;
            for (int i=K; i<N && t01==-1; i++)
                if (A[i]<0)
                    t01 = i;
            long long t10 = -1;
            for (int i=K-1; i>=0 && t10==-1; i--)
                if (A[i]<0)
                    t10 = i;
            long long t11 = -1;
            for (int i=K; i<N && t11==-1; i++)
                if (A[i]>0)
                    t11 = i;

            if (t00!=-1 && t01!=-1 && t10!=-1 && t11!=-1 && A[t01]*A[t10]>A[t11]*A[t00] ||
                t00!=-1 && t01!=-1 && !(t10!=-1 && t11!=-1))
            {
                ans = ans*powmod((A[t00]%M+M)%M, M-2, M)%M;
                ans = (ans*A[t01]%M+M)%M;
            }
            else if (t10!=-1 && t11!=-1)
            {
                ans = ans*powmod((A[t10]%M+M)%M, M-2, M)%M;
                ans = (ans*A[t11]%M+M)%M;
            }
            else
            {
                for (long long a: A)
                    if (a==0)
                        ans = 0;
            }
        }
    }
    return ans;
}

long long naive(int N, int K, vector<long long> A)
{
    long long ans = -99999999;
    for (int b=0; b<1<<N; b++)
    {
        int c = 0;
        for (int i=0; i<N; i++)
            c += b>>i&1;
        if (c==K)
        {
            long long a = 1;
            for (int i=0; i<N; i++)
                if (b>>i&1)
                    a *= A[i];
            if (a>ans)
                ans = a;
        }
    }
    return (ans%1000000007+1000000007)%1000000007;
}

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

    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;
    cout<<solve(N, K, A)<<endl;

    //while (true)
    //{
    //    int N = rand()%8+1;
    //    int K = rand()%N+1;
    //    vector<long long> A(N);
    //    for (long long &a: A)
    //        a = rand()%17-8;

    //    if (solve(N, K, A)!=naive(N, K, A))
    //    {
    //        cout<<solve(N, K, A)<<"!="<<naive(N, K, A)<<endl;
    //        cout<<N<<" "<<K<<endl;
    //        for (long long a: A)
    //            cout<<a<<endl;
    //        break;
    //    }
    //}
}


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

int main(){
  int n,s[50],ans[50],a;
  vector<int> t;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a,s[a]=i,ans[i]=a;
  for(int i=0;i<n;i++)cin>>a,t.push_back(s[a]);
  t.push_back(-1);
  while(t.size()!=2){
    for(int i=0;i<t.size()-1;i++){
      if(t[i]>t[i+1]){
	cout<<ans[t[i]]<<" ";
	t.erase(t.begin()+i);
	break;
      }
    }
  }
  cout<<ans[0]<<endl;
  return 0;
}

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

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

  int count = 0;
  for (int i = 1; i < N; ++i) {
    count += i;
  }
  for (int i = 1; i < M; ++i) {
    count += i;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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!(
        a1 : i32,
        a2 : i32,
        a3 : i32,
    );

    let mut ans = "";
    if a1 + a2 + a3 > 21{
        ans = "bust";
    }
    else {
        ans = "win";
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
int main(){
    int a[3];
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    for(int i = 0;i<100;i++){
        sort(a,a+3);
        if(a[0]%2||a[1]%2||a[2]%2){
            printf("%d\n",i);
            return 0;
        }
        int b[3]={(a[1]+a[2])/2,(a[0]+a[2])/2,(a[0]+a[1])/2};
       // printf("%d %d %d\n",a[0],a[1],a[2]);
        a[0]=b[0];
        a[1]=b[1];
        a[2]=b[2];
    }
    printf("-1\n");
}
/*
1-n 0
2-n 1
3-n 2
-3 0
-2 1
-1 2
0 3
*/
/*
1 0
2 -10  01
3 -20 -1 1 0 2


*/
/*

k*cnt[i]-k*cnt[j]=i-j;
k*cnt[i]-i=k*cnt[j]-j
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5    3
1 2 3 5 6    4 
1 2 3 4 6
3
0 1 2
0 2 2.5

1 2 3 4 5
1 2 3 4 5
1 3
1 4
1
*/
/*
AC
AGCG
AGCGU
AT
*/

Measured memory_bytes: 256
n = int(input())
fib_ls = [0] * (n+1)
fib_ls[0], fib_ls[1] = 1,1
for i in range(2,n+1):
    fib_ls[i] = fib_ls[i-1] + fib_ls[i-2]
print(fib_ls[n])


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

int main()
{
	int k,a,b,i;
	cin >> k >> a >> b;
	
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout << "OK";
			return 0;
		}
		else
			continue;
	}
	
	cout << "NG";
	return 0;
} 

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
int main()
{
  int n,m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  priority_queue<ll> q;
  rep(i,n) q.push(a[i]);
  ll res = 0;
  rep(i,n) res += a[i];
  rep(i,m){
    ll x = q.top();
    q.pop();
    res -= (x+1)/2;
    q.push(x/2);
  }
  
  cout << res << "\n";
  
  return 0;
}


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

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    
    double t;
    double rad;
    double V = a * a * b;

    if (x * 2 > V) {
        t = 2 * x / (a * a) - b;
        rad = atan2(a, b - t);
    }
    else {
        t = x * 2 / b / a;
        rad = atan2(t, b);
    }

    cout.precision(10);
    cout << 90 - rad  * 180.0 / M_PI << endl;

    return 0;
}

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

int main(){
	char str[1024], *s;
	scanf("%[^\n]", str);
	int i=0;
	while(str[i++]!='\0');
	s = new char[i];
	for( int j=0; j<i; j++ ){
		s[j] = str[j];
		if( ('a'<=s[j])&&(s[j]<='z') ){
			s[j] -= 32;
		}
	}
	printf("%s\n", s);
	delete[] s;
	s=0;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
  string s;
	cin >> s;
  int c = 0;
  rep(i, s.size()/2) {
    if(s.at(i) != s.at(s.size() - i - 1)) {
      c++;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i, j, k, l, num;
	
	while (scanf("%d", &n) != EOF){		
		num = 0;
		
		for (i = 0; i <= 9; i++){
			for (j = 0; j <= 9; j++){
				for (k = 0; k <= 9; k++){
					for (l = 0; l <= 9; l++){
						if (i + j + k + l == n){
							num++;
						}
					}
				}
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pb push_back
#define x first
#define y second

int main()
{
	ll n,k,i,j;
	cin>>n>>k;
	ll h[n+1],c[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	c[1]=0;
	for(i=2;i<=k && i<=n;i++)
		c[i]=abs(h[i]-h[1]);
	for(i=k+1;i<=n;i++)
	{
		c[i]=c[i-1]+abs(h[i]-h[i-1]);
		for(j=i-2;j>=i-k;j--)
		{
			c[i]=min(c[i],c[j]+abs(h[j]-h[i]));
		}
	}
	cout<<c[n];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  string s,t;
  cin >> s >> t;
  int a,b; cin >> a >> b;
  string x;
  cin >> x;
  if (x == s) {
    a--;
  } else {
    b--;
  }
  cout << a << " " << b << nl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	cout<<fixed<<setprecision(20);
	double r; cin>>r;
	double ans = 2*3.14159265358979323846*r;
	cout<<ans;
	
	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << (char)(a.front() + ('A' - 'a')) <<  (char)(b.front() + ('A' - 'a')) <<  (char)(c.front() + ('A' - 'a')) << endl;
}

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

using namespace std;

int judge(int i){
    if (i == 2){
        return 3;
    }else if (i == 4 || i == 6 || i == 9 || i == 11){
        return 2;
    }else if ( i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 13){
        return 1;
    }
}
int main() {
    int x, y;
    cin >> x >> y;

    if (judge(x) == judge(y)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

string s,t;

int main(){
	cin >> s >> t;
	sort(ALL(s));
	sort(ALL(t));
	reverse(ALL(t));
	if(s < t)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 764
n,m=list(map(int,input().split()))

H=list(map(int, input().split()))
A = [input().split() for l in range(m)]

li = []

for a,b in A:
    if H[int(a)-1]<H[int(b)-1]:
        li.append((a,0))
    elif H[int(a)-1]>H[int(b)-1]:
        li.append((b,0))
    else:
        li.append((a,0))
        li.append((b,0))


di=dict(li)
print(n-len(di))
        

Measured memory_bytes: 118516
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int main() {
    int x, y; cin >> x >> y;
    int ret = 1e9 + 7;
    if (x <= y) ret = min(ret, y - x);
    if (-x <= y) ret = min(ret, y - (-x) + 1);
    if (-x <= -y) ret = min(ret, (-y) - (-x) + 2);
    if (x <= -y) ret = min(ret, (-y) - x + 1);
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=200000;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  invinit();
  inv[0]=1;
  
  long long n,a,b,c;
  cin>>n>>a>>b>>c;
  
  long long ans=0;
  long long temp;
  for(long long m=n;m<=(2*n-1);m++){
    temp = comb(m-1,n-1);
    temp = mod(temp*(mod(mod(po(a,n)*po(b,m-n))+mod(po(a,m-n)*po(b,n)))));
    temp = mod(temp*po(inv[a+b],m));
    temp = mod(temp*m);
    temp = mod(temp*100);
    temp = mod(temp*inv[100-c]);
    
    ans = mod(ans+temp);
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 4992
S = gets.chomp

que = S.chars
list = 'AKIHABARA'.chars

list.each do |ch|
  if ch == 'A'
    que.shift if que.first == 'A'
  else
    if ch != que.first
      puts 'NO'
      exit
    end

    que.shift
  end
end

if que.empty?
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 1788
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
set<pii> Edges;

int main()
{
    int N, M;
    cin >> N >> M;
    for (int m = 0; m < M; ++m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        Edges.insert(make_pair(a, b));
        Edges.insert(make_pair(b, a));
    }

    vector<int> Now;
    for (int n = 0; n < N; ++n) {
        Now.push_back(n);
    }

    int Res = 0;
    do {
        if (Now[0] != 0) break;
        bool OK = true;
        for (int n = 0; n < N-1; ++n) {
            if (Edges.count(make_pair(Now[n], Now[n+1])) == 0) {
                OK = false;
                break;
            }
        }
        if (OK) ++Res;
    } while (next_permutation(Now.begin(), Now.end()));

    cout << Res << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	ll l = 0;
	for (ll i = 0; i < n; i++) l += a[i];
	ll ans = l;
	for (ll i = 0; i < n; i++) {
		l -= 2 * a[i];
		ans = min(ans, abs(l));
	}
	cout << ans << endl;
}


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

int main()
{
    int n, lower, upper;
    cin >> n;
    int a[n], s[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s[i] = a[i];
    }
    sort(s, s+n);
    lower = s[n/2-1];
    upper = s[n/2];
    for(int i = 0; i < n; i++){
        if(a[i] <= lower) 
            cout << upper << endl;
        else{
            cout << lower << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2
const int maxn = 2e5;
bool prime[maxn+1];
void SieveOfEratosthenes(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p
            for (int i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }
}
class CNextPrime {
public:
	void solve(std::istream& in, std::ostream& out) {
        SieveOfEratosthenes(maxn);
        int n;
        s(n);
        f(i,n,maxn+1){
            if(prime[i]){
                out<<i<<endl;
                break;
            }
        }
	}
};


main() {
	CNextPrime solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n; cin>>n;
  if (n/100 == n%10) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main()
{
  solve();
  return 0;
}


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

int main()
{
  string A,B,C;
  cin >> A >> B >> C;
  char R=A.at(0), S;
  while (1){
    if(R=='a'){
      if(A.size()==0){
        S='A';
        break;
      }
      R=A.at(0);
      A.erase(0,1);
    }
    else if(R=='b'){
      if(B.size()==0){
        S='B';
        break;
      }
      R=B.at(0);
      B.erase(0,1);
    }
    else if(R=='c'){
      if(C.size()==0){
        S='C';
        break;
      }
      R=C.at(0);
      C.erase(0,1);
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-7;
const int N=200000+10,maxn=60000+10,inf=0x3f3f3f;

int f[32];
int a[N],b[N];
int main()
{
    for(int i=0;i<31;i++)
        f[i]=(1<<i);
    int n,k;
    scanf("%d%d",&n,&k);
    ll res=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        if((a[i]&k)==a[i])res+=b[i];
    }
    for(int i=30;i>=0;i--)
    {
        if(k&f[i])
        {
            ll ans=0,te=(k^f[i])|(f[i]-1);
            for(int j=0;j<n;j++)
                if((te&a[j])==a[j])
                    ans+=b[j];
            res=max(res,ans);
        }
    }
    printf("%lld\n",res);
    return 0;
}
/********************

********************/


Measured memory_bytes: 1024
N, M = list(map(int,input().split()))

MOD = 1000000007

b = [0]*(N+2)
b[0] = 1

for i in range(M):
    b[int(input())] = -1

for i in range(N):
    if b[i] != -1:
        if b[i+1] != -1:
            b[i+1] += b[i]
        if b[i+2] != -1:
            b[i+2] += b[i]
        b[i] %= MOD

print(b[N]%MOD)

Measured memory_bytes: 7028
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(n%2==1){
        cout << "No" << endl;
        return 0;
    }
    bool flag = 0;
    rep(i,n){
        if(i%2==0){
            if(s[i]!='h')flag = 1;
        }
        if(i%2==1){
            if(s[i]!='i')flag = 1;
        }
    }
    if(flag){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl; 
    }
    return 0;
}

Measured memory_bytes: 888